Inherit hedgehog from gear which caused damage, thus keeping track of which hog actually did the damage
authorunc0rr
Sun, 09 Jan 2011 21:37:45 +0300
changeset 4826 d6a0a38407c8
parent 4825 e8539e429ae3
child 4827 7895de87636b
Inherit hedgehog from gear which caused damage, thus keeping track of which hog actually did the damage
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Sun Jan 09 21:36:51 2011 +0300
+++ b/hedgewars/uGears.pas	Sun Jan 09 21:37:45 2011 +0300
@@ -558,6 +558,8 @@
             Gear^.Damage:= t;
             if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF))) and (hwRound(Gear^.Y) < cWaterLine + 256) then
                 spawnHealthTagForHH(Gear, t);
+
+            // should be CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
             uStats.HedgehogDamaged(Gear, CurrentHedgehog^.Gear)
             end;
 
@@ -1028,7 +1030,8 @@
            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
            end;
         end;
-    end;
+    end else // not gtHedgehog
+        Gear^.Hedgehog:= Attacker^.Hedgehog;
     inc(Gear^.Damage, Damage);
     ScriptCall('onGearDamage', Gear^.UID, Damage);
 end;