From d5b8ed62ae49f202ae08f7a084bea83e11930836 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 2 Jan 2020 20:15:42 +0100 Subject: [PATCH] AI_AIR - Fixed call to .Resume function if AI_A2A_CAP is calling. --- Moose Development/Moose/AI/AI_Air.lua | 12 +++++++++++- Moose Development/Moose/AI/AI_Air_Patrol.lua | 1 - Moose Development/Moose/Core/Base.lua | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Air.lua b/Moose Development/Moose/AI/AI_Air.lua index eeb9053b7..c829cc6e9 100644 --- a/Moose Development/Moose/AI/AI_Air.lua +++ b/Moose Development/Moose/AI/AI_Air.lua @@ -748,10 +748,20 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To ) AIGroup:OptionROEHoldFire() AIGroup:OptionROTEvadeFire() + + -- Get Class name for .Resume function + local classname=self:GetClassName() + + -- AI_A2A_CAP can call this function but does not have a .Resume function. Try to fix. + local fsm=self + if classname=="AI_A2A_CAP" then + fsm=self:GetParent(self, AI_A2A_CAP) + classname=fsm:GetClassName() + end local Tasks = {} Tasks[#Tasks+1] = AIGroup:TaskRefueling() - Tasks[#Tasks+1] = AIGroup:TaskFunction( self:GetClassName() .. ".Resume", self ) + Tasks[#Tasks+1] = AIGroup:TaskFunction( classname .. ".Resume", fsm ) RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks ) AIGroup:Route( RefuelRoute, self.TaskDelay ) diff --git a/Moose Development/Moose/AI/AI_Air_Patrol.lua b/Moose Development/Moose/AI/AI_Air_Patrol.lua index 6458c80d1..32bd99cea 100644 --- a/Moose Development/Moose/AI/AI_Air_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Air_Patrol.lua @@ -356,7 +356,6 @@ function AI_AIR_PATROL:onafterPatrolRoute( AIPatrol, From, Event, To ) local taskOrbit=AIPatrol:TaskOrbit(c1, altitude, UTILS.KmphToMps(speedkmh), c2) -- Task function to redo the patrol at other random position. - --local taskPatrol=AIPatrol:TaskFunction("AI_A2A_PATROL.PatrolRoute", self) local taskPatrol=AIPatrol:TaskFunction("AI_AIR_PATROL.___PatrolRoute", self) -- Controlled task with task condition. diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index d20f068ee..e95eac8ce 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -298,7 +298,8 @@ end -- -- -- @param #BASE self --- @param #BASE Child is the Child class from which the Parent class needs to be retrieved. +-- @param #BASE Child This is the Child class from which the Parent class needs to be retrieved. +-- @param #BASE FromClass (Optional) The class from which to get the parent. -- @return #BASE function BASE:GetParent( Child, FromClass )