From fa5afae7832a4115c080e15846d5d8055a388daa Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Mon, 4 Apr 2022 12:58:28 +0200 Subject: [PATCH] A2A Dispatcher - nil checks to evade dead units --- Moose Development/Moose/AI/AI_A2A_Dispatcher.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index 960bfce89..7d48e4ce5 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -2971,7 +2971,20 @@ do -- AI_A2A_DISPATCHER for FriendlyDistance, AIFriendly in UTILS.spairs( DefenderFriendlies or {} ) do -- We only allow to ENGAGE targets as long as the Units on both sides are balanced. if AttackerCount > DefenderCount then - local Friendly = AIFriendly:GetGroup() -- Wrapper.Group#GROUP + --self:I("***** AI_A2A_DISPATCHER:CountDefendersToBeEngaged() *****\nThis is supposed to be a UNIT:") + if AIFriendly then + local classname = AIFriendly.ClassName or "No Class Name" + local unitname = AIFriendly.IdentifiableName or "No Unit Name" + --self:I("Class Name: " .. classname) + --self:I("Unit Name: " .. unitname) + --self:I({AIFriendly}) + end + local Friendly = nil + if AIFriendly and AIFriendly:IsAlive() then + --self:I("AIFriendly alive, getting GROUP") + Friendly = AIFriendly:GetGroup() -- Wrapper.Group#GROUP + end + if Friendly and Friendly:IsAlive() then -- Ok, so we have a friendly near the potential target. -- Now we need to check if the AIGroup has a Task.