From 438b2240f4122e5ea7015a37ae687693ec1be72e Mon Sep 17 00:00:00 2001 From: Smittytron Date: Fri, 19 Feb 2021 17:32:24 -0600 Subject: [PATCH] Add AI infantry production to Soviet02a --- mods/ra/maps/soviet-02a/map.yaml | 2 +- mods/ra/maps/soviet-02a/rules.yaml | 2 +- mods/ra/maps/soviet-02a/soviet02a.lua | 36 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mods/ra/maps/soviet-02a/map.yaml b/mods/ra/maps/soviet-02a/map.yaml index 7272d09939..324ceae1f8 100644 --- a/mods/ra/maps/soviet-02a/map.yaml +++ b/mods/ra/maps/soviet-02a/map.yaml @@ -161,7 +161,7 @@ Actors: Actor40: powr Location: 36,52 Owner: Greece - Actor41: tent + Tent: tent Location: 41,58 Owner: Greece Actor42: gun diff --git a/mods/ra/maps/soviet-02a/rules.yaml b/mods/ra/maps/soviet-02a/rules.yaml index 35ee82bddb..d7e4ded2cb 100644 --- a/mods/ra/maps/soviet-02a/rules.yaml +++ b/mods/ra/maps/soviet-02a/rules.yaml @@ -58,7 +58,7 @@ MSLO: E3: Buildable: - Prerequisites: ~disabled + Prerequisites: ~tent E4: Buildable: diff --git a/mods/ra/maps/soviet-02a/soviet02a.lua b/mods/ra/maps/soviet-02a/soviet02a.lua index b1757dab87..703828b9f0 100644 --- a/mods/ra/maps/soviet-02a/soviet02a.lua +++ b/mods/ra/maps/soviet-02a/soviet02a.lua @@ -13,6 +13,39 @@ CmdAtk = { Attacker1, Attacker2, Attacker3, Attacker4 } FleeingUnits = { Fleeing1, Fleeing2 } HuntingUnits = { Hunter1, Hunter2, Hunter3, Hunter4 } +AttackWaypoints = { AttackWaypoint1, AttackWaypoint2 } +AttackGroup = { } +AttackGroupSize = 3 +AlliedInfantry = { "e1", "e1", "e3" } + +SendAttackGroup = function() + if #AttackGroup < AttackGroupSize then + return + end + + local way = Utils.Random(AttackWaypoints) + Utils.Do(AttackGroup, function(unit) + if not unit.IsDead then + unit.AttackMove(way.Location) + Trigger.OnIdle(unit, unit.Hunt) + end + end) + + AttackGroup = { } +end + +ProduceInfantry = function() + if Tent.IsDead then + return + end + + greece.Build({ Utils.Random(AlliedInfantry) }, function(units) + table.insert(AttackGroup, units[1]) + SendAttackGroup() + Trigger.AfterDelay(DateTime.Seconds(10), ProduceInfantry) + end) +end + WorldLoaded = function() player = Player.GetPlayer("USSR") greece = Player.GetPlayer("Greece") @@ -127,6 +160,9 @@ WorldLoaded = function() powerproxy.TargetParatroopers(ParadropLZ.CenterPosition, Angle.SouthEast) powerproxy.Destroy() end) + + greece.Resources = 2000 + Trigger.AfterDelay(DateTime.Seconds(30), ProduceInfantry) end Tick = function()