Map Database  •  FAQ  •  RSS  •  Login

Need a script for the map

<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 03 Oct 2014, 10:49

Need a script for the map

So the script should do
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
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 03 Oct 2014, 16:34

Re: Need a script for the map

I think you could adapt the script of "Coastal Encounter Scored" to your needs.
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 03 Oct 2014, 19:16

Re: Need a script for the map

Thanks but i could need more clear code than then one in coastal
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 04 Oct 2014, 09:32

Re: Need a script for the map

(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;
You do not have the required permissions to view the files attached to this post.
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"
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 04 Oct 2014, 11:21

Re: Need a script for the map

(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;
Big thanks
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 04 Oct 2014, 12:09

Re: Need a script for the map

No problem.

Anyway, this one is better: :$ :wink: :P
  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; 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;
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"
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 04 Oct 2014, 12:57

Re: Need a script for the map

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

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 04 Oct 2014, 13:18

Re: Need a script for the map

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);
States.UnitAt returns the UnitID, not the Unit Type :P

The UnitID is the "name" that the game gives to each unit... I guess you're trying to detect if the unit at 124,145 is a civilian, am I right?
Try this:
  Code:
begin if States.UnitType(States.UnitAt(124,145)) < 14 then begin Actions.MapTileSet(114,141,192,0);
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"
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 04 Oct 2014, 13:28

Re: Need a script for the map

Still isn't working GroupAt

Let me describe what i want to achive:

I want to make if there is any type of unit on the specifed tile then do stuff
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 04 Oct 2014, 13:45

Re: Need a script for the map

Thank you for sending me the whole script. Let's see:

GroupAt returns a Group ID, not a Unit ID... it's the "name" of the troop, and since different unit types can be in the same troop, UnitType won't work with GroupAt.

Also, the game complains if UnitType is given an invalid UnitID... it will still work, just worse.

Lastly, you do not need to add a "begin": you only need it when opening a new "procedure", or when you want to have a series of commands "follow" the same line. :wink:

Oh, and the last "end" doesn't need a full stop... it should be "end;" even if it is the last one. :P

Try this:
  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; 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;
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"
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 04 Oct 2014, 15:35

Re: Need a script for the map

Rage sorry.
this now works thanks

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 5 guests