BIS fnc randomPos: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>\[\[private\]\] (_?[a-zA-Z0-9_]+) = \[([^\[]*)\] \[\[(call|spawn)\]\] \[\[(BI(N|S)_fnc_[a-zA-Z0-9_]+)\]\];?<\/code>" to "<sqf>private $1 = [$2] $3 $4;</sqf>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 31: | Line 31: | ||
|x1= <sqf>private _randomPosMapNoWater = [] call BIS_fnc_randomPos;</sqf> | |x1= <sqf>private _randomPosMapNoWater = [] call BIS_fnc_randomPos;</sqf> | ||
|x2= < | |x2= <sqf>private _randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos;</sqf> | ||
|x3= < | |x3= <sqf>private _randomPosMapNoLand = [nil, ["ground"]] call BIS_fnc_randomPos;</sqf> | ||
|x4= < | |x4= <sqf>private _randomPosMap = [nil, []] call BIS_fnc_randomPos;</sqf> | ||
|x5= < | |x5= <sqf>private _randomPosAroundPlayer = [[[position player, 50]], []] call BIS_fnc_randomPos;</sqf> | ||
|seealso= [[BIS_fnc_randomPosTrigger]] [[BIS_fnc_getArea]] [[BIS_fnc_findSafePos]] | |seealso= [[BIS_fnc_randomPosTrigger]] [[BIS_fnc_getArea]] [[BIS_fnc_findSafePos]] | ||
Line 46: | Line 46: | ||
|timestamp= 20200330213300 | |timestamp= 20200330213300 | ||
|text= The code parameter here can be quite powerful. | |text= The code parameter here can be quite powerful. | ||
If using {{ | If using {{Link|#Example 5}} above, adding code as below will make the returned positions always be on a road. | ||
< | <sqf>private _randomRoadPosAroundPlayer = [[[position player, 50]], [], { isOnRoad _this }] call BIS_fnc_randomPos;</sqf> | ||
}} | }} |
Revision as of 11:52, 13 July 2022
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:
- 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:
- Example 2:
- Example 3:
- Example 4:
- Example 5:
Additional Information
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
- 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.