targetsQuery: Difference between revisions

From Bohemia Interactive Community
m (Text replacement - " \{\{GameCategory *\| *arma2 *\| *(New )?Scripting Commands\}\}" to "")
mNo edit summary
 
(27 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma2
|game1= arma2
|1.00
|version1= 1.00


|game2= arma2oa
|game2= arma2oa
Line 15: Line 15:
|gr1= Object Detection
|gr1= Object Detection


| Returns sorted array of targets, '''known''' to the enquirer (including own troops), where the accuracy coefficient reflects how close the result matches the query. This command could be CPU intensive.
|descr= Returns sorted array of targets, '''known''' to the enquirer (including own troops), where the accuracy coefficient reflects how close the result matches the query. This command could be CPU intensive.


|s1= enquirer '''targetsQuery''' [targetIgnore, targetSide, targetType, targetPosition, targetMaxAge]
|s1= enquirer [[targetsQuery]] [targetIgnore, targetSide, targetType, targetPosition, targetMaxAge]


|p1= enquirer: [[Object]] - For whom the query will be made
|p1= enquirer: [[Object]] - for whom the query will be made


|p2= [targetIgnore, targetSide, targetType, targetPosition, targetMaxAge]: [[Array]] - Query
|p2= targetIgnore: [[Object]] - target object to exclude from results. [[objNull]] - return every target


|p3= targetIgnore: [[Object]] - Target object to exclude from results. [[objNull]] - return every target
|p3= targetSide: [[Side]] - desired side of the target. [[sideUnknown]] - any side
|p4= targetSide: [[Side]] - Desired side of the target. [[sideUnknown]] - any side
|p5= targetType: [[String]] - Desired target [[typeOf]]. "" - any type
|p6= targetPosition: [[Array]] - Desired target position in format of [[Position2D]] or [[Position3D]] (only [x,y] is considered). Position tolerance is 200m from the actual position of the target. [] - any position
|p7= targetMaxAge: [[Number]] - Desired max age of the target. This will limit returned results to the targets younger than specified age. 0 - any age


| [[Array]] - '''sorted''' array of returned targets in the following format:
|p4= targetType: [[String]] - desired target [[typeOf]]. "" - any type
<nowiki>[</nowiki>[accuracy, target, targetSide, targetType, targetPosition, targetAge],...] where:
 
* accuracy: [[Number]] - a coefficient, which reflects how close the returned result to the query filter. Range: 0 - 1 (1 - best match)
|p5= targetPosition: [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]] - desired target position (only [x,y] is considered). Position tolerance is 200m from the actual position of the target. [] - any position
 
|p6= targetMaxAge: [[Number]] - desired max age of the target. This will limit returned results to the targets younger than specified age. 0 - any age
 
|r1= [[Array]] of [[Array]]s with [accuracy, target, targetSide, targetType, targetPosition, targetAge]
* accuracy: [[Number]] in range 0..1 - a coefficient, which reflects how close the returned result to the query filter. (1 - best match)
* target: [[Object]] - the actual target object
* target: [[Object]] - the actual target object
* targetSide: [[Side]] - side of the target
* targetSide: [[Side]] - side of the target
Line 38: Line 39:
* targetAge: [[Number]] - the actual target age in seconds (can be negative)
* targetAge: [[Number]] - the actual target age in seconds (can be negative)


|x1= Return all known targets for player:<code>_targets = [[player]] [[targetsQuery]] [<nowiki/>[[objNull]], [[sideUnknown]], "", [], 0];</code>
|x1= Return all known targets for player:
|x2= Prioritise all known OPFOR targets and return targets less than 10 seconds old:<code>_targets = [[player]] [[targetsQuery]] [<nowiki/>[[objNull]], [[east]], "", [], 10];</code>
<sqf>_targets = player targetsQuery [objNull, sideUnknown, "", [], 0];</sqf>
|x2= Prioritise all known OPFOR targets and return targets less than 10 seconds old:
<sqf>_targets = player targetsQuery [objNull, east, "", [], 10];</sqf>


|seealso= [[targetsAggregate]], [[targetKnowledge]], [[knowsAbout]], [[forgetTarget]]
|seealso= [[targets]] [[nearTargets]] [[targetsAggregate]] [[targetKnowledge]] [[knowsAbout]] [[reveal]] [[forgetTarget]] [[setTargetAge]] [[getHideFrom]]
}}
}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}

Latest revision as of 10:03, 2 January 2026

Hover & click on the images for description

Description

Description:
Returns sorted array of targets, known to the enquirer (including own troops), where the accuracy coefficient reflects how close the result matches the query. This command could be CPU intensive.
Groups:
Object Detection

Syntax

Syntax:
enquirer targetsQuery [targetIgnore, targetSide, targetType, targetPosition, targetMaxAge]
Parameters:
enquirer: Object - for whom the query will be made
targetIgnore: Object - target object to exclude from results. objNull - return every target
targetSide: Side - desired side of the target. sideUnknown - any side
targetType: String - desired target typeOf. "" - any type
targetPosition: Position2D or Position3D - desired target position (only [x,y] is considered). Position tolerance is 200m from the actual position of the target. [] - any position
targetMaxAge: Number - desired max age of the target. This will limit returned results to the targets younger than specified age. 0 - any age
Return Value:
Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]
  • accuracy: Number in range 0..1 - a coefficient, which reflects how close the returned result to the query filter. (1 - best match)
  • target: Object - the actual target object
  • targetSide: Side - side of the target
  • targetType: String - target typeOf
  • targetPosition: Array - [x,y] of the target
  • targetAge: Number - the actual target age in seconds (can be negative)

Examples

Example 1:
Return all known targets for player:
_targets = player targetsQuery [objNull, sideUnknown, "", [], 0];
Example 2:
Prioritise all known OPFOR targets and return targets less than 10 seconds old:
_targets = player targetsQuery [objNull, east, "", [], 10];

Additional Information

See also:
targets nearTargets targetsAggregate targetKnowledge knowsAbout reveal forgetTarget setTargetAge getHideFrom

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord.
Only post proven facts here! Add Note