Banner Image

Module Core.Spawn

Core - Spawn dynamically new groups of units in running missions.

Features:

  • Spawn new groups in running missions.
  • Schedule spawning of new groups.
  • Put limits on the amount of groups that can be spawned, and the amount of units that can be alive at the same time.
  • Randomize the spawning location between different zones.
  • Randomize the initial positions within the zones.
  • Spawn in array formation.
  • Spawn uncontrolled (for planes or helos only).
  • Clean up inactive helicopters that "crashed".
  • Place a hook to capture a spawn event, and tailor with customer code.
  • Spawn late activated.
  • Spawn with or without an initial delay.
  • Respawn after landing, on the runway or at the ramp after engine shutdown.
  • Spawn with custom heading, both for a group formation and for the units in the group.
  • Spawn with different skills.
  • Spawn with different liveries.
  • Spawn with an inner and outer radius to set the initial position.
  • Spawn with a randomize route.
  • Spawn with a randomized template.
  • Spawn with a randomized start points on a route.
  • Spawn with an alternative name.
  • Spawn and keep the unit names.
  • Spawn with a different coalition and country.
  • Enquiry methods to check on spawn status.

Demo Missions


YouTube Playlist


Author: FlightControl

Contributions: A lot of people within this community!


Global(s)

Global SPAWN

Allows to spawn dynamically new Core.Groups.

#SPAWN SPAWN

Allows to spawn dynamically new Core.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 Wrapper.Units that can be alive at the same time...
  • The maximum amount of Wrapper.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 Wrapper.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 Wrapper.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

Enable / Disable AI when spawning a new Wrapper.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 Wrapper.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 Wrapper.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 Wrapper.Group Spawn Event in a callback function!

When using the SPAWN.SpawnScheduleds are created following the spawn time interval parameters. When a new Wrapper.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 Wrapper.Group is spawned, the given function is called, and the Wrapper.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 Wrapper.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 Wrapper.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.SpawnScheduleStop() ; SPAWN.SpawnScheduleStart() sequence would have been used.

Type(s)

SPAWN , extends Core.Base#BASE
Fields and Methods inherited from SPAWN Description

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 Wrapper.Group it has spawned, and return the alive Wrapper.Group object and the first Index where the first alive Wrapper.Group object has been found.

SPAWN:GetGroupFromIndex(SpawnIndex)

Get the group from an index.

SPAWN:GetLastAliveGroup()

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

SPAWN:GetNextAliveGroup(SpawnIndexStart)

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

SPAWN:GetSpawnIndexFromGroup(SpawnGroup)

Get the index from a given group.

SPAWN:InitAIOff()

Turns the AI Off for the Wrapper.Group when spawning.

SPAWN:InitAIOn()

Turns the AI On for the Wrapper.Group when spawning.

SPAWN:InitAIOnOff(AIOnOff)

SPAWN:InitAirbase(AirbaseName, Takeoff, TerminalTyple, TerminalType)

Set spawns to happen at a particular airbase.

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

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

SPAWN:InitCategory(Category)

Sets category ID of the group.

SPAWN:InitCleanUp(SpawnCleanUpInterval)

CleanUp groups when they are still alive, but inactive.

SPAWN:InitCoalition(Coalition)

Sets the coalition of the spawned group.

SPAWN:InitCountry(Country)

Sets the country of the spawn group.

SPAWN:InitDelayOff()

Turns the Delay Off for the Wrapper.Group when spawning.

SPAWN:InitDelayOn()

Turns the Delay On for the Wrapper.Group when spawning.

SPAWN:InitDelayOnOff(DelayOnOff)

SPAWN:InitGroupHeading(HeadingMin, HeadingMax, unitVar)

Defines the heading of the overall formation of the new spawned group.

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:InitLivery(Livery)

Sets livery of the group.

SPAWN:InitModex(modex)

Sets the modex of the first unit of the group.

SPAWN:InitRadioCommsOnOff(switch)

Sets the radio comms on or off.

SPAWN:InitRadioFrequency(frequency)

Sets the radio frequency of the group.

SPAWN:InitRadioModulation(modulation)

Set radio modulation.

SPAWN:InitRandomizePosition(RandomizePosition, OuterRadius, InnerRadius)

Randomizes the position of Wrapper.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)

This method provides the functionality to randomize the spawning of the Groups at a given list of zones of different types.

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:InitSkill(Skill)

Sets skill of the group.

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 Wrapper.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:ParkAircraft(SpawnAirbase, TerminalType, Parkingdata, SpawnIndex)

Will park a group at an Wrapper.Airbase.

SPAWN:ParkAtAirbase(SpawnAirbase, TerminalType, Parkingdata)

Will park a group at an Wrapper.Airbase.

SPAWN:ReSpawn(SpawnIndex)

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

SPAWN.Repeat

SPAWN.RepeatOnEngineShutDown

SPAWN.RepeatOnLanding

SPAWN:SetSpawnIndex(SpawnIndex)

Set the spawn index to a specified index number.

SPAWN:Spawn()

Will spawn a group based on the internal index.

SPAWN.SpawnAliasPrefix

SPAWN:SpawnAtAirbase(SpawnAirbase, Takeoff, TakeoffAltitude, TerminalType, EmergencyAirSpawn, Parkingdata)

Will spawn a group at an Wrapper.Airbase.

SPAWN:SpawnAtParkingSpot(Airbase, Spots, Takeoff)

Spawn a group on an Wrapper.Airbase at a specific parking spot.

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

SPAWN.SpawnInitCategory

SPAWN.SpawnInitCoalition

SPAWN.SpawnInitCountry

SPAWN.SpawnInitFreq

SPAWN.SpawnInitGroupHeadingMax

SPAWN.SpawnInitGroupHeadingMin

SPAWN.SpawnInitGroupUnitVar

SPAWN.SpawnInitHeadingMax

SPAWN.SpawnInitHeadingMin

SPAWN.SpawnInitKeepUnitNames

SPAWN.SpawnInitLimit

SPAWN.SpawnInitLivery

SPAWN.SpawnInitModex

SPAWN.SpawnInitModu

SPAWN.SpawnInitRadio

SPAWN.SpawnInitSkill

SPAWN.SpawnInitTakeoff

SPAWN.SpawnInitTerminalType

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

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, NoBirth)

Will spawn a group with a specified index number.

SPAWN.SpawnZoneTable

SPAWN.Takeoff

SPAWN.TweakedTemplate

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)

Fields and Methods inherited from BASE Description

SPAWN.ClassID

The ID number of the class.

SPAWN.ClassName

The name of the class.

SPAWN.ClassNameAndID

The name of the class concatenated with the ID number of the class.

SPAWN:ClearState(Object, StateName)

Clear the state of an object.

SPAWN:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace)

Creation of a Birth Event.

SPAWN:CreateEventCrash(EventTime, Initiator)

Creation of a Crash Event.

SPAWN:CreateEventDead(EventTime, Initiator)

Creation of a Dead Event.

SPAWN:CreateEventRemoveUnit(EventTime, Initiator)

Creation of a Remove Unit Event.

SPAWN:CreateEventTakeoff(EventTime, Initiator)

Creation of a Takeoff Event.

SPAWN:E(Arguments)

Log an exception which will be traced always.

SPAWN:EventDispatcher()

Returns the event dispatcher

SPAWN:EventRemoveAll()

Remove all subscribed events

SPAWN:F(Arguments)

Trace a function call.

SPAWN:F2(Arguments)

Trace a function call level 2.

SPAWN:F3(Arguments)

Trace a function call level 3.

SPAWN:GetClassID()

Get the ClassID of the class instance.

SPAWN:GetClassName()

Get the ClassName of the class instance.

SPAWN:GetClassNameAndID()

Get the ClassName + ClassID of the class instance.

SPAWN:GetEventPriority()

Get the Class Event processing Priority.

SPAWN:GetParent(Child, FromClass)

This is the worker method to retrieve the Parent class.

SPAWN:GetState(Object, Key)

Get a Value given a Key from the Object.

SPAWN:HandleEvent(Event, EventFunction)

Subscribe to a DCS Event.

SPAWN:I(Arguments)

Log an information which will be traced always.

SPAWN:Inherit(Child, Parent)

This is the worker method to inherit from a parent class.

SPAWN:IsInstanceOf(ClassName)

This is the worker method to check if an object is an (sub)instance of a class.

SPAWN:IsTrace()

Enquires if tracing is on (for the class).

SPAWN:New()

BASE constructor.

SPAWN:OnEvent(EventData)

Occurs when an object is completely destroyed.

SPAWN:OnEventBaseCaptured(EventData)

Occurs when a ground unit captures either an airbase or a farp.

SPAWN:OnEventBirth(EventData)

Occurs when any object is spawned into the mission.

SPAWN:OnEventCrash(EventData)

Occurs when any aircraft crashes into the ground and is completely destroyed.

SPAWN:OnEventDead(EventData)

Occurs when an object is dead.

SPAWN:OnEventDetailedFailure(EventData)

Unknown precisely what creates this event, likely tied into newer damage model.

SPAWN:OnEventEjection(EventData)

Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected

SPAWN:OnEventEngineShutdown(EventData)

Occurs when any aircraft shuts down its engines.

SPAWN:OnEventEngineStartup(EventData)

Occurs when any aircraft starts its engines.

SPAWN:OnEventHit(EventData)

Occurs whenever an object is hit by a weapon.

SPAWN:OnEventHumanFailure(EventData)

Occurs when any system fails on a human controlled aircraft.

SPAWN:OnEventKill(EventData)

Occurs on the death of a unit.

SPAWN:OnEventLand(EventData)

Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed place: Object that the unit landed on.

SPAWN:OnEventLandingAfterEjection(EventData)

Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up.

SPAWN:OnEventMarkAdded(EventData)

Occurs when a new mark was added.

SPAWN:OnEventMarkChange(EventData)

Occurs when a mark text was changed.

SPAWN:OnEventMarkRemoved(EventData)

Occurs when a mark was removed.

SPAWN:OnEventMissionEnd(EventData)

Occurs when a mission ends

SPAWN:OnEventMissionStart(EventData)

Occurs when a mission starts

SPAWN:OnEventPilotDead(EventData)

Occurs when the pilot of an aircraft is killed.

SPAWN:OnEventPlayerEnterUnit(EventData)

Occurs when any player assumes direct control of a unit.

SPAWN:OnEventPlayerLeaveUnit(EventData)

Occurs when any player relieves control of a unit to the AI.

SPAWN:OnEventRefueling(EventData)

Occurs when an aircraft connects with a tanker and begins taking on fuel.

SPAWN:OnEventRefuelingStop(EventData)

Occurs when an aircraft is finished taking fuel.

SPAWN:OnEventScore(EventData)

Occurs when any modification to the "Score" as seen on the debrief menu would occur.

SPAWN:OnEventShootingEnd(EventData)

Occurs when any unit stops firing its weapon.

SPAWN:OnEventShootingStart(EventData)

Occurs when any unit begins firing a weapon that has a high rate of fire.

SPAWN:OnEventShot(EventData)

Occurs whenever any unit in a mission fires a weapon.

SPAWN:OnEventTakeoff(EventData)

Occurs when an aircraft takes off from an airbase, farp, or ship.

SPAWN:OnEventUnitLost(EventData)

Occurs when the game thinks an object is destroyed.

SPAWN:ScheduleOnce(Start, SchedulerFunction, ...)

Schedule a new time event.

SPAWN:ScheduleRepeat(Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ...)

Schedule a new time event.

SPAWN:ScheduleStop(SchedulerFunction)

Stops the Schedule.

SPAWN.Scheduler

SPAWN:SetEventPriority(EventPriority)

Set the Class Event processing Priority.

SPAWN:SetState(Object, Key, Value)

Set a state or property of the Object given a Key and a Value.

SPAWN:T(Arguments)

Trace a function logic level 1.

SPAWN:T2(Arguments)

Trace a function logic level 2.

SPAWN:T3(Arguments)

Trace a function logic level 3.

SPAWN:TraceAll(TraceAll)

Trace all methods in MOOSE

SPAWN:TraceClass(Class)

Set tracing for a class

SPAWN:TraceClassMethod(Class, Method)

Set tracing for a specific method of class

SPAWN:TraceLevel(Level)

Set trace level

SPAWN:TraceOff()

Set trace off.

SPAWN:TraceOn()

Set trace on.

SPAWN:TraceOnOff(TraceOnOff)

Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

SPAWN:UnHandleEvent(Event)

UnSubscribe to a DCS event.

SPAWN._

SPAWN:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function call.

SPAWN:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function logic.

SPAWN.__

SPAWN:onEvent(event)

SPAWN Class

Field(s)

#boolean SPAWN.AIOnOff

The AI is on by default when spawning a group.

SPAWN.CleanUpScheduler

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

#boolean SPAWN.DelayOnOff

No intial delay when spawning the first group.

#boolean SPAWN.Repeat

Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.

#number SPAWN.SpawnCount

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

#table SPAWN.SpawnGroups

Array containing the descriptions of each Group to be Spawned.

#boolean SPAWN.SpawnInitKeepUnitNames

Overwrite unit names by default with group name.

#boolean SPAWN.SpawnInitLimit

By default, no InitLimit

#boolean SPAWN.SpawnIsScheduled

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

#number SPAWN.SpawnMaxGroups

The maximum amount of groups that can be spawned.

#number SPAWN.SpawnMaxUnitsAlive

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

#boolean SPAWN.SpawnRandomize

Sets the randomization flag of new Spawned units to false.

SPAWN.SpawnTemplate

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

#boolean SPAWN.SpawnVisible

Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.

#boolean SPAWN.TweakedTemplate

Check if the user is using self made template.

#boolean SPAWN.UnControlled

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

Function(s)

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

Defined in:

SPAWN

Return value:

The Coordinate

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

Defined in:

SPAWN

Return values:

The Wrapper.Group object found, the new Index where the group was found.

#nil, #nil:

When no group is found, #nil is returned.

Usage:

-- Find the first alive @{Wrapper.Group} object of the SpawnPlanes SPAWN object @{Wrapper.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

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.

Defined in:

SPAWN

Parameter:

#number SpawnIndex

The index of the group to return.

Return value:

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

Defined in:

SPAWN

Return values:

The last alive Wrapper.Group object found, the last Index where the last alive Wrapper.Group object was found.

#nil, #nil:

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

Usage:

-- Find the last alive @{Wrapper.Group} object of the SpawnPlanes SPAWN object @{Wrapper.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

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

Defined in:

SPAWN

Parameter:

#number SpawnIndexStart

A Index holding the start position to search from. This method can also be used to find the first alive Wrapper.Group object from the given Index.

Return values:

The next alive Wrapper.Group object found, the next Index where the next alive Wrapper.Group object was found.

#nil, #nil:

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

Usage:

-- Find the first alive @{Wrapper.Group} object of the SpawnPlanes SPAWN object @{Wrapper.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

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.

Defined in:

SPAWN

Parameter:

SpawnGroup

Turns the AI Off for the Wrapper.Group when spawning.

Defined in:

SPAWN

Return value:

The SPAWN object

Turns the AI On for the Wrapper.Group when spawning.

Defined in:

SPAWN

Return value:

The SPAWN object

Defined in:

SPAWN

Parameter:

AIOnOff

Set spawns to happen at a particular airbase.

Only for aircraft, of course.

Defined in:

SPAWN

Parameters:

#string AirbaseName

Name of the airbase.

#number Takeoff

(Optional) Takeoff type. Can be SPAWN.Takeoff.Hot (default), SPAWN.Takeoff.Cold or SPAWN.Takeoff.Runway.

#number TerminalTyple

(Optional) The terminal type.

TerminalType

Return value:

self

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. CAUTION: this directive will NOT work with OnSpawnGroup function.

Defined in:

SPAWN

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:

self

Usage:

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

Sets category ID of the group.

Defined in:

SPAWN

Parameter:

#number Category

Category id.

Return value:

self

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.

Defined in:

SPAWN

Parameter:

#string SpawnCleanUpInterval

The interval to check for inactive groups within seconds.

Return value:

self

Usage:


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

Sets the coalition of the spawned group.

Note that it might be necessary to also set the country explicitly!

Defined in:

SPAWN

Parameter:

DCS#coalition.side Coalition

Coalition of the group as number of enumerator:

Return value:

self

Sets the country of the spawn group.

Note that the country determins the coalition of the group depending on which country is defined to be on which side for each specific mission!

Defined in:

SPAWN

Parameter:

#number Country

Country id as number or enumerator:

Return value:

self

Turns the Delay Off for the Wrapper.Group when spawning.

Defined in:

SPAWN

Return value:

The SPAWN object

Turns the Delay On for the Wrapper.Group when spawning.

Defined in:

SPAWN

Return value:

The SPAWN object

Defined in:

SPAWN

Parameter:

DelayOnOff

Defines the heading of the overall formation of the new spawned group.

The heading can be given as one fixed degree, or can be randomized between minimum and maximum degrees. The Group's formation as laid out in its template will be rotated around the first unit in the group Group individual units facings will rotate to match. If InitHeading is also applied to this SPAWN then that will take precedence for individual unit facings. Note that InitGroupHeading does not rotate the groups route; only its initial facing!

Defined in:

SPAWN

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 for the group will be HeadingMin.

#number unitVar

(optional) Individual units within the group will have their heading randomized by +/- unitVar degrees. Default is zero.

Return value:

self

Usage:


mySpawner = SPAWN:New( ... )

-- Spawn the Group with the formation rotated +100 degrees around unit #1, compared to the mission template.
mySpawner:InitGroupHeading( 100 )

Spawn the Group with the formation rotated units between +100 and +150 degrees around unit #1, compared to the mission template, and with individual units varying by +/- 10 degrees from their templated facing.
mySpawner:InitGroupHeading( 100, 150, 10 )

Spawn the Group with the formation rotated -60 degrees around unit #1, compared to the mission template, but with all units facing due north regardless of how they were laid out in the template.
mySpawner:InitGroupHeading(-60):InitHeading(0)
 or
mySpawner:InitHeading(0):InitGroupHeading(-60)

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

Defined in:

SPAWN

Parameter:

#number Grouping

Indicates the maximum amount of units in the group.

Return value:

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.

Defined in:

SPAWN

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:

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 )

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

Defined in:

SPAWN

Parameter:

#boolean KeepUnitNames

(optional) If true, the unit names are kept, false or not provided to make new unit names.

Return value:

self

Flags that the spawned groups must be spawned late activated.

Defined in:

SPAWN

Parameter:

#boolean LateActivated

(optional) If true, the spawned groups are late activated.

Return value:

self

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.

Defined in:

SPAWN

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:

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 )

Sets livery of the group.

Defined in:

SPAWN

Parameter:

#string Livery

Livery name. Note that this is not necessarily the same name as displayed in the mission edior.

Return value:

self

Sets the modex of the first unit of the group.

If more units are in the group, the number is increased by one with every unit.

Defined in:

SPAWN

Parameter:

#number modex

Modex of the first unit.

Return value:

self

Sets the radio comms on or off.

Same as checking/unchecking the COMM box in the mission editor.

Defined in:

SPAWN

Parameter:

#number switch

If true (or nil), enables the radio comms. If false, disables the radio for the spawned group.

Return value:

self

Sets the radio frequency of the group.

Defined in:

SPAWN

Parameter:

#number frequency

The frequency in MHz.

Return value:

self

Set radio modulation.

Default is AM.

Defined in:

SPAWN

Parameter:

#string modulation

Either "FM" or "AM". If no value is given, modulation is set to AM.

Return value:

self

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

Defined in:

SPAWN

Parameters:

#boolean RandomizePosition

If true, SPAWN will perform the randomization of the Wrapper.Groups position between a given outer and inner radius.

DCS#Distance OuterRadius

(optional) The outer radius in meters where the new group will be spawned.

DCS#Distance InnerRadius

(optional) The inner radius in meters where the new group will NOT be spawned.

Return value:

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

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

Defined in:

SPAWN

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:

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 )

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.

Defined in:

SPAWN

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:

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 )

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.

Defined in:

SPAWN

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:

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 )

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.

Defined in:

SPAWN

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:

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 )

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

Defined in:

SPAWN

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#Distance OuterRadius

(optional) The outer radius in meters where the new group will be spawned.

DCS#Distance InnerRadius

(optional) The inner radius in meters where the new group will NOT be spawned.

Return value:

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 )

This method provides the functionality to randomize the spawning of the Groups at a given list of zones of different types.

Defined in:

SPAWN

Parameter:

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

Usage:

 -- Create a zone table of the 2 zones.
 ZoneTable = { ZONE:New( "Zone1" ), ZONE:New( "Zone2" ) }
 
 Spawn_Vehicle_1 = SPAWN:New( "Spawn Vehicle 1" )
   :InitLimit( 10, 10 )
   :InitRandomizeRoute( 1, 1, 200 ) 
   :InitRandomizeZones( ZoneTable )
   :SpawnScheduled( 5, .5 )
   

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

Defined in:

SPAWN

Return value:

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

Respawn after landing when its engines have shut down.

Defined in:

SPAWN

Return value:

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

Respawn group after landing.

Defined in:

SPAWN

Return value:

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

Sets skill of the group.

Defined in:

SPAWN

Parameter:

#string Skill

Skill, possible values "Average", "Good", "High", "Excellent" or "Random".

Return value:

self

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

Defined in:

SPAWN

Parameter:

#boolean UnControlled

true if UnControlled, false if Controlled.

Return value:

self

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

Defined in:

SPAWN

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:

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.

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

Defined in:

SPAWN

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:

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

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

Defined in:

SPAWN

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:

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.

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 Wrapper.Group#GROUP that was spawned.

Defined in:

SPAWN

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:

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 )
   

Will park a group at an Wrapper.Airbase.

Defined in:

SPAWN

Parameters:

The Wrapper.Airbase where to spawn the group.

(optional) The terminal type the aircraft should be spawned at. See Wrapper.Airbase#AIRBASE.TerminalType.

#table Parkingdata

(optional) Table holding the coordinates and terminal ids for all units of the group. Spawning will be forced to happen at exactily these spots!

SpawnIndex

Return value:

#nil:

Nothing is returned!

Will park a group at an Wrapper.Airbase.

This method is mostly advisable to be used if you want to simulate parking units at an airbase and be visible. Note that each point in the route assigned to the spawning group is reset to the point of the spawn.

All groups that are in the spawn collection and that are alive, and not in the air, are parked.

The Wrapper.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 Wrapper.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 Wrapper.Airbase#AIRBASE enumeration defined. You need to provide the exact name of the airbase as the parameter to the Wrapper.Airbase#AIRBASE.FindByName() method!

Defined in:

SPAWN

Parameters:

The Wrapper.Airbase where to spawn the group.

(optional) The terminal type the aircraft should be spawned at. See Wrapper.Airbase#AIRBASE.TerminalType.

#table Parkingdata

(optional) Table holding the coordinates and terminal ids for all units of the group. Spawning will be forced to happen at exactily these spots!

Return value:

#nil:

Nothing is returned!

Usage:

  Spawn_Plane = SPAWN:New( "Plane" )
  Spawn_Plane:ParkAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Krymsk ) )
  
  Spawn_Heli = SPAWN:New( "Heli")
  
  Spawn_Heli:ParkAtAirbase( AIRBASE:FindByName( "FARP Cold" ) )
  
  Spawn_Heli:ParkAtAirbase( AIRBASE:FindByName( "Carrier" ) )
  
  Spawn_Plane:ParkAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Krymsk ), AIRBASE.TerminalType.OpenBig )

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

Note: Uses DATABASE module defined in MOOSE.

Defined in:

SPAWN

Parameter:

#string SpawnIndex

The index of the group to be spawned.

Return value:

The group that was spawned. You can use this group for further actions.

Set the spawn index to a specified index number.

This method can be used to "reset" the spawn counter to a specific index number. This will actually enable a respawn of groups from the specific index.

Defined in:

SPAWN

Parameter:

#string SpawnIndex

The index of the group from where the spawning will start again. The default value would be 0, which means a complete reset of the spawnindex.

Return value:

self

Will spawn a group based on the internal index.

Note: Uses DATABASE module defined in MOOSE.

Defined in:

SPAWN

Return value:

The group that was spawned. You can use this group for further actions.

Will spawn a group at an Wrapper.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 Wrapper.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 Wrapper.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 Wrapper.Airbase#AIRBASE enumeration defined. You need to provide the exact name of the airbase as the parameter to the Wrapper.Airbase#AIRBASE.FindByName() method!

Defined in:

SPAWN

Parameters:

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

(optional) The terminal type the aircraft should be spawned at. See Wrapper.Airbase#AIRBASE.TerminalType.

#boolean EmergencyAirSpawn

(optional) If true (default), groups are spawned in air if there is no parking spot at the airbase. If false, nothing is spawned if no parking spot is available.

#table Parkingdata

(optional) Table holding the coordinates and terminal ids for all units of the group. Spawning will be forced to happen at exactily these spots!

Return value:

The group that was spawned or nil when 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_Plane:SpawnAtAirbase( AIRBASE:FindByName( AIRBASE.Caucasus.Krymsk ), SPAWN.Takeoff.Cold, nil, AIRBASE.TerminalType.OpenBig )

Spawn a group on an Wrapper.Airbase at a specific parking spot.

Defined in:

SPAWN

Parameters:

The Wrapper.Airbase where to spawn the group.

#table Spots

Table of parking spot IDs. Note that these in general are different from the numbering in the mission editor!

#SPAWN.Takeoff Takeoff

(Optional) Takeoff type, i.e. either SPAWN.Takeoff.Cold or SPAWN.Takeoff.Hot. Default is Hot.

Return value:

The group that was spawned or nil when nothing was spawned.

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.

Defined in:

SPAWN

Parameters:

The Coordinate coordinates where to spawn the group.

#number SpawnIndex

(optional) The index which group to spawn within the given zone.

Return values:

that was spawned.

#nil:

Nothing was spawned.

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.

Defined in:

SPAWN

Parameters:

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:

that was spawned.

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

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.

Defined in:

SPAWN

Parameters:

The PointVec3 coordinates where to spawn the group.

#number SpawnIndex

(optional) The index which group to spawn within the given zone.

Return values:

that was spawned.

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

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.

Defined in:

SPAWN

Parameters:

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:

that was spawned.

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

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.

Defined in:

SPAWN

Parameters:

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:

that was spawned.

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

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.

Defined in:

SPAWN

Parameters:

DCS#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:

that was spawned.

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

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.

Defined in:

SPAWN

Parameters:

DCS#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:

that was spawned.

#nil:

Nothing was spawned.

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

Defined in:

SPAWN

Parameter:

#number SpawnIndex

Is the number of the Group that is to be spawned.

Return value:

#string:

SpawnGroupName

Will spawn a Group within a given Zone.

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

Defined in:

SPAWN

Parameters:

The zone where the group is to be spawned.

#boolean RandomizeGroup

(optional) Randomization of the Wrapper.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:

that was spawned.

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

Will re-start the spawning scheduler.

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

Defined in:

SPAWN

Return value:

Will stop the scheduled spawning scheduler.

Defined in:

SPAWN

Return value:

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.

Defined in:

SPAWN

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:

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 )

Will spawn a group with a specified index number.

Uses DATABASE global object defined in MOOSE.

Defined in:

SPAWN

Parameters:

#string SpawnIndex

The index of the group to be spawned.

NoBirth

Return value:

The group that was spawned. You can use this group for further actions.

Gets the CategoryID of the Group with the given SpawnPrefix

Defined in:

SPAWN

Parameter:

SpawnPrefix

Gets the CoalitionID of the Group with the given SpawnPrefix

Defined in:

SPAWN

Parameter:

SpawnPrefix

Gets the CountryID of the Group with the given SpawnPrefix

Defined in:

SPAWN

Parameter:

SpawnPrefix

Return the last maximum index that can be used.

Defined in:

SPAWN

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.

Defined in:

SPAWN

Parameters:

DCS#UNIT DCSUnit

The DCSUnit to be searched.

SpawnGroup

Return values:

#string:

The prefix

#nil:

Nothing found

Get the next index of the groups to be spawned.

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

Defined in:

SPAWN

Parameter:

#number SpawnIndex

Spawn index.

Return value:

#number:

self.SpawnIndex

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.

Defined in:

SPAWN

Parameter:

#string SpawnTemplatePrefix

Return value:

@SPAWN self

Initalize the SpawnGroups collection.

Defined in:

SPAWN

Parameter:

SpawnIndex

Defined in:

SPAWN

Parameter:

Defined in:

SPAWN

Parameter:

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.

Defined in:

SPAWN

Parameter:

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.

Defined in:

SPAWN

Parameter:

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.

Defined in:

SPAWN

Parameter:

Prepares the new Group Template.

Defined in:

SPAWN

Parameters:

#string SpawnTemplatePrefix

#number SpawnIndex

Return value:

self

Private method randomizing the routes.

Defined in:

SPAWN

Parameter:

#number SpawnIndex

The index of the group to be spawned.

Return value:

Private method that randomizes the template of the group.

Defined in:

SPAWN

Parameter:

#number SpawnIndex

Return value:

self

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

Defined in:

SPAWN

Parameter:

#number SpawnIndex

Return value:

self

This function is called automatically by the Spawning scheduler.

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

Defined in:

SPAWN

Schedules the CleanUp of Groups

Defined in:

SPAWN

Return value:

#boolean:

True = Continue Scheduler

Defined in:

SPAWN

Parameters:

SpawnIndex

SpawnRootX

SpawnRootY

SpawnX

SpawnY

SpawnAngle

Field(s)

#boolean SPAWN.AIOnOff

The AI is on by default when spawning a group.

SPAWN.CleanUpScheduler

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

#boolean SPAWN.DelayOnOff

No intial delay when spawning the first group.

#boolean SPAWN.Repeat

Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.

#number SPAWN.SpawnCount

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

#table SPAWN.SpawnGroups

Array containing the descriptions of each Group to be Spawned.

#boolean SPAWN.SpawnInitKeepUnitNames

Overwrite unit names by default with group name.

#boolean SPAWN.SpawnInitLimit

By default, no InitLimit

#boolean SPAWN.SpawnIsScheduled

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

#number SPAWN.SpawnMaxGroups

The maximum amount of groups that can be spawned.

#number SPAWN.SpawnMaxUnitsAlive

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

#boolean SPAWN.SpawnRandomize

Sets the randomization flag of new Spawned units to false.

SPAWN.SpawnTemplate

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

#boolean SPAWN.SpawnVisible

Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.

#boolean SPAWN.TweakedTemplate

Check if the user is using self made template.

#boolean SPAWN.UnControlled

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

Function(s)

Clear the state of an object.

Defined in:

Parameters:

Object

The object that holds the Value set by the Key.

StateName

The key that is should be cleared.

Creation of a Birth Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

#string IniUnitName

The initiating unit name.

place

subplace

Creation of a Crash Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Dead Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Remove Unit Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Takeoff Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Log an exception which will be traced always.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Returns the event dispatcher

Defined in:

Return value:

Remove all subscribed events

Defined in:

Return value:

Trace a function call.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function call level 2.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function call level 3.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Get the ClassID of the class instance.

Defined in:

Return value:

#string:

The ClassID of the class instance.

Get the ClassName of the class instance.

Defined in:

Return value:

#string:

The ClassName of the class instance.

Get the ClassName + ClassID of the class instance.

The ClassName + ClassID is formatted as '%s#%09d'.

Defined in:

Return value:

#string:

The ClassName + ClassID of the class instance.

Get the Class Event processing Priority.

The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.

Defined in:

Return value:

#number:

The Event processing Priority.

This is the worker method to retrieve the Parent class.

Note that the Parent class must be passed to call the parent class method.

self:GetParent(self):ParentMethod()


Defined in:

Parameters:

#BASE Child

This is the Child class from which the Parent class needs to be retrieved.

#BASE FromClass

(Optional) The class from which to get the parent.

Return value:

Get a Value given a Key from the Object.

Note that if the Object is destroyed, nillified or garbage collected, then the Values and Keys will also be gone.

Defined in:

Parameters:

Object

The object that holds the Value set by the Key.

Key

The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!

Return value:

The Value retrieved or nil if the Key was not found and thus the Value could not be retrieved.

Subscribe to a DCS Event.

Defined in:

Parameters:

#function EventFunction

(optional) The function to be called when the event occurs for the unit.

Return value:

Log an information which will be traced always.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

This is the worker method to inherit from a parent class.

Defined in:

Parameters:

Child

is the Child class that inherits.

#BASE Parent

is the Parent class that the Child inherits from.

Return value:

Child

This is the worker method to check if an object is an (sub)instance of a class.

Examples:

  • ZONE:New( 'some zone' ):IsInstanceOf( ZONE ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'ZONE' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'zone' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'BASE' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'GROUP' ) will return false

Defined in:

Parameter:

ClassName

is the name of the class or the class itself to run the check against

Return value:

#boolean:

Enquires if tracing is on (for the class).

Defined in:

Return value:

#boolean:

BASE constructor.

This is an example how to use the BASE:New() constructor in a new class definition when inheriting from BASE.

function EVENT:New()
  local self = BASE:Inherit( self, BASE:New() ) -- #EVENT
  return self
end
  

Defined in:

Return value:

Occurs when an object is completely destroyed.

initiator : The unit that is was destroyed.

Defined in:

Parameter:

The EventData structure.

Occurs when a ground unit captures either an airbase or a farp.

initiator : The unit that captured the base place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.

Defined in:

Parameter:

The EventData structure.

Occurs when any object is spawned into the mission.

initiator : The unit that was spawned

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft crashes into the ground and is completely destroyed.

initiator : The unit that has crashed

Defined in:

Parameter:

The EventData structure.

Occurs when an object is dead.

initiator : The unit that is dead.

Defined in:

Parameter:

The EventData structure.

Unknown precisely what creates this event, likely tied into newer damage model.

Will update this page when new information become available.

  • initiator: The unit that had the failure.

Defined in:

Parameter:

The EventData structure.

Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft shuts down its engines.

initiator : The unit that is stopping its engines.

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft starts its engines.

initiator : The unit that is starting its engines.

Defined in:

Parameter:

The EventData structure.

Occurs whenever an object is hit by a weapon.

initiator : The unit object the fired the weapon weapon: Weapon object that hit the target target: The Object that was hit.

Defined in:

Parameter:

The EventData structure.

Occurs when any system fails on a human controlled aircraft.

initiator : The unit that had the failure

Defined in:

Parameter:

The EventData structure.

Occurs on the death of a unit.

Contains more and different information. Similar to unit_lost it will occur for aircraft before the aircraft crash event occurs.

  • initiator: The unit that killed the target
  • target: Target Object
  • weapon: Weapon Object

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed place: Object that the unit landed on.

Can be an Airbase Object, FARP, or Ships

Defined in:

Parameter:

The EventData structure.

Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up.

Event does not occur if the pilot lands in the water and sub combs to Davey Jones Locker.

  • initiator: Static object representing the ejected pilot. Place : Aircraft that the pilot ejected from.
  • place: may not return as a valid object if the aircraft has crashed into the ground and no longer exists.
  • subplace: is always 0 for unknown reasons.

Defined in:

Parameter:

The EventData structure.

Occurs when a new mark was added.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mark text was changed.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mark was removed.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mission ends

Defined in:

Parameter:

The EventData structure.

Occurs when a mission starts

Defined in:

Parameter:

The EventData structure.

Occurs when the pilot of an aircraft is killed.

Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane. initiator : The unit that the pilot has died in.

Defined in:

Parameter:

The EventData structure.

Occurs when any player assumes direct control of a unit.

initiator : The unit that is being taken control of.

Defined in:

Parameter:

The EventData structure.

Occurs when any player relieves control of a unit to the AI.

initiator : The unit that the player left.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft connects with a tanker and begins taking on fuel.

initiator : The unit that is receiving fuel.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft is finished taking fuel.

initiator : The unit that was receiving fuel.

Defined in:

Parameter:

The EventData structure.

Occurs when any modification to the "Score" as seen on the debrief menu would occur.

There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.

Defined in:

Parameter:

The EventData structure.

Occurs when any unit stops firing its weapon.

Event will always correspond with a shooting start event. initiator : The unit that was doing the shooting.

Defined in:

Parameter:

The EventData structure.

Occurs when any unit begins firing a weapon that has a high rate of fire.

Most common with aircraft cannons (GAU-8), autocannons, and machine guns. initiator : The unit that is doing the shooting. target: The unit that is being targeted.

Defined in:

Parameter:

The EventData structure.

Occurs whenever any unit in a mission fires a weapon.

But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft takes off from an airbase, farp, or ship.

initiator : The unit that tookoff place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships

Defined in:

Parameter:

The EventData structure.

Occurs when the game thinks an object is destroyed.

  • initiator: The unit that is was destroyed.

Defined in:

Parameter:

The EventData structure.

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Defined in:

Parameters:

#number Start

Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

#table ...

Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

Return value:

#number:

The ScheduleID of the planned schedule.

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Defined in:

Parameters:

#number Start

Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

#number Repeat

Specifies the interval in seconds when the scheduler will call the event function.

#number RandomizeFactor

Specifies a randomization factor between 0 and 1 to randomize the Repeat.

#number Stop

Specifies the amount of seconds when the scheduler will be stopped.

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

#table ...

Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

Return value:

#number:

The ScheduleID of the planned schedule.

Stops the Schedule.

Defined in:

Parameter:

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

Set the Class Event processing Priority.

The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.

Defined in:

Parameter:

#number EventPriority

The Event processing Priority.

Return value:

self

Set a state or property of the Object given a Key and a Value.

Note that if the Object is destroyed, nillified or garbage collected, then the Values and Keys will also be gone.

Defined in:

Parameters:

Object

The object that will hold the Value set by the Key.

Key

The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!

Value

The value to is stored in the object.

Return value:

The Value set.

Trace a function logic level 1.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function logic level 2.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function logic level 3.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace all methods in MOOSE

Defined in:

Parameter:

#boolean TraceAll

true = trace all methods in MOOSE.

Set tracing for a class

Defined in:

Parameter:

#string Class

Set tracing for a specific method of class

Defined in:

Parameters:

#string Class

#string Method

Set trace level

Defined in:

Parameter:

#number Level

Set trace off.

Defined in:

Usage:

-- Switch the tracing Off
BASE:TraceOff()

Set trace on.

Defined in:

Usage:

-- Switch the tracing On
BASE:TraceOn()

Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

So tracing must be switched on manually in your mission if you are using Moose statically. When moose is loading dynamically (for moose class development), tracing is switched on by default.

Defined in:

Parameter:

#boolean TraceOnOff

Switch the tracing on or off.

Usage:

-- Switch the tracing On
BASE:TraceOnOff( true )

-- Switch the tracing Off
BASE:TraceOnOff( false )

UnSubscribe to a DCS event.

Defined in:

Parameter:

Return value:

Trace a function call.

This function is private.

Defined in:

Parameters:

Arguments

A #table or any field.

DebugInfoCurrentParam

DebugInfoFromParam

Trace a function logic.

Defined in:

Parameters:

Arguments

A #table or any field.

DebugInfoCurrentParam

DebugInfoFromParam

TODO: Complete DCS#Event structure.
- The main event handling function... This function captures all events generated for the class. @param #BASE self @param DCS#Event event

Defined in:

Parameter:

event