Fix hammer not digging when hitting hog with 0 health
authorWuzzy <Wuzzy2@mail.ru>
Thu, 08 Oct 2020 12:33:14 +0200
changeset 15742 0b5aea8e5eab
parent 15741 8997e212be4c
child 15743 b74ce48abdea
Fix hammer not digging when hitting hog with 0 health
ChangeLog.txt
hedgewars/uGearsHandlersMess.pas
--- a/ChangeLog.txt	Thu Oct 08 11:12:22 2020 +0200
+++ b/ChangeLog.txt	Thu Oct 08 12:33:14 2020 +0200
@@ -21,6 +21,7 @@
  * Fix game hanging if computer hog has nothing to attack
  * Fix hog sometimes not falling after resurrection
  * Fix hog not returning from TimeBox when all land was destroyed
+ * Fix hammer not digging when hitting hog with 0 health
 
 Campaigns:
  + A Space Adventure: Spacetrip: Meteorite appears blown-up after victory
--- a/hedgewars/uGearsHandlersMess.pas	Thu Oct 08 11:12:22 2020 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Oct 08 12:33:14 2020 +0200
@@ -6087,22 +6087,20 @@
         if (tmp^.Kind = gtHedgehog) or (tmp^.Kind = gtMine) or (tmp^.Kind = gtExplosives) then
             begin
             dmg:= 0;
-            if (tmp^.Kind <> gtHedgehog) or (tmp^.Hedgehog^.Effects[heInvulnerable] = 0) then
+            if (tmp^.Kind <> gtHedgehog) or
+               ((tmp^.Hedgehog^.Effects[heInvulnerable] = 0) and ((tmp^.State and gstHHDeath) = 0)) then
                 begin
                 // base damage on remaining health
                 dmg:= (tmp^.Health - tmp^.Damage);
+                // always rounding down
+                dmg:= dmg div Gear^.Boom;
+
                 if dmg > 0 then
-                    begin
-                    // always rounding down
-                    dmg:= dmg div Gear^.Boom;
-
-                    if dmg > 0 then
-                        ApplyDamage(tmp, CurrentHedgehog, dmg, dsHammer);
-                    end;
-        tmp^.dY:= _0_03 * Gear^.Boom
+                    ApplyDamage(tmp, CurrentHedgehog, dmg, dsHammer);
+                tmp^.dY:= _0_03 * Gear^.Boom
                 end;
 
-            if (tmp^.Kind <> gtHedgehog) or (dmg > 0) or (tmp^.Health > tmp^.Damage) then
+            if ((tmp^.Kind = gtHedgehog) and ((tmp^.State and gstHHDeath) = 0)) or (tmp^.Health > tmp^.Damage) then
                 begin
                 tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0);
                 tmp2^.LinkedGear:= tmp;