Module WeaponUnit
Displays information about the weapon's state.
Element class: Weapon
Extends: Element
Functions
getWidgetData () | Get element data as JSON. |
getAmmo () | Returns the item ID of the currently equipped ammo. |
getAmmoCount () | Returns the current amount of remaining ammunition. |
getMaxAmmo () | Returns the maximum amount of ammunition the weapon can carry. |
isOutOfAmmo () | Checks if the weapon is out of ammo. |
isOperational () | Deprecated: Returns 1 if the wapon is not broken and compatible with the construct size. |
getOperationalState () | Returns 1 if the wapon is not broken and compatible with the construct size. |
getStatus () | Returns the current weapon status. |
getContainerId () | Returns the local ID of the container linked to the weapon. |
getHitProbability () | Returns the current hit probability of the weapon for the current target. |
getBaseDamage () | Returns the base weapon damage. |
getOptimalAimingCone () | Returns the optimal aim cone. |
getOptimalDistance () | Returns the optimal distance to target. |
getMaxDistance () | Returns the maximum distance to target. |
getOptimalTracking () | Returns the optimal tracking rate. |
getMagazineVolume () | Returns the magazine volume. |
getCycleTime () | Returns the weapon cycle time. |
getReloadTime () | Returns the weapon reload time. |
getUnloadTime () | Returns the weapon unload time. |
getTargetId () | Returns the ID of the current target construct of the weapon. |
EVENT_onReload (ammoId) | Event: Emitted when the weapon starts reloading. |
EVENT_onReloaded (ammoId) | Event: Emitted when the weapon has reloaded. |
EVENT_onMissed (targetId) | Event: Emitted when the weapon has missed its target. |
EVENT_onDestroyed (targetId) | Event: Emitted when the weapon target has been destroyed. |
EVENT_onElementDestroyed (targetId, itemId) | Event: Emitted when an element on the weapon target has been destroyed. |
EVENT_onHit (targetId, damage) | Event: Emitted when the weapon has hit. |
Functions
- getWidgetData ()
-
Get element data as JSON.
Weapons have a
weapon
widget, which contains the following fields (bold fields are visible when making custom use of the widget):- properties (table) Current weapon properties.
- ammoCount (int) Remaining ammo. Not present while reloading.
- ammoMax (int) Max capacity for current ammo. Not present while reloading.
- ammoName (int) Name of current ammo.
- ammoTypeId (int) Type id of current ammo.
- baseDamage (float) (?).
- cycleAnimationRemainingTime (float) Remaining time for current action (s), only appears to affect status codes 3 and 4.
- disableFire (int) (?).
- fireBlocked (boolean) Indicates weapon is blocked (?).
- fireCounter (int) Number of shots fired (?).
- fireReady (boolean) Indicates weapon is ready to fire (?).
- hitProbability (float) Likelyhood of hitting target (?).
- hitResult (int) (?).
- impactCounter (int) (?).
- maxDistance (float) (?).
- missCounter (int) (?).
- operationalStatus (int) (?).
- optimalAimingCone (float) Optimal aim cone (deg).
- optimalDistance (float) Optimal distance (m).
- optimalTracking (float) Optimal tracking rate (deg/s).
- outOfZone (boolean) Indicates out of PVP zone (?).
- repeatedFire (boolean) Indicates weapon will fire repeatedly (?).
- weaponStatus (int) Status code:
- 0: No animation in progress.
- 1: Firing(?).
- 2: (?)
- 3: Loading/Reloading(?) ammo.
- 4: Unloading ammo.
- staticProperties (table) Weapon attributes.
- baseDamage (float) Weapon base damage.
- magazineVolume (float) Magazine volume (L).
- cycleTime (float) Weapon rate of fire (s).
- reloadTime (float) Weapon reload time (s).
- unloadTime (float) Weapon unload time (s).
- size (float) Weapon cycle time (s).
- targetConstruct (table) Target attributes.
- name (string) Name of target, will be blank if not provided.
- constructId (int) Id of target.
- name (string) The name of the element.
- elementId (int) The (globally unique?) id of the weapon element, may be related to linking the commands to the element.
- helperId (string)
weapon
- type (string)
weapon
Descriptions of fields with a (?) are uncertain and need more testing.
Returns:
-
string
Data as JSON.
- properties (table) Current weapon properties.
- getAmmo ()
-
Returns the item ID of the currently equipped ammo.
Returns:
-
int
The item ID of the ammunition in the weapon.
- getAmmoCount ()
-
Returns the current amount of remaining ammunition.
Returns:
-
int
The remaining ammunition count (0 when reloading).
- getMaxAmmo ()
-
Returns the maximum amount of ammunition the weapon can carry.
Returns:
-
int
The maximum amount of ammunition.
- isOutOfAmmo ()
-
Checks if the weapon is out of ammo.
Returns:
-
0/1
1 if the weapon is out of ammo.
- isOperational ()
-
Deprecated: Returns 1 if the wapon is not broken and compatible with the construct size.
This method is deprecated: getOperationalState should be used instead
Returns:
-
0/1
1 if the weapon is operational, otherwise 0.
See also:
- getOperationalState ()
-
Returns 1 if the wapon is not broken and compatible with the construct size.
Returns:
-
int
1 if the weapon is operational, otherwise 0 = broken, -1 = incompatible size.
- getStatus ()
-
Returns the current weapon status.
Possible status:
- 1: Idle
- 2: Firing
- 3: Reloading
- 4: Unloading
Returns:
-
int
The current status of the weapon.
- getContainerId ()
-
Returns the local ID of the container linked to the weapon.
Returns:
-
int
The local ID of the container.
- getHitProbability ()
-
Returns the current hit probability of the weapon for the current target.
Returns:
-
float
The hit probability of the weapon.
- getBaseDamage ()
-
Returns the base weapon damage.
Returns:
-
float
The base weapon damage in hitpoints.
- getOptimalAimingCone ()
-
Returns the optimal aim cone.
Returns:
-
float
The optimal aim cone in degrees.
- getOptimalDistance ()
-
Returns the optimal distance to target.
Returns:
-
float
The optimal distance in meters.
- getMaxDistance ()
-
Returns the maximum distance to target.
Returns:
-
float
The optimal distance in meters.
- getOptimalTracking ()
-
Returns the optimal tracking rate.
Returns:
-
float
The optimal tracking rate in degrees per second.
- getMagazineVolume ()
-
Returns the magazine volume.
Returns:
-
float
The magazine volume in liters.
- getCycleTime ()
-
Returns the weapon cycle time.
Returns:
-
float
The weapon cycle time in seconds.
- getReloadTime ()
-
Returns the weapon reload time.
Returns:
-
float
The weapon reload time in seconds.
- getUnloadTime ()
-
Returns the weapon unload time.
Returns:
-
float
The weapon unload time in seconds.
- getTargetId ()
-
Returns the ID of the current target construct of the weapon.
Returns:
-
int
The target construct ID.
- EVENT_onReload (ammoId)
-
Event: Emitted when the weapon starts reloading.
Note: This is documentation on an event handler, not a callable method.
Parameters:
- ammoId int The item ID of the ammo.
- EVENT_onReloaded (ammoId)
-
Event: Emitted when the weapon has reloaded.
Note: This is documentation on an event handler, not a callable method.
Parameters:
- ammoId int The item ID of the ammo.
- EVENT_onMissed (targetId)
-
Event: Emitted when the weapon has missed its target.
Note: This is documentation on an event handler, not a callable method.
Parameters:
- targetId int The construct ID of the target.
- EVENT_onDestroyed (targetId)
-
Event: Emitted when the weapon target has been destroyed.
Note: This is documentation on an event handler, not a callable method.
Parameters:
- targetId int The construct ID of the target.
- EVENT_onElementDestroyed (targetId, itemId)
-
Event: Emitted when an element on the weapon target has been destroyed.
Note: This is documentation on an event handler, not a callable method.
Parameters:
- targetId int The construct ID of the target.
- itemId int The item ID of the destroyed element.
- EVENT_onHit (targetId, damage)
-
Event: Emitted when the weapon has hit.
Note: This is documentation on an event handler, not a callable method.
Parameters:
- targetId int The construct ID of the target.
- damage float The damage amount dealt by the hit.