From 992ab199ddd21fd8bca5ebca9a4fff075691458d Mon Sep 17 00:00:00 2001 From: oiad Date: Sun, 9 Apr 2017 10:45:29 +1200 Subject: [PATCH] =?UTF-8?q?Convert=20DZE=5FSafeZoneNoBuildItems=20to=20han?= =?UTF-8?q?dle=20nested=20arrays=20for=20custom=20d=E2=80=A6=20(#1934)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Convert DZE_SafeZoneNoBuildItems to handle nested arrays for custom distances per items. This makes the DZE_SafeZoneNoBuildItems be able to handle nested arrays, This allows you to set custom distances per item instead of having it all the default distance. E.g DZE_SafeZoneNoBuildItems = ["VaultStorageLocked","LockboxStorageLocked",["Plastic_Pole_EP1_DZ",1300]]; * Fix forgotten exitWith syntax. * Removed unneeded check. --- SQF/dayz_code/compile/dze_buildChecks.sqf | 29 +++++++++++++++++++---- SQF/dayz_code/configVariables.sqf | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/SQF/dayz_code/compile/dze_buildChecks.sqf b/SQF/dayz_code/compile/dze_buildChecks.sqf index ae6ed9268..2efd11fd7 100644 --- a/SQF/dayz_code/compile/dze_buildChecks.sqf +++ b/SQF/dayz_code/compile/dze_buildChecks.sqf @@ -12,6 +12,25 @@ if (!canbuild) exitWith {dayz_actionInProgress = false; format[localize "STR_EPO if (isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then { _requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot"); }; + +_checkClass = { + private ["_checkOK","_distance"]; + + _checkOK = false; + _distance = DZE_SafeZoneNoBuildDistance; + + { + if (typeName _x == "ARRAY") then { + if (_x select 0 == _classname) then {_checkOK = true; _distance = _x select 1;}; + } else { + if (_x == _className) then {_checkOK = true}; + }; + if (_checkOK) exitWith {}; + } count DZE_SafeZoneNoBuildItems; + + [_checkOK,_distance] +}; + _isPole = (_classname == "Plastic_Pole_EP1_DZ"); _isLandFireDZ = (_classname == "Land_Fire_DZ"); @@ -85,13 +104,15 @@ if ((count (nearestObjects [_center,_buildables,_distance])) >= DZE_BuildingLimi _text = getText (configFile >> 'CfgMagazines' >> _item >> 'displayName'); -if (((count DZE_SafeZoneNoBuildItems) > 0) && {_classname in DZE_SafeZoneNoBuildItems}) then { +_buildCheck = call _checkClass; + +if (_buildCheck select 0) then { { - if ((player distance (_x select 0)) < DZE_SafeZoneNoBuildDistance) exitWith { _canBuild = false; }; - } forEach DZE_safeZonePosArray; + if ((player distance (_x select 0)) < _buildCheck select 1) exitWith {_canBuild = false;}; + } count DZE_safeZonePosArray; }; -if !(_canBuild) exitWith { dayz_actionInProgress = false; format [localize "STR_EPOCH_PLAYER_166",_text,DZE_SafeZoneNoBuildDistance] call dayz_rollingMessages; [false, _isPole]; }; +if !(_canBuild) exitWith {dayz_actionInProgress = false; format [localize "STR_EPOCH_PLAYER_166",_text,_buildCheck select 1] call dayz_rollingMessages; [false, _isPole];}; if ((count DZE_NoBuildNear) > 0) then { _near = (nearestObjects [_pos,DZE_NoBuildNear,DZE_NoBuildNearDistance]); diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index 5e57bd93a..04b0afaec 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -26,7 +26,7 @@ DZE_VanillaUICombatIcon = true; //Display or hide combat UI icon if using DZE_UI timezoneswitch = 0; // Changes murderMenu times with this offset in hours. DZE_NoVehicleExplosions = false; //Disable vehicle explosions to prevent damage to objects by ramming. Doesn't work with amphibious pook which should not be used due to FPS issues. DZE_SafeZonePosArray = []; //Prevent players in safeZones from being killed if their vehicle is destroyed. Format is [[[3D POS], RADIUS],[[3D POS], RADIUS]]; Ex. DZE_SafeZonePosArray = [[[6325.6772,7807.7412,0],150],[[4063.4226,11664.19,0],150]]; -DZE_SafeZoneNoBuildItems = []; // Array of object class names not allowed to build near the safe zones listed above. i.e ["VaultStorageLocked","LockboxStorageLocked","Plastic_Pole_EP1_DZ"] etc. +DZE_SafeZoneNoBuildItems = []; // Array of object class names not allowed to be built near the safe zones listed above. Can be nested arrays for custom distances. i.e ["VaultStorageLocked","LockboxStorageLocked",["Plastic_Pole_EP1_DZ",1300]] etc. DZE_SafeZoneNoBuildDistance = 150; // Distance from safe zones listed above to disallow building near. DZE_NoBuildNear = []; //Array of object class names that are blacklisted to build near. i.e ["Land_Mil_ControlTower","Land_SS_hangar"] etc. DZE_NoBuildNearDistance = 150; // Distance from blacklisted objects to disallow building near.