This commit is contained in:
FlightControl 2017-06-15 19:46:46 +02:00
parent 18591c434f
commit a42b5fcea7

View File

@ -229,6 +229,8 @@ function AI_A2A:New( AIGroup )
self:AddTransition( "*", "Crash", "Crashed" ) self:AddTransition( "*", "Crash", "Crashed" )
self:AddTransition( "*", "PilotDead", "*" ) self:AddTransition( "*", "PilotDead", "*" )
self.IdleCount = 0
return self return self
end end
@ -402,24 +404,26 @@ function AI_A2A:onafterStatus()
RTB = true RTB = true
end end
-- Check if planes went RTB -- Check if planes went RTB and are out of control.
local TargetDistance = self.TargetDistance if self.Controllable:HasTask() == false then
local ClosestTargetDistance = self.ClosestTargetDistance if not self:Is( "Started" ) and
if TargetDistance then not self:Is( "Stopped" ) then
if ClosestTargetDistance <= 40000 then if self.IdleCount >= 2 then
if TargetDistance > 40000 then self:E( self.Controllable:GetName() .. " control lost! " )
self:E( "Lost control of group " .. self.Controllable:GetName() .. " ... RTB!" )
self:LostControl() self:LostControl()
RTB = true else
self.IdleCount = self.IdleCount + 1
end end
end end
else
self.IdleCount = 0
end end
if RTB == true then if RTB == true then
self:__RTB( 0.5 ) self:__RTB( 0.5 )
else
self:__Status( 10 ) -- Execute the Patrol event after 30 seconds.
end end
self:__Status( 10 )
end end
end end
@ -432,20 +436,22 @@ function AI_A2A.RTBRoute( AIGroup )
_AI_A2A:__RTB( 0.5 ) _AI_A2A:__RTB( 0.5 )
end end
--- @param #AI_A2A self --- @param #AI_A2A self
-- @param Wrapper.Group#GROUP AIGroup -- @param Wrapper.Group#GROUP AIGroup
function AI_A2A:onafterRTB( AIGroup, From, Event, To ) function AI_A2A:onafterRTB( AIGroup, From, Event, To )
self:F( { AIGroup, From, Event, To } ) self:F( { AIGroup, From, Event, To } )
self:E( "Group " .. self.Controllable:GetName() .. " ... RTB! ( " .. self:GetState() .. " )" )
if AIGroup and AIGroup:IsAlive() then if AIGroup and AIGroup:IsAlive() then
self:E( "Group " .. AIGroup:GetName() .. " ... RTB! ( " .. self:GetState() .. " )" )
self.CheckStatus = false self.CheckStatus = false
self:ClearTargetDistance() self:ClearTargetDistance()
AIGroup:ClearTasks() AIGroup:ClearTasks()
AIGroup:ClearTasks()
local EngageRoute = {} local EngageRoute = {}