BIS fnc randomPos: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (return value was also wrong)
(documentation)
Line 9: Line 9:
|1.00|=
|1.00|=
____________________________________________________________________________________________
____________________________________________________________________________________________
| Selects a random position of given whitelist array in trigger area (uses a position as center position). Includes only areas of one of the given types: ''water'', ''ground'', ''out'' (outside of the [[trigger]]) and can exclude types. Can execute a custom code as optional parameter when a position was found. |= Description
| Selects random position according to given params within given area |= Description


| <pre>_mylocation <nowiki>=</nowiki> [array, array, code] call BIS_fnc_randomPos;</pre> |= Syntax
| [whitelist, blacklist, code] call '''BIS_fnc_randomPos''' |= Syntax
____________________________________________________________________________________________
____________________________________________________________________________________________




|p1= [whitelist, blacklist, code]: [[Array]]|= Parameter 1
|p2=whitelist (Optional): [[Array]] - whitelisted areas. If not given, whole map is used. Areas could be:
* [[Object]] - trigger
* [[String]] - marker
* [[Array]] - in format [center, radius] or [center, [a, b, angle, rect]]
* [[Location]] - location.  |= Parameter 2
|p3=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.  |= Parameter 3
|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|= Parameter 4


|p1=(''optional'') Whitelist (array containing array [[[position]], radius],  or a [[trigger]] object or tags ("water", "ground", "out"). Defaults to [world area] - [[Array]] |= Parameter 1
|[[Array]] - position candidate in format [x,y,z] or [0,0] if position cannot be found |= Return value
|p2=(''optional'') Blacklist (array containing the following tags gettings excluded from the result: "water", "ground", "out"). Defaults to ["water", "out"] - [[Array]] |= Parameter 2
|p3=(''optional'') Custom condition. Passes position candidate to code as [[_this]] variable. If code evaluates true then position is ultimately returned - [[Code]] |= Parameter 3
 
 
 
|[[position]] (array with x,y position) - [[Array]] |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>/* lets take a look in the area of the trigger ''_triggerobject'' with a longitude greater than 10000
|x1= <code>_randomPosMapNoWater = [] [[call]] [[BIS_fnc_randomPos]];</code> |= Syntax
but no position in the water or outside of the trigger, return the position to _myposition */
|x2= <code>_randomPosMapNoWater = <nowiki>[</nowiki>[[nil]], ["water"]] [[call]] [[BIS_fnc_randomPos]];</code> |= Syntax
 
|x3= <code>_randomPosMapNoLand = <nowiki>[</nowiki>[[nil]], ["ground"]] [[call]] [[BIS_fnc_randomPos]];</code> |= Syntax
_myposition <nowiki>=</nowiki> [ [_triggerobject], ["water","out"], {_this select 0 > 10000} ] [[call]] [[BIS_fnc_randomPos]];
|x4= <code>_randomPosMap = <nowiki>[</nowiki>[[nil]], []] [[call]] [[BIS_fnc_randomPos]];</code> |= Syntax
</code> |= Syntax
|x5= <code>_randomPosAroundPlayer = <nowiki>[[[</nowiki>[[position]] [[player]], 50]],[]] [[call]] [[BIS_fnc_randomPos]];</code> |= Syntax
____________________________________________________________________________________________
____________________________________________________________________________________________


| |mp= Can be used on client or server machine.


| |= See also
| [[BIS_fnc_randomPosTrigger]], [[BIS_fnc_getArea]]|= See also


}}
}}

Revision as of 10:36, 4 May 2017


Hover & click on the images for description

Description

Description:
Selects random position according to given params within given area
Execution:
call
Groups:
Uncategorised

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_getArea

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

Notes

Bottom Section