diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 8f4ea93c54..7b59fe679c 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -296,7 +296,7 @@ namespace OpenRA } // Returns true if played successfully - public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant, bool attenuateVolume) + public static bool PlayPredefined(Player p, Actor voicedUnit, string type, string definition, string variant, bool relative, WPos pos, float volumeModifier, bool attenuateVolume) { if (definition == null) return false; @@ -350,8 +350,8 @@ namespace OpenRA if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer)) soundEngine.Play2D(sounds[name], - false, true, WPos.Zero, - InternalSoundVolume, attenuateVolume); + false, relative, pos, + (InternalSoundVolume * volumeModifier), attenuateVolume); return true; } @@ -366,10 +366,10 @@ namespace OpenRA return false; var type = mi.Voice.ToLowerInvariant(); - return PlayPredefined(null, voicedUnit, type, phrase, variant, true); + return PlayPredefined(null, voicedUnit, type, phrase, variant, true, WPos.Zero, 1f, true); } - public static bool PlayVoiceLocal(string phrase, Actor voicedUnit, string variant, WPos pos) + public static bool PlayVoiceLocal(string phrase, Actor voicedUnit, string variant, WPos pos, float volume) { if (voicedUnit == null || phrase == null) return false; @@ -379,7 +379,7 @@ namespace OpenRA return false; var type = mi.Voice.ToLowerInvariant(); - return PlayPredefined(null, voicedUnit, type, phrase, variant, true); + return PlayPredefined(null, voicedUnit, type, phrase, variant, false, pos, volume, true); } public static bool PlayNotification(Player player, string type, string notification, string variant) @@ -387,7 +387,7 @@ namespace OpenRA if (type == null || notification == null) return false; - return PlayPredefined(player, null, type.ToLowerInvariant(), notification, variant, false); + return PlayPredefined(player, null, type.ToLowerInvariant(), notification, variant, true, WPos.Zero, 1f, false); } } diff --git a/OpenRA.Mods.RA/DeathSounds.cs b/OpenRA.Mods.RA/DeathSounds.cs index 2ab4cef0a2..291985c8b0 100644 --- a/OpenRA.Mods.RA/DeathSounds.cs +++ b/OpenRA.Mods.RA/DeathSounds.cs @@ -17,9 +17,14 @@ namespace OpenRA.Mods.RA { public class DeathSoundsInfo : ITraitInfo { - public readonly string DeathVoice = "Die"; - public readonly string Burned = null; - public readonly string Zapped = null; + [Desc("Death notification voice.")] + public readonly string DeathSound = "Die"; + + [Desc("Multiply volume with this factor.")] + public readonly float VolumeMultiplier = 1f; + + [Desc("InfDeaths that this should be used for. If empty, this will be used as the default sound.")] + public readonly string[] InfDeaths = { }; public object Create(ActorInitializer init) { return new DeathSounds(this); } } @@ -38,16 +43,8 @@ namespace OpenRA.Mods.RA var cp = self.CenterPosition; - // Killed by fire - if (info.Burned != null && e.Warhead.InfDeath == 5) - Sound.Play(info.Burned, cp); - - // Killed by Tesla/Laser zap - if (info.Zapped != null && e.Warhead.InfDeath == 6) - Sound.Play(info.Zapped, cp); - - if ((e.Warhead.InfDeath < 5) || (info.Burned == null && info.Zapped == null)) - Sound.PlayVoiceLocal(info.DeathVoice, self, self.Owner.Country.Race, cp); + if (info.InfDeaths.Contains(e.Warhead.InfDeath) || (!info.InfDeaths.Any() && !self.Info.Traits.WithInterface().Any(dsi => dsi.InfDeaths.Contains(e.Warhead.InfDeath)))) + Sound.PlayVoiceLocal(info.DeathSound, self, self.Owner.Country.Race, cp, info.VolumeMultiplier); } } } \ No newline at end of file