Page 1 of 1

HELP WITH SCRIPT

PostPosted: 27 Sep 2015, 15:46
by BLUE
I've make a map, where i need the autofeed for all the units, because it's a battle map, but it can take more than 2 hours, so i need it. I tryed to take the script from other maps, but it doesn't work...if someone can help me, i'll be so grateful to him. :D

Re: HELP WITH SCRIPT

PostPosted: 27 Sep 2015, 23:21
by Esthlos
  Code:
const cDelay = 6000; //Every unit is fed in 6000 ticks (10 minutes; 1 tick is 0,1 seconds); set this too low and the script performance gets worse, set this too high and the script becomes useless var aPlayer, aTime, aActualDelay: Integer; procedure OnMissionStart; begin aActualDelay := cDelay div States.LocationCount; end; procedure OnTick; var iUnits: array of Integer; i: Integer; begin Inc(aTime); if aTime > aActualDelay then begin aTime := 0; Inc(aPlayer); if aPlayer >= States.LocationCount then aPlayer := 0; iUnits := States.GetAllUnits(aPlayer); for i := 0 to Length(iUnits)-1 do Actions.UnitHungerSet(iUnits[i], States.UnitMaxHunger); end; end;