Banner Image

Module Functional.ZoneGoalCoalition

Functional - Base class that models processes to achieve goals involving a Zone for a Coalition.


ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition. Derived classes implement the ways how the achievements can be realized.


Author: FlightControl


Global(s)

Global ZONE_GOAL_COALITION

ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition.

#ZONE_GOAL_COALITION ZONE_GOAL_COALITION

ZONE_GOAL_COALITION models processes that have a Goal with a defined achievement involving a Zone for a Coalition.

Derived classes implement the ways how the achievements can be realized.

1. ZONE_GOAL_COALITION constructor

2. ZONE_GOAL_COALITION is a finite state machine (FSM).

2.1 ZONE_GOAL_COALITION States

2.2 ZONE_GOAL_COALITION Events

2.3 ZONE_GOAL_COALITION State Machine

Type(s)

Fields and Methods inherited from ZONE_GOAL_COALITION Description

ZONE_GOAL_COALITION.ClassName

Name of the Class.

ZONE_GOAL_COALITION.Coalition

The current coalition ID of the zone owner.

ZONE_GOAL_COALITION:GetCoalition()

Get the owning coalition of the zone.

ZONE_GOAL_COALITION:GetCoalitionName()

Get the owning coalition name of the zone.

ZONE_GOAL_COALITION:GetPreviousCoalition()

Get the previous coalition, i.e.

ZONE_GOAL_COALITION:New(Zone, Coalition, UnitCategories)

ZONE_GOAL_COALITION Constructor.

ZONE_GOAL_COALITION.ObjectCategories

Table of object categories that are able to hold a zone. Default is UNITS and STATICS.

ZONE_GOAL_COALITION.PreviousCoalition

The previous owner of the zone.

ZONE_GOAL_COALITION:SetCoalition(Coalition)

Set the owning coalition of the zone.

ZONE_GOAL_COALITION:SetObjectCategories(ObjectCategories)

Set the owning coalition of the zone.

ZONE_GOAL_COALITION:SetUnitCategories(UnitCategories)

Set the owning coalition of the zone.

ZONE_GOAL_COALITION.States

ZONE_GOAL_COALITION:StatusZone()

Check status Coalition ownership.

ZONE_GOAL_COALITION.UnitCategories

Table of unit categories that are able to capture and hold the zone. Default is only GROUND units.

Fields and Methods inherited from ZONE_GOAL Description

ZONE_GOAL_COALITION.ClassName

Name of the class.

ZONE_GOAL_COALITION:DestroyedUnit()

DestroyedUnit event.

ZONE_GOAL_COALITION:Flare(FlareColor)

Flare the zone boundary.

ZONE_GOAL_COALITION:GetZone()

Get the Zone.

ZONE_GOAL_COALITION:GetZoneName()

Get the name of the Zone.

ZONE_GOAL_COALITION.Goal

The goal object.

ZONE_GOAL_COALITION:MonitorDestroyedUnits()

Activate the event UnitDestroyed to be fired when a unit is destroyed in the zone.

ZONE_GOAL_COALITION:New(Zone)

ZONE_GOAL Constructor.

ZONE_GOAL_COALITION:OnAfterDestroyedUnit(From, Event, To, DestroyedUnit, PlayerName)

DestroyedUnit Handler OnAfter for ZONE_GOAL

ZONE_GOAL_COALITION:SetSmokeZone(switch)

Activate smoking of zone with the color or the current owner.

ZONE_GOAL_COALITION:Smoke(SmokeColor)

Set the smoke color.

ZONE_GOAL_COALITION.SmokeColor

Color of the smoke.

ZONE_GOAL_COALITION.SmokeScheduler

Scheduler responsible for smoking the zone.

ZONE_GOAL_COALITION.SmokeTime

Time stamp in seconds when the last smoke of the zone was triggered.

ZONE_GOAL_COALITION.SmokeZone

If true, smoke zone.

ZONE_GOAL_COALITION:StatusSmoke()

Check status Smoke.

ZONE_GOAL_COALITION:__Destroyed(EventData)

ZONE_GOAL_COALITION:__DestroyedUnit(delay)

DestroyedUnit delayed event

ZONE_GOAL_COALITION:onafterGuard()

When started, check the Smoke and the Zone status.

Fields and Methods inherited from ZONE_RADIUS Description

ZONE_GOAL_COALITION:BoundZone(Points, CountryID, UnBound)

Bounds the zone with tires.

ZONE_GOAL_COALITION:CheckScannedCoalition(Coalition)

Check if a certain coalition is inside a scanned zone.

ZONE_GOAL_COALITION:CountScannedCoalitions()

Count the number of different coalitions inside the zone.

ZONE_GOAL_COALITION.DrawID

ZONE_GOAL_COALITION:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)

Draw the zone circle on the F10 map.

ZONE_GOAL_COALITION:FlareZone(FlareColor, Points, Azimuth, AddHeight)

Flares the zone boundaries in a color.

ZONE_GOAL_COALITION:GetRadius()

Returns the radius of the zone.

ZONE_GOAL_COALITION:GetRandomCoordinate(inner, outer, surfacetypes)

Returns a Core.Point#COORDINATE object reflecting a random 3D location within the zone.

ZONE_GOAL_COALITION:GetRandomCoordinateWithoutBuildings(inner, outer, distance, markbuildings, markfinal)

Returns a Core.Point#COORDINATE object reflecting a random location within the zone where there are no map objects of type "Building".

ZONE_GOAL_COALITION:GetRandomPointVec2(inner, outer)

Returns a Core.Point#POINT_VEC2 object reflecting a random 2D location within the zone.

ZONE_GOAL_COALITION:GetRandomPointVec3(inner, outer)

Returns a Core.Point#POINT_VEC3 object reflecting a random 3D location within the zone.

ZONE_GOAL_COALITION:GetRandomVec2(inner, outer, surfacetypes)

Returns a random Vec2 location within the zone.

ZONE_GOAL_COALITION:GetRandomVec3(inner, outer)

Returns Returns a random Vec3 location within the zone.

ZONE_GOAL_COALITION:GetScannedCoalition(Coalition)

Get Coalitions of the units in the Zone, or Check if there are units of the given Coalition in the Zone.

ZONE_GOAL_COALITION:GetScannedScenery()

Get scanned scenery table

ZONE_GOAL_COALITION:GetScannedSceneryObjects()

Get table of scanned scenery objects

ZONE_GOAL_COALITION:GetScannedSceneryType(SceneryType)

Get scanned scenery type

ZONE_GOAL_COALITION:GetScannedSetGroup()

Get a set of scanned groups.

ZONE_GOAL_COALITION:GetScannedSetScenery()

Get set of scanned scenery objects

ZONE_GOAL_COALITION:GetScannedSetUnit()

Get a set of scanned units.

ZONE_GOAL_COALITION:GetScannedUnits()

Get a table of scanned units.

ZONE_GOAL_COALITION:GetVec2()

Returns the DCS#Vec2 of the zone.

ZONE_GOAL_COALITION:GetVec3(Height)

Returns the DCS#Vec3 of the ZONE_RADIUS.

ZONE_GOAL_COALITION:IsAllInZoneOfCoalition(Coalition)

Is All in Zone of Coalition?

ZONE_GOAL_COALITION:IsAllInZoneOfOtherCoalition(Coalition)

Is All in Zone of Other Coalition?

ZONE_GOAL_COALITION:IsNoneInZone()

Is None in Zone?

ZONE_GOAL_COALITION:IsNoneInZoneOfCoalition(Coalition)

Is None in Zone of Coalition?

ZONE_GOAL_COALITION:IsSomeInZoneOfCoalition(Coalition)

Is Some in Zone of Coalition?

ZONE_GOAL_COALITION:IsVec2InZone(Vec2)

Returns if a location is within the zone.

ZONE_GOAL_COALITION:IsVec3InZone(Vec3)

Returns if a point is within the zone.

ZONE_GOAL_COALITION:MarkZone(Points)

Mark the zone with markers on the F10 map.

ZONE_GOAL_COALITION:New(ZoneName, Vec2, Radius, DoNotRegisterZone)

Constructor of #ZONE_RADIUS, taking the zone name, the zone location and a radius.

ZONE_GOAL_COALITION.Radius

The radius of the zone.

ZONE_GOAL_COALITION:RemoveJunk()

Remove junk inside the zone using the world.removeJunk function.

ZONE_GOAL_COALITION:Scan(ObjectCategories, UnitCategories)

Scan the zone for the presence of units of the given ObjectCategories.

ZONE_GOAL_COALITION.ScanData

ZONE_GOAL_COALITION.ScanSetGroup

ZONE_GOAL_COALITION:SearchZone(ObjectCategories, EvaluateFunction)

Searches the zone

ZONE_GOAL_COALITION:SetRadius(Radius)

Sets the radius of the zone.

ZONE_GOAL_COALITION:SetVec2(Vec2)

Sets the DCS#Vec2 of the zone.

ZONE_GOAL_COALITION:SmokeZone(SmokeColor, Points, AddHeight, AddOffSet, AngleOffset)

Smokes the zone boundaries in a color.

ZONE_GOAL_COALITION:UpdateFromVec2(Vec2, Radius)

Update zone from a 2D vector.

ZONE_GOAL_COALITION:UpdateFromVec3(Vec3, Radius)

Update zone from a 2D vector.

ZONE_GOAL_COALITION.Vec2

The current location of the zone.

Field(s)

#string ZONE_GOAL_COALITION.ClassName

Name of the Class.

#number ZONE_GOAL_COALITION.Coalition

The current coalition ID of the zone owner.

#table ZONE_GOAL_COALITION.ObjectCategories

Table of object categories that are able to hold a zone. Default is UNITS and STATICS.

#number ZONE_GOAL_COALITION.PreviousCoalition

The previous owner of the zone.

#table ZONE_GOAL_COALITION.UnitCategories

Table of unit categories that are able to capture and hold the zone. Default is only GROUND units.

Function(s)

Get the owning coalition of the zone.

Defined in:

ZONE_GOAL_COALITION

Return value:

#number:

Coalition.

Get the owning coalition name of the zone.

Defined in:

ZONE_GOAL_COALITION

Return value:

#string:

Coalition name.

Get the previous coalition, i.e.

the one owning the zone before the current one.

Defined in:

ZONE_GOAL_COALITION

Return value:

#number:

Coalition.

ZONE_GOAL_COALITION Constructor.

Defined in:

ZONE_GOAL_COALITION

Parameters:

A Core.Zone object with the goal to be achieved.

#number Coalition

The initial coalition owning the zone. Default coalition.side.NEUTRAL.

#table UnitCategories

Table of unit categories. See DCS Class Unit. Default {Unit.Category.GROUND_UNIT}.

Return value:

Set the owning coalition of the zone.

Defined in:

ZONE_GOAL_COALITION

Parameter:

#number Coalition

The coalition ID, e.g. coalition.side.RED.

Return value:

Set the owning coalition of the zone.

Defined in:

ZONE_GOAL_COALITION

Parameter:

#table ObjectCategories

Table of unit categories. See DCS Class Object. Default {Object.Category.UNIT, Object.Category.STATIC}, i.e. all UNITS and STATICS.

Return value:

Set the owning coalition of the zone.

Defined in:

ZONE_GOAL_COALITION

Parameter:

#table UnitCategories

Table of unit categories. See DCS Class Unit. Default {Unit.Category.GROUND_UNIT}.

Return value:

Check status Coalition ownership.

Defined in:

ZONE_GOAL_COALITION

Return value:

Field(s)

#string ZONE_GOAL_COALITION.ClassName

Name of the Class.

#number ZONE_GOAL_COALITION.Coalition

The current coalition ID of the zone owner.

#table ZONE_GOAL_COALITION.ObjectCategories

Table of object categories that are able to hold a zone. Default is UNITS and STATICS.

#number ZONE_GOAL_COALITION.PreviousCoalition

The previous owner of the zone.

#table ZONE_GOAL_COALITION.UnitCategories

Table of unit categories that are able to capture and hold the zone. Default is only GROUND units.

Function(s)

Flare the zone boundary.

Defined in:

Parameter:

Get the name of the Zone.

Defined in:

Return value:

#string:

Activate the event UnitDestroyed to be fired when a unit is destroyed in the zone.

ZONE_GOAL Constructor.

Defined in:

Parameter:

A Core.Zone object with the goal to be achieved. Alternatively, can be handed as the name of late activated group describing a ZONE_POLYGON with its waypoints.

Return value:

DestroyedUnit Handler OnAfter for ZONE_GOAL

Defined in:

Parameters:

#string From

#string Event

#string To

Wrapper.Unit#UNIT DestroyedUnit

The destroyed unit.

#string PlayerName

The name of the player.

Activate smoking of zone with the color or the current owner.

Defined in:

Parameter:

#boolean switch

If true or nil activate smoke. If false or nil, no smoke.

Return value:

Set the smoke color.

Defined in:

Parameter:

DestroyedUnit delayed event

Defined in:

Parameter:

#number delay

Delay in seconds.

When started, check the Smoke and the Zone status.

Field(s)

#string ZONE_GOAL_COALITION.ClassName

Name of the Class.

#number ZONE_GOAL_COALITION.Coalition

The current coalition ID of the zone owner.

#table ZONE_GOAL_COALITION.ObjectCategories

Table of object categories that are able to hold a zone. Default is UNITS and STATICS.

#number ZONE_GOAL_COALITION.PreviousCoalition

The previous owner of the zone.

#table ZONE_GOAL_COALITION.UnitCategories

Table of unit categories that are able to capture and hold the zone. Default is only GROUND units.

Function(s)

Bounds the zone with tires.

Defined in:

Parameters:

#number Points

(optional) The amount of points in the circle. Default 360.

DCS#country.id CountryID

The country id of the tire objects, e.g. country.id.USA for blue or country.id.RUSSIA for red.

#boolean UnBound

(Optional) If true the tyres will be destroyed.

Return value:

self

Check if a certain coalition is inside a scanned zone.

Defined in:

Parameter:

#number Coalition

The coalition id, e.g. coalition.side.BLUE.

Return value:

#boolean:

If true, the coalition is inside the zone.

Count the number of different coalitions inside the zone.

Defined in:

Return value:

#number:

Counted coalitions.

Draw the zone circle on the F10 map.

Defined in:

Parameters:

#number Coalition

Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.

#table Color

RGB color table {r, g, b}, e.g. {1,0,0} for red.

#number Alpha

Transparency [0,1]. Default 1.

#table FillColor

RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as Color value.

#number FillAlpha

Transparency [0,1]. Default 0.15.

#number LineType

Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.

#boolean ReadOnly

(Optional) Mark is readonly and cannot be removed by users. Default false.

Return value:

self

Flares the zone boundaries in a color.

Defined in:

Parameters:

The flare color.

#number Points

(optional) The amount of points in the circle.

DCS#Azimuth Azimuth

(optional) Azimuth The azimuth of the flare.

#number AddHeight

(optional) The height to be added for the smoke.

Return value:

self

Returns the radius of the zone.

Defined in:

Return value:

The radius of the zone.

Returns a Core.Point#COORDINATE object reflecting a random 3D location within the zone.

Defined in:

Parameters:

#number inner

(Optional) Minimal distance from the center of the zone in meters. Default is 0 m.

#number outer

(Optional) Maximal distance from the outer edge of the zone in meters. Default is the radius of the zone.

#table surfacetypes

(Optional) Table of surface types. Can also be a single surface type. We will try max 100 times to find the right type!

Return value:

The random coordinate.

Returns a Core.Point#COORDINATE object reflecting a random location within the zone where there are no map objects of type "Building".

Does not find statics you might have placed there. Note This might be quite CPU intensive, use with care.

Defined in:

Parameters:

#number inner

(Optional) Minimal distance from the center of the zone in meters. Default is 0m.

#number outer

(Optional) Maximal distance from the outer edge of the zone in meters. Default is the radius of the zone.

#number distance

(Optional) Minimum distance from any building coordinate. Defaults to 100m.

#boolean markbuildings

(Optional) Place markers on found buildings (if any).

#boolean markfinal

(Optional) Place marker on the final coordinate (if any).

Return value:

The random coordinate or nil if cannot be found in 1000 iterations.

Returns a Core.Point#POINT_VEC2 object reflecting a random 2D location within the zone.

Note that this is actually a Core.Point#COORDINATE type object, and not a simple Vec2 table.

Defined in:

Parameters:

#number inner

(optional) Minimal distance from the center of the zone. Default is 0.

#number outer

(optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.

Return value:

The Core.Point#POINT_VEC2 object reflecting the random 3D location within the zone.

Returns a Core.Point#POINT_VEC3 object reflecting a random 3D location within the zone.

Note that this is actually a Core.Point#COORDINATE type object, and not a simple Vec3 table.

Defined in:

Parameters:

#number inner

(optional) Minimal distance from the center of the zone. Default is 0.

#number outer

(optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.

Return value:

The Core.Point#POINT_VEC3 object reflecting the random 3D location within the zone.

Returns a random Vec2 location within the zone.

Defined in:

Parameters:

#number inner

(Optional) Minimal distance from the center of the zone. Default is 0.

#number outer

(Optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.

#table surfacetypes

(Optional) Table of surface types. Can also be a single surface type. We will try max 100 times to find the right type!

Return value:

The random location within the zone.

Returns Returns a random Vec3 location within the zone.

Defined in:

Parameters:

#number inner

(optional) Minimal distance from the center of the zone. Default is 0.

#number outer

(optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.

Return value:

The random location within the zone.

Get Coalitions of the units in the Zone, or Check if there are units of the given Coalition in the Zone.

Returns nil if there are none to two Coalitions in the zone! Returns one Coalition if there are only Units of one Coalition in the Zone. Returns the Coalition for the given Coalition if there are units of the Coalition in the Zone.

Defined in:

Parameter:

Coalition

Return value:

#table:

Get scanned scenery table

Defined in:

Return value:

#table:

Structured object table: [type].[name].SCENERY

Get table of scanned scenery objects

Defined in:

Return value:

#table:

Table of SCENERY objects.

Get scanned scenery type

Defined in:

Parameter:

SceneryType

Return value:

#table:

Table of DCS scenery type objects.

Get a set of scanned groups.

Defined in:

Return value:

Set of groups.

Get set of scanned scenery objects

Defined in:

Return value:

#table:

Table of Wrapper.Scenery#SCENERY scenery objects.

Get a set of scanned units.

Defined in:

Return value:

Set of units and statics inside the zone.

Get a table of scanned units.

Defined in:

Return value:

#table:

Table of DCS units and DCS statics inside the zone.

Returns the DCS#Vec2 of the zone.

Defined in:

Return value:

The location of the zone.

Returns the DCS#Vec3 of the ZONE_RADIUS.

Defined in:

Parameter:

DCS#Distance Height

The height to add to the land height where the center of the zone is located.

Return value:

The point of the zone.

Is All in Zone of Coalition?

Check if only the specified coalition is inside the zone and no one else.

Defined in:

Parameter:

#number Coalition

Coalition ID of the coalition which is checked to be the only one in the zone.

Return value:

#boolean:

True, if only that coalition is inside the zone and no one else.

Usage:

   self.Zone:Scan()
   local IsGuarded = self.Zone:IsAllInZoneOfCoalition( self.Coalition )

Is All in Zone of Other Coalition?

Check if only one coalition is inside the zone and the specified coalition is not the one. You first need to use the ZONE_RADIUS.Scan method to scan the zone before it can be evaluated! Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.

Defined in:

Parameter:

#number Coalition

Coalition ID of the coalition which is not supposed to be in the zone.

Return value:

#boolean:

True, if and only if only one coalition is inside the zone and the specified coalition is not it.

Usage:

   self.Zone:Scan()
   local IsCaptured = self.Zone:IsAllInZoneOfOtherCoalition( self.Coalition )

Is None in Zone?

You first need to use the ZONE_RADIUS.Scan method to scan the zone before it can be evaluated! Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.

Defined in:

Return value:

#boolean:

Usage:

   self.Zone:Scan()
   local IsEmpty = self.Zone:IsNoneInZone()

Is None in Zone of Coalition?

You first need to use the ZONE_RADIUS.Scan method to scan the zone before it can be evaluated! Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.

Defined in:

Parameter:

Coalition

Return value:

#boolean:

Usage:

   self.Zone:Scan()
   local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition )

Is Some in Zone of Coalition?

Check if more than one coalition is inside the zone and the specified coalition is one of them. You first need to use the ZONE_RADIUS.Scan method to scan the zone before it can be evaluated! Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.

Defined in:

Parameter:

#number Coalition

ID of the coalition which is checked to be inside the zone.

Return value:

#boolean:

True if more than one coalition is inside the zone and the specified coalition is one of them.

Usage:

   self.Zone:Scan()
   local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )

Returns if a location is within the zone.

Defined in:

Parameter:

DCS#Vec2 Vec2

The location to test.

Return value:

#boolean:

true if the location is within the zone.

Returns if a point is within the zone.

Defined in:

Parameter:

DCS#Vec3 Vec3

The point to test.

Return value:

#boolean:

true if the point is within the zone.

Mark the zone with markers on the F10 map.

Defined in:

Parameter:

#number Points

(Optional) The amount of points in the circle. Default 360.

Return value:

self

Constructor of #ZONE_RADIUS, taking the zone name, the zone location and a radius.

Defined in:

Parameters:

#string ZoneName

Name of the zone.

DCS#Vec2 Vec2

The location of the zone.

DCS#Distance Radius

The radius of the zone.

DCS#Boolean DoNotRegisterZone

Determines if the Zone should not be registered in the _Database Table. Default=false

Return value:

self

Remove junk inside the zone using the world.removeJunk function.

Defined in:

Return value:

#number:

Number of deleted objects.

Scan the zone for the presence of units of the given ObjectCategories.

Note that only after a zone has been scanned, the zone can be evaluated by:

Defined in:

Parameters:

ObjectCategories

An array of categories of the objects to find in the zone. E.g. {Object.Category.UNIT}

UnitCategories

An array of unit categories of the objects to find in the zone. E.g. {Unit.Category.GROUND_UNIT,Unit.Category.SHIP}

Usage:

   myzone:Scan({Object.Category.UNIT},{Unit.Category.GROUND_UNIT})
   local IsAttacked = myzone:IsSomeInZoneOfCoalition( self.Coalition )

Searches the zone

Defined in:

Parameters:

ObjectCategories

A list of categories, which are members of Object.Category

EvaluateFunction

Sets the radius of the zone.

Defined in:

Parameter:

DCS#Distance Radius

The radius of the zone.

Return value:

The radius of the zone.

Sets the DCS#Vec2 of the zone.

Defined in:

Parameter:

DCS#Vec2 Vec2

The new location of the zone.

Return value:

The new location of the zone.

Smokes the zone boundaries in a color.

Defined in:

Parameters:

The smoke color.

#number Points

(optional) The amount of points in the circle.

#number AddHeight

(optional) The height to be added for the smoke.

#number AddOffSet

(optional) The angle to be added for the smoking start position.

AngleOffset

Return value:

self

Update zone from a 2D vector.

Defined in:

Parameters:

DCS#Vec2 Vec2

The location of the zone.

DCS#Distance Radius

The radius of the zone.

Return value:

self

Update zone from a 2D vector.

Defined in:

Parameters:

DCS#Vec3 Vec3

The location of the zone.

DCS#Distance Radius

The radius of the zone.

Return value:

self