From 94c208cbc9ea18e595f733ac4c467314ac9c616c Mon Sep 17 00:00:00 2001 From: FlightControl Date: Tue, 13 Jun 2017 07:00:44 +0200 Subject: [PATCH] Progress --- .../Moose/AI/AI_A2A_Dispatcher.lua | 45 ++++++++++--------- Moose Development/Moose/AI/AI_A2A_Patrol.lua | 2 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index 7f2fa575f..35263c50a 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -475,6 +475,10 @@ do -- AI_A2A_DISPATCHER end if Defender and DefenderTask and DefenderTask.Target then DefenderTask.Target = nil + if DefenderTask.Fsm:Is("Engaging") then + DefenderTask.Fsm:Return() + DefenderTask.Fsm:__RTB( 0.5 ) + end end -- if Defender and DefenderTask then -- if DefenderTask.Fsm:Is( "Fuel" ) @@ -1012,24 +1016,7 @@ do -- AI_A2A_DISPATCHER return self end - --- Sets flights to take-off from the airbase at a cold location, as part of the defense system. - -- @param #AI_A2A_DISPATCHER self - -- @param #string SquadronName The name of the squadron. - -- @usage: - -- - -- local Dispatcher = AI_A2A_DISPATCHER:New( ... ) - -- - -- -- Let new flights take-off in the air. - -- Dispatcher:SetSquadronLandingFromAirbaseCold( "SquadronName" ) - -- - -- @return #AI_A2A_DISPATCHER - function AI_A2A_DISPATCHER:SetSquadronLandingFromAirbaseCold( SquadronName ) - self:SetSquadronLanding( SquadronName, AI_A2A_DISPATCHER.Landing.FromAirbaseCold ) - - return self - end - --- @param #AI_A2A_DISPATCHER self function AI_A2A_DISPATCHER:AddDefenderToSquadron( Squadron, Defender ) self.Defenders = self.Defenders or {} @@ -1229,6 +1216,21 @@ do -- AI_A2A_DISPATCHER local AIGroup = self:GetControllable() Dispatcher:ClearDefenderTaskTarget( AIGroup ) end + + --- @param #AI_A2A_DISPATCHER self + function Fsm:onafterHome( Defender, From, Event, To ) + self:F({"CAP Home"}) + self:GetParent(self).onafterHome( self, Defender, From, Event, To ) + + local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER + local AIGroup = self:GetControllable() + local Squadron = Dispatcher:GetSquadronFromDefender( AIGroup ) + if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then + Dispatcher:RemoveDefenderFromSquadron( Squadron, AIGroup ) + AIGroup:Destroy() + end + end + end end end @@ -1328,10 +1330,10 @@ do -- AI_A2A_DISPATCHER local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER local AIGroup = self:GetControllable() - local Squadron = self:GetSquadronFromDefender( Defender ) - if self:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then - Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender ) - Defender:Destroy() + local Squadron = Dispatcher:GetSquadronFromDefender( AIGroup ) + if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then + Dispatcher:RemoveDefenderFromSquadron( Squadron, AIGroup ) + AIGroup:Destroy() end end end @@ -1420,6 +1422,7 @@ do -- AI_A2A_DISPATCHER if not Target then self:F( { "Removing obsolete Target:", DefenderTask.Target.Index } ) self:ClearDefenderTaskTarget( AIGroup ) + else if DefenderTask.Target.Set then if DefenderTask.Target.Set:Count() == 0 then diff --git a/Moose Development/Moose/AI/AI_A2A_Patrol.lua b/Moose Development/Moose/AI/AI_A2A_Patrol.lua index b81f1980e..110991d19 100644 --- a/Moose Development/Moose/AI/AI_A2A_Patrol.lua +++ b/Moose Development/Moose/AI/AI_A2A_Patrol.lua @@ -315,7 +315,7 @@ end --- @param Wrapper.Group#GROUP AIGroup -- This statis method is called from the route path within the last task at the last waaypoint of the Controllable. -- Note that this method is required, as triggers the next route when patrolling for the Controllable. -function AI_A2A_PATROL:PatrolRoute( AIGroup ) +function AI_A2A_PATROL.PatrolRoute( AIGroup ) local _AI_A2A_Patrol = AIGroup:GetState( AIGroup, "AI_A2A_PATROL" ) -- #AI_A2A_PATROL _AI_A2A_Patrol:Route()