merge blowtorch draft
authoralfadur
Sun, 21 Jun 2020 03:08:21 +0300
changeset 15623 6c689729b745
parent 15622 237d691e5069 (diff)
parent 15619 92ce801d0681 (current diff)
child 15624 adbd2bcf7159
merge blowtorch draft
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Fri Jun 12 02:53:01 2020 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Jun 21 03:08:21 2020 +0300
@@ -1849,7 +1849,7 @@
 procedure doStepBlowTorchWork(Gear: PGear);
 var
     HHGear: PGear;
-    dig: boolean;
+    dig, hit: boolean;
     prevX: LongInt;
 begin
     AllInactive := false;
@@ -1858,6 +1858,7 @@
 
     if Gear^.Hedgehog^.Gear = nil then
         begin
+        ClearProximityCache();
         StopSoundChan(Gear^.SoundChannel);
         DeleteGear(Gear);
         AfterAttack;
@@ -1869,11 +1870,13 @@
     HedgehogChAngle(HHGear);
 
     dig := false;
+    hit := false;
 
     if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7  then
         begin
         Gear^.dX := SignAs(AngleSin(HHGear^.Angle) * _0_5, Gear^.dX);
         Gear^.dY := AngleCos(HHGear^.Angle) * ( - _0_5);
+
         BTPrevAngle := HHGear^.Angle;
         dig := true
         end;
@@ -1885,6 +1888,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;
@@ -1909,7 +1915,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
@@ -1917,24 +1923,41 @@
                 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);
-        end;
+            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 HHGear^.dX.isNegative <> (Gear^.Tag = -1) then
+    begin
+        inc(Gear^.WDTimer);
+        if Gear^.WDTimer > 150 then
+        begin
+            Gear^.WDTimer := 0;
+            Gear^.Tag := - Gear^.Tag;
+        end
+    end else
+        Gear^.WDTimer := 0;
 
     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);
@@ -1960,6 +1983,15 @@
         cHHStepTicks, cHHRadius * 2 + 7);
     HHGear^.Message := 0;
     HHGear^.State := HHGear^.State or gstNotKickable;
+    RefillProximityCache(Gear, 200);
+
+    //Throttle counter for direction changes
+    Gear^.WDTimer := 0;
+    if HHGear^.dX.isNegative then
+        Gear^.Tag := -1
+    else
+        Gear^.Tag := 1;
+
     Gear^.SoundChannel := LoopSound(sndBlowTorch);
     Gear^.doStep := @doStepBlowTorchWork
 end;
--- a/hedgewars/uGearsRender.pas	Fri Jun 12 02:53:01 2020 +0200
+++ b/hedgewars/uGearsRender.pas	Sun Jun 21 03:08:21 2020 +0300
@@ -416,6 +416,8 @@
         hogLR:= -1
     else
         hogLR:= 1;
+    if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtBlowTorch) then
+        hogLR:= CurAmmoGear^.Tag;
 
     if (Gear^.State and gstHHDeath) <> 0 then
         begin
@@ -662,8 +664,9 @@
                     end;
                 gtBlowTorch:
                     begin
-                    DrawSpriteRotated(sprBlowTorch, hx, hy, sign, aangle);
-                    DrawHedgehog(sx, sy,
+                    sign:= CurAmmoGear^.Tag;
+                    DrawSpriteRotated(sprBlowTorch, ox + 8 * sign, oy - 2, sign, aangle);
+                    DrawHedgehog(ox + 1, oy - 3,
                             sign,
                             3,
                             HH^.visStepPos div 2,
@@ -673,8 +676,8 @@
                             begin
                             DrawTextureF(curhat,
                                 1,
-                                sx,
-                                sy - 5,
+                                ox + 1,
+                                oy - 8,
                                 0,
                                 sign,
                                 32,
@@ -688,8 +691,8 @@
                                 Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
                                 DrawTextureF(curhat,
                                     1,
-                                    sx,
-                                    sy - 5,
+                                    ox + 1,
+                                    oy - 8,
                                     tx,
                                     sign,
                                     32,
@@ -697,7 +700,8 @@
                                 untint
                                 end
                             end;
-                    defaultPos:= false
+                    defaultPos:= false;
+                    sign:= hwSign(Gear^.dX);
                     end;
                 gtFirePunch:
                     begin