Script GCICAP

Overview

Autonomous GCI and CAP script for DCS: World.

The script provides an autonomous model of combat air patrols and ground controlled interceptors for use with DCS World by mission builders.

After minimal setup the script will automatically spawn CAP and GCI flights for two sides and give them patrol and intercept tasks as well as returning them to base when threats cease to be detected.

Originally created by Snafu, enhanced and further modified by Stonehouse, Rivvern, Chameleon Silk.

Rewritten by lukrop.

Links

Github repository: https://github.com/lukrop/GCICAP

Info:

  • Copyright: 2016 Snafu, Stonehouse, Rivvern, Chameleon Silk, lukrop.
  • License: Modified MIT. See LICENSE file.
  • Author: Snafu,Stonehouse,Rivvern,Chameleon Silk,lukrop

Tables

gcicap.red.gci.messages_to Names of red groups which will receive GCI messages.
gcicap.blue.gci.messages_to Names of blue groups which will receive GCI messages.

Fields

gcicap.log Enable/disable log messages completly
gcicap.log_level Sets how verbose the log output will be.
gcicap.interval Interval, in seconds, of main and vectorToTarget functions.
gcicap.red.borders_enabled Enable/disable borders for the red side.
gcicap.blue.borders_enabled Enable/disable borders for the blue side.
gcicap.cap.min_alt CAP minimum altitudes in meters.
gcicap.cap.max_alt CAP maximum altitudes in meters.
gcicap.cap.speed Speed for CAP flights on their CAP route.
gcicap.gci.speed Speed for GCI flights on intercept speed is in m/s.
gcicap.cap.max_engage_distance Maximum engage distance for CAP flights as long as they are on patrol.
gcicap.cap.waypoints_count Amount of waypoints inside the CAP zone.
gcicap.red.cap.start_airborne Enable/disable red CAP flights airborne start.
gcicap.blue.cap.start_airborne Enable/disable blue CAP flights airborne start.
gcicap.red.cap.zones_count Amount of red CAP zones.
gcicap.blue.cap.zones_count Amount of blue CAP zones.
gcicap.red.cap.groups_count Amount of red CAP groups concurrently in the air.
gcicap.blue.cap.groups_count Amount of blue CAP groups concurrently in the air.
gcicap.red.cap.group_size Group size of red CAP flights.
gcicap.blue.cap.group_size Group size of blue CAP flights.
gcicap.red.gci.groups_count Maximum amount of concurrent red intercepts.
gcicap.blue.gci.groups_count Maximum amount of concurrent blue intercepts.
gcicap.red.gci.group_size Group size of red GCI flights.
gcicap.blue.gci.group_size Group size of blue GCI flights.
gcicap.red.gci.messages Enable/disable GCI messages for red
gcicap.blue.gci.messages Enable/disable GCI messages for blue
gcicap.gci.message_time How long a GCI message will be shown in seconds.
gcicap.red.gci.messages_metric Display GCI messages with metric measurment for red.
gcicap.blue.gci.messages_metric Display GCI messages with metric measurment for blue.
gcicap.red.cap.spawn_mode How red CAP flights are spawned.
gcicap.red.gci.spawn_mode How red GCI flights are spawned.
gcicap.blue.cap.spawn_mode How blue CAP flights are spawned.
gcicap.blue.gci.spawn_mode How blue GCI flights are spawned.
gcicap.blue.hide_groups Hide or reveal blue air units in the mission.
gcicap.red.hide_groups Hide or reveal red air units in the mission.
gcicap.red.cap.enabled Enable/disable red CAP flights.
gcicap.blue.cap.enabled Enable/disable blue CAP flights.
gcicap.red.gci.enabled Enable/disable red GCI flights.
gcicap.blue.gci.enabled Enable/disable blue GCI flights.
gcicap.red.limit_resources Enabel/disable resource limitation for red.
gcicap.blue.limit_resources Enabel/disable resource limitation for blue.
gcicap.red.supply Amount of groups(!) red has at it's disposal.
gcicap.blue.supply Amount of groups(!) red has at it's disposal.
gcicap.red.cap.zone_name Name of the trigger zone which defines red CAP zones.
gcicap.blue.cap.zone_name Name of the trigger zone which defines blue CAP zones.
gcicap.red.border_group Name of group which waypoints define the red border.
gcicap.blue.border_group Name of group which waypoints define the blue border.
gcicap.gci.template_prefix GCI template unit's names prefix.
gcicap.cap.template_prefix CAP template unit's names prefix.
gcicap.template_count Count of template units.
gcicap.red.awacs Wether red will also acquire targets by AWACS aircraft.
gcicap.blue.awacs Wether blue will also acquire targets by AWACS aircraft.

Class gcicap.Flight

gcicap.Flight.getFlight (group) Returns the flight for the given group.
gcicap.Flight:new (group, airbase, task, param) Creates a new flight.
gcicap.Flight:remove (self) Removes the flight
gcicap.Flight:leaveCAPZone () Decreases active flights counter in this flights zone.
gcicap.Flight:enterCAPZone () Increases active flights counter in this flights zone.
gcicap.Flight:vectorToTarget (intruder[, cold]) Tasks the flight to search and engage the target.
gcicap.Flight:taskWithCAP ([cold]) Tasks flight with combat air patrol.
gcicap.Flight:taskWithRTB ([airbase[, cold]]) Tasks the flight to return to it's homeplate.

Functions

gcicap.coalitionToSide (coal) Converts coaltion number to side string.
gcicap.sideToCoalition (side) Converts side string to coaltion number.
gcicap.getFirstActiveUnit (group) Returns first active unit of a group.
gcicap.getClosestAirfieldToUnit (side, unit) Returns the closest airfield to unit.
closestAirfieldReturn Table returned by getClosestAirfieldToUnit.
gcicap.getClosestFlightsToUnit (side, unit) Returns the closest flights to the given unit.
closestFlightsReturn Table returned by getClosestFlightsToUnit.
gcicap.buildCAPRoute (zone[, wp_count]) Returns a table containting a CAP route.
gcicap.taskEngage (group[, max_dist]) Tasks group to automatically engage any spotted targets.
gcicap.taskEngageInZone (group, center, radius) Tasks group to engage targets inside a zone.
gcicap.taskEngageGroup (group, target) Tasks group to engage a group.
gcicap.spawnFighterGroup (side, name, size, airbase, spawn_mode, task[, cold]) Spawns a fighter group.
gcicap.despawnHandler (event) Handle despawns/removal of flights created by GCICAP.
gcicap.spawnCAP (side, zone, spawn_mode) Spawns a CAP flight.
gcicap.spawnGCI (side, intruder, airbase) Spawns a GCI flight.
gcicap.init () Initialization function Checks if all template units are present.
gcicap.main () Main function.


Tables

gcicap.red.gci.messages_to
Names of red groups which will receive GCI messages. Leave blank for all groups of coalition

Usage:

    gcicap.red.gci.messages_to = { "my group 1", "GCI Flight" }
gcicap.blue.gci.messages_to
Names of blue groups which will receive GCI messages. See gcicap.red.gci.messages_to for format.

Fields

gcicap.log
Enable/disable log messages completly
gcicap.log_level
Sets how verbose the log output will be. Possible values are "info", "warning" and "error". I recommend "error" for production.
gcicap.interval
Interval, in seconds, of main and vectorToTarget functions. Default 30 seconds.
gcicap.red.borders_enabled
Enable/disable borders for the red side. CAP units only engage if enemy units intrude their airspace
gcicap.blue.borders_enabled
Enable/disable borders for the blue side. CAP units only engage if enemy units intrude their airspace
gcicap.cap.min_alt
CAP minimum altitudes in meters. Default 4500
gcicap.cap.max_alt
CAP maximum altitudes in meters. Default 7500
gcicap.cap.speed
Speed for CAP flights on their CAP route. speed is in m/s. Default 220.
gcicap.gci.speed
Speed for GCI flights on intercept speed is in m/s. Default 300.
gcicap.cap.max_engage_distance
Maximum engage distance for CAP flights as long as they are on patrol. this might be overruled by an intercept vector given from ground control (EWR). Default 15000.
gcicap.cap.waypoints_count
Amount of waypoints inside the CAP zone. Default 10.
gcicap.red.cap.start_airborne
Enable/disable red CAP flights airborne start. set to true for CAP flight to start airborne at script initialisation (mission start), false for taking off from the airfield. Default true.
gcicap.blue.cap.start_airborne
Enable/disable blue CAP flights airborne start.
gcicap.red.cap.zones_count
Amount of red CAP zones. placed with triggerzones in the ME.
gcicap.blue.cap.zones_count
Amount of blue CAP zones.
gcicap.red.cap.groups_count
Amount of red CAP groups concurrently in the air.
gcicap.blue.cap.groups_count
Amount of blue CAP groups concurrently in the air.
gcicap.red.cap.group_size
Group size of red CAP flights. Can be "2", "4" or "randomized"

If "2" it consists of 2 planes, if "4" it consists of 4 planes if "randomized", the CAP groups consist of either 2 or 4 planes

gcicap.blue.cap.group_size
Group size of blue CAP flights. See gcicap.red.cap.group_size
gcicap.red.gci.groups_count
Maximum amount of concurrent red intercepts.
gcicap.blue.gci.groups_count
Maximum amount of concurrent blue intercepts.
gcicap.red.gci.group_size
Group size of red GCI flights. Can be "2", "4" or "dynamic"

If "2" it consists of 2 planes, if "4" it consists of 4 planes if "dynamic", the GCI groups consist of as much aircrafts as the intruder group.

gcicap.blue.gci.group_size
Group size of blue GCI flights. See gcicap.red.gci.group_size
gcicap.red.gci.messages
Enable/disable GCI messages for red
gcicap.blue.gci.messages
Enable/disable GCI messages for blue
gcicap.gci.message_time
How long a GCI message will be shown in seconds.
gcicap.red.gci.messages_metric
Display GCI messages with metric measurment for red. If false the imperial system is used.
gcicap.blue.gci.messages_metric
Display GCI messages with metric measurment for blue. If false the imperial system is used.
gcicap.red.cap.spawn_mode
How red CAP flights are spawned. can be "parking", "takeoff" or "air" and defines the way the fighters spawn takeoff is NOT RECOMMENDED currently since their occur timing issues with tasking if a flight is queued for takeoff and not already in the game world while getting tasked

Default 'parking'

gcicap.red.gci.spawn_mode
How red GCI flights are spawned.

See also:

gcicap.blue.cap.spawn_mode
How blue CAP flights are spawned.

See also:

gcicap.blue.gci.spawn_mode
How blue GCI flights are spawned.

See also:

gcicap.blue.hide_groups
Hide or reveal blue air units in the mission.
gcicap.red.hide_groups
Hide or reveal red air units in the mission.
gcicap.red.cap.enabled
Enable/disable red CAP flights.
gcicap.blue.cap.enabled
Enable/disable blue CAP flights.
gcicap.red.gci.enabled
Enable/disable red GCI flights.
gcicap.blue.gci.enabled
Enable/disable blue GCI flights.
gcicap.red.limit_resources
Enabel/disable resource limitation for red. If set to true limits the amount of groups a side can spawn.
gcicap.blue.limit_resources
Enabel/disable resource limitation for blue.

See also:

gcicap.red.supply
Amount of groups(!) red has at it's disposal. In other words how many Groups of airplanes this side can spawn.
gcicap.blue.supply
Amount of groups(!) red has at it's disposal.

See also:

gcicap.red.cap.zone_name
Name of the trigger zone which defines red CAP zones. This will be postfixed with the number of the zone. e.g. "redCAPzone3" or "blueCAPzone1".

Default: 'redCAPzone'.

gcicap.blue.cap.zone_name
Name of the trigger zone which defines blue CAP zones. Default: 'blueCAPzone'.

See also:

gcicap.red.border_group
Name of group which waypoints define the red border. Default: 'redborder'.
gcicap.blue.border_group
Name of group which waypoints define the blue border. Default: 'blueborder'.
gcicap.gci.template_prefix
GCI template unit's names prefix.
gcicap.cap.template_prefix
CAP template unit's names prefix.
gcicap.template_count
Count of template units. Remember that this means you need that many template units for each type. E.g. if the template_count is 2 you would need two GCI and two CAP template units for each side.
gcicap.red.awacs
Wether red will also acquire targets by AWACS aircraft. This is is currently broken since isTargetDetected doesn't seem to work with AWACS airplanes. Needs a workaround.

Default false.

gcicap.blue.awacs
Wether blue will also acquire targets by AWACS aircraft.

See also:

Class gcicap.Flight

Flight class.
gcicap.Flight.getFlight (group)
Returns the flight for the given group.

Parameters:

  • group string or Group this can be a Group object or the group name.

Returns:

    gcicap.Flight the flight for the given group.
gcicap.Flight:new (group, airbase, task, param)
Creates a new flight.

Parameters:

  • group Group group of the flight.
  • airbase Airbase homplate of the new flight.
  • task string task of the new flight. Can be "cap" or "gci".
  • param task parameter. This can be a zone table if it's a CAP flight or it could be a target unit if it's a GCI flight.
gcicap.Flight:remove (self)
Removes the flight

Parameters:

gcicap.Flight:leaveCAPZone ()
Decreases active flights counter in this flights zone. Actually just decreases the active flights counter of a zone. Does NOT task the flight itself.
gcicap.Flight:enterCAPZone ()
Increases active flights counter in this flights zone. Actually just increases the active flights counter of a zone. Does NOT task the flight itself.
gcicap.Flight:vectorToTarget (intruder[, cold])
Tasks the flight to search and engage the target.

Parameters:

  • intruder Unit target unit.
  • cold boolean whether the flight should not destroy the target and just follow it. Default false. (optional)
gcicap.Flight:taskWithCAP ([cold])
Tasks flight with combat air patrol. Creates waypoints inside it's assigned zone and tasks the flight with patroling along the route.

Parameters:

  • cold boolean If set to true the flight won't engage any enemy unit's it detects by itself. Default false. (optional)
gcicap.Flight:taskWithRTB ([airbase[, cold]])
Tasks the flight to return to it's homeplate.

Parameters:

  • airbase Airbase optionally use this as homeplate/airbase to return to. (optional)
  • cold boolean If set to true the flight won't engage any targets it detects on the way back to base. Default false. (optional)

Functions

gcicap.coalitionToSide (coal)
Converts coaltion number to side string. 0 = "neutral", 1 = "red", 2 = "blue"

Parameters:

  • coal number coaltion number.

Returns:

    string side
gcicap.sideToCoalition (side)
Converts side string to coaltion number. 0 = "neutral", 1 = "red", 2 = "blue"

Parameters:

Returns:

    number coalition number.

See also:

gcicap.getFirstActiveUnit (group)
Returns first active unit of a group.

Parameters:

  • group Group group whose first active unit to return.

Returns:

    Unit first active unit of group.
gcicap.getClosestAirfieldToUnit (side, unit)
Returns the closest airfield to unit. Returned airfield is controlled by given side. This function also returns the distance to the unit.

Parameters:

  • side string side string, either "red" or "blue". The airfield returned has to be controlled by this side.
  • unit Unit unit to use as reference.

Returns:

    table closestAirfieldReturn
closestAirfieldReturn
Table returned by getClosestAirfieldToUnit.

Fields:

  • airfield Airbase the Airbase object
  • distance number the distance in meters to the unit.
gcicap.getClosestFlightsToUnit (side, unit)
Returns the closest flights to the given unit. Flights returned are of given side. This function also returns their distance to the unit. The returned flights are sorted by distance. First is the closest.

Parameters:

  • side string side whose flights to search.
  • unit Unit unit object used as reference.

Returns:

    table Array sorted by distance containing closestFlightsReturn tables.
closestFlightsReturn
Table returned by getClosestFlightsToUnit.

Fields:

  • flight gcicap.Flight object
  • distance number distance in meters from the unit.
gcicap.buildCAPRoute (zone[, wp_count])
Returns a table containting a CAP route. Route originating from given airbase, waypoints are placed randomly inside given zone. Optionally you can specify the amount of waypoints inside the zone.

Parameters:

  • zone string trigger zone name
  • wp_count number count of waypoints to create. (optional)
gcicap.taskEngage (group[, max_dist])
Tasks group to automatically engage any spotted targets.

Parameters:

  • group Group group to task.
  • max_dist number maximum engagment distance. Targets further out (from the route) won't be engaged. (optional)
gcicap.taskEngageInZone (group, center, radius)
Tasks group to engage targets inside a zone.

Parameters:

  • group Group group to task.
  • center Vec2 or Point center of the zone.
  • radius number zone radius.
gcicap.taskEngageGroup (group, target)
Tasks group to engage a group.

Parameters:

  • group Group group to task.
  • target Group group that should be engaged by given group.
gcicap.spawnFighterGroup (side, name, size, airbase, spawn_mode, task[, cold])
Spawns a fighter group.

Parameters:

  • side string side of the newly created group. Can be "red" or "blue".
  • name string new group name.
  • size number count of aircraft in the new group.
  • airbase Airbase home plate of the new group.
  • spawn_mode string How the new group will be spawned. Can be 'parking' or 'air'. 'parking' will spawn them at the ramp wit engines turned off. 'air' will spawn them in the air already flying.
  • task string Task of the new group. Can either be 'cap', for combat air patrol, or 'gci', for ground controlled intercept.
  • cold boolean if set to true the newly group won't engage any enemys until tasked otherwise. Default false. (optional)

Returns:

    Group or nil newly spawned group or nil on failure.
gcicap.despawnHandler (event)
Handle despawns/removal of flights created by GCICAP. Don't call this function. It's automatically called by MIST.

Parameters:

  • event event table
gcicap.spawnCAP (side, zone, spawn_mode)
Spawns a CAP flight.

Parameters:

  • side string side for the new CAP.
  • zone string CAP zone (trigger zone) name.
  • spawn_mode string how the new CAP will be spawned. Can be 'parking' or 'air'.
gcicap.spawnGCI (side, intruder, airbase)
Spawns a GCI flight.

Parameters:

  • side string side for the new GCI.
  • intruder Unit unit to intercept.
  • airbase Airbase airbase where this GCI should spawn.
gcicap.init ()
Initialization function Checks if all template units are present. Creates border polygons if borders enabled.
gcicap.main ()
Main function. Run approx. every gcicap.interval sconds. A random amount of 0 to 2 seconds is added for declustering.
generated by LDoc 1.4.3 Last updated 2016-01-09 17:49:19