Module Group

This module contains the GROUP class.

1) Wrapper.Group#GROUP class, extends Wrapper.Controllable#CONTROLLABLE

The Wrapper.Group#GROUP class is a wrapper class to handle the DCS Group objects:

  • Support all DCS Group APIs.
  • Enhance with Group specific APIs not in the DCS Group API set.
  • Handle local Group Controller.
  • Manage the "state" of the DCS Group.

IMPORTANT: ONE SHOULD NEVER SANATIZE these GROUP OBJECT REFERENCES! (make the GROUP object references nil).

1.1) GROUP reference methods

For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _DATABASE object. This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the SPAWN class).

The GROUP class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference using the DCS Group or the DCS GroupName.

Another thing to know is that GROUP objects do not "contain" the DCS Group object. The GROUP methods will reference the DCS Group object by name when it is needed during API execution. If the DCS Group object does not exist or is nil, the GROUP methods will return nil and log an exception in the DCS.log file.

The GROUP class provides the following functions to retrieve quickly the relevant GROUP instance:

  • GROUP.Find(): Find a GROUP instance from the _DATABASE object using a DCS Group object.
  • GROUP.FindByName(): Find a GROUP instance from the _DATABASE object using a DCS Group name.

1.2) GROUP task methods

Several group task methods are available that help you to prepare tasks. These methods return a string consisting of the task description, which can then be given to either a
Wrapper.Controllable#CONTROLLABLE.PushTask or Wrapper.Controllable#CONTROLLABLE.SetTask method to assign the task to the GROUP. Tasks are specific for the category of the GROUP, more specific, for AIR, GROUND or AIR and GROUND. Each task description where applicable indicates for which group category the task is valid. There are 2 main subdivisions of tasks: Assigned tasks and EnRoute tasks.

1.2.1) Assigned task methods

Assigned task methods make the group execute the task where the location of the (possible) targets of the task are known before being detected. This is different from the EnRoute tasks, where the targets of the task need to be detected before the task can be executed.

Find below a list of the assigned task methods:

1.2.2) EnRoute task methods

EnRoute tasks require the targets of the task need to be detected by the group (using its sensors) before the task can be executed:

1.2.3) Preparation task methods

There are certain task methods that allow to tailor the task behaviour:

1.2.4) Obtain the mission from group templates

Group templates contain complete mission descriptions. Sometimes you want to copy a complete mission from a group and assign it to another:

1.3) GROUP Command methods

Group command methods prepare the execution of commands using the Wrapper.Controllable#CONTROLLABLE.SetCommand method:

1.4) GROUP Option methods

Group Option methods change the behaviour of the Group while being alive.

1.4.1) Rule of Engagement:

To check whether an ROE option is valid for a specific group, use:

1.4.2) Rule on thread:

To test whether an ROT option is valid for a specific group, use:

1.5) GROUP Zone validation methods

The group can be validated whether it is completely, partly or not within a Zone. Use the following Zone validation methods on the group:

The zone can be of any Zone class derived from Core.Zone#ZONE_BASE. So, these methods are polymorphic to the zones tested on.

Global(s)

GROUP

Type GROUP

GROUP:Activate()

Activates a GROUP.

GROUP:AllOnGround()

Returns if all units of the group are on the ground or landed.

GROUP:CalculateThreatLevelA2G()

Calculate the maxium A2G threat level of the Group.

GROUP.ClassName
GROUP:CopyRoute(Begin, End, Randomize, Radius)

Return the route of a group by using the Core.Database#DATABASE class.

GROUP:Destroy()

Destroys the DCS Group and all of its DCS Units.

GROUP:Find(DCSGroup)

Find the GROUP wrapper class instance using the DCS Group.

GROUP:FindByName(GroupName)

Find the created GROUP using the DCS Group Name.

GROUP:GetCallsign()

Gets the CallSign of the first DCS Unit of the DCS Group.

GROUP:GetCategory()

Returns category of the DCS Group.

GROUP:GetCategoryName()

Returns the category name of the DCS Group.

GROUP:GetCoalition()

Returns the coalition of the DCS Group.

GROUP:GetCountry()

Returns the country of the DCS Group.

GROUP:GetDCSObject()

Returns the DCS Group.

GROUP:GetDCSUnit(UnitNumber)

Returns the DCS Unit with number UnitNumber.

GROUP:GetDCSUnits()

Returns the DCS Units of the DCS Group.

GROUP:GetInitialSize()
  • Returns the initial size of the DCS Group.
GROUP:GetMaxHeight()

Returns the current maximum height of the group.

GROUP:GetMaxVelocity()

Returns the current maximum velocity of the group.

GROUP:GetMinHeight()

Returns the current minimum height of the group.

GROUP:GetSize()

Returns current size of the DCS Group.

GROUP:GetTaskMission()

Return the mission template of the group.

GROUP:GetTaskRoute()

Return the mission route of the group.

GROUP:GetTemplate()

Returns the group template from the DATABASE (_DATABASE object).

GROUP:GetTypeName()

Gets the type name of the group.

GROUP:GetUnit(UnitNumber)

Returns the UNIT wrapper class with number UnitNumber.

GROUP:GetUnits()

Returns the UNITs wrappers of the DCS Units of the DCS Group.

GROUP:GetVec2()

Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group.

GROUP:GetVec3()

Returns the current Vec3 vector of the first DCS Unit in the GROUP.

GROUP.GroupName

The name of the group.

GROUP:IsAir()

Returns if the group is of an air category.

GROUP:IsAirPlane()

Returns if the DCS Group contains AirPlanes.

GROUP:IsAlive()

Returns if the DCS Group is alive.

GROUP:IsCompletelyInZone(Zone)

Returns true if all units of the group are within a Zone.

GROUP:IsGround()

Returns if the DCS Group contains Ground troops.

GROUP:IsHelicopter()

Returns if the DCS Group contains Helicopters.

GROUP:IsNotInZone(Zone)

Returns true if none of the group units of the group are within a Zone.

GROUP:IsPartlyInZone(Zone)

Returns true if some units of the group are within a Zone.

GROUP:IsShip()

Returns if the DCS Group contains Ships.

GROUP:Register(GroupName)

Create a new GROUP from a DCSGroup

GROUP:Respawn(Template)

Respawn the GROUP using a (tweaked) template of the Group.

GROUP:SetTemplateCoalition(CoalitionID, Template)

Sets the CoalitionID of the group in a Template.

GROUP:SetTemplateControlled(Controlled, Template)

Sets the controlled status in a Template.

GROUP:SetTemplateCountry(CountryID, Template)

Sets the CountryID of the group in a Template.

Global(s)

#GROUP GROUP

Type Group

Type GROUP

The GROUP class

Field(s)

GROUP:Activate()

Activates a GROUP.

GROUP:AllOnGround()

Returns if all units of the group are on the ground or landed.

If all units of this group are on the ground, this function will return true, otherwise false.

Return value

#boolean: All units on the ground result.

GROUP:CalculateThreatLevelA2G()

Calculate the maxium A2G threat level of the Group.

#string GROUP.ClassName
GROUP:CopyRoute(Begin, End, Randomize, Radius)

Return the route of a group by using the Core.Database#DATABASE class.

Parameters

  • #number Begin : The route point from where the copy will start. The base route point is 0.

  • #number End : The route point where the copy will end. The End point is the last point - the End point. The last point has base 0.

  • #boolean Randomize : Randomization of the route, when true.

  • #number Radius : When randomization is on, the randomization is within the radius.

GROUP:Destroy()

Destroys the DCS Group and all of its DCS Units.

Note that this destroy method also raises a destroy event at run-time. So all event listeners will catch the destroy event of this DCS Group.

GROUP:Find(DCSGroup)

Find the GROUP wrapper class instance using the DCS Group.

Parameter

Return value

#GROUP: The GROUP.

GROUP:FindByName(GroupName)

Find the created GROUP using the DCS Group Name.

Parameter

  • #string GroupName : The DCS Group Name.

Return value

#GROUP: The GROUP.

GROUP:GetCallsign()

Gets the CallSign of the first DCS Unit of the DCS Group.

Return value

#string: The CallSign of the first DCS Unit of the DCS Group.

GROUP:GetCategory()

Returns category of the DCS Group.

Return value

Dcs.DCSWrapper.Group#Group.Category: The category ID

GROUP:GetCategoryName()

Returns the category name of the DCS Group.

Return value

#string: Category name = Helicopter, Airplane, Ground Unit, Ship

GROUP:GetCoalition()

Returns the coalition of the DCS Group.

Return value

Dcs.DCSCoalitionWrapper.Object#coalition.side: The coalition side of the DCS Group.

GROUP:GetCountry()

Returns the country of the DCS Group.

Return values

  1. Dcs.DCScountry#country.id: The country identifier.

  2. #nil: The DCS Group is not existing or alive.

GROUP:GetDCSObject()

Returns the DCS Group.

Return value

Dcs.DCSWrapper.Group#Group: The DCS Group.

GROUP:GetDCSUnit(UnitNumber)

Returns the DCS Unit with number UnitNumber.

If the underlying DCS Unit does not exist, the method will return nil. .

Parameter

  • #number UnitNumber : The number of the DCS Unit to be returned.

Return value

Dcs.DCSWrapper.Unit#Unit: The DCS Unit.

GROUP:GetDCSUnits()

Returns the DCS Units of the DCS Group.

Return value

#table: The DCS Units.

GROUP:GetInitialSize()
  • Returns the initial size of the DCS Group.

If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged.

Return value

#number: The DCS Group initial size.

GROUP:GetMaxHeight()

Returns the current maximum height of the group.

Each unit within the group gets evaluated, and the maximum height (= the unit which is the highest elevated) is returned.

Return value

#number: Maximum height found.

GROUP:GetMaxVelocity()

Returns the current maximum velocity of the group.

Each unit within the group gets evaluated, and the maximum velocity (= the unit which is going the fastest) is returned.

Return value

#number: Maximum velocity found.

GROUP:GetMinHeight()

Returns the current minimum height of the group.

Each unit within the group gets evaluated, and the minimum height (= the unit which is the lowest elevated) is returned.

Return value

#number: Minimum height found.

GROUP:GetSize()

Returns current size of the DCS Group.

If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed.

Return value

#number: The DCS Group size.

GROUP:GetTaskMission()

Return the mission template of the group.

Return value

#table: The MissionTemplate

GROUP:GetTaskRoute()

Return the mission route of the group.

Return value

#table: The mission route defined by points.

GROUP:GetTemplate()

Returns the group template from the DATABASE (_DATABASE object).

Return value

#table:

GROUP:GetTypeName()

Gets the type name of the group.

Return value

#string: The type name of the group.

GROUP:GetUnit(UnitNumber)

Returns the UNIT wrapper class with number UnitNumber.

If the underlying DCS Unit does not exist, the method will return nil. .

Parameter

  • #number UnitNumber : The number of the UNIT wrapper class to be returned.

Return value

Wrapper.Unit#UNIT: The UNIT wrapper class.

GROUP:GetUnits()

Returns the UNITs wrappers of the DCS Units of the DCS Group.

Return value

#table: The UNITs wrappers.

GROUP:GetVec2()

Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group.

Return value

Dcs.DCSTypes#Vec2: Current Vec2 point of the first DCS Unit of the DCS Group.

GROUP:GetVec3()

Returns the current Vec3 vector of the first DCS Unit in the GROUP.

Return value

Dcs.DCSTypes#Vec3: Current Vec3 of the first DCS Unit of the GROUP.

#string GROUP.GroupName

The name of the group.

GROUP:IsAir()

Returns if the group is of an air category.

If the group is a helicopter or a plane, then this method will return true, otherwise false.

Return value

#boolean: Air category evaluation result.

GROUP:IsAirPlane()

Returns if the DCS Group contains AirPlanes.

Return value

#boolean: true if DCS Group contains AirPlanes.

GROUP:IsAlive()

Returns if the DCS Group is alive.

When the group exists at run-time, this method will return true, otherwise false.

Return value

#boolean: true if the DCS Group is alive.

GROUP:IsCompletelyInZone(Zone)

Returns true if all units of the group are within a Zone.

Parameter

Return value

#boolean: Returns true if the Group is completely within the Core.Zone#ZONE_BASE

GROUP:IsGround()

Returns if the DCS Group contains Ground troops.

Return value

#boolean: true if DCS Group contains Ground troops.

GROUP:IsHelicopter()

Returns if the DCS Group contains Helicopters.

Return value

#boolean: true if DCS Group contains Helicopters.

GROUP:IsNotInZone(Zone)

Returns true if none of the group units of the group are within a Zone.

Parameter

Return value

#boolean: Returns true if the Group is completely within the Core.Zone#ZONE_BASE

GROUP:IsPartlyInZone(Zone)

Returns true if some units of the group are within a Zone.

Parameter

Return value

#boolean: Returns true if the Group is completely within the Core.Zone#ZONE_BASE

GROUP:IsShip()

Returns if the DCS Group contains Ships.

Return value

#boolean: true if DCS Group contains Ships.

GROUP:Register(GroupName)

Create a new GROUP from a DCSGroup

Parameter

Return value

#GROUP: self

GROUP:Respawn(Template)

Respawn the GROUP using a (tweaked) template of the Group.

The template must be retrieved with the Wrapper.Group#GROUP.GetTemplate() function. The template contains all the definitions as declared within the mission file. To understand templates, do the following:

  • unpack your .miz file into a directory using 7-zip.
  • browse in the directory created to the file mission.
  • open the file and search for the country group definitions.

Your group template will contain the fields as described within the mission file.

This function will:

  • Get the current position and heading of the group.
  • When the group is alive, it will tweak the template x, y and heading coordinates of the group and the embedded units to the current units positions.
  • Then it will destroy the current alive group.
  • And it will respawn the group using your new template definition.

Parameter

  • #table Template : The template of the Group retrieved with GROUP:GetTemplate()

GROUP:SetTemplateCoalition(CoalitionID, Template)

Sets the CoalitionID of the group in a Template.

Parameters

Return value

#table:

GROUP:SetTemplateControlled(Controlled, Template)

Sets the controlled status in a Template.

Parameters

  • #boolean Controlled : true is controlled, false is uncontrolled.

  • Template :

Return value

#table:

GROUP:SetTemplateCountry(CountryID, Template)

Sets the CountryID of the group in a Template.

Parameters

Return value

#table: