BIS fnc randomPos: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "code>_([a-zA-Z0-9_]+) = " to "code>private _$1 = ")
m (Text replacement - "\|seealso= ([^ ]+)(\]\]|\}\}), *(\[\[|\{\{)" to "|seealso= $1$2 $3")
Line 39: Line 39:
|x5= <code>[[private]] _randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]], []] [[call]] [[BIS_fnc_randomPos]];</code>
|x5= <code>[[private]] _randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]], []] [[call]] [[BIS_fnc_randomPos]];</code>


|seealso= [[BIS_fnc_randomPosTrigger]], [[BIS_fnc_getArea]], [[BIS_fnc_findSafePos]]
|seealso= [[BIS_fnc_randomPosTrigger]] [[BIS_fnc_getArea]], [[BIS_fnc_findSafePos]]
}}
}}



Revision as of 12:53, 1 July 2022

Hover & click on the images for description

Description

Description:
Selects random position according to given params within given area
Execution:
call
Groups:
Map and Markers

Syntax

Syntax:
[whitelist, blacklist, code] call BIS_fnc_randomPos
Parameters:
whitelist: Array - whitelisted areas. If not given, whole map is used. Areas can be:
blacklist: Array - (Optional, default []) blacklisted areas. If not given, water is blacklisted. Areas can be:
  • Object - trigger
  • String - marker name or special tags names: "water" - exclude water, "ground" - exclude land
  • Array - in format [center, radius] or [center, [a, b, angle, rect]]
  • Location - location
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
Return Value:
Array - position candidate in format [x,y,z] or [0,0] if position cannot be found

Examples

Example 1:
private _randomPosMapNoWater = [] call BIS_fnc_randomPos;
Example 2:
private _randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos;
Example 3:
private _randomPosMapNoLand = [nil, ["ground"]] call BIS_fnc_randomPos;
Example 4:
private _randomPosMap = [nil, []] call BIS_fnc_randomPos;
Example 5:
private _randomPosAroundPlayer = [[[position player, 50]], []] call BIS_fnc_randomPos;

Additional Information

See also:
BIS_fnc_randomPosTrigger BIS_fnc_getAreaBIS_fnc_findSafePos

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Tankbuster - c
Posted on Mar 30, 2020 - 21:33 (UTC)
The code parameter here can be quite powerful. If using Example 5 above, adding code as below will make the returned positions always be on a road. private _randomRoadPosAroundPlayer = [[[position player, 50]], [], { isOnRoad _this }] call BIS_fnc_randomPos;