From 2a053daa2ee3ae29ee0b33017a3497e230b20170 Mon Sep 17 00:00:00 2001 From: Scott_NZ Date: Sun, 12 Aug 2012 21:21:33 +1200 Subject: [PATCH] Add Soviet attacks, scrap chinook timer since we might have pathing issues if Tanya is on the island and we have off-map attacks. Counter this by bringing back reinforcements timer --- OpenRA.Mods.RA/Missions/Allies02Script.cs | 76 ++++++++++++++++++---- mods/ra/maps/allies-02/map.bin | Bin 81925 -> 81925 bytes mods/ra/maps/allies-02/map.yaml | 46 +++++-------- 3 files changed, 81 insertions(+), 41 deletions(-) diff --git a/OpenRA.Mods.RA/Missions/Allies02Script.cs b/OpenRA.Mods.RA/Missions/Allies02Script.cs index 375b9035d3..01a273ea05 100644 --- a/OpenRA.Mods.RA/Missions/Allies02Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies02Script.cs @@ -15,6 +15,7 @@ using System.Linq; using OpenRA.FileFormats; using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Air; +using OpenRA.Mods.RA.Buildings; using OpenRA.Traits; using OpenRA.Widgets; @@ -56,7 +57,16 @@ namespace OpenRA.Mods.RA.Missions Player allies2; Player soviets; + Actor sovietBarracks; + Actor sovietWarFactory; + + const string InfantryQueueName = "Infantry"; + const string VehicleQueueName = "Vehicle"; + static readonly string[] sovietInfantry = { "e1", "e2", "e3", "dog" }; + static readonly string[] sovietVehicles = { "3tnk", "v2rl" }; + static readonly string[] reinforcements = { "1tnk", "1tnk", "jeep", "mcv" }; + const string ChinookName = "tran"; const string SignalFlareName = "flare"; const string EngineerName = "e6"; @@ -96,9 +106,13 @@ namespace OpenRA.Mods.RA.Missions { DisplayObjective(); } - if (world.FrameNumber == 200) + if (world.FrameNumber == 25 * 10) { - SendReinforcements(); + StartReinforcementsTimer(); + } + if (world.FrameNumber % 25 == 0) + { + BuildSovietUnits(); } if (!engineerMiss.Destroyed && engineer == null && AlliesControlMiss()) { @@ -113,7 +127,7 @@ namespace OpenRA.Mods.RA.Missions DisplayObjective(); SpawnSignalFlare(); Sound.Play("flaren1.aud"); - StartChinookTimer(); + SendChinook(); } } else if (currentObjective == 1) @@ -133,14 +147,48 @@ namespace OpenRA.Mods.RA.Missions } } - void InitializeSovietAI() + void BuildSovietUnits() { - if (!Game.IsHost) + var powerManager = soviets.PlayerActor.Trait(); + if (powerManager.ExcessPower < 0) { return; } - var logic = world.LocalPlayer.PlayerActor.TraitsImplementing().First(b => b.Info.Name == "Soviet AI"); - logic.Activate(soviets); + if (!sovietBarracks.Destroyed) + { + BuildUnitIfQueueIdle(soviets, InfantryQueueName, sovietInfantry[world.SharedRandom.Next(sovietInfantry.Length)]); + } + if (!sovietWarFactory.Destroyed) + { + BuildUnitIfQueueIdle(soviets, VehicleQueueName, sovietVehicles[world.SharedRandom.Next(sovietVehicles.Length)]); + } + } + + void InitializeSoviets() + { + var res = soviets.PlayerActor.Trait(); + res.GiveCash(100000); + sovietBarracks.Trait().rallyPoint = allies2BasePoint.Location; + sovietWarFactory.Trait().rallyPoint = allies2BasePoint.Location; + sovietBarracks.Trait().SetPrimaryProducer(sovietBarracks, true); + sovietWarFactory.Trait().SetPrimaryProducer(sovietWarFactory, true); + } + + IEnumerable FindQueues(Player player, string category) + { + return world.ActorsWithTrait() + .Where(a => a.Actor.Owner == player && a.Trait.Info.Type == category) + .Select(a => a.Trait); + } + + void BuildUnitIfQueueIdle(Player player, string category, string unit) + { + var queue = FindQueues(player, category).FirstOrDefault(q => q.CurrentItem() == null); + if (queue == null) + { + return; + } + world.IssueOrder(Order.StartProduction(queue.self, unit, 1)); } void SpawnSignalFlare() @@ -148,17 +196,17 @@ namespace OpenRA.Mods.RA.Missions world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies1), new LocationInit(extractionLZ.Location) }); } - void StartChinookTimer() + void StartReinforcementsTimer() { - var timer = new CountdownTimerWidget("Extraction arrives in", 1500 * 6, ChinookTimerExpired, new float2(128, 96)); + Sound.Play("timergo1.aud"); + var timer = new CountdownTimerWidget("Reinforcements arrive in", 1500 * 12, ReinforcementsTimerExpired, new float2(128, 96)); Ui.Root.AddChild(timer); } - void ChinookTimerExpired(CountdownTimerWidget timer) + void ReinforcementsTimerExpired(CountdownTimerWidget timer) { - Sound.Play("reinfor1.aud"); timer.Visible = false; - SendChinook(); + SendReinforcements(); } void SendReinforcements() @@ -225,12 +273,14 @@ namespace OpenRA.Mods.RA.Missions extractionLZ = actors["ExtractionLZ"]; extractionLZEntryPoint = actors["ExtractionLZEntryPoint"]; engineerMiss = actors["EngineerMiss"]; + sovietBarracks = actors["SovietBarracks"]; + sovietWarFactory = actors["SovietWarFactory"]; w.WorldActor.Trait().Explore(w, sam1.Location, 2); w.WorldActor.Trait().Explore(w, sam2.Location, 2); w.WorldActor.Trait().Explore(w, sam3.Location, 2); w.WorldActor.Trait().Explore(w, sam4.Location, 2); Game.MoveViewport(((w.LocalPlayer ?? allies1) == allies1 ? chinookHusk.Location : allies2BasePoint.Location).ToFloat2()); - InitializeSovietAI(); + InitializeSoviets(); } } diff --git a/mods/ra/maps/allies-02/map.bin b/mods/ra/maps/allies-02/map.bin index cbfc523d1ab15368ed8e724d67be00de70e8e5dc..a8a343985c03896d95b35524f1a062f6ed609ad2 100644 GIT binary patch delta 417 zcmXYtODIHP9L4{4X71(c)|HyVh;JB7ZYJ_dVKOE1iqe!kHbROiva( zdCXi}7h%D|l_}#D*;ul$7Bf+&vpc8rJ2OFXCMX`9<#0BJGS?Sp61=slv`@580-QBY z&N}d&rQkgG1-)(s$38nYyk5@guoslkmVb}eW)c4SG`MOVob_R7Nx_Z#2?vuhyo(aL z+$xS+?VJtZb6ZAB!5cD0RJ1nAXv#}Lmo|jq9Thj)3swRuK7BIgb4oaCLUo26orSk> zbvlv^B7>|3Nji6q!!sqr^ecGqnA$a2uStrMHB1yHOPFjS5<+oL2vIC27-TajK_@{+ zn>PACJGM*9M8i@Fj`~$B6akMuH7gu%5kqA8A^MX+7K22C5_Ph~^6tPtpM>Of2R@1q z5zS2HYz`Cc3f5*N>~6~FE;++{RqTyr6mH3QEPe@c@9Gv&|?XyoFtZs-)%Jzl2M&gp>DuRDv=^!hLUV=bTk`hlrm%yO*&~{Sr zYc6_G5yey5zSr$-U~QK=>{ha*D8kY`4;?y1eUA->IsASz!%Qw4&Sk@IiftT93e~vC zRQoT(Pfpez|_Cq+?Zp z3il@xO3w3QS8)7BRY_Zv5Guj0AjFYGoMU&KApX&wwsoEJd%A_IZBIGW+QfU^-x#?c z=lW8FV;L=*WAeFR`L4s0WSPtJF}pU0QU z%pzs~lm9(!Hf*)