diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 283a24420..5f0e915ce 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -64,6 +64,7 @@ FLIGHTGROUP = { speedmax = nil, range = nil, altmax = nil, + fuelthresh = nil, } @@ -155,7 +156,7 @@ FLIGHTGROUP.TaskType={ --- FLIGHTGROUP class version. -- @field #string version -FLIGHTGROUP.version="0.0.6" +FLIGHTGROUP.version="0.0.7" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -197,6 +198,9 @@ function FLIGHTGROUP:New(groupname) -- Init set of detected units. self.detectedunits=SET_UNIT:New() + + -- Defaults + self:SetFuelLowThreshold() -- Add FSM transitions. @@ -216,6 +220,13 @@ function FLIGHTGROUP:New(groupname) self:AddTransition("*", "Orbit", "Orbiting") -- Group is holding position. self:AddTransition("*", "PassingWaypoint", "*") -- Group passed a waypoint. + + self:AddTransition("*", "OutOfFuel", "*") -- Group is out of fuel + self:AddTransition("*", "OutOfAmmo", "*") -- Group is out of ammo + self:AddTransition("*", "OutOfGuns", "*") -- Group is out of ammo + self:AddTransition("*", "OutOfRockets", "*") -- Group is out of ammo + self:AddTransition("*", "OutOfBombs", "*") -- Group is out of ammo + self:AddTransition("*", "OutOfMissiles", "*") -- Group is out of ammo self:AddTransition("*", "TaskExecute", "*") -- Group will execute a task. self:AddTransition("*", "TaskDone", "*") -- Group finished a task. @@ -388,6 +399,16 @@ function FLIGHTGROUP:AddTaskWaypoint(description, task, waypointindex, prio, dur return self end +--- Fuel threshold for RTB. +-- @param #FLIGHTGROUP self +-- @param #number threshold Fuel threshold in percent. Default 15 %. +-- @param #boolean rtb If true, RTB on low fuel event. +-- @return #FLIGHTGROUP self +function FLIGHTGROUP:SetFuelLowThreshold(threshold, rtb) + self.fuellow=threshold or 15 + self.fuellowrtb=rtb + return self +end --- Get set of decteded units. -- @param #FLIGHTGROUP self @@ -538,6 +559,7 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To) -- Element status. text="Elements:" + local fuelmin=999999 for i,_element in pairs(self.element) do local element=_element --#FLIGHTGROUP.Element local name=element.name @@ -545,6 +567,10 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To) local unit=element.unit local fuel=unit:GetFuel() or 0 local life=unit:GetLifeRelative() or 0 + + if fuel