secondcoming

ExileClient_util_world_canBuildHere.sqf

May 9th, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 3.62 KB | None | 0 0
  1. /**
  2.  * ExileClient_util_world_canBuildHere
  3.  *
  4.  * Exile Mod
  5.  * www.exilemod.com
  6.  * © 2015 Exile Mod Team
  7.  *
  8.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10.  */
  11.  
  12. private["_constructionConfigName","_position","_playerUID","_result","_requiresTerritory","_canBePlacedOnRoad","_minimumDistanceToTraderZones","_minimumDistanceToSpawnZones","_minimumDistanceToOtherTerritories","_maximumTerritoryRadius","_positionObject","_nearestFlags","_radius","_buildRights","_territoryLevelConfigs","_territoryLevelConfig","_numberOfConstructionsAllowed"];
  13. _constructionConfigName = _this select 0;
  14. _position = _this select 1;
  15. _playerUID = _this select 2;
  16. _result = 0;
  17. _requiresTerritory = getNumber (configFile >> "CfgConstruction" >> _constructionConfigName >> "requiresTerritory") isEqualTo 1;
  18. _canBePlacedOnRoad = getNumber (configFile >> "CfgConstruction" >> _constructionConfigName >> "canBePlacedOnRoad") isEqualTo 1;
  19. _minimumDistanceToTraderZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToTraderZones");
  20. _minimumDistanceToSpawnZones = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToSpawnZones");
  21. _minimumDistanceToOtherTerritories = getNumber (missionConfigFile >> "CfgTerritories" >> "minimumDistanceToOtherTerritories");
  22. _maximumTerritoryRadius = getNumber (missionConfigFile >> "CfgTerritories" >> "maximumRadius");
  23. try
  24. {
  25.     //////////////////////////////////////
  26.     // Builiding Height Restriction
  27.     //////////////////////////////////////
  28.     if (_position select 2 > 50) then
  29.     {
  30.         throw 9;
  31.     }; 
  32.     //////////////////////////////////////
  33.     if ([_position, _minimumDistanceToTraderZones] call ExileClient_util_world_isTraderZoneInRange) then
  34.     {
  35.         throw 4;
  36.     };
  37.     if ([_position, _minimumDistanceToSpawnZones] call ExileClient_util_world_isSpawnZoneInRange) then
  38.     {
  39.         throw 5;
  40.     };
  41.     if ((AGLtoASL _position) call ExileClient_util_world_isInRadiatedZone) then
  42.     {
  43.         throw 8;
  44.     };
  45.     if !(_canBePlacedOnRoad) then
  46.     {
  47.         if (isOnRoad [_position select 0, _position select 1, 0]) then
  48.         {
  49.             throw 3;
  50.         };
  51.     };
  52.     {
  53.         _positionObject = (ASLtoAGL (getPosASL _x));
  54.         if (_position isEqualTo _positionObject) then
  55.         {
  56.             throw 7;
  57.         };
  58.     } forEach (_position nearObjects ["Exile_Construction_Abstract_Static", 3]);
  59.     if (_constructionConfigName isEqualTo "Flag") then
  60.     {
  61.         if ([_position, _minimumDistanceToOtherTerritories] call ExileClient_util_world_isTerritoryInRange) then
  62.         {
  63.             throw 2;
  64.         };
  65.     }
  66.     else
  67.     {
  68.         _nearestFlags = (nearestObjects [_position, ["Exile_Construction_Flag_Static"], _maximumTerritoryRadius]);
  69.         if !(_nearestFlags isEqualTo []) then
  70.         {
  71.             {
  72.                 _radius = _x getVariable ["ExileTerritorySize", -1];
  73.                 if (((AGLtoASL _position) distance (getPosASL _x)) < _radius) then
  74.                 {
  75.                     _buildRights = _x getVariable ["ExileTerritoryBuildRights", []];
  76.                     if (_playerUID in _buildRights) then
  77.                     {
  78.                         _territoryLevelConfigs = getArray (missionConfigFile >> "CfgTerritories" >> "prices");
  79.                         _territoryLevelConfig = _territoryLevelConfigs select ((_x getVariable ["ExileTerritoryLevel", 0]) - 1);
  80.                         _numberOfConstructionsAllowed = _territoryLevelConfig select 2;
  81.                         if ((_x getVariable ["ExileTerritoryNumberOfConstructions", 0]) >= _numberOfConstructionsAllowed) then
  82.                         {
  83.                             throw 6;
  84.                         };
  85.                         throw 0;
  86.                     };
  87.                 };
  88.                 throw 2;
  89.             }
  90.             forEach _nearestFlags;
  91.         };
  92.         if (_requiresTerritory) then
  93.         {
  94.             throw 1;   
  95.         };
  96.     };
  97. }
  98. catch
  99. {
  100.     _result = _exception;
  101. };
  102. _result
Advertisement
Add Comment
Please, Sign In to add comment