Update FlightGroup.lua

Added check for velocity for the RTB loop (if group is taxiing). Added OutOfAAMissiles.
This commit is contained in:
Applevangelist 2021-04-04 12:49:40 +02:00 committed by GitHub
parent 31b93fb42c
commit b1465d89a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,6 +140,7 @@ FLIGHTGROUP = {
fuelcritical = nil, fuelcritical = nil,
fuelcriticalthresh = nil, fuelcriticalthresh = nil,
fuelcriticalrtb = false, fuelcriticalrtb = false,
outofAAMrtb = true,
squadron = nil, squadron = nil,
flightcontrol = nil, flightcontrol = nil,
flaghold = nil, flaghold = nil,
@ -477,6 +478,20 @@ function FLIGHTGROUP:SetFuelLowRTB(switch)
return self return self
end end
--- Set if flight is out of Air-Air-Missiles, flight goes RTB.
-- @param #FLIGHTGROUP self
-- @param #boolean switch If true or nil, flight goes RTB. If false, turn this off.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SetOutOfAMMRTB(switch)
if switch==false then
self.outofAAMrtb=false
else
self.outofAAMrtb=true
end
return self
end
--- Set if low fuel threshold is reached, flight tries to refuel at the neares tanker. --- Set if low fuel threshold is reached, flight tries to refuel at the neares tanker.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param #boolean switch If true or nil, flight goes for refuelling. If false, turn this off. -- @param #boolean switch If true or nil, flight goes for refuelling. If false, turn this off.
@ -1015,7 +1030,18 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
if fuelmin<self.fuelcriticalthresh and not self.fuelcritical then if fuelmin<self.fuelcriticalthresh and not self.fuelcritical then
self:FuelCritical() self:FuelCritical()
end end
-- Out of AA Ammo? CAP, GCICAP, INTERCEPT
local CurrIsCap = false
local CurrAuftrag = self:GetMissionCurrent()
if CurrAuftrag then
local CurrAuftragType = CurrAuftrag:GetType()
if CurrAuftragType == "CAP" or CurrAuftragType == "GCICAP" or CurrAuftragType == "INTERCEPT" then CurrIsCap = true end
end
if (not self:CanAirToAir(true)) and CurrIsCap then
self:OutOfMissilesAA()
end
end end
--- ---
@ -2047,6 +2073,20 @@ function FLIGHTGROUP:onafterRespawn(From, Event, To, Template)
end end
--- On after "OutOfMissilesAA" event.
-- @param #FLIGHTGROUP self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
function FLIGHTGROUP:onafterOutOfMissilesAA(From, Event, To)
self:I(self.lid.."Group is out of AA Missiles!")
if self.outofAAMrtb then
-- Back to destination or home.
local airbase=self.destbase or self.homebase
self:__RTB(-5,airbase)
end
end
--- Check if flight is done, i.e. --- Check if flight is done, i.e.
-- --
-- * passed the final waypoint, -- * passed the final waypoint,
@ -2155,8 +2195,9 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
self:I(self.lid..string.format("WARNING: Group is not AIRBORNE ==> RTB event is suspended for 20 sec.")) self:I(self.lid..string.format("WARNING: Group is not AIRBORNE ==> RTB event is suspended for 20 sec."))
allowed=false allowed=false
Tsuspend=-20 Tsuspend=-20
self.RTBRecallCount = self.RTBRecallCount+1 local groupspeed = self.group:GetVelocityMPS()
if self.RTBRecallCount > 3 then if groupspeed <= 1 then self.RTBRecallCount = self.RTBRecallCount+1 end
if self.RTBRecallCount > 6 then
self:Despawn(5) self:Despawn(5)
end end
end end