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
| 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) | Generates a fire task appropriate for this weapon to fire on the specified target. |
| 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) | |
| isAtonomousFire () | |
| isAtonomousFireType (targetType) | |
| isBlockedByOtherWeapon () | Checks to see if this weapon conflicts with another higher priority weapon that is currently in use. |
| isReady () | Indicates whether the weapon is in a ready state and can be fired. |
| isValid () | Indicates weapon validity. |
| targetApplicability (targetType) | Returns the applicability of the weapon against the specified target type. |
Functions
- canTargetLocation (location)
-
Indicates whether this weapon has the specified location within its target region.
Parameters:
-
location: Location3D
Return value:
- True if the location is in the 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:
- [bool] true if conflict exists.
-
- createFireTask (target)
-
Generates a fire task appropriate for this weapon to fire on the specified target.
Parameters:
-
target: A LocationReference, which can be a Location3D, SimObject or a table specifying a reference location.
Return value:
- A table in the form { name = "
", parameters = } or nil if no task could be generated. -
- getFireTasks ()
-
Provides a list of tasks that this weapon is capable of handling.
Return value:
- A table that is a list of strings that are the 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:
- WeaponId (string)
- 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:
- The value of the weapon property, if found. nil if not found. The type of the return will depend on the of the property data.
-
- isAtonomousFire ()
-
Return value:
- True if this weapon has been specified that it should be used for autonomous fire.
- isAtonomousFireType (targetType)
-
Parameters:
-
targetType: [String] An entity type string.
Return value:
- True if targetType matches (using pattern match) any of the autonomous target types for this weapon.
-
- isBlockedByOtherWeapon ()
-
Checks to see if this weapon conflicts with another higher priority weapon that is currently in use.
Return value:
- [bool] [string] The block status and 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:
- True if the WeaponInfo is valid and can be used.
- 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.
-
