Map Database  •  FAQ  •  RSS  •  Register  •  Login

My problems with dynamic scripts

<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 21 Mar 2018, 16:22

My problems with dynamic scripts

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.
<<

Esthlos

User avatar

Knight

Posts: 672

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 21 Mar 2018, 18:23

Re: My problems with dynamic scripts

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;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 22 Mar 2018, 06:10

Re: My problems with dynamic scripts

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.
<<

Esthlos

User avatar

Knight

Posts: 672

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 22 Mar 2018, 07:45

Re: My problems with dynamic scripts

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;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 22 Mar 2018, 13:48

Re: My problems with dynamic scripts

What syntax you use in Notepad++
<<

Rey

User avatar

KaM Remake Developer

Posts: 206

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Fair

Post 22 Mar 2018, 14:11

Re: My problems with dynamic scripts

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
Last edited by Rey on 23 Mar 2018, 19:57, edited 1 time in total.
<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 23 Mar 2018, 12:58

Re: My problems with dynamic scripts

How can I do this army missing?

eg. missing: 12 swordmans
<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 29 Dec 2018, 20:22

Re: My problems with dynamic scripts

Hello Again!

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

cmowla

User avatar

Knight

Posts: 403

Joined: 04 Aug 2013, 19:59

Location: United States

KaM Skill Level: Expert

Post 30 Dec 2018, 04:05

Re: My problems with dynamic scripts

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?
Invasion and Lava Valley with 0 losses|Invasion (without saves)|TSK 20 in 4.47 minutes|Northern Islands I Co-op in 1.71 hours
What makes me an Expert isn't my skill in of itself but my desire to win big.
<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 21 Feb 2019, 14:20

Re: My problems with dynamic scripts

Can I change unit speed by scripts?
To make unit slower than normal.

Return to Dynamic Scripting

Who is online

Users browsing this forum: No registered users and 2 guests