Page 1 of 1

My problems with dynamic scripts

PostPosted: 21 Mar 2018, 16:22
by memerion2
Hi! I have problem with this script:
If (States.UnitPositionX(k) = 123) and (States.UnitPositionY(k) = 53) then
Actions.UnitKill((k),true);
Brama3;

I want to: if unit "k" is at this coordinates (123,53) then do procedure Brama3 and kill unit"k"

I don't know what is wrong with this script.

Re: My problems with dynamic scripts

PostPosted: 21 Mar 2018, 18:23
by Esthlos
memerion2 wrote:I don't know what is wrong with this script.

You need to group them in a begin...end block, or else the program won't know that they are together.

  Code:
If (States.UnitPositionX(k) = 123) and (States.UnitPositionY(k) = 53) then begin
  Actions.UnitKill((k),true);
  Brama3;
end;

Re: My problems with dynamic scripts

PostPosted: 22 Mar 2018, 06:10
by memerion2
Thanks for help:)

Now I want to do:You need 300 gold
And in msg write how much missing to 300 gold.

it will be better if you explain it to me.

Re: My problems with dynamic scripts

PostPosted: 22 Mar 2018, 07:45
by Esthlos
memerion2 wrote:Thanks for help:)

Now I want to do:You need 300 gold
And in msg write how much missing to 300 gold.

it will be better if you explain it to me.


procedure OnTick;
var
  iPlayer: Byte;
  iGoldMissing, i: Integer;
  aHouses: array of Integer;
begin
  iPlayer := 0; //What player is this for; it's always 1 less than the in-game number (example: "0" here is player 1)

//Get the Gold count
  aHouses := States.PlayerGetAllHouses(iPlayer);
  iGoldMissing := 300; //300 is the target quantity

  for i := 0 to Length(aHouses)-1 do if States.HouseType(aHouses[i]) = 11 then //Storehouses only
    iGoldMissing := iGoldMissing-States.HouseResourceAmount(aHouses[i], 7);

//Make sure that it doesn't go negative when the player has more than the target quantity
  if iGoldMissing < 0 then iGoldMissing := 0;

//Let's now add the text; use OverlayTextAppendFormatted if you're adding a new line instead of refreshing the whole text
  Actions.OverlayTextSetFormatted(iPlayer, '%s : %s Gold missing', [States.PlayerName(iPlayer), IntToStr(iGoldMissing)]);
end;

Re: My problems with dynamic scripts

PostPosted: 22 Mar 2018, 13:48
by memerion2
What syntax you use in Notepad++

Re: My problems with dynamic scripts

PostPosted: 22 Mar 2018, 14:11
by Rey
I use Pascal, as its pascalscript.

Also @Strangelove's notepad++ plugin is quite usefull, check it out: http://knightsandmerchants.net/forum/vi ... =32&t=2722

Re: My problems with dynamic scripts

PostPosted: 23 Mar 2018, 12:58
by memerion2
How can I do this army missing?

eg. missing: 12 swordmans

Re: My problems with dynamic scripts

PostPosted: 29 Dec 2018, 20:22
by memerion2
Hello Again!

Can someone tell me how to do immortal unit?
I mean soldier "k" can't be killed by other soldier or tower.

Re: My problems with dynamic scripts

PostPosted: 30 Dec 2018, 04:05
by cmowla
memerion2 wrote:Hello Again!

Can someone tell me how to do immortal unit?
I mean soldier "k" can't be killed by other soldier or tower.
Maybe see this thread?

Re: My problems with dynamic scripts

PostPosted: 21 Feb 2019, 14:20
by memerion2
Can I change unit speed by scripts?
To make unit slower than normal.