You would get better results if you figured it out for yourself...
Anyway:
- Code:
procedure OnTick;
var
i, iPlayer: Integer;
iUnits: array of Integer;
begin
iPlayer := States.GameTime mod States.LocationCount;
if States.PlayerEnabled(iPlayer) then begin
iUnits := States.PlayerGetAllUnits(iPlayer);
for i := 0 to Length(iUnits)-1 do
if (States.UnitHome(iUnits[i]) > 0) then
if (States.HouseType(States.UnitHome(iUnits[i])) = 18) then
Actions.UnitHungerSet(iUnits[i], States.UnitMaxHunger);
end;
end;
"iPlayer := States.GameTime mod States.LocationCount;" defines which player are we doing this for; using this formula allows us to spread the load over time, thus resulting in a slightly smoother script; if you wanted to you could also add a delay, since it's not necessary to feed units this often (OnTick = 10 times per second).
"States.PlayerEnabled(iPlayer)" checks that that player is actually being played.
"States.PlayerGetAllUnits(iPlayer)" finds and writes down the IDs of all the units owned by iPlayer (the names by which the program calls each unit);
"(States.UnitHome(iUnits
) > 0) " checks that the unit "iUnits" does have an home (Recruits could also have no home);
"(States.HouseType(States.UnitHome(iUnits)) = 18) " checks that said home is a Tower (Recruits could also live in the Barracks);
And finally "Actions.UnitHungerSet" feeds the Recruit (no need to check that it actually is a Recruit, since only Recruits can live in the Tower).