From edeb980f5bb33b947a982c20677eb0d6668b595a Mon Sep 17 00:00:00 2001 From: Andre Mohren Date: Fri, 29 Sep 2017 23:18:14 +0200 Subject: [PATCH] Implemented a percentual chance to play the ImpactSound to CreateEffectWarhead --- OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 84f4acf2c3..0f95be10c0 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -38,6 +38,9 @@ namespace OpenRA.Mods.Common.Warheads [Desc("List of sounds that can be played on impact.")] public readonly string[] ImpactSounds = new string[0]; + [Desc("Chance of impact sound to play.")] + public readonly int ImpactSoundChance = 100; + [Desc("Consider explosion above this altitude an air explosion.", "If that's the case, this warhead will consider the explosion position to have the 'Air' TargetType (in addition to any nearby actor's TargetTypes).")] public readonly WDist AirThreshold = new WDist(128); @@ -135,7 +138,7 @@ namespace OpenRA.Mods.Common.Warheads } var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom); - if (impactSound != null) + if (impactSound != null && Game.CosmeticRandom.Next(0, 100) < ImpactSoundChance) Game.Sound.Play(SoundType.World, impactSound, pos); }