diff --git a/Embedded/Moose_Create_Embedded.bat b/Embedded/Moose_Create_Embedded.bat
new file mode 100644
index 000000000..0d28173c2
--- /dev/null
+++ b/Embedded/Moose_Create_Embedded.bat
@@ -0,0 +1,31 @@
+rem Generate Moose_Embedded.lua
+
+copy /b ..\Moose\Trace.lua ^
+ + ..\Moose\Routines.lua ^
+ + ..\Moose\Base.lua ^
+ + ..\Moose\Menu.lua ^
+ + ..\Moose\Group.lua ^
+ + ..\Moose\Unit.lua ^
+ + ..\Moose\Zone.lua ^
+ + ..\Moose\Database.lua ^
+ + ..\Moose\Cargo.lua ^
+ + ..\Moose\Client.lua ^
+ + ..\Moose\Message.lua ^
+ + ..\Moose\Stage.lua ^
+ + ..\Moose\Task.lua ^
+ + ..\Moose\GoHomeTask.lua ^
+ + ..\Moose\DestroyBaseTask.lua ^
+ + ..\Moose\DestroyGroupsTask.lua ^
+ + ..\Moose\DestroyRadarsTask.lua ^
+ + ..\Moose\DestroyUnitTypesTask.lua ^
+ + ..\Moose\PickupTask.lua ^
+ + ..\Moose\DeployTask.lua ^
+ + ..\Moose\NoTask.lua ^
+ + ..\Moose\RouteTask.lua ^
+ + ..\Moose\Mission.lua ^
+ + ..\Moose\CleanUp.lua ^
+ + ..\Moose\Spawn.lua ^
+ + ..\Moose\Movement.lua ^
+ + ..\Moose\Sead.lua ^
+ Moose_Embedded.lua /y
+
\ No newline at end of file
diff --git a/Moose/Moose_Embedded.lua b/Embedded/Moose_Embedded.lua
similarity index 99%
rename from Moose/Moose_Embedded.lua
rename to Embedded/Moose_Embedded.lua
index 1a27b1b0c..2e0e0ecd1 100644
--- a/Moose/Moose_Embedded.lua
+++ b/Embedded/Moose_Embedded.lua
@@ -3573,6 +3573,19 @@ function UNIT:IsAlive()
end
+function UNIT:GetDCSUnit()
+ self:T( self.DCSUnit )
+
+ return self.DCSUnit
+end
+
+function UNIT:GetID()
+ self:T( self.UnitID )
+
+ return self.UnitID
+end
+
+
function UNIT:GetName()
self:T( self.UnitName )
diff --git a/MissionScripting/MissionScripting.lua b/MissionScripting/MissionScripting.lua
index 08a1e8e73..993b711a4 100644
--- a/MissionScripting/MissionScripting.lua
+++ b/MissionScripting/MissionScripting.lua
@@ -4,7 +4,7 @@ dofile('Scripts/ScriptingSystem.lua')
Include = {}
-Include.LoadPath = 'Scripts/MOOSE/MOOSE'
+Include.LoadPath = 'Scripts/MOOSE'
Include.Files = {}
Include.File = function( IncludeFile )
@@ -15,13 +15,11 @@ Include.File = function( IncludeFile )
end
end
-Include.File( "Trace" )
-Include.File( "Routines" )
Include.File( "Database" )
-Include.File( "StatHandler" )
+--Include.File( "StatHandler" )
--Sanitize Mission Scripting environment
---This makes unavailable some unsecure functions.
+--This makes unavailable some unsecure functions.
--Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions.
--You can remove the code below and make availble these functions at your own risk.
@@ -36,4 +34,4 @@ do
sanitizeModule('lfs')
require = nil
loadlib = nil
-end
+end
\ No newline at end of file
diff --git a/Moose/Client.lua b/Moose/Client.lua
index 3da8dbbc5..8332dc994 100644
--- a/Moose/Client.lua
+++ b/Moose/Client.lua
@@ -42,7 +42,6 @@ CLIENT = {
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() )
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() )
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
-
function CLIENT:New( ClientName, ClientBriefing )
local self = BASE:Inherit( self, BASE:New() )
self:T()
diff --git a/Moose/DeployTask.lua b/Moose/DeployTask.lua
index 612f1f6ad..811e086eb 100644
--- a/Moose/DeployTask.lua
+++ b/Moose/DeployTask.lua
@@ -3,6 +3,9 @@
Include.File( "Task" )
+--- A DeployTask
+-- @type DEPLOYTASK
+--
DEPLOYTASK = {
ClassName = "DEPLOYTASK",
TEXT = { "Deploy", "deployed", "unloaded" },
@@ -11,8 +14,9 @@ DEPLOYTASK = {
--- Creates a new DEPLOYTASK object, which models the sequence of STAGEs to unload a cargo.
--- @tparam table{string,...}|string LandingZones Table or name of the zone(s) where Cargo is to be unloaded.
--- @tparam CARGO_TYPE CargoType Type of the Cargo.
+-- @function [parent=#DEPLOYTASK] New
+-- @param #string CargoType Type of the Cargo.
+-- @return #DEPLOYTASK The created DeployTask
function DEPLOYTASK:New( CargoType )
local self = BASE:Inherit( self, TASK:New() )
self:T()
diff --git a/Moose/Group.lua b/Moose/Group.lua
index 13859aa4f..4fecbb528 100644
--- a/Moose/Group.lua
+++ b/Moose/Group.lua
@@ -1,17 +1,20 @@
--- GROUP Classes
--- @classmod GROUP
+-- @module GROUP
+-- @return #GROUP
Include.File( "Routines" )
Include.File( "Base" )
Include.File( "Message" )
Include.File( "Unit" )
-GROUPS = {}
-
-
+--- The GROUP class
+-- @type GROUP
+-- @field ClassName The name of the class.
GROUP = {
- ClassName="GROUP",
+ ClassName = "GROUP",
}
+
+GROUPS = {}
function GROUP:New( DCSGroup )
local self = BASE:Inherit( self, BASE:New() )
diff --git a/Moose/MissionScripting.lua b/Moose/MissionScripting.lua
deleted file mode 100644
index 993b711a4..000000000
--- a/Moose/MissionScripting.lua
+++ /dev/null
@@ -1,37 +0,0 @@
---Initialization script for the Mission lua Environment (SSE)
-
-dofile('Scripts/ScriptingSystem.lua')
-
-Include = {}
-
-Include.LoadPath = 'Scripts/MOOSE'
-Include.Files = {}
-
-Include.File = function( IncludeFile )
- if not Include.Files[ IncludeFile ] then
- Include.Files[IncludeFile] = IncludeFile
- dofile( Include.LoadPath .. "/" .. IncludeFile .. ".lua" )
- env.info( "Include:" .. IncludeFile .. " loaded." )
- end
-end
-
-Include.File( "Database" )
---Include.File( "StatHandler" )
-
---Sanitize Mission Scripting environment
---This makes unavailable some unsecure functions.
---Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions.
---You can remove the code below and make availble these functions at your own risk.
-
-local function sanitizeModule(name)
- _G[name] = nil
- package.loaded[name] = nil
-end
-
-do
- --sanitizeModule('os')
- --sanitizeModule('io')
- sanitizeModule('lfs')
- require = nil
- loadlib = nil
-end
\ No newline at end of file
diff --git a/Moose/Moose_Create_Embedded.bat b/Moose/Moose_Create_Embedded.bat
deleted file mode 100644
index 6eda4668f..000000000
--- a/Moose/Moose_Create_Embedded.bat
+++ /dev/null
@@ -1,31 +0,0 @@
-rem Generate Moose_Embedded.lua
-
-copy /b Trace.lua ^
- + Routines.lua ^
- + Base.lua ^
- + Menu.lua ^
- + Group.lua ^
- + Unit.lua ^
- + Zone.lua ^
- + Database.lua ^
- + Cargo.lua ^
- + Client.lua ^
- + Message.lua ^
- + Stage.lua ^
- + Task.lua ^
- + GoHomeTask.lua ^
- + DestroyBaseTask.lua ^
- + DestroyGroupsTask.lua ^
- + DestroyRadarsTask.lua ^
- + DestroyUnitTypesTask.lua ^
- + PickupTask.lua ^
- + DeployTask.lua ^
- + NoTask.lua ^
- + RouteTask.lua ^
- + Mission.lua ^
- + CleanUp.lua ^
- + Spawn.lua ^
- + Movement.lua ^
- + Sead.lua ^
- Moose_Embedded.lua /y
-
\ No newline at end of file
diff --git a/Moose/Spawn.lua b/Moose/Spawn.lua
index f991500d9..b3a238e1d 100644
--- a/Moose/Spawn.lua
+++ b/Moose/Spawn.lua
@@ -1,8 +1,43 @@
---- Dynamic spawning of Groups and Units.
--- @classmod SPAWN
--- @author Flightcontrol
+--- Dynamic spawning of groups and units.
+-- SPAWN: The SPAWN module allows to spawn dynamically new groups, based on pre-defined initialization settings.
+-- =============================================================================================================
+-- Spawned groups will follow the following naming convention when instantiated within the DCS World run-time environment:
+--
+-- 1. Groups will have the name SpawnTemplatePrefix#ggg, where ggg is a counter from 0 to 999 for each new spawned Group.
+-- 2. Units will have the name SpawnTemplatePrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned Unit belonging to that Group.
+--
+-- Some additional notes that need to remember:
+--
+-- * Templates are actually groups defined within the mission editor, with the flag "Late Activation" set. As such, these groups are never used within the mission, but are used by the @{#SPAWN} module.
+-- * It is important to defined BEFORE you spawn new groups, a proper initialization of the SPAWN instance is done with the options you want to use.
+-- * When designing a mission, NEVER name groups using a "#" within the name of the group Template(s), or the SPAWN module logic won't work anymore.
+--
+-- 1. Construction:
+-- ----------------
+-- Create a new @{SPAWN object with the @{#SPAWN.New} and the @{#SPAWN.NewWithAlias} methods.
+--
+-- 2. Initialization of the SPAWN object.
+-- ------------------
+-- A SPAWN instance will behave differently based on the usage of initialization methods:
+--
+-- * Limit the amount of groups that can be alive at the same time and that can be dynamically spawned using the @{#SPAWN.Limit} method.
+-- * Spawned groups can get their routes randomized using the @{#SPAWN.RandomizeRoute} method.
+-- * Using the @{#SPAWN.RandomizeTemplate}, random group templates can be defined so that when a new group is spawned, the group template is selected from one of the templates defined.
+-- * Spawing of groups can be scheduled at defined but randomized intervals. Use the @{#SPAWN.Scheduled} method to schedule spawning of groups.
+--
+-- 2. Instantiation
+-- ------------------------------
+--
+-- @module SPAWN
+-- @author FlightControl
-MOOSE_Version = "0.1.1.1"
+
+---
+-- @type SPAWN
+-- @field ClassName Contains SPAWN
+SPAWN = {
+ ClassName = "SPAWN",
+}
Include.File( "Routines" )
Include.File( "Base" )
@@ -11,22 +46,16 @@ Include.File( "Group" )
Include.File( "Zone" )
-SPAWN = {
- ClassName = "SPAWN",
-}
---- Public
--- @section Public
---- Creates the main object to spawn a Group defined in the DCS ME.
--- Spawned Groups and Units will follow the following naming convention within the DCS World run-time environment:
--- Groups will have the name SpawnTemplatePrefix#ggg, where ggg is a counter from 0 to 999 for each new spawned Group.
--- Units will have the name SpawnTemplatePrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned Unit belonging to that Group.
--- @tparam string SpawnTemplatePrefix is the name of the Group in the ME that defines the Template. That Group must have the flag "Late Activation" set. Note that this SpawnTemplatePrefix name should not contain any # character.
--- @treturn SPAWN
+--- Creates the main object to spawn a GROUP defined in the DCS ME.
+-- @param self
+-- @param #string SpawnTemplatePrefix is the name of the Group in the ME that defines the Template. Each new group will have the name starting with SpawnTemplatePrefix.
+-- @return #SPAWN
-- @usage
-- -- NATO helicopters engaging in the battle field.
-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' )
+-- @usage local Plane = SPAWN:New( "Plane" ) -- Creates a new local variable that can initiate new planes with the name "Plane#ddd" using the template "Plane" as defined within the ME.
function SPAWN:New( SpawnTemplatePrefix )
local self = BASE:Inherit( self, BASE:New() )
self:T( { SpawnTemplatePrefix } )
@@ -41,7 +70,7 @@ function SPAWN:New( SpawnTemplatePrefix )
self.SpawnTemplate = self._GetTemplate( self, SpawnTemplatePrefix ) -- Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!!
self.SpawnRepeat = false -- Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.
self.UnControlled = false -- When working in UnControlled mode, all planes are Spawned in UnControlled mode before the scheduler starts.
- self.SpawnMaxGroupsAlive = 0 -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
+ self.SpawnMaxUnitsAlive = 0 -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
self.SpawnMaxGroups = 0 -- The maximum amount of groups that can be spawned.
self.SpawnRandomize = false -- Sets the randomization flag of new Spawned units to false.
self.SpawnVisible = false -- Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.
@@ -60,15 +89,15 @@ function SPAWN:New( SpawnTemplatePrefix )
return self
end
---- Creates the main object to spawn a Group defined in the DCS ME.
--- Spawned Groups and Units will follow the following naming convention within the DCS World run-time environment:
--- Groups will have the name SpawnTemplatePrefix#ggg, where ggg is a counter from 0 to 999 for each new spawned Group.
--- Units will have the name SpawnTemplatePrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned Unit belonging to that Group.
--- @tparam string SpawnTemplatePrefix is the name of the Group in the ME that defines the Template. That Group must have the flag "Late Activation" set. Note that this SpawnTemplatePrefix name should not contain any # character.
--- @treturn SPAWN
+--- Creates a new SPAWN instance to create new groups based on the defined template and using a new alias for each new group.
+-- @param self
+-- @param #string SpawnTemplatePrefix is the name of the Group in the ME that defines the Template.
+-- @param #string SpawnAliasPrefix is the name that will be given to the Group at runtime.
+-- @return #SPAWN
-- @usage
-- -- NATO helicopters engaging in the battle field.
--- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' )
+-- Spawn_BE_KA50 = SPAWN:NewWithAlias( 'BE KA-50@RAMP-Ground Defense', 'Helicopter Attacking a City' )
+-- @usage local PlaneWithAlias = SPAWN:NewWithAlias( "Plane", "Bomber" ) -- Creates a new local variable that can instantiate new planes with the name "Bomber#ddd" using the template "Plane" as defined within the ME.
function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
local self = BASE:Inherit( self, BASE:New() )
self:T( { SpawnTemplatePrefix, SpawnAliasPrefix } )
@@ -84,7 +113,7 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
self.SpawnTemplate = self._GetTemplate( self, SpawnTemplatePrefix ) -- Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!!
self.SpawnRepeat = false -- Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.
self.UnControlled = false -- When working in UnControlled mode, all planes are Spawned in UnControlled mode before the scheduler starts.
- self.SpawnMaxGroupsAlive = 0 -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
+ self.SpawnMaxUnitsAlive = 0 -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
self.SpawnMaxGroups = 0 -- The maximum amount of groups that can be spawned.
self.SpawnRandomize = false -- Sets the randomization flag of new Spawned units to false.
self.SpawnVisible = false -- Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.
@@ -104,10 +133,25 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
end
-function SPAWN:Limit( SpawnMaxGroupsAlive, SpawnMaxGroups )
- self:T( { self.SpawnTemplatePrefix, SpawnMaxGroupsAlive, SpawnMaxGroups } )
+--- Limits the Maximum amount of Units that can be alive at the same time, and the maximum amount of groups that can be spawned.
+-- Note that this method is exceptionally important to balance the performance of the mission. Depending on the machine etc, a mission can only process a maximum amount of units.
+-- If the time interval must be short, but there should not be more Units or Groups alive than a maximum amount of units, then this function should be used...
+-- When a @{#SPAWN.New} is executed and the limit of the amount of units alive is reached, then no new spawn will happen of the group, until some of these units of the spawn object will be destroyed.
+-- @param self
+-- @param #number SpawnMaxUnitsAlive The maximum amount of units that can be alive at runtime.
+-- @param #number SpawnMaxGroups The maximum amount of groups that can be spawned. When the limit is reached, then no more actual spawns will happen of the group.
+-- This parameter is useful to define a maximum amount of airplanes, ground troops, helicopters, ships etc within a supply area.
+-- This parameter accepts the value 0, which defines that there are no maximum group limits, but there are limits on the maximum of units that can be alive at the same time.
+-- @return #SPAWN self
+-- @usage
+-- -- NATO helicopters engaging in the battle field.
+-- -- This helicopter group consists of one Unit. So, this group will SPAWN maximum 2 groups simultaneously within the DCSRTE.
+-- -- There will be maximum 24 groups spawned during the whole mission lifetime.
+-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Limit( 2, 24 )
+function SPAWN:Limit( SpawnMaxUnitsAlive, SpawnMaxGroups )
+ self:T( { self.SpawnTemplatePrefix, SpawnMaxUnitsAlive, SpawnMaxGroups } )
- self.SpawnMaxGroupsAlive = SpawnMaxGroupsAlive -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
+ self.SpawnMaxUnitsAlive = SpawnMaxUnitsAlive -- The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.
self.SpawnMaxGroups = SpawnMaxGroups -- The maximum amount of groups that can be spawned.
for SpawnGroupID = 1, self.SpawnMaxGroups do
@@ -118,18 +162,20 @@ function SPAWN:Limit( SpawnMaxGroupsAlive, SpawnMaxGroups )
end
---- Randomizes a defined route of the Template Group in the ME when the Group is Spawned. This is very useful to define extra variation in the DCS World run-time environment of the behaviour of Groups like Ground Units, Ships, Planes, Helicopters.
--- @tparam number SpawnStartPoint is the waypoint where the randomization begins. Note that the StartPoint = 0 equals the point where the Group is Spawned. This parameter is useful to avoid randomization to start from the first waypoint, but a bit further down the route...
--- @tparam number SpawnEndPoint is the waypoint where the randomization ends. this parameter is useful to avoid randomization to end at a waypoint earlier than the last waypoint on the route.
--- @tparam number SpawnRadius is the radius in meters, that defines the concentric circle in which the randomization of the new waypoint will take place, with the original waypoint located in the middle...
--- @treturn SPAWN
+--- Randomizes the defined route of the SpawnTemplatePrefix group in the ME. This is very useful to define extra variation of the behaviour of groups.
+-- @param self
+-- @param #number SpawnStartPoint is the waypoint where the randomization begins.
+-- Note that the StartPoint = 0 equaling the point where the group is spawned.
+-- @param #number SpawnEndPoint is the waypoint where the randomization ends counting backwards.
+-- This parameter is useful to avoid randomization to end at a waypoint earlier than the last waypoint on the route.
+-- @param #number SpawnRadius is the radius in meters in which the randomization of the new waypoints, with the original waypoint of the original template located in the middle ...
+-- @return #SPAWN
-- @usage
-- -- NATO helicopters engaging in the battle field.
--- -- The KA-50 has waypoints SP, 1, 2, 3, 4, DP.
--- -- Waypoints 2 and 3 will only be randomized. The others will remain on their original position with each new ${SPAWN} of the helicopter.
--- -- The randomization of waypoint 2 and 3 will take place within a diameter of 4000 meters.
+-- -- The KA-50 has waypoints Start point ( =0 or SP ), 1, 2, 3, 4, End point (= 5 or DP).
+-- -- Waypoints 2 and 3 will only be randomized. The others will remain on their original position with each new spawn of the helicopter.
+-- -- The randomization of waypoint 2 and 3 will take place within a radius of 2000 meters.
-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):RandomizeRoute( 2, 2, 2000 )
-
function SPAWN:RandomizeRoute( SpawnStartPoint, SpawnEndPoint, SpawnRadius )
self:T( { self.SpawnTemplatePrefix, SpawnStartPoint, SpawnEndPoint, SpawnRadius } )
@@ -145,6 +191,10 @@ function SPAWN:RandomizeRoute( SpawnStartPoint, SpawnEndPoint, SpawnRadius )
return self
end
+--- Internal function randomizing the routes.
+-- @param self
+-- @param #number SpawnIndex The index of the group to be spawned.
+-- @return #SPAWN
function SPAWN:_RandomizeRoute( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnRandomizeRoute, self.SpawnRandomizeRouteStartPoint, self.SpawnRandomizeRouteEndPoint, self.SpawnRandomizeRouteRadius } )
@@ -165,24 +215,25 @@ function SPAWN:_RandomizeRoute( SpawnIndex )
return self
end
---- This function is rather complicated to understand. But I'll try to explain...
--- This function becomes useful when you need to SPAWN random types of Groups defined within the ME, but they all need to follow the same Template route and have the same SpawnTemplatePrefix name, then this method becomes very useful.
--- @tparam table{string,...} SpawnTemplatePrefixTable is a table with the names of the Groups defined within the ME (with late activatio on), from which on a new SPAWN of SpawnTemplatePrefix (the main Group name), a NEW Group will be choosen as the Group to be SPAWNed.
--- In other words, this method randomizes between a defined set of Groups the Group to be SPAWNed for each new SPAWN.
--- @treturn SPAWN
+--- This function is rather complicated to understand. But I'll try to explain.
+-- This function becomes useful when you need to spawn groups with random templates of groups defined within the mission editor,
+-- but they will all follow the same Template route and have the same prefix name.
+-- In other words, this method randomizes between a defined set of groups the template to be used for each new spawn of a group.
+-- @param self
+-- @param #string SpawnTemplatePrefixTable A table with the names of the groups defined within the mission editor, from which one will be choosen when a new group will be spawned.
+-- @return #SPAWN
-- @usage
-- -- NATO Tank Platoons invading Gori.
--- -- Choose between 13 different 'US Tank Platoon' configurations for each new SPAWN the Group to be SPAWNed for the
+-- -- Choose between 13 different 'US Tank Platoon' configurations for each new SPAWN the Group to be spawned for the
-- -- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SpawnTemplatePrefixes.
-- -- Each new SPAWN will randomize the route, with a defined time interval of 200 seconds with 40% time variation (randomization) and
--- -- with a limit set of maximum 12 Units alive simulteneously and 150 Groups to be SPAWNed during the whole mission.
+-- -- with a limit set of maximum 12 Units alive simulteneously and 150 Groups to be spawned during the whole mission.
-- Spawn_US_Platoon = { 'US Tank Platoon 1', 'US Tank Platoon 2', 'US Tank Platoon 3', 'US Tank Platoon 4', 'US Tank Platoon 5',
-- 'US Tank Platoon 6', 'US Tank Platoon 7', 'US Tank Platoon 8', 'US Tank Platoon 9', 'US Tank Platoon 10',
-- 'US Tank Platoon 11', 'US Tank Platoon 12', 'US Tank Platoon 13' }
-- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):Limit( 12, 150 ):Schedule( 200, 0.4 ):RandomizeTemplate( Spawn_US_Platoon ):RandomizeRoute( 3, 3, 2000 )
-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):Limit( 12, 150 ):Schedule( 200, 0.4 ):RandomizeTemplate( Spawn_US_Platoon ):RandomizeRoute( 3, 3, 2000 )
-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):Limit( 12, 150 ):Schedule( 200, 0.4 ):RandomizeTemplate( Spawn_US_Platoon ):RandomizeRoute( 3, 3, 2000 )
-
function SPAWN:RandomizeTemplate( SpawnTemplatePrefixTable )
self:T( { self.SpawnTemplatePrefix, SpawnTemplatePrefixTable } )
@@ -214,15 +265,17 @@ end
---- When a Group got SPAWNed, it has a life within the DCSRTE. For planes and helicopters, when these Units go home and land on their home airbases and farps, they normally would taxi to the parking spot, shut-down their engines and wait forever until the Group is removed by the DCSRTE.
--- This function is used to Re-Spawn automatically (so no extra call is needed anymore) the same Group after it landed. This will enable a SPAWNed group to be Re-SPAWNed after it lands, until it is destroyed...
--- Note: When the Group is respawned, it will @{ReSpawn} at the original airbase where it took off. So ensure that the paths for Groups that ReSpawn, always return to the original airbase.
--- @treturn SPAWN
+--- For planes and helicopters, when these groups go home and land on their home airbases and farps, they normally would taxi to the parking spot, shut-down their engines and wait forever until the Group is removed by the runtime environment.
+-- This function is used to re-spawn automatically (so no extra call is needed anymore) the same group after it has landed.
+-- This will enable a spawned group to be re-spawned after it lands, until it is destroyed...
+-- Note: When the group is respawned, it will re-spawn from the original airbase where it took off.
+-- So ensure that the routes for groups that respawn, always return to the original airbase, or players may get confused ...
+-- @param self
+-- @return #SPAWN self
-- @usage
-- -- RU Su-34 - AI Ship Attack
-- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically.
-- SpawnRU_SU34 = SPAWN:New( 'TF1 RU Su-34 Krymsk@AI - Attack Ships' ):Schedule( 2, 3, 1800, 0.4 ):SpawnUncontrolled():RandomizeRoute( 1, 1, 3000 ):RepeatOnEngineShutDown()
-
function SPAWN:Repeat()
self:T( { self.SpawnTemplatePrefix } )
@@ -239,7 +292,7 @@ function SPAWN:Repeat()
end
--- Same as the @{Repeat) method.
--- @treturn SPAWN
+-- @return SPAWN
-- @see Repeat
function SPAWN:RepeatOnLanding()
@@ -252,10 +305,8 @@ function SPAWN:RepeatOnLanding()
return self
end
---- Same as the @{Repeat) method, but now the Group will respawn after its engines have shut down.
--- @treturn SPAWN
--- @see Repeat
-
+--- Same as the @{#SPAWN.Repeat) method, but now the Group will respawn after its engines have shut down.
+-- @return SPAWN
function SPAWN:RepeatOnEngineShutDown()
self:T( { self.SpawnTemplatePrefix } )
@@ -266,30 +317,37 @@ function SPAWN:RepeatOnEngineShutDown()
return self
end
+
+--- CleanUp groups when they are still alive, but inactive.
+-- When groups are still alive and have become inactive due to damage and are unable to contribute anything, then this group will be removed at defined intervals in seconds.
+-- @param self
+-- @param #string SpawnCleanUpInterval The interval to check for inactive groups within seconds.
+-- @return #SPAWN self
+-- @usage Spawn_Helicopter:CleanUp( 20 ) -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.
function SPAWN:CleanUp( SpawnCleanUpInterval )
self:T( { self.SpawnTemplatePrefix, SpawnCleanUpInterval } )
self.SpawnCleanUpInterval = SpawnCleanUpInterval
self.SpawnCleanUpTimeStamps = {}
- self.CleanUpFunction = routines.scheduleFunction( self._SpawnCleanUpScheduler, { self }, timer.getTime() + 1, 60 )
+ self.CleanUpFunction = routines.scheduleFunction( self._SpawnCleanUpScheduler, { self }, timer.getTime() + 1, SpawnCleanUpInterval )
return self
end
---- Makes the Groups visible before start (like a batallion).
--- @tparam number SpawnZone A @{ZONE} where the group will be positioned. The X and Y coordinates of the zone define the start position.
--- @tparam number SpawnAngle The angle in degrees how the Groups and each Unit of the Group will be positioned.
--- @tparam number SpawnFormation The formation of the Units within the Group.
--- @tparam number SpawnWidth The amount of Groups that will be positioned on the X axis.
--- @tparam number SpawnDeltaX The space between each Group on the X-axis.
--- @tparam number SpawnDeltaY The space between each Group on the Y-axis.
--- @treturn SPAWN
+--- Makes the groups visible before start (like a batallion).
+-- The method will take the position of the group as the first position in the array.
+-- @param self
+-- @param #number SpawnAngle The angle in degrees how the groups and each unit of the group will be positioned.
+-- @param #number SpawnFormation The formation of the Units within the Group.
+-- @param #number SpawnWidth The amount of Groups that will be positioned on the X axis.
+-- @param #number SpawnDeltaX The space between each Group on the X-axis.
+-- @param #number SpawnDeltaY The space between each Group on the Y-axis.
+-- @return #SPAWN self
-- @usage
--- -- Define an array of Groups within Zone "Start".
--- Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):Limit( 2, 24 ):Visible( ZONE:New( "Start" ), 90, "Diamond", 10, 100, 50 )
-
+-- -- Define an array of Groups.
+-- Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):Limit( 2, 24 ):Visible( 90, "Diamond", 10, 100, 50 )
function SPAWN:SpawnArray( SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY )
self:T( { self.SpawnTemplatePrefix, SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY } )
@@ -375,12 +433,14 @@ function SPAWN:_TranslateRotate( SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, Spa
return self
end
+
+--- Get the next index of the groups to be spawned. This function is complicated, as it is used at several spaces.
function SPAWN:GetSpawnIndex( SpawnIndex )
- self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxGroupsAlive, self.AliveUnits, #self.SpawnTemplate.units } )
+ self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive, self.AliveUnits, #self.SpawnTemplate.units } )
if ( self.SpawnMaxGroups == 0 ) or ( SpawnIndex <= self.SpawnMaxGroups ) then
- if ( self.SpawnMaxGroupsAlive == 0 ) or ( self.AliveUnits < self.SpawnMaxGroupsAlive * #self.SpawnTemplate.units ) or self.UnControlled then
+ if ( self.SpawnMaxUnitsAlive == 0 ) or ( self.AliveUnits < self.SpawnMaxUnitsAlive * #self.SpawnTemplate.units ) or self.UnControlled then
if SpawnIndex and SpawnIndex >= self.SpawnCount + 1 then
self.SpawnCount = self.SpawnCount + 1
SpawnIndex = self.SpawnCount
@@ -400,21 +460,21 @@ function SPAWN:GetSpawnIndex( SpawnIndex )
end
---- Will SPAWN a Group whenever you want to do this.
--- Note that the configuration with the above functions will apply when calling this method: Maxima, Randomization of routes, Scheduler, ...
--- Uses @{DATABASE} global object defined in MOOSE.
--- @treturn SPAWN
+--- Will re-spawn a group based on a given index.
+-- Note: Uses @{DATABASE} module defined in MOOSE.
+-- @param self
+-- @return #GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:Spawn()
self:T( { self.SpawnTemplatePrefix, self.SpawnIndex } )
return self:SpawnWithIndex( self.SpawnIndex + 1 )
end
---- Will Re-SPAWN a Group based on a given GroupName. The GroupName must be a group that is already alive within the DCSRTE and should have a Group Template defined in the ME (with Late Activation flag on).
--- Note that the configuration with the above functions will apply when calling this method: Maxima, Randomization of routes, Scheduler, ...
--- @tparam string SpawnGroupName
--- @treturn SPAWN
--- Uses _Database global object defined in MOOSE.
+--- Will re-spawn a group based on a given index.
+-- Note: Uses @{DATABASE} module defined in MOOSE.
+-- @param self
+-- @param #string SpawnIndex The index of the group to be spawned.
+-- @return #GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:ReSpawn( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } )
@@ -430,10 +490,9 @@ function SPAWN:ReSpawn( SpawnIndex )
return self:SpawnWithIndex( SpawnIndex )
end
---- Will SPAWN a Group with a specified index number whenever you want to do this.
--- Note that the configuration with the above functions will apply when calling this method: Maxima, Randomization of routes, Scheduler, ...
+--- Will spawn a group with a specified index number.
-- Uses @{DATABASE} global object defined in MOOSE.
--- @treturn GROUP The @{GROUP} that was spawned. You can use this group for further actions.
+-- @return #GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:SpawnWithIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } )
@@ -458,10 +517,13 @@ function SPAWN:SpawnWithIndex( SpawnIndex )
return nil
end
---- SPAWNs a new Group within varying time intervals. This is useful if you want to have continuity within your missions of certain (AI) Groups to be present (alive) within your missions.
--- @tparam number SpawnTime is the time interval defined in seconds between each new SPAWN of new Groups.
--- @tparam number SpawnTimeVariation is the variation to be applied on the defined time interval between each new SPAWN. The variation is defined as a value between 0 and 1, which expresses the %-tage of variation to be applied as the low and high time interval boundaries. Between these boundaries a new time interval will be applied. See usage.
--- @treturn SPAWN
+--- Spawns new groups at varying time intervals.
+-- This is useful if you want to have continuity within your missions of certain (AI) groups to be present (alive) within your missions.
+-- @param self
+-- @param #number SpawnTime The time interval defined in seconds between each new spawn of new groups.
+-- @param #number SpawnTimeVariation The variation to be applied on the defined time interval between each new spawn.
+-- The variation is a number between 0 and 1, representing the %-tage of variation to be applied on the time interval.
+-- @return #SPAWN self
-- @usage
-- -- NATO helicopters engaging in the battle field.
-- -- The time interval is set to SPAWN new helicopters between each 600 seconds, with a time variation of 50%.
@@ -469,9 +531,8 @@ end
-- -- This is calculated as follows:
-- -- Low limit: 600 * ( 1 - 0.5 / 2 ) = 450
-- -- High limit: 600 * ( 1 + 0.5 / 2 ) = 750
--- -- Between these two values, a random amount of seconds will be choosen for each new SPAWN of the helicopters.
+-- -- Between these two values, a random amount of seconds will be choosen for each new spawn of the helicopters.
-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
-
function SPAWN:SpawnScheduled( SpawnTime, SpawnTimeVariation )
self:T( { SpawnTime, SpawnTimeVariation } )
@@ -492,8 +553,10 @@ function SPAWN:SpawnScheduled( SpawnTime, SpawnTimeVariation )
return self
end
---- Will start the SPAWNing timers.
--- This function is called automatically when @{Schedule} is called.
+
+
+--- Will start the spawning scheduler.
+-- Note: This function is called automatically when @{#SPAWN.Scheduled} is called.
function SPAWN:ScheduleStart()
self:T( { self.SpawnTemplatePrefix } )
@@ -510,30 +573,18 @@ function SPAWN:ScheduleStart()
end
end
---- Will stop the scheduled SPAWNing activity.
+--- Will stop the scheduled spawning scheduler.
function SPAWN:ScheduleStop()
self:T( { self.SpawnTemplatePrefix } )
self.SpawnIsScheduled = false
end
---- Limits the Maximum amount of Units to be alive, and the maximum amount of Groups to be SPAWNed within the DCS World run-time environment.
--- Note that this method is exceptionally important to balance the amount of Units alive within the DCSRTE and the performance of the mission. Depending on the machine etc, a mission can only process a maximum amount of units.
--- If the time interval must be short, but there should not be more Units or Groups alive than a maximum amount of units, then this function should be used...
--- @tparam number SpawnMaxGroupsAlive is the Maximum amount of Units to be alive. When there are more Units alive in the DCSRTE of SpawnTemplatePrefix, then no new SPAWN will happen of the Group, until some of these Units will be destroyed.
--- @tparam number SpawnMaxGroups is the Maximum amount of Groups that can be SPAWNed from SpawnTemplatePrefix. When there are more Groups alive in the DCSRTE of SpawnTemplatePrefix, then no more SPAWNs will happen of the Group. This parameter is useful to define a maximum amount of airplanes, ground troops, helicopters, ships etc within a supply area.
--- This parameter accepts the value 0, which expresses no Group count limits.
--- @treturn SPAWN
--- @usage
--- -- NATO helicopters engaging in the battle field.
--- -- This helicopter group consists of one Unit. So, this group will SPAWN maximum 2 groups simultaneously within the DCSRTE.
--- -- There will be maximum 24 groups SPAWNed during the whole mission lifetime.
--- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Limit( 2, 24 )
-
---- Will SPAWN a Group whenever you want to do this, but for AIR Groups only to be applied, and will SPAWN the Group in Uncontrolled mode... This will be similar to the Uncontrolled flag setting in the ME.
--- @treturn SPAWN
+--- Will spawn a plane group in uncontrolled mode...
+-- This will be similar to the uncontrolled flag setting in the ME.
+-- @return #SPAWN self
function SPAWN:UnControlled()
self:T( { self.SpawnTemplatePrefix } )
@@ -547,14 +598,18 @@ function SPAWN:UnControlled()
end
---- Will SPAWN a Group from a Hosting @{UNIT}. This function is mostly advisable to be used if you want to simulate SPAWNing from air units, like helicopters, which are dropping infantry into a defined Landing Zone.
--- Note that each point in the route assigned to the spawning @{GROUP} is reset to the Point of the spawn.
--- You can use the returned @{GROUP} to further define the route to be followed.
--- @tparam UNIT HostUnit is the AIR unit or GROUND unit dropping or unloading the Spawn group.
--- @treturn GROUP Spawned.
--- @treturn nil when nothing was spawned.
+--- Will spawn a group from a hosting unit. This function is mostly advisable to be used if you want to simulate spawning from air units, like helicopters, which are dropping infantry into a defined Landing Zone.
+-- Note that each point in the route assigned to the spawning group is reset to the point of the spawn.
+-- You can use the returned group to further define the route to be followed.
+-- @param self
+-- @param #UNIT HostUnit The air or ground unit dropping or unloading the group.
+-- @param #number OuterRadius The outer radius in meters where the new group will be spawned.
+-- @param #number InnerRadius The inner radius in meters where the new group will NOT be spawned.
+-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone.
+-- @return #GROUP that was spawned.
+-- @return #nil Nothing was spawned.
function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex )
- self:T( { self.SpawnTemplatePrefix, HostUnit, SpawnFormation, SpawnIndex } )
+ self:T( { self.SpawnTemplatePrefix, HostUnit, OuterRadius, InnerRadius, SpawnIndex } )
if HostUnit and HostUnit:IsAlive() then -- and HostUnit:getUnit(1):inAir() == false then
@@ -623,9 +678,11 @@ function SPAWN:SpawnFromUnit( HostUnit, OuterRadius, InnerRadius, SpawnIndex )
end
--- Will spawn a Group within a given @{ZONE}.
--- @tparam ZONE The @{ZONE} where the Group is to be SPAWNed.
--- @treturn GROUP that was spawned.
--- @treturn nil when nothing as spawned.
+-- @param self
+-- @param #ZONE Zone The zone where the group is to be spawned.
+-- @param #number SpawnIndex (Optional) The index which group to spawn within the given zone.
+-- @return #GROUP that was spawned.
+-- @return #nil when nothing was spawned.
function SPAWN:SpawnInZone( Zone, SpawnIndex )
self:T( { self.SpawnTemplatePrefix, Zone, SpawnIndex } )
@@ -677,8 +734,9 @@ end
--- Will return the SpawnGroupName either with with a specific count number or without any count.
--- @tparam number SpawnIndex is the number of the Group that is to be SPAWNed.
--- @treturn string SpawnGroupName
+-- @param self
+-- @param #number SpawnIndex Is the number of the Group that is to be spawned.
+-- @return string SpawnGroupName
function SPAWN:SpawnGroupName( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, SpawnIndex } )
@@ -698,6 +756,13 @@ function SPAWN:SpawnGroupName( SpawnIndex )
end
+
+--- Get the group from an index.
+-- Returns the group from the SpawnGroups list.
+-- If no index is given, it will return the first group in the list.
+-- @param self
+-- @param #number SpawnIndex The index of the group to return.
+-- @return #GROUP
function SPAWN:GetGroupFromIndex( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
@@ -710,6 +775,13 @@ function SPAWN:GetGroupFromIndex( SpawnIndex )
end
end
+--- Get the group index from a DCSUnit.
+-- The method will search for a #-mark, and will return the index behind the #-mark of the DCSUnit.
+-- It will return nil of no prefix was found.
+-- @param self
+-- @param DCSUnit The DCS unit to be searched.
+-- @return #string The prefix
+-- @return #nil Nothing found
function SPAWN:GetGroupIndexFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
@@ -727,6 +799,13 @@ function SPAWN:GetGroupIndexFromDCSUnit( DCSUnit )
return nil
end
+--- Return the prefix of a DCSUnit.
+-- The method will search for a #-mark, and will return the text before the #-mark.
+-- It will return nil of no prefix was found.
+-- @param self
+-- @param DCSUnit The DCS unit to be searched.
+-- @return #string The prefix
+-- @return #nil Nothing found
function SPAWN:GetPrefixFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
@@ -734,8 +813,6 @@ function SPAWN:GetPrefixFromDCSUnit( DCSUnit )
local SpawnPrefix = string.match( DCSUnit:getName(), ".*#" )
if SpawnPrefix then
SpawnPrefix = SpawnPrefix:sub( 1, -2 )
- else
- self:E( { "This name does not contain a #", DCSUnit:getName() } )
end
self:T( SpawnPrefix )
return SpawnPrefix
@@ -744,6 +821,7 @@ function SPAWN:GetPrefixFromDCSUnit( DCSUnit )
return nil
end
+--- Return the group within the SpawnGroups collection with input a DCSUnit.
function SPAWN:GetGroupFromDCSUnit( DCSUnit )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, DCSUnit } )
@@ -762,7 +840,8 @@ function SPAWN:GetGroupFromDCSUnit( DCSUnit )
end
---TODO: Rename to GetGroupIndexFromGroup
+--- Get the index from a given group.
+-- The function will search the name of the group for a #, and will return the number behind the #-mark.
function SPAWN:GetGroupIndexFromGroup( SpawnGroup )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
@@ -774,13 +853,14 @@ function SPAWN:GetGroupIndexFromGroup( SpawnGroup )
end
+--- Return the last maximum index that can be used.
function SPAWN:GetLastIndex()
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
return self.SpawnMaxGroups
end
-
+--- Initalize the SpawnGroups collection.
function SPAWN:InitializeSpawnGroups( SpawnIndex )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnIndex } )
@@ -804,7 +884,11 @@ function SPAWN:InitializeSpawnGroups( SpawnIndex )
end
-
+--- Find the first alive group.
+-- @param self
+-- @param #number SpawnCursor A number holding the index from where to find the first group from.
+-- @return #GROUP, #number The group found, the new index where the group was found.
+-- @return #nil, #nil When no group is found, #nil is returned.
function SPAWN:GetFirstAliveGroup( SpawnCursor )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
@@ -819,6 +903,12 @@ function SPAWN:GetFirstAliveGroup( SpawnCursor )
return nil, nil
end
+
+--- Find the next alive group.
+-- @param self
+-- @param #number SpawnCursor A number holding the last found previous index.
+-- @return #GROUP, #number The group found, the new index where the group was found.
+-- @return #nil, #nil When no group is found, #nil is returned.
function SPAWN:GetNextAliveGroup( SpawnCursor )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnCursor } )
@@ -834,6 +924,7 @@ function SPAWN:GetNextAliveGroup( SpawnCursor )
return nil, nil
end
+--- Find the last alive group during runtime.
function SPAWN:GetLastAliveGroup()
self:T( { self.SpawnTemplatePrefixself.SpawnAliasPrefix } )
@@ -851,10 +942,6 @@ function SPAWN:GetLastAliveGroup()
end
-
---- Private
--- @section
-
--- Gets the CategoryID of the Group with the given SpawnPrefix
function SPAWN:_GetGroupCategoryID( SpawnPrefix )
local TemplateGroup = Group.getByName( SpawnPrefix )
@@ -892,7 +979,7 @@ function SPAWN:_GetGroupCountryID( SpawnPrefix )
end
--- Gets the Group Template from the ME environment definition.
--- This method used the @{DATABASE} object, which contains ALL initial and new SPAWNed object in MOOSE.
+-- This method used the @{DATABASE} object, which contains ALL initial and new spawned object in MOOSE.
function SPAWN:_GetTemplate( SpawnTemplatePrefix )
self:T( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnTemplatePrefix } )
@@ -942,11 +1029,9 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex )
end
---- Events
--- @section Events
---- Obscolete
--- @todo Need to delete this... _Database does this now ...
+
+-- TODO Need to delete this... _Database does this now ...
function SPAWN:OnBirth( event )
if timer.getTime0() < timer.getAbsTime() then -- dont need to add units spawned in at the start of the mission if mist is loaded in init line
@@ -982,7 +1067,7 @@ function SPAWN:OnDeadOrCrash( event )
end
end
---- Will detect AIR Units taking off... When the event takes place, the SPAWNed Group is registered as airborne...
+--- Will detect AIR Units taking off... When the event takes place, the spawned Group is registered as airborne...
-- This is needed to ensure that Re-SPAWNing only is done for landed AIR Groups.
-- @todo Need to test for AIR Groups only...
function SPAWN:OnTakeOff( event )
@@ -997,7 +1082,7 @@ function SPAWN:OnTakeOff( event )
end
end
---- Will detect AIR Units landing... When the event takes place, the SPAWNed Group is registered as landed.
+--- Will detect AIR Units landing... When the event takes place, the spawned Group is registered as landed.
-- This is needed to ensure that Re-SPAWNing is only done for landed AIR Groups.
-- @todo Need to test for AIR Groups only...
function SPAWN:OnLand( event )
@@ -1018,7 +1103,7 @@ function SPAWN:OnLand( event )
end
--- Will detect AIR Units shutting down their engines ...
--- When the event takes place, and the method @{RepeatOnEngineShutDown} was called, the SPAWNed Group will Re-SPAWN.
+-- When the event takes place, and the method @{RepeatOnEngineShutDown} was called, the spawned Group will Re-SPAWN.
-- But only when the Unit was registered to have landed.
-- @see OnTakeOff
-- @see OnLand
@@ -1038,13 +1123,10 @@ function SPAWN:OnEngineShutDown( event )
end
end
---- Scheduled
--- @section Scheduled
-
--- This function is called automatically by the Spawning scheduler.
-- It is the internal worker method SPAWNing new Groups on the defined time intervals.
function SPAWN:_Scheduler()
-self:T( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxGroupsAlive } )
+self:T( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive } )
if self.SpawnInit or self.SpawnCurrentTimer == self.SpawnSetTimer then
-- Validate if there are still groups left in the batch...
@@ -1091,5 +1173,3 @@ function SPAWN:_SpawnCleanUpScheduler()
end
end
-
-
diff --git a/Test Missions/MOOSE_Spawn_Test.lua b/Test Missions/MOOSE_Spawn_Test.lua
index 6084847de..34dc8bfb3 100644
--- a/Test Missions/MOOSE_Spawn_Test.lua
+++ b/Test Missions/MOOSE_Spawn_Test.lua
@@ -9,14 +9,19 @@ Group_Plane = Spawn_Plane:Spawn()
Spawn_Helicopter = SPAWN:New( "Spawn Helicopter" ):RandomizeRoute( 1, 1, 1000 )
Group_Helicopter = Spawn_Helicopter:Spawn()
+Group_Helicopter2 = Spawn_Helicopter:Spawn()
Spawn_Ship = SPAWN:New( "Spawn Ship" ):RandomizeRoute( 0, 0, 2000 )
Group_Ship1 = Spawn_Ship:Spawn()
Group_Ship2 = Spawn_Ship:Spawn()
-Spawn_Vehicle = SPAWN:New( "Spawn Vehicle" )
+Spawn_Vehicle = SPAWN:New( "Spawn Vehicle" ):RandomizeRoute( 1, 0, 50 )
Group_Vehicle1 = Spawn_Vehicle:Spawn()
Group_Vehicle2 = Spawn_Vehicle:Spawn()
+Group_Vehicle3 = Spawn_Vehicle:Spawn()
+Group_Vehicle4 = Spawn_Vehicle:Spawn()
+Group_Vehicle5 = Spawn_Vehicle:Spawn()
+Group_Vehicle6 = Spawn_Vehicle:Spawn()
Group_Vehicle1:RouteToZone( ZONE:New( "Landing Zone" ), true, 40, "Cone" )
diff --git a/Test Missions/MOOSE_Spawn_Test.miz b/Test Missions/MOOSE_Spawn_Test.miz
index 7350449fb..b4e4a3614 100644
Binary files a/Test Missions/MOOSE_Spawn_Test.miz and b/Test Missions/MOOSE_Spawn_Test.miz differ
diff --git a/doc/classes/BASE.html b/doc/classes/BASE.html
index e38ccc9b4..d041d5139 100644
--- a/doc/classes/BASE.html
+++ b/doc/classes/BASE.html
@@ -3,7 +3,7 @@
- Internal Table to understand the form of the CARGO.
-
-
-
Fields:
-
-
UNIT
+ Clients are those Groups defined within the Mission Editor that have the skillset defined as "Client" or "Player".
+ These clients are defined within the Mission Orchestration Framework (MOF)
-
-
SLING
-
-
STATIC
+
+
+
+
Fields
+
+
+
+
+ self.CargoGroupName
+
+
+ ReSpawn the Cargo from the CargoHost
-
-
INVISIBLE
-
-
-
-
-
-
-
- CARGO.CARGO_TYPE
+
+ self.CargoGroupName
- CARGO_TYPE Defines the different types of transports, which has an impact on the menu commands shown in F10.
+ ReSpawn the Cargo in the CargoZone without a host ...
-
+ Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class...
+
+
+
- Detects if the Unit has an SEVENTENGINESHUTDOWN or an SEVENT_HIT within the given ZoneNames. If this is the case, add the Group to the CLEANUP List.
+ Destroys a group from the simulator, but checks first if it is still existing!
+
+
+
+ Detects if the Unit has an S_EVENT_HIT within the given ZoneNames. If this is the case, destroy the unit.
+
+
+
Parameters:
+
+
event
+
+
+
+
+
+
+
+
+
+
+
+ CLEANUP:_EventAddForCleanUp (event)
+
+
+ Detects if the Unit has an S_EVENT_ENGINE_SHUTDOWN or an S_EVENT_HIT within the given ZoneNames. If this is the case, add the Group to the CLEANUP List.
+
+
+
CargoGroupName
- string
- is the name of an active Group defined within the Mission Editor or Dynamically Spawned. Note that this is only applicable for Unit CARGO Types.
-
- Handle the SEVENTDEAD events to validate the destruction of units for the task monitoring.
+ Handle the S_EVENT_DEAD events to validate the destruction of units for the task monitoring.
Parameters:
event
-
-
Event structure of DCS world.
-
-
+ Event structure of DCS world.
@@ -184,16 +176,10 @@
Parameters:
DestroyGroup
-
-
Group structure describing the group to be evaluated.
-
-
+ Group structure describing the group to be evaluated.
DestroyUnit
-
-
Unit structure describing the Unit to be evaluated.
-
-
+ Unit structure describing the Unit to be evaluated.
Message System to display Messages for Clients and Coalitions or All.
-
Messages are grouped on the display panel per Category to improve readability for the players.
+
+ Messages are grouped on the display panel per Category to improve readability for the players.
Messages are shown on the display panel for an amount of seconds, and will then disappear.
Messages are identified by an ID. The messages with the same ID belonging to the same category will be overwritten if they were still being displayed on the display panel.
Messages are created with MESSAGE:New().
@@ -104,6 +102,14 @@
+ -- Send a message created with the New method to the BLUE coalition.
+ MessageBLUE = MESSAGE:New( "To the BLUE Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToBlue()
+ or
+ MESSAGE:New( "To the BLUE Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToBlue()
+ or
+ MessageBLUE = MESSAGE:New( "To the BLUE Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
+ MessageBLUE:ToBlue()
+ -- Send a message created with the New method to the RED coalition.
+ MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToRed()
+ or
+ MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToRed()
+ or
+ MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" )
+ MessageRED:ToRed()
A MISSION is the main owner of a Mission orchestration within MOOSE .
+
A MISSION is the main owner of a Mission orchestration within MOOSE .
The Mission framework orchestrates CLIENTs, TASKs, STAGEs etc.
A CLIENT needs to be registered within the MISSION through the function AddClient. A TASK needs to be registered within the MISSION through the function AddTask.
- Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class...
-
-
-
-
-
-
-
-
Limit the simultaneous movement of Groups within a running Mission.
-
This module is defined to improve the performance in missions, and to bring additional realism for GROUND vehicles.
+
+ This module is defined to improve the performance in missions, and to bring additional realism for GROUND vehicles.
Performance: If in a DCSRTE there are a lot of moving GROUND units, then in a multi player mission, this WILL create lag if
the main DCS execution core of your CPU is fully utilized. So, this class will limit the amount of simultaneous moving GROUND units
on defined intervals (currently every minute).
- Prepares the new Group Template before Spawning.
+ Prepares the new Group Template.
Parameters:
-
SpawnIncrement
-
-
+
SpawnTemplatePrefix
-
-
-
-
-
-
-
-
-
- SPAWN:_RandomizeRoute (SpawnTemplate)
-
-
- Will randomize the route of the Group Template.
-
-
-
Parameters:
-
-
SpawnTemplate
-
-
+
SpawnIndex
@@ -374,8 +352,6 @@
event
-
-
@@ -396,31 +372,6 @@
event
-
-
-
-
-
-
-
-
-
-
-
-
- SPAWN:OnLand (event)
-
-
- Will detect AIR Units landing... When the event takes place, the SPAWNed Group is registered as landed.
- This is needed to ensure that Re-SPAWNing is only done for landed AIR Groups.
-
-
-
Parameters:
-
-
event
-
-
-
@@ -442,8 +393,27 @@
event
+
+
+
+
+
+
+
+
+ SPAWN:OnLand (event)
+
+
+ Will detect AIR Units landing... When the event takes place, the SPAWNed Group is registered as landed.
+ This is needed to ensure that Re-SPAWNing is only done for landed AIR Groups.
+
+
+
Creates the main object to spawn a Group defined in the DCS ME.
- Spawned Groups and Units will follow the following naming convention within the DCS World run-time environment:
-
Groups will have the name SpawnPrefix#ggg, where ggg is a counter from 0 to 999 for each new spawned Group.
- Units will have the name SpawnPrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned Unit belonging to that Group.
-
-
+ Creates the main object to spawn a Group defined in the DCS ME.
+ Spawned Groups and Units will follow the following naming convention within the DCS World run-time environment:
+ Groups will have the name SpawnTemplatePrefix#ggg, where ggg is a counter from 0 to 999 for each new spawned Group.
+ Units will have the name SpawnTemplatePrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned Unit belonging to that Group.
Parameters:
-
SpawnPrefix
+
SpawnTemplatePrefixstring
- is the name of the Group in the ME that defines the Template. That Group must have the flag "Late Activation" set. Note that this SpawnPrefix name should not contain any # character.
+ is the name of the Group in the ME that defines the Template. That Group must have the flag "Late Activation" set. Note that this SpawnTemplatePrefix name should not contain any # character.
+ Creates the main object to spawn a Group defined in the DCS ME.
+ Spawned Groups and Units will follow the following naming convention within the DCS World run-time environment:
+ Groups will have the name SpawnTemplatePrefix#ggg, where ggg is a counter from 0 to 999 for each new spawned Group.
+ Units will have the name SpawnTemplatePrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned Unit belonging to that Group.
+
+
+
Parameters:
+
+
SpawnTemplatePrefix
+ string
+ is the name of the Group in the ME that defines the Template. That Group must have the flag "Late Activation" set. Note that this SpawnTemplatePrefix name should not contain any # character.
+
+ Limits the Maximum amount of Units to be alive, and the maximum amount of Groups to be SPAWNed within the DCS World run-time environment.
+ Note that this method is exceptionally important to balance the amount of Units alive within the DCSRTE and the performance of the mission. Depending on the machine etc, a mission can only process a maximum amount of units.
+ If the time interval must be short, but there should not be more Units or Groups alive than a maximum amount of units, then this function should be used...
+
+
+
Parameters:
+
+
SpawnMaxGroupsAlive
+ number
+ is the Maximum amount of Units to be alive. When there are more Units alive in the DCSRTE of SpawnTemplatePrefix, then no new SPAWN will happen of the Group, until some of these Units will be destroyed.
+
+
SpawnMaxGroups
+ number
+ is the Maximum amount of Groups that can be SPAWNed from SpawnTemplatePrefix. When there are more Groups alive in the DCSRTE of SpawnTemplatePrefix, then no more SPAWNs will happen of the Group. This parameter is useful to define a maximum amount of airplanes, ground troops, helicopters, ships etc within a supply area.
+ This parameter accepts the value 0, which expresses no Group count limits.
+
+ -- NATO helicopters engaging in the battle field.
+-- This helicopter group consists of one Unit. So, this group will SPAWN maximum 2 groups simultaneously within the DCSRTE.
+-- There will be maximum 24 groups SPAWNed during the whole mission lifetime.
+ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Limit( 2, 24 )
- SPAWNs a new Group within varying time intervals. This is useful if you want to have continuity within your missions of certain (AI) Groups to be present (alive) within your missions.
-
-
-
Parameters:
-
-
SpawnTime
- number
- is the time interval defined in seconds between each new SPAWN of new Groups.
-
-
SpawnTimeVariation
- number
- is the variation to be applied on the defined time interval between each new SPAWN. The variation is defined as a value between 0 and 1, which expresses the %-tage of variation to be applied as the low and high time interval boundaries. Between these boundaries a new time interval will be applied. See usage.
-
- -- NATO helicopters engaging in the battle field.
--- The time interval is set to SPAWN new helicopters between each 600 seconds, with a time variation of 50%.
--- The time variation in this case will be between 450 seconds and 750 seconds.
--- This is calculated as follows:
--- Low limit: 600 * ( 1 - 0.5 / 2 ) = 450
--- High limit: 600 * ( 1 + 0.5 / 2 ) = 750
--- Between these two values, a random amount of seconds will be choosen for each new SPAWN of the helicopters.
- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
-
-
-
-
-
- SPAWN:ScheduleStart ()
-
-
- Will start the SPAWNing timers.
- This function is called automatically when Schedule is called.
-
-
-
-
-
-
-
-
-
-
- SPAWN:ScheduleStop ()
-
-
- Will stop the scheduled SPAWNing activity.
-
-
-
-
-
-
-
-
- Limits the Maximum amount of Units to be alive, and the maximum amount of Groups to be SPAWNed within the DCS World run-time environment.
- Note that this method is exceptionally important to balance the amount of Units alive within the DCSRTE and the performance of the mission. Depending on the machine etc, a mission can only process a maximum amount of units.
- If the time interval must be short, but there should not be more Units or Groups alive than a maximum amount of units, then this function should be used...
-
-
-
Parameters:
-
-
SpawnMaxGroupsAlive
- number
- is the Maximum amount of Units to be alive. When there are more Units alive in the DCSRTE of SpawnPrefix, then no new SPAWN will happen of the Group, until some of these Units will be destroyed.
-
-
SpawnMaxGroups
- number
-
-
is the Maximum amount of Groups that can be SPAWNed from SpawnPrefix. When there are more Groups alive in the DCSRTE of SpawnPrefix, then no more SPAWNs will happen of the Group. This parameter is useful to define a maximum amount of airplanes, ground troops, helicopters, ships etc within a supply area.
-
This parameter accepts the value 0, which expresses no Group count limits.
-
- -- NATO helicopters engaging in the battle field.
--- This helicopter group consists of one Unit. So, this group will SPAWN maximum 2 groups simultaneously within the DCSRTE.
--- There will be maximum 24 groups SPAWNed during the whole mission lifetime.
- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Limit( 2, 24 )
This function is rather complicated to understand. But I'll try to explain...
- This function becomes useful when you need to SPAWN random types of Groups defined within the ME, but they all need to follow the same Template route and have the same SpawnPrefix name, then this method becomes very useful.
+ This function becomes useful when you need to SPAWN random types of Groups defined within the ME, but they all need to follow the same Template route and have the same SpawnTemplatePrefix name, then this method becomes very useful.
Parameters:
-
SpawnPrefixTable
+
SpawnTemplatePrefixTabletable{string,...}
- is a table with the names of the Groups defined within the ME (with late activatio on), from which on a new SPAWN of SpawnPrefix (the main Group name), a NEW Group will be choosen as the Group to be SPAWNed.
+ is a table with the names of the Groups defined within the ME (with late activatio on), from which on a new SPAWN of SpawnTemplatePrefix (the main Group name), a NEW Group will be choosen as the Group to be SPAWNed.
In other words, this method randomizes between a defined set of Groups the Group to be SPAWNed for each new SPAWN.
-- NATO Tank Platoons invading Gori.
-- Choose between 13 different 'US Tank Platoon' configurations for each new SPAWN the Group to be SPAWNed for the
--- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SpawnPrefixes.
+-- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SpawnTemplatePrefixes.
-- Each new SPAWN will randomize the route, with a defined time interval of 200 seconds with 40% time variation (randomization) and
-- with a limit set of maximum 12 Units alive simulteneously and 150 Groups to be SPAWNed during the whole mission.
Spawn_US_Platoon = { 'US Tank Platoon 1', 'US Tank Platoon 2', 'US Tank Platoon 3', 'US Tank Platoon 4', 'US Tank Platoon 5',
@@ -767,7 +683,7 @@
When a Group got SPAWNed, it has a life within the DCSRTE. For planes and helicopters, when these Units go home and land on their home airbases and farps, they normally would taxi to the parking spot, shut-down their engines and wait forever until the Group is removed by the DCSRTE.
This function is used to Re-Spawn automatically (so no extra call is needed anymore) the same Group after it landed. This will enable a SPAWNed group to be Re-SPAWNed after it lands, until it is destroyed...
- Note: When the Group is respawned, it will ReSpawn at the original airbase where it took off. So ensure that the paths for Groups that ReSpawn, always return to the orignal airbase.
+ Note: When the Group is respawned, it will ReSpawn at the original airbase where it took off. So ensure that the paths for Groups that ReSpawn, always return to the original airbase.
@@ -776,8 +692,6 @@
SPAWN
-
-
@@ -805,8 +719,6 @@
SPAWN
-
-
@@ -831,8 +743,6 @@
SPAWN
-
-
@@ -842,6 +752,59 @@
+
- Will SPAWN a Group whenever you want to do this, but for AIR Groups only to be applied, and will SPAWN the Group in Uncontrolled mode... This will be similar to the Uncontrolled flag setting in the ME.
+ Will SPAWN a Group with a specified index number whenever you want to do this.
+ Note that the configuration with the above functions will apply when calling this method: Maxima, Randomization of routes, Scheduler, ...
+ Uses DATABASE global object defined in MOOSE.
+
+
+
Parameters:
+
+
SpawnIndex
+
+
+
+
+
Returns:
+
+
+ GROUP
+ The GROUP that was spawned. You can use this group for further actions.
+
+
+
+
+
+
+ SPAWNs a new Group within varying time intervals. This is useful if you want to have continuity within your missions of certain (AI) Groups to be present (alive) within your missions.
+
+
+
Parameters:
+
+
SpawnTime
+ number
+ is the time interval defined in seconds between each new SPAWN of new Groups.
+
+
SpawnTimeVariation
+ number
+ is the variation to be applied on the defined time interval between each new SPAWN. The variation is defined as a value between 0 and 1, which expresses the %-tage of variation to be applied as the low and high time interval boundaries. Between these boundaries a new time interval will be applied. See usage.
+
+ -- NATO helicopters engaging in the battle field.
+-- The time interval is set to SPAWN new helicopters between each 600 seconds, with a time variation of 50%.
+-- The time variation in this case will be between 450 seconds and 750 seconds.
+-- This is calculated as follows:
+-- Low limit: 600 * ( 1 - 0.5 / 2 ) = 450
+-- High limit: 600 * ( 1 + 0.5 / 2 ) = 750
+-- Between these two values, a random amount of seconds will be choosen for each new SPAWN of the helicopters.
+ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
+
+
+
+
+
+ SPAWN:ScheduleStart ()
+
+
+ Will start the SPAWNing timers.
+ This function is called automatically when ??? is called.
+
+
+
+
+
+
+
+
+
+
+ SPAWN:ScheduleStop ()
+
+
+ Will stop the scheduled SPAWNing activity.
+
+
+
+
+
+
+
+
+
+
+ SPAWN:UnControlled ()
+
+
+ Will SPAWN a Group whenever you want to do this, but for AIR Groups only to be applied, and will SPAWN the Group in Uncontrolled mode...
+ This will be similar to the Uncontrolled flag setting in the ME.
@@ -911,8 +971,6 @@
SPAWN
-
-
@@ -920,61 +978,88 @@
- Will SPAWN a Group from a Carrier. This function is mostly advisable to be used if you want to simulate SPAWNing from air units, like helicopters, which are dropping infantry into a defined Landing Zone.
+ Will SPAWN a Group from a Hosting UNIT. This function is mostly advisable to be used if you want to simulate SPAWNing from air units, like helicopters, which are dropping infantry into a defined Landing Zone.
+ Note that each point in the route assigned to the spawning GROUP is reset to the Point of the spawn.
+ You can use the returned GROUP to further define the route to be followed.
Parameters:
-
CarrierGroup
- Group
- is the Group of the AIR unit or GROUND unit dropping or unloading other units.
-
-
TargetZonePrefix
- string
- is the Prefix of the Zone defined in the ME where the Group should be moving to after drop.
-