diff --git a/SQF/dayz_code/actions/modular_build.sqf b/SQF/dayz_code/actions/modular_build.sqf index 210a5599c..c9f9b771f 100644 --- a/SQF/dayz_code/actions/modular_build.sqf +++ b/SQF/dayz_code/actions/modular_build.sqf @@ -55,31 +55,34 @@ _isLandFireDZ = _itemConfig select 10; //bool //Check for nearby plotpoles. Returns [_IsNearPlot,_nearestPole,_ownerID,_friendlies] [int,Obj,int,array] [_isPole, _requireplot, _isLandFireDZ] call player_build_plotCheck; +if (DZE_ActionInProgress) then { //needed otherwise _hasRequired gets RPT error + //Check for build requirements (missing tools and items). Returns [_hasrequireditem,_reason] [bool,string] _hasRequired = [_require, _text, true, true] call player_build_buildReq; //define item collected from function _hasrequireditem = _hasRequired select 0; //bool -if (_hasrequireditem and DZE_ActionInProgress) then { - - //Create object that is attached to a player (i.e Ghost preview if available) - _buildObject = [_classname, _ghost, _offset, true] call player_build_create; - - //define items collected from function - _location1 = _buildObject select 0; //array - _object = _buildObject select 1; //Obj - _position = _buildObject select 2; // array - _objectHelper = _buildObject select 3; //Obj - - _controls = [_object, _isAllowedUnderGround, _location1, _position, _objectHelper] call player_build_controls; + if (_hasrequireditem) then { + + //Create object that is attached to a player (i.e Ghost preview if available) + _buildObject = [_classname, _ghost, _offset, true] call player_build_create; + + //define items collected from function + _location1 = _buildObject select 0; //array + _object = _buildObject select 1; //Obj + _position = _buildObject select 2; // array + _objectHelper = _buildObject select 3; //Obj + + _controls = [_object, _isAllowedUnderGround, _location1, _position, _objectHelper] call player_build_controls; - //define items collected from function - _cancel = _controls select 0; //bool - _reason = _controls select 1; //string - _position = _controls select 2; //array - _dir = _controls select 3; //int - - //Publish item to a database - [_cancel, _position, _classnametmp,_isAllowedUnderGround, _text, _isPole, _lockable,_dir, _reason] call player_build_publish; -}; + //define items collected from function + _cancel = _controls select 0; //bool + _reason = _controls select 1; //string + _position = _controls select 2; //array + _dir = _controls select 3; //int + + //Publish item to a database + [_cancel, _position, _classnametmp,_isAllowedUnderGround, _text, _isPole, _lockable,_dir, _reason] call player_build_publish; + }; +}; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_build_buildReq.sqf b/SQF/dayz_code/actions/player_build_buildReq.sqf index 4364c1094..976a6dc79 100644 --- a/SQF/dayz_code/actions/player_build_buildReq.sqf +++ b/SQF/dayz_code/actions/player_build_buildReq.sqf @@ -1,3 +1,4 @@ +if(!DZE_ActionInProgress) exitWith {}; //Check for build requirements like tools and if item is in magazines (check args to disable checks) private ["_passArray","_missing","_hasrequireditem","_require","_hastoolweapon","_hasbuilditem","_checkMag","_checkTools","_reason"]; @@ -20,11 +21,14 @@ _passArray = []; _hasbuilditem = DZE_buildItem in magazines player; +_passArray = [_hasrequireditem,_reason]; + if (_checkMag) then { //passed argument if (!_hasbuilditem) exitWith { //End script if magazine was not found DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"build"] , "PLAIN DOWN"]; _reason = "missing item"; + _passArray }; }; @@ -33,9 +37,8 @@ if (_checkTools) then { //passed argument DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_137"),_missing] , "PLAIN DOWN"]; _reason = "missing tools"; + _passArray }; }; - -_passArray = [_hasrequireditem,_reason]; _passArray //[bool,string] diff --git a/SQF/dayz_code/actions/player_build_controls.sqf b/SQF/dayz_code/actions/player_build_controls.sqf index 6757f61db..6a17c2169 100644 --- a/SQF/dayz_code/actions/player_build_controls.sqf +++ b/SQF/dayz_code/actions/player_build_controls.sqf @@ -1,4 +1,4 @@ -private ["_canDo","_passArray","_objHDiff","_isOk","_zheightchanged","_zheightdirection","_rotate","_dir","_object","_position","_isAllowedUnderGround","_location2","_cancel","_reason","_lastDir","_objectHelper","_objectHelperDir","_objectHelperPos"]; +private ["_canDo","_passArray","_objHDiff","_isOk","_zheightchanged","_zheightdirection","_rotate","_dir","_object","_position","_isAllowedUnderGround","_location1","_location2","_cancel","_reason","_lastDir","_objectHelper","_objectHelperDir","_objectHelperPos"]; _object = _this select 0; _isAllowedUnderGround = _this select 1; @@ -142,8 +142,6 @@ while {_isOk} do { _objectHelper setPosATL _position; - //diag_log format["DEBUG Change BUILDING POS: %1", _position]; - if (!helperDetach) then { _objectHelper attachTo [player]; }; @@ -153,13 +151,13 @@ while {_isOk} do { _location2 = getPosATL player; _objectHelperPos = getPosATL _objectHelper; - + if(DZE_5) exitWith { _isOk = false; detach _object; - _dir = getDir _object; _position = getPosATL _object; - //diag_log format["DEBUG BUILDING POS: %1", _position]; + _dir = getDir _object; + deleteVehicle _object; detach _objectHelper; deleteVehicle _objectHelper; diff --git a/SQF/dayz_code/actions/player_build_countNearby.sqf b/SQF/dayz_code/actions/player_build_countNearby.sqf index c4949068f..d91b20b8e 100644 --- a/SQF/dayz_code/actions/player_build_countNearby.sqf +++ b/SQF/dayz_code/actions/player_build_countNearby.sqf @@ -1,7 +1,7 @@ -// disallow building if too many objects are found within 30m +// disallow building if too many objects are found within 30m (by default) private ["_cnt"]; -_cnt = count ((getPosATL player) nearObjects ["All",30]); +_cnt = count ((getPosATL player) nearObjects ["All",DZE_checkNearbyRadius]); if (_cnt >= DZE_BuildingLimit) exitWith { //end script if too many objects nearby DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"]; diff --git a/SQF/dayz_code/actions/player_build_getConfig.sqf b/SQF/dayz_code/actions/player_build_getConfig.sqf index b27f01004..a626ddcf3 100644 --- a/SQF/dayz_code/actions/player_build_getConfig.sqf +++ b/SQF/dayz_code/actions/player_build_getConfig.sqf @@ -1,3 +1,4 @@ +if(!DZE_ActionInProgress) exitWith {}; //Build an array of various variables gathered about build object from config files, only applies to legit buildable objects private ["_passArray","_classname","_classnametmp","_require","_text","_ghost","_lockable","_requireplot","_isAllowedUnderGround","_offset","_isPole","_isLandFireDZ"]; diff --git a/SQF/dayz_code/actions/player_build_needNearby.sqf b/SQF/dayz_code/actions/player_build_needNearby.sqf index e6eb22bd1..d6dfb82da 100644 --- a/SQF/dayz_code/actions/player_build_needNearby.sqf +++ b/SQF/dayz_code/actions/player_build_needNearby.sqf @@ -1,3 +1,4 @@ +if(!DZE_ActionInProgress) exitWith {}; //disallow building if required items (defined in config) are not found nearby private ["_abort","_reason","_distance","_needNear","_isNear"]; @@ -41,5 +42,3 @@ if (_abort) exitWith { cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"]; DZE_ActionInProgress = false; }; - -_reason //return string to a caller diff --git a/SQF/dayz_code/actions/player_build_plotCheck.sqf b/SQF/dayz_code/actions/player_build_plotCheck.sqf index 8dc87c45b..00117e6c8 100644 --- a/SQF/dayz_code/actions/player_build_plotCheck.sqf +++ b/SQF/dayz_code/actions/player_build_plotCheck.sqf @@ -1,3 +1,4 @@ +if(!DZE_ActionInProgress) exitWith {}; //Check if nearby plotpoles exists private ["_passArray","_isPole","_needText","_distance","_findNearestPoles","_findNearestPole","_IsNearPlot","_requireplot","_isLandFireDZ","_canBuildOnPlot","_nearestPole","_ownerID","_friendlies"]; @@ -11,7 +12,6 @@ _canBuildOnPlot = false; _nearestPole = objNull; _ownerID = 0; _friendlies = []; -_passArray = []; if(_isPole) then { //check if object is plotpole and adjust distance accordingly _distance = DZE_PlotPole select 1; @@ -31,12 +31,6 @@ _findNearestPole = []; //must define an empty array to avoid problems _IsNearPlot = count (_findNearestPole); //count our new array of non-destroyed plotpoles. Empty array will return 0 -// End script early if item is plot pole and another one exists within defined radius -if(_isPole && _IsNearPlot > 0) exitWith { - DZE_ActionInProgress = false; - cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; -}; - if(_IsNearPlot == 0) then { //No live plotpoles were found nearby // Allow building of plot if(_requireplot == 0 || _isLandFireDZ) then { @@ -68,10 +62,18 @@ if(_IsNearPlot == 0) then { //No live plotpoles were found nearby }; }; +_passArray = [_IsNearPlot,_nearestPole,_ownerID,_friendlies]; //create new array and pass it to caller + +// End script if item is plot pole and another one exists within defined radius +if(_isPole && _IsNearPlot > 0) exitWith { + DZE_ActionInProgress = false; + cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; + _passArray +}; + if(!_canBuildOnPlot) exitWith { //end script if requirements were not met DZE_ActionInProgress = false; cutText [format[(localize "STR_EPOCH_PLAYER_135"),_needText,_distance] , "PLAIN DOWN"]; + _passArray }; - -_passArray = [_IsNearPlot,_nearestPole,_ownerID,_friendlies]; //create new array and pass it to caller _passArray //[int,Obj,int,array] diff --git a/SQF/dayz_code/actions/player_build_states.sqf b/SQF/dayz_code/actions/player_build_states.sqf index b79b8e98a..d5f16221f 100644 --- a/SQF/dayz_code/actions/player_build_states.sqf +++ b/SQF/dayz_code/actions/player_build_states.sqf @@ -1,3 +1,4 @@ +if(!DZE_ActionInProgress) exitWith {}; //disallow building if these conditions are not met private ["_isFine","_onLadder","_vehicle","_inVehicle"]; @@ -10,24 +11,28 @@ if (dayz_isSwimming) exitWith { //end script if player is swimming DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"]; _isFine = "Swimming"; + _isFine }; if (_inVehicle) exitWith { //end script if player is in vehicle DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"]; _isFine = "In vehicle"; + _isFine }; if (_onLadder) exitWith { //end script if player is climbing on ladder DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"]; _isFine = "On ladder"; + _isFine }; if (player getVariable["combattimeout", 0] >= time) exitWith { //end script if player is in combat DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"]; _isFine = "In combat"; + _isFine }; _isFine //returns string to caller, default is "ok" if conditions were not met diff --git a/SQF/dayz_code/actions/snap_build.sqf b/SQF/dayz_code/actions/snap_build.sqf index ba3d8850a..087d9a0b4 100644 --- a/SQF/dayz_code/actions/snap_build.sqf +++ b/SQF/dayz_code/actions/snap_build.sqf @@ -3,7 +3,7 @@ // July 10 2014 // /*--------------------------------*/ -private ["_object","_objectSnapGizmo","_objColorActive","_objColorInactive","_classname","_whitelist","_points","_radius","_cfg","_cnt","_pos","_findWhitelisted","_nearbyObject","_posNearby","_selectedAction","_newPos","_pointsNearby","_onWater"]; +private ["_object","_objectSnapGizmo","_objColorActive","_objColorInactive","_classname","_whitelist","_points","_radius","_cfg","_cnt","_pos","_findWhitelisted","_nearbyObject","_posNearby","_selectedAction","_newPos","_pointsNearby","_onWater","_waterBase"]; //Args snapActionState = _this select 3 select 0; _object = _this select 3 select 1; @@ -58,8 +58,10 @@ fnc_initSnapPoints = { fnc_initSnapPointsNearby = { _pos = getPosATL _object; - _findWhitelisted = []; _pointsNearby = []; - _findWhitelisted = nearestObjects [_pos,_whitelist,(_radius + DZE_snapExtraRange)]-[_object]; + _findWhitelisted = []; _pointsNearby = []; _waterBase = 0; + _onWater = surfaceIsWater position player; + if (_onWater) then { _waterBase = (getPosATL player select 2);}; + _findWhitelisted = nearestObjects [_pos,_whitelist,(_radius + DZE_snapExtraRange + _waterBase)]-[_object]; snapGizmosNearby = []; { _nearbyObject = _x; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index c345e790b..b383c0b53 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -551,6 +551,9 @@ if (isNil "DZE_modularBuild") then { if (isNil "DZE_snapExtraRange") then { DZE_snapExtraRange = 0; }; +if (isNil "DZE_checkNearbyRadius") then { + DZE_checkNearbyRadius = 30; +}; // needed on server if(isNil "DZE_PlotPole") then {