allow deploying sentries on water
authoralfadur
Sat, 11 Jul 2020 17:35:36 +0300
changeset 15716 d5fce8a02092
parent 15715 e0cdb6ae88ab
child 15717 9060532c25f7
allow deploying sentries on water
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sat Jul 11 02:12:02 2020 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Jul 11 17:35:36 2020 +0300
@@ -7471,10 +7471,36 @@
     end
 end;
 
+procedure doStepSentryWater(Gear: PGear);
+begin
+    if Gear^.Tag < 0 then
+    begin
+        CheckGearDrowning(Gear);
+        exit;
+    end;
+
+    Gear^.Y := int2hwFloat(cWaterLine - 3 * Gear^.Radius);
+    if TestCollisionYwithGear(Gear, -1) <> 0 then
+    begin
+        Gear^.Tag := -1;
+        exit;
+    end;
+end;
+
 procedure doStepSentryDeploy(Gear: PGear);
 begin
     Gear^.Tag := -1;
-    if Gear^.dY.isNegative or (TestCollisionYwithGear(Gear, 1) = 0) then
+    if hwRound(Gear^.Y) + 3 * Gear^.Radius >= cWaterLine then
+    begin
+        Gear^.Y := int2hwFloat(cWaterLine - 3 * Gear^.Radius);
+        if Gear^.Timer > 0 then dec(Gear^.Timer);
+        if Gear^.Timer = 0 then
+        begin
+            Gear^.Tag := 0;
+            Gear^.doStep := @doStepSentryWater;
+        end;
+    end
+    else if Gear^.dY.isNegative or (TestCollisionYwithGear(Gear, 1) = 0) then
         doStepFallingGear(Gear)
     else
     begin