Post 11 Jun 2017, 06:44 by Esthlos
You would get better results if you figured it out for yourself...
i, iPlayer: Integer;
iUnits: array of Integer;
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
"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).
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"