Colin Rice
authorunc0rr
Mon, 28 Mar 2011 21:27:06 +0400
changeset 5062 e2d38329b84a
parent 5060 7d0f6e5b1c1c
child 5063 d0722d0b024d
Colin Rice *Give correct credit for damage
hedgewars/uGears.pas
hedgewars/uTypes.pas
--- a/hedgewars/uGears.pas	Mon Mar 28 20:31:01 2011 +0400
+++ b/hedgewars/uGears.pas	Mon Mar 28 21:27:06 2011 +0400
@@ -578,7 +578,10 @@
 
             // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
             // same stand for CheckHHDamage
-            uStats.HedgehogDamaged(Gear, CurrentHedgehog)
+            if (Gear^.LastDamage <> nil) then
+                uStats.HedgehogDamaged(Gear, Gear^.LastDamage)
+            else
+                uStats.HedgehogDamaged(Gear, CurrentHedgehog)
             end;
 
         team:= Gear^.Hedgehog^.Team;
@@ -1019,6 +1022,9 @@
 
     if (Gear^.Kind = gtHedgehog) then
     begin
+
+    Gear^.LastDamage := AttackerHog;
+
     Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
     uStats.HedgehogDamaged(Gear, AttackerHog);
     HHHurt(Gear^.Hedgehog, Source);
@@ -1053,6 +1059,7 @@
            not CurrentHedgehog^.Gear^.Invulnerable then
            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
+           CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog;
            spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
            end;
         end;
--- a/hedgewars/uTypes.pas	Mon Mar 28 20:31:01 2011 +0400
+++ b/hedgewars/uTypes.pas	Mon Mar 28 21:27:06 2011 +0400
@@ -235,7 +235,8 @@
             ImpactSound: TSound; // first sound, others have to be after it in the sounds def.
             nImpactSounds: Word; // count of ImpactSounds
             SoundChannel: LongInt;
-            PortalCounter: LongWord  // Hopefully temporary, but avoids infinite portal loops in a guaranteed fashion.
+            PortalCounter: LongWord;  // Hopefully temporary, but avoids infinite portal loops in a guaranteed fashion.
+            LastDamage: PHedgehog;
         end;
     TPGearArray = Array of PGear;