From b6dc30ca935e7783daf28bb36fb052d72096ae28 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 12 Sep 2016 22:53:44 +0200 Subject: [PATCH 1/3] Add support for playing the weapon report of the ion cannon --- OpenRA.Mods.Cnc/Projectiles/IonCannon.cs | 5 ++++- OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs b/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs index 1f4a81dcc5..cd1f938058 100644 --- a/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs +++ b/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Effects int weaponDelay; bool impacted = false; - public IonCannon(Player firedBy, WeaponInfo weapon, World world, CPos location, string effect, string sequence, string palette, int delay) + public IonCannon(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, CPos location, string effect, string sequence, string palette, int delay) { this.firedBy = firedBy; this.weapon = weapon; @@ -38,6 +38,9 @@ namespace OpenRA.Mods.Cnc.Effects target = Target.FromCell(world, location); anim = new Animation(world, effect); anim.PlayThen(sequence, () => Finish(world)); + + if (weapon.Report != null && weapon.Report.Any()) + Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), launchPos); } public void Tick(World world) diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs index 44ac999112..938ded2d9e 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs @@ -64,7 +64,8 @@ namespace OpenRA.Mods.Cnc.Traits self.World.AddFrameEndTask(w => { Game.Sound.Play(Info.LaunchSound, self.World.Map.CenterOfCell(order.TargetLocation)); - w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, order.TargetLocation, info.Effect, info.EffectSequence, info.EffectPalette, info.WeaponDelay)); + w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, self.CenterPosition, order.TargetLocation, + info.Effect, info.EffectSequence, info.EffectPalette, info.WeaponDelay)); if (info.CameraActor == null) return; From 41bc3b20ba4315aefb7bbd57c858a3ee8b1de703 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 12 Sep 2016 23:19:45 +0200 Subject: [PATCH 2/3] Add a new OnFireSound property to IonCannonPower This replaces the hacky use of LaunchSound --- OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs | 6 +++++- mods/cnc/rules/structures.yaml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs index 938ded2d9e..cfc70ffebe 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs @@ -43,6 +43,9 @@ namespace OpenRA.Mods.Cnc.Traits [Desc("Apply the weapon impact this many ticks into the effect")] public readonly int WeaponDelay = 7; + [Desc("Sound to instantly play at the targeted area.")] + public readonly string OnFireSound = null; + public override object Create(ActorInitializer init) { return new IonCannonPower(init.Self, this); } public void RulesetLoaded(Ruleset rules, ActorInfo ai) { WeaponInfo = rules.Weapons[Weapon.ToLowerInvariant()]; } } @@ -63,7 +66,8 @@ namespace OpenRA.Mods.Cnc.Traits self.World.AddFrameEndTask(w => { - Game.Sound.Play(Info.LaunchSound, self.World.Map.CenterOfCell(order.TargetLocation)); + Game.Sound.Play(Info.LaunchSound); + Game.Sound.Play(info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation)); w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, self.CenterPosition, order.TargetLocation, info.Effect, info.EffectSequence, info.EffectPalette, info.WeaponDelay)); diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 04c4e07cf7..46ed2ece8b 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -575,9 +575,9 @@ EYE: LongDesc: Initiate an Ion Cannon strike.\nApplies instant damage to a small area. BeginChargeSpeechNotification: IonCannonCharging EndChargeSpeechNotification: IonCannonReady - LaunchSound: ion1.aud SelectTargetSpeechNotification: SelectTarget InsufficientPowerSpeechNotification: InsufficientPower + OnFireSound: ion1.aud DisplayRadarPing: True CameraActor: camera.small SupportPowerChargeBar: From 348249119a910e16a5781fc4fae2e89308ca8e28 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 12 Sep 2016 23:21:29 +0200 Subject: [PATCH 3/3] Play all IonCannonPower launch sounds using the new helper method --- OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs index cfc70ffebe..ebdd6a346d 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Traits self.World.AddFrameEndTask(w => { - Game.Sound.Play(Info.LaunchSound); + PlayLaunchSounds(); Game.Sound.Play(info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation)); w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, self.CenterPosition, order.TargetLocation, info.Effect, info.EffectSequence, info.EffectPalette, info.WeaponDelay));