reduce digging damage frequency
authoralfadur
Sat, 16 Oct 2021 01:06:05 +0300
changeset 15819 c5198f55ee1c
parent 15818 0c21cdbc5207
child 15820 b6379a7ed674
reduce digging damage frequency
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Thu Sep 09 21:06:45 2021 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Oct 16 01:06:05 2021 +0300
@@ -1849,6 +1849,7 @@
 var
     HHGear: PGear;
     dig, hit: boolean;
+    newX, newY: hwFloat;
 begin
     AllInactive := false;
     WorldWrap(Gear);
@@ -1879,7 +1880,7 @@
         dig := true
         end;
 
-    if ((HHGear^.State and gstMoving) <> 0) then
+    if (HHGear^.State and gstMoving) <> 0 then
         begin
         doStepHedgehogMoving(HHGear);
         if (HHGear^.State and gstHHDriven) = 0 then
@@ -1897,25 +1898,28 @@
         else
             HHGear^.Message := (HHGear^.Message and (gmAttack or gmUp or gmDown)) or gmRight;
 
-        if ((HHGear^.State and gstMoving) = 0) then
+        if (HHGear^.State and gstMoving) = 0 then
             begin
             HHGear^.State := HHGear^.State and (not gstAttacking);
 
-            if CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y),lfIndestructible) then
+            if CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), lfIndestructible) then
                 HedgehogStep(HHGear);
 
             HHGear^.State := HHGear^.State or gstAttacking
             end;
 
+            newX := HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC);
+            newY := HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC);
+            if CheckLandValue(hwRound(newX + SignAs(_6, Gear^.dX)), hwRound(newY), lfIndestructible) then
+                begin
+                Gear^.X := newX;
+                Gear^.Y := newY;
+                end;
+
         inc(BTSteps);
-        if BTSteps = 11 then
+        if BTSteps = 15 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
-                begin
-                Gear^.X := HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC);
-                Gear^.Y := HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC);
-                end;
             hit := true
             end;
         end;