Module Spawn

Core -- SPAWN class dynamically spawns new groups of units in your missions.

Banner Image


The documentation of the SPAWN class can be found further in this document.


Demo Missions


YouTube Playlist


Author: FlightControl

Contributions: A lot of people within this community!


Global(s)

SPAWN

SPAWN class, extends Base#BASE

-- Banner Image


The SPAWN class allows to spawn dynamically new groups.

Type SPAWN

SPAWN.AIOnOff
SPAWN.AliveUnits
SPAWN.ClassName
SPAWN.CleanUpScheduler
SPAWN.DelayOnOff
SPAWN:GetCoordinate()

Get the Coordinate of the Group that is Late Activated as the template for the SPAWN object.

SPAWN:GetFirstAliveGroup()

Will find the first alive Group it has spawned, and return the alive Group object and the first Index where the first alive Group object has been found.

SPAWN:GetGroupFromIndex(SpawnIndex)

Get the group from an index.

SPAWN:GetLastAliveGroup()

Will find the last alive Group object, and will return a reference to the last live Group object and the last Index where the last alive Group object has been found.

SPAWN:GetNextAliveGroup(SpawnIndexStart)

Will find the next alive Group object from a given Index, and return a reference to the alive Group object and the next Index where the alive Group has been found.

SPAWN:GetSpawnIndexFromGroup(SpawnGroup)

Get the index from a given group.

SPAWN.Grouping
SPAWN:InitAIOff()

Turns the AI Off for the Group when spawning.

SPAWN:InitAIOn()

Turns the AI On for the Group when spawning.

SPAWN:InitAIOnOff(AIOnOff)
SPAWN:InitArray(SpawnAngle, SpawnWidth, SpawnDeltaX, SpawnDeltaY)

Makes the groups visible before start (like a batallion).

SPAWN:InitCategory(Category)
SPAWN:InitCleanUp(SpawnCleanUpInterval)

CleanUp groups when they are still alive, but inactive.

SPAWN:InitCoalition(Coalition)
SPAWN:InitCountry(Country)
SPAWN:InitDelayOff()

Turns the Delay Off for the Group when spawning.

SPAWN:InitDelayOn()

Turns the Delay On for the Group when spawning.

SPAWN:InitDelayOnOff(DelayOnOff)
SPAWN:InitGrouping(Grouping)

When spawning a new group, make the grouping of the units according the InitGrouping setting.

SPAWN:InitHeading(HeadingMin, HeadingMax)

Defines the Heading for the new spawned units.

SPAWN:InitKeepUnitNames(KeepUnitNames)

Keeps the unit names as defined within the mission editor, but note that anything after a # mark is ignored, and any spaces before and after the resulting name are removed.

SPAWN:InitLateActivated(LateActivated)

Flags that the spawned groups must be spawned late activated.

SPAWN:InitLimit(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:InitRandomizePosition(RandomizePosition, OuterRadius, InnerRadius)

Randomizes the position of Groups that are spawned within a radius band, given an Outer and Inner radius, from the point that the spawn happens.

SPAWN:InitRandomizeRoute(SpawnStartPoint, SpawnEndPoint, SpawnRadius, SpawnHeight)

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

SPAWN:InitRandomizeTemplate(SpawnTemplatePrefixTable)

This method is rather complicated to understand.

SPAWN:InitRandomizeTemplatePrefixes(SpawnTemplatePrefixes)

Randomize templates to be used as the unit representatives for the Spawned group, defined by specifying the prefix names.

SPAWN:InitRandomizeTemplateSet(SpawnTemplateSet)

Randomize templates to be used as the unit representatives for the Spawned group, defined using a SET_GROUP object.

SPAWN:InitRandomizeUnits(RandomizeUnits, OuterRadius, InnerRadius)

Randomizes the UNITs that are spawned within a radius band given an Outer and Inner radius.

SPAWN:InitRandomizeZones(SpawnZoneTable)
SPAWN:InitRepeat()

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:InitRepeatOnEngineShutDown()

Respawn after landing when its engines have shut down.

SPAWN:InitRepeatOnLanding()

Respawn group after landing.

SPAWN:InitUnControlled(UnControlled)

(AIR) Will spawn a plane group in UnControlled or Controlled mode...

SPAWN.LateActivated
SPAWN.MaxAliveGroups
SPAWN.MaxAliveUnits
SPAWN:New(SpawnTemplatePrefix)

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

SPAWN:NewFromTemplate(SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPrefix)

Creates a new SPAWN instance to create new groups based on the provided template.

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:OnSpawnGroup(SpawnCallBackFunction, SpawnFunctionArguments, ...)

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

SPAWN:ReSpawn(SpawnIndex)

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

SPAWN.Repeat
SPAWN.RepeatOnEngineShutDown
SPAWN.RepeatOnLanding
SPAWN:Spawn()

Will spawn a group based on the internal index.

SPAWN.SpawnAliasPrefix
SPAWN:SpawnAtAirbase(SpawnAirbase, Takeoff, TakeoffAltitude)

Will spawn a group at an Airbase.

SPAWN.SpawnCleanUpInterval
SPAWN.SpawnCleanUpTimeStamps
SPAWN.SpawnCount
SPAWN:SpawnFromCoordinate(Coordinate, SpawnIndex)

Will spawn a group from a Coordinate in 3D space.

SPAWN:SpawnFromPointVec2(PointVec2, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a POINT_VEC2 in 3D space.

SPAWN:SpawnFromPointVec3(PointVec3, SpawnIndex)

Will spawn a group from a PointVec3 in 3D space.

SPAWN:SpawnFromStatic(HostStatic, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a hosting static.

SPAWN:SpawnFromUnit(HostUnit, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a hosting unit.

SPAWN:SpawnFromVec2(Vec2, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a Vec2 in 3D space.

SPAWN:SpawnFromVec3(Vec3, SpawnIndex)

Will spawn a group from a Vec3 in 3D space.

SPAWN.SpawnFunctionArguments
SPAWN.SpawnFunctionHook
SPAWN:SpawnGroupName(SpawnIndex)

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

SPAWN.SpawnGrouping
SPAWN.SpawnGroups
SPAWN.SpawnHookScheduler
SPAWN:SpawnInZone(Zone, RandomizeGroup, MinHeight, MaxHeight, SpawnIndex)

Will spawn a Group within a given Zone.

SPAWN.SpawnIndex
SPAWN.SpawnInitHeadingMax
SPAWN.SpawnInitHeadingMin
SPAWN.SpawnInitKeepUnitNames
SPAWN.SpawnInitLimit
SPAWN.SpawnInnerRadius
SPAWN.SpawnIsScheduled
SPAWN.SpawnMaxGroups
SPAWN.SpawnMaxUnitsAlive
SPAWN.SpawnOuterRadius
SPAWN.SpawnRandomize
SPAWN.SpawnRandomizePosition
SPAWN.SpawnRandomizePositionInnerRadius
SPAWN.SpawnRandomizePositionOuterRadius
SPAWN.SpawnRandomizeRoute
SPAWN.SpawnRandomizeRouteEndPoint
SPAWN.SpawnRandomizeRouteHeight
SPAWN.SpawnRandomizeRouteRadius
SPAWN.SpawnRandomizeRouteStartPoint
SPAWN.SpawnRandomizeTemplate
SPAWN.SpawnRandomizeUnits
SPAWN:SpawnScheduleStart()

Will re-start the spawning scheduler.

SPAWN:SpawnScheduleStop()

Will stop the scheduled spawning scheduler.

SPAWN:SpawnScheduled(SpawnTime, SpawnTimeVariation)

Spawns new groups at varying time intervals.

SPAWN.SpawnScheduler
SPAWN.SpawnTemplate
SPAWN.SpawnTemplatePrefix
SPAWN.SpawnTemplatePrefixTable
SPAWN.SpawnUnControlled
SPAWN.SpawnVisible
SPAWN:SpawnWithIndex(SpawnIndex)

Will spawn a group with a specified index number.

SPAWN.SpawnZoneTable
SPAWN.Takeoff
SPAWN.UnControlled
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:_GetLastIndex()

Return the last maximum index that can be used.

SPAWN:_GetPrefixFromGroup(DCSUnit, SpawnGroup)

Return the prefix of a SpawnUnit.

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(EventData)
SPAWN:_OnDeadOrCrash(EventData)
SPAWN:_OnEngineShutDown(EventData)

Will detect AIR Units shutting down their engines ...

SPAWN:_OnLand(EventData)

Will detect AIR Units landing...

SPAWN:_OnTakeOff(EventData)

Will detect AIR Units taking off...

SPAWN:_Prepare(SpawnTemplatePrefix, SpawnIndex)

Prepares the new Group Template.

SPAWN:_RandomizeRoute(SpawnIndex)

Private method randomizing the routes.

SPAWN:_RandomizeTemplate(SpawnIndex)

Private method that randomizes the template of the group.

SPAWN:_RandomizeZones(SpawnIndex)

Private method that randomizes the Zones where the Group will be spawned.

SPAWN:_Scheduler()

This function is called automatically by the Spawning scheduler.

SPAWN:_SpawnCleanUpScheduler()

Schedules the CleanUp of Groups

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

Global(s)

#SPAWN SPAWN

SPAWN class, extends Base#BASE

-- Banner Image


The SPAWN class allows to spawn dynamically new groups.

Each SPAWN object needs to be have related template groups setup in the Mission Editor (ME), which is a normal group with the Late Activation flag set. This template group will never be activated in your mission.
SPAWN uses that template group to reference to all the characteristics (air, ground, livery, unit composition, formation, skill level etc) of each new group to be spawned.

Therefore, when creating a SPAWN object, the SPAWN.New and SPAWN.NewWithAlias require the name of the template group to be given as a string to those constructor methods.

Initialization settings can be applied on the SPAWN object, which modify the behaviour or the way groups are spawned. These initialization methods have the prefix Init. There are also spawn methods with the prefix Spawn and will spawn new groups in various ways.

IMPORTANT! The methods with prefix Init must be used before any methods with prefix Spawn method are used, or unexpected results may appear!!!

Because SPAWN can spawn multiple groups of a template group, SPAWN has an internal index that keeps track which was the latest group that was spawned.

Limits can be set on how many groups can be spawn in each SPAWN object, using the method SPAWN.InitLimit. SPAWN has 2 kind of limits:

  • The maximum amount of Units that can be alive at the same time...
  • The maximum amount of Groups that can be spawned... This is more of a resource-type of limit.

When new groups get spawned using the Spawn methods, it will be evaluated whether any limits have been reached. When no spawn limit is reached, a new group will be created by the spawning methods, and the internal index will be increased with 1.

These limits ensure that your mission does not accidentally get flooded with spawned groups.
Additionally, it also guarantees that independent of the group composition, at any time, the most optimal amount of groups are alive in your mission. For example, if your template group has a group composition of 10 units, and you specify a limit of 100 units alive at the same time, with unlimited resources = :InitLimit( 100, 0 ) and 10 groups are alive, but two groups have only one unit alive in the group, then a sequent Spawn(Scheduled) will allow a new group to be spawned!!!

IMPORTANT!! If a limit has been reached, it is possible that a Spawn method returns nil, meaning, no Group had been spawned!!!

Spawned groups get the same name as the name of the template group.
Spawned units in those groups keep by default the same name as the name of the template group.
However, because multiple groups and units are created from the template group, a suffix is added to each spawned group and unit.

Newly spawned groups will get the following naming structure at run-time:

  1. Spawned groups will have the name _GroupName#nnn_, where GroupName is the name of the template group, and nnn is a counter from 0 to 999.
  2. Spawned units will have the name _GroupName#nnn-uu_, where uu is a counter from 0 to 99 for each new spawned unit belonging to the group.

That being said, there is a way to keep the same unit names!
The method SPAWN.InitKeepUnitNames() will keep the same unit names as defined within the template group, thus:

  1. Spawned units will have the name _UnitName#nnn-uu_, where UnitName is the unit name as defined in the template group*, and uu is a **counter from 0 to 99 for each new spawned unit belonging to the group.

Some additional notes that need to be considered!!:

  • 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 represents the GROUP template (definition).
  • SPAWN.NewWithAlias(): Creates a new SPAWN object taking the name of the group that represents the GROUP template (definition), and gives each spawned Group an different name.

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 methods 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, which all start with the Init prefix:

Unit Names

  • SPAWN.InitKeepUnitNames(): Keeps the unit names as defined within the mission editor, but note that anything after a # mark is ignored, and any spaces before and after the resulting name are removed. IMPORTANT! This method MUST be the first used after :New !!!

Route randomization

Group composition randomization

  • SPAWN.InitRandomizeTemplate(): Randomize the group templates so that when a new group is spawned, a random group template is selected from one of the templates defined.

Uncontrolled

Array formation

  • SPAWN.InitArray(): Make groups visible before they are actually activated, and order these groups like a batallion in an array.

Position randomization

  • SPAWN.InitRandomizePosition(): Randomizes the position of Groups that are spawned within a radius band, given an Outer and Inner radius, from the point that the spawn happens.
  • SPAWN.InitRandomizeUnits(): Randomizes the Units in the Group that is spawned within a radius band, given an Outer and Inner radius.
  • SPAWN.InitRandomizeZones(): Randomizes the spawning between a predefined list of Zones that are declared using this function. Each zone can be given a probability factor.

Enable / Disable AI when spawning a new Group

Limit scheduled spawning

  • SPAWN.InitLimit(): Limits the amount of groups that can be alive at the same time and that can be dynamically spawned.

Delay initial scheduled spawn

Repeat spawned Groups upon landing

SPAWN Spawn methods

Groups can be spawned at different times and methods:

Single spawning methods

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.

Scheduled spawning methods

Retrieve alive GROUPs spawned by the SPAWN object

The SPAWN class administers which GROUPS it has reserved (in stock) or has created during mission execution. Every time a SPAWN object spawns a new GROUP object, a reference to the GROUP object is added to an internal table of GROUPS. SPAWN provides methods to iterate through that internal GROUP object reference table:

  • SPAWN.GetFirstAliveGroup(): Will find the first alive GROUP it has spawned, and return the alive GROUP object and the first Index where the first alive GROUP object has been found.
  • SPAWN.GetNextAliveGroup(): Will find the next alive GROUP object from a given Index, and return a reference to the alive GROUP object and the next Index where the alive GROUP has been found.
  • SPAWN.GetLastAliveGroup(): Will find the last alive GROUP object, and will return a reference to the last live GROUP object and the last Index where the last alive GROUP object has been found.

You can use the methods SPAWN.GetFirstAliveGroup() and sequently SPAWN.GetNextAliveGroup() to iterate through the alive GROUPS within the SPAWN object, and to actions... See the respective methods for an example. The method SPAWN.GetGroupFromIndex() will return the GROUP object reference from the given Index, dead or alive...

Spawned cleaning of inactive groups

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.InitCleanUp() 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.InitCleanUp() for further info.

Catch the Group Spawn Event in a callback function!

When using the SPAWN.SpawnScheduleds are created following the spawn time interval parameters. When a new Group is spawned, you maybe want to execute actions with that group spawned at the spawn event. The SPAWN class supports this functionality through the method SPAWN.OnSpawnGroup( *function( SpawnedGroup ) end * ), which takes a function as a parameter that you can define locally. Whenever a new Group is spawned, the given function is called, and the Group that was just spawned, is given as a parameter. As a result, your spawn event handling function requires one parameter to be declared, which will contain the spawned Group object. A coding example is provided at the description of the SPAWN.OnSpawnGroup( *function( SpawnedGroup ) end * ) method.

Delay the initial spawning

When using the SPAWN.SpawnScheduled immediately when :SpawnScheduled() is initiated. The methods SPAWN.InitDelayOnOff() and SPAWN.InitDelayOn() can be used to activate a delay before the first Group is spawned. For completeness, a method SPAWN.InitDelayOff() is also available, that can be used to switch off the initial delay. Because there is no delay by default, this method would only be used when a SPAWN.SpawnScheduledStop() ; SPAWN.SpawnScheduledStart() sequence would have been used.

Type Spawn

Type SPAWN

SPAWN Class

Field(s)

#boolean SPAWN.AIOnOff

The AI is on by default when spawning a group.

#number SPAWN.AliveUnits
SPAWN.ClassName
SPAWN.CleanUpScheduler

self.CleanUpFunction = routines.scheduleFunction( self._SpawnCleanUpScheduler, { self }, timer.getTime() + 1, SpawnCleanUpInterval )

#boolean SPAWN.DelayOnOff

No intial delay when spawning the first group.

SPAWN:GetCoordinate()

Get the Coordinate of the Group that is Late Activated as the template for the SPAWN object.

Return value

Core.Point#COORDINATE: The Coordinate

SPAWN:GetFirstAliveGroup()

Will find the first alive Group it has spawned, and return the alive Group object and the first Index where the first alive Group object has been found.

Return values

  1. Wrapper.Group#GROUP, #number: The Group object found, the new Index where the group was found.

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

Usage:

-- Find the first alive @{Group} object of the SpawnPlanes SPAWN object @{Group} collection that it has spawned during the mission.
local GroupPlane, Index = SpawnPlanes:GetFirstAliveGroup()
while GroupPlane ~= nil do
  -- Do actions with the GroupPlane object.
  GroupPlane, Index = SpawnPlanes:GetNextAliveGroup( Index )
end
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

Wrapper.Group#GROUP: self

SPAWN:GetLastAliveGroup()

Will find the last alive Group object, and will return a reference to the last live Group object and the last Index where the last alive Group object has been found.

Return values

  1. Wrapper.Group#GROUP, #number: The last alive Group object found, the last Index where the last alive Group object was found.

  2. #nil, #nil: When no alive Group object is found, #nil is returned.

Usage:

-- Find the last alive @{Group} object of the SpawnPlanes SPAWN object @{Group} collection that it has spawned during the mission.
local GroupPlane, Index = SpawnPlanes:GetLastAliveGroup()
if GroupPlane then -- GroupPlane can be nil!!!
  -- Do actions with the GroupPlane object.
end
SPAWN:GetNextAliveGroup(SpawnIndexStart)

Will find the next alive Group object from a given Index, and return a reference to the alive Group object and the next Index where the alive Group has been found.

Parameter

  • #number SpawnIndexStart : A Index holding the start position to search from. This method can also be used to find the first alive Group object from the given Index.

Return values

  1. Wrapper.Group#GROUP, #number: The next alive Group object found, the next Index where the next alive Group object was found.

  2. #nil, #nil: When no alive Group object is found from the start Index position, #nil is returned.

Usage:

-- Find the first alive @{Group} object of the SpawnPlanes SPAWN object @{Group} collection that it has spawned during the mission.
local GroupPlane, Index = SpawnPlanes:GetFirstAliveGroup()
while GroupPlane ~= nil do
  -- Do actions with the GroupPlane object.
  GroupPlane, Index = SpawnPlanes:GetNextAliveGroup( Index )
end
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.Grouping

No grouping

SPAWN:InitAIOff()

Turns the AI Off for the Group when spawning.

Return value

#SPAWN: The SPAWN object

SPAWN:InitAIOn()

Turns the AI On for the Group when spawning.

Return value

#SPAWN: The SPAWN object

SPAWN:InitAIOnOff(AIOnOff)

Parameter

  • AIOnOff :

SPAWN:InitArray(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' )
  :InitLimit( 2, 24 )
  :InitArray( 90, 10, 100, 50 )
  
SPAWN:InitCategory(Category)

Parameter

  • Category :

SPAWN:InitCleanUp(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:InitCleanUp( 20 )  -- CleanUp the spawning of the helicopters every 20 seconds when they become inactive.
SPAWN:InitCoalition(Coalition)

Parameter

  • Coalition :

SPAWN:InitCountry(Country)

Parameter

  • Country :

SPAWN:InitDelayOff()

Turns the Delay Off for the Group when spawning.

Return value

#SPAWN: The SPAWN object

SPAWN:InitDelayOn()

Turns the Delay On for the Group when spawning.

Return value

#SPAWN: The SPAWN object

SPAWN:InitDelayOnOff(DelayOnOff)

Parameter

  • DelayOnOff :

SPAWN:InitGrouping(Grouping)

When spawning a new group, make the grouping of the units according the InitGrouping setting.

Parameter

  • #number Grouping : Indicates the maximum amount of units in the group.

Return value

#SPAWN:

SPAWN:InitHeading(HeadingMin, HeadingMax)

Defines the Heading for the new spawned units.

The heading can be given as one fixed degree, or can be randomized between minimum and maximum degrees.

Parameters

  • #number HeadingMin : The minimum or fixed heading in degrees.

  • #number HeadingMax : (optional) The maximum heading in degrees. This there is no maximum heading, then the heading will be fixed for all units using minimum heading.

Return value

#SPAWN: self

Usage:


Spawn = SPAWN:New( ... )

-- Spawn the units pointing to 100 degrees.
Spawn:InitHeading( 100 )

-- Spawn the units pointing between 100 and 150 degrees.
Spawn:InitHeading( 100, 150 )
SPAWN:InitKeepUnitNames(KeepUnitNames)

Keeps the unit names as defined within the mission editor, but note that anything after a # mark is ignored, and any spaces before and after the resulting name are removed.

IMPORTANT! This method MUST be the first used after :New !!!

Parameter

  • #boolean KeepUnitNames : (optional) If true, the unit names are kept, false or not provided to make new unit names.

Return value

#SPAWN: self

SPAWN:InitLateActivated(LateActivated)

Flags that the spawned groups must be spawned late activated.

Parameter

  • #boolean LateActivated : (optional) If true, the spawned groups are late activated.

Return value

#SPAWN: self

SPAWN:InitLimit(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 method 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' ):InitLimit( 2, 24 )
SPAWN:InitRandomizePosition(RandomizePosition, OuterRadius, InnerRadius)

Randomizes the position of Groups that are spawned within a radius band, given an Outer and Inner radius, from the point that the spawn happens.

Parameters

  • #boolean RandomizePosition : If true, SPAWN will perform the randomization of the Groups position between a given outer and inner radius.

  • Dcs.DCSTypes#Distance OuterRadius : (optional) The outer radius in meters where the new group will be spawned.

  • Dcs.DCSTypes#Distance InnerRadius : (optional) The inner radius in meters where the new group will NOT be spawned.

Return value

#SPAWN:

SPAWN:InitRandomizeRoute(SpawnStartPoint, SpawnEndPoint, SpawnRadius, SpawnHeight)

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

  • #number SpawnHeight : (optional) Specifies the additional height in meters that can be added to the base height specified at each waypoint in the ME.

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' ):InitRandomizeRoute( 2, 2, 2000 )
SPAWN:InitRandomizeTemplate(SpawnTemplatePrefixTable)

This method is rather complicated to understand.

But I'll try to explain. This method 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' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 )
Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 )
Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 )
SPAWN:InitRandomizeTemplatePrefixes(SpawnTemplatePrefixes)

Randomize templates to be used as the unit representatives for the Spawned group, defined by specifying the prefix names.

This method 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 SpawnTemplatePrefixes : A string or a list of string that contains the prefixes of the groups that are possible unit representatives of the group to be spawned.

Return value

#SPAWN:

Usage:

-- NATO Tank Platoons invading Gori.

-- Choose between different 'US Tank Platoon Templates' configurations to be spawned for the 
-- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SPAWN objects.

-- 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_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 )
Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 )
Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 )
SPAWN:InitRandomizeTemplateSet(SpawnTemplateSet)

Randomize templates to be used as the unit representatives for the Spawned group, defined using a SET_GROUP object.

This method 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

  • Core.Set#SET_GROUP SpawnTemplateSet : A SET_GROUP object set, that contains the groups that are possible unit representatives of the group to be spawned.

Return value

#SPAWN:

Usage:

-- NATO Tank Platoons invading Gori.

-- Choose between different 'US Tank Platoon Template' configurations to be spawned for the 
-- 'US Tank Platoon Left', 'US Tank Platoon Middle' and 'US Tank Platoon Right' SPAWN objects.

-- 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_PlatoonSet = SET_GROUP:New():FilterPrefixes( "US Tank Platoon Templates" ):FilterOnce()

--- Now use the Spawn_US_PlatoonSet to define the templates using InitRandomizeTemplateSet.
Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 )
Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 )
Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 )
SPAWN:InitRandomizeUnits(RandomizeUnits, OuterRadius, InnerRadius)

Randomizes the UNITs that are spawned within a radius band given an Outer and Inner radius.

Parameters

  • #boolean RandomizeUnits : If true, SPAWN will perform the randomization of the UNITs position within the group between a given outer and inner radius.

  • Dcs.DCSTypes#Distance OuterRadius : (optional) The outer radius in meters where the new group will be spawned.

  • Dcs.DCSTypes#Distance InnerRadius : (optional) The inner radius in meters where the new group will NOT be spawned.

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' ):InitRandomizeRoute( 2, 2, 2000 )
SPAWN:InitRandomizeZones(SpawnZoneTable)

TODO: Add example. - This method provides the functionality to randomize the spawning of the Groups at a given list of zones of different types. @param #SPAWN self @param #table SpawnZoneTable A table with Zone objects. If this table is given, then each spawn will be executed within the given list of Zones objects. @return #SPAWN @usage -- NATO Tank Platoons invading Gori. -- Choose between 3 different zones for each new SPAWN the Group to be executed, regardless of the zone type.

Parameter

  • SpawnZoneTable :

SPAWN:InitRepeat()

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 method 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( 'Su-34' )
  :Schedule( 2, 3, 1800, 0.4 )
  :SpawnUncontrolled()
  :InitRandomizeRoute( 1, 1, 3000 )
  :InitRepeatOnEngineShutDown()
  
SPAWN:InitRepeatOnEngineShutDown()

Respawn after landing when its engines have shut down.

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( 'Su-34' )
  :Schedule( 2, 3, 1800, 0.4 )
  :SpawnUncontrolled()
  :InitRandomizeRoute( 1, 1, 3000 )
  :InitRepeatOnEngineShutDown()
  
SPAWN:InitRepeatOnLanding()

Respawn group after landing.

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( 'Su-34' )
  :Schedule( 2, 3, 1800, 0.4 )
  :SpawnUncontrolled()
  :InitRandomizeRoute( 1, 1, 3000 )
  :InitRepeatOnLanding()
  
SPAWN:InitUnControlled(UnControlled)

(AIR) Will spawn a plane group in UnControlled or Controlled mode...

This will be similar to the uncontrolled flag setting in the ME. You can use UnControlled mode to simulate planes startup and ready for take-off but aren't moving (yet). ReSpawn the plane in Controlled mode, and the plane will move...

Parameter

  • #boolean UnControlled : true if UnControlled, false if Controlled.

Return value

#SPAWN: self

SPAWN.LateActivated
#number SPAWN.MaxAliveGroups
#number SPAWN.MaxAliveUnits
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:NewFromTemplate(SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPrefix)

Creates a new SPAWN instance to create new groups based on the provided template.

Parameters

  • #table SpawnTemplate : is the Template of the Group. This must be a valid Group Template structure!

  • #string SpawnTemplatePrefix : is the name of the Group that will be given at each spawn.

  • #string SpawnAliasPrefix : (optional) is the name that will be given to the Group at runtime.

Return value

#SPAWN:

Usages:

  • -- Create a new SPAWN object based on a Group Template defined from scratch.
    Spawn_BE_KA50 = SPAWN:NewWithAlias( 'BE KA-50@RAMP-Ground Defense', 'Helicopter Attacking a City' )
  • 
    -- Create a new CSAR_Spawn object based on a normal Group Template to spawn a soldier.
    local CSAR_Spawn = SPAWN:NewWithFromTemplate( Template, "CSAR", "Pilot" )
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:OnSpawnGroup(SpawnCallBackFunction, SpawnFunctionArguments, ...)

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

The provided method 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 SpawnCallBackFunction : 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:

Usage:

-- Declare SpawnObject and call a function when a new Group is spawned.
local SpawnObject = SPAWN
  :New( "SpawnObject" )
  :InitLimit( 2, 10 )
  :OnSpawnGroup(
    function( SpawnGroup )
      SpawnGroup:E( "I am spawned" )
    end 
    )
  :SpawnScheduled( 300, 0.3 )
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

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

#boolean SPAWN.Repeat
#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

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

#string SPAWN.SpawnAliasPrefix
SPAWN:SpawnAtAirbase(SpawnAirbase, Takeoff, TakeoffAltitude)

Will spawn a group at an Airbase.

This method is mostly advisable to be used if you want to simulate spawning units at an airbase. 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.

The Airbase#AIRBASE object must refer to a valid airbase known in the sim. You can use the following enumerations to search for the pre-defined airbases on the current known maps of DCS:

Use the method Airbase#AIRBASE.FindByName() to retrieve the airbase object. The known AIRBASE objects are automatically imported at mission start by MOOSE. Therefore, there isn't any New() constructor defined for AIRBASE objects.

Ships and Farps are added within the mission, and are therefore not known. For these AIRBASE objects, there isn't an Airbase#AIRBASE enumeration defined. You need to provide the exact name of the airbase as the parameter to the Airbase#AIRBASE.FindByName() method!

Parameters

  • Wrapper.Airbase#AIRBASE SpawnAirbase : The Airbase where to spawn the group.

  • #SPAWN.Takeoff Takeoff : (optional) The location and takeoff method. Default is Hot.

  • #number TakeoffAltitude : (optional) The altitude above the ground.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

Usage:

  Spawn_Plane = SPAWN:New( "Plane" )
  Spawn_Plane:SpawnAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Krymsk ), SPAWN.Takeoff.Cold )
  Spawn_Plane:SpawnAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Krymsk ), SPAWN.Takeoff.Hot )
  Spawn_Plane:SpawnAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Krymsk ), SPAWN.Takeoff.Runway )
  
  Spawn_Plane:SpawnAtAirbase( AIRBASE:FindByName( "Carrier" ), SPAWN.Takeoff.Cold )
  
  Spawn_Heli = SPAWN:New( "Heli")
  
  Spawn_Heli:SpawnAtAirbase( AIRBASE:FindByName( "FARP Cold" ), SPAWN.Takeoff.Cold )
  Spawn_Heli:SpawnAtAirbase( AIRBASE:FindByName( "FARP Hot" ), SPAWN.Takeoff.Hot )
  Spawn_Heli:SpawnAtAirbase( AIRBASE:FindByName( "FARP Runway" ), SPAWN.Takeoff.Runway )
  Spawn_Heli:SpawnAtAirbase( AIRBASE:FindByName( "FARP Air" ), SPAWN.Takeoff.Air )
  
  Spawn_Heli:SpawnAtAirbase( AIRBASE:FindByName( "Carrier" ), SPAWN.Takeoff.Cold )
SPAWN.SpawnCleanUpInterval
SPAWN.SpawnCleanUpTimeStamps
#number SPAWN.SpawnCount

The internal counter of the amount of spawning the has happened since SpawnStart.

SPAWN:SpawnFromCoordinate(Coordinate, SpawnIndex)

Will spawn a group from a Coordinate in 3D space.

This method is mostly advisable to be used if you want to simulate spawning units in the air, like helicopters or airplanes. 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

  • Core.Point#Coordinate Coordinate : The Coordinate coordinates where to spawn the group.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

SPAWN:SpawnFromPointVec2(PointVec2, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a POINT_VEC2 in 3D space.

This method is mostly advisable to be used if you want to simulate spawning groups on the ground from air units, like vehicles. 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

  • Core.Point#POINT_VEC2 PointVec2 : The PointVec2 coordinates where to spawn the group.

  • #number MinHeight : (optional) The minimum height to spawn an airborne group into the zone.

  • #number MaxHeight : (optional) The maximum height to spawn an airborne group into the zone.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

Usage:


  local SpawnPointVec2 = ZONE:New( ZoneName ):GetPointVec2()

  -- Spawn at the zone center position at the height specified in the ME of the group template!
  SpawnAirplanes:SpawnFromPointVec2( SpawnPointVec2 )  
  
  -- Spawn from the static position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnFromPointVec2( SpawnPointVec2, 2000, 4000 )  
SPAWN:SpawnFromPointVec3(PointVec3, SpawnIndex)

Will spawn a group from a PointVec3 in 3D space.

This method is mostly advisable to be used if you want to simulate spawning units in the air, like helicopters or airplanes. 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

  • Core.Point#POINT_VEC3 PointVec3 : The PointVec3 coordinates where to spawn the group.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

Usage:


  local SpawnPointVec3 = ZONE:New( ZoneName ):GetPointVec3( 2000 ) -- Get the center of the ZONE object at 2000 meters from the ground.

  -- Spawn at the zone center position at 2000 meters from the ground!
  SpawnAirplanes:SpawnFromPointVec3( SpawnPointVec3 )  
  
SPAWN:SpawnFromStatic(HostStatic, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a hosting static.

This method is mostly advisable to be used if you want to simulate spawning from buldings and structures (static buildings). You can use the returned group to further define the route to be followed.

Parameters

  • Wrapper.Static#STATIC HostStatic : The static dropping or unloading the group.

  • #number MinHeight : (optional) The minimum height to spawn an airborne group into the zone.

  • #number MaxHeight : (optional) The maximum height to spawn an airborne group into the zone.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

Usage:


  local SpawnStatic = STATIC:FindByName( StaticName )

  -- Spawn from the static position at the height specified in the ME of the group template!
  SpawnAirplanes:SpawnFromStatic( SpawnStatic )  
  
  -- Spawn from the static position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnFromStatic( SpawnStatic, 2000, 4000 )  
SPAWN:SpawnFromUnit(HostUnit, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a hosting unit.

This method 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

  • Wrapper.Unit#UNIT HostUnit : The air or ground unit dropping or unloading the group.

  • #number MinHeight : (optional) The minimum height to spawn an airborne group into the zone.

  • #number MaxHeight : (optional) The maximum height to spawn an airborne group into the zone.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

Usage:


  local SpawnStatic = STATIC:FindByName( StaticName )

  -- Spawn from the static position at the height specified in the ME of the group template!
  SpawnAirplanes:SpawnFromUnit( SpawnStatic )  
  
  -- Spawn from the static position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnFromUnit( SpawnStatic, 2000, 4000 )  
SPAWN:SpawnFromVec2(Vec2, MinHeight, MaxHeight, SpawnIndex)

Will spawn a group from a Vec2 in 3D space.

This method is mostly advisable to be used if you want to simulate spawning groups on the ground from air units, like vehicles. 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

  • Dcs.DCSTypes#Vec2 Vec2 : The Vec2 coordinates where to spawn the group.

  • #number MinHeight : (optional) The minimum height to spawn an airborne group into the zone.

  • #number MaxHeight : (optional) The maximum height to spawn an airborne group into the zone.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

Usage:


  local SpawnVec2 = ZONE:New( ZoneName ):GetVec2()

  -- Spawn at the zone center position at the height specified in the ME of the group template!
  SpawnAirplanes:SpawnFromVec2( SpawnVec2 )  
  
  -- Spawn from the static position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnFromVec2( SpawnVec2, 2000, 4000 )  
SPAWN:SpawnFromVec3(Vec3, SpawnIndex)

Will spawn a group from a Vec3 in 3D space.

This method is mostly advisable to be used if you want to simulate spawning units in the air, like helicopters or airplanes. 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

  • Dcs.DCSTypes#Vec3 Vec3 : The Vec3 coordinates where to spawn the group.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: Nothing was spawned.

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

SPAWN.SpawnGrouping
SPAWN.SpawnGroups

Array containing the descriptions of each Group to be Spawned.

SPAWN.SpawnHookScheduler
SPAWN:SpawnInZone(Zone, RandomizeGroup, MinHeight, MaxHeight, SpawnIndex)

Will spawn a Group within a given Zone.

The Zone can be of any type derived from Zone#ZONE_BASE. Once the Group is spawned within the zone, the Group will continue on its route. The first waypoint (where the group is spawned) is replaced with the zone location coordinates.

Parameters

  • Core.Zone#ZONE Zone : The zone where the group is to be spawned.

  • #boolean RandomizeGroup : (optional) Randomization of the Group position in the zone.

  • #number MinHeight : (optional) The minimum height to spawn an airborne group into the zone.

  • #number MaxHeight : (optional) The maximum height to spawn an airborne group into the zone.

  • #number SpawnIndex : (optional) The index which group to spawn within the given zone.

Return values

  1. Wrapper.Group#GROUP: that was spawned.

  2. #nil: when nothing was spawned.

Usage:


  local SpawnZone = ZONE:New( ZoneName )

  -- Spawn at the zone center position at the height specified in the ME of the group template!
  SpawnAirplanes:SpawnInZone( SpawnZone )  
  
  -- Spawn in the zone at a random position at the height specified in the Me of the group template.
  SpawnAirplanes:SpawnInZone( SpawnZone, true )  
  
  -- Spawn in the zone at a random position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnInZone( SpawnZone, true, 2000, 4000 )  

  -- Spawn at the zone center position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnInZone( SpawnZone, false, 2000, 4000 )  
  
  -- Spawn at the zone center position at the height randomized between 2000 and 4000 meters.
  SpawnAirplanes:SpawnInZone( SpawnZone, nil, 2000, 4000 )  
  
#number SPAWN.SpawnIndex
SPAWN.SpawnInitHeadingMax
SPAWN.SpawnInitHeadingMin
#boolean SPAWN.SpawnInitKeepUnitNames

Overwrite unit names by default with group name.

#boolean SPAWN.SpawnInitLimit
SPAWN.SpawnInnerRadius
#boolean SPAWN.SpawnIsScheduled

Reflects if the spawning for this SpawnTemplatePrefix is going to be scheduled or not.

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.

SPAWN.SpawnOuterRadius
#boolean SPAWN.SpawnRandomize

Sets the randomization flag of new Spawned units to false.

SPAWN.SpawnRandomizePosition
SPAWN.SpawnRandomizePositionInnerRadius
SPAWN.SpawnRandomizePositionOuterRadius
#boolean SPAWN.SpawnRandomizeRoute
SPAWN.SpawnRandomizeRouteEndPoint
SPAWN.SpawnRandomizeRouteHeight
SPAWN.SpawnRandomizeRouteRadius
SPAWN.SpawnRandomizeRouteStartPoint
#boolean SPAWN.SpawnRandomizeTemplate
SPAWN.SpawnRandomizeUnits
SPAWN:SpawnScheduleStart()

Will re-start the spawning scheduler.

Note: This method is only required to be called when the schedule was stopped.

Return value

#SPAWN:

SPAWN:SpawnScheduleStop()

Will stop the scheduled spawning scheduler.

Return value

#SPAWN:

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 )
SPAWN.SpawnScheduler
SPAWN.SpawnTemplate

Contains the template structure for a Group Spawn from the Mission Editor. Note that this group must have lateActivation always on!!!

#string SPAWN.SpawnTemplatePrefix
SPAWN.SpawnTemplatePrefixTable
SPAWN.SpawnUnControlled
#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

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

Return value

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

#SPAWN.SpawnZoneTable SPAWN.SpawnZoneTable
#SPAWN.Takeoff SPAWN.Takeoff
#boolean SPAWN.UnControlled

When working in UnControlled mode, all planes are Spawned in UnControlled mode before the scheduler starts.

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:_GetLastIndex()

Return the last maximum index that can be used.

SPAWN:_GetPrefixFromGroup(DCSUnit, SpawnGroup)

Return the prefix of a SpawnUnit.

The method will search for a #-mark, and will return the text before the #-mark. It will return nil of no prefix was found.

Parameters

Return values

  1. #string: The prefix

  2. #nil: Nothing found

SPAWN:_GetSpawnIndex(SpawnIndex)

Get the next index of the groups to be spawned.

This method 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

  • #string SpawnTemplatePrefix :

Return value

@SPAWN self

SPAWN:_InitializeSpawnGroups(SpawnIndex)

Initalize the SpawnGroups collection.

Parameter

  • SpawnIndex :

SPAWN:_OnBirth(EventData)

Parameter

SPAWN:_OnDeadOrCrash(EventData)

Parameter

SPAWN:_OnEngineShutDown(EventData)

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

SPAWN:_OnLand(EventData)

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

SPAWN:_OnTakeOff(EventData)

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

SPAWN:_Prepare(SpawnTemplatePrefix, SpawnIndex)

Prepares the new Group Template.

Parameters

  • #string SpawnTemplatePrefix :

  • #number SpawnIndex :

Return value

#SPAWN: self

SPAWN:_RandomizeRoute(SpawnIndex)

Private method randomizing the routes.

Parameter

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

Return value

#SPAWN:

SPAWN:_RandomizeTemplate(SpawnIndex)

Private method that randomizes the template of the group.

Parameter

  • #number SpawnIndex :

Return value

#SPAWN: self

SPAWN:_RandomizeZones(SpawnIndex)

Private method that randomizes the Zones where the Group will be spawned.

Parameter

  • #number SpawnIndex :

Return value

#SPAWN: self

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

Schedules the CleanUp of Groups

Return value

#boolean: True = Continue Scheduler

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

Parameters

  • SpawnIndex :

  • SpawnRootX :

  • SpawnRootY :

  • SpawnX :

  • SpawnY :

  • SpawnAngle :

Type SPAWN.SpawnZoneTable

Type SPAWN.Takeoff

Enumerator for spawns at airbases