{"name":"targetsAggregate","title":"targetsAggregate","type":"command","url":"https://community.bistudio.com/wiki/targetsAggregate","revid":377663,"updated":"2026-01-02T09:02:16Z","groups":["Object Manipulation"],"status":"ok","games":{"arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma2 1.00","arma3_since":"0.50","description":"Aggregate candidates.","syntaxes":[{"syntax":"[speaker, side, classname, position, timeMax] targetsAggregate candidates","params":[{"name":"speaker","type":"Object","type_expr":"Object"},{"name":"side","type":"Side","description":"if provided, a target with a side matching *side* will see it replaced by `\"$\"`","type_expr":"Side"},{"name":"classname","type":"String","description":"`CfgVehicles` classname - if provided, a target with a type matching *classname* will see it replaced by `\"$\"`","type_expr":"String"},{"name":"position","type":"Position (Z-value is ignored)","description":"centre of a hardcoded 200m radius","type_expr":"Position"},{"name":"timeMax","type":"Number","description":"max age of the target","type_expr":"Number"},{"name":"candidates","type":"Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]","description":"- 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.","type_expr":"Array<Array>","text":"candidates: Array of Arrays with [accuracy, target, targetSide, targetType, targetPosition, targetAge]\n\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","type_expr":"Array","description":"with [countInfo, sideInfo, unitInfo, placeInfo, timeInfo, uCountInfo, uTypeInfo]\n- 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\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","left":{"text":"[speaker, side, classname, position, timeMax]"},"right":{"text":"candidates"}}],"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\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*/"]}],"see_also":["targets","targetsQuery","nearTargets","targetKnowledge","knowsAbout","reveal","forgetTarget","setTargetAge","getHideFrom"]}