engagementUtil
(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)
Summary
Engagement utilities help computation with engagment geometry.
Dependencies
Please make sure that this is preceded by these inclusions:
require "vrfutil"
require "formationUtils" Usage
require "engagementUtil" Constants
| Constant | Description |
|---|---|
| GRENADE_LAUNCHER_RANGE_MAX = 400 | A maximum limit in meters on the practical use of a M203 Launcher, for purposes of engagement behaviors. |
| GRENADE_LAUNCHER_RANGE_MIN | A minimum limit in meters on the practical use of a M203 Launcher, for purposes of engagement behaviors. |
| grenadeLauncherWeaponSystemNames | An array of weapon system names that helps behaviors find a grenade launcher on a "this" simulated object. |
Function List
| calculateHighExplosiveTarget (shooterLocation, hostiles, lateralDistribution, altitudeOffset) | Compute a Location3D at which to shoot grenades. |
| calculateSmokeTarget (originLocation, objectiveLocation, objectiveRadius, lateralDistribution, altitudeOffset, trimRange) | Calculates a smoke target location interposed betweeen origin and objective, short by objective radius. |
| chooseProneOrPostureForLocation (location, enemyLocation, defaultPosture) | Returns a recommended posture for lifeforms based on a location and an enemyLocation. |
| hasLineOfSight (locationA, locationB) | Check if line of sight exists between two locations. |
Functions
- calculateHighExplosiveTarget (shooterLocation, hostiles, lateralDistribution, altitudeOffset)
-
Compute a Location3D at which to shoot grenades. Uses GRENADE_LAUNCHER_RANGE_MAX and GRENADE_LAUNCHER_RANGE_MIN. The returned target location will be trimmed to fit within those ranges, in the direction from shooter location to objective location, with added height above ground from altitude offset.
Parameters:
-
shooterLocation: Location3D. Where the shooter is shooting from. -
hostiles: Array (table) of SimObjects. A list of enemies from which to select a target. -
lateralDistribution: Number. Distance in meters to one side of target, used to randomize placement about the target. -
altitudeOffset: Number. Distance in meters the target should be above the ground.
Return value:
- Location3D or nil for the target location.
-
- calculateSmokeTarget (originLocation, objectiveLocation, objectiveRadius, lateralDistribution, altitudeOffset, trimRange)
-
Calculates a smoke target location interposed betweeen origin and objective, short by objective radius.
Parameters:
-
originLocation: Location3D. Starting point for line toward the objective. Origin can be shooter location, or a group assault position or location of a unit to support, for example. The goal is to obscure by interposing origin and objective. -
objectiveLocation: Location3D. End point of line. -
objectiveRadius: Number. Radius about objective, used to trim the origin-objective line. -
lateralDistribution: Number. Distance in meters to one side of target, used to randomize placement about the target. -
altitudeOffset: Number. Distance in meters the target should be above the ground. -
trimRange: Number. (optional) A maximum distance in meters from origin to target location.
Return value:
- a Location3D for the target position.
-
- chooseProneOrPostureForLocation (location, enemyLocation, defaultPosture)
-
Returns a recommended posture for lifeforms based on a location and an enemyLocation. Based on a location, enemyLocation and a defaultPosture, return a string for recommended posture at that location. Checks line of sight to enemyLocation which is a Location3D that represents a place where enemies are suspected to be near. By default, returns the input string defaultPosture If the shooting location has LOS to enemyLocation then it returns prone.
Parameters:
-
location: Location3D. A location of interest, that will be tested for line of sight with enemy. -
enemyLocation: Location3D. A location where enemy is anticipated. -
defaultPosture: String. A string ("standing", "kneeling" , "crouching", etc.) representing posture to use if line of sight is blocked between locations.
Return value:
- string. "prone" if line of sight exists between location and enemyLocation, otherwise defaultPosture
-
- hasLineOfSight (locationA, locationB)
-
Check if line of sight exists between two locations.
Parameters:
-
locationA: Location3D. -
locationB: Location3D.
Return value:
- bool, Location3D. true if line of sight exists between locations, blocking location.
-
