Advertisement
secondcoming

fnc_isSafePos.sqf

Feb 5th, 2019
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.28 KB | None | 0 0
  1. private _position       = _this select 0;
  2. private _validspot      = true;
  3.  
  4. // is position in range of a player?
  5. if([_position, SC_maxDistanceToPlayer] call ExileClient_util_world_isAlivePlayerInRange) then
  6. {
  7.     _validspot = true;
  8. }
  9. else
  10. {
  11.     _validspot = false;
  12. };
  13.  
  14. // Check if position is near a blacklisted area
  15. {
  16.     private _blacklistPos       = _x select 0;
  17.     private _blacklistRadius    = _x select 1;
  18.     private _blacklistMap       = _x select 2;
  19.     if(isNil "_blacklistPos" OR isNil "_blacklistRadius" OR isNil "_blacklistMap") exitWith
  20.     {
  21.         _logDetail = format["[OCCUPATION]:: Invalid blacklist position supplied check SC_blackListedAreas in your config.sqf"];
  22.         [_logDetail] call SC_fnc_log;          
  23.        
  24.     };
  25.     if (worldName == _blacklistMap) then
  26.     {
  27.            
  28.         _distance = _position distance2D _blacklistPos;
  29.         if(_distance < _blacklistRadius) then
  30.         {
  31.             _validspot = false;
  32.             diag_log format["[OCCUPATION]:: %1 is %2m from blacklisted position %3 (blacklisted)",_position,_distance,_blacklistPos];          
  33.         };
  34.     };
  35. }forEach SC_blackListedAreas;
  36.  
  37. if(_validspot) then
  38. {
  39.    
  40.  
  41.     // is position too close to a player?
  42.     if([_position, SC_minDistanceToPlayer] call ExileClient_util_world_isAlivePlayerInRange) exitwith { _validspot = false; };
  43.  
  44.     //Check if near player territory
  45.     private _nearBase = (nearestObjects [_position,["Exile_Construction_Flag_Static"],SC_minDistanceToTerritory]) select 0;
  46.     if (!isNil "_nearBase") then { _validspot = false;  }; 
  47.  
  48.     // is position in range of a territory?
  49.     if([_position, SC_minDistanceToTerritory] call ExileClient_util_world_isTerritoryInRange) exitwith { _validspot = false; };
  50.  
  51.     // is position in range of a trader zone?
  52.     if([_position, SC_minDistanceToTraders] call ExileClient_util_world_isTraderZoneInRange) exitwith { _validspot = false; };
  53.  
  54.     // is position in range of a spawn zone?
  55.     if([_position, SC_minDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) exitwith { _validspot = false; };
  56.  
  57.  
  58.    
  59.     // is position in range of a map marker?
  60.     {
  61.         _markerPos = getMarkerPos _x;
  62.         if ((_markerPos distance2D _position) < 350) exitWith { _validspot = false; };
  63.     }
  64.     forEach allMapMarkers;
  65. };      
  66.  
  67. _validspot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement