- Use more sounds
authorunc0rr
Thu, 24 Apr 2008 15:40:39 +0000
changeset 867 dc7901b1120e
parent 866 ac6f6c95c23f
child 868 4884bce5e5eb
- Use more sounds - Improve statistics
doc/SoundsMapping.txt
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uStats.pas
--- a/doc/SoundsMapping.txt	Thu Apr 24 15:19:33 2008 +0000
+++ b/doc/SoundsMapping.txt	Thu Apr 24 15:40:39 2008 +0000
@@ -8,7 +8,7 @@
 Hello - when you havent done anything for a certain amount of time, telling you to take your go
 Coward - when you end your go without attacking
 cut it out   -  when your hedgehog takes a very low amount of damage
-Enemy down - when you reduce enemys health to 0
+ + Enemy down - when you reduce enemys health to 0
 Excellent - when you do a high amount of damage
 Fire - when you shoot
  + First blood - when a hedgehog first takes damage
--- a/hedgewars/uConsts.pas	Thu Apr 24 15:19:33 2008 +0000
+++ b/hedgewars/uConsts.pas	Thu Apr 24 15:40:39 2008 +0000
@@ -62,7 +62,8 @@
                    sndMineTick, sndPickhammer, sndGun, sndUFO, sndJump1, sndJump2,
                    sndJump3, sndYesSir, sndLaugh, sndIllGetYou, sndIncoming,
                    sndMissed, sndStupid, sndFirstBlood, sndBoring, sndByeBye,
-                   sndSameTeam, sndNutter, sndReinforce, sndTraitor, sndRegret);
+                   sndSameTeam, sndNutter, sndReinforce, sndTraitor, sndRegret,
+                   sndEnemyDown);
 
      TAmmoType  = (amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer,
                    amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch,
@@ -404,7 +405,8 @@
                 (FileName:        'Nutter.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndNutter
                 (FileName:'Reinforcements.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndReinforce
                 (FileName:       'Traitor.ogg'; Path: ptVoices; id: nil; lastChan: 0),// sndTraitor
-                (FileName:'Youllregretthat.ogg';Path: ptVoices; id: nil; lastChan: 0) // sndRegret
+                (FileName:'Youllregretthat.ogg';Path: ptVoices; id: nil; lastChan: 0),// sndRegret
+                (FileName:     'Enemydown.ogg'; Path: ptVoices; id: nil; lastChan: 0) // sndEnemyDown
                 );
 
       Ammoz: array [TAmmoType] of record
--- a/hedgewars/uGears.pas	Thu Apr 24 15:19:33 2008 +0000
+++ b/hedgewars/uGears.pas	Thu Apr 24 15:40:39 2008 +0000
@@ -327,8 +327,9 @@
       if not (hwRound(Gear^.Y) < cWaterLine) then
          begin
          t:= max(Gear^.Damage, Gear^.Health);
+         Gear^.Damage:= t;
          AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
-         uStats.HedgehogDamaged(Gear, t)
+         uStats.HedgehogDamaged(Gear)
          end;
       team:= PHedgehog(Gear^.Hedgehog)^.Team;
       if CurrentHedgehog^.Gear = Gear then
@@ -351,22 +352,27 @@
 CheckNoDamage:= true;
 Gear:= GearsList;
 while Gear <> nil do
-      begin
-      if Gear^.Kind = gtHedgehog then
-         if Gear^.Damage <> 0 then
-            begin
-            CheckNoDamage:= false;
-            if Gear^.Health < Gear^.Damage then Gear^.Health:= 0
-                                           else dec(Gear^.Health, Gear^.Damage);
-            AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
-                    gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
-            RenderHealth(PHedgehog(Gear^.Hedgehog)^);
-            RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
+	begin
+	if Gear^.Kind = gtHedgehog then
+		if Gear^.Damage <> 0 then
+		begin
+		CheckNoDamage:= false;
+		uStats.HedgehogDamaged(Gear);
 
-            Gear^.Damage:= 0
-            end;
-      Gear:= Gear^.NextGear
-      end;
+		if Gear^.Health < Gear^.Damage then
+			Gear^.Health:= 0
+		else
+			dec(Gear^.Health, Gear^.Damage);
+
+		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
+				gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
+		RenderHealth(PHedgehog(Gear^.Hedgehog)^);
+		RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
+
+		Gear^.Damage:= 0
+		end;
+	Gear:= Gear^.NextGear
+	end;
 end;
 
 procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear);
@@ -824,10 +830,7 @@
                              begin
                              inc(Gear^.Damage, dmg);
                              if Gear^.Kind = gtHedgehog then
-                                begin
-                                uStats.HedgehogDamaged(Gear, dmg);
                                 AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, Gear)
-                                end
                              end;
                           if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
                              begin
@@ -868,11 +871,10 @@
                gtCase,
              gtTarget: begin
                        inc(t^.Damage, dmg);
+
                        if t^.Kind = gtHedgehog then
-                          begin
                           AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t);
-                          uStats.HedgehogDamaged(t, dmg)
-                          end;
+
                        DeleteCI(t);
                        t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX);
                        t^.dY:= t^.dY + Gear^.dY * dmg * _0_01;
@@ -906,11 +908,10 @@
              gtTarget,
                gtCase: begin
                        inc(t^.ar[i]^.Damage, Damage);
+
                        if t^.ar[i]^.Kind = gtHedgehog then
-                          begin
                           AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]);
-                          uStats.HedgehogDamaged(t^.ar[i], Damage)
-                          end;
+
                        DeleteCI(t^.ar[i]);
                        t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01;
                        t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01;
--- a/hedgewars/uStats.pas	Thu Apr 24 15:19:33 2008 +0000
+++ b/hedgewars/uStats.pas	Thu Apr 24 15:40:39 2008 +0000
@@ -31,7 +31,7 @@
                    end;
 
 procedure AmmoUsed(am: TAmmoType);
-procedure HedgehogDamaged(Gear: PGear; Damage: Longword);
+procedure HedgehogDamaged(Gear: PGear);
 procedure TurnReaction;
 procedure SendStats;
 
@@ -40,20 +40,29 @@
 var DamageGiven : Longword = 0;
     DamageClan  : Longword = 0;
     DamageTotal : Longword = 0;
+    KillsClan   : LongWord = 0;
+    Kills       : LongWord = 0;
+    KillsTotal  : LongWord = 0;
     AmmoUsedCount : Longword = 0;
     AmmoDamagingUsed : boolean = false;
 
-procedure HedgehogDamaged(Gear: PGear; Damage: Longword);
+procedure HedgehogDamaged(Gear: PGear);
 begin
 if Gear <> CurrentHedgehog^.Gear then
-   inc(CurrentHedgehog^.stats.StepDamageGiven, Damage);
+	inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage);
 
-if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Damage);
+if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage);
 
+if Gear^.Health <= Gear^.Damage then
+	begin
+	inc(Kills);
+	inc(KillsTotal);
+	if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan);
+	end;
 
-inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Damage);
-inc(DamageGiven, Damage);
-inc(DamageTotal, Damage)
+inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage);
+inc(DamageGiven, Gear^.Damage);
+inc(DamageTotal, Gear^.Damage)
 end;
 
 procedure TurnReaction;
@@ -76,9 +85,14 @@
 		else
 			PlaySound(sndTraitor, false)
 
-else if DamageGiven <> 0 then PlaySound(sndRegret, false)
+else if DamageGiven <> 0 then
+	if Kills > 0 then
+		PlaySound(sndEnemyDown, false)
+	else
+		PlaySound(sndRegret, false)
 
-else if AmmoDamagingUsed then PlaySound(sndMissed, false);
+else if AmmoDamagingUsed then
+	PlaySound(sndMissed, false);
 
 Gear:= GearsList;
 while Gear <> nil do
@@ -96,6 +110,8 @@
   Gear:= Gear^.NextGear
   end;
 
+Kills:= 0;
+KillsClan:= 0;
 DamageGiven:= 0;
 DamageClan:= 0;
 AmmoUsedCount:= 0;