VR-Forces 5.0.3 Lua Function Documentation

unitUtil

(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)


Unit Utilities

Summary

These utilities help computation about units.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"
require "formationUtils"

Function List

averagePositionOfDismountedSubordinates (unit, clamp, SimObject, boolean) Computes the average position of dismounted subordinates.
calculateSubordinatePosition (subordinate, battlePosition, targetPoint, formationOffsetMap) Given a SimObject subordinate, a Location3D representing a battlefield position,a Location3D representing a location toward which to orient, and a map of subordinates to formation offset locations, use the formationOffsetMap offset to return a Location3D representing a location relative to battlePosition according to formationOffset.
calculateSubordinatePositionFromHeading (subordinate, battlePosition, heading, formationOffsetMap) Given a SimObject subordinate, a Location3D representing a battlefield position,a heading, and a map of subordinates to formation offset locations, use the formationOffsetMap offset to return a Location3D representing a location relative to battlePosition according to formationOffset.
orderSubordinatesAlongDirection (subordinates, heading, table.) returns a list of subordinates ordered along the direction from least to most
setPostureUrgency (simObjects, urgencyLevel) Sets the posture urgency for the SimObjects in the given array (table).


Functions

averagePositionOfDismountedSubordinates (unit, clamp, SimObject, boolean)
Computes the average position of dismounted subordinates.

Parameters:

  • unit:
  • clamp:
  • SimObject: that is a unit
  • boolean: terrain clamp Result (default or nil is true)

Return value:

    Location3D of that unit based on average of not destroyed, dismounted subordinates
calculateSubordinatePosition (subordinate, battlePosition, targetPoint, formationOffsetMap)
Given a SimObject subordinate, a Location3D representing a battlefield position,a Location3D representing a location toward which to orient, and a map of subordinates to formation offset locations, use the formationOffsetMap offset to return a Location3D representing a location relative to battlePosition according to formationOffset. the return location is clamped 0.5m above terrain.

Parameters:

  • subordinate: SimObject. Subordinate for whom to calculate a position.
  • battlePosition: Location3D. The location about which to position the subordinate.
  • targetPoint: Location3D. A location toward which to orient from the battlePosition.
  • formationOffsetMap: ObjectMap. A table indexed by SimObject with value VectorOffset3D representing subordinate formation offsets. See formationUtils.fillFormationOffsetObjectMap()

Return value:

    Location3D. Represents a location relative to battlePosition according to formationOffset, clamped 0.5m above terrain.
calculateSubordinatePositionFromHeading (subordinate, battlePosition, heading, formationOffsetMap)
Given a SimObject subordinate, a Location3D representing a battlefield position,a heading, and a map of subordinates to formation offset locations, use the formationOffsetMap offset to return a Location3D representing a location relative to battlePosition according to formationOffset. the return location is clamped 0.5m above terrain.

Parameters:

  • subordinate: SimObject. Subordinate for whom to calculate a position.
  • battlePosition: Location3D. The location about which to position the subordinate.
  • heading: Number. A heading toward the enemy
  • formationOffsetMap: ObjectMap. A table indexed by SimObject with value VectorOffset3D representing subordinate formation offsets. See formationUtils.fillFormationOffsetObjectMap()

Return value:

    Location3D. Represents a location relative to battlePosition according to formationOffset, clamped 0.5m above terrain.
orderSubordinatesAlongDirection (subordinates, heading, table.)
returns a list of subordinates ordered along the direction from least to most

Parameters:

  • subordinates:
  • heading:
  • table.: Array of subordinates

Return value:

    table. Array of subordinates. First element is the first along the heading.
setPostureUrgency (simObjects, urgencyLevel)
Sets the posture urgency for the SimObjects in the given array (table).

Parameters:

  • simObjects: Table. Array of SimObjects.
  • urgencyLevel:

Copyright© 2023 MAK Technologies, Inc. All rights reserved.