Need a script for the map
show on script overlay amount of killed soldier for each player
show on script overlay time limit 4h that if runned out the winner will be the player with most kills
var TheEndBye: Boolean;
var aMaxTimeOut: Integer;
var aCurrTimeOut: Integer;
var aBest: array of Integer;
var aPreviousS: Integer;
var s: Integer;
var m: Integer;
var h: Integer;
procedure OnMissionStart;
begin
TheEndBye := False;
aMaxTimeOut := 72000 //Timer, in seconds times 10, at the moment it is 2 hours
end;
procedure OnTick;
var i: Integer;
var u: Integer;
var t: Integer;
var aCurrID: Integer;
begin
if TheEndBye = False then begin //Probably unneeded, but let's make sure that it will work.
//Set overlay texts
Actions.OverlayTextSet(-1, '');
for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
Actions.OverlayTextAppendFormatted(-1, '%s: '+IntToStr(t)+'|', [States.PlayerName(i)]);
end;
//Check time
aCurrTimeOut := aMaxTimeOut-States.Gametime;
if States.Gametime mod 10 = 0 then begin //No sense doing this more than once per second
t := (aCurrTimeOut-(aCurrTimeOut mod 10))/10;
s := t mod 60; //seconds
m := ((t-s)/60) mod 60; //minutes
h := (((t-s)/60)-m)/60; //hours
end;
Actions.OverlayTextAppend(-1, IntToStr(h)+':'+IntToStr(m)+':'+IntToStr(s)+'|');
//Winning conditions
if aCurrTimeOut <= 0 then TheEndBye := True; //Time's out
end;
//Win commands
if TheEndBye = True then begin
//Check which is the highest score
aPreviousS := 0;
for i := 0 to States.LocationCount-1 do begin
if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
if t >= aPreviousS then begin
aPreviousS := t;
aCurrID := i;
end;
end;
end;
//Chack which players reached the highest score
aBest := [aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID]; //Static arrays never worked for me :( ; every value is defaulted to a player that we already know is going to be among the winners
aCurrID := 0;
for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
if t = aPreviousS then begin
aBest[aCurrID] := i;
aCurrID := aCurrID+1;
end;
end;
Actions.PlayerWin(aBest, True);
end;
end;
(4 hours is a lot... this script is set for 2 hours, you can edit this by changing aMaxTimeOut in OnMissionStart)
- Code:
var TheEndBye: Boolean; var aMaxTimeOut: Integer; var aCurrTimeOut: Integer; var aBest: array of Integer; var aPreviousS: Integer; var s: Integer; var m: Integer; var h: Integer; procedure OnMissionStart; begin TheEndBye := False; aMaxTimeOut := 72000 //Timer, in seconds times 10, at the moment it is 2 hours end; procedure OnTick; var i: Integer; var u: Integer; var t: Integer; var aCurrID: Integer; begin if TheEndBye = False then begin //Probably unneeded, but let's make sure that it will work. //Set overlay texts Actions.OverlayTextSet(-1, ''); for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin t := 0; for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u); Actions.OverlayTextAppendFormatted(-1, '%s: '+IntToStr(t)+'|', [States.PlayerName(i)]); end; //Check time aCurrTimeOut := aMaxTimeOut-States.Gametime; if States.Gametime mod 10 = 0 then begin //No sense doing this more than once per second t := (aCurrTimeOut-(aCurrTimeOut mod 10))/10; s := t mod 60; //seconds m := ((t-s)/60) mod 60; //minutes h := (((t-s)/60)-m)/60; //hours end; Actions.OverlayTextAppend(-1, IntToStr(h)+':'+IntToStr(m)+':'+IntToStr(s)+'|'); //Winning conditions if aCurrTimeOut <= 0 then TheEndBye := True; //Time's out end; //Win commands if TheEndBye = True then begin //Check which is the highest score aPreviousS := 0; for i := 0 to States.LocationCount-1 do begin if States.PlayerEnabled(i) = True then begin t := 0; for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u); if t >= aPreviousS then begin aPreviousS := t; aCurrID := i; end; end; end; //Chack which players reached the highest score aBest := [aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID, aCurrID]; //Static arrays never worked for me :( ; every value is defaulted to a player that we already know is going to be among the winners aCurrID := 0; for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin t := 0; for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u); if t = aPreviousS then begin aBest[aCurrID] := i; aCurrID := aCurrID+1; end; end; Actions.PlayerWin(aBest, True); end; end;
var TheEndBye: Boolean;
var aMaxTimeOut: Integer;
var aCurrTimeOut: Integer;
var aBest: array of Integer;
var aPreviousS: Integer;
var s: Integer;
var m: Integer;
var h: Integer;
procedure OnMissionStart;
begin
TheEndBye := False;
aMaxTimeOut := 72000 //Timer, in seconds times 10, at the moment it is 2 hours
end;
procedure OnTick;
var i: Integer;
var u: Integer;
var t: Integer;
begin
if TheEndBye = False then begin //Probably unneeded, but let's make sure that it will work.
//Set overlay texts
Actions.OverlayTextSet(-1, '');
for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
Actions.OverlayTextAppendFormatted(-1, '%s: '+IntToStr(t)+'|', [States.PlayerName(i)]);
end;
//Check time
aCurrTimeOut := aMaxTimeOut-States.Gametime;
if States.Gametime mod 10 = 0 then begin //No sense doing this more than once per second
t := (aCurrTimeOut-(aCurrTimeOut mod 10))/10;
s := t mod 60; //seconds
m := ((t-s)/60) mod 60; //minutes
h := (((t-s)/60)-m)/60; //hours
end;
Actions.OverlayTextAppend(-1, IntToStr(h)+':'+IntToStr(m)+':'+IntToStr(s)+'|');
//Winning conditions
if aCurrTimeOut <= 0 then TheEndBye := True; //Time's out
end;
//Win commands
if TheEndBye = True then begin
//Check which is the highest score
aPreviousS := 0;
for i := 0 to States.LocationCount-1 do begin
if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
if t >= aPreviousS then begin
aPreviousS := t;
end;
end;
end;
//Check which players reached the highest score
SetLength(aBest, 0)
for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
if t = aPreviousS then begin
SetLength(aBest, Length(aBest)+1)
aBest[Length(aBest)-1] := i;
end;
end;
Actions.PlayerWin(aBest, True);
end;
end;
Can't get UnitAt to working i m doing something wrong?
begin
if States.UnitAt(124,145) < 14
then begin
Actions.MapTileSet(114,141,192,0);
var TheEndBye: Boolean;
var aMaxTimeOut: Integer;
var aCurrTimeOut: Integer;
var aBest: array of Integer;
var aPreviousS: Integer;
var s: Integer;
var m: Integer;
var h: Integer;
procedure OnMissionStart;
begin
TheEndBye := False;
aMaxTimeOut := 72000 //Timer, in seconds times 10, at the moment it is 2 hours
end;
procedure OnTick;
var i: Integer;
var u: Integer;
var t: Integer;
begin
if TheEndBye = False then begin //Probably unneeded, but let's make sure that it will work.
//Set overlay texts
Actions.OverlayTextSet(-1, '');
for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
Actions.OverlayTextAppendFormatted(-1, '%s: '+IntToStr(t)+'|', [States.PlayerName(i)]);
end;
//Check time
aCurrTimeOut := aMaxTimeOut-States.Gametime;
if States.Gametime mod 10 = 0 then begin //No sense doing this more than once per second
t := (aCurrTimeOut-(aCurrTimeOut mod 10))/10;
s := t mod 60; //seconds
m := ((t-s)/60) mod 60; //minutes
h := (((t-s)/60)-m)/60; //hours
end;
Actions.OverlayTextAppend(-1, IntToStr(h)+':'+IntToStr(m)+':'+IntToStr(s)+'|');
//Winning conditions
if aCurrTimeOut <= 0 then TheEndBye := True; //Time's out
end;
//Win commands
if TheEndBye = True then begin
//Check which is the highest score
aPreviousS := 0;
for i := 0 to States.LocationCount-1 do begin
if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
if t >= aPreviousS then begin
aPreviousS := t;
end;
end;
end;
//Check which players reached the highest score
SetLength(aBest, 0)
for i := 0 to States.LocationCount-1 do if States.PlayerEnabled(i) = True then begin
t := 0;
for u := 14 to 27 do t := t+States.StatUnitKilledCount(i, u);
if t = aPreviousS then begin
SetLength(aBest, Length(aBest)+1)
aBest[Length(aBest)-1] := i;
end;
end;
Actions.PlayerWin(aBest, True);
end;
if States.UnitAt(124,145) > -1 then begin //The game complains if asked the Unit Type of a non existing unit
if States.UnitType(States.UnitAt(124,145)) > 14 then begin
Actions.MapTileSet(114,141,192,0);
Actions.MapTileSet(115,141,192,0);
Actions.MapTileSet(116,141,192,0);
Actions.MapTileSet(117,141,192,0);
Actions.MapTileSet(118,141,192,0);
Actions.MapTileSet(114,142,192,0); //2nd line
Actions.MapTileSet(115,142,192,0);
Actions.MapTileSet(116,142,192,0);
Actions.MapTileSet(117,142,192,0);
Actions.MapTileSet(118,142,192,0);
end;
end;
end;
Users browsing this forum: No registered users and 2 guests
Powered by phpBB® Forum Software © phpBB Group Designed by ST Software |