Map Database  •  FAQ  •  RSS  •  Register  •  Login

HELP WITH SCRIPT

<<

BLUE

Peasant

Posts: 3

Joined: 21 May 2015, 18:31

KaM Skill Level: Veteran

Post 27 Sep 2015, 15:46

HELP WITH SCRIPT

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
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 27 Sep 2015, 23:21

Re: HELP WITH SCRIPT

  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;
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"

Return to Map Design

Who is online

Users browsing this forum: No registered users and 4 guests