BIS fnc randomPos: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "</dd> </dl>" to "</dd> </dl>") |
Lou Montana (talk | contribs) m (Fix parameters) |
||
Line 13: | Line 13: | ||
|s1= [whitelist, blacklist, code] call [[BIS_fnc_randomPos]] | |s1= [whitelist, blacklist, code] call [[BIS_fnc_randomPos]] | ||
|p1 | |p1= whitelist: [[Array]] - whitelisted areas. If not given, whole map is used. Areas can be: | ||
* [[Object]] - trigger | * [[Object]] - trigger | ||
* [[String]] - marker | * [[String]] - marker | ||
* [[Array]] - in format [center, radius] or [center, [a, b, angle, rect]] | * [[Array]] - in format [center, radius] or [center, [a, b, angle, rect]] | ||
* [[Location]] - location | * [[Location]] - location | ||
| | |p2= blacklist: [[Array]] - (Optional, default []) blacklisted areas. If not given, water is blacklisted. Areas can be: | ||
* [[Object]] - trigger | * [[Object]] - trigger | ||
* [[String]] - marker name or special tags names: "water" - exclude water, "ground" - exclude land | * [[String]] - marker name or special tags names: "water" - exclude water, "ground" - exclude land | ||
* [[Array]] - in format [center, radius] or [center, [a, b, angle, rect]] | * [[Array]] - in format [center, radius] or [center, [a, b, angle, rect]] | ||
* [[Location]] - location | * [[Location]] - location | ||
| | |p3= code: [[Code]] - (Optional, default {{ic|{ [[true]] }<nowiki/>}}) custom condition which should return true for current position candidate passed in [[Magic Variables#this|_this]] variable to be accepted. If not specified all candidates are accepted | ||
|r1= [[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found | |r1= [[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found | ||
Line 39: | Line 37: | ||
|x4= <code>_randomPosMap = [<nowiki/>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code> | |x4= <code>_randomPosMap = [<nowiki/>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code> | ||
|x5= <code>_randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]],[]] [[call]] [[BIS_fnc_randomPos]];</code> | |x5= <code>_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]] | ||
}} | }} | ||
{{Note | |||
|user= Tankbuster | |||
|timestamp= 20200330213300 | |||
|text= The code parameter here can be quite powerful. | |||
If using {{HashLink|#Example 5}} above, adding code as below will make the returned positions always be on a road. | |||
<code>[[private]] _randomRoadPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]], [], { [[isOnRoad]] _this }] [[call]] [[BIS_fnc_randomPos]];</code> | |||
The code parameter here can be quite powerful. | }} | ||
If using | |||
<code> | |||
Revision as of 12:28, 19 January 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:
_randomPosMapNoWater = [] call BIS_fnc_randomPos;
- Example 2:
_randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos;
- Example 3:
_randomPosMapNoLand = [nil, ["ground"]] call BIS_fnc_randomPos;
- Example 4:
_randomPosMap = [nil, []] call BIS_fnc_randomPos;
- Example 5:
_randomPosAroundPlayer = [[[position player, 50]], []] call BIS_fnc_randomPos;
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