add collision to land sentries
authoralfadur
Sun, 12 Jul 2020 01:27:27 +0300
changeset 15722 498c1482dec2
parent 15721 1244c64b8e28
child 15723 4e65fd69f58c
add collision to land sentries
hedgewars/uCollisions.pas
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uCollisions.pas	Sun Jul 12 01:08:42 2020 +0300
+++ b/hedgewars/uCollisions.pas	Sun Jul 12 01:27:27 2020 +0300
@@ -671,7 +671,7 @@
             if (Gear <> info.cGear)
                 and ((centerX > info.X) xor (Dir > 0))
                 and ((info.cGear^.State and gstNotKickable) = 0)
-                and ((info.cGear^.Kind in [gtHedgehog, gtMine, gtKnife])
+                and ((info.cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtSentry])
                     or (info.cGear^.Kind = gtExplosives) and ((info.cGear^.State and gsttmpflag) <> 0)) // only apply X kick if the barrel is knocked over
                 and (sqr(centerX - info.X) + sqr(centerY - info.Y) <= sqr(info.Radius + Gear^.Radius + 2)) then
             begin
@@ -718,7 +718,7 @@
             if (Gear <> info.cGear)
                 and ((centerY + Gear^.Radius > info.Y) xor (Dir > 0))
                 and (info.cGear^.State and gstNotKickable = 0)
-                and (info.cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives])
+                and (info.cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives, gtSentry])
                 and (sqr(centerX - info.X) + sqr(centerY - info.Y) <= sqr(info.Radius + Gear^.Radius + 2)) then
             begin
                 with info.cGear^ do
--- a/hedgewars/uGearsHandlersMess.pas	Sun Jul 12 01:08:42 2020 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Jul 12 01:27:27 2020 +0300
@@ -7388,16 +7388,20 @@
 
     if Gear^.dY.isNegative or (TestCollisionYwithGear(Gear, 1) = 0) then
     begin
+        DeleteCI(Gear);
         doStepFallingGear(Gear);
         if not (Gear^.Tag in [sentry_Idle, sentry_Reloading]) then
             ResetSentryState(Gear, sentry_Idle, 1000);
         exit;
-    end;
+    end
+    else
+        AddCI(Gear);
 
     if Gear^.Timer > 0 then dec(Gear^.Timer);
 
     if Gear^.Timer = 0 then
     begin
+        DeleteCI(Gear);
         if Gear^.Tag = sentry_Idle then
         begin
             Gear^.Tag := sentry_Walking;
@@ -7474,12 +7478,15 @@
                 Gear^.Timer := 100;
             end
         end;
+        AddCI(Gear);
     end;
 
     if (Gear^.Tag = sentry_Walking) and ((GameTicks and $1F) = 0) then
     begin
+        DeleteCI(Gear);
         if not MakeSentryStep(Gear, 6, false) then
-            Gear^.Timer := 0
+            Gear^.Timer := 0;
+        AddCI(Gear);
     end;
 
     if ((GameTicks and $1F) = 0) and (Gear^.Tag = sentry_Aiming) then