From 20af089fcd0215fcafaad82a8fd201bd6e516d2c Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Mon, 18 Jun 2012 22:13:24 +1200 Subject: [PATCH 1/9] Added Allies 01 SP map and Allies01Script.cs --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 307 ++++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + mods/ra/maps/allies-01.oramap | Bin 0 -> 2713 bytes 3 files changed, 308 insertions(+) create mode 100644 OpenRA.Mods.RA/Missions/Allies01Script.cs create mode 100644 mods/ra/maps/allies-01.oramap diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs new file mode 100644 index 0000000000..cd32a232b3 --- /dev/null +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -0,0 +1,307 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 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. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using OpenRA.FileFormats; +using OpenRA.Mods.RA.Activities; +using OpenRA.Mods.RA.Air; +using OpenRA.Network; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Missions +{ + public class Allies01ScriptInfo : TraitInfo, Requires { } + + public class Allies01Script : IWorldLoaded, ITick + { + private string[] objectives = + { + "Find Einstein.", + "Wait for the helicopter and extract Einstein." + }; + + private int currentObjective; + + private Player allies; + private Player soviets; + + private ISound music; + + private bool tanyaLanded; + private int frameLastAttackWave; + private int currentAttackWave; + + private Actor insertionLZ; + private Actor extractionLZ; + private Actor lab; + private Actor insertionLZEntryPoint; + private Actor extractionLZEntryPoint; + private Actor chinookExitPoint; + private Actor shipSpawnPoint; + private Actor shipMovePoint; + private Actor einstein; + private Actor einsteinChinook; + private Actor tanya; + private Actor attackEntryPoint1; + private Actor attackEntryPoint2; + + private Random random = new Random(); + private static readonly string[] taunts = { "laugh1.aud", "lefty1.aud", "cmon1.aud", "gotit1.aud" }; + private static readonly string[] ships = { "ca", "ca", "ca", "ca" }; + + private static readonly string[][] attackWaves = new string[][] { + new[] { "e1", "e1", "e1", "e2", "e2", "dog" }, + new[] { "e1", "e1", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "dog" }, + new[] { "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "e2", "e2", "dog", "dog", "3tnk" }, + new[] { "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "e2", "e2", "dog", "dog", "e4", "e4", "3tnk", "3tnk" }, + }; + + private static readonly string[] reinforcements = { "e1", "e1", "e1", "e3", "e3" }; + + private const int labRange = 5; + private const int lzRange = 3; + private const string einsteinName = "c1"; + private const string tanyaName = "e7"; + private const string chinookName = "tran"; + + private void DisplayObjective(string text) + { + Game.AddChatLine(Color.LimeGreen, "Objective", text); + } + + private void MissionFailed(Actor self, string text) + { + if (allies.WinState != WinState.Undefined) + { + return; + } + allies.WinState = WinState.Lost; + Game.AddChatLine(Color.Red, "Mission failed", text); + foreach (var actor in self.World.Actors.Where(a => a.Owner.InternalName == allies.InternalName)) + { + actor.Kill(actor); + } + self.World.LocalShroud.Disabled = true; + } + + private void MissionAccomplished(Actor self, string text) + { + if (allies.WinState != WinState.Undefined) + { + return; + } + allies.WinState = WinState.Won; + Game.AddChatLine(Color.Blue, "Mission accomplished", text); + self.World.LocalShroud.Disabled = true; + } + + public void Tick(Actor self) + { + if (allies.WinState != WinState.Undefined) + { + return; + } + // display current objective every so often + if (self.World.FrameNumber % 1500 == 1) + { + DisplayObjective(objectives[currentObjective]); + } + // taunt every so often + if (self.World.FrameNumber % 1000 == 0) + { + Sound.Play(taunts[random.Next(0, taunts.Length)]); + } + // take Tanya to the LZ + if (self.World.FrameNumber == 1) + { + FlyTanyaToInsertionLZ(self); + } + // laugh when Tanya arrives at the LZ + if (tanya.IsInWorld && !tanyaLanded) + { + Sound.Play("laugh1.aud"); // "Hahaha" - Tanya + tanyaLanded = true; + } + // objectives + if (currentObjective == 0) + { + if (AlliesControlLab(self)) + { + SpawnEinsteinAtLab(self); // spawn Einstein once the area is clear + Sound.Play("einok1.aud"); // "Incredible!" - Einstein + FlyUnitsToInsertionLZ(self, reinforcements); + SendShips(self); + currentObjective++; + DisplayObjective(objectives[currentObjective]); + } + if (lab.Destroyed) + { + MissionFailed(self, "Einstein was killed."); + } + } + else if (currentObjective == 1) + { + if (self.World.FrameNumber >= frameLastAttackWave + 600) + { + FlyUnitsToInsertionLZ(self, reinforcements); + SendAttackWave(self, attackWaves[Math.Min(currentAttackWave, attackWaves.Length - 1)]); + if (currentAttackWave == attackWaves.Length - 1) + { + FlyToExtractionLZ(self); + } + currentAttackWave++; + frameLastAttackWave = self.World.FrameNumber; + } + if (einsteinChinook != null) + { + if (einsteinChinook.Trait().Passengers.Contains(einstein)) + { + FlyFromExtractionLZ(); + } + if (UnitsNearActor(self, chinookExitPoint, 5).Contains(einsteinChinook) && !einstein.IsInWorld) + { + MissionAccomplished(self, "Einstein was rescued."); + } + } + if (einstein.Destroyed) + { + MissionFailed(self, "Einstein was killed."); + } + } + if (tanya.Destroyed) + { + MissionFailed(self, "Tanya was killed."); + } + } + + private void SendAttackWave(Actor self, IEnumerable wave) + { + foreach (var unit in wave) + { + var spawnActor = random.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2; + var targetActor = random.Next(2) == 0 ? einstein : tanya; + var actor = self.World.CreateActor(unit, new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnActor.Location) }); + actor.QueueActivity(new Attack(Target.FromActor(targetActor), 2)); + } + } + + private IEnumerable UnitsNearActor(Actor self, Actor actor, int range) + { + return self.World.FindUnitsInCircle(actor.CenterLocation, Game.CellSize * range) + .Where(a => a.IsInWorld && a != self.World.WorldActor && !a.Destroyed && a.HasTrait() && !a.Owner.NonCombatant); + } + + private IEnumerable UnitsNearExtractionLZ(Actor self, int range) + { + return UnitsNearActor(self, extractionLZ, range); + } + + private IEnumerable UnitsNearLab(Actor self, int range) + { + return UnitsNearActor(self, lab, range); + } + + private bool AlliesControlLab(Actor self) + { + var units = UnitsNearLab(self, labRange); + return units.Count() >= 1 && units.All(a => a.Owner.InternalName == allies.InternalName); + } + + private void SpawnEinsteinAtLab(Actor self) + { + einstein = self.World.CreateActor(einsteinName, new TypeDictionary { new OwnerInit(allies), new LocationInit(lab.Location) }); + } + + private void SendShips(Actor self) + { + for (int i = 0; i < ships.Length; i++) + { + var actor = self.World.CreateActor(ships[i], + new TypeDictionary { new OwnerInit(allies), new LocationInit(shipSpawnPoint.Location + new int2(i * 2, 0)) }); + actor.QueueActivity(new Move.Move(shipMovePoint.Location + new int2(i * 4, 0))); + } + } + + private void FlyFromExtractionLZ() + { + einsteinChinook.QueueActivity(new Wait(150)); + einsteinChinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); + einsteinChinook.QueueActivity(new RemoveSelf()); + } + + private void FlyToExtractionLZ(Actor self) + { + einsteinChinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZEntryPoint.Location) }); + einsteinChinook.QueueActivity(new HeliFly(extractionLZ.CenterLocation)); + einsteinChinook.QueueActivity(new Turn(0)); + einsteinChinook.QueueActivity(new HeliLand(true)); + } + + private void FlyTanyaToInsertionLZ(Actor self) + { + tanya = self.World.CreateActor(false, tanyaName, new TypeDictionary { new OwnerInit(allies) }); + FlyUnitsToInsertionLZ(self, new[] { tanya }); + } + + private void FlyUnitsToInsertionLZ(Actor self, IEnumerable unitNames) + { + var units = unitNames.Select(name => self.World.CreateActor(false, name, new TypeDictionary { new OwnerInit(allies) })); + FlyUnitsToInsertionLZ(self, units); + } + + private void FlyUnitsToInsertionLZ(Actor self, IEnumerable units) + { + var chinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(insertionLZEntryPoint.Location) }); + foreach (var unit in units) + { + chinook.Trait().Load(chinook, unit); + } + // use CenterLocation for HeliFly, Location for Move + chinook.QueueActivity(new HeliFly(insertionLZ.CenterLocation)); + chinook.QueueActivity(new Turn(0)); + chinook.QueueActivity(new HeliLand(true)); + chinook.QueueActivity(new UnloadCargo()); + chinook.QueueActivity(new Wait(150)); + chinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); + chinook.QueueActivity(new RemoveSelf()); + } + + public void WorldLoaded(World w) + { + allies = w.Players.Single(p => p.InternalName == "Allies"); + soviets = w.Players.Single(p => p.InternalName == "Soviets"); + var actors = w.WorldActor.Trait().Actors; + insertionLZ = actors["InsertionLZ"]; + extractionLZ = actors["ExtractionLZ"]; + lab = actors["Lab"]; + insertionLZEntryPoint = actors["InsertionLZEntryPoint"]; + chinookExitPoint = actors["ChinookExitPoint"]; + extractionLZEntryPoint = actors["ExtractionLZEntryPoint"]; + shipSpawnPoint = actors["ShipSpawnPoint"]; + shipMovePoint = actors["ShipMovePoint"]; + attackEntryPoint1 = actors["SovietAttackEntryPoint1"]; + attackEntryPoint2 = actors["SovietAttackEntryPoint2"]; + music = Sound.Play("hell226m.aud"); // Hell March + Game.ConnectionStateChanged += StopMusic; + } + + private void StopMusic(OrderManager orderManager) + { + if (!orderManager.GameStarted) + { + Sound.StopSound(music); + Game.ConnectionStateChanged -= StopMusic; + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 3c07c8ae01..d78e59a294 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -213,6 +213,7 @@ + diff --git a/mods/ra/maps/allies-01.oramap b/mods/ra/maps/allies-01.oramap new file mode 100644 index 0000000000000000000000000000000000000000..8e23ab172baf468f62b48bc6f7235ce0eb3fe0de GIT binary patch literal 2713 zcmZ{mc`zH=7sq1{K~h`nyLz;UmTGGW>YYn-Nv#-bbdDRaQ>7E8S*QH zprK^n8GAR+Zd1$0jlC{<_;&Tg%d$PP4vp)#lQ`I3ReVj>`uNSnn{vZwib#}<(jAPkZ?pSu0l7TI zP(HO;(McvyS6Vr}yPSLj{iQe;>*rzQQDGc_D6ms=-rpBV(5HeD50_4*t0EEPCi>c8 z;?r1W0Y1%>gS9bI$M)rZ0TG@0%3$m8lU$#so^5>R!Nkymyvktm2XuXg#HFnTe7}Gg z&Z0_)Wd=iWK7v~hyypDj<#uYw+)wV+nO0+qIxK37A{vwStNivI8o3N#y%C>8{T#4M z2aUpE)1RCW$%Tlr-mmN`xrSQco=&_C>>~{JBqq#H3qF6Ht5l7EwHhb28d(WYCEn?>6(m(53pc z#)jBjfxNqvr7vib38@;%^nP6edHY#-#zMJE(WtU6!+5SSiq3y1`<)T-`zFVYZkx|i zeaZq=#}CO&`)}Kz-{lI_%}%3zA%e4TZ16@u(ZA39$Yq^nI;T_M5A)MnomwTIOn9zc zE6+AP&pkC;%5zmWRog_{ROI9JgF#8jOG2I}a9rP&6VG_7X+@+B>?xA4(trAJ**|IT zbaDv3BY-+St1Z(~kYlH|bf<1G_+YSMP-ee-2t`QTABZ}^SqP@LtVtg9Lai-->IKs^ zUZ=$MEL|Si92k0fU1#LZ2DR)^V7<=BSKRlbRIKtc>+{%*rQx%5!>1Xs!}|Q_Q*~ho z@Xrr_056DYML9fSdHA=#yJJ-Nz16BrvCwWs*G2IdSncR>0Q}tNg8r|3{T)2qGw&mwj=&&lOLp;~&Td%JvN=*zohQY0%7Cqh8LI7r@4{C` zml}0^cqp-^QOfWly>`m;Ih^Ds@%Xc}nQnkxNwu=Z%9~e&%hNmO8U(Db;~U zPG%?6o!){4-jL=6LcnA!y?+XZ79$RRX(+>2SFKo5%;KRPdRXJeGclLMkrmRhpRR95I|VV&8tUX#9{JgxC&KhxE+)*s(J{kyyG zYQz;hqbZ3rW?K|zyfAQ!gH-#FC8$`L)Z#R-zWUpQPM{;|UUf`T-%;G_+n{zz7k0sR zp0#b12@QfDug%9*`d;o(#oAlzmJ@Z+Ip5T|E^IOnmE$ikVr=$c-lYYh!3w;)RgG{4 zCy|??u?dGjYC(uR8QXg+k34cUD5IVxGBLmWz=OZtbX_Ee)D%%+PiZ|fhT$Wh5u%#Y)Noc3Y zATv)cII~;d;P^c$9BTrn3UZvlCDSFR*`wsIE442>!o;0NYKl95%zy*wW1IZ!GCr3- zD`(M|e^+WD^ulqRUig09W5G@Vukx-`Q3Tf@&oRky$i3Ciaq``5EBsQjDrV zqLWL1`vQLxSs*nw2vgbo&5xH1MwH&a}>h>}|o0C9$x4 z=~v$2`3w{ac>HbSRxUN>H!m&j!narQj7&hn;}{3cKsRX1T`k7 zgPVhw($WoaN|}U_OY%-qBUk*ER-Q_m?G}Qxc#Mib`aV=>78~)OxW=K2@9TC()uQo| zW#)PUb-NT7(1*{k+^*6E>ejXFf{~I2%U@#8LjXvJi2oC!F{hDV+)(=0Ezb4CsH8kv1nPH zOu1Y&1}rZs{NZYutu3Vs6h6G(ASiR4A^-A*_BiB?ir%I(rIIFcW@~h?V6jX#^^VMp zxi6$}lFrGJTiV0qo9~QwfFG`qiL=DP+gomYuBUX^!uq~ zIbLO5JBwWd2(dOqKh?j%|2u2`4Q@L#kmttneDeI8%$NLxPX3JOtbg Date: Tue, 19 Jun 2012 01:04:18 +1200 Subject: [PATCH 2/9] Made Soviet attack waves a bit saner --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 36 +++++++++++------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index cd32a232b3..1bf7a49170 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -38,8 +38,6 @@ namespace OpenRA.Mods.RA.Missions private ISound music; private bool tanyaLanded; - private int frameLastAttackWave; - private int currentAttackWave; private Actor insertionLZ; private Actor extractionLZ; @@ -55,18 +53,15 @@ namespace OpenRA.Mods.RA.Missions private Actor attackEntryPoint1; private Actor attackEntryPoint2; - private Random random = new Random(); + private static readonly Random random = new Random(); private static readonly string[] taunts = { "laugh1.aud", "lefty1.aud", "cmon1.aud", "gotit1.aud" }; + private static readonly string[] ships = { "ca", "ca", "ca", "ca" }; - private static readonly string[][] attackWaves = new string[][] { - new[] { "e1", "e1", "e1", "e2", "e2", "dog" }, - new[] { "e1", "e1", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "dog" }, - new[] { "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "e2", "e2", "dog", "dog", "3tnk" }, - new[] { "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "e2", "e2", "dog", "dog", "e4", "e4", "3tnk", "3tnk" }, - }; - - private static readonly string[] reinforcements = { "e1", "e1", "e1", "e3", "e3" }; + private static readonly string[] attackWave = { "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "dog" }; + private int currentAttackWaveFrameNumber = -600; + private int currentAttackWave; + private const int einsteinChinookArrivesAtAttackWave = 5; private const int labRange = 5; private const int lzRange = 3; @@ -74,6 +69,11 @@ namespace OpenRA.Mods.RA.Missions private const string tanyaName = "e7"; private const string chinookName = "tran"; + private void NextObjective(int currentFrameNumber) + { + currentObjective++; + } + private void DisplayObjective(string text) { Game.AddChatLine(Color.LimeGreen, "Objective", text); @@ -139,9 +139,8 @@ namespace OpenRA.Mods.RA.Missions { SpawnEinsteinAtLab(self); // spawn Einstein once the area is clear Sound.Play("einok1.aud"); // "Incredible!" - Einstein - FlyUnitsToInsertionLZ(self, reinforcements); SendShips(self); - currentObjective++; + NextObjective(self.World.FrameNumber); DisplayObjective(objectives[currentObjective]); } if (lab.Destroyed) @@ -151,16 +150,15 @@ namespace OpenRA.Mods.RA.Missions } else if (currentObjective == 1) { - if (self.World.FrameNumber >= frameLastAttackWave + 600) + if (self.World.FrameNumber >= currentAttackWaveFrameNumber + 600) { - FlyUnitsToInsertionLZ(self, reinforcements); - SendAttackWave(self, attackWaves[Math.Min(currentAttackWave, attackWaves.Length - 1)]); - if (currentAttackWave == attackWaves.Length - 1) + SendAttackWave(self, attackWave); + currentAttackWave++; + currentAttackWaveFrameNumber = self.World.FrameNumber; + if (currentAttackWave == einsteinChinookArrivesAtAttackWave) { FlyToExtractionLZ(self); } - currentAttackWave++; - frameLastAttackWave = self.World.FrameNumber; } if (einsteinChinook != null) { From f5d397030cc5ff395e292dcdd7cbf8370b62d44a Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Tue, 19 Jun 2012 01:19:09 +1200 Subject: [PATCH 3/9] Remove unneeded UnitsNearExtractionLZ code --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index 1bf7a49170..1625160cc5 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -69,14 +69,14 @@ namespace OpenRA.Mods.RA.Missions private const string tanyaName = "e7"; private const string chinookName = "tran"; - private void NextObjective(int currentFrameNumber) + private void NextObjective() { currentObjective++; } - private void DisplayObjective(string text) + private void DisplayObjective() { - Game.AddChatLine(Color.LimeGreen, "Objective", text); + Game.AddChatLine(Color.LimeGreen, "Objective", objectives[currentObjective]); } private void MissionFailed(Actor self, string text) @@ -114,7 +114,7 @@ namespace OpenRA.Mods.RA.Missions // display current objective every so often if (self.World.FrameNumber % 1500 == 1) { - DisplayObjective(objectives[currentObjective]); + DisplayObjective(); } // taunt every so often if (self.World.FrameNumber % 1000 == 0) @@ -140,8 +140,8 @@ namespace OpenRA.Mods.RA.Missions SpawnEinsteinAtLab(self); // spawn Einstein once the area is clear Sound.Play("einok1.aud"); // "Incredible!" - Einstein SendShips(self); - NextObjective(self.World.FrameNumber); - DisplayObjective(objectives[currentObjective]); + NextObjective(); + DisplayObjective(); } if (lab.Destroyed) { @@ -164,7 +164,7 @@ namespace OpenRA.Mods.RA.Missions { if (einsteinChinook.Trait().Passengers.Contains(einstein)) { - FlyFromExtractionLZ(); + FlyEinsteinFromExtractionLZ(); } if (UnitsNearActor(self, chinookExitPoint, 5).Contains(einsteinChinook) && !einstein.IsInWorld) { @@ -199,11 +199,6 @@ namespace OpenRA.Mods.RA.Missions .Where(a => a.IsInWorld && a != self.World.WorldActor && !a.Destroyed && a.HasTrait() && !a.Owner.NonCombatant); } - private IEnumerable UnitsNearExtractionLZ(Actor self, int range) - { - return UnitsNearActor(self, extractionLZ, range); - } - private IEnumerable UnitsNearLab(Actor self, int range) { return UnitsNearActor(self, lab, range); @@ -230,7 +225,7 @@ namespace OpenRA.Mods.RA.Missions } } - private void FlyFromExtractionLZ() + private void FlyEinsteinFromExtractionLZ() { einsteinChinook.QueueActivity(new Wait(150)); einsteinChinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); From ce05b8dfeccfa0eb3e7db7ba8f5217265fd44798 Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Tue, 19 Jun 2012 01:27:42 +1200 Subject: [PATCH 4/9] Use IsInMap & IsInWorld to detect whether Einstein has been saved --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index 1625160cc5..5ad0aa72c1 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -166,7 +166,7 @@ namespace OpenRA.Mods.RA.Missions { FlyEinsteinFromExtractionLZ(); } - if (UnitsNearActor(self, chinookExitPoint, 5).Contains(einsteinChinook) && !einstein.IsInWorld) + if (!self.World.Map.IsInMap(einsteinChinook.Location) && !einstein.IsInWorld) { MissionAccomplished(self, "Einstein was rescued."); } From 11ddd88d605edb428b429e866dcc5ef598bec0c4 Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Tue, 19 Jun 2012 01:45:46 +1200 Subject: [PATCH 5/9] Remove more unneeded code, use CallFunc activity to make Tanya laugh when she disembarks. --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 32 +++-------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index 5ad0aa72c1..27cebd711f 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -37,8 +37,6 @@ namespace OpenRA.Mods.RA.Missions private ISound music; - private bool tanyaLanded; - private Actor insertionLZ; private Actor extractionLZ; private Actor lab; @@ -126,12 +124,6 @@ namespace OpenRA.Mods.RA.Missions { FlyTanyaToInsertionLZ(self); } - // laugh when Tanya arrives at the LZ - if (tanya.IsInWorld && !tanyaLanded) - { - Sound.Play("laugh1.aud"); // "Hahaha" - Tanya - tanyaLanded = true; - } // objectives if (currentObjective == 0) { @@ -199,14 +191,9 @@ namespace OpenRA.Mods.RA.Missions .Where(a => a.IsInWorld && a != self.World.WorldActor && !a.Destroyed && a.HasTrait() && !a.Owner.NonCombatant); } - private IEnumerable UnitsNearLab(Actor self, int range) - { - return UnitsNearActor(self, lab, range); - } - private bool AlliesControlLab(Actor self) { - var units = UnitsNearLab(self, labRange); + var units = UnitsNearActor(self, lab, labRange); return units.Count() >= 1 && units.All(a => a.Owner.InternalName == allies.InternalName); } @@ -243,27 +230,14 @@ namespace OpenRA.Mods.RA.Missions private void FlyTanyaToInsertionLZ(Actor self) { tanya = self.World.CreateActor(false, tanyaName, new TypeDictionary { new OwnerInit(allies) }); - FlyUnitsToInsertionLZ(self, new[] { tanya }); - } - - private void FlyUnitsToInsertionLZ(Actor self, IEnumerable unitNames) - { - var units = unitNames.Select(name => self.World.CreateActor(false, name, new TypeDictionary { new OwnerInit(allies) })); - FlyUnitsToInsertionLZ(self, units); - } - - private void FlyUnitsToInsertionLZ(Actor self, IEnumerable units) - { var chinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(insertionLZEntryPoint.Location) }); - foreach (var unit in units) - { - chinook.Trait().Load(chinook, unit); - } + chinook.Trait().Load(chinook, tanya); // use CenterLocation for HeliFly, Location for Move chinook.QueueActivity(new HeliFly(insertionLZ.CenterLocation)); chinook.QueueActivity(new Turn(0)); chinook.QueueActivity(new HeliLand(true)); chinook.QueueActivity(new UnloadCargo()); + chinook.QueueActivity(new CallFunc(() => Sound.Play("laugh1.aud"))); chinook.QueueActivity(new Wait(150)); chinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); chinook.QueueActivity(new RemoveSelf()); From b0e10c9ada550c138052a3a6edcd72aaa69a534d Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Tue, 19 Jun 2012 12:57:45 +1200 Subject: [PATCH 6/9] Don't need lzRange --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index 27cebd711f..c9b20c1378 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -62,7 +62,6 @@ namespace OpenRA.Mods.RA.Missions private const int einsteinChinookArrivesAtAttackWave = 5; private const int labRange = 5; - private const int lzRange = 3; private const string einsteinName = "c1"; private const string tanyaName = "e7"; private const string chinookName = "tran"; From b30e4ab4324891382b41cae9d119942b84180aa6 Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Tue, 19 Jun 2012 14:43:11 +1200 Subject: [PATCH 7/9] Use SharedRandom to stop desync --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index c9b20c1378..331a09ab56 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -51,7 +51,6 @@ namespace OpenRA.Mods.RA.Missions private Actor attackEntryPoint1; private Actor attackEntryPoint2; - private static readonly Random random = new Random(); private static readonly string[] taunts = { "laugh1.aud", "lefty1.aud", "cmon1.aud", "gotit1.aud" }; private static readonly string[] ships = { "ca", "ca", "ca", "ca" }; @@ -116,7 +115,7 @@ namespace OpenRA.Mods.RA.Missions // taunt every so often if (self.World.FrameNumber % 1000 == 0) { - Sound.Play(taunts[random.Next(0, taunts.Length)]); + Sound.Play(taunts[self.World.SharedRandom.Next(taunts.Length)]); } // take Tanya to the LZ if (self.World.FrameNumber == 1) @@ -177,8 +176,8 @@ namespace OpenRA.Mods.RA.Missions { foreach (var unit in wave) { - var spawnActor = random.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2; - var targetActor = random.Next(2) == 0 ? einstein : tanya; + var spawnActor = self.World.SharedRandom.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2; + var targetActor = self.World.SharedRandom.Next(2) == 0 ? einstein : tanya; var actor = self.World.CreateActor(unit, new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnActor.Location) }); actor.QueueActivity(new Attack(Target.FromActor(targetActor), 2)); } @@ -193,7 +192,7 @@ namespace OpenRA.Mods.RA.Missions private bool AlliesControlLab(Actor self) { var units = UnitsNearActor(self, lab, labRange); - return units.Count() >= 1 && units.All(a => a.Owner.InternalName == allies.InternalName); + return units.Count() >= 1 && units.All(a => a.Owner == allies); } private void SpawnEinsteinAtLab(Actor self) From cb3daab5fa469e488835b0ab4cee8c8f39e994e4 Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Wed, 20 Jun 2012 17:48:03 +1200 Subject: [PATCH 8/9] Tabify lines --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 451 +++++++++++----------- 1 file changed, 225 insertions(+), 226 deletions(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index 331a09ab56..bd38412637 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -8,7 +8,6 @@ */ #endregion -using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -20,253 +19,253 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Missions { - public class Allies01ScriptInfo : TraitInfo, Requires { } + public class Allies01ScriptInfo : TraitInfo, Requires { } - public class Allies01Script : IWorldLoaded, ITick - { - private string[] objectives = - { - "Find Einstein.", - "Wait for the helicopter and extract Einstein." - }; + public class Allies01Script : IWorldLoaded, ITick + { + private string[] objectives = + { + "Find Einstein.", + "Wait for the helicopter and extract Einstein." + }; - private int currentObjective; + private int currentObjective; - private Player allies; - private Player soviets; + private Player allies; + private Player soviets; - private ISound music; + private ISound music; - private Actor insertionLZ; - private Actor extractionLZ; - private Actor lab; - private Actor insertionLZEntryPoint; - private Actor extractionLZEntryPoint; - private Actor chinookExitPoint; - private Actor shipSpawnPoint; - private Actor shipMovePoint; - private Actor einstein; - private Actor einsteinChinook; - private Actor tanya; - private Actor attackEntryPoint1; - private Actor attackEntryPoint2; + private Actor insertionLZ; + private Actor extractionLZ; + private Actor lab; + private Actor insertionLZEntryPoint; + private Actor extractionLZEntryPoint; + private Actor chinookExitPoint; + private Actor shipSpawnPoint; + private Actor shipMovePoint; + private Actor einstein; + private Actor einsteinChinook; + private Actor tanya; + private Actor attackEntryPoint1; + private Actor attackEntryPoint2; - private static readonly string[] taunts = { "laugh1.aud", "lefty1.aud", "cmon1.aud", "gotit1.aud" }; + private static readonly string[] taunts = { "laugh1.aud", "lefty1.aud", "cmon1.aud", "gotit1.aud" }; - private static readonly string[] ships = { "ca", "ca", "ca", "ca" }; + private static readonly string[] ships = { "ca", "ca", "ca", "ca" }; - private static readonly string[] attackWave = { "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "dog" }; - private int currentAttackWaveFrameNumber = -600; - private int currentAttackWave; - private const int einsteinChinookArrivesAtAttackWave = 5; + private static readonly string[] attackWave = { "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2", "dog" }; + private int currentAttackWaveFrameNumber = -600; + private int currentAttackWave; + private const int einsteinChinookArrivesAtAttackWave = 5; - private const int labRange = 5; - private const string einsteinName = "c1"; - private const string tanyaName = "e7"; - private const string chinookName = "tran"; + private const int labRange = 5; + private const string einsteinName = "c1"; + private const string tanyaName = "e7"; + private const string chinookName = "tran"; - private void NextObjective() - { - currentObjective++; - } + private void NextObjective() + { + currentObjective++; + } - private void DisplayObjective() - { - Game.AddChatLine(Color.LimeGreen, "Objective", objectives[currentObjective]); - } + private void DisplayObjective() + { + Game.AddChatLine(Color.LimeGreen, "Objective", objectives[currentObjective]); + } - private void MissionFailed(Actor self, string text) - { - if (allies.WinState != WinState.Undefined) - { - return; - } - allies.WinState = WinState.Lost; - Game.AddChatLine(Color.Red, "Mission failed", text); - foreach (var actor in self.World.Actors.Where(a => a.Owner.InternalName == allies.InternalName)) - { - actor.Kill(actor); - } - self.World.LocalShroud.Disabled = true; - } + private void MissionFailed(Actor self, string text) + { + if (allies.WinState != WinState.Undefined) + { + return; + } + allies.WinState = WinState.Lost; + Game.AddChatLine(Color.Red, "Mission failed", text); + foreach (var actor in self.World.Actors.Where(a => a.Owner.InternalName == allies.InternalName)) + { + actor.Kill(actor); + } + self.World.LocalShroud.Disabled = true; + } - private void MissionAccomplished(Actor self, string text) - { - if (allies.WinState != WinState.Undefined) - { - return; - } - allies.WinState = WinState.Won; - Game.AddChatLine(Color.Blue, "Mission accomplished", text); - self.World.LocalShroud.Disabled = true; - } + private void MissionAccomplished(Actor self, string text) + { + if (allies.WinState != WinState.Undefined) + { + return; + } + allies.WinState = WinState.Won; + Game.AddChatLine(Color.Blue, "Mission accomplished", text); + self.World.LocalShroud.Disabled = true; + } - public void Tick(Actor self) - { - if (allies.WinState != WinState.Undefined) - { - return; - } - // display current objective every so often - if (self.World.FrameNumber % 1500 == 1) - { - DisplayObjective(); - } - // taunt every so often - if (self.World.FrameNumber % 1000 == 0) - { - Sound.Play(taunts[self.World.SharedRandom.Next(taunts.Length)]); - } - // take Tanya to the LZ - if (self.World.FrameNumber == 1) - { - FlyTanyaToInsertionLZ(self); - } - // objectives - if (currentObjective == 0) - { - if (AlliesControlLab(self)) - { - SpawnEinsteinAtLab(self); // spawn Einstein once the area is clear - Sound.Play("einok1.aud"); // "Incredible!" - Einstein - SendShips(self); - NextObjective(); - DisplayObjective(); - } - if (lab.Destroyed) - { - MissionFailed(self, "Einstein was killed."); - } - } - else if (currentObjective == 1) - { - if (self.World.FrameNumber >= currentAttackWaveFrameNumber + 600) - { - SendAttackWave(self, attackWave); - currentAttackWave++; - currentAttackWaveFrameNumber = self.World.FrameNumber; - if (currentAttackWave == einsteinChinookArrivesAtAttackWave) - { - FlyToExtractionLZ(self); - } - } - if (einsteinChinook != null) - { - if (einsteinChinook.Trait().Passengers.Contains(einstein)) - { - FlyEinsteinFromExtractionLZ(); - } - if (!self.World.Map.IsInMap(einsteinChinook.Location) && !einstein.IsInWorld) - { - MissionAccomplished(self, "Einstein was rescued."); - } - } - if (einstein.Destroyed) - { - MissionFailed(self, "Einstein was killed."); - } - } - if (tanya.Destroyed) - { - MissionFailed(self, "Tanya was killed."); - } - } + public void Tick(Actor self) + { + if (allies.WinState != WinState.Undefined) + { + return; + } + // display current objective every so often + if (self.World.FrameNumber % 1500 == 1) + { + DisplayObjective(); + } + // taunt every so often + if (self.World.FrameNumber % 1000 == 0) + { + Sound.Play(taunts[self.World.SharedRandom.Next(taunts.Length)]); + } + // take Tanya to the LZ + if (self.World.FrameNumber == 1) + { + FlyTanyaToInsertionLZ(self); + } + // objectives + if (currentObjective == 0) + { + if (AlliesControlLab(self)) + { + SpawnEinsteinAtLab(self); // spawn Einstein once the area is clear + Sound.Play("einok1.aud"); // "Incredible!" - Einstein + SendShips(self); + NextObjective(); + DisplayObjective(); + } + if (lab.Destroyed) + { + MissionFailed(self, "Einstein was killed."); + } + } + else if (currentObjective == 1) + { + if (self.World.FrameNumber >= currentAttackWaveFrameNumber + 600) + { + SendAttackWave(self, attackWave); + currentAttackWave++; + currentAttackWaveFrameNumber = self.World.FrameNumber; + if (currentAttackWave == einsteinChinookArrivesAtAttackWave) + { + FlyToExtractionLZ(self); + } + } + if (einsteinChinook != null) + { + if (einsteinChinook.Trait().Passengers.Contains(einstein)) + { + FlyEinsteinFromExtractionLZ(); + } + if (!self.World.Map.IsInMap(einsteinChinook.Location) && !einstein.IsInWorld) + { + MissionAccomplished(self, "Einstein was rescued."); + } + } + if (einstein.Destroyed) + { + MissionFailed(self, "Einstein was killed."); + } + } + if (tanya.Destroyed) + { + MissionFailed(self, "Tanya was killed."); + } + } - private void SendAttackWave(Actor self, IEnumerable wave) - { - foreach (var unit in wave) - { - var spawnActor = self.World.SharedRandom.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2; - var targetActor = self.World.SharedRandom.Next(2) == 0 ? einstein : tanya; - var actor = self.World.CreateActor(unit, new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnActor.Location) }); - actor.QueueActivity(new Attack(Target.FromActor(targetActor), 2)); - } - } + private void SendAttackWave(Actor self, IEnumerable wave) + { + foreach (var unit in wave) + { + var spawnActor = self.World.SharedRandom.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2; + var targetActor = self.World.SharedRandom.Next(2) == 0 ? einstein : tanya; + var actor = self.World.CreateActor(unit, new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnActor.Location) }); + actor.QueueActivity(new Attack(Target.FromActor(targetActor), 2)); + } + } - private IEnumerable UnitsNearActor(Actor self, Actor actor, int range) - { - return self.World.FindUnitsInCircle(actor.CenterLocation, Game.CellSize * range) - .Where(a => a.IsInWorld && a != self.World.WorldActor && !a.Destroyed && a.HasTrait() && !a.Owner.NonCombatant); - } + private IEnumerable UnitsNearActor(Actor self, Actor actor, int range) + { + return self.World.FindUnitsInCircle(actor.CenterLocation, Game.CellSize * range) + .Where(a => a.IsInWorld && a != self.World.WorldActor && !a.Destroyed && a.HasTrait() && !a.Owner.NonCombatant); + } - private bool AlliesControlLab(Actor self) - { - var units = UnitsNearActor(self, lab, labRange); - return units.Count() >= 1 && units.All(a => a.Owner == allies); - } + private bool AlliesControlLab(Actor self) + { + var units = UnitsNearActor(self, lab, labRange); + return units.Count() >= 1 && units.All(a => a.Owner == allies); + } - private void SpawnEinsteinAtLab(Actor self) - { - einstein = self.World.CreateActor(einsteinName, new TypeDictionary { new OwnerInit(allies), new LocationInit(lab.Location) }); - } + private void SpawnEinsteinAtLab(Actor self) + { + einstein = self.World.CreateActor(einsteinName, new TypeDictionary { new OwnerInit(allies), new LocationInit(lab.Location) }); + } - private void SendShips(Actor self) - { - for (int i = 0; i < ships.Length; i++) - { - var actor = self.World.CreateActor(ships[i], - new TypeDictionary { new OwnerInit(allies), new LocationInit(shipSpawnPoint.Location + new int2(i * 2, 0)) }); - actor.QueueActivity(new Move.Move(shipMovePoint.Location + new int2(i * 4, 0))); - } - } + private void SendShips(Actor self) + { + for (int i = 0; i < ships.Length; i++) + { + var actor = self.World.CreateActor(ships[i], + new TypeDictionary { new OwnerInit(allies), new LocationInit(shipSpawnPoint.Location + new int2(i * 2, 0)) }); + actor.QueueActivity(new Move.Move(shipMovePoint.Location + new int2(i * 4, 0))); + } + } - private void FlyEinsteinFromExtractionLZ() - { - einsteinChinook.QueueActivity(new Wait(150)); - einsteinChinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); - einsteinChinook.QueueActivity(new RemoveSelf()); - } + private void FlyEinsteinFromExtractionLZ() + { + einsteinChinook.QueueActivity(new Wait(150)); + einsteinChinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); + einsteinChinook.QueueActivity(new RemoveSelf()); + } - private void FlyToExtractionLZ(Actor self) - { - einsteinChinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZEntryPoint.Location) }); - einsteinChinook.QueueActivity(new HeliFly(extractionLZ.CenterLocation)); - einsteinChinook.QueueActivity(new Turn(0)); - einsteinChinook.QueueActivity(new HeliLand(true)); - } + private void FlyToExtractionLZ(Actor self) + { + einsteinChinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZEntryPoint.Location) }); + einsteinChinook.QueueActivity(new HeliFly(extractionLZ.CenterLocation)); + einsteinChinook.QueueActivity(new Turn(0)); + einsteinChinook.QueueActivity(new HeliLand(true)); + } - private void FlyTanyaToInsertionLZ(Actor self) - { - tanya = self.World.CreateActor(false, tanyaName, new TypeDictionary { new OwnerInit(allies) }); - var chinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(insertionLZEntryPoint.Location) }); - chinook.Trait().Load(chinook, tanya); - // use CenterLocation for HeliFly, Location for Move - chinook.QueueActivity(new HeliFly(insertionLZ.CenterLocation)); - chinook.QueueActivity(new Turn(0)); - chinook.QueueActivity(new HeliLand(true)); - chinook.QueueActivity(new UnloadCargo()); - chinook.QueueActivity(new CallFunc(() => Sound.Play("laugh1.aud"))); - chinook.QueueActivity(new Wait(150)); - chinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); - chinook.QueueActivity(new RemoveSelf()); - } + private void FlyTanyaToInsertionLZ(Actor self) + { + tanya = self.World.CreateActor(false, tanyaName, new TypeDictionary { new OwnerInit(allies) }); + var chinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(insertionLZEntryPoint.Location) }); + chinook.Trait().Load(chinook, tanya); + // use CenterLocation for HeliFly, Location for Move + chinook.QueueActivity(new HeliFly(insertionLZ.CenterLocation)); + chinook.QueueActivity(new Turn(0)); + chinook.QueueActivity(new HeliLand(true)); + chinook.QueueActivity(new UnloadCargo()); + chinook.QueueActivity(new CallFunc(() => Sound.Play("laugh1.aud"))); + chinook.QueueActivity(new Wait(150)); + chinook.QueueActivity(new HeliFly(chinookExitPoint.CenterLocation)); + chinook.QueueActivity(new RemoveSelf()); + } - public void WorldLoaded(World w) - { - allies = w.Players.Single(p => p.InternalName == "Allies"); - soviets = w.Players.Single(p => p.InternalName == "Soviets"); - var actors = w.WorldActor.Trait().Actors; - insertionLZ = actors["InsertionLZ"]; - extractionLZ = actors["ExtractionLZ"]; - lab = actors["Lab"]; - insertionLZEntryPoint = actors["InsertionLZEntryPoint"]; - chinookExitPoint = actors["ChinookExitPoint"]; - extractionLZEntryPoint = actors["ExtractionLZEntryPoint"]; - shipSpawnPoint = actors["ShipSpawnPoint"]; - shipMovePoint = actors["ShipMovePoint"]; - attackEntryPoint1 = actors["SovietAttackEntryPoint1"]; - attackEntryPoint2 = actors["SovietAttackEntryPoint2"]; - music = Sound.Play("hell226m.aud"); // Hell March - Game.ConnectionStateChanged += StopMusic; - } + public void WorldLoaded(World w) + { + allies = w.Players.Single(p => p.InternalName == "Allies"); + soviets = w.Players.Single(p => p.InternalName == "Soviets"); + var actors = w.WorldActor.Trait().Actors; + insertionLZ = actors["InsertionLZ"]; + extractionLZ = actors["ExtractionLZ"]; + lab = actors["Lab"]; + insertionLZEntryPoint = actors["InsertionLZEntryPoint"]; + chinookExitPoint = actors["ChinookExitPoint"]; + extractionLZEntryPoint = actors["ExtractionLZEntryPoint"]; + shipSpawnPoint = actors["ShipSpawnPoint"]; + shipMovePoint = actors["ShipMovePoint"]; + attackEntryPoint1 = actors["SovietAttackEntryPoint1"]; + attackEntryPoint2 = actors["SovietAttackEntryPoint2"]; + music = Sound.Play("hell226m.aud"); // Hell March + Game.ConnectionStateChanged += StopMusic; + } - private void StopMusic(OrderManager orderManager) - { - if (!orderManager.GameStarted) - { - Sound.StopSound(music); - Game.ConnectionStateChanged -= StopMusic; - } - } - } + private void StopMusic(OrderManager orderManager) + { + if (!orderManager.GameStarted) + { + Sound.StopSound(music); + Game.ConnectionStateChanged -= StopMusic; + } + } + } } From 8f6b8b75bc91a9e6b697ba0c54d9c404d61c9b9e Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Wed, 20 Jun 2012 18:17:13 +1200 Subject: [PATCH 9/9] Remove redundant call to InternalName when mission failed --- OpenRA.Mods.RA/Missions/Allies01Script.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Missions/Allies01Script.cs b/OpenRA.Mods.RA/Missions/Allies01Script.cs index bd38412637..9712484eb0 100644 --- a/OpenRA.Mods.RA/Missions/Allies01Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies01Script.cs @@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Missions } allies.WinState = WinState.Lost; Game.AddChatLine(Color.Red, "Mission failed", text); - foreach (var actor in self.World.Actors.Where(a => a.Owner.InternalName == allies.InternalName)) + foreach (var actor in self.World.Actors.Where(a => a.Owner == allies)) { actor.Kill(actor); }