Map Database  •  FAQ  •  RSS  •  Login

Help!

<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 11 Feb 2014, 19:33

Re: Help!

A new problem/question: when I use a script command like GroupOrderAttackHouse on OnTick and I delay it so that it only gets triggered every (for example) 10 seconds, the soldiers already attacking that building stop and continue, stop and continue, stop and continue, etc. It looks quite odd. Is there any workaround to avoid this?
This is what one of the attack looks like now:
  Code:
if (States.HouseDestroyed(SwineFarm) = true) and ((States.GameTime mod 50) = 0) then begin Actions.GroupOrderAttackHouse(Pike1, States.ClosestHouse(1, 69, 38)); end;
So they first destroy the swine farm, then every 5 seconds they select the closest building from 69, 38 and attack it. But there is no way to check if a unit/group is fighting or if a house is under attack, so I don't know how to stop them from starting the attack again and again and again while already attacking it... Or could OnHouseDamaged be of any help?
Best solution for me of course would be if soldiers would 'know' that they are already attacking the closest building and would stop with this despicable behaviour! :P
<<

Nissarin

User avatar

Pikeman

Posts: 185

Joined: 26 Sep 2012, 18:11

KaM Skill Level: Average

Location: Poland

Post 11 Feb 2014, 21:12

Re: Help!

You could do something like this:
- create mapping (2 dimensional array/array of records containing 2 ints) of group-buildings and building-group relationships (for convenience, in practice just one would be enough)
- in the procedure responsible for "giving an order" to attack check the group in the mappings, if it's present omit that group
- after you give order to attack a building record it in both arrays
- if building is destroyed (OnHouseDestroyed) - remove group from arrays

Other way (far more complicated imho) - check building surroundings for any enemy units..

Anyway I can write some example later if you want.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 12 Feb 2014, 04:11

Re: Help!

It looks like the problem is with the fact you keep on checking for SwineFarm every time and every time it's returning True. So maybe you can replace that with
  Code:
if (States.HouseDestroyed(CurrentAim) = true) and ((States.GameTime mod 50) = 0) then begin CurrentAim := States.ClosestHouse(1, 69, 38); //Change aim to a new house Actions.GroupOrderAttackHouse(Pike1, CurrentAim); end;
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 14 Feb 2014, 11:25

Re: Help!

Thanks! I think that's what I need. I'll try it when I have time. :)

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 4 guests