fix trace when bullets skip on water
authoralfadur
Thu, 03 May 2018 14:44:17 -0400
changeset 13381 caed04706564
parent 13380 cd55c7f25e04
child 13383 354ceada9c40
fix trace when bullets skip on water
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsHandlersMess.pas	Fri May 04 15:08:59 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu May 03 14:44:17 2018 -0400
@@ -1322,6 +1322,22 @@
     end;
 end;
 
+procedure CheckBulletDrowningHelp(Bullet: PGear);
+var dX, dY: hwFloat;
+begin
+    dX := Bullet^.dX;
+    dY := Bullet^.dY;
+    CheckGearDrowning(Bullet);
+    if (dX <> Bullet^.dX) or (dY <> Bullet^.dY) then
+    begin
+        SpawnBulletTrail(Bullet, Bullet^.X, Bullet^.Y, Bullet^.FlightTime = 0);
+        Bullet^.Elasticity := Bullet^.X;
+        Bullet^.Friction := Bullet^.Y;
+        Inc(Bullet^.PortalCounter);
+        Bullet^.FlightTime:= 1;
+    end;
+end;
+
 procedure doStepBulletWork(Gear: PGear);
 var
     i, x, y, iInit: LongWord;
@@ -1378,7 +1394,7 @@
             dec(Gear^.Damage);
             Gear^.X := Gear^.X - Gear^.dX;
             Gear^.Y := Gear^.Y - Gear^.dY;
-            CheckGearDrowning(Gear);
+            CheckBulletDrowningHelp(Gear);
             break;
             end
         else if (not isDigging) then
@@ -1395,7 +1411,7 @@
             oY:= Gear^.Y;
             end;
 
-        CheckGearDrowning(Gear);
+        CheckBulletDrowningHelp(Gear);
         case Gear^.Kind of
             gtMinigunBullet: isDead:= isDigging or ((Gear^.State and gstDrowning) <> 0);
             gtDEagleShot, gtSniperRifleShot: isDead:= (Gear^.Damage >= Gear^.Health) or ((Gear^.State and gstDrowning) <> 0)
--- a/hedgewars/uGearsUtils.pas	Fri May 04 15:08:59 2018 +0200
+++ b/hedgewars/uGearsUtils.pas	Thu May 03 14:44:17 2018 -0400
@@ -1273,7 +1273,7 @@
     if (Gear^.State and gstNoDamage) = 0 then
         begin
 
-        if (Gear^.Kind <> gtMinigun) and
+        if (not (Gear^.Kind in [gtMinigun, gtPortal])) and
             ((Ammo^.Kind = gtDEagleShot)
                 or (Ammo^.Kind = gtSniperRifleShot)
                 or (Ammo^.Kind = gtMinigunBullet)) then