This commit is contained in:
FlightControl 2017-06-13 07:00:44 +02:00
parent 1ea916ec73
commit 94c208cbc9
2 changed files with 25 additions and 22 deletions

View File

@ -475,6 +475,10 @@ do -- AI_A2A_DISPATCHER
end end
if Defender and DefenderTask and DefenderTask.Target then if Defender and DefenderTask and DefenderTask.Target then
DefenderTask.Target = nil DefenderTask.Target = nil
if DefenderTask.Fsm:Is("Engaging") then
DefenderTask.Fsm:Return()
DefenderTask.Fsm:__RTB( 0.5 )
end
end end
-- if Defender and DefenderTask then -- if Defender and DefenderTask then
-- if DefenderTask.Fsm:Is( "Fuel" ) -- if DefenderTask.Fsm:Is( "Fuel" )
@ -1012,23 +1016,6 @@ do -- AI_A2A_DISPATCHER
return self return self
end 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 --- @param #AI_A2A_DISPATCHER self
function AI_A2A_DISPATCHER:AddDefenderToSquadron( Squadron, Defender ) function AI_A2A_DISPATCHER:AddDefenderToSquadron( Squadron, Defender )
@ -1229,6 +1216,21 @@ do -- AI_A2A_DISPATCHER
local AIGroup = self:GetControllable() local AIGroup = self:GetControllable()
Dispatcher:ClearDefenderTaskTarget( AIGroup ) Dispatcher:ClearDefenderTaskTarget( AIGroup )
end 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 end
end end
@ -1328,10 +1330,10 @@ do -- AI_A2A_DISPATCHER
local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER local Dispatcher = self:GetDispatcher() -- #AI_A2A_DISPATCHER
local AIGroup = self:GetControllable() local AIGroup = self:GetControllable()
local Squadron = self:GetSquadronFromDefender( Defender ) local Squadron = Dispatcher:GetSquadronFromDefender( AIGroup )
if self:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender ) Dispatcher:RemoveDefenderFromSquadron( Squadron, AIGroup )
Defender:Destroy() AIGroup:Destroy()
end end
end end
end end
@ -1420,6 +1422,7 @@ do -- AI_A2A_DISPATCHER
if not Target then if not Target then
self:F( { "Removing obsolete Target:", DefenderTask.Target.Index } ) self:F( { "Removing obsolete Target:", DefenderTask.Target.Index } )
self:ClearDefenderTaskTarget( AIGroup ) self:ClearDefenderTaskTarget( AIGroup )
else else
if DefenderTask.Target.Set then if DefenderTask.Target.Set then
if DefenderTask.Target.Set:Count() == 0 then if DefenderTask.Target.Set:Count() == 0 then

View File

@ -315,7 +315,7 @@ end
--- @param Wrapper.Group#GROUP AIGroup --- @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. -- 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. -- 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 local _AI_A2A_Patrol = AIGroup:GetState( AIGroup, "AI_A2A_PATROL" ) -- #AI_A2A_PATROL
_AI_A2A_Patrol:Route() _AI_A2A_Patrol:Route()