DMS_Exile/@ExileServer/addons/a3_dms/scripts/findSafePos.sqf
eraser1 0b0c290495 Function Changes + Fixes + Comments + Logs
Added configurable distance to when cleanup will be aborted for an
object with a player nearby.

Created TargetsKilled function

Rewrite BroadCastMissionStatus (the function was doing the same thing
for each switch case except one, so I just put that in a select
statement)

Created function information for CleanUp.

CleanUp was using "_this" instead of "_x"

Created more/better debug info for CleanUp

Changed calling parameters for FillCrate.

Increased robustness of FillCrate.

Made FillCrate prettier

Created function information for FindSafePos

Created function information for IsPlayerNearByARRAY (deprecated)

Tweaks to MissionStatusCheck:
Created debug log for empty "DMS_Mission_Arr"
Fixed placement of index increase (otherwise deleteAt would remove
incorrect element if it existed)

Created MissionSuccessState

Created logs for RemoveMarkers

Created function information for RemoveMarkers + made it prettier

Created function information for SelectMagazine

Created TargetsKilled
2015-08-28 16:52:56 -05:00

77 lines
2.0 KiB
Plaintext

/*
DMS_findSafePos
Created by eraser1
Usage:
[
_nearestObjectMinDistance,
_maxTerrainGradient
] call DMS_findSafePos;
*/
private ["_nearestObjectMinDistance","_maxTerrainGradient","_safePosParams","_validspot","_i","_pos"];
params [["_nearestObjectMinDistance",25,[0]],["_maxTerrainGradient",10,[0]]];
if (worldName=="Altis") then {
_safePosParams = [[16000,16000],0,16000,_nearestObjectMinDistance,0,_maxTerrainGradient,0,DMS_findSafePosBlacklist];
} else {
_safePosParams = [[],0,-1,_nearestObjectMinDistance,0,_maxTerrainGradient,0,DMS_findSafePosBlacklist];
};
_validspot = false;
_i = 0;
while{!_validspot} do {
_pos = _safePosParams call BIS_fnc_findSafePos;
_i = _i+1;
try
{
// Check for nearby water
if ([_pos,DMS_WaterNearBlacklist] call DMS_isNearWater) exitWith
{
throw ("water");
};
// Check for nearby players
if ([_pos,DMS_PlayerNearBlacklist] call ExileServer_util_position_isPlayerNearby) exitWith
{
throw ("players");
};
{
// Check for nearby spawn points
if (((markertype _x) isEqualTo "ExileSpawnZone") && {((getMarkerPos _x) distance2D _pos)<=DMS_SpawnZoneNearBlacklist}) exitWith
{
throw ("a spawn zone");
};
// Check for nearby trader zones
if (((markertype _x) isEqualTo "ExileTraderZone") && {((getMarkerPos _x) distance2D _pos)<=DMS_TraderZoneNearBlacklist}) exitWith
{
throw ("a trader zone");
};
// Check for nearby missions
if (((_x find "DMS_MissionMarkerDot")>-1) && {((getMarkerPos _x) distance2D _pos)<=DMS_MissionNearBlacklist}) exitWith
{
throw ("another mission");
};
false;
} count allMapMarkers;
// 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];
};
};
};
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;