experimental blowtorching
authoralfadur
Fri, 05 Jun 2020 21:58:17 +0300
changeset 15618 106d7162caea
parent 15617 b988d3be7100
child 15643 969f67193d0b
experimental blowtorching
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Fri Jun 05 21:21:48 2020 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Jun 05 21:58:17 2020 +0300
@@ -1842,7 +1842,7 @@
 procedure doStepBlowTorchWork(Gear: PGear);
 var
     HHGear: PGear;
-    dig: boolean;
+    dig, hit: boolean;
     prevX: LongInt;
 begin
     AllInactive := false;
@@ -1851,6 +1851,7 @@
 
     if Gear^.Hedgehog^.Gear = nil then
         begin
+        ClearProximityCache();
         StopSoundChan(Gear^.SoundChannel);
         DeleteGear(Gear);
         AfterAttack;
@@ -1862,6 +1863,7 @@
     HedgehogChAngle(HHGear);
 
     dig := false;
+    hit := false;
 
     if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7  then
         begin
@@ -1878,6 +1880,9 @@
             Gear^.Timer := 0
         end;
 
+    if Gear^.Timer mod 1500 = 0 then
+        RefillProximityCache(Gear, 200);
+
     if Gear^.Timer mod cHHStepTicks = 0 then
         begin
         dig := true;
@@ -1902,7 +1907,7 @@
             end;
 
         inc(BTSteps);
-        if BTSteps = 7 then
+        if BTSteps = 11 then
             begin
             BTSteps := 0;
             if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6,Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)),lfIndestructible) then
@@ -1910,24 +1915,30 @@
                 Gear^.X := HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC);
                 Gear^.Y := HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC);
                 end;
-            HHGear^.State := HHGear^.State or gstNoDamage;
-            AmmoShove(Gear, Gear^.Boom, 15);
-            HHGear^.State := HHGear^.State and (not gstNoDamage)
+            hit := true
             end;
         end;
 
     if dig then
         begin
         DrawTunnel(HHGear^.X + Gear^.dX * cHHRadius,
-        HHGear^.Y + Gear^.dY * cHHRadius - _1 -
-        ((hwAbs(Gear^.dX) / (hwAbs(Gear^.dX) + hwAbs(Gear^.dY))) * _0_5 * 7),
-        Gear^.dX, Gear^.dY,
-        cHHStepTicks, cHHRadius * 2 + 7);
+            HHGear^.Y + Gear^.dY * cHHRadius - _1 -
+                ((hwAbs(Gear^.dX) / (hwAbs(Gear^.dX) + hwAbs(Gear^.dY))) * _0_5 * 7),
+            Gear^.dX, Gear^.dY,
+            cHHStepTicks, cHHRadius * 2 + 7);
+
+        HHGear^.State := HHGear^.State or gstNoDamage;
+        if hit then
+            AmmoShoveCache(Gear, Gear^.Boom, 15)
+        else
+            AmmoShoveCache(Gear, 0, 15);
+        HHGear^.State := HHGear^.State and (not gstNoDamage);
         end;
 
     if (TurnTimeLeft = 0) or (Gear^.Timer = 0)
     or ((HHGear^.Message and gmAttack) <> 0) then
         begin
+        ClearProximityCache();
         StopSoundChan(Gear^.SoundChannel);
         HHGear^.Message := 0;
         HHGear^.State := HHGear^.State and (not gstNotKickable);
@@ -1953,6 +1964,7 @@
         cHHStepTicks, cHHRadius * 2 + 7);
     HHGear^.Message := 0;
     HHGear^.State := HHGear^.State or gstNotKickable;
+    RefillProximityCache(Gear, 200);
     Gear^.SoundChannel := LoopSound(sndBlowTorch);
     Gear^.doStep := @doStepBlowTorchWork
 end;