Merge pull request #170 from FlightControl-Master/MR2-Fixing-Add-new-Player

Mr2 fixing add new player
This commit is contained in:
Sven Van de Velde
2016-12-17 16:37:37 +01:00
committed by GitHub
165 changed files with 71347 additions and 5812 deletions

View File

@@ -1,35 +1,35 @@
--- This module contains the AIBALANCER class.
--- This module contains the AI_BALANCER class.
--
-- ===
--
-- 1) @{Functional.AIBalancer#AIBALANCER} class, extends @{Fsm.Fsm#FSM_SET}
-- 1) @{AI.AI_Balancer#AI_BALANCER} class, extends @{Core.Fsm#FSM_SET}
-- ===================================================================================
-- The @{Functional.AIBalancer#AIBALANCER} class monitors and manages as many AI GROUPS as there are
-- The @{AI.AI_Balancer#AI_BALANCER} class monitors and manages as many AI GROUPS as there are
-- CLIENTS in a SET_CLIENT collection not occupied by players.
-- The AIBALANCER class manages internally a collection of AI management objects, which govern the behaviour
-- The AI_BALANCER class manages internally a collection of AI management objects, which govern the behaviour
-- of the underlying AI GROUPS.
--
-- The parent class @{Fsm.Fsm#FSM_SET} manages the functionality to control the Finite State Machine (FSM)
-- and calls for each event the state transition methods providing the internal @{Fsm.Fsm#FSM_SET.Set} object containing the
-- The parent class @{Core.Fsm#FSM_SET} manages the functionality to control the Finite State Machine (FSM)
-- and calls for each event the state transition methods providing the internal @{Core.Fsm#FSM_SET.Set} object containing the
-- SET_GROUP and additional event parameters provided during the event.
--
-- 1.1) AIBALANCER construction method
-- 1.1) AI_BALANCER construction method
-- ---------------------------------------
-- Create a new AIBALANCER object with the @{#AIBALANCER.New} method:
-- Create a new AI_BALANCER object with the @{#AI_BALANCER.New} method:
--
-- * @{#AIBALANCER.New}: Creates a new AIBALANCER object.
-- * @{#AI_BALANCER.New}: Creates a new AI_BALANCER object.
--
-- 1.2)
-- ----
-- * Add
-- * Remove
--
-- 1.2) AIBALANCER returns AI to Airbases
-- 1.2) AI_BALANCER returns AI to Airbases
-- ------------------------------------------
-- You can configure to have the AI to return to:
--
-- * @{#AIBALANCER.ReturnToHomeAirbase}: Returns the AI to the home @{Wrapper.Airbase#AIRBASE}.
-- * @{#AIBALANCER.ReturnToNearestAirbases}: Returns the AI to the nearest friendly @{Wrapper.Airbase#AIRBASE}.
-- * @{#AI_BALANCER.ReturnToHomeAirbase}: Returns the AI to the home @{Wrapper.Airbase#AIRBASE}.
-- * @{#AI_BALANCER.ReturnToNearestAirbases}: Returns the AI to the nearest friendly @{Wrapper.Airbase#AIRBASE}.
-- --
-- ===
--
@@ -56,42 +56,42 @@
-- ### Contributions:
--
-- * **Dutch_Baron (James)**: Who you can search on the Eagle Dynamics Forums.
-- Working together with James has resulted in the creation of the AIBALANCER class.
-- Working together with James has resulted in the creation of the AI_BALANCER class.
-- James has shared his ideas on balancing AI with air units, and together we made a first design which you can use now :-)
--
-- * **SNAFU**:
-- Had a couple of mails with the guys to validate, if the same concept in the GCI/CAP script could be reworked within MOOSE.
-- None of the script code has been used however within the new AIBALANCER moose class.
-- None of the script code has been used however within the new AI_BALANCER moose class.
--
-- ### Authors:
--
-- * FlightControl: Framework Design & Programming
--
-- @module AIBalancer
-- @module AI_Balancer
--- AIBALANCER class
-- @type AIBALANCER
--- AI_BALANCER class
-- @type AI_BALANCER
-- @field Core.Set#SET_CLIENT SetClient
-- @extends Fsm.Fsm#FSM_SET
AIBALANCER = {
ClassName = "AIBALANCER",
-- @extends Core.Fsm#FSM_SET
AI_BALANCER = {
ClassName = "AI_BALANCER",
PatrolZones = {},
AIGroups = {},
}
--- Creates a new AIBALANCER object
-- @param #AIBALANCER self
--- Creates a new AI_BALANCER object
-- @param #AI_BALANCER self
-- @param Core.Set#SET_CLIENT SetClient A SET\_CLIENT object that will contain the CLIENT objects to be monitored if they are alive or not (joined by a player).
-- @param Functional.Spawn#SPAWN SpawnAI The default Spawn object to spawn new AI Groups when needed.
-- @return #AIBALANCER
-- @return #AI_BALANCER
-- @usage
-- -- Define a new AIBALANCER Object.
function AIBALANCER:New( SetClient, SpawnAI )
-- -- Define a new AI_BALANCER Object.
function AI_BALANCER:New( SetClient, SpawnAI )
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_SET:New( SET_GROUP:New() ) ) -- Fsm.Fsm#FSM_SET
local self = BASE:Inherit( self, FSM_SET:New( SET_GROUP:New() ) ) -- Core.Fsm#FSM_SET
self:SetStartState( "None" )
self:AddTransition( "*", "Start", "Monitoring" )
@@ -116,10 +116,10 @@ function AIBALANCER:New( SetClient, SpawnAI )
end
--- Returns the AI to the nearest friendly @{Wrapper.Airbase#AIRBASE}.
-- @param #AIBALANCER self
-- @param #AI_BALANCER self
-- @param Dcs.DCSTypes#Distance ReturnTresholdRange If there is an enemy @{Wrapper.Client#CLIENT} within the ReturnTresholdRange given in meters, the AI will not return to the nearest @{Wrapper.Airbase#AIRBASE}.
-- @param Core.Set#SET_AIRBASE ReturnAirbaseSet The SET of @{Core.Set#SET_AIRBASE}s to evaluate where to return to.
function AIBALANCER:ReturnToNearestAirbases( ReturnTresholdRange, ReturnAirbaseSet )
function AI_BALANCER:ReturnToNearestAirbases( ReturnTresholdRange, ReturnAirbaseSet )
self.ToNearestAirbase = true
self.ReturnTresholdRange = ReturnTresholdRange
@@ -127,19 +127,19 @@ function AIBALANCER:ReturnToNearestAirbases( ReturnTresholdRange, ReturnAirbaseS
end
--- Returns the AI to the home @{Wrapper.Airbase#AIRBASE}.
-- @param #AIBALANCER self
-- @param #AI_BALANCER self
-- @param Dcs.DCSTypes#Distance ReturnTresholdRange If there is an enemy @{Wrapper.Client#CLIENT} within the ReturnTresholdRange given in meters, the AI will not return to the nearest @{Wrapper.Airbase#AIRBASE}.
function AIBALANCER:ReturnToHomeAirbase( ReturnTresholdRange )
function AI_BALANCER:ReturnToHomeAirbase( ReturnTresholdRange )
self.ToHomeAirbase = true
self.ReturnTresholdRange = ReturnTresholdRange
end
--- @param #AIBALANCER self
--- @param #AI_BALANCER self
-- @param Core.Set#SET_GROUP SetGroup
-- @param #string ClientName
-- @param Wrapper.Group#GROUP AIGroup
function AIBALANCER:onenterSpawning( SetGroup, Event, From, To, ClientName )
function AI_BALANCER:onenterSpawning( SetGroup, Event, From, To, ClientName )
-- OK, Spawn a new group from the default SpawnAI object provided.
local AIGroup = self.SpawnAI:Spawn()
@@ -153,18 +153,18 @@ function AIBALANCER:onenterSpawning( SetGroup, Event, From, To, ClientName )
self:Spawned( AIGroup )
end
--- @param #AIBALANCER self
--- @param #AI_BALANCER self
-- @param Core.Set#SET_GROUP SetGroup
-- @param Wrapper.Group#GROUP AIGroup
function AIBALANCER:onenterDestroying( SetGroup, Event, From, To, AIGroup )
function AI_BALANCER:onenterDestroying( SetGroup, Event, From, To, AIGroup )
AIGroup:Destroy()
end
--- @param #AIBALANCER self
--- @param #AI_BALANCER self
-- @param Core.Set#SET_GROUP SetGroup
-- @param Wrapper.Group#GROUP AIGroup
function AIBALANCER:onenterReturning( SetGroup, Event, From, To, AIGroup )
function AI_BALANCER:onenterReturning( SetGroup, Event, From, To, AIGroup )
local AIGroupTemplate = AIGroup:GetTemplate()
if self.ToHomeAirbase == true then
@@ -187,8 +187,8 @@ function AIBALANCER:onenterReturning( SetGroup, Event, From, To, AIGroup )
end
--- @param #AIBALANCER self
function AIBALANCER:onenterMonitoring( SetGroup )
--- @param #AI_BALANCER self
function AI_BALANCER:onenterMonitoring( SetGroup )
self.SetClient:ForEachClient(
--- @param Wrapper.Client#CLIENT Client

View File

@@ -4,31 +4,31 @@
--
-- Cargo can be of various forms, always are composed out of ONE object ( one unit or one static or one slingload crate ):
--
-- * CARGO_UNIT, represented by a @{Unit} in a @{Group}: Cargo can be represented by a Unit in a Group. Destruction of the Unit will mean that the cargo is lost.
-- * AI_CARGO_UNIT, represented by a @{Unit} in a @{Group}: Cargo can be represented by a Unit in a Group. Destruction of the Unit will mean that the cargo is lost.
-- * CARGO_STATIC, represented by a @{Static}: Cargo can be represented by a Static. Destruction of the Static will mean that the cargo is lost.
-- * CARGO_PACKAGE, contained in a @{Unit} of a @{Group}: Cargo can be contained within a Unit of a Group. The cargo can be **delivered** by the @{Unit}. If the Unit is destroyed, the cargo will be destroyed also.
-- * CARGO_PACKAGE, Contained in a @{Static}: Cargo can be contained within a Static. The cargo can be **collected** from the @Static. If the @{Static} is destroyed, the cargo will be destroyed.
-- * AI_CARGO_PACKAGE, contained in a @{Unit} of a @{Group}: Cargo can be contained within a Unit of a Group. The cargo can be **delivered** by the @{Unit}. If the Unit is destroyed, the cargo will be destroyed also.
-- * AI_CARGO_PACKAGE, Contained in a @{Static}: Cargo can be contained within a Static. The cargo can be **collected** from the @Static. If the @{Static} is destroyed, the cargo will be destroyed.
-- * CARGO_SLINGLOAD, represented by a @{Cargo} that is transportable: Cargo can be represented by a Cargo object that is transportable. Destruction of the Cargo will mean that the cargo is lost.
--
-- * CARGO_GROUPED, represented by a Group of CARGO_UNITs.
-- * AI_CARGO_GROUPED, represented by a Group of CARGO_UNITs.
--
-- 1) @{Fsm.Cargo#CARGO_BASE} class, extends @{Fsm.Fsm#FSM_PROCESS}
-- 1) @{AI.AI_Cargo#AI_CARGO} class, extends @{Core.Fsm#FSM_PROCESS}
-- ==========================================================================
-- The @{#CARGO_BASE} class defines the core functions that defines a cargo object within MOOSE.
-- The @{#AI_CARGO} class defines the core functions that defines a cargo object within MOOSE.
-- A cargo is a logical object defined that is available for transport, and has a life status within a simulation.
--
-- The CARGO_BASE is a state machine: it manages the different events and states of the cargo.
-- All derived classes from CARGO_BASE follow the same state machine, expose the same cargo event functions, and provide the same cargo states.
-- The AI_CARGO is a state machine: it manages the different events and states of the cargo.
-- All derived classes from AI_CARGO follow the same state machine, expose the same cargo event functions, and provide the same cargo states.
--
-- ## 1.2.1) CARGO_BASE Events:
-- ## 1.2.1) AI_CARGO Events:
--
-- * @{#CARGO_BASE.Board}( ToCarrier ): Boards the cargo to a carrier.
-- * @{#CARGO_BASE.Load}( ToCarrier ): Loads the cargo into a carrier, regardless of its position.
-- * @{#CARGO_BASE.UnBoard}( ToPointVec2 ): UnBoard the cargo from a carrier. This will trigger a movement of the cargo to the option ToPointVec2.
-- * @{#CARGO_BASE.UnLoad}( ToPointVec2 ): UnLoads the cargo from a carrier.
-- * @{#CARGO_BASE.Dead}( Controllable ): The cargo is dead. The cargo process will be ended.
-- * @{#AI_CARGO.Board}( ToCarrier ): Boards the cargo to a carrier.
-- * @{#AI_CARGO.Load}( ToCarrier ): Loads the cargo into a carrier, regardless of its position.
-- * @{#AI_CARGO.UnBoard}( ToPointVec2 ): UnBoard the cargo from a carrier. This will trigger a movement of the cargo to the option ToPointVec2.
-- * @{#AI_CARGO.UnLoad}( ToPointVec2 ): UnLoads the cargo from a carrier.
-- * @{#AI_CARGO.Dead}( Controllable ): The cargo is dead. The cargo process will be ended.
--
-- ## 1.2.2) CARGO_BASE States:
-- ## 1.2.2) AI_CARGO States:
--
-- * **UnLoaded**: The cargo is unloaded from a carrier.
-- * **Boarding**: The cargo is currently boarding (= running) into a carrier.
@@ -37,7 +37,7 @@
-- * **Dead**: The cargo is dead ...
-- * **End**: The process has come to an end.
--
-- ## 1.2.3) CARGO_BASE state transition methods:
-- ## 1.2.3) AI_CARGO state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@@ -52,15 +52,15 @@
-- The state transition method needs to start with the name **OnAfter + the name of the state**.
-- These state transition methods need to provide a return value, which is specified at the function description.
--
-- 2) #CARGO_UNIT class
-- 2) #AI_CARGO_UNIT class
-- ====================
-- The CARGO_UNIT class defines a cargo that is represented by a UNIT object within the simulator, and can be transported by a carrier.
-- Use the event functions as described above to Load, UnLoad, Board, UnBoard the CARGO_UNIT objects to and from carriers.
-- The AI_CARGO_UNIT class defines a cargo that is represented by a UNIT object within the simulator, and can be transported by a carrier.
-- Use the event functions as described above to Load, UnLoad, Board, UnBoard the AI_CARGO_UNIT objects to and from carriers.
--
-- 5) #CARGO_GROUPED class
-- 5) #AI_CARGO_GROUPED class
-- =======================
-- The CARGO_GROUPED class defines a cargo that is represented by a group of UNIT objects within the simulator, and can be transported by a carrier.
-- Use the event functions as described above to Load, UnLoad, Board, UnBoard the CARGO_UNIT objects to and from carriers.
-- The AI_CARGO_GROUPED class defines a cargo that is represented by a group of UNIT objects within the simulator, and can be transported by a carrier.
-- Use the event functions as described above to Load, UnLoad, Board, UnBoard the AI_CARGO_UNIT objects to and from carriers.
--
-- This module is still under construction, but is described above works already, and will keep working ...
--
@@ -72,14 +72,14 @@
--- Boards the cargo to a Carrier. The event will create a movement (= running or driving) of the cargo to the Carrier.
-- The cargo must be in the **UnLoaded** state.
-- @function [parent=#CARGO_BASE] Board
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] Board
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE ToCarrier The Carrier that will hold the cargo.
--- Boards the cargo to a Carrier. The event will create a movement (= running or driving) of the cargo to the Carrier.
-- The cargo must be in the **UnLoaded** state.
-- @function [parent=#CARGO_BASE] __Board
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] __Board
-- @param #AI_CARGO self
-- @param #number DelaySeconds The amount of seconds to delay the action.
-- @param Wrapper.Controllable#CONTROLLABLE ToCarrier The Carrier that will hold the cargo.
@@ -88,14 +88,14 @@
--- UnBoards the cargo to a Carrier. The event will create a movement (= running or driving) of the cargo from the Carrier.
-- The cargo must be in the **Loaded** state.
-- @function [parent=#CARGO_BASE] UnBoard
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] UnBoard
-- @param #AI_CARGO self
-- @param Core.Point#POINT_VEC2 ToPointVec2 (optional) @{Core.Point#POINT_VEC2) to where the cargo should run after onboarding. If not provided, the cargo will run to 60 meters behind the Carrier location.
--- UnBoards the cargo to a Carrier. The event will create a movement (= running or driving) of the cargo from the Carrier.
-- The cargo must be in the **Loaded** state.
-- @function [parent=#CARGO_BASE] __UnBoard
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] __UnBoard
-- @param #AI_CARGO self
-- @param #number DelaySeconds The amount of seconds to delay the action.
-- @param Core.Point#POINT_VEC2 ToPointVec2 (optional) @{Core.Point#POINT_VEC2) to where the cargo should run after onboarding. If not provided, the cargo will run to 60 meters behind the Carrier location.
@@ -104,14 +104,14 @@
--- Loads the cargo to a Carrier. The event will load the cargo into the Carrier regardless of its position. There will be no movement simulated of the cargo loading.
-- The cargo must be in the **UnLoaded** state.
-- @function [parent=#CARGO_BASE] Load
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] Load
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE ToCarrier The Carrier that will hold the cargo.
--- Loads the cargo to a Carrier. The event will load the cargo into the Carrier regardless of its position. There will be no movement simulated of the cargo loading.
-- The cargo must be in the **UnLoaded** state.
-- @function [parent=#CARGO_BASE] __Load
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] __Load
-- @param #AI_CARGO self
-- @param #number DelaySeconds The amount of seconds to delay the action.
-- @param Wrapper.Controllable#CONTROLLABLE ToCarrier The Carrier that will hold the cargo.
@@ -120,14 +120,14 @@
--- UnLoads the cargo to a Carrier. The event will unload the cargo from the Carrier. There will be no movement simulated of the cargo loading.
-- The cargo must be in the **Loaded** state.
-- @function [parent=#CARGO_BASE] UnLoad
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] UnLoad
-- @param #AI_CARGO self
-- @param Core.Point#POINT_VEC2 ToPointVec2 (optional) @{Core.Point#POINT_VEC2) to where the cargo will be placed after unloading. If not provided, the cargo will be placed 60 meters behind the Carrier location.
--- UnLoads the cargo to a Carrier. The event will unload the cargo from the Carrier. There will be no movement simulated of the cargo loading.
-- The cargo must be in the **Loaded** state.
-- @function [parent=#CARGO_BASE] __UnLoad
-- @param #CARGO_BASE self
-- @function [parent=#AI_CARGO] __UnLoad
-- @param #AI_CARGO self
-- @param #number DelaySeconds The amount of seconds to delay the action.
-- @param Core.Point#POINT_VEC2 ToPointVec2 (optional) @{Core.Point#POINT_VEC2) to where the cargo will be placed after unloading. If not provided, the cargo will be placed 60 meters behind the Carrier location.
@@ -135,46 +135,46 @@
-- UnLoaded
--- @function [parent=#CARGO_BASE] OnBeforeUnLoaded
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnBeforeUnLoaded
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @return #boolean
--- @function [parent=#CARGO_BASE] OnAfterUnLoaded
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnAfterUnLoaded
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- Loaded
--- @function [parent=#CARGO_BASE] OnBeforeLoaded
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnBeforeLoaded
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @return #boolean
--- @function [parent=#CARGO_BASE] OnAfterLoaded
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnAfterLoaded
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- Boarding
--- @function [parent=#CARGO_BASE] OnBeforeBoarding
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnBeforeBoarding
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @return #boolean
--- @function [parent=#CARGO_BASE] OnAfterBoarding
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnAfterBoarding
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- UnBoarding
--- @function [parent=#CARGO_BASE] OnBeforeUnBoarding
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnBeforeUnBoarding
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @return #boolean
--- @function [parent=#CARGO_BASE] OnAfterUnBoarding
-- @param #CARGO_BASE self
--- @function [parent=#AI_CARGO] OnAfterUnBoarding
-- @param #AI_CARGO self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
@@ -182,10 +182,10 @@
CARGOS = {}
do -- CARGO_BASE
do -- AI_CARGO
--- @type CARGO_BASE
-- @extends Fsm.Fsm#FSM_PROCESS
--- @type AI_CARGO
-- @extends Core.Fsm#FSM_PROCESS
-- @field #string Type A string defining the type of the cargo. eg. Engineers, Equipment, Screwdrivers.
-- @field #string Name A string defining the name of the cargo. The name is the unique identifier of the cargo.
-- @field #number Weight A number defining the weight of the cargo. The weight is expressed in kg.
@@ -197,8 +197,8 @@ do -- CARGO_BASE
-- @field #boolean Moveable This flag defines if the cargo is moveable.
-- @field #boolean Representable This flag defines if the cargo can be represented by a DCS Unit.
-- @field #boolean Containable This flag defines if the cargo can be contained within a DCS Unit.
CARGO_BASE = {
ClassName = "CARGO_BASE",
AI_CARGO = {
ClassName = "AI_CARGO",
Type = nil,
Name = nil,
Weight = nil,
@@ -210,21 +210,21 @@ do -- CARGO_BASE
Containable = false,
}
--- @type CARGO_BASE.CargoObjects
--- @type AI_CARGO.CargoObjects
-- @map < #string, Wrapper.Positionable#POSITIONABLE > The alive POSITIONABLE objects representing the the cargo.
--- CARGO_BASE Constructor. This class is an abstract class and should not be instantiated.
-- @param #CARGO_BASE self
--- AI_CARGO Constructor. This class is an abstract class and should not be instantiated.
-- @param #AI_CARGO self
-- @param #string Type
-- @param #string Name
-- @param #number Weight
-- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional)
-- @return #CARGO_BASE
function CARGO_BASE:New( Type, Name, Weight, ReportRadius, NearRadius )
-- @return #AI_CARGO
function AI_CARGO:New( Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, FSM:New() ) -- Fsm.Fsm#FSM_CONTROLLABLE
local self = BASE:Inherit( self, FSM:New() ) -- Core.Fsm#FSM_CONTROLLABLE
self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
self:SetStartState( "UnLoaded" )
@@ -259,20 +259,20 @@ function CARGO_BASE:New( Type, Name, Weight, ReportRadius, NearRadius )
end
--- Template method to spawn a new representation of the CARGO_BASE in the simulator.
-- @param #CARGO_BASE self
-- @return #CARGO_BASE
function CARGO_BASE:Spawn( PointVec2 )
--- Template method to spawn a new representation of the AI_CARGO in the simulator.
-- @param #AI_CARGO self
-- @return #AI_CARGO
function AI_CARGO:Spawn( PointVec2 )
self:F()
end
--- Check if CargoCarrier is near the Cargo to be Loaded.
-- @param #CARGO_BASE self
-- @param #AI_CARGO self
-- @param Core.Point#POINT_VEC2 PointVec2
-- @return #boolean
function CARGO_BASE:IsNear( PointVec2 )
function AI_CARGO:IsNear( PointVec2 )
self:F( { PointVec2 } )
local Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
@@ -287,36 +287,36 @@ end
end
do -- CARGO_REPRESENTABLE
do -- AI_CARGO_REPRESENTABLE
--- @type CARGO_REPRESENTABLE
-- @extends #CARGO_BASE
CARGO_REPRESENTABLE = {
ClassName = "CARGO_REPRESENTABLE"
--- @type AI_CARGO_REPRESENTABLE
-- @extends #AI_CARGO
AI_CARGO_REPRESENTABLE = {
ClassName = "AI_CARGO_REPRESENTABLE"
}
--- CARGO_REPRESENTABLE Constructor.
-- @param #CARGO_REPRESENTABLE self
--- AI_CARGO_REPRESENTABLE Constructor.
-- @param #AI_CARGO_REPRESENTABLE self
-- @param Wrapper.Controllable#Controllable CargoObject
-- @param #string Type
-- @param #string Name
-- @param #number Weight
-- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional)
-- @return #CARGO_REPRESENTABLE
function CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, CARGO_BASE:New( Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO_BASE
-- @return #AI_CARGO_REPRESENTABLE
function AI_CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, AI_CARGO:New( Type, Name, Weight, ReportRadius, NearRadius ) ) -- #AI_CARGO
self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
return self
end
--- Route a cargo unit to a PointVec2.
-- @param #CARGO_REPRESENTABLE self
-- @param #AI_CARGO_REPRESENTABLE self
-- @param Core.Point#POINT_VEC2 ToPointVec2
-- @param #number Speed
-- @return #CARGO_REPRESENTABLE
function CARGO_REPRESENTABLE:RouteTo( ToPointVec2, Speed )
-- @return #AI_CARGO_REPRESENTABLE
function AI_CARGO_REPRESENTABLE:RouteTo( ToPointVec2, Speed )
self:F2( ToPointVec2 )
local Points = {}
@@ -331,27 +331,27 @@ function CARGO_REPRESENTABLE:RouteTo( ToPointVec2, Speed )
return self
end
end -- CARGO_BASE
end -- AI_CARGO
do -- CARGO_UNIT
do -- AI_CARGO_UNIT
--- @type CARGO_UNIT
-- @extends #CARGO_REPRESENTABLE
CARGO_UNIT = {
ClassName = "CARGO_UNIT"
--- @type AI_CARGO_UNIT
-- @extends #AI_CARGO_REPRESENTABLE
AI_CARGO_UNIT = {
ClassName = "AI_CARGO_UNIT"
}
--- CARGO_UNIT Constructor.
-- @param #CARGO_UNIT self
--- AI_CARGO_UNIT Constructor.
-- @param #AI_CARGO_UNIT self
-- @param Wrapper.Unit#UNIT CargoUnit
-- @param #string Type
-- @param #string Name
-- @param #number Weight
-- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional)
-- @return #CARGO_UNIT
function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoUnit, Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO_UNIT
-- @return #AI_CARGO_UNIT
function AI_CARGO_UNIT:New( CargoUnit, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, AI_CARGO_REPRESENTABLE:New( CargoUnit, Type, Name, Weight, ReportRadius, NearRadius ) ) -- #AI_CARGO_UNIT
self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
self:T( CargoUnit )
@@ -363,12 +363,12 @@ function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, ReportRadius, NearRadius
end
--- Enter UnBoarding State.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Core.Point#POINT_VEC2 ToPointVec2
function CARGO_UNIT:onenterUnBoarding( Event, From, To, ToPointVec2 )
function AI_CARGO_UNIT:onenterUnBoarding( Event, From, To, ToPointVec2 )
self:F()
local Angle = 180
@@ -408,12 +408,12 @@ function CARGO_UNIT:onenterUnBoarding( Event, From, To, ToPointVec2 )
end
--- Leave UnBoarding State.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Core.Point#POINT_VEC2 ToPointVec2
function CARGO_UNIT:onleaveUnBoarding( Event, From, To, ToPointVec2 )
function AI_CARGO_UNIT:onleaveUnBoarding( Event, From, To, ToPointVec2 )
self:F( { ToPointVec2, Event, From, To } )
local Angle = 180
@@ -432,12 +432,12 @@ function CARGO_UNIT:onleaveUnBoarding( Event, From, To, ToPointVec2 )
end
--- UnBoard Event.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Core.Point#POINT_VEC2 ToPointVec2
function CARGO_UNIT:onafterUnBoarding( Event, From, To, ToPointVec2 )
function AI_CARGO_UNIT:onafterUnBoarding( Event, From, To, ToPointVec2 )
self:F( { ToPointVec2, Event, From, To } )
self.CargoInAir = self.CargoObject:InAir()
@@ -457,12 +457,12 @@ end
--- Enter UnLoaded State.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Core.Point#POINT_VEC2
function CARGO_UNIT:onenterUnLoaded( Event, From, To, ToPointVec2 )
function AI_CARGO_UNIT:onenterUnLoaded( Event, From, To, ToPointVec2 )
self:F( { ToPointVec2, Event, From, To } )
local Angle = 180
@@ -495,12 +495,12 @@ end
--- Enter Boarding State.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Wrapper.Unit#UNIT CargoCarrier
function CARGO_UNIT:onenterBoarding( Event, From, To, CargoCarrier )
function AI_CARGO_UNIT:onenterBoarding( Event, From, To, CargoCarrier )
self:F( { CargoCarrier.UnitName, Event, From, To } )
local Speed = 10
@@ -527,12 +527,12 @@ function CARGO_UNIT:onenterBoarding( Event, From, To, CargoCarrier )
end
--- Leave Boarding State.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Wrapper.Unit#UNIT CargoCarrier
function CARGO_UNIT:onleaveBoarding( Event, From, To, CargoCarrier )
function AI_CARGO_UNIT:onleaveBoarding( Event, From, To, CargoCarrier )
self:F( { CargoCarrier.UnitName, Event, From, To } )
if self:IsNear( CargoCarrier:GetPointVec2() ) then
@@ -545,12 +545,12 @@ function CARGO_UNIT:onleaveBoarding( Event, From, To, CargoCarrier )
end
--- Loaded State.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Wrapper.Unit#UNIT CargoCarrier
function CARGO_UNIT:onenterLoaded( Event, From, To, CargoCarrier )
function AI_CARGO_UNIT:onenterLoaded( Event, From, To, CargoCarrier )
self:F()
self.CargoCarrier = CargoCarrier
@@ -564,11 +564,11 @@ end
--- Board Event.
-- @param #CARGO_UNIT self
-- @param #AI_CARGO_UNIT self
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_UNIT:onafterBoard( Event, From, To, CargoCarrier )
function AI_CARGO_UNIT:onafterBoard( Event, From, To, CargoCarrier )
self:F()
self.CargoInAir = self.CargoObject:InAir()
@@ -585,25 +585,25 @@ end
end
do -- CARGO_PACKAGE
do -- AI_CARGO_PACKAGE
--- @type CARGO_PACKAGE
-- @extends #CARGO_REPRESENTABLE
CARGO_PACKAGE = {
ClassName = "CARGO_PACKAGE"
--- @type AI_CARGO_PACKAGE
-- @extends #AI_CARGO_REPRESENTABLE
AI_CARGO_PACKAGE = {
ClassName = "AI_CARGO_PACKAGE"
}
--- CARGO_PACKAGE Constructor.
-- @param #CARGO_PACKAGE self
--- AI_CARGO_PACKAGE Constructor.
-- @param #AI_CARGO_PACKAGE self
-- @param Wrapper.Unit#UNIT CargoCarrier The UNIT carrying the package.
-- @param #string Type
-- @param #string Name
-- @param #number Weight
-- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional)
-- @return #CARGO_PACKAGE
function CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoCarrier, Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO_PACKAGE
-- @return #AI_CARGO_PACKAGE
function AI_CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, ReportRadius, NearRadius )
local self = BASE:Inherit( self, AI_CARGO_REPRESENTABLE:New( CargoCarrier, Type, Name, Weight, ReportRadius, NearRadius ) ) -- #AI_CARGO_PACKAGE
self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
self:T( CargoCarrier )
@@ -613,7 +613,7 @@ function CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, ReportRadius, Near
end
--- Board Event.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -621,7 +621,7 @@ end
-- @param #number Speed
-- @param #number BoardDistance
-- @param #number Angle
function CARGO_PACKAGE:onafterOnBoard( Event, From, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
function AI_CARGO_PACKAGE:onafterOnBoard( Event, From, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
self:F()
self.CargoInAir = self.CargoCarrier:InAir()
@@ -651,10 +651,10 @@ function CARGO_PACKAGE:onafterOnBoard( Event, From, To, CargoCarrier, Speed, Boa
end
--- Check if CargoCarrier is near the Cargo to be Loaded.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param Wrapper.Unit#UNIT CargoCarrier
-- @return #boolean
function CARGO_PACKAGE:IsNear( CargoCarrier )
function AI_CARGO_PACKAGE:IsNear( CargoCarrier )
self:F()
local CargoCarrierPoint = CargoCarrier:GetPointVec2()
@@ -670,12 +670,12 @@ function CARGO_PACKAGE:IsNear( CargoCarrier )
end
--- Boarded Event.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Wrapper.Unit#UNIT CargoCarrier
function CARGO_PACKAGE:onafterOnBoarded( Event, From, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
function AI_CARGO_PACKAGE:onafterOnBoarded( Event, From, To, CargoCarrier, Speed, BoardDistance, LoadDistance, Angle )
self:F()
if self:IsNear( CargoCarrier ) then
@@ -686,7 +686,7 @@ function CARGO_PACKAGE:onafterOnBoarded( Event, From, To, CargoCarrier, Speed, B
end
--- UnBoard Event.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -695,7 +695,7 @@ end
-- @param #number UnBoardDistance
-- @param #number Radius
-- @param #number Angle
function CARGO_PACKAGE:onafterUnBoard( Event, From, To, CargoCarrier, Speed, UnLoadDistance, UnBoardDistance, Radius, Angle )
function AI_CARGO_PACKAGE:onafterUnBoard( Event, From, To, CargoCarrier, Speed, UnLoadDistance, UnBoardDistance, Radius, Angle )
self:F()
self.CargoInAir = self.CargoCarrier:InAir()
@@ -728,12 +728,12 @@ function CARGO_PACKAGE:onafterUnBoard( Event, From, To, CargoCarrier, Speed, UnL
end
--- UnBoarded Event.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Wrapper.Unit#UNIT CargoCarrier
function CARGO_PACKAGE:onafterUnBoarded( Event, From, To, CargoCarrier, Speed )
function AI_CARGO_PACKAGE:onafterUnBoarded( Event, From, To, CargoCarrier, Speed )
self:F()
if self:IsNear( CargoCarrier ) then
@@ -744,7 +744,7 @@ function CARGO_PACKAGE:onafterUnBoarded( Event, From, To, CargoCarrier, Speed )
end
--- Load Event.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -752,7 +752,7 @@ end
-- @param #number Speed
-- @param #number LoadDistance
-- @param #number Angle
function CARGO_PACKAGE:onafterLoad( Event, From, To, CargoCarrier, Speed, LoadDistance, Angle )
function AI_CARGO_PACKAGE:onafterLoad( Event, From, To, CargoCarrier, Speed, LoadDistance, Angle )
self:F()
self.CargoCarrier = CargoCarrier
@@ -772,13 +772,13 @@ function CARGO_PACKAGE:onafterLoad( Event, From, To, CargoCarrier, Speed, LoadDi
end
--- UnLoad Event.
-- @param #CARGO_PACKAGE self
-- @param #AI_CARGO_PACKAGE self
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param #number Distance
-- @param #number Angle
function CARGO_PACKAGE:onafterUnLoad( Event, From, To, CargoCarrier, Speed, Distance, Angle )
function AI_CARGO_PACKAGE:onafterUnLoad( Event, From, To, CargoCarrier, Speed, Distance, Angle )
self:F()
local StartPointVec2 = self.CargoCarrier:GetPointVec2()
@@ -800,27 +800,27 @@ end
end
do -- CARGO_GROUP
do -- AI_CARGO_GROUP
--- @type CARGO_GROUP
-- @extends Fsm.Cargo#CARGO_BASE
--- @type AI_CARGO_GROUP
-- @extends AI.AI_Cargo#AI_CARGO
-- @field Set#SET_BASE CargoSet A set of cargo objects.
-- @field #string Name A string defining the name of the cargo group. The name is the unique identifier of the cargo.
CARGO_GROUP = {
ClassName = "CARGO_GROUP",
AI_CARGO_GROUP = {
ClassName = "AI_CARGO_GROUP",
}
--- CARGO_GROUP constructor.
-- @param #CARGO_GROUP self
--- AI_CARGO_GROUP constructor.
-- @param #AI_CARGO_GROUP self
-- @param Core.Set#Set_BASE CargoSet
-- @param #string Type
-- @param #string Name
-- @param #number Weight
-- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional)
-- @return #CARGO_GROUP
function CARGO_GROUP:New( CargoSet, Type, Name, ReportRadius, NearRadius )
local self = BASE:Inherit( self, CARGO_BASE:New( Type, Name, 0, ReportRadius, NearRadius ) ) -- #CARGO_GROUP
-- @return #AI_CARGO_GROUP
function AI_CARGO_GROUP:New( CargoSet, Type, Name, ReportRadius, NearRadius )
local self = BASE:Inherit( self, AI_CARGO:New( Type, Name, 0, ReportRadius, NearRadius ) ) -- #AI_CARGO_GROUP
self:F( { Type, Name, ReportRadius, NearRadius } )
self.CargoSet = CargoSet
@@ -829,44 +829,44 @@ function CARGO_GROUP:New( CargoSet, Type, Name, ReportRadius, NearRadius )
return self
end
end -- CARGO_GROUP
end -- AI_CARGO_GROUP
do -- CARGO_GROUPED
do -- AI_CARGO_GROUPED
--- @type CARGO_GROUPED
-- @extends Fsm.Cargo#CARGO_GROUP
CARGO_GROUPED = {
ClassName = "CARGO_GROUPED",
--- @type AI_CARGO_GROUPED
-- @extends AI.AI_Cargo#AI_CARGO_GROUP
AI_CARGO_GROUPED = {
ClassName = "AI_CARGO_GROUPED",
}
--- CARGO_GROUPED constructor.
-- @param #CARGO_GROUPED self
--- AI_CARGO_GROUPED constructor.
-- @param #AI_CARGO_GROUPED self
-- @param Core.Set#Set_BASE CargoSet
-- @param #string Type
-- @param #string Name
-- @param #number Weight
-- @param #number ReportRadius (optional)
-- @param #number NearRadius (optional)
-- @return #CARGO_GROUPED
function CARGO_GROUPED:New( CargoSet, Type, Name, ReportRadius, NearRadius )
local self = BASE:Inherit( self, CARGO_GROUP:New( CargoSet, Type, Name, ReportRadius, NearRadius ) ) -- #CARGO_GROUPED
-- @return #AI_CARGO_GROUPED
function AI_CARGO_GROUPED:New( CargoSet, Type, Name, ReportRadius, NearRadius )
local self = BASE:Inherit( self, AI_CARGO_GROUP:New( CargoSet, Type, Name, ReportRadius, NearRadius ) ) -- #AI_CARGO_GROUPED
self:F( { Type, Name, ReportRadius, NearRadius } )
return self
end
--- Enter Boarding State.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Wrapper.Unit#UNIT CargoCarrier
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onenterBoarding( Event, From, To, CargoCarrier )
function AI_CARGO_GROUPED:onenterBoarding( Event, From, To, CargoCarrier )
self:F( { CargoCarrier.UnitName, Event, From, To } )
if From == "UnLoaded" then
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
-- For each Cargo object within the AI_CARGO_GROUPED, route each object to the CargoLoadPointVec2
self.CargoSet:ForEach(
function( Cargo )
Cargo:__Board( 1, CargoCarrier )
@@ -879,16 +879,16 @@ function CARGO_GROUPED:onenterBoarding( Event, From, To, CargoCarrier )
end
--- Enter Loaded State.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Wrapper.Unit#UNIT CargoCarrier
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onenterLoaded( Event, From, To, CargoCarrier )
function AI_CARGO_GROUPED:onenterLoaded( Event, From, To, CargoCarrier )
self:F( { CargoCarrier.UnitName, Event, From, To } )
if From == "UnLoaded" then
-- For each Cargo object within the CARGO_GROUPED, load each cargo to the CargoCarrier.
-- For each Cargo object within the AI_CARGO_GROUPED, load each cargo to the CargoCarrier.
for CargoID, Cargo in pairs( self.CargoSet:GetSet() ) do
Cargo:Load( CargoCarrier )
end
@@ -896,17 +896,17 @@ function CARGO_GROUPED:onenterLoaded( Event, From, To, CargoCarrier )
end
--- Leave Boarding State.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Wrapper.Unit#UNIT CargoCarrier
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onleaveBoarding( Event, From, To, CargoCarrier )
function AI_CARGO_GROUPED:onleaveBoarding( Event, From, To, CargoCarrier )
self:F( { CargoCarrier.UnitName, Event, From, To } )
local Boarded = true
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
-- For each Cargo object within the AI_CARGO_GROUPED, route each object to the CargoLoadPointVec2
for CargoID, Cargo in pairs( self.CargoSet:GetSet() ) do
self:T( Cargo.current )
if not Cargo:is( "Loaded" ) then
@@ -923,19 +923,19 @@ function CARGO_GROUPED:onleaveBoarding( Event, From, To, CargoCarrier )
end
--- Enter UnBoarding State.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Core.Point#POINT_VEC2 ToPointVec2
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onenterUnBoarding( Event, From, To, ToPointVec2 )
function AI_CARGO_GROUPED:onenterUnBoarding( Event, From, To, ToPointVec2 )
self:F()
local Timer = 1
if From == "Loaded" then
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
-- For each Cargo object within the AI_CARGO_GROUPED, route each object to the CargoLoadPointVec2
self.CargoSet:ForEach(
function( Cargo )
Cargo:__UnBoard( Timer, ToPointVec2 )
@@ -949,12 +949,12 @@ function CARGO_GROUPED:onenterUnBoarding( Event, From, To, ToPointVec2 )
end
--- Leave UnBoarding State.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Core.Point#POINT_VEC2 ToPointVec2
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onleaveUnBoarding( Event, From, To, ToPointVec2 )
function AI_CARGO_GROUPED:onleaveUnBoarding( Event, From, To, ToPointVec2 )
self:F( { ToPointVec2, Event, From, To } )
local Angle = 180
@@ -964,7 +964,7 @@ function CARGO_GROUPED:onleaveUnBoarding( Event, From, To, ToPointVec2 )
if From == "UnBoarding" then
local UnBoarded = true
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
-- For each Cargo object within the AI_CARGO_GROUPED, route each object to the CargoLoadPointVec2
for CargoID, Cargo in pairs( self.CargoSet:GetSet() ) do
self:T( Cargo.current )
if not Cargo:is( "UnLoaded" ) then
@@ -984,12 +984,12 @@ function CARGO_GROUPED:onleaveUnBoarding( Event, From, To, ToPointVec2 )
end
--- UnBoard Event.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Core.Point#POINT_VEC2 ToPointVec2
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onafterUnBoarding( Event, From, To, ToPointVec2 )
function AI_CARGO_GROUPED:onafterUnBoarding( Event, From, To, ToPointVec2 )
self:F( { ToPointVec2, Event, From, To } )
self:__UnLoad( 1, ToPointVec2 )
@@ -998,17 +998,17 @@ end
--- Enter UnLoaded State.
-- @param #CARGO_GROUPED self
-- @param #AI_CARGO_GROUPED self
-- @param Core.Point#POINT_VEC2
-- @param #string Event
-- @param #string From
-- @param #string To
function CARGO_GROUPED:onenterUnLoaded( Event, From, To, ToPointVec2 )
function AI_CARGO_GROUPED:onenterUnLoaded( Event, From, To, ToPointVec2 )
self:F( { ToPointVec2, Event, From, To } )
if From == "Loaded" then
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
-- For each Cargo object within the AI_CARGO_GROUPED, route each object to the CargoLoadPointVec2
self.CargoSet:ForEach(
function( Cargo )
Cargo:UnLoad( ToPointVec2 )
@@ -1019,7 +1019,7 @@ function CARGO_GROUPED:onenterUnLoaded( Event, From, To, ToPointVec2 )
end
end -- CARGO_GROUPED
end -- AI_CARGO_GROUPED

View File

@@ -2,9 +2,9 @@
--
-- ===
--
-- 1) @{#PATROLZONE} class, extends @{Fsm.Fsm#FSM}
-- 1) @{#AI_PATROLZONE} class, extends @{Core.Fsm#FSM_CONTROLLABLE}
-- ================================================================
-- The @{#PATROLZONE} class implements the core functions to patrol a @{Zone} by an AIR @{Controllable} @{Group}.
-- The @{#AI_PATROLZONE} class implements the core functions to patrol a @{Zone} by an AIR @{Controllable} @{Group}.
-- The patrol algorithm works that for each airplane patrolling, upon arrival at the patrol zone,
-- a random point is selected as the route point within the 3D space, within the given boundary limits.
-- The airplane will fly towards the random 3D point within the patrol zone, using a random speed within the given altitude and speed limits.
@@ -12,24 +12,24 @@
-- This cycle will continue until a fuel treshold has been reached by the airplane.
-- When the fuel treshold has been reached, the airplane will fly towards the nearest friendly airbase and will land.
--
-- 1.1) PATROLZONE constructor:
-- 1.1) AI_PATROLZONE constructor:
-- ----------------------------
--
-- * @{#PATROLZONE.New}(): Creates a new PATROLZONE object.
-- * @{#AI_PATROLZONE.New}(): Creates a new AI_PATROLZONE object.
--
-- 1.2) PATROLZONE state machine:
-- 1.2) AI_PATROLZONE state machine:
-- ----------------------------------
-- The PATROLZONE is a state machine: it manages the different events and states of the AIControllable it is controlling.
-- The AI_PATROLZONE is a state machine: it manages the different events and states of the AIControllable it is controlling.
--
-- ### 1.2.1) PATROLZONE Events:
-- ### 1.2.1) AI_PATROLZONE Events:
--
-- * @{#PATROLZONE.Route}( AIControllable ): A new 3D route point is selected and the AIControllable will fly towards that point with the given speed.
-- * @{#PATROLZONE.Patrol}( AIControllable ): The AIControllable reports it is patrolling. This event is called every 30 seconds.
-- * @{#PATROLZONE.RTB}( AIControllable ): The AIControllable will report return to base.
-- * @{#PATROLZONE.End}( AIControllable ): The end of the PATROLZONE process.
-- * @{#PATROLZONE.Dead}( AIControllable ): The AIControllable is dead. The PATROLZONE process will be ended.
-- * @{#AI_PATROLZONE.Route}( AIControllable ): A new 3D route point is selected and the AIControllable will fly towards that point with the given speed.
-- * @{#AI_PATROLZONE.Patrol}( AIControllable ): The AIControllable reports it is patrolling. This event is called every 30 seconds.
-- * @{#AI_PATROLZONE.RTB}( AIControllable ): The AIControllable will report return to base.
-- * @{#AI_PATROLZONE.End}( AIControllable ): The end of the AI_PATROLZONE process.
-- * @{#AI_PATROLZONE.Dead}( AIControllable ): The AIControllable is dead. The AI_PATROLZONE process will be ended.
--
-- ### 1.2.2) PATROLZONE States:
-- ### 1.2.2) AI_PATROLZONE States:
--
-- * **Route**: A new 3D route point is selected and the AIControllable will fly towards that point with the given speed.
-- * **Patrol**: The AIControllable is patrolling. This state is set every 30 seconds, so every 30 seconds, a state transition method can be used.
@@ -37,7 +37,7 @@
-- * **Dead**: The AIControllable is dead ...
-- * **End**: The process has come to an end.
--
-- ### 1.2.3) PATROLZONE state transition methods:
-- ### 1.2.3) AI_PATROLZONE state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@@ -52,7 +52,7 @@
-- The state transition method needs to start with the name **OnAfter + the name of the state**.
-- These state transition methods need to provide a return value, which is specified at the function description.
--
-- An example how to manage a state transition for an PATROLZONE object **Patrol** for the state **RTB**:
-- An example how to manage a state transition for an AI_PATROLZONE object **Patrol** for the state **RTB**:
--
-- local PatrolZoneGroup = GROUP:FindByName( "Patrol Zone" )
-- local PatrolZone = ZONE_POLYGON:New( "PatrolZone", PatrolZoneGroup )
@@ -60,46 +60,46 @@
-- local PatrolSpawn = SPAWN:New( "Patrol Group" )
-- local PatrolGroup = PatrolSpawn:Spawn()
--
-- local Patrol = PATROLZONE:New( PatrolZone, 3000, 6000, 300, 600 )
-- local Patrol = AI_PATROLZONE:New( PatrolZone, 3000, 6000, 300, 600 )
-- Patrol:SetControllable( PatrolGroup )
-- Patrol:ManageFuel( 0.2, 60 )
--
-- **OnBefore**RTB( AIGroup ) will be called by the PATROLZONE object when the AIGroup reports RTB, but **before** the RTB default action is processed by the PATROLZONE object.
-- **OnBefore**RTB( AIGroup ) will be called by the AI_PATROLZONE object when the AIGroup reports RTB, but **before** the RTB default action is processed by the AI_PATROLZONE object.
--
-- --- State transition function for the PATROLZONE **Patrol** object
-- -- @param #PATROLZONE self
-- --- State transition function for the AI_PATROLZONE **Patrol** object
-- -- @param #AI_PATROLZONE self
-- -- @param Wrapper.Controllable#CONTROLLABLE AIGroup
-- -- @return #boolean If false is returned, then the OnAfter state transition method will not be called.
-- function Patrol:OnBeforeRTB( AIGroup )
-- AIGroup:MessageToRed( "Returning to base", 20 )
-- end
--
-- **OnAfter**RTB( AIGroup ) will be called by the PATROLZONE object when the AIGroup reports RTB, but **after** the RTB default action was processed by the PATROLZONE object.
-- **OnAfter**RTB( AIGroup ) will be called by the AI_PATROLZONE object when the AIGroup reports RTB, but **after** the RTB default action was processed by the AI_PATROLZONE object.
--
-- --- State transition function for the PATROLZONE **Patrol** object
-- -- @param #PATROLZONE self
-- --- State transition function for the AI_PATROLZONE **Patrol** object
-- -- @param #AI_PATROLZONE self
-- -- @param Wrapper.Controllable#CONTROLLABLE AIGroup
-- -- @return #Wrapper.Controllable#CONTROLLABLE The new AIGroup object that is set to be patrolling the zone.
-- function Patrol:OnAfterRTB( AIGroup )
-- return PatrolSpawn:Spawn()
-- end
--
-- 1.3) Manage the PATROLZONE parameters:
-- 1.3) Manage the AI_PATROLZONE parameters:
-- ------------------------------------------
-- The following methods are available to modify the parameters of a PATROLZONE object:
-- The following methods are available to modify the parameters of a AI_PATROLZONE object:
--
-- * @{#PATROLZONE.SetControllable}(): Set the AIControllable.
-- * @{#PATROLZONE.GetControllable}(): Get the AIControllable.
-- * @{#PATROLZONE.SetSpeed}(): Set the patrol speed of the AI, for the next patrol.
-- * @{#PATROLZONE.SetAltitude}(): Set altitude of the AI, for the next patrol.
-- * @{#AI_PATROLZONE.SetControllable}(): Set the AIControllable.
-- * @{#AI_PATROLZONE.GetControllable}(): Get the AIControllable.
-- * @{#AI_PATROLZONE.SetSpeed}(): Set the patrol speed of the AI, for the next patrol.
-- * @{#AI_PATROLZONE.SetAltitude}(): Set altitude of the AI, for the next patrol.
--
-- 1.3) Manage the out of fuel in the PATROLZONE:
-- 1.3) Manage the out of fuel in the AI_PATROLZONE:
-- ----------------------------------------------
-- When the AIControllable is out of fuel, it is required that a new AIControllable is started, before the old AIControllable can return to the home base.
-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated.
-- When the fuel treshold is reached, the AIControllable will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the PATROLZONE.
-- When the fuel treshold is reached, the AIControllable will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_PATROLZONE.
-- Once the time is finished, the old AIControllable will return to the base.
-- Use the method @{#PATROLZONE.ManageFuel}() to have this proces in place.
-- Use the method @{#AI_PATROLZONE.ManageFuel}() to have this proces in place.
--
-- ====
--
@@ -135,50 +135,50 @@
-- State Transition Functions
--- OnBefore State Transition Function
-- @function [parent=#PATROLZONE] OnBeforeRoute
-- @param #PATROLZONE self
-- @function [parent=#AI_PATROLZONE] OnBeforeRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
-- @return #boolean
--- OnAfter State Transition Function
-- @function [parent=#PATROLZONE] OnAfterRoute
-- @param #PATROLZONE self
-- @function [parent=#AI_PATROLZONE] OnAfterRoute
-- @param #AI_PATROLZONE self
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
--- PATROLZONE class
-- @type PATROLZONE
--- AI_PATROLZONE class
-- @type AI_PATROLZONE
-- @field Wrapper.Controllable#CONTROLLABLE AIControllable The @{Controllable} patrolling.
-- @field Core.Zone#ZONE_BASE PatrolZone The @{Zone} where the patrol needs to be executed.
-- @field Dcs.DCSTypes#Altitude PatrolFloorAltitude The lowest altitude in meters where to execute the patrol.
-- @field Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol.
-- @field Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h.
-- @field Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h.
-- @extends Fsm.Fsm#FSM_CONTROLLABLE
PATROLZONE = {
ClassName = "PATROLZONE",
-- @extends Core.Fsm#FSM_CONTROLLABLE
AI_PATROLZONE = {
ClassName = "AI_PATROLZONE",
}
--- Creates a new PATROLZONE object
-- @param #PATROLZONE self
--- Creates a new AI_PATROLZONE object
-- @param #AI_PATROLZONE self
-- @param Core.Zone#ZONE_BASE PatrolZone The @{Zone} where the patrol needs to be executed.
-- @param Dcs.DCSTypes#Altitude PatrolFloorAltitude The lowest altitude in meters where to execute the patrol.
-- @param Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol.
-- @param Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h.
-- @param Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h.
-- @return #PATROLZONE self
-- @return #AI_PATROLZONE self
-- @usage
-- -- Define a new PATROLZONE Object. This PatrolArea will patrol an AIControllable within PatrolZone between 3000 and 6000 meters, with a variying speed between 600 and 900 km/h.
-- -- Define a new AI_PATROLZONE Object. This PatrolArea will patrol an AIControllable within PatrolZone between 3000 and 6000 meters, with a variying speed between 600 and 900 km/h.
-- PatrolZone = ZONE:New( 'PatrolZone' )
-- PatrolSpawn = SPAWN:New( 'Patrol Group' )
-- PatrolArea = PATROLZONE:New( PatrolZone, 3000, 6000, 600, 900 )
function PATROLZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed )
-- PatrolArea = AI_PATROLZONE:New( PatrolZone, 3000, 6000, 600, 900 )
function AI_PATROLZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed )
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New() ) -- Fsm.Fsm#FSM_CONTROLLABLE
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New() ) -- Core.Fsm#FSM_CONTROLLABLE
self:SetStartState( "None" )
self:AddTransition( "*", "Start", "Route" )
@@ -201,11 +201,11 @@ end
--- Sets (modifies) the minimum and maximum speed of the patrol.
-- @param #PATROLZONE self
-- @param #AI_PATROLZONE self
-- @param Dcs.DCSTypes#Speed PatrolMinSpeed The minimum speed of the @{Controllable} in km/h.
-- @param Dcs.DCSTypes#Speed PatrolMaxSpeed The maximum speed of the @{Controllable} in km/h.
-- @return #PATROLZONE self
function PATROLZONE:SetSpeed( PatrolMinSpeed, PatrolMaxSpeed )
-- @return #AI_PATROLZONE self
function AI_PATROLZONE:SetSpeed( PatrolMinSpeed, PatrolMaxSpeed )
self:F2( { PatrolMinSpeed, PatrolMaxSpeed } )
self.PatrolMinSpeed = PatrolMinSpeed
@@ -215,11 +215,11 @@ end
--- Sets the floor and ceiling altitude of the patrol.
-- @param #PATROLZONE self
-- @param #AI_PATROLZONE self
-- @param Dcs.DCSTypes#Altitude PatrolFloorAltitude The lowest altitude in meters where to execute the patrol.
-- @param Dcs.DCSTypes#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol.
-- @return #PATROLZONE self
function PATROLZONE:SetAltitude( PatrolFloorAltitude, PatrolCeilingAltitude )
-- @return #AI_PATROLZONE self
function AI_PATROLZONE:SetAltitude( PatrolFloorAltitude, PatrolCeilingAltitude )
self:F2( { PatrolFloorAltitude, PatrolCeilingAltitude } )
self.PatrolFloorAltitude = PatrolFloorAltitude
@@ -232,7 +232,7 @@ end
function _NewPatrolRoute( AIControllable )
AIControllable:T( "NewPatrolRoute" )
local PatrolZone = AIControllable:GetState( AIControllable, "PatrolZone" ) -- PatrolCore.Zone#PATROLZONE
local PatrolZone = AIControllable:GetState( AIControllable, "PatrolZone" ) -- PatrolCore.Zone#AI_PATROLZONE
PatrolZone:__Route( 1 )
end
@@ -241,13 +241,13 @@ end
--- When the AIControllable is out of fuel, it is required that a new AIControllable is started, before the old AIControllable can return to the home base.
-- Therefore, with a parameter and a calculation of the distance to the home base, the fuel treshold is calculated.
-- When the fuel treshold is reached, the AIControllable will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the PATROLZONE.
-- When the fuel treshold is reached, the AIControllable will continue for a given time its patrol task in orbit, while a new AIControllable is targetted to the AI_PATROLZONE.
-- Once the time is finished, the old AIControllable will return to the base.
-- @param #PATROLZONE self
-- @param #AI_PATROLZONE self
-- @param #number PatrolFuelTresholdPercentage The treshold in percentage (between 0 and 1) when the AIControllable is considered to get out of fuel.
-- @param #number PatrolOutOfFuelOrbitTime The amount of seconds the out of fuel AIControllable will orbit before returning to the base.
-- @return #PATROLZONE self
function PATROLZONE:ManageFuel( PatrolFuelTresholdPercentage, PatrolOutOfFuelOrbitTime )
-- @return #AI_PATROLZONE self
function AI_PATROLZONE:ManageFuel( PatrolFuelTresholdPercentage, PatrolOutOfFuelOrbitTime )
self.PatrolManageFuel = true
self.PatrolFuelTresholdPercentage = PatrolFuelTresholdPercentage
@@ -257,9 +257,9 @@ function PATROLZONE:ManageFuel( PatrolFuelTresholdPercentage, PatrolOutOfFuelOrb
end
--- Defines a new patrol route using the @{Process_PatrolZone} parameters and settings.
-- @param #PATROLZONE self
-- @return #PATROLZONE self
function PATROLZONE:onenterRoute()
-- @param #AI_PATROLZONE self
-- @return #AI_PATROLZONE self
function AI_PATROLZONE:onenterRoute()
self:F2()
@@ -345,7 +345,7 @@ function PATROLZONE:onenterRoute()
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
--- NOW FSM_ROUTE THE GROUP!
--- NOW ACT_ROUTE THE GROUP!
self.Controllable:WayPointExecute( 1 )
self:__Patrol( 30 )
@@ -354,8 +354,8 @@ function PATROLZONE:onenterRoute()
end
--- @param #PATROLZONE self
function PATROLZONE:onenterPatrol()
--- @param #AI_PATROLZONE self
function AI_PATROLZONE:onenterPatrol()
self:F2()
if self.Controllable and self.Controllable:IsAlive() then

View File

@@ -2,16 +2,16 @@
--
-- ===
--
-- # @{#FSM_ACCOUNT} FSM class, extends @{Fsm.Fsm#FSM_PROCESS}
-- # @{#ACT_ACCOUNT} FSM class, extends @{Core.Fsm#FSM_PROCESS}
--
-- ## FSM_ACCOUNT state machine:
-- ## ACT_ACCOUNT state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSM_ACCOUNT **Events**:
-- ### ACT_ACCOUNT **Events**:
--
-- These are the events defined in this class:
--
@@ -21,7 +21,7 @@
-- * **More**: There are more DCS events that need to be accounted for. The process will go back into the Report state.
-- * **NoMore**: There are no more DCS events that need to be accounted for. The process will go into the Success state.
--
-- ### FSM_ACCOUNT **Event methods**:
-- ### ACT_ACCOUNT **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@@ -29,7 +29,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSM_ACCOUNT **States**:
-- ### ACT_ACCOUNT **States**:
--
-- * **Assigned**: The player is assigned to the task. This is the initialization state for the process.
-- * **Waiting**: the process is waiting for a DCS event to occur within the simulator. This state is set automatically.
@@ -40,7 +40,7 @@
--
-- (*) End states of the process.
--
-- ### FSM_ACCOUNT state transition methods:
-- ### ACT_ACCOUNT state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@@ -55,41 +55,41 @@
-- The state transition method needs to start with the name **OnAfter + the name of the state**.
-- These state transition methods need to provide a return value, which is specified at the function description.
--
-- # 1) @{#FSM_ACCOUNT_DEADS} FSM class, extends @{Fsm.Account#FSM_ACCOUNT}
-- # 1) @{#ACT_ACCOUNT_DEADS} FSM class, extends @{Fsm.Account#ACT_ACCOUNT}
--
-- The FSM_ACCOUNT_DEADS class accounts (detects, counts and reports) successful kills of DCS units.
-- The ACT_ACCOUNT_DEADS class accounts (detects, counts and reports) successful kills of DCS units.
-- The process is given a @{Set} of units that will be tracked upon successful destruction.
-- The process will end after each target has been successfully destroyed.
-- Each successful dead will trigger an Account state transition that can be scored, modified or administered.
--
--
-- ## FSM_ACCOUNT_DEADS constructor:
-- ## ACT_ACCOUNT_DEADS constructor:
--
-- * @{#FSM_ACCOUNT_DEADS.New}(): Creates a new FSM_ACCOUNT_DEADS object.
-- * @{#ACT_ACCOUNT_DEADS.New}(): Creates a new ACT_ACCOUNT_DEADS object.
--
-- ===
--
-- @module Account
do -- FSM_ACCOUNT
do -- ACT_ACCOUNT
--- FSM_ACCOUNT class
-- @type FSM_ACCOUNT
--- ACT_ACCOUNT class
-- @type ACT_ACCOUNT
-- @field Set#SET_UNIT TargetSetUnit
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_ACCOUNT = {
ClassName = "FSM_ACCOUNT",
-- @extends Core.Fsm#FSM_PROCESS
ACT_ACCOUNT = {
ClassName = "ACT_ACCOUNT",
TargetSetUnit = nil,
}
--- Creates a new DESTROY process.
-- @param #FSM_ACCOUNT self
-- @return #FSM_ACCOUNT
function FSM_ACCOUNT:New()
-- @param #ACT_ACCOUNT self
-- @return #ACT_ACCOUNT
function ACT_ACCOUNT:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_PROCESS:New() ) -- Fsm.Fsm#FSM_PROCESS
local self = BASE:Inherit( self, FSM_PROCESS:New() ) -- Core.Fsm#FSM_PROCESS
self:AddTransition( "Assigned", "Start", "Waiting")
self:AddTransition( "*", "Wait", "Waiting")
@@ -110,12 +110,12 @@ do -- FSM_ACCOUNT
--- Process Events
--- StateMachine callback function
-- @param #FSM_ACCOUNT self
-- @param #ACT_ACCOUNT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ACCOUNT:onafterStart( ProcessUnit, Event, From, To )
function ACT_ACCOUNT:onafterStart( ProcessUnit, Event, From, To )
self:EventOnDead( self.onfuncEventDead )
@@ -124,12 +124,12 @@ do -- FSM_ACCOUNT
--- StateMachine callback function
-- @param #FSM_ACCOUNT self
-- @param #ACT_ACCOUNT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ACCOUNT:onenterWaiting( ProcessUnit, Event, From, To )
function ACT_ACCOUNT:onenterWaiting( ProcessUnit, Event, From, To )
if self.DisplayCount >= self.DisplayInterval then
self:Report()
@@ -142,37 +142,37 @@ do -- FSM_ACCOUNT
end
--- StateMachine callback function
-- @param #FSM_ACCOUNT self
-- @param #ACT_ACCOUNT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ACCOUNT:onafterEvent( ProcessUnit, Event, From, To, Event )
function ACT_ACCOUNT:onafterEvent( ProcessUnit, Event, From, To, Event )
self:__NoMore( 1 )
end
end -- FSM_ACCOUNT
end -- ACT_ACCOUNT
do -- FSM_ACCOUNT_DEADS
do -- ACT_ACCOUNT_DEADS
--- FSM_ACCOUNT_DEADS class
-- @type FSM_ACCOUNT_DEADS
--- ACT_ACCOUNT_DEADS class
-- @type ACT_ACCOUNT_DEADS
-- @field Set#SET_UNIT TargetSetUnit
-- @extends #FSM_ACCOUNT
FSM_ACCOUNT_DEADS = {
ClassName = "FSM_ACCOUNT_DEADS",
-- @extends #ACT_ACCOUNT
ACT_ACCOUNT_DEADS = {
ClassName = "ACT_ACCOUNT_DEADS",
TargetSetUnit = nil,
}
--- Creates a new DESTROY process.
-- @param #FSM_ACCOUNT_DEADS self
-- @param #ACT_ACCOUNT_DEADS self
-- @param Set#SET_UNIT TargetSetUnit
-- @param #string TaskName
function FSM_ACCOUNT_DEADS:New( TargetSetUnit, TaskName )
function ACT_ACCOUNT_DEADS:New( TargetSetUnit, TaskName )
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_ACCOUNT:New() ) -- #FSM_ACCOUNT_DEADS
local self = BASE:Inherit( self, ACT_ACCOUNT:New() ) -- #ACT_ACCOUNT_DEADS
self.TargetSetUnit = TargetSetUnit
self.TaskName = TaskName
@@ -186,7 +186,7 @@ do -- FSM_ACCOUNT_DEADS
return self
end
function FSM_ACCOUNT_DEADS:Init( FsmAccount )
function ACT_ACCOUNT_DEADS:Init( FsmAccount )
self.TargetSetUnit = FsmAccount.TargetSetUnit
self.TaskName = FsmAccount.TaskName
@@ -194,7 +194,7 @@ do -- FSM_ACCOUNT_DEADS
function FSM_ACCOUNT_DEADS:_Destructor()
function ACT_ACCOUNT_DEADS:_Destructor()
self:E("_Destructor")
self:EventRemoveAll()
@@ -204,26 +204,25 @@ do -- FSM_ACCOUNT_DEADS
--- Process Events
--- StateMachine callback function
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ACCOUNT_DEADS self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ACCOUNT_DEADS:onenterReport( ProcessUnit, Event, From, To )
function ACT_ACCOUNT_DEADS:onenterReport( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
local TaskGroup = ProcessUnit:GetGroup()
MESSAGE:New( "Your group with assigned " .. self.TaskName .. " task has " .. self.TargetSetUnit:GetUnitTypesText() .. " targets left to be destroyed.", 5, "HQ" ):ToGroup( TaskGroup )
self:Message( "Your group with assigned " .. self.TaskName .. " task has " .. self.TargetSetUnit:GetUnitTypesText() .. " targets left to be destroyed." )
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ACCOUNT_DEADS self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ACCOUNT_DEADS:onenterAccount( ProcessUnit, Event, From, To, EventData )
function ACT_ACCOUNT_DEADS:onenterAccount( ProcessUnit, Event, From, To, EventData )
self:T( { ProcessUnit, EventData, Event, From, To } )
self:T({self.Controllable})
@@ -233,17 +232,17 @@ do -- FSM_ACCOUNT_DEADS
if self.TargetSetUnit:FindUnit( EventData.IniUnitName ) then
local TaskGroup = ProcessUnit:GetGroup()
self.TargetSetUnit:RemoveUnitsByName( EventData.IniUnitName )
MESSAGE:New( "You hit a target. Your group with assigned " .. self.TaskName .. " task has " .. self.TargetSetUnit:Count() .. " targets ( " .. self.TargetSetUnit:GetUnitTypesText() .. " ) left to be destroyed.", 15, "HQ" ):ToGroup( TaskGroup )
self:Message( "You hit a target. Your group with assigned " .. self.TaskName .. " task has " .. self.TargetSetUnit:Count() .. " targets ( " .. self.TargetSetUnit:GetUnitTypesText() .. " ) left to be destroyed." )
end
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ACCOUNT_DEADS self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ACCOUNT_DEADS:onafterEvent( ProcessUnit, Event, From, To, EventData )
function ACT_ACCOUNT_DEADS:onafterEvent( ProcessUnit, Event, From, To, EventData )
if self.TargetSetUnit:Count() > 0 then
self:__More( 1 )
@@ -254,9 +253,9 @@ do -- FSM_ACCOUNT_DEADS
--- DCS Events
--- @param #FSM_ACCOUNT_DEADS self
--- @param #ACT_ACCOUNT_DEADS self
-- @param Event#EVENTDATA EventData
function FSM_ACCOUNT_DEADS:onfuncEventDead( EventData )
function ACT_ACCOUNT_DEADS:onfuncEventDead( EventData )
self:T( { "EventDead", EventData } )
if EventData.IniDCSUnit then
@@ -264,4 +263,4 @@ do -- FSM_ACCOUNT_DEADS
end
end
end -- FSM_ACCOUNT DEADS
end -- ACT_ACCOUNT DEADS

View File

@@ -2,16 +2,16 @@
--
-- ===
--
-- # @{#FSM_ASSIGN} FSM template class, extends @{Fsm.Fsm#FSM_PROCESS}
-- # @{#ACT_ASSIGN} FSM template class, extends @{Core.Fsm#FSM_PROCESS}
--
-- ## FSM_ASSIGN state machine:
-- ## ACT_ASSIGN state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSM_ASSIGN **Events**:
-- ### ACT_ASSIGN **Events**:
--
-- These are the events defined in this class:
--
@@ -19,7 +19,7 @@
-- * **Assign**: Assign the task.
-- * **Reject**: Reject the task..
--
-- ### FSM_ASSIGN **Event methods**:
-- ### ACT_ASSIGN **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@@ -27,7 +27,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSM_ASSIGN **States**:
-- ### ACT_ASSIGN **States**:
--
-- * **UnAssigned**: The player has not accepted the task.
-- * **Assigned (*)**: The player has accepted the task.
@@ -37,7 +37,7 @@
--
-- (*) End states of the process.
--
-- ### FSM_ASSIGN state transition methods:
-- ### ACT_ASSIGN state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@@ -54,52 +54,52 @@
--
-- ===
--
-- # 1) @{#FSM_ASSIGN_ACCEPT} class, extends @{Fsm.Assign#FSM_ASSIGN}
-- # 1) @{#ACT_ASSIGN_ACCEPT} class, extends @{Fsm.Assign#ACT_ASSIGN}
--
-- The FSM_ASSIGN_ACCEPT class accepts by default a task for a player. No player intervention is allowed to reject the task.
-- The ACT_ASSIGN_ACCEPT class accepts by default a task for a player. No player intervention is allowed to reject the task.
--
-- ## 1.1) FSM_ASSIGN_ACCEPT constructor:
-- ## 1.1) ACT_ASSIGN_ACCEPT constructor:
--
-- * @{#FSM_ASSIGN_ACCEPT.New}(): Creates a new FSM_ASSIGN_ACCEPT object.
-- * @{#ACT_ASSIGN_ACCEPT.New}(): Creates a new ACT_ASSIGN_ACCEPT object.
--
-- ===
--
-- # 2) @{#FSM_ASSIGN_MENU_ACCEPT} class, extends @{Fsm.Assign#FSM_ASSIGN}
-- # 2) @{#ACT_ASSIGN_MENU_ACCEPT} class, extends @{Fsm.Assign#ACT_ASSIGN}
--
-- The FSM_ASSIGN_MENU_ACCEPT class accepts a task when the player accepts the task through an added menu option.
-- The ACT_ASSIGN_MENU_ACCEPT class accepts a task when the player accepts the task through an added menu option.
-- This assignment type is useful to conditionally allow the player to choose whether or not he would accept the task.
-- The assignment type also allows to reject the task.
--
-- ## 2.1) FSM_ASSIGN_MENU_ACCEPT constructor:
-- ## 2.1) ACT_ASSIGN_MENU_ACCEPT constructor:
-- -----------------------------------------
--
-- * @{#FSM_ASSIGN_MENU_ACCEPT.New}(): Creates a new FSM_ASSIGN_MENU_ACCEPT object.
-- * @{#ACT_ASSIGN_MENU_ACCEPT.New}(): Creates a new ACT_ASSIGN_MENU_ACCEPT object.
--
-- ===
--
-- @module Assign
do -- FSM_ASSIGN
do -- ACT_ASSIGN
--- FSM_ASSIGN class
-- @type FSM_ASSIGN
-- @field Tasking.Task#TASK_BASE Task
--- ACT_ASSIGN class
-- @type ACT_ASSIGN
-- @field Tasking.Task#TASK Task
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_ASSIGN = {
ClassName = "FSM_ASSIGN",
-- @extends Core.Fsm#FSM_PROCESS
ACT_ASSIGN = {
ClassName = "ACT_ASSIGN",
}
--- Creates a new task assignment state machine. The process will accept the task by default, no player intervention accepted.
-- @param #FSM_ASSIGN self
-- @return #FSM_ASSIGN The task acceptance process.
function FSM_ASSIGN:New()
-- @param #ACT_ASSIGN self
-- @return #ACT_ASSIGN The task acceptance process.
function ACT_ASSIGN:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_PROCESS:New( "FSM_ASSIGN" ) ) -- Fsm.Fsm#FSM_PROCESS
local self = BASE:Inherit( self, FSM_PROCESS:New( "ACT_ASSIGN" ) ) -- Core.Fsm#FSM_PROCESS
self:AddTransition( "UnAssigned", "Start", "Waiting" )
self:AddTransition( "Waiting", "Assign", "Assigned" )
@@ -115,96 +115,93 @@ do -- FSM_ASSIGN
return self
end
end -- FSM_ASSIGN
end -- ACT_ASSIGN
do -- FSM_ASSIGN_ACCEPT
do -- ACT_ASSIGN_ACCEPT
--- FSM_ASSIGN_ACCEPT class
-- @type FSM_ASSIGN_ACCEPT
-- @field Tasking.Task#TASK_BASE Task
--- ACT_ASSIGN_ACCEPT class
-- @type ACT_ASSIGN_ACCEPT
-- @field Tasking.Task#TASK Task
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSM_ASSIGN
FSM_ASSIGN_ACCEPT = {
ClassName = "FSM_ASSIGN_ACCEPT",
-- @extends #ACT_ASSIGN
ACT_ASSIGN_ACCEPT = {
ClassName = "ACT_ASSIGN_ACCEPT",
}
--- Creates a new task assignment state machine. The process will accept the task by default, no player intervention accepted.
-- @param #FSM_ASSIGN_ACCEPT self
-- @param #ACT_ASSIGN_ACCEPT self
-- @param #string TaskBriefing
function FSM_ASSIGN_ACCEPT:New( TaskBriefing )
function ACT_ASSIGN_ACCEPT:New( TaskBriefing )
local self = BASE:Inherit( self, FSM_ASSIGN:New() ) -- #FSM_ASSIGN_ACCEPT
local self = BASE:Inherit( self, ACT_ASSIGN:New() ) -- #ACT_ASSIGN_ACCEPT
self.TaskBriefing = TaskBriefing
return self
end
function FSM_ASSIGN_ACCEPT:Init( FsmAssign )
function ACT_ASSIGN_ACCEPT:Init( FsmAssign )
self.TaskBriefing = FsmAssign.TaskBriefing
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_ACCEPT self
-- @param #ACT_ASSIGN_ACCEPT self
-- @param Wrapper.Unit#UNIT ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ASSIGN_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
function ACT_ASSIGN_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
local ProcessGroup = ProcessUnit:GetGroup()
MESSAGE:New( self.TaskBriefing, 30, ProcessUnit:GetPlayerName() .. " Task Acceptance" ):ToGroup( ProcessGroup )
self:__Assign( 1 )
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_ACCEPT self
-- @param #ACT_ASSIGN_ACCEPT self
-- @param Wrapper.Unit#UNIT ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ASSIGN_ACCEPT:onenterAssigned( ProcessUnit, Event, From, To )
function ACT_ASSIGN_ACCEPT:onenterAssigned( ProcessUnit, Event, From, To )
env.info( "in here" )
self:E( { ProcessUnit, Event, From, To } )
local ProcessGroup = ProcessUnit:GetGroup()
MESSAGE:New( "You are assigned to the task " .. self.Task:GetName(), 30, ProcessUnit:GetPlayerName() .. ": Task Assignment" ):ToGroup( ProcessGroup )
self:Message( "You are assigned to the task " .. self.Task:GetName() )
self.Task:Assign()
end
end -- FSM_ASSIGN_ACCEPT
end -- ACT_ASSIGN_ACCEPT
do -- FSM_ASSIGN_MENU_ACCEPT
do -- ACT_ASSIGN_MENU_ACCEPT
--- FSM_ASSIGN_MENU_ACCEPT class
-- @type FSM_ASSIGN_MENU_ACCEPT
-- @field Tasking.Task#TASK_BASE Task
--- ACT_ASSIGN_MENU_ACCEPT class
-- @type ACT_ASSIGN_MENU_ACCEPT
-- @field Tasking.Task#TASK Task
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSM_ASSIGN
FSM_ASSIGN_MENU_ACCEPT = {
ClassName = "FSM_ASSIGN_MENU_ACCEPT",
-- @extends #ACT_ASSIGN
ACT_ASSIGN_MENU_ACCEPT = {
ClassName = "ACT_ASSIGN_MENU_ACCEPT",
}
--- Init.
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ASSIGN_MENU_ACCEPT self
-- @param #string TaskName
-- @param #string TaskBriefing
-- @return #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:New( TaskName, TaskBriefing )
-- @return #ACT_ASSIGN_MENU_ACCEPT self
function ACT_ASSIGN_MENU_ACCEPT:New( TaskName, TaskBriefing )
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_ASSIGN:New() ) -- #FSM_ASSIGN_MENU_ACCEPT
local self = BASE:Inherit( self, ACT_ASSIGN:New() ) -- #ACT_ASSIGN_MENU_ACCEPT
self.TaskName = TaskName
self.TaskBriefing = TaskBriefing
@@ -212,7 +209,7 @@ do -- FSM_ASSIGN_MENU_ACCEPT
return self
end
function FSM_ASSIGN_MENU_ACCEPT:Init( FsmAssign )
function ACT_ASSIGN_MENU_ACCEPT:Init( FsmAssign )
self.TaskName = FsmAssign.TaskName
self.TaskBriefing = FsmAssign.TaskBriefing
@@ -220,11 +217,11 @@ do -- FSM_ASSIGN_MENU_ACCEPT
--- Creates a new task assignment state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ASSIGN_MENU_ACCEPT self
-- @param #string TaskName
-- @param #string TaskBriefing
-- @return #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:Init( TaskName, TaskBriefing )
-- @return #ACT_ASSIGN_MENU_ACCEPT self
function ACT_ASSIGN_MENU_ACCEPT:Init( TaskName, TaskBriefing )
self.TaskBriefing = TaskBriefing
self.TaskName = TaskName
@@ -233,15 +230,15 @@ do -- FSM_ASSIGN_MENU_ACCEPT
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ASSIGN_MENU_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
function ACT_ASSIGN_MENU_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
MESSAGE:New( self.TaskBriefing .. "\nAccess the radio menu to accept the task. You have 30 seconds or the assignment will be cancelled.", 30, "Task Assignment" ):ToGroup( ProcessUnit:GetGroup() )
self:Message( "Access the radio menu to accept the task. You have 30 seconds or the assignment will be cancelled." )
local ProcessGroup = ProcessUnit:GetGroup()
@@ -251,40 +248,40 @@ do -- FSM_ASSIGN_MENU_ACCEPT
end
--- Menu function.
-- @param #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:MenuAssign()
-- @param #ACT_ASSIGN_MENU_ACCEPT self
function ACT_ASSIGN_MENU_ACCEPT:MenuAssign()
self:E( )
self:__Assign( 1 )
end
--- Menu function.
-- @param #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:MenuReject()
-- @param #ACT_ASSIGN_MENU_ACCEPT self
function ACT_ASSIGN_MENU_ACCEPT:MenuReject()
self:E( )
self:__Reject( 1 )
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ASSIGN_MENU_ACCEPT:onafterAssign( ProcessUnit, Event, From, To )
function ACT_ASSIGN_MENU_ACCEPT:onafterAssign( ProcessUnit, Event, From, To )
self:E( { ProcessUnit.UnitNameEvent, From, To } )
self.Menu:Remove()
end
--- StateMachine callback function
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #ACT_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ASSIGN_MENU_ACCEPT:onafterReject( ProcessUnit, Event, From, To )
function ACT_ASSIGN_MENU_ACCEPT:onafterReject( ProcessUnit, Event, From, To )
self:E( { ProcessUnit.UnitName, Event, From, To } )
self.Menu:Remove()
@@ -293,4 +290,4 @@ do -- FSM_ASSIGN_MENU_ACCEPT
ProcessUnit:Destroy()
end
end -- FSM_ASSIGN_MENU_ACCEPT
end -- ACT_ASSIGN_MENU_ACCEPT

View File

@@ -2,23 +2,23 @@
--
-- ===
--
-- # @{#FSM_SMOKE} FSM class, extends @{Fsm.Fsm#FSM_PROCESS}
-- # @{#ACT_ASSIST} FSM class, extends @{Core.Fsm#FSM_PROCESS}
--
-- ## FSM_SMOKE state machine:
-- ## ACT_ASSIST state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSM_SMOKE **Events**:
-- ### ACT_ASSIST **Events**:
--
-- These are the events defined in this class:
--
-- * **Start**: The process is started.
-- * **Next**: The process is smoking the targets in the given zone.
--
-- ### FSM_SMOKE **Event methods**:
-- ### ACT_ASSIST **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@@ -26,7 +26,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSM_SMOKE **States**:
-- ### ACT_ASSIST **States**:
--
-- * **None**: The controllable did not receive route commands.
-- * **AwaitSmoke (*)**: The process is awaiting to smoke the targets in the zone.
@@ -35,7 +35,7 @@
--
-- (*) End states of the process.
--
-- ### FSM_SMOKE state transition methods:
-- ### ACT_ASSIST state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@@ -52,36 +52,36 @@
--
-- ===
--
-- # 1) @{#FSM_SMOKE_TARGETS_ZONE} class, extends @{Fsm.Route#FSM_SMOKE}
-- # 1) @{#ACT_ASSIST_SMOKE_TARGETS_ZONE} class, extends @{Fsm.Route#ACT_ASSIST}
--
-- The FSM_SMOKE_TARGETS_ZONE class implements the core functions to smoke targets in a @{Zone}.
-- The ACT_ASSIST_SMOKE_TARGETS_ZONE class implements the core functions to smoke targets in a @{Zone}.
-- The targets are smoked within a certain range around each target, simulating a realistic smoking behaviour.
-- At random intervals, a new target is smoked.
--
-- # 1.1) FSM_SMOKE_TARGETS_ZONE constructor:
-- # 1.1) ACT_ASSIST_SMOKE_TARGETS_ZONE constructor:
--
-- * @{#FSM_SMOKE_TARGETS_ZONE.New}(): Creates a new FSM_SMOKE_TARGETS_ZONE object.
-- * @{#ACT_ASSIST_SMOKE_TARGETS_ZONE.New}(): Creates a new ACT_ASSIST_SMOKE_TARGETS_ZONE object.
--
-- ===
--
-- @module Smoke
do -- FSM_SMOKE
do -- ACT_ASSIST
--- FSM_SMOKE class
-- @type FSM_SMOKE
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_SMOKE = {
ClassName = "FSM_SMOKE",
--- ACT_ASSIST class
-- @type ACT_ASSIST
-- @extends Core.Fsm#FSM_PROCESS
ACT_ASSIST = {
ClassName = "ACT_ASSIST",
}
--- Creates a new target smoking state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSM_SMOKE self
-- @return #FSM_SMOKE
function FSM_SMOKE:New()
-- @param #ACT_ASSIST self
-- @return #ACT_ASSIST
function ACT_ASSIST:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_PROCESS:New( "FSM_SMOKE" ) ) -- Fsm.Fsm#FSM_PROCESS
local self = BASE:Inherit( self, FSM_PROCESS:New( "ACT_ASSIST" ) ) -- Core.Fsm#FSM_PROCESS
self:AddTransition( "None", "Start", "AwaitSmoke" )
self:AddTransition( "AwaitSmoke", "Next", "Smoking" )
@@ -100,12 +100,12 @@ do -- FSM_SMOKE
--- Task Events
--- StateMachine callback function
-- @param #FSM_SMOKE self
-- @param #ACT_ASSIST self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_SMOKE:onafterStart( ProcessUnit, Event, From, To )
function ACT_ASSIST:onafterStart( ProcessUnit, Event, From, To )
local ProcessGroup = ProcessUnit:GetGroup()
local MissionMenu = self:GetMission():GetMissionMenu( ProcessGroup )
@@ -128,18 +128,18 @@ do -- FSM_SMOKE
end
do -- FSM_SMOKE_TARGETS_ZONE
do -- ACT_ASSIST_SMOKE_TARGETS_ZONE
--- FSM_SMOKE_TARGETS_ZONE class
-- @type FSM_SMOKE_TARGETS_ZONE
--- ACT_ASSIST_SMOKE_TARGETS_ZONE class
-- @type ACT_ASSIST_SMOKE_TARGETS_ZONE
-- @field Set#SET_UNIT TargetSetUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSM_SMOKE
FSM_SMOKE_TARGETS_ZONE = {
ClassName = "FSM_SMOKE_TARGETS_ZONE",
-- @extends #ACT_ASSIST
ACT_ASSIST_SMOKE_TARGETS_ZONE = {
ClassName = "ACT_ASSIST_SMOKE_TARGETS_ZONE",
}
-- function FSM_SMOKE_TARGETS_ZONE:_Destructor()
-- function ACT_ASSIST_SMOKE_TARGETS_ZONE:_Destructor()
-- self:E("_Destructor")
--
-- self.Menu:Remove()
@@ -147,11 +147,11 @@ do -- FSM_SMOKE_TARGETS_ZONE
-- end
--- Creates a new target smoking state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSM_SMOKE_TARGETS_ZONE self
-- @param #ACT_ASSIST_SMOKE_TARGETS_ZONE self
-- @param Set#SET_UNIT TargetSetUnit
-- @param Core.Zone#ZONE_BASE TargetZone
function FSM_SMOKE_TARGETS_ZONE:New( TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, FSM_SMOKE:New() ) -- #FSM_SMOKE
function ACT_ASSIST_SMOKE_TARGETS_ZONE:New( TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, ACT_ASSIST:New() ) -- #ACT_ASSIST
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
@@ -159,18 +159,18 @@ do -- FSM_SMOKE_TARGETS_ZONE
return self
end
function FSM_SMOKE_TARGETS_ZONE:Init( FsmSmoke )
function ACT_ASSIST_SMOKE_TARGETS_ZONE:Init( FsmSmoke )
self.TargetSetUnit = FsmSmoke.TargetSetUnit
self.TargetZone = FsmSmoke.TargetZone
end
--- Creates a new target smoking state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSM_SMOKE_TARGETS_ZONE self
-- @param #ACT_ASSIST_SMOKE_TARGETS_ZONE self
-- @param Set#SET_UNIT TargetSetUnit
-- @param Core.Zone#ZONE_BASE TargetZone
-- @return #FSM_SMOKE_TARGETS_ZONE self
function FSM_SMOKE_TARGETS_ZONE:Init( TargetSetUnit, TargetZone )
-- @return #ACT_ASSIST_SMOKE_TARGETS_ZONE self
function ACT_ASSIST_SMOKE_TARGETS_ZONE:Init( TargetSetUnit, TargetZone )
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
@@ -179,12 +179,12 @@ do -- FSM_SMOKE_TARGETS_ZONE
end
--- StateMachine callback function
-- @param #FSM_SMOKE_TARGETS_ZONE self
-- @param #ACT_ASSIST_SMOKE_TARGETS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, Event, From, To )
function ACT_ASSIST_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, Event, From, To )
self.TargetSetUnit:ForEachUnit(
--- @param Wrapper.Unit#UNIT SmokeUnit

View File

@@ -4,7 +4,7 @@
-- @type PROCESS_JTAC
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Set#SET_UNIT TargetSetUnit
-- @extends Fsm.Fsm#FSM_PROCESS
-- @extends Core.Fsm#FSM_PROCESS
PROCESS_JTAC = {
ClassName = "PROCESS_JTAC",
Fsm = {},
@@ -66,7 +66,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_JTAC self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -77,7 +77,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_JTAC self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -123,7 +123,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_JTAC self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -147,7 +147,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_JTAC self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -174,7 +174,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_JTAC self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To

View File

@@ -4,7 +4,7 @@
-- @type PROCESS_PICKUP
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Set#SET_UNIT TargetSetUnit
-- @extends Fsm.Fsm#FSM_PROCESS
-- @extends Core.Fsm#FSM_PROCESS
PROCESS_PICKUP = {
ClassName = "PROCESS_PICKUP",
Fsm = {},
@@ -57,7 +57,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -68,7 +68,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -89,7 +89,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -115,7 +115,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -126,7 +126,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -139,7 +139,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -151,7 +151,7 @@ end
--- StateMachine callback function for a PROCESS
-- @param #PROCESS_PICKUP self
-- @param Fsm.Fsm#FSM_PROCESS Fsm
-- @param Core.Fsm#FSM_PROCESS Fsm
-- @param #string Event
-- @param #string From
-- @param #string To

View File

@@ -2,16 +2,16 @@
--
-- ===
--
-- # @{#FSM_ROUTE} FSM class, extends @{Fsm.Fsm#FSM_PROCESS}
-- # @{#ACT_ROUTE} FSM class, extends @{Core.Fsm#FSM_PROCESS}
--
-- ## FSM_ROUTE state machine:
-- ## ACT_ROUTE state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSM_ROUTE **Events**:
-- ### ACT_ROUTE **Events**:
--
-- These are the events defined in this class:
--
@@ -23,7 +23,7 @@
-- * **More**: There are more route points that need to be followed. The process will go back into the Report state.
-- * **NoMore**: There are no more route points that need to be followed. The process will go into the Success state.
--
-- ### FSM_ROUTE **Event methods**:
-- ### ACT_ROUTE **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@@ -31,7 +31,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSM_ROUTE **States**:
-- ### ACT_ROUTE **States**:
--
-- * **None**: The controllable did not receive route commands.
-- * **Arrived (*)**: The controllable has arrived at a route point.
@@ -43,7 +43,7 @@
--
-- (*) End states of the process.
--
-- ### FSM_ROUTE state transition methods:
-- ### ACT_ROUTE state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@@ -60,41 +60,41 @@
--
-- ===
--
-- # 1) @{#FSM_ROUTE_ZONE} class, extends @{Fsm.Route#FSM_ROUTE}
-- # 1) @{#ACT_ROUTE_ZONE} class, extends @{Fsm.Route#ACT_ROUTE}
--
-- The FSM_ROUTE_ZONE class implements the core functions to route an AIR @{Controllable} player @{Unit} to a @{Zone}.
-- The ACT_ROUTE_ZONE class implements the core functions to route an AIR @{Controllable} player @{Unit} to a @{Zone}.
-- The player receives on perioding times messages with the coordinates of the route to follow.
-- Upon arrival at the zone, a confirmation of arrival is sent, and the process will be ended.
--
-- # 1.1) FSM_ROUTE_ZONE constructor:
-- # 1.1) ACT_ROUTE_ZONE constructor:
--
-- * @{#FSM_ROUTE_ZONE.New}(): Creates a new FSM_ROUTE_ZONE object.
-- * @{#ACT_ROUTE_ZONE.New}(): Creates a new ACT_ROUTE_ZONE object.
--
-- ===
--
-- @module Route
do -- FSM_ROUTE
do -- ACT_ROUTE
--- FSM_ROUTE class
-- @type FSM_ROUTE
--- ACT_ROUTE class
-- @type ACT_ROUTE
-- @field Tasking.Task#TASK TASK
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_ROUTE = {
ClassName = "FSM_ROUTE",
-- @extends Core.Fsm#FSM_PROCESS
ACT_ROUTE = {
ClassName = "ACT_ROUTE",
}
--- Creates a new routing state machine. The process will route a CLIENT to a ZONE until the CLIENT is within that ZONE.
-- @param #FSM_ROUTE self
-- @return #FSM_ROUTE self
function FSM_ROUTE:New()
-- @param #ACT_ROUTE self
-- @return #ACT_ROUTE self
function ACT_ROUTE:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_PROCESS:New( "FSM_ROUTE" ) ) -- Fsm.Fsm#FSM_PROCESS
local self = BASE:Inherit( self, FSM_PROCESS:New( "ACT_ROUTE" ) ) -- Core.Fsm#FSM_PROCESS
self:AddTransition( "None", "Start", "Routing" )
self:AddTransition( "*", "Report", "Reporting" )
@@ -118,32 +118,32 @@ do -- FSM_ROUTE
--- Task Events
--- StateMachine callback function
-- @param #FSM_ROUTE self
-- @param #ACT_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ROUTE:onafterStart( ProcessUnit, Event, From, To )
function ACT_ROUTE:onafterStart( ProcessUnit, Event, From, To )
self:__Route( 1 )
end
--- Check if the controllable has arrived.
-- @param #FSM_ROUTE self
-- @param #ACT_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @return #boolean
function FSM_ROUTE:onfuncHasArrived( ProcessUnit )
function ACT_ROUTE:onfuncHasArrived( ProcessUnit )
return false
end
--- StateMachine callback function
-- @param #FSM_ROUTE self
-- @param #ACT_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ROUTE:onbeforeRoute( ProcessUnit, Event, From, To )
function ACT_ROUTE:onbeforeRoute( ProcessUnit, Event, From, To )
if ProcessUnit:IsAlive() then
local HasArrived = self:onfuncHasArrived( ProcessUnit ) -- Polymorphic
@@ -172,28 +172,28 @@ do -- FSM_ROUTE
end
end -- FSM_ROUTE
end -- ACT_ROUTE
do -- FSM_ROUTE_ZONE
do -- ACT_ROUTE_ZONE
--- FSM_ROUTE_ZONE class
-- @type FSM_ROUTE_ZONE
--- ACT_ROUTE_ZONE class
-- @type ACT_ROUTE_ZONE
-- @field Tasking.Task#TASK TASK
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSM_ROUTE
FSM_ROUTE_ZONE = {
ClassName = "FSM_ROUTE_ZONE",
-- @extends #ACT_ROUTE
ACT_ROUTE_ZONE = {
ClassName = "ACT_ROUTE_ZONE",
}
--- Creates a new routing state machine. The task will route a controllable to a ZONE until the controllable is within that ZONE.
-- @param #FSM_ROUTE_ZONE self
-- @param #ACT_ROUTE_ZONE self
-- @param Core.Zone#ZONE_BASE TargetZone
function FSM_ROUTE_ZONE:New( TargetZone )
local self = BASE:Inherit( self, FSM_ROUTE:New() ) -- #FSM_ROUTE_ZONE
function ACT_ROUTE_ZONE:New( TargetZone )
local self = BASE:Inherit( self, ACT_ROUTE:New() ) -- #ACT_ROUTE_ZONE
self.TargetZone = TargetZone
@@ -201,30 +201,28 @@ do -- FSM_ROUTE_ZONE
self.DisplayCount = 30
self.DisplayMessage = true
self.DisplayTime = 10 -- 10 seconds is the default
self.DisplayCategory = "HQ" -- Route is the default display category
return self
end
function FSM_ROUTE_ZONE:Init( FsmRoute )
function ACT_ROUTE_ZONE:Init( FsmRoute )
self.TargetZone = FsmRoute.TargetZone
self.DisplayInterval = 30
self.DisplayCount = 30
self.DisplayMessage = true
self.DisplayTime = 10 -- 10 seconds is the default
self.DisplayCategory = "HQ" -- Route is the default display category
end
--- Method override to check if the controllable has arrived.
-- @param #FSM_ROUTE self
-- @param #ACT_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @return #boolean
function FSM_ROUTE_ZONE:onfuncHasArrived( ProcessUnit )
function ACT_ROUTE_ZONE:onfuncHasArrived( ProcessUnit )
if ProcessUnit:IsInZone( self.TargetZone ) then
local RouteText = ProcessUnit:GetCallsign() .. ": You have arrived within the zone!"
MESSAGE:New( RouteText, self.DisplayTime, self.DisplayCategory ):ToGroup( ProcessUnit:GetGroup() )
local RouteText = "You have arrived within the zone."
self:Message( RouteText )
end
return ProcessUnit:IsInZone( self.TargetZone )
@@ -233,19 +231,19 @@ do -- FSM_ROUTE_ZONE
--- Task Events
--- StateMachine callback function
-- @param #FSM_ROUTE_ZONE self
-- @param #ACT_ROUTE_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSM_ROUTE_ZONE:onenterReporting( ProcessUnit, Event, From, To )
function ACT_ROUTE_ZONE:onenterReporting( ProcessUnit, Event, From, To )
local ZoneVec2 = self.TargetZone:GetVec2()
local ZonePointVec2 = POINT_VEC2:New( ZoneVec2.x, ZoneVec2.y )
local TaskUnitVec2 = ProcessUnit:GetVec2()
local TaskUnitPointVec2 = POINT_VEC2:New( TaskUnitVec2.x, TaskUnitVec2.y )
local RouteText = ProcessUnit:GetCallsign() .. ": Route to " .. TaskUnitPointVec2:GetBRText( ZonePointVec2 ) .. " km to target."
MESSAGE:New( RouteText, self.DisplayTime, self.DisplayCategory ):ToGroup( ProcessUnit:GetGroup() )
local RouteText = "Route to " .. TaskUnitPointVec2:GetBRText( ZonePointVec2 ) .. " km to target."
self:Message( RouteText )
end
end -- FSM_ROUTE_ZONE
end -- ACT_ROUTE_ZONE

View File

@@ -90,24 +90,6 @@ FORMATION = {
--- The base constructor. This is the top top class of all classed defined within the MOOSE.
-- Any new class needs to be derived from this class for proper inheritance.
-- @param #BASE self
-- @return #BASE The new instance of the BASE class.
-- @usage
-- -- This declares the constructor of the class TASK, inheriting from BASE.
-- --- TASK constructor
-- -- @param #TASK self
-- -- @param Parameter The parameter of the New constructor.
-- -- @return #TASK self
-- function TASK:New( Parameter )
--
-- local self = BASE:Inherit( self, BASE:New() )
--
-- self.Variable = Parameter
--
-- return self
-- end
-- @todo need to investigate if the deepCopy is really needed... Don't think so.
function BASE:New()
local self = routines.utils.deepCopy( self ) -- Create a new self instance

View File

@@ -32,17 +32,6 @@ do -- FSM
-- Inherits from BASE
local self = BASE:Inherit( self, BASE:New() )
--local self = routines.utils.deepCopy( self ) -- Create a new self instance
--assert(options.events)
--local MT = {}
--setmetatable( self, MT )
--self.__index = self
self.options = options or {}
self.options.subs = self.options.subs or {}
self.current = self.options.initial or 'none'
@@ -95,10 +84,8 @@ do -- FSM
return self._Transitions or {}
end
--- Set the default @{Process} template with key ProcessName providing the ProcessClass and the process object when it is assigned to a @{Controllable} by the task.
-- @return Fsm.Fsm#FSM_PROCESS
-- @return Core.Fsm#FSM_PROCESS
function FSM:AddProcess( From, Event, Process, ReturnEvents )
self:E( { From, Event, Process, ReturnEvents } )
@@ -391,27 +378,7 @@ do -- FSM
function FSM:cannot(e)
return not self:can(e)
end
function FSM:CopyCallHandlers( FsmT )
local Parent = BASE:GetParent( FsmT )
if Parent then
self:CopyCallHandlers( Parent )
end
for ElementID, Element in pairs( FsmT ) do
self:E( { ElementID = ElementID } )
if type( Element ) == "function" then
if ElementID.find( ElementID, "^onbefore" ) or
ElementID.find( ElementID, "^onafter" ) or
ElementID.find( ElementID, "^onenter" ) or
ElementID.find( ElementID, "^onleave" ) or
ElementID.find( ElementID, "^onfunc" ) then
self[ ElementID ] = Element
end
end
end
end
end
do -- FSM_CONTROLLABLE
@@ -419,7 +386,7 @@ do -- FSM_CONTROLLABLE
--- FSM_CONTROLLABLE class
-- @type FSM_CONTROLLABLE
-- @field Wrapper.Controllable#CONTROLLABLE Controllable
-- @extends Fsm.Fsm#FSM
-- @extends Core.Fsm#FSM
FSM_CONTROLLABLE = {
ClassName = "FSM_CONTROLLABLE",
}
@@ -432,7 +399,7 @@ do -- FSM_CONTROLLABLE
function FSM_CONTROLLABLE:New( FSMT, Controllable )
-- Inherits from BASE
local self = BASE:Inherit( self, FSM:New( FSMT ) ) -- Fsm.Fsm#FSM_CONTROLLABLE
local self = BASE:Inherit( self, FSM:New( FSMT ) ) -- Core.Fsm#FSM_CONTROLLABLE
if Controllable then
self:SetControllable( Controllable )
@@ -482,8 +449,8 @@ do -- FSM_PROCESS
--- FSM_PROCESS class
-- @type FSM_PROCESS
-- @field Tasking.Task#TASK_BASE Task
-- @extends Fsm.Fsm#FSM_CONTROLLABLE
-- @field Tasking.Task#TASK Task
-- @extends Core.Fsm#FSM_CONTROLLABLE
FSM_PROCESS = {
ClassName = "FSM_PROCESS",
}
@@ -493,7 +460,7 @@ do -- FSM_PROCESS
-- @return #FSM_PROCESS
function FSM_PROCESS:New( Controllable, Task )
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New() ) -- Fsm.Fsm#FSM_PROCESS
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New() ) -- Core.Fsm#FSM_PROCESS
self:F( Controllable, Task )
@@ -512,7 +479,7 @@ do -- FSM_PROCESS
function FSM_PROCESS:Copy( Controllable, Task )
self:E( { self:GetClassNameAndID() } )
local NewFsm = self:New( Controllable, Task ) -- Fsm.Fsm#FSM_PROCESS
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
NewFsm:Assign( Controllable, Task )
@@ -549,9 +516,9 @@ do -- FSM_PROCESS
end
--- Sets the task of the process.
-- @param #PROCESS self
-- @param Tasking.Task#TASK_BASE Task
-- @return #PROCESS
-- @param #FSM_PROCESS self
-- @param Tasking.Task#TASK Task
-- @return #FSM_PROCESS
function FSM_PROCESS:SetTask( Task )
self.Task = Task
@@ -560,25 +527,46 @@ do -- FSM_PROCESS
end
--- Gets the task of the process.
-- @param #PROCESS self
-- @return Tasking.Task#TASK_BASE
-- @param #FSM_PROCESS self
-- @return Tasking.Task#TASK
function FSM_PROCESS:GetTask()
return self.Task
end
--- Gets the mission of the process.
-- @param #PROCESS self
-- @param #FSM_PROCESS self
-- @return Tasking.Mission#MISSION
function FSM_PROCESS:GetMission()
return self.Task.Mission
end
--- Gets the mission of the process.
-- @param #FSM_PROCESS self
-- @return Tasking.CommandCenter#COMMANDCENTER
function FSM_PROCESS:GetCommandCenter()
return self:GetTask():GetMission():GetCommandCenter()
end
--- Send a message of the @{Task} to the Group of the Unit.
-- @param #FSM_PROCESS self
function FSM_PROCESS:Message( Message )
self:F( { Message = Message } )
local CC = self:GetCommandCenter()
local TaskGroup = self.Controllable:GetGroup()
CC:MessageToGroup( Message, TaskGroup )
end
--- Assign the process to a @{Unit} and activate the process.
-- @param #FSM_PROCESS self
-- @param Task.Tasking#TASK_BASE Task
-- @param Task.Tasking#TASK Task
-- @param Wrapper.Unit#UNIT ProcessUnit
-- @return #FSM_PROCESS self
function FSM_PROCESS:Assign( ProcessUnit, Task )
@@ -636,7 +624,7 @@ do -- FSM_PROCESS
self:E( { ProcessUnit, Event, From, To, Dummy, self:IsTrace() } )
if self:IsTrace() then
MESSAGE:New( "Process " .. self:GetClassNameAndID() .. " : " .. Event .. " changed to state " .. To, 15 ):ToAll()
MESSAGE:New( "@ Process " .. self:GetClassNameAndID() .. " : " .. Event .. " changed to state " .. To, 2 ):ToAll()
end
self:E( self.Scores[To] )
@@ -657,8 +645,8 @@ do -- FSM_TASK
--- FSM_TASK class
-- @type FSM_TASK
-- @field Tasking.Task#TASK_BASE Task
-- @extends Fsm.Fsm#FSM
-- @field Tasking.Task#TASK Task
-- @extends Core.Fsm#FSM
FSM_TASK = {
ClassName = "FSM_TASK",
}
@@ -666,12 +654,12 @@ do -- FSM_TASK
--- Creates a new FSM_TASK object.
-- @param #FSM_TASK self
-- @param #table FSMT
-- @param Tasking.Task#TASK_BASE Task
-- @param Tasking.Task#TASK Task
-- @param Wrapper.Unit#UNIT TaskUnit
-- @return #FSM_TASK
function FSM_TASK:New( FSMT )
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New( FSMT ) ) -- Fsm.Fsm#FSM_TASK
local self = BASE:Inherit( self, FSM_CONTROLLABLE:New( FSMT ) ) -- Core.Fsm#FSM_TASK
self["onstatechange"] = self.OnStateChange
@@ -692,7 +680,7 @@ do -- FSM_SET
--- FSM_SET class
-- @type FSM_SET
-- @field Core.Set#SET_BASE Set
-- @extends Fsm.Fsm#FSM
-- @extends Core.Fsm#FSM
FSM_SET = {
ClassName = "FSM_SET",
}
@@ -705,7 +693,7 @@ do -- FSM_SET
function FSM_SET:New( FSMSet )
-- Inherits from BASE
local self = BASE:Inherit( self, FSM:New() ) -- Fsm.Fsm#FSM_SET
local self = BASE:Inherit( self, FSM:New() ) -- Core.Fsm#FSM_SET
if FSMSet then
self:Set( FSMSet )

View File

@@ -54,7 +54,7 @@ end
-- @param #SCHEDULEDISPATCHER self
-- @param Core.Scheduler#SCHEDULER Scheduler
function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleArguments, Start, Repeat, Randomize, Stop )
self:F( { Scheduler, ScheduleFunction, ScheduleArguments, Start, Repeat, Randomize, Stop } )
self:F2( { Scheduler, ScheduleFunction, ScheduleArguments, Start, Repeat, Randomize, Stop } )
self.CallID = self.CallID + 1
@@ -88,7 +88,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
self:T3( self.Schedule[Scheduler][self.CallID] )
self.Schedule[Scheduler][self.CallID].CallHandler = function( CallID )
self:F( CallID )
self:F2( CallID )
local ErrorHandler = function( errmsg )
env.info( "Error in timer function: " .. errmsg )
@@ -103,13 +103,13 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
Scheduler = self.PersistentSchedulers[CallID]
end
self:T( { Scheduler = Scheduler } )
self:T3( { Scheduler = Scheduler } )
if Scheduler then
local Schedule = self.Schedule[Scheduler][CallID]
self:T( { Schedule = Schedule } )
self:T3( { Schedule = Schedule } )
local ScheduleObject = Scheduler.SchedulerObject
--local ScheduleObjectName = Scheduler.SchedulerObject:GetNameAndClassID()
@@ -168,7 +168,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
end
function SCHEDULEDISPATCHER:RemoveSchedule( Scheduler, CallID )
self:F( { Remove = CallID, Scheduler = Scheduler } )
self:F2( { Remove = CallID, Scheduler = Scheduler } )
if CallID then
self:Stop( Scheduler, CallID )
@@ -177,7 +177,7 @@ function SCHEDULEDISPATCHER:RemoveSchedule( Scheduler, CallID )
end
function SCHEDULEDISPATCHER:Start( Scheduler, CallID )
self:F( { Start = CallID, Scheduler = Scheduler } )
self:F2( { Start = CallID, Scheduler = Scheduler } )
if CallID then
local Schedule = self.Schedule[Scheduler]
@@ -194,7 +194,7 @@ function SCHEDULEDISPATCHER:Start( Scheduler, CallID )
end
function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
self:F( { Stop = CallID, Scheduler = Scheduler } )
self:F2( { Stop = CallID, Scheduler = Scheduler } )
if CallID then
local Schedule = self.Schedule[Scheduler]

View File

@@ -1,45 +0,0 @@
--- @module Process
--- The PROCESS class
-- @type PROCESS
-- @field Tasking.Task#TASK_BASE ProcessTask
-- @field Wrapper.Group#GROUP ProcessGroup
-- @field Core.Menu#MENU_GROUP MissionMenu
-- @field #string ProcessName
-- @extends Fsm.Fsm#FSM_CONTROLLABLE
PROCESS = {
ClassName = "PROCESS",
NextEvent = nil,
Scores = {},
}
--- Instantiates a new TASK Base. Should never be used. Interface Class.
-- @param #PROCESS self
-- @param #string ProcessName
-- @param Wrapper.Unit#UNIT ProcessUnit (Optional) If provided, it defines the UNIT for which the process is running.
-- @return #PROCESS
function PROCESS:New( FSMT, ProcessName, ProcessUnit )
local self = BASE:Inherit( self, FSM_PROCESS:New( FSMT, ProcessUnit ) )
self:F()
if ProcessUnit then
self.ProcessGroup = ProcessUnit:GetGroup()
end
--self.MissionMenu = Task.Mission:GetMissionMenu( self.ProcessGroup )
self.ProcessName = ProcessName
return self
end
--- Gets the Group of the process.
-- @param #PROCESS self
-- @return Wrapper.Group#GROUP
function PROCESS:GetGroup()
return self.ProcessGroup
end

View File

@@ -15,6 +15,7 @@ Include.File( "Core/Database" )
Include.File( "Core/Set" )
Include.File( "Core/Point" )
Include.File( "Core/Message" )
Include.File( "Core/Fsm" )
--- Wrapper Classes
Include.File( "Wrapper/Object" )
@@ -37,18 +38,17 @@ Include.File( "Functional/Escort" )
Include.File( "Functional/MissileTrainer" )
Include.File( "Functional/AirbasePolice" )
Include.File( "Functional/Detection" )
Include.File( "Functional/AIBalancer" )
--- Fsm Classes
Include.File( "Fsm/Fsm" )
Include.File( "Fsm/Process" )
Include.File( "Fsm/Process_JTAC" )
Include.File( "Fsm/Patrol" )
Include.File( "Fsm/Cargo" )
Include.File( "Fsm/FsmAssign" )
Include.File( "Fsm/FsmRoute" )
Include.File( "Fsm/FsmAccount" )
Include.File( "Fsm/FsmSmoke" )
--- AI Classes
Include.File( "AI/AI_Balancer" )
Include.File( "AI/AI_Patrol" )
Include.File( "AI/AI_Cargo" )
--- Actions
Include.File( "Actions/Act_Assign" )
Include.File( "Actions/Act_Route" )
Include.File( "Actions/Act_Account" )
Include.File( "Actions/Act_Assist" )
--- Task Handling Classes
Include.File( "Tasking/CommandCenter" )

View File

@@ -74,11 +74,65 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
local EventGroup = GROUP:Find( EventData.IniDCSGroup )
if EventGroup and self:HasGroup( EventGroup ) then
local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", self.CommandCenterMenu )
local MenuMissions = MENU_GROUP_COMMAND:New( EventGroup, "Missions", MenuReporting, self.ReportMissions, self, EventGroup )
self:ReportMissions( EventGroup )
local MenuMissionsSummary = MENU_GROUP_COMMAND:New( EventGroup, "Missions Summary Report", MenuReporting, self.ReportSummary, self, EventGroup )
local MenuMissionsDetails = MENU_GROUP_COMMAND:New( EventGroup, "Missions Details Report", MenuReporting, self.ReportDetails, self, EventGroup )
self:ReportSummary( EventGroup )
end
local PlayerUnit = EventData.IniUnit
for MissionID, Mission in pairs( self:GetMissions() ) do
local Mission = Mission -- Tasking.Mission#MISSION
Mission:JoinUnit( PlayerUnit )
Mission:ReportDetails()
end
end
)
-- When a player enters a client or a unit, the CommandCenter will check for each Mission and each Task in the Mission if the player has things to do.
-- For these elements, it will=
-- - Set the correct menu.
-- - Assign the PlayerUnit to the Task if required.
-- - Send a message to the other players in the group that this player has joined.
self:EventOnPlayerEnterUnit(
--- @param #COMMANDCENTER self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
local PlayerUnit = EventData.IniUnit
for MissionID, Mission in pairs( self:GetMissions() ) do
local Mission = Mission -- Tasking.Mission#MISSION
Mission:JoinUnit( PlayerUnit )
Mission:ReportDetails()
end
end
)
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
self:EventOnPlayerLeaveUnit(
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
local PlayerUnit = EventData.IniUnit
for MissionID, Mission in pairs( self:GetMissions() ) do
Mission:AbortUnit( PlayerUnit )
end
end
)
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
self:EventOnCrash(
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
local PlayerUnit = EventData.IniUnit
for MissionID, Mission in pairs( self:GetMissions() ) do
Mission:CrashUnit( PlayerUnit )
end
end
)
return self
end
@@ -98,6 +152,13 @@ function COMMANDCENTER:GetPositionable()
return self.CommandCenterPositionable
end
--- Get the Missions governed by the HQ command center.
-- @param #COMMANDCENTER self
-- @return #list<Tasking.Mission#MISSION>
function COMMANDCENTER:GetMissions()
return self.Missions
end
--- Add a MISSION to be governed by the HQ command center.
-- @param #COMMANDCENTER self
@@ -125,10 +186,11 @@ end
--- Sets the menu structure of the Missions governed by the HQ command center.
-- @param #COMMANDCENTER self
function COMMANDCENTER:SetMenu()
self:F()
self.CommandCenterMenu = self.CommandCenterMenu or MENU_COALITION:New( self.CommandCenterCoalition, "HQ" )
for MissionID, Mission in pairs( self.Missions ) do
for MissionID, Mission in pairs( self:GetMissions() ) do
local Mission = Mission -- Tasking.Mission#MISSION
Mission:SetMenu()
end
@@ -162,16 +224,26 @@ function COMMANDCENTER:MessageToGroup( Message, TaskGroup )
end
--- Report the status of all MISSIONs to a GROUP.
--- Send a CC message to the coalition of the CC.
-- @param #COMMANDCENTER self
function COMMANDCENTER:ReportMissions( ReportGroup )
function COMMANDCENTER:MessageToCoalition( Message )
local CCCoalition = self:GetPositionable():GetCoalition()
self:GetPositionable():MessageToBlue( Message , 20, CCCoalition )
end
--- Report the status of all MISSIONs to a GROUP.
-- Each Mission is listed, with an indication how many Tasks are still to be completed.
-- @param #COMMANDCENTER self
function COMMANDCENTER:ReportSummary( ReportGroup )
self:E( ReportGroup )
local Report = REPORT:New()
for MissionID, Mission in pairs( self.Missions ) do
local Mission = Mission -- Tasking.Mission#MISSION
Report:Add( " - " .. Mission:ReportStatus() )
Report:Add( " - " .. Mission:ReportOverview() )
end
self:GetPositionable():MessageToGroup( Report:Text(), 30, ReportGroup )
@@ -179,18 +251,18 @@ function COMMANDCENTER:ReportMissions( ReportGroup )
end
--- Report the status of a Task to a Group.
-- Report the details of a Mission, listing the Mission, and all the Task details.
-- @param #COMMANDCENTER self
function COMMANDCENTER:ReportTaskStatus( ReportGroup, Task )
function COMMANDCENTER:ReportDetails( ReportGroup, Task )
self:E( ReportGroup )
local Report = REPORT:New()
for MissionID, Mission in pairs( self.Missions ) do
local Mission = Mission -- Tasking.Mission#MISSION
Report:Add( " - " .. Mission:ReportStatus() )
Report:Add( " - " .. Mission:ReportDetails() )
end
self:GetPositionable():MessageToGroup( Report:Text(), 30, ReportGroup )
end

View File

@@ -317,7 +317,7 @@ do -- DETECTION_DISPATCHER
--- Creates a CAS task when there are targets for it.
-- @param #DETECTION_DISPATCHER self
-- @param Functional.Detection#DETECTION_AREAS.DetectedArea DetectedArea
-- @return Tasking.Task#TASK_BASE
-- @return Tasking.Task#TASK
function DETECTION_DISPATCHER:EvaluateCAS( DetectedArea )
self:F( { DetectedArea.AreaID } )
@@ -345,7 +345,7 @@ do -- DETECTION_DISPATCHER
--- Creates a BAI task when there are targets for it.
-- @param #DETECTION_DISPATCHER self
-- @param Functional.Detection#DETECTION_AREAS.DetectedArea DetectedArea
-- @return Tasking.Task#TASK_BASE
-- @return Tasking.Task#TASK
function DETECTION_DISPATCHER:EvaluateBAI( DetectedArea, FriendlyCoalition )
self:F( { DetectedArea.AreaID } )
@@ -374,9 +374,9 @@ do -- DETECTION_DISPATCHER
-- Can only occur when the DetectedArea is Changed AND the state of the Task is "Planned".
-- @param #DETECTION_DISPATCHER self
-- @param Tasking.Mission#MISSION Mission
-- @param Tasking.Task#TASK_BASE Task
-- @param Tasking.Task#TASK Task
-- @param Functional.Detection#DETECTION_AREAS.DetectedArea DetectedArea
-- @return Tasking.Task#TASK_BASE
-- @return Tasking.Task#TASK
function DETECTION_DISPATCHER:EvaluateRemoveTask( Mission, Task, DetectedArea )
if Task then

View File

@@ -7,7 +7,7 @@
-- @field #MISSION.Clients _Clients
-- @field Core.Menu#MENU_COALITION MissionMenu
-- @field #string MissionBriefing
-- @extends Fsm.Fsm#FSM
-- @extends Core.Fsm#FSM
MISSION = {
ClassName = "MISSION",
Name = "",
@@ -40,13 +40,14 @@ MISSION = {
-- @return #MISSION self
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
local self = BASE:Inherit( self, FSM:New() ) -- Fsm.Fsm#FSM
local self = BASE:Inherit( self, FSM:New() ) -- Core.Fsm#FSM
self:SetStartState( "Idle" )
self:AddTransition( "Idle", "Start", "Ongoing" )
self:AddTransition( "Ongoing", "Stop", "Idle" )
self:AddTransition( "Ongoing", "Finish", "Finished" )
self:AddTransition( "Ongoing", "Complete", "Completed" )
self:AddTransition( "*", "Fail", "Failed" )
self:T( { MissionName, MissionPriority, MissionBriefing, MissionCoalition } )
@@ -60,12 +61,35 @@ function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefi
self.Tasks = {}
-- Build the Fsm for the mission.
return self
end
--- FSM function for a MISSION
-- @param #MISSION self
-- @param #string Event
-- @param #string From
-- @param #string To
function MISSION:onbeforeComplete( Event, From, To )
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK
if not Task:IsStateSuccess() and not Task:IsStateFailed() and not Task:IsStateAborted() and not Task:IsStateCancelled() then
return false -- Mission cannot be completed. Other Tasks are still active.
end
end
return true -- Allow Mission completion.
end
--- FSM function for a MISSION
-- @param #MISSION self
-- @param #string Event
-- @param #string From
-- @param #string To
function MISSION:onenterCompleted( Event, From, To )
self:GetCommandCenter():MessageToCoalition( "Mission " .. self:GetName() .. " has been completed! Good job guys!" )
end
--- Gets the mission name.
-- @param #MISSION self
-- @return #MISSION self
@@ -73,6 +97,70 @@ function MISSION:GetName()
return self.Name
end
--- Add a Unit to join the Mission.
-- For each Task within the Mission, the Unit is joined with the Task.
-- If the Unit was not part of a Task in the Mission, false is returned.
-- If the Unit is part of a Task in the Mission, true is returned.
-- @param #MISSION self
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player joining the Mission.
-- @return #boolean true if Unit is part of a Task in the Mission.
function MISSION:JoinUnit( PlayerUnit )
self:F( { PlayerUnit = PlayerUnit } )
local PlayerUnitAdded = false
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK
if Task:JoinUnit( PlayerUnit ) then
PlayerUnitAdded = true
end
end
return PlayerUnitAdded
end
--- Aborts a PlayerUnit from the Mission.
-- For each Task within the Mission, the PlayerUnit is removed from Task where it is assigned.
-- If the Unit was not part of a Task in the Mission, false is returned.
-- If the Unit is part of a Task in the Mission, true is returned.
-- @param #MISSION self
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player joining the Mission.
-- @return #boolean true if Unit is part of a Task in the Mission.
function MISSION:AbortUnit( PlayerUnit )
self:F( { PlayerUnit = PlayerUnit } )
local PlayerUnitRemoved = false
for TaskID, Task in pairs( self:GetTasks() ) do
if Task:AbortUnit( PlayerUnit ) then
PlayerUnitRemoved = true
end
end
return PlayerUnitRemoved
end
--- Handles a crash of a PlayerUnit from the Mission.
-- For each Task within the Mission, the PlayerUnit is removed from Task where it is assigned.
-- If the Unit was not part of a Task in the Mission, false is returned.
-- If the Unit is part of a Task in the Mission, true is returned.
-- @param #MISSION self
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player crashing.
-- @return #boolean true if Unit is part of a Task in the Mission.
function MISSION:CrashUnit( PlayerUnit )
self:F( { PlayerUnit = PlayerUnit } )
local PlayerUnitRemoved = false
for TaskID, Task in pairs( self:GetTasks() ) do
if Task:CrashUnit( PlayerUnit ) then
PlayerUnitRemoved = true
end
end
return PlayerUnitRemoved
end
--- Add a scoring to the mission.
-- @param #MISSION self
-- @return #MISSION self
@@ -96,7 +184,7 @@ function MISSION:GetGroups()
local SetGroup = SET_GROUP:New()
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK_BASE
local Task = Task -- Tasking.Task#TASK
local GroupSet = Task:GetGroups()
GroupSet:ForEachGroup(
function( TaskGroup )
@@ -114,9 +202,10 @@ end
-- @param #MISSION self
-- @param Core.Menu#MENU_COALITION CommandCenterMenu
function MISSION:SetMenu()
self:F()
for _, Task in pairs( self.Tasks ) do
local Task = Task -- Tasking.Task#TASK_BASE
for _, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK
Task:SetMenu()
end
end
@@ -131,13 +220,13 @@ end
--- Sets the Assigned Task menu.
-- @param #MISSION self
-- @param Tasking.Task#TASK_BASE Task
-- @param Tasking.Task#TASK Task
-- @param #string MenuText The menu text.
-- @return #MISSION self
function MISSION:SetAssignedMenu( Task )
for _, Task in pairs( self.Tasks ) do
local Task = Task -- Tasking.Task#TASK_BASE
local Task = Task -- Tasking.Task#TASK
Task:RemoveMenu()
Task:SetAssignedMenu()
end
@@ -146,7 +235,7 @@ end
--- Removes a Task menu.
-- @param #MISSION self
-- @param Tasking.Task#TASK_BASE Task
-- @param Tasking.Task#TASK Task
-- @return #MISSION self
function MISSION:RemoveTaskMenu( Task )
@@ -182,7 +271,7 @@ end
--- Get the TASK identified by the TaskNumber from the Mission. This function is useful in GoalFunctions.
-- @param #string TaskName The Name of the @{Task} within the @{Mission}.
-- @return Tasking.Task#TASK_BASE The Task
-- @return Tasking.Task#TASK The Task
-- @return #nil Returns nil if no task was found.
function MISSION:GetTask( TaskName )
self:F( { TaskName } )
@@ -195,8 +284,8 @@ end
-- Note that there can be multiple @{Task}s registered to be completed.
-- Each Task can be set a certain Goals. The Mission will not be completed until all Goals are reached.
-- @param #MISSION self
-- @param Tasking.Task#TASK_BASE Task is the @{Task} object.
-- @return Tasking.Task#TASK_BASE The task added.
-- @param Tasking.Task#TASK Task is the @{Task} object.
-- @return Tasking.Task#TASK The task added.
function MISSION:AddTask( Task )
local TaskName = Task:GetTaskName()
@@ -205,6 +294,8 @@ function MISSION:AddTask( Task )
self.Tasks[TaskName] = self.Tasks[TaskName] or { n = 0 }
self.Tasks[TaskName] = Task
self:GetCommandCenter():SetMenu()
return Task
end
@@ -213,7 +304,7 @@ end
-- Note that there can be multiple @{Task}s registered to be completed.
-- Each Task can be set a certain Goals. The Mission will not be completed until all Goals are reached.
-- @param #MISSION self
-- @param Tasking.Task#TASK_BASE Task is the @{Task} object.
-- @param Tasking.Task#TASK Task is the @{Task} object.
-- @return #nil The cleaned Task reference.
function MISSION:RemoveTask( Task )
@@ -227,14 +318,16 @@ function MISSION:RemoveTask( Task )
Task = nil
collectgarbage()
self:GetCommandCenter():SetMenu()
return nil
end
--- Return the next @{Task} ID to be completed within the @{Mission}.
-- @param #MISSION self
-- @param Tasking.Task#TASK_BASE Task is the @{Task} object.
-- @return Tasking.Task#TASK_BASE The task added.
-- @param Tasking.Task#TASK Task is the @{Task} object.
-- @return Tasking.Task#TASK The task added.
function MISSION:GetNextTaskID( Task )
local TaskName = Task:GetTaskName()
@@ -320,7 +413,7 @@ function MISSION:HasGroup( TaskGroup )
local Has = false
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK_BASE
local Task = Task -- Tasking.Task#TASK
if Task:HasGroup( TaskGroup ) then
Has = true
break
@@ -330,10 +423,12 @@ function MISSION:HasGroup( TaskGroup )
return Has
end
--- Create a summary report of the mission (one line).
--- Create a summary report of the Mission (one line).
-- @param #MISSION self
-- @return #string
function MISSION:ReportStatus()
function MISSION:ReportSummary()
local Report = REPORT:New()
-- List the name of the mission.
local Name = self:GetName()
@@ -344,14 +439,66 @@ function MISSION:ReportStatus()
-- Determine how many tasks are remaining.
local TasksRemaining = 0
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK_BASE
local Task = Task -- Tasking.Task#TASK
if Task:IsStateSuccess() or Task:IsStateFailed() then
else
TasksRemaining = TasksRemaining + 1
end
end
return "Mission " .. Name .. " - " .. Status .. " - " .. TasksRemaining .. " tasks remaining."
Report:Add( "Mission " .. Name .. " - " .. Status .. " - " .. TasksRemaining .. " tasks remaining." )
return Report:Text()
end
--- Create a overview report of the Mission (multiple lines).
-- @param #MISSION self
-- @return #string
function MISSION:ReportOverview()
local Report = REPORT:New()
-- List the name of the mission.
local Name = self:GetName()
-- Determine the status of the mission.
local Status = self:GetState()
Report:Add( "Mission " .. Name .. " - State '" .. Status .. "'" )
-- Determine how many tasks are remaining.
local TasksRemaining = 0
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK
Report:Add( "- " .. Task:ReportSummary() )
end
return Report:Text()
end
--- Create a detailed report of the Mission, listing all the details of the Task.
-- @param #MISSION self
-- @return #string
function MISSION:ReportDetails()
local Report = REPORT:New()
-- List the name of the mission.
local Name = self:GetName()
-- Determine the status of the mission.
local Status = self:GetState()
Report:Add( "Mission " .. Name .. " - State '" .. Status .. "'" )
-- Determine how many tasks are remaining.
local TasksRemaining = 0
for TaskID, Task in pairs( self:GetTasks() ) do
local Task = Task -- Tasking.Task#TASK
Report:Add( Task:ReportDetails() )
end
return Report:Text()
end
--- Report the status of all MISSIONs to all active Clients.

File diff suppressed because it is too large Load Diff

View File

@@ -47,7 +47,7 @@ end
--- StateMachine callback function for a TASK2
-- @param #TASK2_MENU_CLIENT self
-- @param Fsm.Fsm#FSM_TASK Fsm
-- @param Core.Fsm#FSM_TASK Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
@@ -71,7 +71,7 @@ end
--- StateMachine callback function for a TASK2
-- @param #TASK2_MENU_CLIENT self
-- @param Fsm.Fsm#FSM_TASK Fsm
-- @param Core.Fsm#FSM_TASK Fsm
-- @param #string Event
-- @param #string From
-- @param #string To

View File

@@ -1,14 +1,14 @@
--- (AI) (SP) (MP) Tasking for Air to Ground Processes.
--
-- 1) @{#TASK_A2G} class, extends @{Tasking.Task#TASK_BASE}
-- 1) @{#TASK_A2G} class, extends @{Tasking.Task#TASK}
-- =================================================
-- The @{#TASK_A2G} class defines a CAS or BAI task of a @{Set} of Target Units,
-- located at a Target Zone, based on the tasking capabilities defined in @{Tasking.Task#TASK_BASE}.
-- located at a Target Zone, based on the tasking capabilities defined in @{Tasking.Task#TASK}.
-- The TASK_A2G is implemented using a @{Statemachine#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSM_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSM_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#ACT_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#ACT_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Success**: The SEAD task is successfully completed. Upon Success, the sub-process @{Process_SEAD#PROCESS_SEAD} is started to follow-up successful SEADing of the targets assigned in the task.
-- * **Failed**: The SEAD task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
@@ -23,7 +23,7 @@ do -- TASK_A2G
--- The TASK_A2G class
-- @type TASK_A2G
-- @extends Tasking.Task#TASK_BASE
-- @extends Tasking.Task#TASK
TASK_A2G = {
ClassName = "TASK_A2G",
}
@@ -38,21 +38,21 @@ do -- TASK_A2G
-- @param Core.Zone#ZONE_BASE TargetZone
-- @return #TASK_A2G self
function TASK_A2G:New( Mission, SetGroup, TaskName, TaskType, TargetSetUnit, TargetZone, FACUnit )
local self = BASE:Inherit( self, TASK_BASE:New( Mission, SetGroup, TaskName, TaskType ) )
local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, TaskType ) )
self:F()
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
self.FACUnit = FACUnit
local Fsm = self:GetFsmTemplate()
local Fsm = self:GetUnitProcess()
Fsm:AddProcess( "Planned", "Accept", FSM_ASSIGN_ACCEPT:New( "Attack the Area" ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", FSM_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddProcess( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( "Attack the Area" ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", ACT_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddAction ( "Rejected", "Eject", "Planned" )
Fsm:AddAction ( "Arrived", "Update", "Updated" )
Fsm:AddProcess( "Updated", "Account", FSM_ACCOUNT_DEADS:New( self.TargetSetUnit, "Attack" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", FSM_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
Fsm:AddProcess( "Updated", "Account", ACT_ACCOUNT_DEADS:New( self.TargetSetUnit, "Attack" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", ACT_ASSIST_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
--Fsm:AddProcess( "Updated", "JTAC", PROCESS_JTAC:New( self, TaskUnit, self.TargetSetUnit, self.FACUnit ) )
Fsm:AddAction ( "Accounted", "Success", "Success" )
Fsm:AddAction ( "Failed", "Fail", "Failed" )

View File

@@ -1,29 +1,29 @@
--- This module contains the AIBALANCER class.
--- This module contains the AI_BALANCER class.
--
-- ===
--
-- 1) @{Functional.AIBalancer#AIBALANCER} class, extends @{Core.Base#BASE}
-- 1) @{AI.AI_Balancer#AI_BALANCER} class, extends @{Core.Base#BASE}
-- =======================================================
-- The @{Functional.AIBalancer#AIBALANCER} class controls the dynamic spawning of AI GROUPS depending on a SET_CLIENT.
-- The @{AI.AI_Balancer#AI_BALANCER} class controls the dynamic spawning of AI GROUPS depending on a SET_CLIENT.
-- There will be as many AI GROUPS spawned as there at CLIENTS in SET_CLIENT not spawned.
-- The AIBalancer uses the @{PatrolCore.Zone#PATROLZONE} class to make AI patrol an zone until the fuel treshold is reached.
-- The AI_Balancer uses the @{PatrolCore.Zone#AI_PATROLZONE} class to make AI patrol an zone until the fuel treshold is reached.
--
-- 1.1) AIBALANCER construction method:
-- 1.1) AI_BALANCER construction method:
-- ------------------------------------
-- Create a new AIBALANCER object with the @{#AIBALANCER.New} method:
-- Create a new AI_BALANCER object with the @{#AI_BALANCER.New} method:
--
-- * @{#AIBALANCER.New}: Creates a new AIBALANCER object.
-- * @{#AI_BALANCER.New}: Creates a new AI_BALANCER object.
--
-- 1.2) AIBALANCER returns AI to Airbases:
-- 1.2) AI_BALANCER returns AI to Airbases:
-- ---------------------------------------
-- You can configure to have the AI to return to:
--
-- * @{#AIBALANCER.ReturnToHomeAirbase}: Returns the AI to the home @{Wrapper.Airbase#AIRBASE}.
-- * @{#AIBALANCER.ReturnToNearestAirbases}: Returns the AI to the nearest friendly @{Wrapper.Airbase#AIRBASE}.
-- * @{#AI_BALANCER.ReturnToHomeAirbase}: Returns the AI to the home @{Wrapper.Airbase#AIRBASE}.
-- * @{#AI_BALANCER.ReturnToNearestAirbases}: Returns the AI to the nearest friendly @{Wrapper.Airbase#AIRBASE}.
--
-- 1.3) AIBALANCER allows AI to patrol specific zones:
-- 1.3) AI_BALANCER allows AI to patrol specific zones:
-- ---------------------------------------------------
-- Use @{Functional.AIBalancer#AIBALANCER.SetPatrolZone}() to specify a zone where the AI needs to patrol.
-- Use @{AI.AI_Balancer#AI_BALANCER.SetPatrolZone}() to specify a zone where the AI needs to patrol.
--
-- ===
--
@@ -50,43 +50,43 @@
-- ### Contributions:
--
-- * **Dutch_Baron (James)**: Who you can search on the Eagle Dynamics Forums.
-- Working together with James has resulted in the creation of the AIBALANCER class.
-- Working together with James has resulted in the creation of the AI_BALANCER class.
-- James has shared his ideas on balancing AI with air units, and together we made a first design which you can use now :-)
--
-- * **SNAFU**:
-- Had a couple of mails with the guys to validate, if the same concept in the GCI/CAP script could be reworked within MOOSE.
-- None of the script code has been used however within the new AIBALANCER moose class.
-- None of the script code has been used however within the new AI_BALANCER moose class.
--
-- ### Authors:
--
-- * FlightControl: Framework Design & Programming
--
-- @module AIBalancer
-- @module AI_Balancer
--- AIBALANCER class
-- @type AIBALANCER
--- AI_BALANCER class
-- @type AI_BALANCER
-- @field Core.Set#SET_CLIENT SetClient
-- @field Functional.Spawn#SPAWN SpawnAI
-- @field #boolean ToNearestAirbase
-- @field Core.Set#SET_AIRBASE ReturnAirbaseSet
-- @field Dcs.DCSTypes#Distance ReturnTresholdRange
-- @field #boolean ToHomeAirbase
-- @field PatrolCore.Zone#PATROLZONE PatrolZone
-- @field PatrolCore.Zone#AI_PATROLZONE PatrolZone
-- @extends Core.Base#BASE
AIBALANCER = {
ClassName = "AIBALANCER",
AI_BALANCER = {
ClassName = "AI_BALANCER",
PatrolZones = {},
AIGroups = {},
}
--- Creates a new AIBALANCER object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.
-- @param #AIBALANCER self
--- Creates a new AI_BALANCER object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.
-- @param #AI_BALANCER self
-- @param SetClient A SET_CLIENT object that will contain the CLIENT objects to be monitored if they are alive or not (joined by a player).
-- @param SpawnAI A SPAWN object that will spawn the AI units required, balancing the SetClient.
-- @return #AIBALANCER self
function AIBALANCER:New( SetClient, SpawnAI )
-- @return #AI_BALANCER self
function AI_BALANCER:New( SetClient, SpawnAI )
-- Inherits from BASE
local self = BASE:Inherit( self, BASE:New() )
@@ -122,10 +122,10 @@ function AIBALANCER:New( SetClient, SpawnAI )
end
--- Returns the AI to the nearest friendly @{Wrapper.Airbase#AIRBASE}.
-- @param #AIBALANCER self
-- @param #AI_BALANCER self
-- @param Dcs.DCSTypes#Distance ReturnTresholdRange If there is an enemy @{Wrapper.Client#CLIENT} within the ReturnTresholdRange given in meters, the AI will not return to the nearest @{Wrapper.Airbase#AIRBASE}.
-- @param Core.Set#SET_AIRBASE ReturnAirbaseSet The SET of @{Core.Set#SET_AIRBASE}s to evaluate where to return to.
function AIBALANCER:ReturnToNearestAirbases( ReturnTresholdRange, ReturnAirbaseSet )
function AI_BALANCER:ReturnToNearestAirbases( ReturnTresholdRange, ReturnAirbaseSet )
self.ToNearestAirbase = true
self.ReturnTresholdRange = ReturnTresholdRange
@@ -133,21 +133,21 @@ function AIBALANCER:ReturnToNearestAirbases( ReturnTresholdRange, ReturnAirbaseS
end
--- Returns the AI to the home @{Wrapper.Airbase#AIRBASE}.
-- @param #AIBALANCER self
-- @param #AI_BALANCER self
-- @param Dcs.DCSTypes#Distance ReturnTresholdRange If there is an enemy @{Wrapper.Client#CLIENT} within the ReturnTresholdRange given in meters, the AI will not return to the nearest @{Wrapper.Airbase#AIRBASE}.
function AIBALANCER:ReturnToHomeAirbase( ReturnTresholdRange )
function AI_BALANCER:ReturnToHomeAirbase( ReturnTresholdRange )
self.ToHomeAirbase = true
self.ReturnTresholdRange = ReturnTresholdRange
end
--- Let the AI patrol a @{Zone} with a given Speed range and Altitude range.
-- @param #AIBALANCER self
-- @param PatrolCore.Zone#PATROLZONE PatrolZone The @{PatrolZone} where the AI needs to patrol.
-- @return PatrolCore.Zone#PATROLZONE self
function AIBALANCER:SetPatrolZone( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed )
-- @param #AI_BALANCER self
-- @param PatrolCore.Zone#AI_PATROLZONE PatrolZone The @{PatrolZone} where the AI needs to patrol.
-- @return PatrolCore.Zone#AI_PATROLZONE self
function AI_BALANCER:SetPatrolZone( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed )
self.PatrolZone = PATROLZONE:New(
self.PatrolZone = AI_PATROLZONE:New(
self.SpawnAI,
PatrolZone,
PatrolFloorAltitude,
@@ -157,18 +157,18 @@ function AIBALANCER:SetPatrolZone( PatrolZone, PatrolFloorAltitude, PatrolCeilin
)
end
--- Get the @{PatrolZone} object assigned by the @{AIBalancer} object.
-- @param #AIBALANCER self
-- @return PatrolCore.Zone#PATROLZONE PatrolZone The @{PatrolZone} where the AI needs to patrol.
function AIBALANCER:GetPatrolZone()
--- Get the @{PatrolZone} object assigned by the @{AI_Balancer} object.
-- @param #AI_BALANCER self
-- @return PatrolCore.Zone#AI_PATROLZONE PatrolZone The @{PatrolZone} where the AI needs to patrol.
function AI_BALANCER:GetPatrolZone()
return self.PatrolZone
end
--- @param #AIBALANCER self
function AIBALANCER:_ClientAliveMonitorScheduler()
--- @param #AI_BALANCER self
function AI_BALANCER:_ClientAliveMonitorScheduler()
self.SetClient:ForEachClient(
--- @param Wrapper.Client#CLIENT Client
@@ -255,7 +255,7 @@ function AIBALANCER:_ClientAliveMonitorScheduler()
--- Now test if the AIGroup needs to patrol a zone, otherwise let it follow its route...
if self.PatrolZone then
self.PatrolZones[#self.PatrolZones+1] = PATROLZONE:New(
self.PatrolZones[#self.PatrolZones+1] = AI_PATROLZONE:New(
self.PatrolZone.PatrolZone,
self.PatrolZone.PatrolFloorAltitude,
self.PatrolZone.PatrolCeilingAltitude,

View File

@@ -1,14 +1,14 @@
--- This module contains the TASK_PICKUP classes.
--
-- 1) @{#TASK_PICKUP} class, extends @{Tasking.Task#TASK_BASE}
-- 1) @{#TASK_PICKUP} class, extends @{Tasking.Task#TASK}
-- ===================================================
-- The @{#TASK_PICKUP} class defines a pickup task of a @{Set} of @{CARGO} objects defined within the mission.
-- based on the tasking capabilities defined in @{Tasking.Task#TASK_BASE}.
-- based on the tasking capabilities defined in @{Tasking.Task#TASK}.
-- The TASK_PICKUP is implemented using a @{Statemachine#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSM_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSM_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#ACT_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#ACT_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Success**: The SEAD task is successfully completed. Upon Success, the sub-process @{Process_SEAD#PROCESS_SEAD} is started to follow-up successful SEADing of the targets assigned in the task.
-- * **Failed**: The SEAD task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
@@ -23,7 +23,7 @@ do -- TASK_PICKUP
--- The TASK_PICKUP class
-- @type TASK_PICKUP
-- @extends Tasking.Task#TASK_BASE
-- @extends Tasking.Task#TASK
TASK_PICKUP = {
ClassName = "TASK_PICKUP",
}
@@ -38,7 +38,7 @@ do -- TASK_PICKUP
-- @param Core.Zone#ZONE_BASE TargetZone
-- @return #TASK_PICKUP self
function TASK_PICKUP:New( Mission, AssignedSetGroup, TaskName, TaskType )
local self = BASE:Inherit( self, TASK_BASE:New( Mission, AssignedSetGroup, TaskName, TaskType, "PICKUP" ) )
local self = BASE:Inherit( self, TASK:New( Mission, AssignedSetGroup, TaskName, TaskType, "PICKUP" ) )
self:F()
_EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventPlayerLeaveUnit, self )
@@ -67,7 +67,7 @@ do -- TASK_PICKUP
function TASK_PICKUP:AssignToUnit( TaskUnit )
self:F( TaskUnit:GetName() )
local ProcessAssign = self:AddProcess( TaskUnit, FSM_ASSIGN_ACCEPT:New( self, TaskUnit, self.TaskBriefing ) )
local ProcessAssign = self:AddProcess( TaskUnit, ACT_ASSIGN_ACCEPT:New( self, TaskUnit, self.TaskBriefing ) )
local ProcessPickup = self:AddProcess( TaskUnit, PROCESS_PICKUP:New( self, self.TaskType, TaskUnit ) )
local Process = self:AddStateMachine( TaskUnit, FSM_TASK:New( self, TaskUnit, {
@@ -98,7 +98,7 @@ do -- TASK_PICKUP
--- StateMachine callback function for a TASK
-- @param #TASK_PICKUP self
-- @param Fsm.Fsm#FSM_TASK Fsm
-- @param Core.Fsm#FSM_TASK Fsm
-- @param #string Event
-- @param #string From
-- @param #string To

View File

@@ -1,14 +1,14 @@
--- This module contains the TASK_SEAD classes.
--
-- 1) @{#TASK_SEAD} class, extends @{Tasking.Task#TASK_BASE}
-- 1) @{#TASK_SEAD} class, extends @{Tasking.Task#TASK}
-- =================================================
-- The @{#TASK_SEAD} class defines a SEAD task for a @{Set} of Target Units, located at a Target Zone,
-- based on the tasking capabilities defined in @{Tasking.Task#TASK_BASE}.
-- based on the tasking capabilities defined in @{Tasking.Task#TASK}.
-- The TASK_SEAD is implemented using a @{Statemachine#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSM_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSM_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#ACT_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#ACT_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Success**: The SEAD task is successfully completed. Upon Success, the sub-process @{Process_SEAD#PROCESS_SEAD} is started to follow-up successful SEADing of the targets assigned in the task.
-- * **Failed**: The SEAD task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
@@ -25,7 +25,7 @@ do -- TASK_SEAD
--- The TASK_SEAD class
-- @type TASK_SEAD
-- @field Set#SET_UNIT TargetSetUnit
-- @extends Tasking.Task#TASK_BASE
-- @extends Tasking.Task#TASK
TASK_SEAD = {
ClassName = "TASK_SEAD",
}
@@ -39,20 +39,20 @@ do -- TASK_SEAD
-- @param Core.Zone#ZONE_BASE TargetZone
-- @return #TASK_SEAD self
function TASK_SEAD:New( Mission, SetGroup, TaskName, TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, TASK_BASE:New( Mission, SetGroup, TaskName, "SEAD" ) ) -- Tasking.Task_SEAD#TASK_SEAD
local self = BASE:Inherit( self, TASK:New( Mission, SetGroup, TaskName, "SEAD" ) ) -- Tasking.Task_SEAD#TASK_SEAD
self:F()
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
local Fsm = self:GetFsmTemplate()
local Fsm = self:GetUnitProcess()
Fsm:AddProcess( "Planned", "Accept", FSM_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", FSM_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddProcess( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", ACT_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddAction ( "Rejected", "Eject", "Planned" )
Fsm:AddAction ( "Arrived", "Update", "Updated" )
Fsm:AddProcess( "Updated", "Account", FSM_ACCOUNT_DEADS:New( self.TargetSetUnit, "SEAD" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", FSM_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
Fsm:AddProcess( "Updated", "Account", ACT_ACCOUNT_DEADS:New( self.TargetSetUnit, "SEAD" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", ACT_ASSIST_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
Fsm:AddAction ( "Accounted", "Success", "Success" )
Fsm:AddAction ( "Failed", "Fail", "Failed" )

View File

@@ -239,7 +239,7 @@ end
--- @param #CLIENT self
function CLIENT:_AliveCheckScheduler( SchedulerName )
self:F( { SchedulerName, self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } )
self:F3( { SchedulerName, self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } )
if self:IsAlive() then
if self.ClientAlive2 == false then
@@ -399,8 +399,8 @@ function CLIENT:IsTransport()
return self.ClientTransport
end
--- Shows the @{Fsm.Cargo#CARGO} contained within the CLIENT to the player as a message.
-- The @{Fsm.Cargo#CARGO} is shown using the @{Core.Message#MESSAGE} distribution system.
--- Shows the @{AI.AI_Cargo#CARGO} contained within the CLIENT to the player as a message.
-- The @{AI.AI_Cargo#CARGO} is shown using the @{Core.Message#MESSAGE} distribution system.
-- @param #CLIENT self
function CLIENT:ShowCargo()
self:F()

View File

@@ -970,7 +970,7 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation,
return DCSTask
end
-- EN-FSM_ROUTE TASKS FOR AIRBORNE CONTROLLABLES
-- EN-ACT_ROUTE TASKS FOR AIRBORNE CONTROLLABLES
--- (AIR) Engaging targets of defined types.
-- @param #CONTROLLABLE self

View File

@@ -64,7 +64,7 @@ end
-- @return #boolean true if Identifiable is alive.
-- @return #nil The DCS Identifiable is not existing or alive.
function IDENTIFIABLE:IsAlive()
self:F2( self.IdentifiableName )
self:F3( self.IdentifiableName )
local DCSIdentifiable = self:GetDCSObject()

View File

@@ -307,6 +307,23 @@ function POSITIONABLE:MessageToAll( Message, Duration )
return nil
end
--- Send a message to a coalition.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #POSITIONABLE self
-- @param #string Message The message text
-- @param Dcs.DCSTYpes#Duration Duration The duration of the message.
function POSITIONABLE:MessageToCoalition( Message, Duration, MessageCoalition )
self:F2( { Message, Duration } )
local DCSObject = self:GetDCSObject()
if DCSObject then
self:GetMessage( Message, Duration ):ToCoalition( MessageCoalition )
end
return nil
end
--- Send a message to the red coalition.
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
-- @param #POSITIONABLE self

View File

@@ -915,7 +915,7 @@ end
_TransportStage: Defines the different stages of which of transport missions can be in. This table is internal and is used to control the sequence of messages, actions and flow.
- _TransportStage.START
- _TransportStage.FSM_ROUTE
- _TransportStage.ACT_ROUTE
- _TransportStage.LAND
- _TransportStage.EXECUTE
- _TransportStage.DONE
@@ -924,7 +924,7 @@ end
_TransportStage = {
HOLD = "HOLD",
START = "START",
FSM_ROUTE = "FSM_ROUTE",
ACT_ROUTE = "ACT_ROUTE",
LANDING = "LANDING",
LANDED = "LANDED",
EXECUTING = "EXECUTING",
@@ -937,7 +937,7 @@ _TransportStage = {
_TransportStageMsgTime = {
HOLD = 10,
START = 60,
FSM_ROUTE = 5,
ACT_ROUTE = 5,
LANDING = 10,
LANDED = 30,
EXECUTING = 30,
@@ -950,7 +950,7 @@ _TransportStageMsgTime = {
_TransportStageTime = {
HOLD = 10,
START = 5,
FSM_ROUTE = 5,
ACT_ROUTE = 5,
LANDING = 1,
LANDED = 1,
EXECUTING = 5,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -45,6 +45,7 @@ COPY /b Moose.lua + %1\Utilities\Utils.lua
rem Core Classes
COPY /b Moose.lua + %1\Core\Base.lua Moose.lua
COPY /b Moose.lua + %1\Core\Scheduler.lua Moose.lua
COPY /b Moose.lua + %1\Core\ScheduleDispatcher.lua Moose.lua
COPY /b Moose.lua + %1\Core\Event.lua Moose.lua
COPY /b Moose.lua + %1\Core\Menu.lua Moose.lua
COPY /b Moose.lua + %1\Core\Zone.lua Moose.lua
@@ -52,6 +53,7 @@ COPY /b Moose.lua + %1\Core\Database.lua Moose.lua
COPY /b Moose.lua + %1\Core\Set.lua Moose.lua
COPY /b Moose.lua + %1\Core\Point.lua Moose.lua
COPY /b Moose.lua + %1\Core\Message.lua Moose.lua
COPY /b Moose.lua + %1\Core\Fsm.lua Moose.lua
rem Wrapper Classes
COPY /b Moose.lua + %1\Wrapper\Object.lua Moose.lua
@@ -74,19 +76,18 @@ COPY /b Moose.lua + %1\Functional\Escort.lua Moose.lua
COPY /b Moose.lua + %1\Functional\MissileTrainer.lua Moose.lua
COPY /b Moose.lua + %1\Functional\AirbasePolice.lua Moose.lua
COPY /b Moose.lua + %1\Functional\Detection.lua Moose.lua
COPY /b Moose.lua + %1\Functional\AIBalancer.lua Moose.lua
rem AI Classes
COPY /b Moose.lua + %1\AI\AI_Balancer.lua Moose.lua
COPY /b Moose.lua + %1\AI\AI_Patrol.lua Moose.lua
COPY /b Moose.lua + %1\AI\AI_Cargo.lua Moose.lua
rem Fsm Classes
COPY /b Moose.lua + %1\Fsm\Fsm.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\Process.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\Process_JTAC.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\Patrol.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\Cargo.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\FsmAssign.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\FsmRoute.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\FsmAccount.lua Moose.lua
COPY /b Moose.lua + %1\Fsm\FsmSmoke.lua Moose.lua
rem Actions
COPY /b Moose.lua + %1\Actions\Act_Assign.lua Moose.lua
COPY /b Moose.lua + %1\Actions\Act_Route.lua Moose.lua
COPY /b Moose.lua + %1\Actions\Act_Account.lua Moose.lua
COPY /b Moose.lua + %1\Actions\Act_Assist.lua Moose.lua
rem Task Handling Classes
COPY /b Moose.lua + %1\Tasking\CommandCenter.lua Moose.lua

View File

@@ -21,7 +21,7 @@
--
-- # Status: TESTED 07 Dec 2016
--
-- @module TEST.AIBALANCER.T001
-- @module TEST.AI_BALANCER.T001
-- Define the SET of CLIENTs from the red coalition. This SET is filled during startup.
local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCategories( "plane" ):FilterStart()
@@ -31,5 +31,5 @@ local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCa
-- If a blocked plane exists, this red plane will be ReSpawned.
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
-- Start the AIBALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
local RU_AIBalancer = AIBALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )

View File

@@ -22,7 +22,7 @@
--
-- # Status: DEVELOP 07 Dec 2016
--
-- @module TEST.AIBALANCER.T002
-- @module TEST.AI_BALANCER.T002
-- Define the SET of CLIENTs from the red coalition. This SET is filled during startup.
local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCategories( "plane" ):FilterStart()
@@ -32,16 +32,16 @@ local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCa
-- If a blocked plane exists, this red plane will be ReSpawned.
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
-- Start the AIBALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
local RU_AIBalancer = AIBALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
function RU_AIBalancer:OnAfterSpawned( SetGroup, Event, From, To, AIGroup )
function RU_AI_Balancer:OnAfterSpawned( SetGroup, Event, From, To, AIGroup )
local PatrolZoneGroup = GROUP:FindByName( "PatrolZone" )
local PatrolZone = ZONE_POLYGON:New( "PatrolZone", PatrolZoneGroup )
local Patrol = PATROLZONE:New( PatrolZone, 3000, 6000, 400, 600 )
local Patrol = AI_PATROLZONE:New( PatrolZone, 3000, 6000, 400, 600 )
Patrol:ManageFuel( 0.2, 60 )
Patrol:SetControllable( AIGroup )
Patrol:__Start( 5 )

View File

@@ -2,23 +2,23 @@
local US_PlanesClientSet = SET_CLIENT:New():FilterCountries( "USA" ):FilterCategories( "plane" ):FilterStart()
local US_PlanesSpawn = SPAWN:New( "AI US" ):InitCleanUp( 20 )
local US_AIBalancer = AIBALANCER:New( US_PlanesClientSet, US_PlanesSpawn )
local US_AI_Balancer = AI_BALANCER:New( US_PlanesClientSet, US_PlanesSpawn )
local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCategories( "plane" ):FilterStart()
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
local RU_AIBalancer = AIBALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
local RU_AirbasesSet = SET_AIRBASE:New():FilterCoalitions("red"):FilterStart()
RU_AirbasesSet:Flush()
RU_AIBalancer:ReturnToNearestAirbases( 10000, RU_AirbasesSet )
--RU_AIBalancer:ReturnToHomeAirbase( 10000 )
RU_AI_Balancer:ReturnToNearestAirbases( 10000, RU_AirbasesSet )
--RU_AI_Balancer:ReturnToHomeAirbase( 10000 )
--local PatrolZoneGroup = GROUP:FindByName( "Patrol Zone Blue" )
--local PatrolZoneBlue = ZONE_POLYGON:New( "PatrolZone", PatrolZoneGroup )
--local PatrolZoneB = PATROLZONE:New( PatrolZoneBlue, 3000, 6000, 900, 1100 ):ManageFuel( 0.2, 180 )
--US_AIBalancer:SetPatrolZone( PatrolZoneB )
--local PatrolZoneB = AI_PATROLZONE:New( PatrolZoneBlue, 3000, 6000, 900, 1100 ):ManageFuel( 0.2, 180 )
--US_AI_Balancer:SetPatrolZone( PatrolZoneB )
--
--local PatrolZoneGroup = GROUP:FindByName( "Patrol Zone Red" )
--local PatrolZoneRed = ZONE_POLYGON:New( "PatrolZone", PatrolZoneGroup )
--local PatrolZoneR = PATROLZONE:New( PatrolZoneRed, 3000, 6000, 900, 1100 ):ManageFuel( 0.2, 180 )
--RU_AIBalancer:SetPatrolZone( PatrolZoneR )
--local PatrolZoneR = AI_PATROLZONE:New( PatrolZoneRed, 3000, 6000, 900, 1100 ):ManageFuel( 0.2, 180 )
--RU_AI_Balancer:SetPatrolZone( PatrolZoneR )

View File

@@ -1,6 +1,6 @@
local CargoEngineer = UNIT:FindByName( "Engineer" )
local InfantryCargo = CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local InfantryCargo = AI_CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local CargoCarrier = UNIT:FindByName( "Carrier" )

View File

@@ -1,6 +1,6 @@
local CargoEngineer = UNIT:FindByName( "Engineer" )
local InfantryCargo = CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local InfantryCargo = AI_CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local CargoCarrier = UNIT:FindByName( "Carrier" )

View File

@@ -1,6 +1,6 @@
local CargoEngineer = UNIT:FindByName( "Engineer" )
local InfantryCargo = CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local InfantryCargo = AI_CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local CargoCarrierFrom = UNIT:FindByName( "CarrierFrom" )

View File

@@ -1,11 +1,11 @@
local CargoSet = SET_BASE:New()
CargoSet:Add( "Engineer1", CARGO_UNIT:New( UNIT:FindByName( "Engineer1" ), "Engineers", "Engineer", 81, 2000, 25 ) )
CargoSet:Add( "Engineer2", CARGO_UNIT:New( UNIT:FindByName( "Engineer2" ), "Engineers", "Engineer", 64, 2000, 25 ) )
CargoSet:Add( "Engineer3", CARGO_UNIT:New( UNIT:FindByName( "Engineer3" ), "Engineers", "Engineer", 72, 2000, 25 ) )
CargoSet:Add( "Engineer4", CARGO_UNIT:New( UNIT:FindByName( "Engineer4" ), "Engineers", "Engineer", 69, 2000, 25 ) )
CargoSet:Add( "Engineer1", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer1" ), "Engineers", "Engineer", 81, 2000, 25 ) )
CargoSet:Add( "Engineer2", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer2" ), "Engineers", "Engineer", 64, 2000, 25 ) )
CargoSet:Add( "Engineer3", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer3" ), "Engineers", "Engineer", 72, 2000, 25 ) )
CargoSet:Add( "Engineer4", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer4" ), "Engineers", "Engineer", 69, 2000, 25 ) )
local InfantryCargo = CARGO_GROUPED:New( CargoSet, "Engineers", "Engineers", 2000, 25 )
local InfantryCargo = AI_CARGO_GROUPED:New( CargoSet, "Engineers", "Engineers", 2000, 25 )
local CargoCarrier = UNIT:FindByName( "Carrier" )

View File

@@ -1,11 +1,11 @@
local CargoSet = SET_BASE:New()
CargoSet:Add( "Engineer1", CARGO_UNIT:New( UNIT:FindByName( "Engineer1" ), "Engineers", "Engineer", 81, 2000, 25 ) )
CargoSet:Add( "Engineer2", CARGO_UNIT:New( UNIT:FindByName( "Engineer2" ), "Engineers", "Engineer", 64, 2000, 25 ) )
CargoSet:Add( "Engineer3", CARGO_UNIT:New( UNIT:FindByName( "Engineer3" ), "Engineers", "Engineer", 72, 2000, 25 ) )
CargoSet:Add( "Engineer4", CARGO_UNIT:New( UNIT:FindByName( "Engineer4" ), "Engineers", "Engineer", 69, 2000, 25 ) )
CargoSet:Add( "Engineer1", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer1" ), "Engineers", "Engineer", 81, 2000, 25 ) )
CargoSet:Add( "Engineer2", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer2" ), "Engineers", "Engineer", 64, 2000, 25 ) )
CargoSet:Add( "Engineer3", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer3" ), "Engineers", "Engineer", 72, 2000, 25 ) )
CargoSet:Add( "Engineer4", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer4" ), "Engineers", "Engineer", 69, 2000, 25 ) )
local InfantryCargo = CARGO_GROUPED:New( CargoSet, "Engineers", "Engineers", 2000, 25 )
local InfantryCargo = AI_CARGO_GROUPED:New( CargoSet, "Engineers", "Engineers", 2000, 25 )
local CargoCarrier = UNIT:FindByName( "Carrier" )

View File

@@ -1,11 +1,11 @@
local CargoSet = SET_BASE:New()
CargoSet:Add( "Engineer1", CARGO_UNIT:New( UNIT:FindByName( "Engineer1" ), "Engineers", "Engineer", 81, 2000, 25 ) )
CargoSet:Add( "Engineer2", CARGO_UNIT:New( UNIT:FindByName( "Engineer2" ), "Engineers", "Engineer", 64, 2000, 25 ) )
CargoSet:Add( "Engineer3", CARGO_UNIT:New( UNIT:FindByName( "Engineer3" ), "Engineers", "Engineer", 72, 2000, 25 ) )
CargoSet:Add( "Engineer4", CARGO_UNIT:New( UNIT:FindByName( "Engineer4" ), "Engineers", "Engineer", 69, 2000, 25 ) )
CargoSet:Add( "Engineer1", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer1" ), "Engineers", "Engineer", 81, 2000, 25 ) )
CargoSet:Add( "Engineer2", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer2" ), "Engineers", "Engineer", 64, 2000, 25 ) )
CargoSet:Add( "Engineer3", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer3" ), "Engineers", "Engineer", 72, 2000, 25 ) )
CargoSet:Add( "Engineer4", AI_CARGO_UNIT:New( UNIT:FindByName( "Engineer4" ), "Engineers", "Engineer", 69, 2000, 25 ) )
local InfantryCargo = CARGO_GROUPED:New( CargoSet, "Engineers", "Engineers", 2000, 25 )
local InfantryCargo = AI_CARGO_GROUPED:New( CargoSet, "Engineers", "Engineers", 2000, 25 )
local CargoCarrierFrom = UNIT:FindByName( "CarrierFrom" )

View File

@@ -1,6 +1,6 @@
local DeliveryUnit = UNIT:FindByName( "Delivery" )
local Letter = CARGO_PACKAGE:New( DeliveryUnit, "Letter", "Secret Orders", "0.3", 2000, 25 )
local Letter = AI_CARGO_PACKAGE:New( DeliveryUnit, "Letter", "Secret Orders", "0.3", 2000, 25 )
local CargoCarrier = UNIT:FindByName( "Carrier" )

View File

@@ -1,6 +1,6 @@
local CargoEngineer = UNIT:FindByName( "Engineer" )
local InfantryCargo = CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local InfantryCargo = AI_CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 2000, 25 )
local CargoCarrier = UNIT:FindByName( "Carrier" )

View File

@@ -1,6 +1,6 @@
-- This test mission models the behaviour of the PATROLZONE class.
-- This test mission models the behaviour of the AI_PATROLZONE class.
--
-- It creates a 2 PATROLZONE objects with the name Patrol1 and Patrol2.
-- It creates a 2 AI_PATROLZONE objects with the name Patrol1 and Patrol2.
-- Patrol1 will govern a GROUP object to patrol the zone defined by PatrolZone1, within 3000 meters and 6000 meters, within a speed of 400 and 600 km/h.
-- When the GROUP object that is assigned to Patrol has fuel below 20%, the GROUP object will orbit for 60 secondes, before returning to base.
--
@@ -23,16 +23,16 @@ local PatrolZone2 = ZONE_POLYGON:New( "Patrol Zone 2", PatrolZoneGroup2 )
local PatrolSpawn = SPAWN:New( "Patrol Group" )
local PatrolGroup = PatrolSpawn:Spawn()
local Patrol1 = PATROLZONE:New( PatrolZone1, 3000, 6000, 400, 600 )
local Patrol1 = AI_PATROLZONE:New( PatrolZone1, 3000, 6000, 400, 600 )
Patrol1:ManageFuel( 0.2, 60 )
Patrol1:SetControllable( PatrolGroup )
Patrol1:__Start( 5 )
local Patrol2 = PATROLZONE:New( PatrolZone2, 600, 1000, 300, 400 )
local Patrol2 = AI_PATROLZONE:New( PatrolZone2, 600, 1000, 300, 400 )
Patrol2:ManageFuel( 0.2, 0 )
--- State transition function for the PROCESS\_PATROLZONE **Patrol1** object
-- @param #PATROLZONE self
-- @param #AI_PATROLZONE self
-- @param Wrapper.Group#GROUP AIGroup
-- @return #boolean If false is returned, then the OnAfter state transition function will not be called.
function Patrol1:OnBeforeRTB( AIGroup )
@@ -40,7 +40,7 @@ function Patrol1:OnBeforeRTB( AIGroup )
end
--- State transition function for the PROCESS\_PATROLZONE **Patrol1** object
-- @param Process_PatrolCore.Zone#PATROLZONE self
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
-- @param Wrapper.Group#GROUP AIGroup
function Patrol1:OnAfterRTB( AIGroup )
local NewGroup = PatrolSpawn:Spawn()
@@ -49,14 +49,14 @@ function Patrol1:OnAfterRTB( AIGroup )
end
--- State transition function for the PROCESS\_PATROLZONE **Patrol1** object
-- @param Process_PatrolCore.Zone#PATROLZONE self
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
-- @param Wrapper.Group#GROUP AIGroup
function Patrol1:OnAfterPatrol( AIGroup )
AIGroup:MessageToRed( "Patrolling in zone " .. PatrolZone1:GetName() , 20 )
end
--- State transition function for the PROCESS\_PATROLZONE **Patrol2** object
-- @param #PATROLZONE self
-- @param #AI_PATROLZONE self
-- @param Wrapper.Group#GROUP AIGroup
-- @return #boolean If false is returned, then the OnAfter state transition function will not be called.
function Patrol2:OnBeforeRTB( AIGroup )
@@ -64,7 +64,7 @@ function Patrol2:OnBeforeRTB( AIGroup )
end
--- State transition function for the PROCESS\_PATROLZONE **Patrol2** object
-- @param Process_PatrolCore.Zone#PATROLZONE self
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
-- @param Wrapper.Group#GROUP AIGroup
function Patrol2:OnAfterRTB( AIGroup )
local NewGroup = PatrolSpawn:Spawn()
@@ -73,7 +73,7 @@ function Patrol2:OnAfterRTB( AIGroup )
end
--- State transition function for the PROCESS\_PATROLZONE **Patrol2** object
-- @param Process_PatrolCore.Zone#PATROLZONE self
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
-- @param Wrapper.Group#GROUP AIGroup
function Patrol2:OnAfterPatrol( AIGroup )
AIGroup:MessageToRed( "Patrolling in zone " .. PatrolZone2:GetName() , 20 )

View File

@@ -1,4 +1,12 @@
--- Task Modelling - SEAD
--
-- ===
--
-- Author: FlightControl
-- Date Created: 15 Dec 2016
--
-- # Situation
--
-- This test mission is a test bed for the TASKING framework.
-- It creates an head quarters (HQ), which contains one mission with one task to be accomplished.
-- When the pilot joins the plane, it will need to accept the task using the HQ menu.
@@ -7,6 +15,56 @@
-- A smoking system is available that the pilot can use the acquire targets.
-- Once all targets are elimitated, the task is finished, and the mission is set to complete.
-- If the pilot crashes during flying, the task will fail, and the mission is set to failed.
--
-- Uses the Tracing functions from BASE within the DCS.log file. Check the DCS.log file for the results.
-- Create a new SCHEDULER object.
-- Check the DCS.log.
--
-- # Test cases:
--
-- There should only be one Task listed under Others Menu -> HQ -> SEAD Targets -> SEAD. This is the TaskSEAD2, that is copied from TaskSEAD.
-- TaskSEAD is removed from the mission once TaskSEAD2 is created.
--
-- ## Run this mission in DCS Single Player:
--
-- * Once started, a slot.
-- * When in the plane, join the SEAD task through the Others Menu -> HQ -> SEAD Targets -> SEAD -> SEAD Radars Vector 2.
-- * When flying, watch the messages appear. It should say that you've been assigned to the task, and that you need to route your plane to a coordinate.
-- * Exit your plane by pressing ESC, and go back to the spectators. When in single player mode, just click on Back, and then click Spectators.
-- * Immediately rejoin a Slot, select an other plane.
-- * When in the plane, you should now not be able to join the Task. No menu options are given. That is because the Task is "Aborted".
-- * However, the aborted task is replanned within 30 seconds. As such, go back to spectators, and after 30 seconds, rejoin a slot in a plane.
-- * When in the plane, you should not be able to join the Task through the Others Menu -> HQ -> SEAD Targets -> SEAD -> SEAD Radars Vector 2.
-- * Once accepted, watch the messages appear. Route to the attach zone, following the coordinates.
-- * Once at the attack zone, you'll see a message how many targets are left to be destroyed. Attack the radar emitting SAM with a kh-25.
-- * When you HIT the SAM, you'll see a scoring message appear. One point is granted.
-- * Maybe you've fired two missiles, so, you'll see another HIT maybe on the SAM, again granting a point.
-- * When the SAM is DEAD (it may take a while), you'll see a scoring message that 10 points have been granted.
-- * You'll see a scoring message appear that grants 25 points because you've hit a target of the Task. (This was programmed below).
-- * You'll see a scoring message appear that grants 250 points because all Task targets have been elimitated. (This was also programmed below).
-- * You'll see a message appear that you have Task success. The Task will be flagged as 'Success', and cannot be joined anymore.
-- * You'll see a message appear that the Mission "SEAD Targets" has been "Completed".
--
-- ## Run this mission in DCS Multiple Player, with one player:
--
-- * Retry the above scenario, but now running this scenario on a multi player server, while connecting with one player to the mission. Watch the consistency of the messages.
--
-- ## Run this mission in DCS Multiple Player, with two to three players simultaneously:
--
-- * Retry the above scenario running this scenario on a multi player server, while connecting with two or three players to the mission. Watch the consistency of the messages.
-- * When the first player has accepted the Task, the 2nd and 3rd player joining the Task, will be automatically assigned to the Task.
--
-- ## Others things to watch out for:
--
-- * When flying to the attack zone, a message should appear every 30 seconds with the coordinates.
-- * When in the attack zone, a message should appear every 30 seconds how many targes are left within the task.
-- * When a player aborts the task, a message is displayed of the player aborting, but only to the group assigned to execute the task.
-- * When a player joins the task, a message is displayed of the player joining, but only to the group assigned to execute the task.
-- * When a player crashes into the ground, a message is displayed of that event.
-- * In multi player, when the Task was assigned to the group, but all players in that group aborted the Task, the Task should become Aborted. It will be replanned in 30 seconds.
--
-- # Status: TESTING - 15 Dec 2016
-- Create the HQ object.
local HQ = COMMANDCENTER:New( GROUP:FindByName( "HQ" ) )
@@ -41,18 +99,18 @@ local TargetSet = SET_UNIT:New():FilterPrefixes( "US Hawk SR" ):FilterOnce()
-- Define the zone to where the pilot needs to navigate.
local TargetZone = ZONE:New( "Target Zone" )
-- MOOSE contains a TASK_BASE class. Use the TASK class to define a new Task object and attach it to a Mission object.
-- MOOSE contains a TASK class. Use the TASK class to define a new Task object and attach it to a Mission object.
-- Here we define a new TaskSEAD object, and attach it to the Mission object.
-- ( The TASK_BASE class is the base class for ALL derived Task templates.
-- ( The TASK class is the base class for ALL derived Task templates.
-- Task templates are TASK classes that quickly setup a Task scenario with given parameters. )
--
-- The TASK_BASE class is thus the primary task, and a task scenario will need to be provided to the TaskSEAD of the states and events that form the task.
-- TASK_BASE gets a couple of parameters:
-- The TASK class is thus the primary task, and a task scenario will need to be provided to the TaskSEAD of the states and events that form the task.
-- TASK gets a couple of parameters:
-- 1. The Mission for which the Task needs to be achieved.
-- 2. The set of groups of planes that pilots can join.
-- 3. The name of the Task... This can be any name, and will be provided when the Pilot joins the task.
-- 4. A type of the Task. When Tasks are in state Planned, then a menu can be provided that group the task based on this given type.
local TaskSEAD = TASK_BASE:New( Mission, SEADSet, "SEAD Radars Vector 1", "SEAD" ) -- Tasking.Task#TASK_BASE
local SEADTask = TASK:New( Mission, SEADSet, "SEAD Radars Vector 1", "SEAD" ) -- Tasking.Task#TASK
-- This is now an important part of the Task process definition.
-- Each TASK contains a "Process Template".
@@ -64,23 +122,23 @@ local TaskSEAD = TASK_BASE:New( Mission, SEADSet, "SEAD Radars Vector 1", "SEAD"
-- The reason why this is done, is that each unit as a role within the Task, and can have different status.
-- Therefore, the FsmSEAD is a TEMPLATE PROCESS of the TASK, and must be designed as a UNIT with a player is executing that PROCESS.
local FsmSEADTemplate = TaskSEAD:GetFsmTemplate()
local SEADProcess = SEADTask:GetUnitProcess()
-- Adding a new sub-process to the Task Template.
-- At first, the task needs to be accepted by a pilot.
-- We use for this the SUB-PROCESS FSM_ASSIGN_ACCEPT.
-- We use for this the SUB-PROCESS ACT_ASSIGN_ACCEPT.
-- The method on the FsmSEAD AddProcess accepts the following parameters:
-- 1. State From "Planned". When the Fsm is in state "Planned", allow the event "Accept".
-- 2. Event "Accept". This event can be triggered through FsmSEAD:Accept() or FsmSEAD:__Accept( 1 ). See documentation on state machines.
-- 3. The PROCESS derived class. In this case, we use the FSM_ASSIGN_ACCEPT to accept the task and provide a briefing. So, when the event "Accept" is fired, this process is executed.
-- 4. A table with the "return" states of the FSM_ASSIGN_ACCEPT process. This table indicates that for a certain return state, a further event needs to be called.
-- 3. The PROCESS derived class. In this case, we use the ACT_ASSIGN_ACCEPT to accept the task and provide a briefing. So, when the event "Accept" is fired, this process is executed.
-- 4. A table with the "return" states of the ACT_ASSIGN_ACCEPT process. This table indicates that for a certain return state, a further event needs to be called.
-- 4.1 When the return state is Assigned, fire the event in the Task FsmSEAD:Route()
-- 4.2 When the return state is Rejected, fire the event in the Task FsmSEAD:Eject()
-- All other AddProcess calls are working in a similar manner.
FsmSEADTemplate:AddProcess ( "Planned", "Accept", FSM_ASSIGN_ACCEPT:New( "SEAD the Area" ), { Assigned = "Route", Rejected = "Eject" } )
SEADProcess:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( "SEAD the Area" ), { Assigned = "Route", Rejected = "Eject" } )
-- Same, adding a process.
FsmSEADTemplate:AddProcess ( "Assigned", "Route", FSM_ROUTE_ZONE:New( TargetZone ), { Arrived = "Update" } )
SEADProcess:AddProcess ( "Assigned", "Route", ACT_ROUTE_ZONE:New( TargetZone ), { Arrived = "Update" } )
-- Adding a new Action...
-- Actions define also the flow of the Task, but the actions will need to be programmed within your script.
@@ -89,59 +147,48 @@ FsmSEADTemplate:AddProcess ( "Assigned", "Route", FSM_ROUTE_ZONE:New( Ta
-- 1. State From "Rejected". When the FsmSEAD is in state "Rejected", the event "Eject" can be fired.
-- 2. Event "Eject". This event can be triggered synchronously through FsmSEAD:Eject() or asynchronously through FsmSEAD:__Eject(secs).
-- 3. State To "Planned". After the event has been fired, the FsmSEAD will transition to Planned.
FsmSEADTemplate:AddTransition ( "Rejected", "Eject", "Planned" )
FsmSEADTemplate:AddTransition ( "Arrived", "Update", "Updated" )
FsmSEADTemplate:AddProcess ( "Updated", "Account", FSM_ACCOUNT_DEADS:New( TargetSet, "SEAD" ), { Accounted = "Success" } )
FsmSEADTemplate:AddProcess ( "Updated", "Smoke", FSM_SMOKE_TARGETS_ZONE:New( TargetSet, TargetZone ) )
FsmSEADTemplate:AddTransition ( "Accounted", "Success", "Success" )
FsmSEADTemplate:AddTransition ( "*", "Fail", "Failed" )
SEADProcess:AddTransition ( "Rejected", "Eject", "Planned" )
SEADProcess:AddTransition ( "Arrived", "Update", "Updated" )
SEADProcess:AddProcess ( "Updated", "Account", ACT_ACCOUNT_DEADS:New( TargetSet, "SEAD" ), { Accounted = "Success" } )
SEADProcess:AddProcess ( "Updated", "Smoke", ACT_ASSIST_SMOKE_TARGETS_ZONE:New( TargetSet, TargetZone ) )
SEADProcess:AddTransition ( "Accounted", "Success", "Success" )
SEADProcess:AddTransition ( "*", "Fail", "Failed" )
FsmSEADTemplate:AddScoreProcess( "Updated", "Account", "Account", "destroyed a radar", 25 )
FsmSEADTemplate:AddScoreProcess( "Updated", "Account", "Failed", "failed to destroy a radar", -10 )
SEADProcess:AddScoreProcess( "Updated", "Account", "Account", "destroyed a radar", 25 )
SEADProcess:AddScoreProcess( "Updated", "Account", "Failed", "failed to destroy a radar", -10 )
-- Now we will set the SCORING. Scoring is set using the TaskSEAD object.
-- Scores can be set on the status of the Task, and on Process level.
FsmSEADTemplate:AddScore( "Success", "Destroyed all target radars", 250 )
FsmSEADTemplate:AddScore( "Failed", "Failed to destroy all target radars", -100 )
SEADProcess:AddScore( "Success", "Destroyed all target radars", 250 )
SEADProcess:AddScore( "Failed", "Failed to destroy all target radars", -100 )
--local TestTask = TASK_BASE:New( Mission, SEADSet, "TEST TASK", "TEST" )
--TestTask:E("Clean TestTask")
--TestTask = nil
--collectgarbage()
--
--local TestUnit = GROUP:FindByName( "HQ" ):GetUnit(1)
--
--local fsm = FSM_PROCESS:New( TestUnit, TaskSEAD )
--
--fsm:AddProcess("test","test",FSM_ACCOUNT_DEADS:New( TargetSet, "SEAD" ))
--
----Mission:AddTask(fsm)
--
--fsm:E("CLEAN fsm")
--fsm = nil
--collectgarbage()
--
--
--TaskSEAD:E("CLEAN TASK")
--TaskSEAD = nil
--collectgarbage()
function FsmSEADTemplate:onenterUpdated( TaskUnit )
function SEADProcess:onenterUpdated( TaskUnit )
self:E( { self } )
self:Account()
self:Smoke()
end
-- Here we handle the PlayerAborted event, which is fired when a Player leaves the unit while being assigned to the Task.
-- Within the event handler, which is passed the PlayerUnit and PlayerName parameter,
-- we check if the SEADTask has still AlivePlayers assigned to the Task.
-- If not, the Task will Abort.
-- And it will be Replanned within 30 seconds.
function SEADTask:OnAfterPlayerCrashed( PlayerUnit, PlayerName )
if not SEADTask:HasAliveUnits() then
SEADTask:__Abort()
SEADTask:__Replan( 30 )
end
end
local TaskSEAD2 = TASK_BASE:New( Mission, SEADSet, "SEAD Radars Vector 2", "SEAD" ) -- Tasking.Task#TASK_BASE
TaskSEAD2:SetFsmTemplate( TaskSEAD:GetFsmTemplate():Copy() )
local TaskSEAD2 = TASK:New( Mission, SEADSet, "SEAD Radars Vector 2", "SEAD" ) -- Tasking.Task#TASK
TaskSEAD2:SetUnitProcess( SEADTask:GetUnitProcess():Copy() )
Mission:AddTask( TaskSEAD2 )
Mission:RemoveTask(TaskSEAD)
Mission:RemoveTask( SEADTask )
TaskSEAD = nil
FsmSEADTemplate = nil
SEADTask = nil
SEADProcess = nil
HQ:SetMenu()
collectgarbage()

View File

@@ -25,11 +25,11 @@ do
Cargo_Pickup_Zone_2 = CARGO_ZONE:New( 'Pickup Zone 2', 'DE Communication Center 2' ):RedSmoke()
for CargoItem = 1, 2 do
CargoTable[CargoItem] = CARGO_GROUP:New( 'Engineers', 'Team ' .. EngineerNames[CargoItem], math.random( 70, 100 ) * 3, 'DE Infantry', Cargo_Pickup_Zone_1 )
CargoTable[CargoItem] = AI_CARGO_GROUP:New( 'Engineers', 'Team ' .. EngineerNames[CargoItem], math.random( 70, 100 ) * 3, 'DE Infantry', Cargo_Pickup_Zone_1 )
end
for CargoItem = 3, 5 do
CargoTable[CargoItem] = CARGO_GROUP:New( 'Engineers', 'Team ' .. EngineerNames[CargoItem], math.random( 70, 100 ) * 3, 'DE Infantry', Cargo_Pickup_Zone_2 )
CargoTable[CargoItem] = AI_CARGO_GROUP:New( 'Engineers', 'Team ' .. EngineerNames[CargoItem], math.random( 70, 100 ) * 3, 'DE Infantry', Cargo_Pickup_Zone_2 )
end
--Cargo_Package = CARGO_INVISIBLE:New( 'Letter', 0.1, 'DE Secret Agent', 'Pickup Zone Package' )
@@ -68,7 +68,7 @@ do
Package_Pickup_Zone = CARGO_ZONE:New( 'Package Pickup Zone', 'DE Guard' ):GreenSmoke()
Cargo_Package = CARGO_PACKAGE:New( 'Letter', 'Letter to Command', 0.1, Client_Package_1 )
Cargo_Package = AI_CARGO_PACKAGE:New( 'Letter', 'Letter to Command', 0.1, Client_Package_1 )
--Cargo_Goods = CARGO_STATIC:New( 'Goods', 20, 'Goods', 'Pickup Zone Goods', 'DE Collection Point' )
--Cargo_SlingLoad = CARGO_SLING:New( 'Basket', 40, 'Basket', 'Pickup Zone Sling Load', 'DE Cargo Guard' )

Some files were not shown because too many files have changed in this diff Show More