diff --git a/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs b/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs index 540e641765..b9826d5d7c 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits.Sound class AmbientSoundInfo : ConditionalTraitInfo { [FieldLoader.Require] - public readonly string SoundFile = null; + public readonly string[] SoundFiles = null; [Desc("Initial delay (in ticks) before playing the sound for the first time.", "Two values indicate a random delay range.")] @@ -74,16 +74,18 @@ namespace OpenRA.Mods.Common.Traits.Sound void StartSound(Actor self) { + var sound = Info.SoundFiles.RandomOrDefault(Game.CosmeticRandom); + ISound s; if (self.OccupiesSpace != null) { cachedPosition = self.CenterPosition; - s = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile, cachedPosition) : - Game.Sound.Play(SoundType.World, Info.SoundFile, self.CenterPosition); + s = loop ? Game.Sound.PlayLooped(SoundType.World, sound, cachedPosition) : + Game.Sound.Play(SoundType.World, sound, self.CenterPosition); } else - s = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile) : - Game.Sound.Play(SoundType.World, Info.SoundFile); + s = loop ? Game.Sound.PlayLooped(SoundType.World, sound) : + Game.Sound.Play(SoundType.World, sound); currentSounds.Add(s); } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 0115b2484a..e350aabe96 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -596,6 +596,11 @@ namespace OpenRA.Mods.Common.UtilityCommands RenameNodeKey(node, "-AcceptsDeliveredCash"); } + // Add random sound support to AmbientSound + if (engineVersion < 20170422) + if (node.Key == "SoundFile" && parent.Key.StartsWith("AmbientSound", StringComparison.Ordinal)) + RenameNodeKey(node, "SoundFiles"); + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 79e3d90e8a..a49673b64e 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -773,7 +773,7 @@ OBLI: ChargingCondition: charging AmbientSound: RequiresCondition: charging - SoundFile: obelpowr.aud + SoundFiles: obelpowr.aud Interval: 30, 40 -EmitInfantryOnSell: DetectCloaked: diff --git a/mods/d2k/rules/arrakis.yaml b/mods/d2k/rules/arrakis.yaml index 3d53db7f44..9433d79889 100644 --- a/mods/d2k/rules/arrakis.yaml +++ b/mods/d2k/rules/arrakis.yaml @@ -82,7 +82,7 @@ sandworm: Sequences: lightninga, lightningb, lightningc, lightningd, lightninge, lightningf RequiresCondition: !attacking AmbientSound: - SoundFile: WRMSIGN1.WAV + SoundFiles: WRMSIGN1.WAV Interval: 160 RequiresCondition: !attacking WithAttackOverlay@mouth: diff --git a/mods/d2k/rules/infantry.yaml b/mods/d2k/rules/infantry.yaml index ed6be9226c..80bd56c611 100644 --- a/mods/d2k/rules/infantry.yaml +++ b/mods/d2k/rules/infantry.yaml @@ -111,7 +111,7 @@ thumper: Sequence: thump-sand RequiresCondition: deployed AmbientSound: - SoundFile: THUMPER1.WAV + SoundFiles: THUMPER1.WAV Interval: 60 RequiresCondition: deployed AttractsWorms: diff --git a/mods/ts/rules/nod-support.yaml b/mods/ts/rules/nod-support.yaml index 837ed02ddf..69f6254833 100644 --- a/mods/ts/rules/nod-support.yaml +++ b/mods/ts/rules/nod-support.yaml @@ -113,7 +113,7 @@ NAOBEL: ChargingCondition: charging AmbientSound: RequiresCondition: charging - SoundFile: obelpowr.aud + SoundFiles: obelpowr.aud Interval: 30, 40 WithChargeOverlay: Palette: player