BIS fnc findSafePos: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(WIp)
No edit summary
Line 11: Line 11:
[[Image:bis_fnc_findsafepos.jpg|800px]]
[[Image:bis_fnc_findsafepos.jpg|800px]]
<br>
<br>
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 object. If '''maxGrad''' > 0 then the position will be also checked for how flat the area around is in '''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 requested on water.<br><br>
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 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 requested on water.<br><br>
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].
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].
<br><br>
<br><br>

Revision as of 18:08, 4 May 2016


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 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 requested on water.

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].

/*
	File: findSafePos.sqf

	Description:
	Function to retrieve and dynamic position in the world according to several parameters.

	Parameter(s):
	_this select 0: center position (Array)
						Note: passing [] (empty Array), the world's safePositionAnchor entry will be used.
	_this select 1: minimum distance from the center position (Number)
	_this select 2: maximum distance from the center position (Number)
						Note: passing -1, the world's safePositionRadius entry will be used.
	_this select 3: minimum distance from the nearest object (Number)
	_this select 4: water mode (Number)
						0: cannot be in water
						1: can either be in water or not
						2: must be in water
	_this select 5: maximum terrain gradient (average altitude difference in meters - Number)
	_this select 6: shore mode (Number):
						0: does not have to be at a shore
						1: must be at a shore
	_this select 7: (optional) blacklist (Array of Arrays):
						(_this select 7) select X: Top-left and bottom-right coordinates of blacklisted area (Array)
	_this select 8: (optional) default positions (Array of Arrays):
						(_this select 8) select 0: default position on land (Array)
						(_this select 8) select 1: default position on water (Array)
	
	Returns:
	Coordinate array with a position solution.
	
	TODO:
	* Maybe allow passing several combinations of position, min and max dist ... so that you can 
	avoid several things?
	* Interpretation of minDist / maxDist is wrong. It's not true distance that is used. Too bad?
*/

(Placeholder description extracted from the function header by BIS_fnc_exportFunctionsToWiki)
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
Syntax needed
Return Value:
Return value needed

Examples

Example 1:
kRandSpawnPos = [kdestPos, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos;

Additional Information

See also:
See also needed

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

Example 1 would generate a position as follows: Minimal 1 meter from "kdestPos" but not further than 150, not closer than 3 meters to any other object, not in the water, maximum gradient of 20 meters, not on the shoreline. And safe the generated position in "kRandSpawnPos". --Kamaradski (talk) 13:56, 10 March 2015 (CET) 1 -->

Bottom Section