mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-01 08:58:21 +00:00
168 lines
5.4 KiB
Lua
168 lines
5.4 KiB
Lua
--- **Ops** - (R2.5) - AI Flight Group for Ops.
|
|
--
|
|
-- **Main Features:**
|
|
--
|
|
-- * Nice stuff.
|
|
--
|
|
-- ===
|
|
--
|
|
-- ### Author: **funkyfranky**
|
|
-- @module Ops.FlightGroup
|
|
-- @image OPS_FlightGroup.png
|
|
|
|
|
|
--- FLIGHTGROUP class.
|
|
-- @type FLIGHTGROUP
|
|
-- @field #string ClassName Name of the class.
|
|
-- @field #boolean Debug Debug mode. Messages to all about status.
|
|
-- @field #string sid Class id string for output to DCS log file.
|
|
-- @field #table element Table of elements, i.e. units of the group.
|
|
-- @extends AI.AI_Air#AI_AIR
|
|
|
|
--- Be surprised!
|
|
--
|
|
-- ===
|
|
--
|
|
-- 
|
|
--
|
|
-- # The FLIGHTGROUP Concept
|
|
--
|
|
--
|
|
--
|
|
-- @field #FLIGHTGROUP
|
|
FLIGHTGROUP = {
|
|
ClassName = "FLIGHTGROUP",
|
|
sid = nil,
|
|
groupname = nil,
|
|
element = {},
|
|
taskqueue = {},
|
|
}
|
|
|
|
|
|
--- Status of flight group element.
|
|
-- @type FLIGHTGROUP.ElementStatus
|
|
-- @field #string
|
|
|
|
--- Flight group element.
|
|
-- @type FLIGHTGROUP.Element
|
|
-- @param #string name Name of the element.
|
|
-- @param Wrapper.Unit#UNIT unit Element unit object.
|
|
-- @param #string status Status, i.e. born, parking, taxiing.
|
|
|
|
--- Flight group tasks.
|
|
-- @type FLIGHTGROUP.Task
|
|
-- @param #string INTERCEPT Intercept task.
|
|
-- @param #string CAP Combat Air Patrol task.s
|
|
-- @param #string BAI Battlefield Air Interdiction task.
|
|
-- @param #string SEAD Suppression/destruction of enemy air defences.
|
|
-- @param #string STRIKE Strike task.
|
|
-- @param #string AWACS AWACS task.
|
|
-- @param #string TANKER Tanker task.
|
|
FLIGHTGROUP.Task={
|
|
INTERCEPT="Intercept",
|
|
CAP="CAP",
|
|
BAI="BAI",
|
|
SEAD="SEAD",
|
|
STRIKE="Strike",
|
|
CAS="CAS",
|
|
AWACS="AWACS",
|
|
TANKER="Tanker",
|
|
}
|
|
|
|
--- FLIGHTGROUP class version.
|
|
-- @field #string version
|
|
FLIGHTGROUP.version="0.0.1"
|
|
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
-- TODO list
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
-- TODO: A lot!
|
|
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
-- Constructor
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
--- Create a new FLIGHTGROUP class object.
|
|
-- @param #FLIGHTGROUP self
|
|
-- @param Wrapper.Group#GROUP AIGroup The AI flight group.
|
|
-- @return #FLIGHTGROUP self
|
|
function FLIGHTGROUP:New(AIGroup)
|
|
|
|
-- Inherit everything from WAREHOUSE class.
|
|
local self=BASE:Inherit(self, AI_AIR:New( AIGroup )) -- #FLIGHTGROUP
|
|
|
|
if not self then
|
|
BASE:E(string.format("ERROR: Could not find flight group!"))
|
|
return nil
|
|
end
|
|
|
|
self.groupname=AIGroup:GetName()
|
|
|
|
-- Set some string id for output to DCS.log file.
|
|
self.sid=string.format("FLIGHTGROUP %s |", self.groupname)
|
|
|
|
-- Add FSM transitions.
|
|
-- From State --> Event --> To State
|
|
self:AddTransition("*", "AirwingStatus", "*") -- FLIGHTGROUP status update.
|
|
self:AddTransition("*", "RequestCAP", "*") -- Request CAP flight.
|
|
self:AddTransition("*", "RequestIntercept", "*") -- Request Intercept.
|
|
self:AddTransition("*", "RequestCAS", "*") -- Request CAS.
|
|
self:AddTransition("*", "RequestSEAD", "*") -- Request SEAD.
|
|
|
|
------------------------
|
|
--- Pseudo Functions ---
|
|
------------------------
|
|
|
|
--- Triggers the FSM event "Start". Starts the FLIGHTGROUP. Initializes parameters and starts event handlers.
|
|
-- @function [parent=#FLIGHTGROUP] Start
|
|
-- @param #FLIGHTGROUP self
|
|
|
|
--- Triggers the FSM event "Start" after a delay. Starts the FLIGHTGROUP. Initializes parameters and starts event handlers.
|
|
-- @function [parent=#FLIGHTGROUP] __Start
|
|
-- @param #FLIGHTGROUP self
|
|
-- @param #number delay Delay in seconds.
|
|
|
|
--- Triggers the FSM event "Stop". Stops the FLIGHTGROUP and all its event handlers.
|
|
-- @param #FLIGHTGROUP self
|
|
|
|
--- Triggers the FSM event "Stop" after a delay. Stops the FLIGHTGROUP and all its event handlers.
|
|
-- @function [parent=#FLIGHTGROUP] __Stop
|
|
-- @param #FLIGHTGROUP self
|
|
-- @param #number delay Delay in seconds.
|
|
|
|
--- Triggers the FSM event "SkipperStatus".
|
|
-- @function [parent=#FLIGHTGROUP] AirwingStatus
|
|
-- @param #FLIGHTGROUP self
|
|
|
|
--- Triggers the FSM event "SkipperStatus" after a delay.
|
|
-- @function [parent=#FLIGHTGROUP] __AirwingStatus
|
|
-- @param #FLIGHTGROUP self
|
|
-- @param #number delay Delay in seconds.
|
|
|
|
|
|
--- Triggers the FSM event "RequestCAP".
|
|
-- @function [parent=#FLIGHTGROUP] RequestCAP
|
|
-- @param #FLIGHTGROUP self
|
|
-- @param Core.Point#COORDINATE coordinate
|
|
-- @param #number altitude Altitude
|
|
-- @param #number leg Race track length.
|
|
-- @param #number heading Heading in degrees.
|
|
-- @param #number speed Speed in knots.
|
|
-- @param #FLIGHTGROUP.Squadron squadron Explicitly request a specific squadron.
|
|
|
|
|
|
-- Debug trace.
|
|
if true then
|
|
self.Debug=true
|
|
BASE:TraceOnOff(true)
|
|
BASE:TraceClass(self.ClassName)
|
|
BASE:TraceLevel(1)
|
|
end
|
|
|
|
return self
|
|
|
|
end
|
|
|
|
|