# Module `Spawn`

Dynamic spawning of groups (and units).

# #SPAWN class

The #SPAWN class allows to spawn dynamically new groups, based on pre-defined initialization settings, modifying the behaviour when groups are spawned. For each group to be spawned, within the mission editor, a group has to be created with the "late activation flag" set. We call this group the "Spawn Template" of the SPAWN object. A reference to this Spawn Template needs to be provided when constructing the SPAWN object, by indicating the name of the group within the mission editor in the constructor methods.

Within the SPAWN object, there is an internal index that keeps track of which group from the internal group list was spawned. When new groups get spawned by using the SPAWN functions (see below), it will be validated whether the Limits (SPAWN.Limit) of the SPAWN object are not reached. When all is valid, a new group will be created by the spawning methods, and the internal index will be increased with 1.

Regarding the name of new spawned groups, a SpawnPrefix will be assigned for each new group created. If you want to have the Spawn Template name to be used as the SpawnPrefix name, use the SPAWN.New constructor. However, when the SPAWN.NewWithAlias constructor was used, the Alias name will define the SpawnPrefix name. Groups will follow the following naming structure when spawned at run-time:

1. Spawned groups will have the name SpawnPrefix#ggg, where ggg is a counter from 0 to 999.
2. Spawned units will have the name SpawnPrefix#ggg-uu, where uu is a counter from 0 to 99 for each new spawned unit belonging to the group.

Some additional notes that need to be remembered:

- 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 Spawn Template(s), or the SPAWN module logic won't work anymore.

# SPAWN construction methods:

Create a new SPAWN object with the SPAWN.New or the SPAWN.NewWithAlias methods:

- SPAWN.New: Creates a new SPAWN object taking the name of the group that functions as the Template.

It is important to understand how the SPAWN class works internally. The SPAWN object created will contain internally a list of groups that will be spawned and that are already spawned. The initialization functions will modify this list of groups so that when a group gets spawned, ALL information is already prepared when spawning. This is done for performance reasons. So in principle, the group list will contain all parameters and configurations after initialization, and when groups get actually spawned, this spawning can be done quickly and efficient.

# SPAWN initialization methods:

A spawn object will behave differently based on the usage of initialization methods:

- SPAWN.Limit: Limits the amount of groups that can be alive at the same time and that can be dynamically spawned.
- SPAWN.RandomizeRoute: Randomize the routes of spawned groups.
- SPAWN.RandomizeTemplate: Randomize the group templates so that when a new group is spawned, a random group template is selected from one of the templates defined.
- SPAWN.Uncontrolled: Spawn plane groups uncontrolled.
- SPAWN.Array: Make groups visible before they are actually activated, and order these groups like a batallion in an array.
- SPAWN.Repeat: Re-spawn groups when they land at the home base. Similar functions are SPAWN.RepeatOnLanding and SPAWN.RepeatOnEngineShutDown.

# SPAWN spawning methods:

Groups can be spawned at different times and methods:

- SPAWN.Spawn: Spawn one new group based on the last spawned index.
- SPAWN.ReSpawn: Re-spawn a group based on a given index.
- SPAWN.SpawnScheduled: Spawn groups at scheduled but randomized intervals. You can use SPAWN.SpawnScheduleStart and SPAWN.SpawnScheduleStop to start and stop the schedule respectively.
- SPAWN.SpawnFromUnit: Spawn a new group taking the position of a UNIT.
- SPAWN.SpawnInZone: Spawn a new group in a ZONE.

Note that SPAWN.Spawn and SPAWN.ReSpawn return a GROUP#GROUP.New object, that contains a reference to the DCSGroup object. You can use the GROUP object to do further actions with the DCSGroup.

# SPAWN object cleaning:

Sometimes, it will occur during a mission run-time, that ground or especially air objects get damaged, and will while being damged stop their activities, while remaining alive. In such cases, the SPAWN object will just sit there and wait until that group gets destroyed, but most of the time it won't, and it may occur that no new groups are or can be spawned as limits are reached. To prevent this, a SPAWN.CleanUp initialization method has been defined that will silently monitor the status of each spawned group. Once a group has a velocity = 0, and has been waiting for a defined interval, that group will be cleaned or removed from run-time. There is a catch however :-) If a damaged group has returned to an airbase within the coalition, that group will not be considered as "lost"... In such a case, when the inactive group is cleaned, a new group will Re-spawned automatically. This models AI that has succesfully returned to their airbase, to restart their combat activities. Check the SPAWN.CleanUp for further info.

## Global(s)

SPAWN |

## Type `SPAWN`

SPAWN.AliveFactor |
SPAWN:Array(SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY) | Makes the groups visible before start (like a batallion).
SPAWN.ClassName |
SPAWN:CleanUp(SpawnCleanUpInterval) | CleanUp groups when they are still alive, but inactive.
SPAWN.CleanUpFunction |
SPAWN:GetFirstAliveGroup(SpawnCursor) | Find the first alive group.
SPAWN:GetGroupFromIndex(SpawnIndex) | Get the group from an index.
SPAWN:GetLastAliveGroup() | Find the last alive group during runtime.
SPAWN:GetNextAliveGroup(SpawnCursor) | Find the next alive group.
SPAWN:GetSpawnIndexFromGroup(SpawnGroup) | Get the index from a given group.
SPAWN:Limit(SpawnMaxUnitsAlive, 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.
SPAWN:New(SpawnTemplatePrefix) | Creates the main object to spawn a GROUP defined in the DCS ME.
SPAWN:NewWithAlias(SpawnTemplatePrefix, SpawnAliasPrefix) | Creates a new SPAWN instance to create new groups based on the defined template and using a new alias for each new group.
SPAWN:RandomizeRoute(SpawnStartPoint, SpawnEndPoint, SpawnRadius) | Randomizes the defined route of the SpawnTemplatePrefix group in the ME.
SPAWN:RandomizeTemplate(SpawnTemplatePrefixTable) | This function is rather complicated to understand.
SPAWN:ReSpawn(SpawnIndex) | Will re-spawn a group based on a given index.
SPAWN:Repeat() | 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.
SPAWN.RepeatOnEngineShutDown |
SPAWN.RepeatOnLanding |
SPAWN:Spawn() | Will spawn a group based on the internal index.
SPAWN.SpawnAliasPrefix |
SPAWN.SpawnCleanUpInterval |
SPAWN.SpawnCleanUpTimeStamps |
SPAWN.SpawnCurrentTimer |
SPAWN:SpawnFromUnit(HostUnit, OuterRadius, InnerRadius, SpawnIndex) | Will spawn a group from a hosting unit.
SPAWN:SpawnFunction(SpawnFunctionHook, SpawnFunctionArguments, ...) | Allows to place a CallFunction hook when a new group spawns.
SPAWN.SpawnFunctionArguments |
SPAWN.SpawnFunctionHook |
SPAWN:SpawnGroupName(SpawnIndex) | Will return the SpawnGroupName either with with a specific count number or without any count.
SPAWN.SpawnHighTimer |
SPAWN:SpawnInZone(Zone, ZoneRandomize, SpawnIndex) | Will spawn a Group within a given Zone#ZONE.
SPAWN.SpawnLowTimer |
SPAWN.SpawnMaxGroups |
SPAWN.SpawnMaxUnitsAlive |
SPAWN.SpawnRandomizeRoute |
SPAWN.SpawnRandomizeRouteEndPoint |
SPAWN.SpawnRandomizeRouteRadius |
SPAWN.SpawnRandomizeRouteStartPoint |
SPAWN.SpawnRandomizeTemplate |
SPAWN.SpawnRepeat |
SPAWN:SpawnScheduleStart() | Will start the spawning scheduler.
SPAWN:SpawnScheduleStop() | Will stop the scheduled spawning scheduler.
SPAWN:SpawnScheduled(SpawnTime, SpawnTimeVariation) | Spawns new groups at varying time intervals.
SPAWN.SpawnSetTimer |
SPAWN.SpawnTemplatePrefix |
SPAWN.SpawnTemplatePrefixTable |
SPAWN.SpawnVisible |
SPAWN:SpawnWithIndex(SpawnIndex) | Will spawn a group with a specified index number.
SPAWN:UnControlled() | Will spawn a plane group in uncontrolled mode...
SPAWN:_GetGroupCategoryID(SpawnPrefix) | Gets the CategoryID of the Group with the given SpawnPrefix
SPAWN:_GetGroupCoalitionID(SpawnPrefix) | Gets the CoalitionID of the Group with the given SpawnPrefix
SPAWN:_GetGroupCountryID(SpawnPrefix) | Gets the CountryID of the Group with the given SpawnPrefix
SPAWN:_GetGroupFromDCSUnit(DCSUnit) | Return the group within the SpawnGroups collection with input a DCSUnit.
SPAWN:_GetGroupIndexFromDCSUnit(DCSUnit) | Get the group index from a DCSUnit.
SPAWN:_GetLastIndex() | Return the last maximum index that can be used.
SPAWN:_GetPrefixFromDCSUnit(DCSUnit) | Return the prefix of a DCSUnit.
SPAWN:_GetSpawnIndex(SpawnIndex) | Get the next index of the groups to be spawned.
SPAWN:_GetTemplate(SpawnTemplatePrefix) | Gets the Group Template from the ME environment definition.
SPAWN:_InitializeSpawnGroups(SpawnIndex) | Initalize the SpawnGroups collection.
SPAWN:_OnBirth(event) |
SPAWN:_OnDeadOrCrash(event) | Obscolete
SPAWN:_OnEngineShutDown(event) | Will detect AIR Units shutting down their engines ...
SPAWN:_OnLand(event) | Will detect AIR Units landing...
SPAWN:_OnTakeOff(event) | Will detect AIR Units taking off...
SPAWN:_Prepare(SpawnTemplatePrefix, SpawnIndex) | Prepares the new Group Template.
SPAWN:_RandomizeRoute(SpawnIndex) | Internal function randomizing the routes.
SPAWN:_RandomizeTemplate(SpawnIndex) |
SPAWN:_Scheduler() | This function is called automatically by the Spawning scheduler.
SPAWN:_SpawnCleanUpScheduler() |
SPAWN:_TranslateRotate(SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle) |

## Global(s)

#SPAWN SPAWN

## Type `Spawn`

SPAWN Class

### Field(s)

#number SPAWN.AliveFactor

SPAWN:Array(SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY)

  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.

  ### Parameters

  - `#number SpawnAngle` :

            The angle in degrees how the groups and each unit of the group will be positioned.

  - `#number SpawnWidth` :

             The amount of Groups that will be positioned on the X axis.

  - `#number SpawnDeltaX` :

           The space between each Group on the X-axis.

  - `#number SpawnDeltaY` :

             The space between each Group on the Y-axis.

  ### Return value

  #SPAWN: self

  ### Usage:

      -- Define an array of Groups.
      Spawn_BE_Ground = SPAWN:New( 'BE Ground' ):Limit( 2, 24 ):Visible( 90, "Diamond", 10, 100, 50 )

SPAWN.ClassName

SPAWN:CleanUp(SpawnCleanUpInterval)

  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.

  ### Parameter

  - `#string SpawnCleanUpInterval` : The interval to check for inactive groups within seconds.

  ### Return value

  #SPAWN: self

  ### Usage:

      Spawn_Helicopter:CleanUp( 20 )  -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.

SPAWN.CleanUpFunction

SPAWN:GetFirstAliveGroup(SpawnCursor)

  Find the first alive group.

  ### Parameter

  - `#number SpawnCursor` : A number holding the index from where to find the first group from.

  ### Return values

  1. Group#GROUP, #number: The group found, the new index where the group was found.

  2. #nil, #nil: When no group is found, #nil is returned.

SPAWN:GetGroupFromIndex(SpawnIndex)

  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.

  ### Parameter

  - `#number SpawnIndex` : The index of the group to return.

  ### Return value

  Group#GROUP:

SPAWN:GetLastAliveGroup()

  Find the last alive group during runtime.

SPAWN:GetNextAliveGroup(SpawnCursor)

  Find the next alive group.

  ### Parameter

  - `#number SpawnCursor` : A number holding the last found previous index.

  ### Return values

  1. Group#GROUP, #number: The group found, the new index where the group was found.

  2. #nil, #nil: When no group is found, #nil is returned.

SPAWN:GetSpawnIndexFromGroup(SpawnGroup)

  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.

  ### Parameter

  - `SpawnGroup` :

SPAWN:Limit(SpawnMaxUnitsAlive, 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.

  ### Parameters

  - `#number SpawnMaxUnitsAlive` : The maximum amount of units that can be alive at runtime.

  - `#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 value

  #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 )

SPAWN:New(SpawnTemplatePrefix)

  Creates the main object to spawn a GROUP defined in the DCS ME.

  ### Parameter

  - `#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 value

  #SPAWN:

  ### Usages:

  -     -- NATO helicopters engaging in the battle field.
        Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' )

  -     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.

SPAWN:NewWithAlias(SpawnTemplatePrefix, SpawnAliasPrefix)

  Creates a new SPAWN instance to create new groups based on the defined template and using a new alias for each new group.

  ### Parameters

  - `#string SpawnTemplatePrefix` : is the name of the Group in the ME that defines the Template.

  - `#string SpawnAliasPrefix` : is the name that will be given to the Group at runtime.

  ### Return value

  #SPAWN:

  ### Usages:

  -     -- NATO helicopters engaging in the battle field.
        Spawn_BE_KA50 = SPAWN:NewWithAlias( 'BE KA-50@RAMP-Ground Defense', 'Helicopter Attacking a City' )

  -     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.

SPAWN:RandomizeRoute(SpawnStartPoint, SpawnEndPoint, SpawnRadius)

  Randomizes the defined route of the SpawnTemplatePrefix group in the ME.

  This is very useful to define extra variation of the behaviour of groups.

  ### Parameters

  - `#number SpawnStartPoint` : is the waypoint where the randomization begins. Note that the StartPoint = 0 equaling the point where the group is spawned.

  - `#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.

  - `#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 value

  #SPAWN:

  ### Usage:

      -- NATO helicopters engaging in the battle field.
      -- 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 )

SPAWN:RandomizeTemplate(SpawnTemplatePrefixTable)

  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.

  ### Parameter

  - `#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 value

  #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
      -- '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',
                           '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 )

SPAWN:ReSpawn(SpawnIndex)

  Will re-spawn a group based on a given index.

  Note: Uses DATABASE module defined in MOOSE.

  ### Parameter

  - `#string SpawnIndex` : The index of the group to be spawned.

  ### Return value

  Group#GROUP: The group that was spawned. You can use this group for further actions.

SPAWN:Repeat()

  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 ...

  ### Return value

  #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()

#boolean SPAWN.RepeatOnEngineShutDown

#boolean SPAWN.RepeatOnLanding

SPAWN:Spawn()

  Will spawn a group based on the internal index.

  Note: Uses DATABASE module defined in MOOSE.

  ### Return value

  Group#GROUP: The group that was spawned. You can use this group for further actions.

#string SPAWN.SpawnAliasPrefix

SPAWN.SpawnCleanUpInterval

SPAWN.SpawnCleanUpTimeStamps

#number SPAWN.SpawnCurrentTimer

  The internal timer counter to trigger a scheduled spawning of SpawnTemplatePrefix.

SPAWN:SpawnFromUnit(HostUnit, OuterRadius, InnerRadius, SpawnIndex)

  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

  - `Unit#UNIT HostUnit` : The air or ground unit dropping or unloading the group.

  - `#number OuterRadius` : The outer radius in meters where the new group will be spawned.

  - `#number InnerRadius` : The inner radius in meters where the new group will NOT be spawned.

  - `#number SpawnIndex` : (Optional) The index which group to spawn within the given zone.

  ### Return values

  1. Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

SPAWN:SpawnFunction(SpawnFunctionHook, SpawnFunctionArguments, ...)

  Allows to place a CallFunction hook when a new group spawns.

  The provided function will be called when a new group is spawned, including its given parameters. The first parameter of the SpawnFunction is the Group#GROUP that was spawned.

  ### Parameters

  - `#function SpawnFunctionHook` : The function to be called when a group spawns.

  - `SpawnFunctionArguments` : A random amount of arguments to be provided to the function when the group spawns.

  - `...` :

  ### Return value

  #SPAWN:

SPAWN.SpawnFunctionArguments

SPAWN.SpawnFunctionHook

SPAWN:SpawnGroupName(SpawnIndex)

  Will return the SpawnGroupName either with with a specific count number or without any count.

  ### Parameter

  - `#number SpawnIndex` : Is the number of the Group that is to be spawned.

  ### Return value

  #string: SpawnGroupName

#number SPAWN.SpawnHighTimer

SPAWN:SpawnInZone(Zone, ZoneRandomize, SpawnIndex)

  Will spawn a Group within a given Zone#ZONE.

  Once the group is spawned within the zone, it will continue on its route. The first waypoint (where the group is spawned) is replaced with the zone coordinates.

  ### Parameters

  - `Zone#ZONE Zone` : The zone where the group is to be spawned.

  - `#number ZoneRandomize` : (Optional) Set to true if you want to randomize the starting point in the zone.

  - `#number SpawnIndex` : (Optional) The index which group to spawn within the given zone.

  ### Return values

  1. Group#GROUP: that was spawned.

  2. #nil: when nothing was spawned.

#number SPAWN.SpawnLowTimer

SPAWN.SpawnMaxGroups

  The maximum amount of groups that can be spawned.

SPAWN.SpawnMaxUnitsAlive

  The maximum amount of groups that can be alive of SpawnTemplatePrefix at the same time.

#boolean SPAWN.SpawnRandomizeRoute

SPAWN.SpawnRandomizeRouteEndPoint

SPAWN.SpawnRandomizeRouteRadius

SPAWN.SpawnRandomizeRouteStartPoint

#boolean SPAWN.SpawnRandomizeTemplate

#boolean SPAWN.SpawnRepeat

SPAWN:SpawnScheduleStart()

  Will start the spawning scheduler.

  Note: This function is called automatically when SPAWN.Scheduled is called.

SPAWN:SpawnScheduleStop()

  Will stop the scheduled spawning scheduler.

SPAWN:SpawnScheduled(SpawnTime, SpawnTimeVariation)

  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.

  ### Parameters

  - `#number SpawnTime` : The time interval defined in seconds between each new spawn of new groups.

  - `#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 value

  #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%.
      -- 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 )

#number SPAWN.SpawnSetTimer

  The internal timer value when a scheduled spawning of SpawnTemplatePrefix occurs.

#string SPAWN.SpawnTemplatePrefix

SPAWN.SpawnTemplatePrefixTable

#boolean SPAWN.SpawnVisible

  When the first Spawn executes, all the Groups need to be made visible before start.

SPAWN:SpawnWithIndex(SpawnIndex)

  Will spawn a group with a specified index number.

  Uses DATABASE global object defined in MOOSE.

  ### Parameter

  - `SpawnIndex` :

  ### Return value

  Group#GROUP: The group that was spawned. You can use this group for further actions.

SPAWN:UnControlled()

  Will spawn a plane group in uncontrolled mode...

  This will be similar to the uncontrolled flag setting in the ME.

  ### Return value

  #SPAWN: self

SPAWN:_GetGroupCategoryID(SpawnPrefix)

  Gets the CategoryID of the Group with the given SpawnPrefix

  ### Parameter

  - `SpawnPrefix` :

SPAWN:_GetGroupCoalitionID(SpawnPrefix)

  Gets the CoalitionID of the Group with the given SpawnPrefix

  ### Parameter

  - `SpawnPrefix` :

SPAWN:_GetGroupCountryID(SpawnPrefix)

  Gets the CountryID of the Group with the given SpawnPrefix

  ### Parameter

  - `SpawnPrefix` :

SPAWN:_GetGroupFromDCSUnit(DCSUnit)

  Return the group within the SpawnGroups collection with input a DCSUnit.

  ### Parameter

  - `DCSUnit` :

SPAWN:_GetGroupIndexFromDCSUnit(DCSUnit)

  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.

  ### Parameter

  - `DCSUnit` : The DCS unit to be searched.

  ### Return values

  1. #string: The prefix

  2. #nil: Nothing found

SPAWN:_GetLastIndex()

  Return the last maximum index that can be used.

SPAWN:_GetPrefixFromDCSUnit(DCSUnit)

  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.

  ### Parameter

  - `DCSUnit` : The DCS unit to be searched.

  ### Return values

  1. #string: The prefix

  2. #nil: Nothing found

SPAWN:_GetSpawnIndex(SpawnIndex)

  Get the next index of the groups to be spawned.

  This function is complicated, as it is used at several spaces.

  ### Parameter

  - `SpawnIndex` :

SPAWN:_GetTemplate(SpawnTemplatePrefix)

  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.

  ### Parameter

  - `SpawnTemplatePrefix` :

SPAWN:_InitializeSpawnGroups(SpawnIndex)

  Initalize the SpawnGroups collection.

  ### Parameter

  - `SpawnIndex` :

SPAWN:_OnBirth(event)

  TODO Need to delete this... _DATABASE does this now ...

  ### Parameter

  - `event` :

SPAWN:_OnDeadOrCrash(event)

  Obscolete

  ### Parameter

  - `event` :

SPAWN:_OnEngineShutDown(event)

  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. But only when the Unit was registered to have landed.

  ### Parameter

  - `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.

  ### Parameter

  - `event` :

SPAWN:_OnTakeOff(event)

  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.

  ### Parameter

  - `event` :

SPAWN:_Prepare(SpawnTemplatePrefix, SpawnIndex)

  Prepares the new Group Template.

  ### Parameters

  - `SpawnTemplatePrefix` :

  - `SpawnIndex` :

SPAWN:_RandomizeRoute(SpawnIndex)

  Internal function randomizing the routes.

  ### Parameter

  - `#number SpawnIndex` : The index of the group to be spawned.

  ### Return value

  #SPAWN:

SPAWN:_RandomizeTemplate(SpawnIndex)

  ### Parameter

  - `SpawnIndex` :

SPAWN:_Scheduler()

  This function is called automatically by the Spawning scheduler.

  It is the internal worker method SPAWNing new Groups on the defined time intervals.

SPAWN:_SpawnCleanUpScheduler()

SPAWN:_TranslateRotate(SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle)

  ### Parameters

  - `SpawnIndex` :

  - `SpawnRootX` :

  - `SpawnRootY` :

  - `SpawnX` :

  - `SpawnY` :

  - `SpawnAngle` :