From 82ee3d779c1878aa57c54c4e21a2ca4d54a1bf42 Mon Sep 17 00:00:00 2001 From: JovialFeline Date: Wed, 26 Feb 2025 13:55:31 -0500 Subject: [PATCH] Fix soviet-06 harvester production crash --- mods/ra/maps/soviet-06a/soviet06a-AI.lua | 22 ++++++++++++---------- mods/ra/maps/soviet-06b/soviet06b-AI.lua | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/mods/ra/maps/soviet-06a/soviet06a-AI.lua b/mods/ra/maps/soviet-06a/soviet06a-AI.lua index 7e476239c2..672207f424 100644 --- a/mods/ra/maps/soviet-06a/soviet06a-AI.lua +++ b/mods/ra/maps/soviet-06a/soviet06a-AI.lua @@ -23,8 +23,8 @@ ProduceInfantry = function(barracks) local delay = Utils.RandomInteger(DateTime.Seconds(3), DateTime.Seconds(9)) local toBuild = { Utils.Random(AlliedInfantryTypes) } local path = Utils.Random(AttackPaths) - Greece.Build(toBuild, function(unit) - InfAttack[#InfAttack + 1] = unit[1] + Greece.Build(toBuild, function(units) + InfAttack[#InfAttack + 1] = units[1] if #InfAttack >= 10 then SendUnits(InfAttack, path) @@ -41,18 +41,19 @@ ProduceInfantry = function(barracks) end ProduceArmor = function(factory) + local delay = Utils.RandomInteger(DateTime.Seconds(12), DateTime.Seconds(17)) + if factory.IsDead or factory.Owner ~= Greece then return elseif IsHarvesterMissing() then - ProduceHarvester(factory) + ProduceHarvester(factory, delay) return end - local delay = Utils.RandomInteger(DateTime.Seconds(12), DateTime.Seconds(17)) local toBuild = { Utils.Random(AlliedArmorTypes) } local path = Utils.Random(AttackPaths) - Greece.Build(toBuild, function(unit) - ArmorAttack[#ArmorAttack + 1] = unit[1] + Greece.Build(toBuild, function(units) + ArmorAttack[#ArmorAttack + 1] = units[1] if #ArmorAttack >= 6 then SendUnits(ArmorAttack, path) @@ -68,15 +69,16 @@ ProduceArmor = function(factory) end) end -ProduceHarvester = function(factory) +ProduceHarvester = function(factory, delay) if GreeceMoney() < Actor.Cost("harv") then return end local toBuild = { "harv" } - Greece.Build(toBuild, function(unit) - unit.FindResources() - ProduceArmor(factory) + Greece.Build(toBuild, function() + Trigger.AfterDelay(delay, function() + ProduceArmor(factory) + end) end) end diff --git a/mods/ra/maps/soviet-06b/soviet06b-AI.lua b/mods/ra/maps/soviet-06b/soviet06b-AI.lua index 7ef5f87648..d72311e0d1 100644 --- a/mods/ra/maps/soviet-06b/soviet06b-AI.lua +++ b/mods/ra/maps/soviet-06b/soviet06b-AI.lua @@ -23,8 +23,8 @@ ProduceInfantry = function(barracks) local delay = Utils.RandomInteger(DateTime.Seconds(3), DateTime.Seconds(9)) local toBuild = { Utils.Random(AlliedInfantryTypes) } local path = Utils.Random(AttackPaths) - Greece.Build(toBuild, function(unit) - InfAttack[#InfAttack + 1] = unit[1] + Greece.Build(toBuild, function(units) + InfAttack[#InfAttack + 1] = units[1] if #InfAttack >= 10 then SendUnits(InfAttack, path) @@ -41,18 +41,19 @@ ProduceInfantry = function(barracks) end ProduceArmor = function(factory) + local delay = Utils.RandomInteger(DateTime.Seconds(12), DateTime.Seconds(17)) + if factory.IsDead or factory.Owner ~= Greece then return elseif IsHarvesterMissing() then - ProduceHarvester(factory) + ProduceHarvester(factory, delay) return end - local delay = Utils.RandomInteger(DateTime.Seconds(12), DateTime.Seconds(17)) local toBuild = { Utils.Random(AlliedArmorTypes) } local path = Utils.Random(AttackPaths) - Greece.Build(toBuild, function(unit) - ArmorAttack[#ArmorAttack + 1] = unit[1] + Greece.Build(toBuild, function(units) + ArmorAttack[#ArmorAttack + 1] = units[1] if #ArmorAttack >= 6 then SendUnits(ArmorAttack, path) @@ -68,15 +69,16 @@ ProduceArmor = function(factory) end) end -ProduceHarvester = function(factory) +ProduceHarvester = function(factory, delay) if GreeceMoney() < Actor.Cost("harv") then return end local toBuild = { "harv" } - Greece.Build(toBuild, function(unit) - unit.FindResources() - ProduceArmor(factory) + Greece.Build(toBuild, function() + Trigger.AfterDelay(delay, function() + ProduceArmor(factory) + end) end) end