place sentries on start
authoralfadur
Sun, 28 Jun 2020 01:06:18 +0300
changeset 15645 fb1f47e382d0
parent 15644 3997d85b3d2e
child 15646 c2a1a34d1841
place sentries on start
hedgewars/uCommandHandlers.pas
hedgewars/uGears.pas
hedgewars/uVariables.pas
--- a/hedgewars/uCommandHandlers.pas	Sun Jun 28 00:47:43 2020 +0300
+++ b/hedgewars/uCommandHandlers.pas	Sun Jun 28 01:06:18 2020 +0300
@@ -856,6 +856,11 @@
 cAirMines:= StrToInt(s)
 end;
 
+procedure chSentries(var s: shortstring);
+begin
+cSentries:= StrToInt(s)
+end;
+        
 procedure chExplosives(var s: shortstring);
 begin
 cExplosives:= StrToInt(s)
@@ -980,6 +985,7 @@
     RegisterVariable('minedudpct',@chMineDudPercent, false);
     RegisterVariable('minesnum', @chLandMines     , false);
     RegisterVariable('airmines', @chAirMines      , false);
+    RegisterVariable('sentries', @chSentries      , false);
     RegisterVariable('explosives',@chExplosives    , false);
     RegisterVariable('gmflags' , @chGameFlags      , false);
     RegisterVariable('turntime', @chHedgehogTurnTime, false);
--- a/hedgewars/uGears.pas	Sun Jun 28 00:47:43 2020 +0300
+++ b/hedgewars/uGears.pas	Sun Jun 28 01:06:18 2020 +0300
@@ -863,6 +863,21 @@
         end;
 if p <> 0 then DeleteGear(Gear);
 
+i:= 0;
+unplaced:= 0;
+while (i < cSentries) and (unplaced < 4) do
+    begin
+        Gear:= AddGear(0, 0, gtSentry, 0, _0, _0, 0);
+        FindPlace(Gear, false, 0, LAND_WIDTH);
+
+        if Gear = nil then
+            inc(unplaced)
+        else
+            unplaced:= 0;
+
+        inc(i)
+    end;
+
 if (GameFlags and gfLowGravity) <> 0 then
     begin
     cGravity:= cMaxWindSpeed;
--- a/hedgewars/uVariables.pas	Sun Jun 28 00:47:43 2020 +0300
+++ b/hedgewars/uVariables.pas	Sun Jun 28 01:06:18 2020 +0300
@@ -177,6 +177,7 @@
 
     cLandMines      : Longword;
     cAirMines       : Longword;
+    cSentries       : Longword;
     cExplosives     : Longword;
 
     cScriptName     : shortstring;
@@ -2959,6 +2960,7 @@
     cMaxCaseDrops   := 5;
     cLandMines      := 4;
     cAirMines       := 0;
+    cSentries       := 0;
     cExplosives     := 2;
 
     GameState       := Low(TGameState);