Weapon#

Weapon represents an in-flight munition: a shell, rocket, missile, or bomb. It extends CoalitionObject (and, transitively, Object). Weapon objects are typically obtained through event handlers (e.g. the initiator/weapon fields on shot/hit events), rather than a static lookup function.

class Weapon#

Inherits all member functions of CoalitionObject and Object.

getLauncher()#

Returns the Unit that launched/fired this weapon.

Returns:

The launching unit.

Return type:

Unit

getTarget()#

Returns the object this weapon is currently guiding toward, if applicable.

Returns:

The weapon’s target, or nil.

Return type:

Object

getCategoryEx()#

Returns the weapon’s more specific category (see Weapon.Category). Equivalent to weapon:getDesc().category.

Returns:

Weapon category.

Return type:

number

Enumerators#

Weapon.Category identifies the specific weapon category (via weapon:getDesc().categorynot weapon:getCategory(), which always returns Object.Category.WEAPON):

Value

Meaning

Weapon.Category.SHELL

Gun shell (0)

Weapon.Category.MISSILE

Missile (1)

Weapon.Category.ROCKET

Unguided rocket (2)

Weapon.Category.BOMB

Bomb (3)

Weapon.GuidanceType identifies a missile/bomb’s guidance method:

Value

Meaning

Weapon.GuidanceType.INS

Inertial navigation (1)

Weapon.GuidanceType.IR

Infra-red (2)

Weapon.GuidanceType.RADAR_ACTIVE

Active radar (3)

Weapon.GuidanceType.RADAR_SEMI_ACTIVE

Semi-active radar (4)

Weapon.GuidanceType.RADAR_PASSIVE

Passive radar (5)

Weapon.GuidanceType.TV

TV (6)

Weapon.GuidanceType.LASER

Laser (7)

Weapon.GuidanceType.TELE

Television/data-link (8)

Weapon.MissileCategory further classifies guided missiles:

Value

Meaning

Weapon.MissileCategory.AAM

Air-to-air missile (1)

Weapon.MissileCategory.SAM

Surface-to-air missile (2)

Weapon.MissileCategory.BM

Ballistic missile (3)

Weapon.MissileCategory.ANTI_SHIP

Anti-ship missile (4)

Weapon.MissileCategory.CRUISE

Cruise missile (5)

Weapon.MissileCategory.OTHER

Other (6)

Weapon.WarheadType identifies the warhead type:

Value

Meaning

Weapon.WarheadType.AP

Armor-piercing (0)

Weapon.WarheadType.HE

High-explosive (1)

Weapon.WarheadType.SHAPED_EXPLOSIVE

Shaped-charge explosive (2)

Footnotes#

  • Weapon objects are commonly obtained via the weapon field of S_EVENT_SHOT/S_EVENT_HIT events registered through world.addEventHandler().