BIS fnc findSafePos: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 63: Line 63:
[[Category:{{Name|tkoh}}: Functions|{{uc:findSafePos}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:findSafePos}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:findSafePos}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:findSafePos}}]]
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on March 15, 2017 - 19:30 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
To make sure position is not inside a building, increase distance to nearest object param.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Revision as of 20:30, 15 March 2017


Hover & click on the images for description

Description

Description:
This function generates position on a map according to several given parameters (see diagram):

bis fnc findsafepos.jpg
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].
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[center, minDist, maxDist, objDist, waterMode, maxGrad, shoreMode, blacklistPos, defaultPos] call BIS_fnc_findSafePos
Parameters:
center (Optional): center position. Could be one of:
  • Array - Position2D or Position3D - position
  • Object - object which position will be used
  • Nothing - when passing empty array [] or nothing, the world's "safePositionAnchor" entry will be used. Default: []
minDist (Optional): Number - minimum distance from the center position. Default: 0
maxDist (Optional): Number - maximum distance from the center position. If -1, the world's "safePositionRadius" entry will be used. Default: -1
objDist (Optional): Number - minimum distance from the nearest object. Default: 0
waterMode (Optional): Number - water mode. Could be one of:
  • 0 - cannot be in water (Default: 0)
  • 1 - can either be in water or not
  • 2 - must be in water
maxGrad (Optional): Number - maximum terrain gradient (hill steepness). Default: 0
shoreMode (Optional): Number - shore mode. Could be one of:
  • 0 - does not have to be at a shore (Default: 0)
  • 1 - must be at a shore
blacklistPos (Optional): blacklisted area. Could be one of:
  • Array - in format [topLeftCorner, bottomRightCorner] (Default: []) - top and bottom coordinates of blacklisted area
  • Object - trigger area
  • String - marker area
  • Location - location
defaultPos (Optional): Array default (fall back) positions in format [posOnLand, posOnSea]. Default: []
Return Value:
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]

Examples

Example 1:
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: _pos = [player, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos;
Example 2:
_pos = [getPos player, 2000, 5000, 1, 0, 0.7, 0, [], [getPos player, getPos player]] call BIS_fnc_findSafePos;
Example 3:
_pos = [[], 0, 1000] call BIS_fnc_findSafePos;

Additional Information

See also:
BIS_fnc_randomPosTriggerBIS_fnc_randomPos

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

Posted on March 15, 2017 - 19:30 (UTC)
Killzone Kid
To make sure position is not inside a building, increase distance to nearest object param.