Class SPAWN

Dynamic spawning of Groups and Units.

Info:

  • Author: Flightcontrol

Private

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:_GetTemplate (SpawnTemplatePrefix) Gets the Group Template from the ME environment definition.
SPAWN:_Prepare (SpawnTemplatePrefix, SpawnIndex) Prepares the new Group Template.

Events

SPAWN:OnBirth (event) Obscolete
SPAWN:OnDeadOrCrash (event) Obscolete
SPAWN:OnTakeOff (event) Will detect AIR Units taking off...
SPAWN:OnLand (event) Will detect AIR Units landing...
SPAWN:OnEngineShutDown (event) Will detect AIR Units shutting down their engines ...

Scheduled

SPAWN:_Scheduler () This function is called automatically by the Spawning scheduler.

Public

SPAWN:New (SpawnTemplatePrefix) Creates the main object to spawn a Group defined in the DCS ME.
SPAWN:NewWithAlias (SpawnTemplatePrefix) Creates the main object to spawn a Group defined in the DCS ME.
SPAWN:Limit (SpawnMaxGroupsAlive, SpawnMaxGroups) 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.
SPAWN:RandomizeRoute (SpawnStartPoint, SpawnEndPoint, SpawnRadius) Randomizes a defined route of the Template Group in the ME when the Group is Spawned.
SPAWN:RandomizeTemplate (SpawnTemplatePrefixTable) This function is rather complicated to understand.
SPAWN:Repeat () When a Group got SPAWNed, it has a life within the DCSRTE.
SPAWN:RepeatOnLanding () Same as the @{Repeat) method.
SPAWN:RepeatOnEngineShutDown () Same as the @{Repeat) method, but now the Group will respawn after its engines have shut down.
SPAWN:SpawnArray (SpawnZone, SpawnAngle, SpawnFormation, SpawnWidth, SpawnDeltaX, SpawnDeltaY) Makes the Groups visible before start (like a batallion).
SPAWN:Spawn () Will SPAWN a Group whenever you want to do this.
SPAWN:ReSpawn (SpawnGroupName) Will Re-SPAWN a Group based on a given GroupName.
SPAWN:SpawnWithIndex (SpawnIndex) Will SPAWN a Group with a specified index number whenever you want to do this.
SPAWN:SpawnScheduled (SpawnTime, SpawnTimeVariation) SPAWNs a new Group within varying time intervals.
SPAWN:ScheduleStart () Will start the SPAWNing timers.
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...
SPAWN:SpawnFromUnit (HostUnit) Will SPAWN a Group from a Hosting UNIT.
SPAWN:SpawnInZone (The) Will spawn a Group within a given ZONE.
SPAWN:SpawnGroupName (SpawnIndex) Will return the SpawnGroupName either with with a specific count number or without any count.


Private

SPAWN:_GetGroupCategoryID (SpawnPrefix)
Gets the CategoryID of the Group with the given SpawnPrefix

Parameters:

  • SpawnPrefix
SPAWN:_GetGroupCoalitionID (SpawnPrefix)
Gets the CoalitionID of the Group with the given SpawnPrefix

Parameters:

  • SpawnPrefix
SPAWN:_GetGroupCountryID (SpawnPrefix)
Gets the CountryID of the Group with the given SpawnPrefix

Parameters:

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

Parameters:

  • SpawnTemplatePrefix
SPAWN:_Prepare (SpawnTemplatePrefix, SpawnIndex)
Prepares the new Group Template.

Parameters:

  • SpawnTemplatePrefix
  • SpawnIndex

Events

SPAWN:OnBirth (event)
Obscolete

Parameters:

  • event
SPAWN:OnDeadOrCrash (event)
Obscolete

Parameters:

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

Parameters:

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

Parameters:

  • event

See also:

Scheduled

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.

Public

SPAWN:New (SpawnTemplatePrefix)
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.

Returns:

    SPAWN

Usage:

     -- NATO helicopters engaging in the battle field.
     Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' )
SPAWN:NewWithAlias (SpawnTemplatePrefix)
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.

Returns:

    SPAWN

Usage:

     -- NATO helicopters engaging in the battle field.
     Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' )
SPAWN:Limit (SpawnMaxGroupsAlive, SpawnMaxGroups)
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.

Returns:

    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 )
SPAWN:RandomizeRoute (SpawnStartPoint, SpawnEndPoint, SpawnRadius)
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.

Parameters:

  • SpawnStartPoint number 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...
  • SpawnEndPoint number 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.
  • SpawnRadius number 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...

Returns:

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

  • SpawnTemplatePrefixTable table{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 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.

Returns:

    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:Repeat ()
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.

Returns:

    SPAWN

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()
SPAWN:RepeatOnLanding ()
Same as the @{Repeat) method.

Returns:

    SPAWN

See also:

SPAWN:RepeatOnEngineShutDown ()
Same as the @{Repeat) method, but now the Group will respawn after its engines have shut down.

Returns:

    SPAWN

See also:

SPAWN:SpawnArray (SpawnZone, SpawnAngle, SpawnFormation, SpawnWidth, SpawnDeltaX, SpawnDeltaY)
Makes the Groups visible before start (like a batallion).

Parameters:

  • SpawnZone number A ZONE where the group will be positioned. The X and Y coordinates of the zone define the start position.
  • SpawnAngle number The angle in degrees how the Groups and each Unit of the Group will be positioned.
  • SpawnFormation number The formation of the Units within the Group.
  • SpawnWidth number The amount of Groups that will be positioned on the X axis.
  • SpawnDeltaX number The space between each Group on the X-axis.
  • SpawnDeltaY number The space between each Group on the Y-axis.

Returns:

    SPAWN

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 )
SPAWN:Spawn ()
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.

Returns:

    SPAWN
SPAWN:ReSpawn (SpawnGroupName)
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, ...

Parameters:

Returns:

    SPAWN Uses _Database global object defined in MOOSE.
SPAWN:SpawnWithIndex (SpawnIndex)
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.
SPAWN:SpawnScheduled (SpawnTime, SpawnTimeVariation)
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.

Returns:

    SPAWN

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.

Returns:

    SPAWN
SPAWN:SpawnFromUnit (HostUnit)
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:

  • HostUnit UNIT is the AIR unit or GROUND unit dropping or unloading the Spawn group.

Returns:

  1. GROUP Spawned.
  2. nil when nothing was spawned.
SPAWN:SpawnInZone (The)
Will spawn a Group within a given ZONE.

Parameters:

  • The ZONE ZONE where the Group is to be SPAWNed.

Returns:

  1. GROUP that was spawned.
  2. nil when nothing as spawned.
SPAWN:SpawnGroupName (SpawnIndex)
Will return the SpawnGroupName either with with a specific count number or without any count.

Parameters:

  • SpawnIndex number is the number of the Group that is to be SPAWNed.

Returns:

    string SpawnGroupName
generated by LDoc 1.4.3 Last updated 2016-03-14 10:50:59