From 384a67def59e1c73fd2df5892e850389a7db1938 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 31 May 2015 22:52:13 +0200 Subject: [PATCH] Add different difficulties to allies02 --- mods/ra/maps/allies-02/allies02.lua | 154 +++++++++++++++++++++++++--- mods/ra/maps/allies-02/map.yaml | 18 ++-- 2 files changed, 152 insertions(+), 20 deletions(-) diff --git a/mods/ra/maps/allies-02/allies02.lua b/mods/ra/maps/allies-02/allies02.lua index 1ccf47a9d0..cf6af42e3b 100644 --- a/mods/ra/maps/allies-02/allies02.lua +++ b/mods/ra/maps/allies-02/allies02.lua @@ -9,7 +9,61 @@ TruckPath = { TruckEntryPoint.Location, TruckRallyPoint.Location } PathGuards = { PathGuard1, PathGuard2, PathGuard3, PathGuard4, PathGuard5, PathGuard6, PathGuard7, PathGuard8, PathGuard9, PathGuard10, PathGuard11, PathGuard12, PathGuard13, PathGuard14, PathGuard15 } -TimerTicks = DateTime.Minutes(10) +IdlingUnits = { } + +if Map.Difficulty == "Easy" then + TimerTicks = DateTime.Minutes(10) + Announcements = + { + { "TenMinutesRemaining", DateTime.Seconds(3) }, + { "WarningFiveMinutesRemaining", DateTime.Minutes(5) }, + { "WarningFourMinutesRemaining", DateTime.Minutes(6) }, + { "WarningThreeMinutesRemaining", DateTime.Minutes(7) }, + { "WarningTwoMinutesRemaining", DateTime.Minutes(8) }, + { "WarningOneMinuteRemaining", DateTime.Minutes(9) } + } + +elseif Map.Difficulty == "Normal" then + TimerTicks = DateTime.Minutes(5) + Announcements = + { + { "WarningFiveMinutesRemaining", DateTime.Seconds(3) }, + { "WarningFourMinutesRemaining", DateTime.Minutes(6) }, + { "WarningThreeMinutesRemaining", DateTime.Minutes(7) }, + { "WarningTwoMinutesRemaining", DateTime.Minutes(8) }, + { "WarningOneMinuteRemaining", DateTime.Minutes(9) } + } + + InfantryTypes = { "e1", "e1", "e1", "e2", "e2", "e1" } + InfantryDelay = DateTime.Seconds(18) + AttackGroupSize = 5 + +elseif Map.Difficulty == "Hard" then + TimerTicks = DateTime.Minutes(3) + Announcements = + { + { "WarningThreeMinutesRemaining", DateTime.Seconds(3) }, + { "WarningTwoMinutesRemaining", DateTime.Minutes(1) }, + { "WarningOneMinuteRemaining", DateTime.Minutes(2) }, + } + + InfantryTypes = { "e1", "e1", "e1", "e2", "e2", "e1" } + InfantryDelay = DateTime.Seconds(10) + VehicleTypes = { "ftrk" } + VehicleDelay = DateTime.Seconds(30) + AttackGroupSize = 7 + +else + TimerTicks = DateTime.Minutes(1) + Announcements = { { "WarningOneMinuteRemaining", DateTime.Seconds(3) } } + ConstructionVehicleReinforcements = { "jeep" } + + InfantryTypes = { "e1", "e1", "e1", "e2", "e2", "dog", "dog" } + InfantryDelay = DateTime.Seconds(10) + VehicleTypes = { "ftrk" } + VehicleDelay = DateTime.Minutes(1) + DateTime.Seconds(10) + AttackGroupSize = 5 +end SendJeepReinforcements = function() Media.PlaySpeechNotification(player, "ReinforcementsArrived") @@ -18,8 +72,85 @@ end RunInitialActivities = function() Harvester.FindResources() + Trigger.OnKilled(Harvester, function() HarvesterKilled = true end) Trigger.OnAllKilled(PathGuards, SendTrucks) + + if InfantryTypes then + Trigger.AfterDelay(InfantryDelay, InfantryProduction) + end + + if VehicleTypes then + Trigger.AfterDelay(VehicleDelay, VehicleProduction) + end +end + +InfantryProduction = function() + if SovietBarracks.IsDead then + return + end + + local toBuild = { Utils.Random(InfantryTypes) } + + if SovietKennel.IsDead and toBuild == "dog" then + toBuild = "e1" + end + + ussr.Build(toBuild, function(unit) + IdlingUnits[#IdlingUnits + 1] = unit[1] + Trigger.AfterDelay(InfantryDelay, InfantryProduction) + + if #IdlingUnits >= (AttackGroupSize * 1.5) then + SendAttack() + end + end) +end + +VehicleProduction = function() + if SovietWarfactory.IsDead then + return + end + + if HarvesterKilled then + ussr.Build({ "harv" }, function(harv) + harv[1].FindResources() + Trigger.OnKilled(harv[1], function() HarvesterKilled = true end) + + HarvesterKilled = false + VehicleProduction() + end) + return + end + + local toBuild = { Utils.Random(VehicleTypes) } + ussr.Build(toBuild, function(unit) + IdlingUnits[#IdlingUnits + 1] = unit[1] + Trigger.AfterDelay(VehicleDelay, VehicleProduction) + + if #IdlingUnits >= (AttackGroupSize * 1.5) then + SendAttack() + end + end) +end + +SendAttack = function() + local units = { } + + for i = 0, AttackGroupSize, 1 do + local number = Utils.RandomInteger(1, #IdlingUnits) + + if IdlingUnits[number] and not IdlingUnits[number].IsDead then + units[i] = IdlingUnits[number] + table.remove(IdlingUnits, number) + end + end + + Utils.Do(units, function(unit) + if Map.Difficulty ~= "Real tough guy" then + unit.AttackMove(DeployPoint.Location) + end + Trigger.OnIdle(unit, unit.Hunt) + end) end ticked = TimerTicks @@ -96,12 +227,14 @@ ConvoyCasualites = function() end end -ConvoyTimer = function(delay, notification) - Trigger.AfterDelay(delay, function() - if not ConvoyOnSite then - Media.PlaySpeechNotification(player, notification) - end - end) +ConvoyTimerAnnouncements = function() + for i = #Announcements, 1, -1 do + Trigger.AfterDelay(Announcements[i][2], function() + if not ConvoyOnSite then + Media.PlaySpeechNotification(player, Announcements[i][1]) + end + end) + end end WorldLoaded = function() @@ -141,10 +274,5 @@ WorldLoaded = function() Camera.Position = ReinforcementsEntryPoint.CenterPosition TimerColor = player.Color - ConvoyTimer(DateTime.Seconds(3), "TenMinutesRemaining") - ConvoyTimer(DateTime.Minutes(5), "WarningFiveMinutesRemaining") - ConvoyTimer(DateTime.Minutes(6), "WarningFourMinutesRemaining") - ConvoyTimer(DateTime.Minutes(7), "WarningThreeMinutesRemaining") - ConvoyTimer(DateTime.Minutes(8), "WarningTwoMinutesRemaining") - ConvoyTimer(DateTime.Minutes(9), "WarningOneMinuteRemaining") + ConvoyTimerAnnouncements() end diff --git a/mods/ra/maps/allies-02/map.yaml b/mods/ra/maps/allies-02/map.yaml index 3818599f5f..709c02729e 100644 --- a/mods/ra/maps/allies-02/map.yaml +++ b/mods/ra/maps/allies-02/map.yaml @@ -33,6 +33,7 @@ Options: StartingCash: 5700 ConfigurableStartingUnits: False ShortGame: False + Difficulties: Easy, Normal, Hard, Real tough guy Players: PlayerReference@USSR: @@ -248,16 +249,9 @@ Actors: Actor60: powr Location: 57,62 Owner: USSR - Actor61: barr - Location: 56,66 - Owner: USSR Actor62: powr Location: 59,62 Owner: USSR - Actor63: kenn - Location: 58,68 - Owner: USSR - Health: 99 Actor64: brl3 Location: 65,59 Owner: USSR @@ -587,6 +581,13 @@ Actors: Actor170: fenc Location: 50,51 Owner: USSR + SovietKennel: kenn + Location: 58,68 + Owner: USSR + Health: 99 + SovietBarracks: barr + Location: 56,66 + Owner: USSR SovietWarfactory: weap Location: 60,66 Owner: USSR @@ -741,6 +742,9 @@ Rules: GenericVisibility: Enemy, Ally, Neutral GenericStancePrefix: false ShowOwnerRow: false + HARV: + Buildable: + Prerequisites: weap APWR: Buildable: Prerequisites: ~disabled