mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Merge pull request #1482 from Applevangelist/patch-74
Update FlightGroup.lua
This commit is contained in:
commit
ebd69fd10d
@ -140,6 +140,8 @@ FLIGHTGROUP = {
|
|||||||
fuelcritical = nil,
|
fuelcritical = nil,
|
||||||
fuelcriticalthresh = nil,
|
fuelcriticalthresh = nil,
|
||||||
fuelcriticalrtb = false,
|
fuelcriticalrtb = false,
|
||||||
|
outofAAMrtb = true,
|
||||||
|
outofAGMrtb = true,
|
||||||
squadron = nil,
|
squadron = nil,
|
||||||
flightcontrol = nil,
|
flightcontrol = nil,
|
||||||
flaghold = nil,
|
flaghold = nil,
|
||||||
@ -147,6 +149,7 @@ FLIGHTGROUP = {
|
|||||||
Tparking = nil,
|
Tparking = nil,
|
||||||
menu = nil,
|
menu = nil,
|
||||||
ishelo = nil,
|
ishelo = nil,
|
||||||
|
RTBRecallCount = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,7 +213,7 @@ FLIGHTGROUP.version="0.6.1"
|
|||||||
-- TODO: Mark assigned parking spot on F10 map.
|
-- TODO: Mark assigned parking spot on F10 map.
|
||||||
-- TODO: Let user request a parking spot via F10 marker :)
|
-- TODO: Let user request a parking spot via F10 marker :)
|
||||||
-- TODO: Monitor traveled distance in air ==> calculate fuel consumption ==> calculate range remaining. Will this give half way accurate results?
|
-- TODO: Monitor traveled distance in air ==> calculate fuel consumption ==> calculate range remaining. Will this give half way accurate results?
|
||||||
-- TODO: Out of AG/AA missiles. Safe state of out-of-ammo.
|
-- DONE: Out of AG/AA missiles. Safe state of out-of-ammo.
|
||||||
-- DONE: Add tasks.
|
-- DONE: Add tasks.
|
||||||
-- DONE: Waypoints, read, add, insert, detour.
|
-- DONE: Waypoints, read, add, insert, detour.
|
||||||
-- DONE: Get ammo.
|
-- DONE: Get ammo.
|
||||||
@ -274,9 +277,9 @@ function FLIGHTGROUP:New(group)
|
|||||||
self:AddTransition("*", "FuelLow", "*") -- Fuel state of group is low. Default ~25%.
|
self:AddTransition("*", "FuelLow", "*") -- Fuel state of group is low. Default ~25%.
|
||||||
self:AddTransition("*", "FuelCritical", "*") -- Fuel state of group is critical. Default ~10%.
|
self:AddTransition("*", "FuelCritical", "*") -- Fuel state of group is critical. Default ~10%.
|
||||||
|
|
||||||
self:AddTransition("*", "OutOfMissilesAA", "*") -- Group is out of A2A missiles. Not implemented yet!
|
self:AddTransition("*", "OutOfMissilesAA", "*") -- Group is out of A2A missiles.
|
||||||
self:AddTransition("*", "OutOfMissilesAG", "*") -- Group is out of A2G missiles. Not implemented yet!
|
self:AddTransition("*", "OutOfMissilesAG", "*") -- Group is out of A2G missiles.
|
||||||
self:AddTransition("*", "OutOfMissilesAS", "*") -- Group is out of A2G missiles. Not implemented yet!
|
self:AddTransition("*", "OutOfMissilesAS", "*") -- Group is out of A2S(ship) missiles. Not implemented yet!
|
||||||
|
|
||||||
self:AddTransition("Airborne", "EngageTarget", "Engaging") -- Engage targets.
|
self:AddTransition("Airborne", "EngageTarget", "Engaging") -- Engage targets.
|
||||||
self:AddTransition("Engaging", "Disengage", "Airborne") -- Engagement over.
|
self:AddTransition("Engaging", "Disengage", "Airborne") -- Engagement over.
|
||||||
@ -476,6 +479,32 @@ 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:SetOutOfAAMRTB(switch)
|
||||||
|
if switch==false then
|
||||||
|
self.outofAAMrtb=false
|
||||||
|
else
|
||||||
|
self.outofAAMrtb=true
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set if flight is out of Air-Ground-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:SetOutOfAGMRTB(switch)
|
||||||
|
if switch==false then
|
||||||
|
self.outofAGMrtb=false
|
||||||
|
else
|
||||||
|
self.outofAGMrtb=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,6 +1044,28 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
self:FuelCritical()
|
self:FuelCritical()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Out of AA Missiles? CAP, GCICAP, INTERCEPT
|
||||||
|
local CurrIsCap = false
|
||||||
|
-- Out of AG Missiles? BAI, SEAD, CAS, STRIKE
|
||||||
|
local CurrIsA2G = false
|
||||||
|
-- Check AUFTRAG Type
|
||||||
|
local CurrAuftrag = self:GetMissionCurrent()
|
||||||
|
if CurrAuftrag then
|
||||||
|
local CurrAuftragType = CurrAuftrag:GetType()
|
||||||
|
if CurrAuftragType == "CAP" or CurrAuftragType == "GCICAP" or CurrAuftragType == "INTERCEPT" then CurrIsCap = true end
|
||||||
|
if CurrAuftragType == "BAI" or CurrAuftragType == "CAS" or CurrAuftragType == "SEAD" or CurrAuftragType == "STRIKE" then CurrIsA2G = true end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check A2A
|
||||||
|
if (not self:CanAirToAir(true)) and CurrIsCap then
|
||||||
|
self:OutOfMissilesAA()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check A2G
|
||||||
|
if (not self:CanAirToGround(false)) and CurrIsA2G then
|
||||||
|
self:OutOfMissilesAG()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -2046,6 +2097,34 @@ 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
|
||||||
|
|
||||||
|
--- On after "OutOfMissilesAG" event.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
function FLIGHTGROUP:onafterOutOfMissilesAG(From, Event, To)
|
||||||
|
self:I(self.lid.."Group is out of AG Missiles!")
|
||||||
|
if self.outofAGMrtb 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,
|
||||||
@ -2150,9 +2229,15 @@ function FLIGHTGROUP:onbeforeRTB(From, Event, To, airbase, SpeedTo, SpeedHold)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not self.group:IsAirborne(true) then
|
if not self.group:IsAirborne(true) then
|
||||||
self:I(self.lid..string.format("WARNING: Group is not AIRBORNE ==> RTB event is suspended for 10 sec."))
|
-- this should really not happen, either the AUFTRAG is cancelled before the group was airborne or it is stuck at the ground for some reason
|
||||||
|
self:I(self.lid..string.format("WARNING: Group is not AIRBORNE ==> RTB event is suspended for 20 sec."))
|
||||||
allowed=false
|
allowed=false
|
||||||
Tsuspend=-10
|
Tsuspend=-20
|
||||||
|
local groupspeed = self.group:GetVelocityMPS()
|
||||||
|
if groupspeed <= 1 then self.RTBRecallCount = self.RTBRecallCount+1 end
|
||||||
|
if self.RTBRecallCount > 6 then
|
||||||
|
self:Despawn(5)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Only if fuel is not low or critical.
|
-- Only if fuel is not low or critical.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user