diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index fe9111745e..0b8711cd60 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -597,6 +597,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs index a5b94be231..a8a39091b5 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs @@ -45,11 +45,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Facing that the actor must face before deploying. Set to -1 to deploy regardless of facing.")] public readonly int Facing = -1; - [Desc("Sound to play when deploying.")] - public readonly string DeploySound = null; + [Desc("Play a randomly selected sound from this list when deploying.")] + public readonly string[] DeploySounds = null; - [Desc("Sound to play when undeploying.")] - public readonly string UndeploySound = null; + [Desc("Play a randomly selected sound from this list when undeploying.")] + public readonly string[] UndeploySounds = null; [Desc("Skip make/deploy animation?")] public readonly bool SkipMakeAnimation = false; @@ -221,8 +221,8 @@ namespace OpenRA.Mods.Common.Traits if (!IsValidTerrain(self.Location)) return; - if (!string.IsNullOrEmpty(Info.DeploySound)) - Game.Sound.Play(SoundType.World, Info.DeploySound, self.CenterPosition); + if (Info.DeploySounds != null && Info.DeploySounds.Any()) + Game.Sound.Play(SoundType.World, Info.DeploySounds.Random(self.World.LocalRandom), self.CenterPosition); // Revoke condition that is applied while undeployed. if (!init) @@ -245,8 +245,8 @@ namespace OpenRA.Mods.Common.Traits if (!init && deployState != DeployState.Deployed) return; - if (!string.IsNullOrEmpty(Info.UndeploySound)) - Game.Sound.Play(SoundType.World, Info.UndeploySound, self.CenterPosition); + if (Info.UndeploySounds != null && Info.UndeploySounds.Any()) + Game.Sound.Play(SoundType.World, Info.UndeploySounds.Random(self.World.LocalRandom), self.CenterPosition); if (!init) OnUndeployStarted(); diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20181215/MultipleDeploySounds.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20181215/MultipleDeploySounds.cs new file mode 100644 index 0000000000..3b079d20c0 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20181215/MultipleDeploySounds.cs @@ -0,0 +1,46 @@ +#region Copyright & License Information +/* + * Copyright 2007-2019 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class MultipleDeploySounds : UpdateRule + { + public override string Name { get { return "'GrantConditionOnDeploy' now supports multiple (un)deploy sounds"; } } + public override string Description + { + get + { + return "Renamed 'DeploySound' to 'DeploySounds' and 'UndeploySound' to 'UndeploySounds'\n" + + "on 'GrantConditionOnDeploy'."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var grants = actorNode.ChildrenMatching("GrantConditionOnDeploy"); + foreach (var g in grants) + { + var deploy = g.LastChildMatching("DeploySound"); + if (deploy != null) + deploy.RenameKey("DeploySounds"); + + var undeploy = g.LastChildMatching("UndeploySound"); + if (undeploy != null) + undeploy.RenameKey("UndeploySounds"); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 76adf67bd5..d6d1b5a2bf 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -118,6 +118,7 @@ namespace OpenRA.Mods.Common.UpdateRules { // Bleed only changes here new RemoveAttackSuicides(), + new MultipleDeploySounds(), new MakeMobilePausableConditional(), new StreamlineRepairableTraits(), }) diff --git a/mods/ts/rules/gdi-vehicles.yaml b/mods/ts/rules/gdi-vehicles.yaml index 6aee65b3a5..34415ba2f4 100644 --- a/mods/ts/rules/gdi-vehicles.yaml +++ b/mods/ts/rules/gdi-vehicles.yaml @@ -349,8 +349,8 @@ JUGG: UndeployedCondition: undeployed Facing: 96 AllowedTerrainTypes: Clear, Road, DirtRoad, Rough - DeploySound: place2.aud - UndeploySound: clicky1.aud + DeploySounds: place2.aud + UndeploySounds: clicky1.aud GrantCondition@PREVIEWWORKAROUND: Condition: real-actor QuantizeFacingsFromSequence: diff --git a/mods/ts/rules/nod-vehicles.yaml b/mods/ts/rules/nod-vehicles.yaml index baae566c60..a7df05c379 100644 --- a/mods/ts/rules/nod-vehicles.yaml +++ b/mods/ts/rules/nod-vehicles.yaml @@ -136,8 +136,8 @@ TTNK: UndeployedCondition: undeployed Facing: 160 AllowedTerrainTypes: Clear, Road, DirtRoad, Rough - DeploySound: place2.aud - UndeploySound: clicky1.aud + DeploySounds: place2.aud + UndeploySounds: clicky1.aud GrantCondition@PREVIEWWORKAROUND: Condition: real-actor WithVoxelBody: @@ -240,8 +240,8 @@ ART2: UndeployedCondition: undeployed Facing: 96 AllowedTerrainTypes: Clear, Road, DirtRoad, Rough - DeploySound: place2.aud - UndeploySound: clicky1.aud + DeploySounds: place2.aud + UndeploySounds: clicky1.aud GrantCondition@PREVIEWWORKAROUND: Condition: real-actor WithVoxelBody: diff --git a/mods/ts/rules/shared-vehicles.yaml b/mods/ts/rules/shared-vehicles.yaml index 1cc7f4fabc..d4aebc667f 100644 --- a/mods/ts/rules/shared-vehicles.yaml +++ b/mods/ts/rules/shared-vehicles.yaml @@ -147,8 +147,8 @@ LPST: UndeployedCondition: undeployed Facing: 160 AllowedTerrainTypes: Clear, Road, DirtRoad, Rough - DeploySound: place2.aud - UndeploySound: clicky1.aud + DeploySounds: place2.aud + UndeploySounds: clicky1.aud WithVoxelBody: RequiresCondition: undeployed WithSpriteBody@deployed: