WeaponInfo
(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)
A WeaponInfo is a class providing information about a specific weapon available on the ownship entity. WeaponInfo instances are accessed by calling getWeaponInfo() on the ownship object.
Function List
| bestMunitionForTarget (targetRef) | Selects the best munition for engaging the given target location. |
| canTargetLocation (location) | Indicates whether this weapon has the specified location within its target region. |
| conflictsWithOtherWeapon (otherWeaponId) | Checks to see if this weapon conflicts with the other specified weapon. |
| createFireTask (target, hitZoneFunction, munitionType) | Generates a fire task appropriate for this weapon to fire on the specified target. |
| getFireResourceNames () | Returns a list of the munition resources used by this weapon. |
| getFireTasks () | Provides a list of tasks that this weapon is capable of handling. |
| getStatus () | Provides the status of the weapon encoded in a number using bit fields. |
| getStatusString () | Provides the status of the weapon as a string. |
| getWeaponId () | Provides an ID that can be used to task this weapon or access information on it. |
| getWeaponProperty (propertyName) | |
| isAutonomousFire () | |
| isAutonomousFireType (targetType) | |
| isBlockedByOtherWeapon () | Checks whether this weapon is currently blocked by another busy weapon on the same entity that shares a resource (art part or token) with it. |
| isReady () | Indicates whether the weapon is in a ready state and can be fired. |
| isValid () | Indicates weapon validity. |
| maximumRange () | Returns the maximum range of the weapon. |
| minimumRange () | Returns the minimum range of the weapon. |
| targetApplicability (targetType) | Returns the applicability of the weapon against the specified target type. |
Functions
- bestMunitionForTarget (targetRef)
-
Selects the best munition for engaging the given target location.
Parameters:
-
targetRef: (LocationReference) The target location or entity reference.
Return value:
- (table) A table with fields: munition (string or nil) -- the chosen munition type, or nil if none found reasons (table) -- keys are munition type strings, values are reason strings ("selected", "no stock", or a ballistic solver reason such as "OutOfRange")
-
- canTargetLocation (location)
-
Indicates whether this weapon has the specified location within its target region.
Parameters:
-
location: (Location3D) The location to check.
Return value:
- (boolean) True if the location is in the target region.
-
- conflictsWithOtherWeapon (otherWeaponId)
-
Checks to see if this weapon conflicts with the other specified weapon. This does not depend on transient state such as the busy status of either weapon, or priority.
Parameters:
-
otherWeaponId: (string) ID of the other weapon.
Return value:
- (boolean) True if a conflict exists.
-
- createFireTask (target, hitZoneFunction, munitionType)
-
Generates a fire task appropriate for this weapon to fire on the specified target.
Parameters:
-
target: (LocationReference) A LocationReference, which can be a Location3D, SimObject or a table specifying a reference location. -
hitZoneFunction: (number) An 8-bit integer specifying which function/system (weapon, sensor, etc.) of the aimed object should be targeted. (optional) -
munitionType: (string) The entity-type string of the preferred munition, or empty string for no preference. (optional)
Return value:
- (table) A table in the form { name = "
", parameters = }, or nil if no task could be generated. -
- getFireResourceNames ()
-
Returns a list of the munition resources used by this weapon. The resource names are entity type strings.
Return value:
- (table) A list of munition resource entity type strings.
- getFireTasks ()
-
Provides a list of tasks that this weapon is capable of handling.
Return value:
- (table) A list of strings that are the fire task IDs.
- getStatus ()
-
Provides the status of the weapon encoded in a number using bit fields. The following are the components of status and their codes:
- Busy = 1,
- Disabled = 2,
- Out Of Ammo = 4,
- Suppressed = 8,
- Stowed = 16
Return value:
- (integer) The encoded weapon status.
- getStatusString ()
-
Provides the status of the weapon as a string. The string contains all of the status components that are currently true.
Return value:
- (string) A readable representation of the weapon status.
- getWeaponId ()
-
Provides an ID that can be used to task this weapon or access information on it.
Return value:
- (string) The weapon ID.
- getWeaponProperty (propertyName)
-
Parameters:
-
propertyName: (string) The name of a property appearing in the weapon property data. These are usually specified in the weapon descriptor.
Return value:
- (any) The value of the weapon property, if found. Nil if not found. The type depends on the property data.
-
- isAutonomousFire ()
-
Return value:
- (boolean) True if this weapon has been specified for autonomous fire.
- isAutonomousFireType (targetType)
-
Parameters:
-
targetType: (string) An entity type string.
Return value:
- (boolean) True if targetType matches any of the autonomous target types for this weapon.
-
- isBlockedByOtherWeapon ()
-
Checks whether this weapon is currently blocked by another busy weapon on the same entity that shares a resource (art part or token) with it. Weapon arbitration is first-to-claim on shared resources.
Return values:
- (boolean) True if this weapon is blocked by another busy weapon.
- (string) The weapon ID of the blocking weapon, if blocked.
- isReady ()
-
Indicates whether the weapon is in a ready state and can be fired.
Return value:
- (boolean) True if the weapon is ready.
- isValid ()
-
Indicates weapon validity.
Return value:
- (boolean) True if the WeaponInfo is valid and can be used.
- maximumRange ()
-
Returns the maximum range of the weapon.
Return value:
- (number) The maximum range of the weapon.
- minimumRange ()
-
Returns the minimum range of the weapon.
Return value:
- (number) The minimum range of the weapon.
- targetApplicability (targetType)
-
Returns the applicability of the weapon against the specified target type. Return values:
0: Unspecified
1: Not Applicable
2: Overkill
3: Applicable
4: Ideal
Parameters:
-
targetType: (string) An entity type string, i.e. 7 numbers separated by colons.
-
