Fix seduction not stopping if hog took damage before attack was complete
authorWuzzy <Wuzzy2@mail.ru>
Fri, 26 Oct 2018 22:46:37 +0200
changeset 13999 996ef4c5d064
parent 13998 ae11b53987db
child 14000 52e20f8f538a
Fix seduction not stopping if hog took damage before attack was complete
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
--- a/ChangeLog.txt	Fri Oct 26 23:04:46 2018 +0300
+++ b/ChangeLog.txt	Fri Oct 26 22:46:37 2018 +0200
@@ -32,6 +32,7 @@
  * Fix projectiles behaving incorrectly with land just behind the wrap world edge
  * Fix bee weapon becoming unusable when hitting attack key in mid-air
  * Fix hog sometimes getting stuck in land if roping very fast
+ * Fix seduction not stopping if hog took damage before attack was complete
  * Limit hedgehog health to 268435455 to prevent some bugs
 
 Game, controls and commands:
--- a/hedgewars/uGearsHandlersMess.pas	Fri Oct 26 23:04:46 2018 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Oct 26 22:46:37 2018 +0200
@@ -3738,8 +3738,19 @@
 procedure doStepSeductionWork(Gear: PGear);
 var i: LongInt;
     hogs: PGearArrayS;
+    HHGear: PGear;
 begin
     AllInactive := false;
+
+    HHGear := Gear^.Hedgehog^.Gear;
+    if (HHGear <> nil) and ((HHGear^.State and gstHHDriven) = 0) then
+        begin
+        StopSound(sndYoohoo);
+        AfterAttack;
+        DeleteGear(Gear);
+        exit;
+        end;
+
     hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
     if hogs.size > 0 then
         begin
@@ -3759,8 +3770,9 @@
                 else if Hedgehog^.Effects[heFrozen] > 255 then
                     Hedgehog^.Effects[heFrozen]:= 255
         end ;
-        AfterAttack;
-        DeleteGear(Gear);
+    AfterAttack;
+    DeleteGear(Gear);
+
 (*
     Gear^.X := Gear^.X + Gear^.dX;
     Gear^.Y := Gear^.Y + Gear^.dY;
@@ -3788,8 +3800,19 @@
 
 procedure doStepSeductionWear(Gear: PGear);
 var heart: PVisualGear;
+    HHGear: PGear;
 begin
     AllInactive := false;
+
+    HHGear := Gear^.Hedgehog^.Gear;
+    if (HHGear <> nil) and ((HHGear^.State and gstHHDriven) = 0) then
+        begin
+        StopSound(sndYoohoo);
+        AfterAttack;
+        DeleteGear(Gear);
+        exit;
+        end;
+
     inc(Gear^.Timer);
     if Gear^.Timer > 250 then
         begin