BIS fnc randomPos: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <h3 style="display:none">Notes</h3> <dl class="command_description"> <!-- Note Section BEGIN --> <!-- Note Section END --> </dl> " to "")
m (Text replacement - " *\| *([Cc]omments|COMMENTS|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments \("local" or "global"\)|Multiplayer Effects \("local" or "global"\)|Multiplayer Execution \("server" o...)
Line 1: Line 1:
{{Function|Comments=
{{Function


| game2= arma3 |GAME2=
| game2= arma3 |GAME2=
Line 5: Line 5:


|TKOH |GAME=
|TKOH |GAME=
|1.00|Game version=
|1.00


|gr1 = Map and Markers |GROUP1=
|gr1 = Map and Markers
| Selects random position according to given params within given area |DESCRIPTION=
| Selects random position according to given params within given area


| [whitelist, blacklist, code] call '''BIS_fnc_randomPos''' |SYNTAX=
| [whitelist, blacklist, code] call '''BIS_fnc_randomPos'''




|p1= [whitelist, blacklist, code]: [[Array]]|PARAMETER1=
|p1= [whitelist, blacklist, code]: [[Array]]
|p2=whitelist (Optional): [[Array]] - whitelisted areas. If not given, whole map is used. Areas could be:
|p2=whitelist (Optional): [[Array]] - whitelisted areas. If not given, whole map is used. Areas could 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. |PARAMETER2=
* [[Location]] - location.
|p3=blacklist (Optional): [[Array]] - blacklisted areas. If not given, water is blacklisted. Areas could be:
|p3=blacklist (Optional): [[Array]] - blacklisted areas. If not given, water is blacklisted. Areas could 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. |PARAMETER3=
* [[Location]] - location.
|p4= code (Optional): [[Code]] - custom condition which should return true for current position candidate passed in [[_this]] variable to be accepted. If not specified all candidates are accepted|PARAMETER4=
|p4= code (Optional): [[Code]] - custom condition which should return true for current position candidate passed in [[_this]] variable to be accepted. If not specified all candidates are accepted


|[[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found |RETURNVALUE=
|[[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found


|x1= <code>_randomPosMapNoWater = [] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE1=
|x1= <code>_randomPosMapNoWater = [] [[call]] [[BIS_fnc_randomPos]];</code>
|x2= <code>_randomPosMapNoWater = [<nowiki/>[[nil]], ["water"]] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE2=
|x2= <code>_randomPosMapNoWater = [<nowiki/>[[nil]], ["water"]] [[call]] [[BIS_fnc_randomPos]];</code>
|x3= <code>_randomPosMapNoLand = [<nowiki/>[[nil]], ["ground"]] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE3=
|x3= <code>_randomPosMapNoLand = [<nowiki/>[[nil]], ["ground"]] [[call]] [[BIS_fnc_randomPos]];</code>
|x4= <code>_randomPosMap = [<nowiki/>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE4=
|x4= <code>_randomPosMap = [<nowiki/>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code>
|x5= <code>_randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]],[]] [[call]] [[BIS_fnc_randomPos]];</code> |EXAMPLE5=
|x5= <code>_randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]],[]] [[call]] [[BIS_fnc_randomPos]];</code>




| [[BIS_fnc_randomPosTrigger]], [[BIS_fnc_getArea]], [[BIS_fnc_findSafePos]]|SEEALSO=
| [[BIS_fnc_randomPosTrigger]], [[BIS_fnc_getArea]], [[BIS_fnc_findSafePos]]


}}
}}

Revision as of 00:36, 18 January 2021

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, blacklist, code]: Array
whitelist (Optional): Array - whitelisted areas. If not given, whole map is used. Areas could be:
blacklist (Optional): Array - blacklisted areas. If not given, water is blacklisted. Areas could 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 (Optional): Code - 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

See also:
BIS_fnc_randomPosTriggerBIS_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

Bottom Section

Posted on March 30, 2020 - 21:33 (UTC)
Tankbuster
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. randomRoadPosAroundPlayer = [[[position player,50]],[], {isOnRoad _this}] call BIS_fnc_randomPos;