Fix enemy saying “Missed” when poisoned w/o damage
authorWuzzy <almikes@aol.com>
Thu, 06 Apr 2017 23:28:13 +0200
changeset 12181 29f1ea94488b
parent 12180 9237bfb198c7
child 12182 bfeeb1c35e77
Fix enemy saying “Missed” when poisoned w/o damage
ChangeLog.txt
hedgewars/uGearsUtils.pas
hedgewars/uStats.pas
--- a/ChangeLog.txt	Thu Apr 06 22:34:02 2017 +0200
+++ b/ChangeLog.txt	Thu Apr 06 23:28:13 2017 +0200
@@ -33,6 +33,7 @@
  * Fixed Seduction's "Yoohoo!" sound not playing
  * Fixed Hedgehogs getting hurt while firing deagle / sniper rifle bullet in certains situations
  * Fixed hedgehogs saying “Missed” when drowning enemy without dealing damage
+ * Fixed enemy saying "Missed” when giving poison without direct damage
  * Fixed incorrect time box tooltip when in Sudden Death
  * Various other fixes
 
--- a/hedgewars/uGearsUtils.pas	Thu Apr 06 22:34:02 2017 +0200
+++ b/hedgewars/uGearsUtils.pas	Thu Apr 06 23:28:13 2017 +0200
@@ -183,7 +183,8 @@
                                     if Gear^.Hedgehog^.Effects[hePoisoned] = 0 then
                                         begin
                                         s:= ansistring(Gear^.Hedgehog^.Name);
-                                        AddCaption(FormatA(GetEventString(eidPoisoned), s), cWhiteColor, capgrpMessage)
+                                        AddCaption(FormatA(GetEventString(eidPoisoned), s), cWhiteColor, capgrpMessage);
+                                        uStats.HedgehogPoisoned(Gear, AttackingHog)
                                         end;
                                     Gear^.Hedgehog^.Effects[hePoisoned] := 5;
                                     end
--- 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;