Fixes PlayVoiceLocal so it actually works as intended, bring DeathSounds in line with suggestions.
This commit is contained in:
@@ -296,7 +296,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if played successfully
|
// 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)
|
if (definition == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -350,8 +350,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
|
if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer))
|
||||||
soundEngine.Play2D(sounds[name],
|
soundEngine.Play2D(sounds[name],
|
||||||
false, true, WPos.Zero,
|
false, relative, pos,
|
||||||
InternalSoundVolume, attenuateVolume);
|
(InternalSoundVolume * volumeModifier), attenuateVolume);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -366,10 +366,10 @@ namespace OpenRA
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var type = mi.Voice.ToLowerInvariant();
|
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)
|
if (voicedUnit == null || phrase == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -379,7 +379,7 @@ namespace OpenRA
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var type = mi.Voice.ToLowerInvariant();
|
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)
|
public static bool PlayNotification(Player player, string type, string notification, string variant)
|
||||||
@@ -387,7 +387,7 @@ namespace OpenRA
|
|||||||
if (type == null || notification == null)
|
if (type == null || notification == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return PlayPredefined(player, null, type.ToLowerInvariant(), notification, variant, false);
|
return PlayPredefined(player, null, type.ToLowerInvariant(), notification, variant, true, WPos.Zero, 1f, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,14 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public class DeathSoundsInfo : ITraitInfo
|
public class DeathSoundsInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly string DeathVoice = "Die";
|
[Desc("Death notification voice.")]
|
||||||
public readonly string Burned = null;
|
public readonly string DeathSound = "Die";
|
||||||
public readonly string Zapped = null;
|
|
||||||
|
[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); }
|
public object Create(ActorInitializer init) { return new DeathSounds(this); }
|
||||||
}
|
}
|
||||||
@@ -38,16 +43,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
var cp = self.CenterPosition;
|
var cp = self.CenterPosition;
|
||||||
|
|
||||||
// Killed by fire
|
if (info.InfDeaths.Contains(e.Warhead.InfDeath) || (!info.InfDeaths.Any() && !self.Info.Traits.WithInterface<DeathSoundsInfo>().Any(dsi => dsi.InfDeaths.Contains(e.Warhead.InfDeath))))
|
||||||
if (info.Burned != null && e.Warhead.InfDeath == 5)
|
Sound.PlayVoiceLocal(info.DeathSound, self, self.Owner.Country.Race, cp, info.VolumeMultiplier);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user