Page 2 of 2

Re: Help!

PostPosted: 11 Feb 2014, 19:33
by The Dark Lord
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

Re: Help!

PostPosted: 11 Feb 2014, 21:12
by Nissarin
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.

Re: Help!

PostPosted: 12 Feb 2014, 04:11
by Krom
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;

Re: Help!

PostPosted: 14 Feb 2014, 11:25
by The Dark Lord
Thanks! I think that's what I need. I'll try it when I have time. :)