Update Airboss.lua

This commit is contained in:
Frank 2020-07-01 23:56:05 +02:00
parent f2e417b21f
commit ba3954ad3f

View File

@ -6060,66 +6060,32 @@ function AIRBOSS:_ScanCarrierZone()
-- Create a new flight group
if knownflight then
-- Debug output.
self:T2(self.lid..string.format("Known flight group %s of type %s in CCA.", groupname, actype))
-- Check if flight is AI and if we want to handle it at all.
if knownflight.ai and self.handleai then
if knownflight.ai and knownflight.flag==-100 and self.handleai then
-- Defines if AI group should be handled by the airboss.
local iscarriersquad=true
local putintomarshal=false
-- Check if AI group is part of the group set if a set was defined.
if self.squadsetAI then
local group=self.squadsetAI:FindGroup(groupname)
if group then
iscarriersquad=true
-- Get flight group.
local flight=_DATABASE:GetFlightGroup(groupname)
if flight and flight:IsInbound() and flight.destbase:GetName()==self.carrier:GetName() then
if flight.ishelo then
else
iscarriersquad=false
end
end
-- Check if group was explicitly excluded.
if self.excludesetAI then
local group=self.excludesetAI:FindGroup(groupname)
if group then
iscarriersquad=false
putintomarshal=true
end
flight.airboss=self
end
-- Get distance to carrier.
local dist=knownflight.group:GetCoordinate():Get2DDistance(self:GetCoordinate())
-- Close in distance. Is >0 if AC comes closer wrt to first detected distance d0.
local closein=knownflight.dist0-dist
-- Debug info.
self:T3(self.lid..string.format("Known AI flight group %s closed in by %.1f NM", knownflight.groupname, UTILS.MetersToNM(closein)))
-- Is this group the tanker?
local istanker=self.tanker and self.tanker.tanker:GetName()==groupname
-- Is this group the AWACS?
local isawacs=self.awacs and self.awacs.tanker:GetName()==groupname
-- Send tanker to marshal stack?
local tanker2marshal = istanker and self.tanker:IsReturning() and self.tanker.airbase:GetName()==self.airbase:GetName() and knownflight.flag==-100 and self.tanker.recovery==true
-- Send AWACS to marhsal stack?
local awacs2marshal = isawacs and self.awacs:IsReturning() and self.awacs.airbase:GetName()==self.airbase:GetName() and knownflight.flag==-100 and self.awacs.recovery==true
-- Put flight into Marshal.
local putintomarshal=closein>UTILS.NMToMeters(5) and knownflight.flag==-100 and iscarriersquad and (not istanker) and (not isawacs)
-- Send AI flight to marshal stack if group closes in more than 5 and has initial flag value.
if putintomarshal or tanker2marshal or awacs2marshal then
-- Send AI flight to marshal stack.
if putintomarshal then
-- Get the next free stack for current recovery case.
local stack=self:_GetFreeStack(knownflight.ai)
-- Repawn.
local respawn=self.respawnAI --or tanker2marshal
local respawn=self.respawnAI
if stack then
@ -6138,8 +6104,9 @@ function AIRBOSS:_ScanCarrierZone()
-- Break the loop to not have all flights at once! Spams the message screen.
break
end -- Closed in or tanker/AWACS
end -- AI
end -- Closed in or tanker/AWACS
end
else