2015-08-28 19:14:59 +00:00
|
|
|
private ["_nearestObjectMinDistance","_maxTerrainGradient","_safePosParams","_validspot","_i","_pos","_markerName"];
|
|
|
|
|
|
|
|
params [["_nearestObjectMinDistance",25,[0]],["_maxTerrainGradient",10,[0]]];
|
2015-08-28 06:04:50 +00:00
|
|
|
|
2015-08-28 08:38:46 +00:00
|
|
|
if (worldName=="Altis") then {
|
2015-08-28 19:14:59 +00:00
|
|
|
_safePosParams = [[16000,16000],0,16000,_nearestObjectMinDistance,0,_maxTerrainGradient,0,DMS_findSafePosBlacklist];
|
2015-08-28 08:38:46 +00:00
|
|
|
} else {
|
2015-08-28 19:14:59 +00:00
|
|
|
_safePosParams = [[],0,-1,_nearestObjectMinDistance,0,_maxTerrainGradient,0,DMS_findSafePosBlacklist];
|
2015-08-28 08:38:46 +00:00
|
|
|
};
|
2015-08-28 06:04:50 +00:00
|
|
|
|
|
|
|
_validspot = false;
|
|
|
|
_i = 0;
|
|
|
|
while{!_validspot} do {
|
2015-08-28 19:14:59 +00:00
|
|
|
_pos = _safePosParams call BIS_fnc_findSafePos;
|
2015-08-28 06:04:50 +00:00
|
|
|
_i = _i+1;
|
2015-08-28 19:14:59 +00:00
|
|
|
try {
|
|
|
|
// Check for nearby water
|
|
|
|
if ([_pos,DMS_WaterNearBlacklist] call DMS_isNearWater) exitWith
|
2015-08-28 06:04:50 +00:00
|
|
|
{
|
2015-08-28 19:14:59 +00:00
|
|
|
throw ("water");
|
2015-08-28 06:04:50 +00:00
|
|
|
};
|
|
|
|
|
2015-08-28 19:14:59 +00:00
|
|
|
// Check for nearby players
|
|
|
|
if ([_pos,DMS_PlayerNearBlacklist] call ExileServer_util_position_isPlayerNearby) exitWith
|
2015-08-28 06:04:50 +00:00
|
|
|
{
|
2015-08-28 19:14:59 +00:00
|
|
|
throw ("players");
|
2015-08-28 06:04:50 +00:00
|
|
|
};
|
2015-08-28 19:14:59 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// Check for nearby spawn points
|
|
|
|
if (((markertype _x) isEqualTo "ExileSpawnZone") && {((getMarkerPos _x) distance2D _pos)<=DMS_SpawnZoneNearBlacklist}) exitWith
|
|
|
|
{
|
|
|
|
throw ("a spawn zone");
|
|
|
|
};
|
2015-08-28 06:04:50 +00:00
|
|
|
|
2015-08-28 19:14:59 +00:00
|
|
|
// Check for nearby trader zones
|
|
|
|
if (((markertype _x) isEqualTo "ExileTraderZone") && {((getMarkerPos _x) distance2D _pos)<=DMS_TraderZoneNearBlacklist}) exitWith
|
|
|
|
{
|
|
|
|
throw ("a trader zone");
|
|
|
|
};
|
2015-08-28 06:04:50 +00:00
|
|
|
|
2015-08-28 19:14:59 +00:00
|
|
|
// Check for nearby missions
|
|
|
|
if (((_x find "DMS_MissionMarkerDot")>-1) && {((getMarkerPos _x) distance2D _pos)<=DMS_MissionNearBlacklist}) exitWith
|
2015-08-28 06:04:50 +00:00
|
|
|
{
|
2015-08-28 19:14:59 +00:00
|
|
|
throw ("another mission");
|
2015-08-28 06:04:50 +00:00
|
|
|
};
|
2015-08-28 08:38:46 +00:00
|
|
|
false;
|
|
|
|
} count allMapMarkers;
|
2015-08-28 19:14:59 +00:00
|
|
|
|
|
|
|
// No exceptions found
|
|
|
|
_validspot = true;
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
if (DMS_DEBUG) then {
|
|
|
|
diag_log format ["DMS_DEBUG findSafePos :: Exception in attempt %1 | Position %2 is too close to %3!",_i,_pos,_exception];
|
|
|
|
};
|
2015-08-28 06:04:50 +00:00
|
|
|
};
|
|
|
|
};
|
2015-08-28 19:14:59 +00:00
|
|
|
if(DMS_DEBUG) then {
|
|
|
|
diag_log format["DMS_DEBUG findSafePos :: Mission position %1 with %2 params found in %3 attempts.",_pos,_safePosParams,_i];
|
|
|
|
};
|
|
|
|
_pos set [2, 0];
|
|
|
|
_pos;
|