# Module `DCSUnit`

## Global(s)

Unit |

## Type `Unit`

Unit.< | Unit.AmmoItem> Ammo
Unit.AmmoItem |
Unit.Category |
Unit.Desc |
Unit.DescAircraft |
Unit.DescAirplane |
Unit.DescHelicopter |
Unit.DescShip |
Unit.DescVehicle |
Unit.ID | Identifier of an unit. It assigned to an unit by the Mission Editor automatically.
Unit.IRST |
Unit.Optic |
Unit.OpticType |
Unit.Radar |
Unit.RadarType |
Unit.RefuelingSystem |
Unit.Sensor |
Unit.SensorType |
Unit.detectionDistanceAfterburner | ..., engines are in afterburner mode
Unit.detectionDistanceIdle | detection of tail-on target with heat signature = 1 in upper hemisphere, engines are in idle
Unit.detectionDistanceMaximal | ..., engines are in maximal mode
Unit:getAmmo() | Returns the unit ammunition.
Unit.getByName(name) | Returns unit object by the name assigned to the unit in Mission Editor.
Unit:getCallsign() | Returns the unit's callsign - the localized string.
Unit:getController() | Returns controller of the unit if it exist and nil otherwise
Unit:getDesc() | Returns unit descriptor.
Unit:getFuel() | Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks.
Unit:getGroup() | Returns the unit's group if it exist and nil otherwise
Unit:getID() | returns the unit's unique identifier.
Unit:getLife() | Returns the unit's health.
Unit:getLife0() | returns the unit's initial health.
Unit:getNumber() | Returns the unit's number in the group.
Unit:getPlayerName() | Returns name of the player that control the unit or nil if the unit is controlled by A.I.
Unit:getRadar() | returns two values: First value indicates if at least one of the unit's radar(s) is on.
Unit:getSensors() | Returns the unit sensors.
Unit:hasSensors(sensorType, ...) | Returns true if the unit has specified types of sensors.
Unit:isActive() | Returns if the unit is activated.

## Type `Unit.AmmoItem`

Unit.AmmoItem.count | ammunition count
Unit.AmmoItem.desc | ammunition descriptor

## Type `Unit.Category`

Unit.Category.AIRPLANE |
Unit.Category.GROUND_UNIT |
Unit.Category.HELICOPTER |
Unit.Category.SHIP |
Unit.Category.STRUCTURE |

## Type `Unit.Desc`

Unit.Desc.category | Unit Category
Unit.Desc.massEmpty | mass of empty unit
Unit.Desc.speedMax | istance / Time, --maximal velocity

## Type `Unit.DescAircraft`

Unit.DescAircraft.Hmax | Ceiling
Unit.DescAircraft.NyMax | maximal safe acceleration
Unit.DescAircraft.NyMin | minimal safe acceleration
Unit.DescAircraft.VyMax | #Distance / #Time, --maximal climb rate
Unit.DescAircraft.fuelMassMax | maximal inner fuel mass
Unit.DescAircraft.range | Operational range
Unit.DescAircraft.tankerType | refueling system type

## Type `Unit.DescAirplane`

Unit.DescAirplane.speedMax0 | Distance / Time maximal TAS at ground level
Unit.DescAirplane.speedMax10K | Distance / Time maximal TAS at altitude of 10 km

## Type `Unit.DescHelicopter`

Unit.DescHelicopter.HmaxStat | static ceiling

## Type `Unit.DescVehicle`

Unit.DescVehicle.maxSlopeAngle | maximal slope angle
Unit.DescVehicle.riverCrossing | can the vehicle cross a rivers

## Type `Unit.Optic`

Unit.Optic.opticType |

## Type `Unit.OpticType`

Unit.OpticType.IR | Infra-Red optic sensor
Unit.OpticType.LLTV | Low-level TV-sensor
Unit.OpticType.TV | TV-sensor

## Type `Unit.Radar`

Unit.Radar.detectionDistanceAir | detection distance for RCS=1m^2 airborne target, nil if radar doesn't support air search
Unit.Radar.detectionDistanceHRM | detection distance for RCS=1m^2 in high-resolution mapping mode, nil if radar has no HRM
Unit.Radar.detectionDistanceRBM | detection distance for RCS=1m^2 in real-beam mapping mode, nil if radar doesn't support surface/land search

## Type `Unit.Radar.detectionDistanceAir`

Unit.Radar.detectionDistanceAir.lowerHemisphere |
Unit.Radar.detectionDistanceAir.upperHemisphere |

## Type `Unit.Radar.detectionDistanceAir.lowerHemisphere`

Unit.Radar.detectionDistanceAir.lowerHemisphere.headOn |
Unit.Radar.detectionDistanceAir.lowerHemisphere.tailOn |

## Type `Unit.Radar.detectionDistanceAir.upperHemisphere`

Unit.Radar.detectionDistanceAir.upperHemisphere.headOn |
Unit.Radar.detectionDistanceAir.upperHemisphere.tailOn |

## Type `Unit.RadarType`

Unit.RadarType.AS | air search radar
Unit.RadarType.SS | surface/land search radar

## Type `Unit.RefuelingSystem`

Unit.RefuelingSystem.BOOM_AND_RECEPTACLE |
Unit.RefuelingSystem.PROBE_AND_DROGUE |

## Type `Unit.Sensor`

Unit.Sensor.type |
Unit.Sensor.typeName |

## Type `Unit.SensorType`

Unit.SensorType.IRST |
Unit.SensorType.OPTIC |
Unit.SensorType.RADAR |
Unit.SensorType.RWR |

## Global(s)

#Unit Unit

## Type `DCSUnit`

## Type `Angle`

## Type `Controller`

## Type `Distance`

## Type `Mass`

## Type `TypeName`

## Type `Unit`

An IRST.

### Field(s)

#list Unit.<

  Unit.AmmoItem> Ammo

#Unit.AmmoItem Unit.AmmoItem

#Unit.Category Unit.Category

#Unit.Desc Unit.Desc

#Unit.DescAircraft Unit.DescAircraft

#Unit.DescAirplane Unit.DescAirplane

#Unit.DescHelicopter Unit.DescHelicopter

#Unit.DescShip Unit.DescShip

#Unit.DescVehicle Unit.DescVehicle

Unit.ID

  Identifier of an unit. It assigned to an unit by the Mission Editor automatically.

#Unit.IRST Unit.IRST

#Unit.Optic Unit.Optic

#Unit.OpticType Unit.OpticType

#Unit.Radar Unit.Radar

#Unit.RadarType Unit.RadarType

#Unit.RefuelingSystem Unit.RefuelingSystem

#Unit.Sensor Unit.Sensor

#Unit.SensorType Unit.SensorType

#Distance Unit.detectionDistanceAfterburner

  ..., engines are in afterburner mode

#Distance Unit.detectionDistanceIdle

  detection of tail-on target with heat signature = 1 in upper hemisphere, engines are in idle

#Distance Unit.detectionDistanceMaximal

  ..., engines are in maximal mode

Unit:getAmmo()

  Returns the unit ammunition.

  ### Return value

  #Unit.Ammo:

Unit.getByName(name)

  Returns unit object by the name assigned to the unit in Mission Editor.

  If there is unit with such name or the unit is destroyed the function will return nil. The function provides access to non-activated units too.

  ### Parameter

  - `#string name` :

  ### Return value

  #Unit:

Unit:getCallsign()

  Returns the unit's callsign - the localized string.

  ### Return value

  #string:

Unit:getController()

  Returns controller of the unit if it exist and nil otherwise

  ### Return value

  #Controller:

Unit:getDesc()

  Returns unit descriptor.

  Descriptor type depends on unit category.

  ### Return value

  #Unit.Desc:

Unit:getFuel()

  Returns relative amount of fuel (from 0.0 to 1.0) the unit has in its internal tanks.

  If there are additional fuel tanks the value may be greater than 1.0.

  ### Return value

  #number:

Unit:getGroup()

  Returns the unit's group if it exist and nil otherwise

  ### Return value

  DCSGroup#Group:

Unit:getID()

  returns the unit's unique identifier.

  ### Return value

  #Unit.ID:

Unit:getLife()

  Returns the unit's health.

  Dead units has health <= 1.0

  ### Return value

  #number:

Unit:getLife0()

  returns the unit's initial health.

  ### Return value

  #number:

Unit:getNumber()

  Returns the unit's number in the group.

  The number is the same number the unit has in ME. It may not be changed during the mission. If any unit in the group is destroyed, the numbers of another units will not be changed.

  ### Return value

  #number:

Unit:getPlayerName()

  Returns name of the player that control the unit or nil if the unit is controlled by A.I.

  ### Return value

  #string:

Unit:getRadar()

  returns two values: First value indicates if at least one of the unit's radar(s) is on.

  Second value is the object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.

  ### Return value

  #boolean, Object#Object:

Unit:getSensors()

  Returns the unit sensors.

  ### Return value

  #Unit.Sensors:

Unit:hasSensors(sensorType, ...)

  Returns true if the unit has specified types of sensors.

  This function is more preferable than Unit.getSensors() if you don't want to get information about all the unit's sensors, and just want to check if the unit has specified types of sensors.

  ### Parameters

  - `#Unit.SensorType sensorType` : (= nil) Sensor type.

  - `...` : Additional parameters.

  ### Return value

  #boolean:

  ### Usage:

      If sensorType is Unit.SensorType.OPTIC, additional parameters are optic sensor types. Following example checks if the unit has LLTV or IR optics:
      unit:hasSensors(Unit.SensorType.OPTIC, Unit.OpticType.LLTV, Unit.OpticType.IR)
      If sensorType is Unit.SensorType.RADAR, additional parameters are radar types. Following example checks if the unit has air search radars:
      unit:hasSensors(Unit.SensorType.RADAR, Unit.RadarType.AS)
      If no additional parameters are specified the function returns true if the unit has at least one sensor of specified type.
      If sensor type is not specified the function returns true if the unit has at least one sensor of any type.

Unit:isActive()

  Returns if the unit is activated.

  ### Return value

  #boolean:

## Type `Unit.Ammo`

## Type `Unit.AmmoItem`

ammunition item: "type-count" pair.

### Field(s)

#number Unit.AmmoItem.count

  ammunition count

#Weapon.Desc Unit.AmmoItem.desc

  ammunition descriptor

## Type `Unit.Category`

Enum that stores unit categories.

### Field(s)

Unit.Category.AIRPLANE

Unit.Category.GROUND_UNIT

Unit.Category.HELICOPTER

Unit.Category.SHIP

Unit.Category.STRUCTURE

## Type `Unit.Desc`

A unit descriptor.

### Field(s)

#Unit.Category Unit.Desc.category

  Unit Category

#Mass Unit.Desc.massEmpty

  mass of empty unit

#number Unit.Desc.speedMax

  istance / Time, --maximal velocity

## Type `Unit.DescAircraft`

An aircraft descriptor.

### Field(s)

#Distance Unit.DescAircraft.Hmax

  Ceiling

#number Unit.DescAircraft.NyMax

  maximal safe acceleration

#number Unit.DescAircraft.NyMin

  minimal safe acceleration

#number Unit.DescAircraft.VyMax

  #Distance / #Time, --maximal climb rate

#Mass Unit.DescAircraft.fuelMassMax

  maximal inner fuel mass

#Distance Unit.DescAircraft.range

  Operational range

#Unit.RefuelingSystem Unit.DescAircraft.tankerType

  refueling system type

## Type `Unit.DescAirplane`

An airplane descriptor.

### Field(s)

#number Unit.DescAirplane.speedMax0

  Distance / Time maximal TAS at ground level

#number Unit.DescAirplane.speedMax10K

  Distance / Time maximal TAS at altitude of 10 km

## Type `Unit.DescHelicopter`

A helicopter descriptor.

### Field(s)

#Distance Unit.DescHelicopter.HmaxStat

  static ceiling

## Type `Unit.DescShip`

A ship descriptor.

## Type `Unit.DescVehicle`

A vehicle descriptor.

### Field(s)

#Angle Unit.DescVehicle.maxSlopeAngle

  maximal slope angle

#boolean Unit.DescVehicle.riverCrossing

  can the vehicle cross a rivers

## Type `Unit.ID`

## Type `Unit.IRST`

## Type `Unit.Optic`

An optic sensor.

### Field(s)

#Unit.OpticType Unit.Optic.opticType

## Type `Unit.OpticType`

Enum that stores types of optic sensors.

### Field(s)

Unit.OpticType.IR

  Infra-Red optic sensor

Unit.OpticType.LLTV

  Low-level TV-sensor

Unit.OpticType.TV

  TV-sensor

## Type `Unit.RWR`

An RWR.

## Type `Unit.Radar`

A radar.

### Field(s)

#Unit.Radar.detectionDistanceAir Unit.Radar.detectionDistanceAir

  detection distance for RCS=1m^2 airborne target, nil if radar doesn't support air search

#Distance Unit.Radar.detectionDistanceHRM

  detection distance for RCS=1m^2 in high-resolution mapping mode, nil if radar has no HRM

#Distance Unit.Radar.detectionDistanceRBM

  detection distance for RCS=1m^2 in real-beam mapping mode, nil if radar doesn't support surface/land search

## Type `Unit.Radar.detectionDistanceAir`

### Field(s)

#Unit.Radar.detectionDistanceAir.lowerHemisphere Unit.Radar.detectionDistanceAir.lowerHemisphere

#Unit.Radar.detectionDistanceAir.upperHemisphere Unit.Radar.detectionDistanceAir.upperHemisphere

## Type `Unit.Radar.detectionDistanceAir.lowerHemisphere`

### Field(s)

#Distance Unit.Radar.detectionDistanceAir.lowerHemisphere.headOn

#Distance Unit.Radar.detectionDistanceAir.lowerHemisphere.tailOn

## Type `Unit.Radar.detectionDistanceAir.upperHemisphere`

### Field(s)

#Distance Unit.Radar.detectionDistanceAir.upperHemisphere.headOn

#Distance Unit.Radar.detectionDistanceAir.upperHemisphere.tailOn

## Type `Unit.RadarType`

Enum that stores radar types.

### Field(s)

Unit.RadarType.AS

  air search radar

Unit.RadarType.SS

  surface/land search radar

## Type `Unit.RefuelingSystem`

Enum that stores aircraft refueling system types.

### Field(s)

Unit.RefuelingSystem.BOOM_AND_RECEPTACLE

Unit.RefuelingSystem.PROBE_AND_DROGUE

## Type `Unit.Sensor`

A unit sensor.

### Field(s)

#Unit.SensorType Unit.Sensor.type

#TypeName Unit.Sensor.typeName

## Type `Unit.SensorType`

Enum that stores sensor types.

### Field(s)

Unit.SensorType.IRST

Unit.SensorType.OPTIC

Unit.SensorType.RADAR

Unit.SensorType.RWR

## Type `Unit.Sensors`

## Type `Weapon.Desc`

## Type `list`