add sentry deployment step
authoralfadur
Sat, 11 Jul 2020 02:12:02 +0300
changeset 15737 e0cdb6ae88ab
parent 15736 7a4b719ac611
child 15738 d5fce8a02092
add sentry deployment step
hedgewars/uGears.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
hedgewars/uGearsRender.pas
--- a/hedgewars/uGears.pas	Sat Jul 11 01:09:56 2020 +0300
+++ b/hedgewars/uGears.pas	Sat Jul 11 02:12:02 2020 +0300
@@ -814,7 +814,7 @@
     end;
 
     for i := 0 to min(count, positionsCount) - 1 do
-        AddGear(positions[i].X, positions[i].Y - cHHRadius, gtSentry, 0, _0, _0, 5000);
+        AddGear(positions[i].X, positions[i].Y - cHHRadius, gtSentry, 0, _0, _0, 0);
 end;
 
 procedure AddMiscGears;
@@ -1520,7 +1520,7 @@
             @doStepCreeper,
             @doStepMinigun,
             @doStepMinigunBullet,
-            @doStepSentry);
+            @doStepSentryDeploy);
 begin
     doStepHandlers:= handlers;
 
--- a/hedgewars/uGearsHandlersMess.pas	Sat Jul 11 01:09:56 2020 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Jul 11 02:12:02 2020 +0300
@@ -141,7 +141,7 @@
 procedure doStepMinigunWork(Gear: PGear);
 procedure doStepMinigun(Gear: PGear);
 procedure doStepMinigunBullet(Gear: PGear);
-procedure doStepSentry(Gear: PGear);
+procedure doStepSentryDeploy(Gear: PGear);
 
 var
     upd: Longword;
@@ -7286,7 +7286,7 @@
     end;
 end;
 
-procedure doStepSentry(Gear: PGear);
+procedure doStepSentryLand(Gear: PGear);
 var HHGear, bullet: PGear;
     distX, distY, invDistance: HwFloat;
 const sentry_Idle = 0;
@@ -7471,4 +7471,20 @@
     end
 end;
 
+procedure doStepSentryDeploy(Gear: PGear);
+begin
+    Gear^.Tag := -1;
+    if Gear^.dY.isNegative or (TestCollisionYwithGear(Gear, 1) = 0) then
+        doStepFallingGear(Gear)
+    else
+    begin
+        if Gear^.Timer > 0 then dec(Gear^.Timer);
+        if Gear^.Timer = 0 then
+        begin
+            Gear^.Tag := 0;
+            Gear^.doStep := @doStepSentryLand;
+        end;
+    end;
+end;
+
 end.
--- a/hedgewars/uGearsList.pas	Sat Jul 11 01:09:56 2020 +0300
+++ b/hedgewars/uGearsList.pas	Sat Jul 11 02:12:02 2020 +0300
@@ -842,7 +842,7 @@
                 gear^.Friction:= _0_93;
                 gear^.Elasticity:= _0_05;
                 gear^.Tag:= 0;
-                gear^.Timer:= 500;
+                gear^.Timer:= 1000;
                 gear^.WDTimer:= 0;
                 end;
 gtGenericFaller:begin
--- a/hedgewars/uGearsRender.pas	Sat Jul 11 01:09:56 2020 +0300
+++ b/hedgewars/uGearsRender.pas	Sat Jul 11 02:12:02 2020 +0300
@@ -1745,7 +1745,8 @@
                     else DrawSpriteRotatedF(sprCreeper, x, y, 1, hwRound(SignAs(_1,Gear^.dX)), 0);
             gtSentry: begin
                 DrawSpriteRotated(sprSentry, x, y, hwSign(Gear^.dX), 0);
-                DrawCircle(x, y, Gear^.Radius, 1, 255, 0, 0, 255);
+                if Gear^.Tag >= 0 then
+                    DrawCircle(x, y, Gear^.Radius, 1, 255, 0, 0, 255);
             end;
             gtGenericFaller: begin
                              // DEBUG: draw gtGenericFaller