{"name":"BIS_fnc_randomPos","operator":null,"title":"BIS fnc randomPos","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_randomPos","revid":349485,"updated":"2023-11-08T17:09:03Z","groups":["Positions"],"status":"ok","replaced_by":[],"games":[{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Selects random position according to given params within given area","syntaxes":[{"syntax":"[whitelist, blacklist, code] call BIS_fnc_randomPos","since":null,"effect":null,"exec":null,"params":[{"name":"whitelist","type":"Array","optional":false,"default":null,"description":"whitelisted areas. If not given, whole map is used. Areas can be:\n- Object - trigger\n- String - marker\n- Array - in format [center, radius] or [center, [a, b, angle, rect]]\n- Location - location","types":["Array"],"since":null,"text":"whitelist: Array - whitelisted areas. If not given, whole map is used. Areas can be:\n- Object - trigger\n- String - marker\n- Array - in format [center, radius] or [center, [a, b, angle, rect]]\n- Location - location"},{"name":"blacklist","type":"Array","optional":true,"default":"`[]`","description":"blacklisted areas. If not given, water is blacklisted. Areas can be:\n- Object - trigger\n- String - marker name or special tags names: \"water\" - exclude water, \"ground\" - exclude land\n- Array - in format [center, radius] or [center, [a, b, angle, rect]]\n- Location - location","types":["Array"],"since":null,"text":"blacklist: Array - (Optional, default `[]`) blacklisted areas. If not given, water is blacklisted. Areas can be:\n- Object - trigger\n- String - marker name or special tags names: \"water\" - exclude water, \"ground\" - exclude land\n- Array - in format [center, radius] or [center, [a, b, angle, rect]]\n- Location - location"},{"name":"code","type":"Code","optional":true,"default":"`{ true }`","description":"custom condition which should return true for current position candidate passed in _this variable to be accepted. If not specified all candidates are accepted","types":["Code"],"since":null,"text":"code: Code - (Optional, default `{ true }`) custom condition which should return true for current position candidate passed in _this variable to be accepted. If not specified all candidates are accepted"}],"returns":{"type":"Array","types":["Array"],"description":"position candidate in format [x,y,z] or [0,0] if position cannot be found","text":"Array - position candidate in format [x,y,z] or [0,0] if position cannot be found"}}],"examples":[{"text":"```sqf\nprivate _randomPosMapNoWater = [] call BIS_fnc_randomPos;\n```","code":["private _randomPosMapNoWater = [] call BIS_fnc_randomPos;"]},{"text":"```sqf\nprivate _randomPosMapNoWater = [nil, [\"water\"]] call BIS_fnc_randomPos;\n```","code":["private _randomPosMapNoWater = [nil, [\"water\"]] call BIS_fnc_randomPos;"]},{"text":"```sqf\nprivate _randomPosMapNoLand = [nil, [\"ground\"]] call BIS_fnc_randomPos;\n```","code":["private _randomPosMapNoLand = [nil, [\"ground\"]] call BIS_fnc_randomPos;"]},{"text":"```sqf\nprivate _randomPosMap = [nil, []] call BIS_fnc_randomPos;\n```","code":["private _randomPosMap = [nil, []] call BIS_fnc_randomPos;"]},{"text":"```sqf\nprivate _randomPosAroundPlayer = [[[position player, 50]], []] call BIS_fnc_randomPos;\n```","code":["private _randomPosAroundPlayer = [[[position player, 50]], []] call BIS_fnc_randomPos;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["BIS_fnc_randomPosTrigger","BIS_fnc_getArea","BIS_fnc_findSafePos"],"notes":[{"user":"Tankbuster","date":"2020-03-30T21:33:00Z","text":"The code parameter here can be quite powerful.\nIf using #Example 5 above, adding code as below will make the returned positions always be on a road.\n\n```sqf\nprivate _randomRoadPosAroundPlayer = [[[position player, 50]], [], { isOnRoad _this }] call BIS_fnc_randomPos;\n```"}],"categories":["Arma 3: Functions","Function Group: Positions","Functions","Introduced with Take On Helicopters version 1.00","Take On Helicopters: Functions","Take On Helicopters: New Functions"],"docblock":null,"filled_from_docblock":[]}