throttle wiggling
authoralfadur
Sun, 21 Jun 2020 02:04:20 +0300
changeset 15621 969f67193d0b
parent 15620 106d7162caea
child 15622 237d691e5069
throttle wiggling
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsHandlersMess.pas	Fri Jun 05 21:58:17 2020 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Jun 21 02:04:20 2020 +0300
@@ -1869,6 +1869,7 @@
         begin
         Gear^.dX := SignAs(AngleSin(HHGear^.Angle) * _0_5, Gear^.dX);
         Gear^.dY := AngleCos(HHGear^.Angle) * ( - _0_5);
+
         BTPrevAngle := HHGear^.Angle;
         dig := true
         end;
@@ -1935,6 +1936,17 @@
         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
@@ -1965,6 +1977,14 @@
     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 05 21:58:17 2020 +0300
+++ b/hedgewars/uGearsRender.pas	Sun Jun 21 02:04:20 2020 +0300
@@ -662,8 +662,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 +674,8 @@
                             begin
                             DrawTextureF(curhat,
                                 1,
-                                sx,
-                                sy - 5,
+                                ox + 1,
+                                oy - 8,
                                 0,
                                 sign,
                                 32,
@@ -688,8 +689,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 +698,8 @@
                                 untint
                                 end
                             end;
-                    defaultPos:= false
+                    defaultPos:= false;
+                    sign:= hwSign(Gear^.dX);
                     end;
                 gtFirePunch:
                     begin