VR-Forces 5.1 Lua Function Documentation

contactsUtils

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


Contact Utilities

Summary

Utilities to provide information about reported hostile (or other) contacts.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"

Usage

require "contactsUtils"

Function List

countDestroyedObjects (simObjects) Tallies the number of destroyed objects in given list of SimObjects Walks the list of objects, counts destroyed objects Returns number of destroyed objects.
filterSimObjectsExcludeEmbarked (simObjects) Returns an array of simObjects that are not embarked.
filterSimObjectsForTypes (simObjects, entityMatchTypes) Returns an array of simObjects that match one or more entity types.
flattenThreatTable (threatTable) Combines the "platform" and "lifeform" elements of the given threat result table into one array.
getHostileForcesWithinSearchRadius (location, radius, friendlyForceType) Finds SimObjects considered hostile to the given force type, within the given radius of a location.
prioritizeThreats (enemies) Build a table of not destroyed, prioritized threats.
threatSorter (enemy1, enemy2) Determine if enemy1 is more threatening than enemy2 This is intended for a table sort, where higher threats should appear sooner in an array.


Functions

countDestroyedObjects (simObjects)
Tallies the number of destroyed objects in given list of SimObjects Walks the list of objects, counts destroyed objects Returns number of destroyed objects.

Parameters:

  • simObjects: (table) List of SimObjects

Return value:

    (integer) Number of destroyed objects.
filterSimObjectsExcludeEmbarked (simObjects)
Returns an array of simObjects that are not embarked. Given an array of objects, Extract an array of sim objects that are not embarked.

Parameters:

  • simObjects: (table) A list of SimObjects

Return value:

    (table) A list that is a subset of simObjects excluding embarked objects.
filterSimObjectsForTypes (simObjects, entityMatchTypes)
Returns an array of simObjects that match one or more entity types. Given an array of objects and an array of entity type match strings, Extract an array of sim objects that match at least one of the strings.

Parameters:

  • simObjects: (table) A list of SimObjects
  • entityMatchTypes: (table) A list of entity type strings.

Return value:

    (table) A list that is a subset of simObjects matching one of the entityMatchTypes.
flattenThreatTable (threatTable)
Combines the "platform" and "lifeform" elements of the given threat result table into one array.

Parameters:

  • threatTable: (table) A table in the form of {landPlatforms = {obj, obj, ...}, lifeforms = {obj, obj, ...}

Return value:

    (table) In the form of {obj, obj, ...}
getHostileForcesWithinSearchRadius (location, radius, friendlyForceType)
Finds SimObjects considered hostile to the given force type, within the given radius of a location.

Parameters:

  • location: (Location3D) This is the suspected enemy location.
  • radius: (Number) A number in meters, about the location. Simulated objects within that radius will be evaluated.
  • friendlyForceType: (Number) A numerical force type (0-255) identifying the friendly force, to be used to evaluate hostility of others based on their force type and the hostility table in the simulation. Uses a ground truth search for anything near. vrf:getSimObjectsNearWithFilter (location, radius, filter)

Return value:

    (table) List of SimObjects that are platforms or lifeforms, destroyed or intact, that are hostile to the given friendly force type.
prioritizeThreats (enemies)
Build a table of not destroyed, prioritized threats. Given an array of SimObjects that are considered hostile, evaluate the objects and their threat levels. Return table will have the form: { landPlatforms = {obj, obj, ...} , lifeforms = {obj, obj, ...} }

Parameters:

  • enemies: (table) A list of SimObjects

Return value:

    (table) A list of prioritized threats in the form {landPlatforms={obj, ...}, lifeforms={obj, ...}}
threatSorter (enemy1, enemy2)
Determine if enemy1 is more threatening than enemy2 This is intended for a table sort, where higher threats should appear sooner in an array. Therefore, when used in a table sort, the result is inverted. That is to say, enemy1 is "less than" enemy2 if enemy1 is more threatening than enemy2. That will result in a table sort that puts higher threats at the beginning of an array. Platform threat score is evaluated first, then lifeform threat score.

Parameters:

  • enemy1: SimObject
  • enemy2: SimObject

Return value:

    true if enemy1 has higher threat than enemy2

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