diff --git a/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs b/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs index 2aceb92ffe..b3982326c2 100644 --- a/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs +++ b/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs @@ -8,14 +8,18 @@ */ #endregion +using OpenRA.Support; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { public class SoundOnDamageTransitionInfo : ITraitInfo { - public readonly string DamagedSound; - public readonly string DestroyedSound; + [Desc("Play a random sound from this list when damaged.")] + public readonly string[] DamagedSounds = { }; + + [Desc("Play a random sound from this list when destroyed.")] + public readonly string[] DestroyedSounds = { }; public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this); } } @@ -31,10 +35,18 @@ namespace OpenRA.Mods.Common.Traits public void DamageStateChanged(Actor self, AttackInfo e) { + var rand = Game.CosmeticRandom; + if (e.DamageState == DamageState.Dead) - Sound.Play(info.DestroyedSound, self.CenterPosition); + { + var sound = info.DestroyedSounds.RandomOrDefault(rand); + Sound.Play(sound, self.CenterPosition); + } else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy) - Sound.Play(info.DamagedSound, self.CenterPosition); + { + var sound = info.DamagedSounds.RandomOrDefault(rand); + Sound.Play(sound, self.CenterPosition); + } } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 7825c58eee..8118e370d0 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -707,6 +707,18 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Key = "Refinery"; } + // Append an 's' as the fields were changed from string to string[] + if (engineVersion < 20150311) + { + if (depth == 2 && parentKey == "SoundOnDamageTransition") + { + if (node.Key == "DamagedSound") + node.Key = "DamagedSounds"; + else if (node.Key == "DestroyedSound") + node.Key = "DestroyedSounds"; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 8d61389ed7..e6e7c78524 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -397,8 +397,8 @@ BuildSounds: constru2.aud, hvydoor1.aud TerrainTypes: Clear,Road SoundOnDamageTransition: - DamagedSound: xplos.aud - DestroyedSound: crumble.aud + DamagedSounds: xplos.aud + DestroyedSounds: crumble.aud RenderBuilding: WithBuildingExplosion: Delay: 1 @@ -655,10 +655,11 @@ Health: HP: 500 SoundOnDamageTransition: - DamagedSound: xplos.aud - DestroyedSound: xplobig4.aud + DamagedSounds: xplos.aud + DestroyedSounds: xplobig4.aud BodyOrientation: ScriptTriggers: + ^Crate: Tooltip: Name: Crate diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index ec1b7d2837..70b06a605f 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -899,7 +899,7 @@ BRIK: CrushClasses: heavywall -CrushSound: SoundOnDamageTransition: - DestroyedSound: crumble.aud + DestroyedSounds: crumble.aud LineBuild: Range: 8 NodeTypes: concrete diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 82657a063c..dcf7110ffa 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -294,8 +294,8 @@ ExternalCapturable: ExternalCapturableBar: SoundOnDamageTransition: - DamagedSound: EXPLSML1.WAV - DestroyedSound: EXPLHG1.WAV + DamagedSounds: EXPLSML1.WAV + DestroyedSounds: EXPLHG1.WAV RenderBuilding: WithBuildingExplosion: RepairableBuilding: @@ -331,3 +331,4 @@ Range: 2c0, 5c0 ScriptTriggers: WithMakeAnimation: + diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 9d4ddb0b1d..496819e39e 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -465,8 +465,8 @@ wall: Prerequisites: barracks BuildPaletteOrder: 60 SoundOnDamageTransition: - DamagedSound: - DestroyedSound: EXPLSML4.WAV + DamagedSounds: + DestroyedSounds: EXPLSML4.WAV Valued: Cost: 100 CustomSellValue: @@ -841,3 +841,4 @@ conyard.ordos: RenderBuilding: Image: conyard.ordos -RaceImages: + diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 3cdefbd12a..2508e3a02e 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -383,8 +383,8 @@ ExternalCapturable: ExternalCapturableBar: SoundOnDamageTransition: - DamagedSound: kaboom1.aud - DestroyedSound: kaboom22.aud + DamagedSounds: kaboom1.aud + DestroyedSounds: kaboom22.aud RenderBuilding: WithMakeAnimation: WithBuildingExplosion: @@ -445,8 +445,8 @@ Adjacent: 7 TerrainTypes: Clear,Road SoundOnDamageTransition: - DamagedSound: sandbag2.aud - DestroyedSound: sandbag2.aud + DamagedSounds: sandbag2.aud + DestroyedSounds: sandbag2.aud Crushable: CrushClasses: wall BlocksBullets: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index dd335f1ba6..1e3c6d367d 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -1533,8 +1533,8 @@ BRIK: Name: Concrete Wall Description: Stop units and blocks enemy fire. SoundOnDamageTransition: - DamagedSound: crmble2.aud - DestroyedSound: kaboom30.aud + DamagedSounds: crmble2.aud + DestroyedSounds: kaboom30.aud Health: HP: 500 Armor: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 2a3d4986fb..58078cabfa 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -16,8 +16,8 @@ GivesBuildableArea: Capturable: SoundOnDamageTransition: - DamagedSound: expnew01.aud - DestroyedSound: crmble2.aud + DamagedSounds: expnew01.aud + DestroyedSounds: crmble2.aud RenderBuilding: WithBuildingExplosion: RepairableBuilding: @@ -84,8 +84,8 @@ Adjacent: 7 TerrainTypes: Clear, Road SoundOnDamageTransition: - DamagedSound: expnew01.aud - DestroyedSound: crmble2.aud + DamagedSounds: expnew01.aud + DestroyedSounds: crmble2.aud Crushable: CrushClasses: wall BlocksBullets: @@ -491,3 +491,4 @@ Footprint: x Dimensions: 1, 1 BodyOrientation: + diff --git a/mods/ts/rules/structures.yaml b/mods/ts/rules/structures.yaml index e02bc20d19..e2ed659f58 100644 --- a/mods/ts/rules/structures.yaml +++ b/mods/ts/rules/structures.yaml @@ -406,8 +406,8 @@ GASAND: BuildPaletteOrder: 1000 Prerequisites: ~structures.gdi SoundOnDamageTransition: - DamagedSound: sandbag1.aud - DestroyedSound: sandbag1.aud + DamagedSounds: sandbag1.aud + DestroyedSounds: sandbag1.aud Valued: Cost: 25 CustomSellValue: @@ -433,8 +433,8 @@ GAWALL: BuildPaletteOrder: 1001 Prerequisites: ~structures.gdi SoundOnDamageTransition: - DamagedSound: - DestroyedSound: + DamagedSounds: + DestroyedSounds: Valued: Cost: 50 CustomSellValue: @@ -458,8 +458,8 @@ NAWALL: BuildPaletteOrder: 1001 Prerequisites: ~structures.nod SoundOnDamageTransition: - DamagedSound: - DestroyedSound: + DamagedSounds: + DestroyedSounds: Valued: Cost: 50 CustomSellValue: