{"name":"targetsAggregate","operator":null,"title":"targetsAggregate","type":"command","url":"https://community.bistudio.com/wiki/targetsAggregate","revid":377663,"updated":"2026-01-02T09:02:16Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Aggregate candidates.","syntaxes":[{"syntax":"[speaker, side, classname, position, timeMax] targetsAggregate candidates","since":null,"effect":null,"exec":null,"params":[{"name":"speaker","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"speaker: Object"},{"name":"side","type":"Side","optional":false,"default":null,"description":"if provided, a target with a side matching *side* will see it replaced by `\"$\"`","types":["Side"],"since":null,"text":"side: Side - if provided, a target with a side matching *side* will see it replaced by `\"$\"`"},{"name":"classname","type":"String","optional":false,"default":null,"description":"`CfgVehicles` classname - if provided, a target with a type matching *classname* will see it replaced by `\"$\"`","types":["String"],"since":null,"text":"classname: String - `CfgVehicles` classname - if provided, a target with a type matching *classname* will see it replaced by `\"$\"`"},{"name":"position","type":"Position (Z-value is ignored)","optional":false,"default":null,"description":"centre of a hardcoded 200m radius","types":["Position"],"since":null,"text":"position: Position (Z-value is ignored) - centre of a hardcoded 200m radius"},{"name":"timeMax","type":"Number","optional":false,"default":null,"description":"max age of the target","types":["Number"],"since":null,"text":"timeMax: Number - max age of the target"},{"name":"candidates","type":null,"optional":false,"default":null,"description":"Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]\n- accuracy: Number - a coefficient, which reflects how close the returned result to the query filter. Range: 0..1, 1 being the best match\n- target: Object - the actual target object\n- targetSide: Side - side of the target\n- targetType: String - target typeOf\n- targetPosition: Position2D - [x,y] of the target\n- targetAge: Number - the actual target age in seconds (can be negative)\n\n> [!NOTE]\n> See targetsQuery format.","types":["Array"],"since":null,"text":"candidates: Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]\n- accuracy: Number - a coefficient, which reflects how close the returned result to the query filter. Range: 0..1, 1 being the best match\n- target: Object - the actual target object\n- targetSide: Side - side of the target\n- targetType: String - target typeOf\n- targetPosition: Position2D - [x,y] of the target\n- targetAge: Number - the actual target age in seconds (can be negative)\n\n> [!NOTE]\n> See targetsQuery format."}],"returns":{"type":"Array with [countInfo, sideInfo, unitInfo, placeInfo, timeInfo, uCountInfo, uTypeInfo]","types":["Array"],"description":"countInfo: Array - [format [\"COUNT%1\", index], count on index] - sideInfo: Array - [format [\"SIDE%1\", index], side or string] if string then $ == \"equal to queried\" - unitInfo: Array - [format [\"UNIT%1\", index], string] $ == \"equal to queried\", otherwise the \"type\" of the unit? Should be CfgVehicles config type I think - placeInfo: Array - [format [\"PLACE%1\", index], [[centerX, centerY], radius]] - timeInfo: Array - [format [\"TIME%1\", index], string or array] if string then $ == \"equal to queried\", otherwise [timeMin, timeMax] - uCountInfo: Array - [format [\"UCOUNT%1\", index], scalar count] - uTypeInfo: Array - [format [\"UTYPE%1\", index], string name] a classname? Will be format [\"*%1\", classname] if count > 1","text":"Array with [countInfo, sideInfo, unitInfo, placeInfo, timeInfo, uCountInfo, uTypeInfo]\n- countInfo: Array - [format [\"COUNT%1\", index], count on index]\n- sideInfo: Array - [format [\"SIDE%1\", index], side or string] if string then $ == \"equal to queried\"\n- unitInfo: Array - [format [\"UNIT%1\", index], string]  $ == \"equal to queried\", otherwise the \"type\" of the unit? Should be CfgVehicles config type I think\n- placeInfo: Array - [format [\"PLACE%1\", index], [[centerX, centerY], radius]]\n- timeInfo: Array - [format [\"TIME%1\", index], string or array] if string then $ == \"equal to queried\", otherwise [timeMin, timeMax]\n- uCountInfo: Array - [format [\"UCOUNT%1\", index], scalar count]\n- uTypeInfo: Array - [format [\"UTYPE%1\", index], string name] a classname? Will be format [\"*%1\", classname] if count > 1"},"form":"binary","operator":null,"left":{"text":"[speaker, side, classname, position, timeMax]","types":["Array"]},"right":{"text":"candidates","types":["Array"]}}],"examples":[{"text":"```sqf\n_aggregation = [player, sideEnemy, \"\", [], 0] targetsAggregate (player targetsQuery [objNull, sideUnknown, \"\", [], 0]);\n/*\n    returns e.g\n    [\n        [\n            [\"COUNT0\", 1],\n            [\"SIDE0\", WEST],\n            [\"UNIT0\", \"B_Soldier_F\"],\n            [\"PLACE0\", [[<null>,<null>], 0, <null>]],\n            [\"TIME0\", [-0.9, -0.9]],\n            [\"UCOUNT0\", 1],\n            [\"UTYPE0\", ...\n        ]\n    ]\n*/\n```\n\nwith e.g\n- one Orca Helicopter\n- one T-100 Varsuk tank\n- one T-140K Angara tank\n- one MBT-52 Kuma tank (independent, set as enemy to blufor)\n\n```sqf\n/*\n    [\n        [[\"COUNT0\",1],[\"SIDE0\",EAST],[\"UNIT0\",\"O_Heli_Light_02_dynamicLoadout_F\"],[\"PLACE0\",[[<null>,<null>],0,<null>]],[\"TIME0\",[-0.982,-0.982]],[\"UCOUNT0\",1],[\"UTYPE0\",\"O_Heli_Light_02_dynamicLoadout_F\"]],\n        [[\"COUNT1\",1],[\"SIDE1\",GUER],[\"UNIT1\",\"I_MBT_03_cannon_F\"],[\"PLACE1\",[[<null>,<null>],0,<null>]],[\"TIME1\",[-0.982,-0.982]],[\"UCOUNT1\",1],[\"UTYPE1\",\"I_MBT_03_cannon_F\"]],\n        [[\"COUNT2\",2],[\"SIDE2\",EAST],[\"UNIT2\",\"*Tank_F\"],[\"PLACE2\",[[<null>,<null>],4.34554,<null>]],[\"TIME2\",[-0.982,-0.982]],[\"UCOUNT2\",2],[\"UTYPE2\",\"*O_MBT_02_cannon_F\"]]]\n    [\n        [[\"COUNT0\",1],[\"SIDE0\",EAST],[\"UNIT0\",\"O_Heli_Light_02_dynamicLoadout_F\"],[\"PLACE0\",[[<null>,<null>],0,<null>]],[\"TIME0\",[-1,-1]],[\"UCOUNT0\",1],[\"UTYPE0\",\"O_Heli_Light_02_dynamicLoadout_F\"]],\n        [[\"COUNT1\",1],[\"SIDE1\",GUER],[\"UNIT1\",\"I_MBT_03_cannon_F\"],[\"PLACE1\",[[<null>,<null>],0,<null>]],[\"TIME1\",[-1,-1]],[\"UCOUNT1\",1],[\"UTYPE1\",\"I_MBT_03_cannon_F\"]],\n        [[\"COUNT2\",2],[\"SIDE2\",EAST],[\"UNIT2\",\"*Tank_F\"],[\"PLACE2\",[[<null>,<null>],4.34565,<null>]],[\"TIME2\",[-1,-1]],[\"UCOUNT2\",2],[\"UTYPE2\",\"*O_MBT_02_cannon_F\"]]\n    ]\n*/\n```","code":["_aggregation = [player, sideEnemy, \"\", [], 0] targetsAggregate (player targetsQuery [objNull, sideUnknown, \"\", [], 0]);\n/*\n\treturns e.g\n\t[\n\t\t[\n\t\t\t[\"COUNT0\", 1],\n\t\t\t[\"SIDE0\", WEST],\n\t\t\t[\"UNIT0\", \"B_Soldier_F\"],\n\t\t\t[\"PLACE0\", [[<null>,<null>], 0, <null>]],\n\t\t\t[\"TIME0\", [-0.9, -0.9]],\n\t\t\t[\"UCOUNT0\", 1],\n\t\t\t[\"UTYPE0\", ...\n\t\t]\n\t]\n*/","/*\n\t[\n\t\t[[\"COUNT0\",1],[\"SIDE0\",EAST],[\"UNIT0\",\"O_Heli_Light_02_dynamicLoadout_F\"],[\"PLACE0\",[[<null>,<null>],0,<null>]],[\"TIME0\",[-0.982,-0.982]],[\"UCOUNT0\",1],[\"UTYPE0\",\"O_Heli_Light_02_dynamicLoadout_F\"]],\n\t\t[[\"COUNT1\",1],[\"SIDE1\",GUER],[\"UNIT1\",\"I_MBT_03_cannon_F\"],[\"PLACE1\",[[<null>,<null>],0,<null>]],[\"TIME1\",[-0.982,-0.982]],[\"UCOUNT1\",1],[\"UTYPE1\",\"I_MBT_03_cannon_F\"]],\n\t\t[[\"COUNT2\",2],[\"SIDE2\",EAST],[\"UNIT2\",\"*Tank_F\"],[\"PLACE2\",[[<null>,<null>],4.34554,<null>]],[\"TIME2\",[-0.982,-0.982]],[\"UCOUNT2\",2],[\"UTYPE2\",\"*O_MBT_02_cannon_F\"]]]\n\t[\n\t\t[[\"COUNT0\",1],[\"SIDE0\",EAST],[\"UNIT0\",\"O_Heli_Light_02_dynamicLoadout_F\"],[\"PLACE0\",[[<null>,<null>],0,<null>]],[\"TIME0\",[-1,-1]],[\"UCOUNT0\",1],[\"UTYPE0\",\"O_Heli_Light_02_dynamicLoadout_F\"]],\n\t\t[[\"COUNT1\",1],[\"SIDE1\",GUER],[\"UNIT1\",\"I_MBT_03_cannon_F\"],[\"PLACE1\",[[<null>,<null>],0,<null>]],[\"TIME1\",[-1,-1]],[\"UCOUNT1\",1],[\"UTYPE1\",\"I_MBT_03_cannon_F\"]],\n\t\t[[\"COUNT2\",2],[\"SIDE2\",EAST],[\"UNIT2\",\"*Tank_F\"],[\"PLACE2\",[[<null>,<null>],4.34565,<null>]],[\"TIME2\",[-1,-1]],[\"UCOUNT2\",2],[\"UTYPE2\",\"*O_MBT_02_cannon_F\"]]\n\t]\n*/"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["targets","targetsQuery","nearTargets","targetKnowledge","knowsAbout","reveal","forgetTarget","setTargetAge","getHideFrom"],"notes":[],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}