Killzone_Kid
To make sure position is not inside a building, increase distance to nearest object param.
Results appear below as you type; use the arrow keys to move through them.
Function · Markdown · JSON · original wiki page
This function generates position on a map according to several given parameters (see diagram).
The position pos will be generated inside an area which resides between minDist and maxDist from the given center. If objDist is also specified, the position will be selected objDist away from nearest terrain object. If maxGrad > 0 then the position will be also checked for how flat the area around is within objDist radius. The function can additionally be instructed to generate position specifically on water or land (waterMode) or on a shoreline (shoreMode). The shoreLine param will be ignored if position is not requested specifically on land.
Additionally, generated position could be checked against the list of blacklisted positions blacklistPos. If search for suitable position failed, defaultPos position will be used. The format for defaultPos is array with 2 positions: [posOnLand, posOnWater].
[center, minDist, maxDist, objDist, waterMode, maxGrad, shoreMode, blacklistPos, defaultPos] call BIS_fnc_findSafePos
Parameters:
center: Array, Object or Nothing - (Optional, default []) center position. Can be one of:
minDist: Number - (Optional, default 0) minimum distance from the center position
maxDist: Number - (Optional, default -1) maximum distance from the center position. If -1, the world's "safePositionRadius" entry will be used
objDist: Number - (Optional, default 0) minimum distance from the resulting position to the center of nearest object. Specifying quite large distance here will slow the function and might often fail to find suitable position. Recommended value: 0..10
waterMode: Number - (Optional, default 0) water mode. Can be one of:
maxGrad: Number - (Optional, default 0) maximum terrain gradient (hill steepness). A quite small non-zero value could result in failure to find suitable position. Recommended: 0.1+
shoreMode: Number - (Optional, default 0) shore mode. Can be one of:
blacklistPos: Array - (Optional, default []) list of blacklisted areas in format [area1, area2, area3... areaN]. Can be one of:
defaultPos: Array - (Optional, default []) default position when no position is found. Array format is [landPosition, seaPosition], where:
Returns: Array - in format [x,y] on success. When position cannot be found at all, default map center position is returned, which will be in format [x,y,0]
Find position minimum 1m from from player but not further than 150m, not closer than 3m to any other object, not in the water, maximum gradient of 20, not on the shoreline:
private _pos = [player, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos;
private _pos = [getPos player, 2000, 5000, 1, 0, 0.7, 0, [], [getPos player, getPos player]] call BIS_fnc_findSafePos;
private _pos = [[], 0, 1000] call BIS_fnc_findSafePos;
BIS_fnc_randomPosTrigger · BIS_fnc_randomPos
To make sure position is not inside a building, increase distance to nearest object param.
If objDist > 0, this function will unfortunately treat all roads and trails seen on the map as obstacles to avoid, due to its unfiltered usage of nearestTerrainObjects.