Fix voicepacks
authorunc0rr
Wed, 14 Jan 2009 22:53:22 +0000
changeset 1678 c8deca7b1e3c
parent 1677 0655bb13af01
child 1679 f9b9c65d4c6a
Fix voicepacks
hedgewars/uStats.pas
hedgewars/uTeams.pas
--- a/hedgewars/uStats.pas	Wed Jan 14 21:59:11 2009 +0000
+++ b/hedgewars/uStats.pas	Wed Jan 14 22:53:22 2009 +0000
@@ -45,20 +45,29 @@
 implementation
 uses uTeams, uSound, uMisc;
 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;
-    SkippedTurns: LongWord = 0;
-    isTurnSkipped: boolean = false;
+	DamageClan  : Longword = 0;
+	DamageTotal : Longword = 0;
+	KillsClan   : LongWord = 0;
+	Kills       : LongWord = 0;
+	KillsTotal  : LongWord = 0;
+	AmmoUsedCount : Longword = 0;
+	AmmoDamagingUsed : boolean = false;
+	SkippedTurns: LongWord = 0;
+	isTurnSkipped: boolean = false;
+	vpHurtSameClan: PVoicepack = nil;
+	vpHurtEnemy: PVoicepack = nil;
 
 procedure HedgehogDamaged(Gear: PGear);
 begin
+if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then
+	vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack
+else
+	vpHurtEnemy:= CurrentHedgehog^.Team^.voicepack;
+
 if bBetweenTurns then exit;
 
+//////////////////////////
+
 if Gear <> CurrentHedgehog^.Gear then
 	inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage);
 
@@ -97,34 +106,34 @@
 		PlaySound(sndFirstBlood, false, CurrentTeam^.voicepack)
 
 	else if CurrentHedgehog^.stats.StepDamageRecv > 0 then
-		PlaySound(sndStupid, false, CurrentTeam^.voicepack)
+		PlaySound(sndStupid, false, PreviousTeam^.voicepack)
 
 	else if DamageClan <> 0 then
 		if DamageTotal > DamageClan then
 			if random(2) = 0 then
 				PlaySound(sndNutter, false, CurrentTeam^.voicepack)
 			else
-				PlaySound(sndWatchIt, false, CurrentTeam^.voicepack)
+				PlaySound(sndWatchIt, false, vpHurtSameClan)
 		else
 			if random(2) = 0 then
-				PlaySound(sndSameTeam, false, CurrentTeam^.voicepack)
+				PlaySound(sndSameTeam, false, vpHurtSameClan)
 			else
-				PlaySound(sndTraitor, false, CurrentTeam^.voicepack)
+				PlaySound(sndTraitor, false, vpHurtSameClan)
 
 	else if DamageGiven <> 0 then
 		if Kills > 0 then
 			PlaySound(sndEnemyDown, false, CurrentTeam^.voicepack)
 		else
-			PlaySound(sndRegret, false, CurrentTeam^.voicepack)
+			PlaySound(sndRegret, false, vpHurtEnemy)
 
 	else if AmmoDamagingUsed then
-		PlaySound(sndMissed, false, CurrentTeam^.voicepack)
+		PlaySound(sndMissed, false, PreviousTeam^.voicepack)
 	else if (AmmoUsedCount > 0) and not isTurnSkipped then
 		// nothing ?
 	else if isTurnSkipped then
-		PlaySound(sndBoring, false, CurrentTeam^.voicepack)
+		PlaySound(sndBoring, false, PreviousTeam^.voicepack)
 	else
-		PlaySound(sndCoward, false, CurrentTeam^.voicepack);
+		PlaySound(sndCoward, false, PreviousTeam^.voicepack);
 	end;
 
 
--- a/hedgewars/uTeams.pas	Wed Jan 14 21:59:11 2009 +0000
+++ b/hedgewars/uTeams.pas	Wed Jan 14 22:53:22 2009 +0000
@@ -80,6 +80,7 @@
 			end;
 
 var CurrentTeam: PTeam = nil;
+	PreviousTeam: PTeam = nil;
 	CurrentHedgehog: PHedgehog = nil;
 	TeamsArray: array[0..Pred(cMaxTeams)] of PTeam;
 	TeamsCount: Longword = 0;
@@ -155,6 +156,7 @@
 FreeActionsList;
 TargetPoint.X:= NoPointX;
 TryDo(CurrentTeam <> nil, 'nil Team', true);
+PreviousTeam:= CurrentTeam;
 
 with CurrentHedgehog^ do
 	if Gear <> nil then