hedgewars/uStats.pas
changeset 12181 29f1ea94488b
parent 12162 e837912ba85d
child 12295 4ce7cb441c75
--- a/hedgewars/uStats.pas	Thu Apr 06 22:34:02 2017 +0200
+++ b/hedgewars/uStats.pas	Thu Apr 06 23:28:13 2017 +0200
@@ -30,6 +30,7 @@
 procedure freeModule;
 
 procedure AmmoUsed(am: TAmmoType);
+procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
 procedure Skipped;
 procedure TurnReaction;
@@ -45,6 +46,9 @@
 var DamageClan  : Longword = 0;
     DamageTotal : Longword = 0;
     DamageTurn  : Longword = 0;
+    PoisonTurn  : Longword = 0; // Poisoned enemies per turn
+    PoisonClan  : Longword = 0; // Poisoned own clan members in turn
+    PoisonTotal : Longword = 0; // Poisoned hogs in whole round
     KillsClan   : LongWord = 0;
     Kills       : LongWord = 0;
     KillsTotal  : LongWord = 0;
@@ -55,6 +59,21 @@
     vpHurtSameClan: PVoicepack = nil;
     vpHurtEnemy: PVoicepack = nil;
 
+procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
+begin
+    if Attacker^.Team^.Clan = Gear^.HEdgehog^.Team^.Clan then
+        begin
+        vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack;
+        inc(PoisonClan)
+        end
+    else
+        begin
+        vpHurtEnemy:= Gear^.Hedgehog^.Team^.voicepack;
+        inc(PoisonTurn)
+        end;
+    inc(PoisonTotal)
+end;
+
 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
 begin
 if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then
@@ -109,8 +128,8 @@
     s:= ansistring(CurrentHedgehog^.Name);
     inc(CurrentHedgehog^.stats.FinishedTurns);
 
-    // First blood (first damage or kill)
-    if ((DamageTotal > 0) or (KillsTotal > 0)) and ((CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (CurrentHedgehog^.stats.StepKills = KillsTotal)) then
+    // First blood (first damage, poison or kill)
+    if ((DamageTotal > 0) or (KillsTotal > 0) or (PoisonTotal > 0)) and ((CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (CurrentHedgehog^.stats.StepKills = KillsTotal) and (PoisonTotal = PoisonTurn + PoisonClan)) then
         AddVoice(sndFirstBlood, CurrentTeam^.voicepack)
 
     // Hog hurts itself only
@@ -121,8 +140,8 @@
             AddCaption(FormatA(GetEventString(eidHurtSelf), s), cWhiteColor, capgrpMessage);
         end
 
-    // Hog hurts own team/clan
-    else if (DamageClan <> 0) or (KillsClan <> 0) then
+    // Hog hurts, poisons or kills own team/clan member
+    else if (DamageClan <> 0) or (KillsClan <> 0) or (PoisonClan <> 0) then
         if (DamageTurn > DamageClan) or (Kills > KillsClan) then
             if random(2) = 0 then
                 AddVoice(sndNutter, CurrentTeam^.voicepack)
@@ -134,15 +153,15 @@
             else
                 AddVoice(sndTraitor, vpHurtSameClan)
 
-    // Hog hurts or kills enemy
-    else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills <> 0) then
+    // Hog hurts, kills or poisons enemy
+    else if (CurrentHedgehog^.stats.StepDamageGiven <> 0) or (CurrentHedgehog^.stats.StepKills <> 0) or (PoisonTurn <> 0) then
         if Kills > 0 then
             AddVoice(sndEnemyDown, CurrentTeam^.voicepack)
         else
             AddVoice(sndRegret, vpHurtEnemy)
 
     // Missed shot
-    else if AmmoDamagingUsed and (Kills = 0) then
+    else if AmmoDamagingUsed and (Kills = 0) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) then
         AddVoice(sndMissed, PreviousTeam^.voicepack)
 
     // Timeout
@@ -187,6 +206,8 @@
 KillsClan:= 0;
 DamageClan:= 0;
 DamageTurn:= 0;
+PoisonClan:= 0;
+PoisonTurn:= 0;
 AmmoUsedCount:= 0;
 AmmoDamagingUsed:= false;
 isTurnSkipped:= false
@@ -349,6 +370,8 @@
     DamageClan  := 0;
     DamageTotal := 0;
     DamageTurn  := 0;
+    PoisonClan  := 0;
+    PoisonTurn  := 0;
     KillsClan   := 0;
     Kills       := 0;
     KillsTotal  := 0;