Don't play “missed” taunt if a target has been hit
authorWuzzy <almikes@aol.com>
Thu, 28 Sep 2017 01:15:25 +0200
changeset 12573 494d3e1c4810
parent 12572 459543ef9b1b
child 12574 87326fec6ea2
Don't play “missed” taunt if a target has been hit
hedgewars/uGearsHandlersMess.pas
hedgewars/uStats.pas
--- a/hedgewars/uGearsHandlersMess.pas	Thu Sep 28 00:46:06 2017 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Sep 28 01:15:25 2017 +0200
@@ -2153,6 +2153,8 @@
             for i:= 0 to 63 do
                 AddGear(x, y, gtFlame, 0, _0, _0, 0);
             end
+        else if k = gtTarget then
+            uStats.TargetHit()
         else if k = gtExplosives then
                 begin
                 doMakeExplosion(x, y, Gear^.Boom, hog, EXPLAutoSound);
--- a/hedgewars/uStats.pas	Thu Sep 28 00:46:06 2017 +0200
+++ b/hedgewars/uStats.pas	Thu Sep 28 01:15:25 2017 +0200
@@ -36,6 +36,7 @@
 procedure HedgehogPoisoned(Gear: PGear; Attacker: PHedgehog);
 procedure HedgehogSacrificed(Hedgehog: PHedgehog);
 procedure HedgehogDamaged(Gear: PGear; Attacker: PHedgehog; Damage: Longword; killed: boolean);
+procedure TargetHit;
 procedure Skipped;
 procedure TurnReaction;
 procedure SendStats;
@@ -56,6 +57,7 @@
     KillsClan   : LongWord = 0;
     Kills       : LongWord = 0;
     KillsTotal  : LongWord = 0;
+    HitTargets  : LongWord = 0; // Target (gtTarget) hits per turn
     AmmoUsedCount : Longword = 0;
     AmmoDamagingUsed : boolean = false;
     SkippedTurns: LongWord = 0;
@@ -121,6 +123,11 @@
 inc(DamageTurn, Damage)
 end;
 
+procedure TargetHit();
+begin
+   inc(HitTargets)
+end;
+
 procedure Skipped;
 begin
 inc(SkippedTurns);
@@ -179,7 +186,8 @@
             AddVoice(sndRegret, vpHurtEnemy)
 
     // Missed shot
-    else if AmmoDamagingUsed and (Kills <= killsCheck) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) then
+    // A miss is defined as a shot with a damaging weapon with 0 kills, 0 damage, 0 hogs poisoned and 0 targets hit
+    else if AmmoDamagingUsed and (Kills <= killsCheck) and (PoisonTurn = 0) and (PoisonClan = 0) and (DamageTurn = 0) and (HitTargets = 0) then
         // Chance to call hedgehog stupid if sacrificed for nothing
         if CurrentHedgehog^.stats.Sacrificed then
             if random(2) = 0 then
@@ -233,6 +241,7 @@
 KillsClan:= 0;
 DamageClan:= 0;
 DamageTurn:= 0;
+HitTargets:= 0;
 PoisonClan:= 0;
 PoisonTurn:= 0;
 AmmoUsedCount:= 0;
@@ -408,6 +417,7 @@
     KillsClan   := 0;
     Kills       := 0;
     KillsTotal  := 0;
+    HitTargets  := 0;
     AmmoUsedCount := 0;
     AmmoDamagingUsed := false;
     SkippedTurns:= 0;