Controller is an object that performs A.I.-routines. Other words controller is an instance of A.I.. Controller stores current main task, active enroute tasks and behavior options. Controller performs commands.
Please, read DCS A-10C GUI Manual EN.pdf chapter "Task Planning for Unit Groups", page 91 to understand A.I. system of DCS:A-10C.
function Controller.setOnOff(Controller self, boolean value)
enables and disables the controller.
Note: Now it works only for ground / naval groups!
value
function Controller.setTask(Controller self, Task task)
resets current task and then sets the task to the controller. Task is a table that contains task identifier and task parameters.
function Controller.resetTask(Controller self)
resets current task of the controller
Common task format is:
Task = { id = string, params = { } }
String task identifier.
function Controller.pushTask(Controller self, Task task)
pushes the task to the front of the queue and makes the task active. Further call of function Controller.setTask() function will stop current task, clear the queue and set the new task active. If the task queue is empty the function will work like function Controller.setTask() function.
function Controller.popTask(Controller self)
pops current (front) task from the queue and makes active next task in the queue (if exists). If no more tasks in the queue the function works like function Controller.resetTask() function. Does nothing if the queue is empty.
boolean function Controller.hasTask(Controller self)
returns true if the controller has a task.
1. NoTask
An empty task. It finished just being started.
NoTask = { id = 'NoTask', params = { } }
2. AttackGroup
Attacking the target group (airborne, ground or naval).
AttackGroup = { id = 'AttackGroup', params = { groupId = Group.ID, weaponType = number, expend = enum AI.Task.WeaponExpend, attackQty = number, directionEnabled = boolean, direction = Azimuth, altitudeEnabled = boolean, altitude = Distance, attackQtyLimit = boolean, } }
groupId
weaponType (optional)
Weapon flags are enlisted in Weapon.flag table.
Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.
This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.
The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.
Note: this looks like not a good solution. It would be better to have two number parameters: required parameter attackQty for "Bombing" and "BombingRunway" tasks and attackQtyLimit for "AttackGroup" and "AttackUnit" tasks.
Indicates ingress direction is defined.
Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.
Indicates attack start altitude is defined.
Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude.
3. AttackUnit
Attacking the target (airborne, ground or naval).
AttackUnit = { id = 'AttackUnit', params = { unitId = Unit.ID, weaponType = number, expend = enum AI.Task.WeaponExpend attackQty = number, direction = Azimuth, attackQtyLimit = boolean, groupAttack = boolean, } }
The task has the same parameters of AttackGroup, but has unitId parameter instead of groupId and additional parameter groupAttack.
Inner unique identifier of the unit to attack.
Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft.
4. Bombing
Delivering weapon at the point on the ground.
Bombing = { id = 'Bombing', params = { point = Vec2, weaponType = number, expend = enum AI.Task.WeaponExpend, attackQty = number, direction = Azimuth, groupAttack = boolean, } }
The task has the same parameters of AttackUnit task, but has parameters point instead of unitId, plus attackQty and minus attackQtyLimit parameters.
point
attackQty
5. AttackMapObject
Attacking the map object (building, structure, e.t.c).
AttackMapObject = { id = 'AttackMapObject', params = { point = Vec2, weaponType = number, expend = enum AI.Task.WeaponExpend, attackQty = number, direction = Azimuth, groupAttack = boolean, } }
The task has the same parameters AttackUnit task has, but has parameters point instead of unitId.
point
Object id is not used here because Mission Editor doesn't support map object identificators.
6. BombingRunway
Delivering weapon on the runway.
BombingRunway = { id = 'BombingRunway', params = { runwayId = AirdromeId, weaponType = number, expend = enum AI.Task.WeaponExpend, attackQty = number, direction = Azimuth, groupAttack = boolean, } }
The task has the same parameters Bombing task has, but has parameter runwayId instead of point.
runwayId
attackQty
7. Orbit
Flying orbit.
Orbit = { id = 'Orbit', params = { pattern = enum AI.Task.OribtPattern, point = Vec2, point2 = Vec2, speed = Distance, altitude = Distance } }
pattern
point (optional)
speed (optional)
altitude (optional)
point2 (optional)
Orbit Patterns.
speed and altitude are an optional parameters. If not defined aircraft will fly orbit at altitude of first waypoint and with speed equal 1.5 of stall airspeed.
8. Refueling
Refueling from the nearest tanker. No parameters.
Refueling = { id = 'Refueling', params = {} }
9. Land
Landing at the ground. For helicopters only.
Land = { id= 'Land', params = { point = Vec2, durationFlag = boolean, duration = Time } }
point
durationFlag
duration
10. Follow
Following another airborne group. The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. If another group is on land the unit / group will orbit around.
Follow = { id = 'Follow', params = { groupId = Group.ID, pos = Vec3, lastWptIndexFlag = boolean, lastWptIndex = number } }
groupId
pos
lastWptIndexFlag
lastWptIndex
11. Escort
Escort another airborne group. The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. The unit / group will also protect that group from threats of specified types.
Escort = { id = 'Escort', params = { groupId = Group.ID, pos = Vec3, lastWptIndexFlag = boolean, lastWptIndex = number, engagementDistMax = Distance, targetTypes = array of AttributeName } }
The parameters are the same Follow task has, but plus 2 additional:
engagementDistMax
targetTypes
12. Mission
Mission is a complex task. Performing the Mission means flying the route and performing tasks at each waypoint of the route.
Mission = { id = 'Mission', params = { route = { points = { [1] = { type = enum AI.Task.WaypointType, airdromeId = Airbase.ID, helipadId = Airbase.ID, action = enum AI.Task.TurnMethod, x = Distance, y = Distance, alt = Distance, alt_type = enum AI.Task.AltitudeType, speed = Distance, speed_locked = boolean, ETA = Time, ETA_locked = boolean, name = string, task = Task }, [2] = { ... }, ... [N]= { ... } } }, } }
route
1. FireAtPoint
Firing at point until there is ammo.
FireAtPoint = { id = 'FireAtPoint', params = { point = Vec2, radius = Distance, } }
point
radius (optional)
2. Hold
Not moving. No parameters.
Hold = { id = 'Hold', params = { } }
3. Mission
Mission is a complex task. Performing the Mission means following the route and performing tasks at each waypoint of the route.
Mission = { id = 'Mission', params = { route = { points = { [1] = { action = enum AI.Task.VehicleFormation, x = Distance, y = Distance, speed = Distance, ETA = Time, ETA_locked = boolean, name = string, task = Task }, [2] = { ... }, ... [N]= { ... } } }, } }
route
points
1. FAC_AttackGroup
The task makes the group/unit a FAC and orders the FAC to control the target (enemy ground group) destruction. The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
If the task is assigned to the group lead unit will be a FAC.
FAC_AttackGroup = { id = 'FAC_AttackGroup', params = { groupId = Group.ID, weaponType = number, designation = enum AI.Task.Designation, datalink = boolean } }
weaponType (optional)
Weapon flags are enlisted in Weapon.flag table.
designation (optional)
datalink (optional)
1. EngageTargets
All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.
Engaging a targets of defined types.
EngageTargets ={ id = 'EngageTargets', params = { maxDist = Distance, targetTypes = array of AttributeName, priority = number } }
maxDist
targetTypes
2. EngageTargetsInZone
Engaging a targets of defined types at circle-shaped zone.
EngageTargetsInZone = { id = 'EngageTargetsInZone', params = { point = Vec2, zoneRadius = Distance, targetTypes = array of AttributeName, priority = number } }
point
zoneRadius
targetTypes
3. Engage Group
Engaging a group. The task does not assign the target group to the unit/group to attack now; it just allows the unit/group to engage the target group as well as other assigned targets.
EngageGroup = { id = 'EngageGroup', params = { groupId = Group.ID, weaponType = number, expend = enum AI.Task.WeaponExpend, attackQty = number, direction = Azimuth, attackQtyLimit = boolean, priority = number } }
The task has same parameters of AttackGroup task, plus priority.
4. EngageUnit
Engaging an unit. By this task you do not assign the target to the unit/group to attack now, you just allow the unit/group to engage the target as well as other assigned targets.
EngageUnit = { id = 'EngageUnit', params = { unitId = UnitId, weaponType = number, expend = enum AI.Task.WeaponExpend, attackQty = number, direction = Azimuth, attackQtyLimit = boolean, groupAttack = boolean, priority = number } }
The task has same parameters of AttackUnit task, plus priority.
5. AWACS
Aircraft will act as an AWACS for friendly units (will provide them with information about contacts). No parameters.
AWACS = { id = 'AWACS', params = { } }
6. Tanker
Aircraft will act as a tanker for friendly units. No parameters.
Tanker = { id = 'Tanker', params = { } }
1. EWR
Ground unit (EW-radar) will act as an EWR for friendly units (will provide them with information about contacts). No parameters.
EWR = { id = 'EWR', params = { } }
1. FAC_EngageGroup
The task makes the group/unit a FAC and lets the FAC to choose the target (enemy ground group) as well as other assigned targets. The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
If the task is assigned to the group lead unit will be a FAC.
FAC_EngageGroup = { id = 'FAC_AttackGroup', params = { groupId = Group.ID, weaponType = number, designation = enum AI.Task.Designation, datalink = boolean, priority = number } }
The parameters are the same FAC_AttackGroup task has plus priority.
2. FAC
The task makes the group/unit a FAC andlets the FAC to choose a targets (enemy ground group) around as well as other assigned targets. The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
If the task is assigned to the group lead unit will be a FAC.
FAC = { id = 'FAC', params = { radius = Distance, priority = number } }
radius
1. Controlled Task
This is a wrapper for a task that makes possible to assign special conditions to stop a task.
ControlledTask = { id = 'ControlledTask', params = { task = Task, stopCondition = StopCondition, } }
StopCondition consists of several sub-conditions. Each sub-condition is optional. If at least one of the conditions has met, the task will be stopped. All the sub-conditions will being checked periodically.
StopCondition = { time = Time, userFlag = string, userFlagValue = boolean, condition = string, duration = Time, lastWaypoint = number, }
time (optional)
or
User Flag (optional).
userFlag
userFlagValue
The condition will be met only is the userFlag has value that equals to userFlagValue.
or
condition (optional)
function [generated name]() return [Lua code] end
The condition will be met when the function will return true.
or
duration (optional)
or
lastWaypoint (optional)
2. Combo Task
Combo Task is a list of actions to run them in the order they are enlisted.
ComboTask = { id = 'ComboTask', params = { tasks = { [1] = Task, [2] = Task, ... [N] = Task } } }
The task may be useful if it is necessary to assign list of actions to the group/unit. For example, actions list created for the waypoint in Mission Editor is a Combo Task. It is only possible to fill Combo Task with tasks. To fill the Combo Task with Commands and Behavior Options you should use Wrapped Action task.
3. Wrapped Action
A command wrapped into task. This construction may be useful in ComboTask.
WrappedAction = { id = 'WrappedAction', params = { action = Command } }
Commands are instant actions those required zero time to perform. Commands may be used both for control unit/group behavior and control game mechanics.
function Controller.setCommand(Controller self, Command command)
sets the command to perform by controller.
Command
Table that contains command identifier and command parameters.
Commands have following format
Command = { id = string, params = { } }
id is a string identifier of the command
1. No Action
Empty action. No parameters.
NoAction = { id = 'NoAction', params = { } }
2. Script
Runs Lua-script.
Script = { id = 'Script', params = { command = string } }
command
3. Set callsign
Sets callsign to the group. It is only valid for western groups those have hierarchic callsigns: [group callname][flight number][aircraft number]. You can change [group callname][flight number] part of callsign for all aircraft in the group of for single aircraft.
SetCallsign = { id = 'SetCallsign', params = { callname = number, number = number, } }
callname
Aircrafts
Callname | Identifier |
Enfield | 1 |
Springfield | 2 |
Uzi | 3 |
Colt | 4 |
Dodge | 5 |
Ford | 6 |
Chevy | 7 |
Pontiac | 8 |
Hawg | 9 |
Boar | 10 |
Pig | 11 |
Tusk | 12 |
AWACS
Callname | Identifier |
Overlord | 1 |
Magic | 2 |
Wizard | 3 |
Focus | 4 |
Darkstar | 5 |
Tanker
Callname | Identifier |
Texaco | 1 |
Arco | 2 |
Shell | 3 |
Ground JTAC
Callname | Identifier |
Axeman | 1 |
Darknight | 2 |
Warrior | 3 |
Pointer | 4 |
Eyeball | 5 |
Moonbeam | 6 |
Whiplash | 7 |
Finger | 8 |
Pinpoint | 9 |
Ferret | 10 |
Shaba | 11 |
Playboy | 12 |
Hammer | 13 |
Jaguar | 14 |
Deathstar | 15 |
Anvil | 16 |
Firefly | 17 |
Mantis | 18 |
Badger | 19 |
number
4. Set frequency
Sets frequency and modulation to the unit's radio or to the radio of each unit in the group.
SetFrequency = { id = 'SetFrequency', params = { frequency = number, modulation = enum radio.modulation, } }
modulation
frequency
5. Switch waypoint
Switches current leg of the route. Has effect only if the "Mission" task is active.
SwitchWaypoint = { id = 'SwitchWaypoint', params = { fromWaypointIndex = number, goToWaypointIndex = number, } }
New leg is defined by a two parameters:
fromWaypointIndex
goToWaypointIndex
6. Stop route
Stops / resumes following the route. Has effect only if the "Mission" task is active.
StopRoute = { id = 'StopRoute', params = { value = boolean, } }
value
7. Switch action
Switches to an another action of the actions list of the waypoint. Has effect only if the "Mission" task is active.
SwitchAction = { id = 'SwitchAction', params = { actionIndex = number, } }
actionIndex
8. Invisible
Makes the unit/group invisible for enemy A.I.
SetInvisible = { id = 'SetInvisible', params = { value = boolean } }
value
9. Immortal
Makes the unit/group immortal.
SetImmortal = { id = 'SetImmortal', params = { value = boolean } }
value
10. Activate beacon
Activates the beacon onboard the aircraft or onboard first aircraft of the group. Note that the only one beacon can be activate at the same time. If you activated new beacon having another beacon active that old beacon will be deactivated.
ActivateBeacon = { id = 'ActivateBeacon', params = { type = number, system = number, name = string, callsign = string, frequency = number, } }
type
BEACON_TYPE_NULL = 0 BEACON_TYPE_VOR = 1 BEACON_TYPE_DME = 2 BEACON_TYPE_VOR_DME = 3 BEACON_TYPE_TACAN = 4 BEACON_TYPE_VORTAC = 5 BEACON_TYPE_RSBN = 32 BEACON_TYPE_BROADCAST_STATION = 1024 BEACON_TYPE_HOMER = 8 BEACON_TYPE_AIRPORT_HOMER = 4104 BEACON_TYPE_AIRPORT_HOMER_WITH_MARKER = 4136 BEACON_TYPE_ILS_FAR_HOMER = 16408 BEACON_TYPE_ILS_NEAR_HOMER = 16456 BEACON_TYPE_ILS_LOCALIZER = 16640 BEACON_TYPE_ILS_GLIDESLOPE = 16896 BEACON_TYPE_NAUTICAL_HOMER = 32776
system
SystemName = { PAR_10 = 1, RSBN_5 = 2, TACAN = 3, TACAN_TANKER = 4, ILS_LOCALIZER = 5, ILS_GLIDESLOPE = 6, BROADCAST_STATION = 7 }
name
callsign
frequency
11. Deactivate beacon
Deactivates beacon onboard the unit. If it is a group the beacon will be activated onboard a first unit of the group. No parameters.
{ id = 'DeactivateBeacon', params = { } }
12. EPLRS
Sets parameters of EPLRS datalink of the unit/group. If EPLRS command called for the airborne group then all aircrafts of the group will be affected. If EPLRS command called for vehicle group then only the first unit of the group will be affected. You can switch EPLRS on/off and change track number of the first unit of the vehicle group.
{ id = 'EPLRS', params = { value = boolean, groupId = number, } }
value
groupId
Option is a pair of identifier and value. Behavior options are global parameters those affect controller behavior in all tasks it performs.
Option identifiers and values are stored in table AI.Option in subtables Air, Ground and Naval.
OptionId = AI.Option.Air.id or AI.Option.Ground.id or AI.Option.Naval.id
OptionValue = AI.Option.Air.val[optionName] or AI.Option.Ground.val[optionName] or AI.Option.Naval.val[optionName]
function Controller.setOption(Controller self, OptionId optionId, OptionValue optionValue)
sets the option to the controller.
optionId
optionValue
Airborne units
Option | Values |
AI.Option.Air.id.NO_OPTION |
|
AI.Option.Air.id.ROE |
AI.Option.Air.val.ROE.WEAPON_FREE
AI.Option.Air.val.ROE.OPEN_FIRE_WEAPON_FREE AI.Option.Air.val.ROE.OPEN_FIRE AI.Option.Air.val.ROE.RETURN_FIRE AI.Option.Air.val.ROE.WEAPON_HOLD |
AI.Option.Air.id.REACTION_ON_THREAT |
AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION
AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENCE AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE AI.Option.Air.val.REACTION_ON_THREAT.ALLOW_ABORT_MISSION |
AI.Option.Air.id.RADAR_USING |
AI.Option.Air.val.RADAR_USING.NEVER
AI.Option.Air.val.RADAR_USING.FOR_ATTACK_ONLY AI.Option.Air.val.RADAR_USING.FOR_SEARCH_IF_REQUIRED AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH |
AI.Option.Air.id.FLARE_USING |
AI.Option.Air.val.FLARE_USING.NEVER
AI.Option.Air.val.FLARE_USING.AGAINST_FIRED_MISSILE AI.Option.Air.val.FLARE_USING.WHEN_FLYING_IN_SAM_WEZ AI.Option.Air.val.FLARE_USING.WHEN_FLYING_NEAR_ENEMIES |
AI.Option.Air.id.FORMATION | complex option. See the description below. |
AI.Option.Air.id.RTB_ON_BINGO |
true
false |
AI.Option.Air.id.SILENCE |
true
false |
Ground units
Option | Values |
AI.Option.Ground.id.NO_OPTION |
|
AI.Option.Ground.id.ROE |
AI.Option.Ground.val.ROE.OPEN_FIRE
AI.Option.Ground.val.ROE.RETURN_FIRE AI.Option.Ground.val.ROE.WEAPON_HOLD |
AI.Option.Ground.id.DISPERSE_ON_ATTACK |
true
false |
AI.Option.Ground.id.ALARM_STATE |
AI.Option.Ground.val.ALARM_STATE.AUTO,
AI.Option.Ground.val.ALARM_STATE.GREEN AI.Option.Ground.val.ALARM_STATE.RED |
Naval units
Option | Values |
AI.Option.Naval.id.NO_OPTION |
|
AI.Option.Naval.id.ROE |
AI.Option.Naval.val.ROE.OPEN_FIRE
AI.Option.Naval.val.ROE.RETURN_FIRE AI.Option.Naval.val.ROE.WEAPON_HOLD |
Formation is a complex parameter that consists of 3 sub-parameters: formation type, formation variant and formation orientation (left/right). Each sub-parameter is represented by a number. These three numbers are packed into a single number - the formation code.
Note: it is not an elegant solution, but we have a limitation here - option value may be a number or boolean. May be it will be reworked later.
[4 bytes formation code] = [2 bytes - formation type][1 byte - formation orientation][1 byte - formation variant]
Formations are enlisted in ./Scripts/Database/db_formations.Lua.
Formation type identifiers
local id = { NO_FORMATION = 0, --airplanes LINE_ABREAST = 1, TRAIL = 2, WEDGE = 3, ECHELON_RIGHT = 4, ECHELON_LEFT = 5, FINGER_FOUR = 6, SPREAD_FOUR = 7, --helicopters HEL_WEDGE = 8, HEL_ECHELON = 9, HEL_FRONT = 10, HEL_COLUMN = 11, -- MAX = 12 }
Formation orientation
Default orientation of each formation type determines by a formation geometry given in the script. All existed formation types have right orientation. To inverse orientation (to the left) the value of formation orientation sub-parameter must be 1.
Formation variant
Some formation types have several variants usually different by a density. Variants are enumerated from 1 to N. If the variant is 0 then default variant will be used.
Airplane formations "Trail", "Wedge", "Echelon Right", "Echelon Left", "Finger Four", "Spred Four" have two variants: "Open" and "Close" (default) and have no variable orientation. Helicopter formation "Echelon" has three variants "50x70", "50x300" (default), "50x600" and has variable orientation. Helicopter formation "Front" has three variants: "interval 300" (default), "interval 600" and has variable orientation. All other formations have no variants and no variable orientation.