make kamikaze hit moving gears as well
authoralfadur
Sat, 27 Oct 2018 07:39:44 +0300
changeset 14007 cfbea054754c
parent 14006 105793e575d6
child 14008 967ed77d6aef
make kamikaze hit moving gears as well
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sat Oct 27 07:20:07 2018 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Oct 27 07:39:44 2018 +0300
@@ -3330,6 +3330,8 @@
     HHGear := Gear^.Hedgehog^.Gear;
     if HHGear = nil then
         begin
+        ClearHitOrder();
+        ClearProximityCache();
         DeleteGear(Gear);
         exit
         end;
@@ -3361,6 +3363,8 @@
         if CheckGearDrowning(HHGear) then
             begin
             AfterAttack;
+            ClearHitOrder();
+            ClearProximityCache();
             DeleteGear(Gear);
             exit;
             end;
@@ -3385,7 +3389,7 @@
                 Gear^.Pos := 2;
             end;
 
-        AmmoShove(Gear, Gear^.Boom, 40);
+        AmmoShoveCache(Gear, Gear^.Boom, 40);
 
         DrawTunnel(HHGear^.X - HHGear^.dX * 10,
                     HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2,
@@ -3397,6 +3401,10 @@
         upd := 0
         end;
 
+    inc(Gear^.Timer);
+    if (Gear^.Timer mod 100) = 0 then
+        RefillProximityCache(Gear, 300);
+
     if Gear^.Health < Gear^.Damage then
         begin
         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
@@ -3423,6 +3431,8 @@
         uStats.HedgehogSacrificed(Gear^.Hedgehog);
         AfterAttack;
         HHGear^.Message:= HHGear^.Message or gmDestroy;
+        ClearHitOrder();
+        ClearProximityCache();
         DeleteGear(Gear);
         end
     else
@@ -3440,6 +3450,8 @@
         begin
         Gear^.Pos := 1;
         PlaySoundV(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack);
+        ClearHitOrder();
+        RefillProximityCache(Gear, 300);
         Gear^.doStep := @doStepKamikazeWork
         end
 end;
--- a/hedgewars/uGearsUtils.pas	Sat Oct 27 07:20:07 2018 +0300
+++ b/hedgewars/uGearsUtils.pas	Sat Oct 27 07:39:44 2018 +0300
@@ -1321,7 +1321,8 @@
     begin
     dec(i);
     Gear:= t^.ar[i];
-    if (Ammo^.Kind in [gtDEagleShot, gtSniperRifleShot, gtMinigunBullet, gtFirePunch])
+    if (Ammo^.Kind in [gtDEagleShot, gtSniperRifleShot, gtMinigunBullet,
+                       gtFirePunch, gtKamikaze])
         and (((Ammo^.Data <> nil) and (PGear(Ammo^.Data) = Gear))
              or (not UpdateHitOrder(Gear, Ammo^.WDTimer))) then
         continue;
@@ -1347,7 +1348,7 @@
             gtExplosives: //,
             //gtStructure:
             begin
-            if (Ammo^.Kind = gtFirePunch) and (Gear^.Kind <> gtSMine) then
+            if (Ammo^.Kind in [gtFirePunch, gtKamikaze]) and (Gear^.Kind <> gtSMine) then
                 PlaySound(sndFirePunchHit);
 
             if Ammo^.Kind in [gtDEagleShot, gtSniperRifleShot, gtMinigunBullet] then