Module Zone
This module contains the ZONE classes, inherited from Core.Zone#ZONE_BASE.
There are essentially two core functions that zones accomodate:
- Test if an object is within the zone boundaries.
- Provide the zone behaviour. Some zones are static, while others are moveable.
The object classes are using the zone classes to test the zone boundaries, which can take various forms:
- Test if completely within the zone.
- Test if partly within the zone (for Wrapper.Group#GROUP objects).
- Test if not in the zone.
- Distance to the nearest intersecting point of the zone.
- Distance to the center of the zone.
- ...
Each of these ZONE classes have a zone name, and specific parameters defining the zone type:
- Core.Zone#ZONE_BASE: The ZONE_BASE class defining the base for all other zone classes.
- Core.Zone#ZONE_RADIUS: The ZONE_RADIUS class defined by a zone name, a location and a radius.
- Core.Zone#ZONE: The ZONE class, defined by the zone name as defined within the Mission Editor.
- Core.Zone#ZONE_UNIT: The ZONE_UNIT class defines by a zone around a Wrapper.Unit#UNIT with a radius.
- Core.Zone#ZONE_GROUP: The ZONE_GROUP class defines by a zone around a Wrapper.Group#GROUP with a radius.
- Core.Zone#ZONE_POLYGON: The ZONE_POLYGON class defines by a sequence of Wrapper.Group#GROUP waypoints within the Mission Editor, forming a polygon.
1) Core.Zone#ZONE_BASE class, extends Core.Base#BASE
This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
1.1) Each zone has a name:
- ZONE_BASE.GetName(): Returns the name of the zone.
1.2) Each zone implements two polymorphic functions defined in Core.Zone#ZONE_BASE:
- ZONE_BASE.IsPointVec2InZone(): Returns if a Core.Point#POINT_VEC2 is within the zone.
- ZONE_BASE.IsPointVec3InZone(): Returns if a Core.Point#POINT_VEC3 is within the zone.
1.3) A zone has a probability factor that can be set to randomize a selection between zones:
- ZONE_BASE.SetRandomizeProbability(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% )
- ZONE_BASE.GetRandomizeProbability(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% )
- ZONE_BASE.GetZoneMaybe(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate.
1.4) A zone manages Vectors:
- ZONE_BASE.GetVec2(): Returns the Dcs.DCSTypes#Vec2 coordinate of the zone.
- ZONE_BASE.GetRandomVec2(): Define a random Dcs.DCSTypes#Vec2 within the zone.
1.5) A zone has a bounding square:
- ZONE_BASE.GetBoundingSquare(): Get the outer most bounding square of the zone.
1.6) A zone can be marked:
- ZONE_BASE.SmokeZone(): Smokes the zone boundaries in a color.
- ZONE_BASE.FlareZone(): Flares the zone boundaries in a color.
2) Core.Zone#ZONE_RADIUS class, extends Core.Zone#ZONE_BASE
The ZONERADIUS class defined by a zone name, a location and a radius. This class implements the inherited functions from Core.Zone#ZONEBASE taking into account the own zone format and properties.
2.1) Core.Zone#ZONE_RADIUS constructor:
- ZONE_BASE.New(): Constructor.
2.2) Manage the radius of the zone:
- ZONE_BASE.SetRadius(): Sets the radius of the zone.
- ZONE_BASE.GetRadius(): Returns the radius of the zone.
2.3) Manage the location of the zone:
- ZONE_BASE.SetVec2(): Sets the Dcs.DCSTypes#Vec2 of the zone.
- ZONE_BASE.GetVec2(): Returns the Dcs.DCSTypes#Vec2 of the zone.
- ZONE_BASE.GetVec3(): Returns the Dcs.DCSTypes#Vec3 of the zone, taking an additional height parameter.
3) Core.Zone#ZONE class, extends Core.Zone#ZONE_RADIUS
The ZONE class, defined by the zone name as defined within the Mission Editor. This class implements the inherited functions from {Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
4) Core.Zone#ZONE_UNIT class, extends Core.Zone#ZONE_RADIUS
The ZONE_UNIT class defined by a zone around a Wrapper.Unit#UNIT with a radius. This class implements the inherited functions from Core.Zone#ZONE_RADIUS taking into account the own zone format and properties.
5) Core.Zone#ZONE_GROUP class, extends Core.Zone#ZONE_RADIUS
The ZONE_GROUP class defines by a zone around a Wrapper.Group#GROUP with a radius. The current leader of the group defines the center of the zone. This class implements the inherited functions from Core.Zone#ZONE_RADIUS taking into account the own zone format and properties.
6) Core.Zone#ZONEPOLYGONBASE class, extends Core.Zone#ZONE_BASE
The ZONEPOLYGONBASE class defined by a sequence of Wrapper.Group#GROUP waypoints within the Mission Editor, forming a polygon. This class implements the inherited functions from Core.Zone#ZONE_RADIUS taking into account the own zone format and properties. This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
7) Core.Zone#ZONE_POLYGON class, extends Core.Zone#ZONEPOLYGONBASE
The ZONE_POLYGON class defined by a sequence of Wrapper.Group#GROUP waypoints within the Mission Editor, forming a polygon. This class implements the inherited functions from Core.Zone#ZONE_RADIUS taking into account the own zone format and properties.
API CHANGE HISTORY
The underlying change log documents the API changes. Please read this carefully. The following notation is used:
- Added parts are expressed in bold type face.
- Removed parts are expressed in italic type face.
Hereby the change log:
2016-08-15: ZONE_BASE:GetName() added.
2016-08-15: ZONE_BASE:SetZoneProbability( ZoneProbability ) added.
2016-08-15: ZONE_BASE:GetZoneProbability() added.
2016-08-15: ZONE_BASE:GetZoneMaybe() added.
Global(s)
| ZONE | |
| ZONE_BASE | |
| ZONE_GROUP | |
| ZONE_POLYGON | |
| ZONE_POLYGON_BASE | |
| ZONE_RADIUS | |
| ZONE_UNIT |
Type ZONE
| ZONE.ClassName | |
| ZONE:New(ZoneName) |
Constructor of ZONE, taking the zone name. |
Type ZONE_BASE
| ZONE_BASE.ClassName | |
| ZONE_BASE:GetBoundingSquare() |
Get the bounding square the zone. |
| ZONE_BASE:GetName() |
Returns the name of the zone. |
| ZONE_BASE:GetRandomVec2() |
Define a random Dcs.DCSTypes#Vec2 within the zone. |
| ZONE_BASE:GetVec2() |
Returns the Dcs.DCSTypes#Vec2 coordinate of the zone. |
| ZONE_BASE:GetZoneMaybe() |
Get the zone taking into account the randomization probability of a zone to be selected. |
| ZONE_BASE:GetZoneProbability() |
Get the randomization probability of a zone to be selected. |
| ZONE_BASE:IsPointVec2InZone(Vec2) |
Returns if a location is within the zone. |
| ZONE_BASE:IsPointVec3InZone(Vec3) |
Returns if a point is within the zone. |
| ZONE_BASE:New(ZoneName) |
ZONE_BASE constructor |
| ZONE_BASE:SetZoneProbability(ZoneProbability) |
Set the randomization probability of a zone to be selected. |
| ZONE_BASE:SmokeZone(SmokeColor) |
Smokes the zone boundaries in a color. |
| ZONE_BASE.ZoneName |
Name of the zone. |
| ZONE_BASE.ZoneProbability |
A value between 0 and 1. 0 = 0% and 1 = 100% probability. |
Type ZONE_BASE.BoundingSquare
| ZONE_BASE.BoundingSquare.x1 |
The lower x coordinate (left down) |
| ZONE_BASE.BoundingSquare.x2 |
The higher x coordinate (right up) |
| ZONE_BASE.BoundingSquare.y1 |
The lower y coordinate (left down) |
| ZONE_BASE.BoundingSquare.y2 |
The higher y coordinate (right up) |
Type ZONE_GROUP
| ZONE_GROUP.ClassName | |
| ZONE_GROUP:GetRandomVec2() |
Returns a random location within the zone of the Group. |
| ZONE_GROUP:GetVec2() |
Returns the current location of the Group. |
| ZONE_GROUP:New(ZoneName, ZoneGROUP, Radius) |
Constructor to create a ZONE_GROUP instance, taking the zone name, a zone Wrapper.Group#GROUP and a radius. |
| ZONE_GROUP.ZoneGROUP |
Type ZONE_POLYGON
| ZONE_POLYGON.ClassName | |
| ZONE_POLYGON:New(ZoneName, ZoneGroup) |
Constructor to create a ZONE_POLYGON instance, taking the zone name and the name of the Wrapper.Group#GROUP defined within the Mission Editor. |
Type ZONE_POLYGON_BASE
| ZONE_POLYGON_BASE.ClassName | |
| ZONE_POLYGON_BASE:Flush() |
Flush polygon coordinates as a table in DCS.log. |
| ZONE_POLYGON_BASE:GetBoundingSquare() |
Get the bounding square the zone. |
| ZONE_POLYGON_BASE:GetRandomVec2() |
Define a random Dcs.DCSTypes#Vec2 within the zone. |
| ZONE_POLYGON_BASE:IsPointVec2InZone(Vec2) |
Returns if a location is within the zone. |
| ZONE_POLYGON_BASE:New(ZoneName, PointsArray) |
Constructor to create a ZONEPOLYGONBASE instance, taking the zone name and an array of Dcs.DCSTypes#Vec2, forming a polygon. |
| ZONE_POLYGON_BASE.Polygon |
The polygon defined by an array of Dcs.DCSTypes#Vec2. |
| ZONE_POLYGON_BASE:SmokeZone(SmokeColor) |
Smokes the zone boundaries in a color. |
Type ZONE_RADIUS
| ZONE_RADIUS.ClassName | |
| ZONE_RADIUS:FlareZone(FlareColor, Points, Azimuth) |
Flares the zone boundaries in a color. |
| ZONE_RADIUS:GetRadius() |
Returns the radius of the zone. |
| ZONE_RADIUS:GetRandomVec2() |
Returns a random location within the zone. |
| ZONE_RADIUS:GetVec2() |
Returns the Dcs.DCSTypes#Vec2 of the zone. |
| ZONE_RADIUS:GetVec3(Height) |
Returns the Dcs.DCSTypes#Vec3 of the ZONE_RADIUS. |
| ZONE_RADIUS:IsPointVec2InZone(Vec2) |
Returns if a location is within the zone. |
| ZONE_RADIUS:IsPointVec3InZone(Vec3) |
Returns if a point is within the zone. |
| ZONE_RADIUS:New(ZoneName, Vec2, Radius) |
Constructor of #ZONE_RADIUS, taking the zone name, the zone location and a radius. |
| ZONE_RADIUS.Radius |
The radius of the zone. |
| ZONE_RADIUS:SetRadius(Radius) |
Sets the radius of the zone. |
| ZONE_RADIUS:SetVec2(Vec2) |
Sets the Dcs.DCSTypes#Vec2 of the zone. |
| ZONE_RADIUS:SmokeZone(SmokeColor, Points) |
Smokes the zone boundaries in a color. |
| ZONE_RADIUS.Vec2 |
The current location of the zone. |
Type ZONE_UNIT
| ZONE_UNIT.ClassName | |
| ZONE_UNIT:GetRandomVec2() |
Returns a random location within the zone. |
| ZONE_UNIT:GetVec2() |
Returns the current location of the Wrapper.Unit#UNIT. |
| ZONE_UNIT:GetVec3(Height) |
Returns the Dcs.DCSTypes#Vec3 of the ZONE_UNIT. |
| ZONE_UNIT.LastVec2 | |
| ZONE_UNIT:New(ZoneName, ZoneUNIT, Radius) |
Constructor to create a ZONE_UNIT instance, taking the zone name, a zone unit and a radius. |
| ZONE_UNIT.ZoneUNIT |
Global(s)
Type Zone
Type ZONE
The ZONE class, defined by the zone name as defined within the Mission Editor.
The location and the radius are automatically collected from the mission settings.
Field(s)
- #string ZONE.ClassName
- ZONE:New(ZoneName)
-
Constructor of ZONE, taking the zone name.
Parameter
-
#string ZoneName: The name of the zone as defined within the mission editor.
Return value
-
Type ZONE_BASE
The ZONE_BASE class
Field(s)
- #string ZONE_BASE.ClassName
- ZONE_BASE:GetBoundingSquare()
-
Get the bounding square the zone.
Return value
#nil: The bounding square.
- ZONE_BASE:GetName()
-
Returns the name of the zone.
Return value
#string: The name of the zone.
- ZONE_BASE:GetRandomVec2()
-
Define a random Dcs.DCSTypes#Vec2 within the zone.
Return value
Dcs.DCSTypes#Vec2: The Vec2 coordinates.
- ZONE_BASE:GetVec2()
-
Returns the Dcs.DCSTypes#Vec2 coordinate of the zone.
Return value
#nil:
- ZONE_BASE:GetZoneMaybe()
-
Get the zone taking into account the randomization probability of a zone to be selected.
Return values
-
#ZONE_BASE: The zone is selected taking into account the randomization probability factor.
-
#nil: The zone is not selected taking into account the randomization probability factor.
-
- ZONE_BASE:GetZoneProbability()
-
Get the randomization probability of a zone to be selected.
Return value
#number: A value between 0 and 1. 0 = 0% and 1 = 100% probability.
- ZONE_BASE:IsPointVec2InZone(Vec2)
-
Returns if a location is within the zone.
Parameter
-
Dcs.DCSTypes#Vec2 Vec2: The location to test.
Return value
#boolean: true if the location is within the zone.
-
- ZONE_BASE:IsPointVec3InZone(Vec3)
-
Returns if a point is within the zone.
Parameter
-
Dcs.DCSTypes#Vec3 Vec3: The point to test.
Return value
#boolean: true if the point is within the zone.
-
- ZONE_BASE:New(ZoneName)
-
ZONE_BASE constructor
Parameter
-
#string ZoneName: Name of the zone.
Return value
#ZONE_BASE: self
-
- ZONE_BASE:SetZoneProbability(ZoneProbability)
-
Set the randomization probability of a zone to be selected.
Parameter
-
ZoneProbability: A value between 0 and 1. 0 = 0% and 1 = 100% probability.
-
- ZONE_BASE:SmokeZone(SmokeColor)
-
Smokes the zone boundaries in a color.
Parameter
-
Utilities.Utils#SMOKECOLOR SmokeColor: The smoke color.
-
- #string ZONE_BASE.ZoneName
-
Name of the zone.
- #number ZONE_BASE.ZoneProbability
-
A value between 0 and 1. 0 = 0% and 1 = 100% probability.
Type ZONE_BASE.BoundingSquare
The ZONE_BASE.BoundingSquare
Field(s)
- Dcs.DCSTypes#Distance ZONE_BASE.BoundingSquare.x1
-
The lower x coordinate (left down)
- Dcs.DCSTypes#Distance ZONE_BASE.BoundingSquare.x2
-
The higher x coordinate (right up)
- Dcs.DCSTypes#Distance ZONE_BASE.BoundingSquare.y1
-
The lower y coordinate (left down)
- Dcs.DCSTypes#Distance ZONE_BASE.BoundingSquare.y2
-
The higher y coordinate (right up)
Type ZONE_GROUP
The ZONE_GROUP class defined by a zone around a Group, taking the average center point of all the units within the Group, with a radius.
Field(s)
- #string ZONE_GROUP.ClassName
- ZONE_GROUP:GetRandomVec2()
-
Returns a random location within the zone of the Group.
Return value
Dcs.DCSTypes#Vec2: The random location of the zone based on the Group location.
- ZONE_GROUP:GetVec2()
-
Returns the current location of the Group.
Return value
Dcs.DCSTypes#Vec2: The location of the zone based on the Group location.
- ZONE_GROUP:New(ZoneName, ZoneGROUP, Radius)
-
Constructor to create a ZONE_GROUP instance, taking the zone name, a zone Wrapper.Group#GROUP and a radius.
Parameters
-
#string ZoneName: Name of the zone. -
Wrapper.Group#GROUP ZoneGROUP: The Group as the center of the zone. -
Dcs.DCSTypes#Distance Radius: The radius of the zone.
Return value
#ZONE_GROUP: self
-
Type ZONE_POLYGON
The ZONE_POLYGON class defined by a sequence of Wrapper.Group#GROUP waypoints within the Mission Editor, forming a polygon.
Field(s)
- #string ZONE_POLYGON.ClassName
- ZONE_POLYGON:New(ZoneName, ZoneGroup)
-
Constructor to create a ZONE_POLYGON instance, taking the zone name and the name of the Wrapper.Group#GROUP defined within the Mission Editor.
The Wrapper.Group#GROUP waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON.
Parameters
-
#string ZoneName: Name of the zone. -
Wrapper.Group#GROUP ZoneGroup: The GROUP waypoints as defined within the Mission Editor define the polygon shape.
Return value
#ZONE_POLYGON: self
-
Type ZONE_POLYGON_BASE
The ZONEPOLYGONBASE class defined by an array of Dcs.DCSTypes#Vec2, forming a polygon.
Field(s)
- #string ZONE_POLYGON_BASE.ClassName
- ZONE_POLYGON_BASE:Flush()
-
Flush polygon coordinates as a table in DCS.log.
Return value
#ZONEPOLYGONBASE: self
- ZONE_POLYGON_BASE:GetBoundingSquare()
-
Get the bounding square the zone.
Return value
#ZONEPOLYGONBASE.BoundingSquare: The bounding square.
- ZONE_POLYGON_BASE:GetRandomVec2()
-
Define a random Dcs.DCSTypes#Vec2 within the zone.
Return value
Dcs.DCSTypes#Vec2: The Vec2 coordinate.
- ZONE_POLYGON_BASE:IsPointVec2InZone(Vec2)
-
Returns if a location is within the zone.
Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
Parameter
-
Dcs.DCSTypes#Vec2 Vec2: The location to test.
Return value
#boolean: true if the location is within the zone.
-
- ZONE_POLYGON_BASE:New(ZoneName, PointsArray)
-
Constructor to create a ZONEPOLYGONBASE instance, taking the zone name and an array of Dcs.DCSTypes#Vec2, forming a polygon.
The Wrapper.Group#GROUP waypoints define the polygon corners. The first and the last point are automatically connected.
Parameters
-
#string ZoneName: Name of the zone. -
#ZONEPOLYGONBASE.ListVec2 PointsArray: An array of Dcs.DCSTypes#Vec2, forming a polygon..
Return value
#ZONEPOLYGONBASE: self
-
- #ZONE_POLYGON_BASE.ListVec2 ZONE_POLYGON_BASE.Polygon
-
The polygon defined by an array of Dcs.DCSTypes#Vec2.
- ZONE_POLYGON_BASE:SmokeZone(SmokeColor)
-
Smokes the zone boundaries in a color.
Parameter
-
Utilities.Utils#SMOKECOLOR SmokeColor: The smoke color.
Return value
#ZONEPOLYGONBASE: self
-
Type ZONE_POLYGON_BASE.BoundingSquare
Type ZONE_POLYGON_BASE.ListVec2
A points array.
Type ZONE_RADIUS
The ZONE_RADIUS class, defined by a zone name, a location and a radius.
Field(s)
- #string ZONE_RADIUS.ClassName
- ZONE_RADIUS:FlareZone(FlareColor, Points, Azimuth)
-
Flares the zone boundaries in a color.
Parameters
-
Utilities.Utils#FLARECOLOR FlareColor: The flare color. -
#number Points: (optional) The amount of points in the circle. -
Dcs.DCSTypes#Azimuth Azimuth: (optional) Azimuth The azimuth of the flare.
Return value
#ZONE_RADIUS: self
-
- ZONE_RADIUS:GetRadius()
-
Returns the radius of the zone.
Return value
Dcs.DCSTypes#Distance: The radius of the zone.
- ZONE_RADIUS:GetRandomVec2()
-
Returns a random location within the zone.
Return value
Dcs.DCSTypes#Vec2: The random location within the zone.
- ZONE_RADIUS:GetVec2()
-
Returns the Dcs.DCSTypes#Vec2 of the zone.
Return value
Dcs.DCSTypes#Vec2: The location of the zone.
- ZONE_RADIUS:GetVec3(Height)
-
Returns the Dcs.DCSTypes#Vec3 of the ZONE_RADIUS.
Parameter
-
Dcs.DCSTypes#Distance Height: The height to add to the land height where the center of the zone is located.
Return value
Dcs.DCSTypes#Vec3: The point of the zone.
-
- ZONE_RADIUS:IsPointVec2InZone(Vec2)
-
Returns if a location is within the zone.
Parameter
-
Dcs.DCSTypes#Vec2 Vec2: The location to test.
Return value
#boolean: true if the location is within the zone.
-
- ZONE_RADIUS:IsPointVec3InZone(Vec3)
-
Returns if a point is within the zone.
Parameter
-
Dcs.DCSTypes#Vec3 Vec3: The point to test.
Return value
#boolean: true if the point is within the zone.
-
- ZONE_RADIUS:New(ZoneName, Vec2, Radius)
-
Constructor of #ZONE_RADIUS, taking the zone name, the zone location and a radius.
Parameters
-
#string ZoneName: Name of the zone. -
Dcs.DCSTypes#Vec2 Vec2: The location of the zone. -
Dcs.DCSTypes#Distance Radius: The radius of the zone.
Return value
#ZONE_RADIUS: self
-
- Dcs.DCSTypes#Distance ZONE_RADIUS.Radius
-
The radius of the zone.
- ZONE_RADIUS:SetRadius(Radius)
-
Sets the radius of the zone.
Parameter
-
Dcs.DCSTypes#Distance Radius: The radius of the zone.
Return value
Dcs.DCSTypes#Distance: The radius of the zone.
-
- ZONE_RADIUS:SetVec2(Vec2)
-
Sets the Dcs.DCSTypes#Vec2 of the zone.
Parameter
-
Dcs.DCSTypes#Vec2 Vec2: The new location of the zone.
Return value
Dcs.DCSTypes#Vec2: The new location of the zone.
-
- ZONE_RADIUS:SmokeZone(SmokeColor, Points)
-
Smokes the zone boundaries in a color.
Parameters
-
Utilities.Utils#SMOKECOLOR SmokeColor: The smoke color. -
#number Points: (optional) The amount of points in the circle.
Return value
#ZONE_RADIUS: self
-
- Dcs.DCSTypes#Vec2 ZONE_RADIUS.Vec2
-
The current location of the zone.
Type ZONE_UNIT
The ZONE_UNIT class defined by a zone around a Wrapper.Unit#UNIT with a radius.
Field(s)
- #string ZONE_UNIT.ClassName
- ZONE_UNIT:GetRandomVec2()
-
Returns a random location within the zone.
Return value
Dcs.DCSTypes#Vec2: The random location within the zone.
- ZONE_UNIT:GetVec2()
-
Returns the current location of the Wrapper.Unit#UNIT.
Return value
Dcs.DCSTypes#Vec2: The location of the zone based on the Wrapper.Unit#UNITlocation.
- ZONE_UNIT:GetVec3(Height)
-
Returns the Dcs.DCSTypes#Vec3 of the ZONE_UNIT.
Parameter
-
Dcs.DCSTypes#Distance Height: The height to add to the land height where the center of the zone is located.
Return value
Dcs.DCSTypes#Vec3: The point of the zone.
-
- ZONE_UNIT:New(ZoneName, ZoneUNIT, Radius)
-
Constructor to create a ZONE_UNIT instance, taking the zone name, a zone unit and a radius.
Parameters
-
#string ZoneName: Name of the zone. -
Wrapper.Unit#UNIT ZoneUNIT: The unit as the center of the zone. -
Dcs.DCSTypes#Distance Radius: The radius of the zone.
Return value
#ZONE_UNIT: self
-