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" Constants
| Constant | Values | Description |
|---|---|---|
| landPlatformCategoryThreatLookup | landPlatformCategoryThreatLookup[1].score = 100 -- Tank landPlatformCategoryThreatLookup[2].score = 90 -- Armored Fighting Vehicle6 landPlatformCategoryThreatLookup[3].score = 50 -- Armored Utility Vehicle7 landPlatformCategoryThreatLookup[4].score = 50 -- Self-propelled Artillery8 landPlatformCategoryThreatLookup[5].score = 45 -- Towed Artillery9 landPlatformCategoryThreatLookup[6].score = 65 -- Small Wheeled Utility Vehicle10 landPlatformCategoryThreatLookup[7].score = 35 -- Large Wheeled Utility Vehicle11 landPlatformCategoryThreatLookup[8].score = 65 -- Small Tracked Utility Vehicle12 landPlatformCategoryThreatLookup[9].score = 35 -- Large Tracked Utility Vehicle13 landPlatformCategoryThreatLookup[10].score = 70 -- Mortar | This table is a lookup by SISO category enumeration for platform kind. Value is an arbitrary, relative threat level, 0-100 |
| lifeformSubcategoryThreatLookup | lifeformSubcategoryThreatLookup[85].score = 100 --Man-Portable Air Defense System lifeformSubcategoryThreatLookup[50].score = 95 --Anti-Tank Missiles lifeformSubcategoryThreatLookup[45].score = 90 --Anti-Tank Rockets lifeformSubcategoryThreatLookup[70].score = 90 --Rocket Launchers lifeformSubcategoryThreatLookup[55].score = 90 --Anti-Tank Guns lifeformSubcategoryThreatLookup[90].score = 90 --Recoilless Rifles lifeformSubcategoryThreatLookup[60].score = 85 --Flame Rockets lifeformSubcategoryThreatLookup[75].score = 85 --Mortars lifeformSubcategoryThreatLookup[40].score = 85 --Grenade Launching Machine Gun lifeformSubcategoryThreatLookup[95].score = 80 --Drone Guns lifeformSubcategoryThreatLookup[30].score = 75 --Grenade Launchers lifeformSubcategoryThreatLookup[65].score = 70 --Flame Throwers lifeformSubcategoryThreatLookup[17].score = 65 --Anti-Materiel Rifle lifeformSubcategoryThreatLookup[35].score = 55 --Machine Guns lifeformSubcategoryThreatLookup[20].score = 50 --Sub Machine Guns lifeformSubcategoryThreatLookup[15].score = 45 -- Sniper Rifles lifeformSubcategoryThreatLookup[10].score = 40 --High Power Rifles lifeformSubcategoryThreatLookup[5].score = 35 --Assault Rifles lifeformSubcategoryThreatLookup[1].score = 30 --Weapon lifeformSubcategoryThreatLookup[25].score = 25 --Shot Guns lifeformSubcategoryThreatLookup[80].score = 10 --Hand Guns | This table is a lookup by SISO subcategory enumeration (i.e. weapon) for lifeform kind. Value is an arbitrary, relative threat level, 0-100 |
Function List
| countDestroyedObjects (simObjects, an) | Tallies the number of destroyed objects in given list of SimObjects Walks the list of objects, counts destroyed objects Returns number of destroyed objects. |
| determineLifeformThreatLevel (entityTypeString) | Returns a number representing threat for the given type, higher is more threating. |
| determinePlatformThreatLevel (entityTypeString) | Returns a number representing threat for the given type, higher is more threating. |
| determineThreatLevel (entityTypeString) | Return threat level for the given entity type string. |
| 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) | Returns a list of 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, an)
-
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: -
an: array (table) of SimObjects
Return value:
- numDestroyed
-
- determineLifeformThreatLevel (entityTypeString)
-
Returns a number representing threat for the given type, higher is more threating.
Parameters:
-
entityTypeString: representing the SISO enumeration for a lifeform, e.g. "3:1:222:11:5:30:6" Return a value 0-100 that represents the threat level, and true if it is a lifeform. Return #, boolean
-
- determinePlatformThreatLevel (entityTypeString)
-
Returns a number representing threat for the given type, higher is more threating.
Parameters:
-
entityTypeString: String representing the SISO enumeration for a platform, e.g. "1:1:255:1:1:0:0" Return a value 0-100 that represents the threat level, and true if it is a platform. Return #, boolean
-
- determineThreatLevel (entityTypeString)
-
Return threat level for the given entity type string. Both platform and lifeform threat levels are returned (at least one will be zero).
Parameters:
-
entityTypeString: String representing the SISO enumeration for a simulated object, e.g. "1:1:255:1:1:0:0" return the platform threat level and the lifeform threat level Return platform, lifeform
Return value:
- #, #
-
- 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: An array (table) of SimObjects
Return value:
- An array (table) 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: An array (table) of SimObjects -
entityMatchTypes: An array (table) of strings that represent EntityType match strings.
Return value:
- An array (table) that is a subset of simObjects matching one of the types.
-
- flattenThreatTable (threatTable)
-
Combines the "platform" and "lifeform" elements of the given threat result table into one array.
Parameters:
-
threatTable: Table in the form of {landPlatforms = {obj, obj, ...}, lifeforms = {obj, obj, ...}
Return value:
- array (table) in the form of {obj, obj, ...}
-
- getHostileForcesWithinSearchRadius (location, radius, friendlyForceType)
-
Returns a list of 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:
- array (table) of simulated objects 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: An array (table) of SimObjects
Return value:
- a table 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
-
