Modulr build changes

- Players may no longer build objects outside the plot radius.
- This is calculated using the object's pivot point, not its geometry nor its bounding box.
- Players may move an object any distance or height within the plot boundary/sphere.
- Therefore, DZE_buildMaxMoveDistance and DZE_buildMaxHeightDistance are now obsolete.
- Players may move a small distance outside the plot radius, provided the object remains inside.	Enabled with DZE_PlotOzone.	Default: 10 meters.
- A line of helpers now appears through the plot's vertical axis to aid line-of-sight to the pole.	Enabled with DZE_AxialHelper.
- This may be useful for nearby plots that are grouped together, or where their radii overlap.
- Players may now cancel the build by fast movement, i.e. running, or fast walking on steep terrain.
- This only applies when the player is holding the object. They may press F to release it, then run without cancelling.
- Crouch-walking or slow-walking will not cancel the build.
- The player will auto-crouch when clicking "build" to prevent accidental cancelling.

Changes made by  @Victor-the-Cleaner
This commit is contained in:
A Man
2021-09-19 18:41:52 +02:00
parent 2a3b895647
commit bb968698e6
5 changed files with 1053 additions and 593 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +1,119 @@
/* ///////////////////////////////////////////////////////////////////////////////////////////////////
DayZ Base Building Maintenance //
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. // DayZ Base Building Maintenance
*/ // Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_52" call dayz_rollingMessages;}; //
// Upgraded by: Victor the Cleaner
// Date: August 2021
//
// - Now includes helper spheres for improved player experience
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_52" call dayz_rollingMessages;}; // Upgrade is already in progress.
dayz_actionInProgress = true; dayz_actionInProgress = true;
private ["_classname","_missing","_proceed","_num_removed","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_requirements","_obj","_upgrade","_finished"];
player removeAction s_player_maint_build; player removeAction s_player_maint_build;
s_player_maint_build = 1; s_player_maint_build = 1;
// get cursortarget from addaction local _obj = _this select 3;
_obj = _this select 3;
// Find objectID local _objectID = _obj getVariable ["ObjectID","0"];
_objectID = _obj getVariable ["ObjectID","0"]; local _objectUID = _obj getVariable ["ObjectUID","0"];
// Find objectUID if (_objectID == "0" && _objectUID == "0") exitWith {
_objectUID = _obj getVariable ["ObjectUID","0"]; dayz_actionInProgress = false;
s_player_maint_build = -1;
if (_objectID == "0" && _objectUID == "0") exitWith {dayz_actionInProgress = false; s_player_maint_build = -1; localize "str_epoch_player_50" call dayz_rollingMessages;}; localize "str_epoch_player_50" call dayz_rollingMessages; // Not setup yet.
// Get classname
_classname = typeOf _obj;
// Find next maintain
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "maintainBuilding");
if ((count _upgrade) > 0) then {
_requirements = _upgrade;
} else {
_requirements = [["PartGeneric",1]];
}; };
_missingQty = 0; local _classname = typeOf _obj;
_missing = "";
// Find next maintain
local _upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "maintainBuilding");
local _requirements = [];
if (count _upgrade > 0) then {
_requirements = _upgrade;
} else {
_requirements = [["PartGeneric", 1]];
};
local _missingQty = 0;
local _missing = "";
local _proceed = true;
_proceed = true;
{ {
_itemIn = _x select 0; local _itemIn = _x select 0;
_countIn = _x select 1; local _countIn = _x select 1;
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; }; local _qty = {(_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)} count magazines player;
if (_qty < _countIn) exitWith {
_missing = _itemIn;
_missingQty = _countIn - _qty;
_proceed = false;
};
} forEach _requirements; } forEach _requirements;
if (_proceed) then { if (_proceed) then {
[player,(getPosATL player),40,"repair"] spawn fnc_alertZombies;
_finished = ["Medic",1] call fn_loopAction; [_obj] call fn_displayHelpers; // create helpers
[player, (getPosATL player), 40, "repair"] spawn fnc_alertZombies; // make noise
local _finished = ["Medic", 1] call fn_loopAction; // animation
[] call fn_displayHelpers; // delete helpers
if (!_finished) exitWith {}; if (!_finished) exitWith {};
["Working",0,[20,40,15,0]] call dayz_NutritionSystem; ["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
_temp_removed_array = []; local _temp_removed_array = [];
_removed_total = 0; local _removed_total = 0;
_tobe_removed_total = 0; local _tobe_removed_total = 0;
{ {
_removed = 0; local _removed = 0;
_itemIn = _x select 0; local _itemIn = _x select 0;
_countIn = _x select 1; local _countIn = _x select 1;
// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn]; // diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
_tobe_removed_total = _tobe_removed_total + _countIn; _tobe_removed_total = _tobe_removed_total + _countIn;
{ {
if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then { if (_removed < _countIn && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
_num_removed = ([player,_x] call BIS_fnc_invRemove);
_removed = _removed + _num_removed; local _num_removed = ([player, _x] call BIS_fnc_invRemove);
_removed_total = _removed_total + _num_removed; _removed = _removed + _num_removed;
if(_num_removed >= 1) then { _removed_total = _removed_total + _num_removed;
_temp_removed_array set [count _temp_removed_array,_x];
if (_num_removed > 0) then {
_temp_removed_array set [count _temp_removed_array, _x];
}; };
}; };
} forEach magazines player; } forEach magazines player;
} forEach _requirements; } forEach _requirements;
// all parts removed proceed // all parts removed proceed
if (_tobe_removed_total == _removed_total) then { if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4",1] call dayz_rollingMessages;
PVDZE_maintainArea = [player,2,[_obj, _objectID, _objectUID]]; format[localize "STR_EPOCH_ACTIONS_4" ,1] call dayz_rollingMessages; // You have maintained %1 building parts.
PVDZE_maintainArea = [player, 2, [_obj, _objectID, _objectUID]];
publicVariableServer "PVDZE_maintainArea"; publicVariableServer "PVDZE_maintainArea";
} else { } else {
{player addMagazine _x;} count _temp_removed_array; {player addMagazine _x;} count _temp_removed_array;
format[localize "str_epoch_player_145",_removed_total,_tobe_removed_total] call dayz_rollingMessages; format[localize "str_epoch_player_145", _removed_total, _tobe_removed_total] call dayz_rollingMessages; // Missing Parts after first check Item: %1 / %2
}; };
} else { } else {
_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName"); local _textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
format[localize "STR_EPOCH_ACTIONS_6",_missingQty, _textMissing] call dayz_rollingMessages; format[localize "STR_EPOCH_ACTIONS_6", _missingQty, _textMissing] call dayz_rollingMessages; // Missing %1 more of %2
}; };
dayz_actionInProgress = false; dayz_actionInProgress = false;

View File

@@ -1,77 +1,105 @@
//Zero Remorse, big thanks to their scripter for this! ///////////////////////////////////////////////////////////////////////////////////////////////////
private ["_density","_model","_thePlot","_center","_radius","_angle","_count","_axis","_obj","_idx","_a","_b"]; //
// Display Plot Boundary Helpers
_density = 3; // density of markers per ring //
_model = "Sign_sphere100cm_EP1"; // marker model to use on rings // Author: Victor the Cleaner
// Possible ones to use :: Sign_sphere10cm_EP1 Sign_sphere25cm_EP1 Sign_sphere100cm_EP1 // Date: August 2021
//
_thePlot = (([player] call FNC_getPos) nearEntities ["Plastic_Pole_EP1_DZ",15]) select 0; // - Plot helpers are now displayed in red if they are above DZE_BuildHeightLimit.
_center = getPosASL _thePlot; // Enabled with DZE_HeightLimitColor. Default: true
_radius = DZE_PlotPole select 0; // - If the plot pole is on sloping terrain, the red helpers follow the ATL height.
_obj = false; // - Number of helpers per ring is now evenly divisible by 8 for improved symmetry.
// - Will ignore helpers that coincide with other rings.
// - Will only draw helpers above ground/sea level for improved performance.
// - Helpers now align to the pole direction.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
local _pos = [player] call FNC_getPos; // player position
local _plot = (_pos nearEntities ["Plastic_Pole_EP1_DZ", 15]) select 0; // get nearest plot
local _toggle = false; // turn plot boundary on/off
if (!isNil "PP_Marks") then { if (!isNil "PP_Marks") then {
if (((PP_Marks select 0) distance _thePlot) < 10) then { _obj = true; };
{ deleteVehicle _x; } count PP_Marks; if (((PP_Marks select 0) distance _plot) < 10) then {_toggle = true}; // if helpers exist
{deleteVehicle _x;} count PP_Marks; // remove helpers
PP_Marks = nil; PP_Marks = nil;
}; };
if ((isNil "PP_Marks") && (!_obj)) then { ///////////////////////////////////////////////////////////////////////////////////////////////////
PP_Marks = []; //
_count = round((2 * pi * _radius) / _density); // initialize
//
///////////////////////////////////////////////////////////////////////////////////////////////////
_obj = "Sign_sphere10cm_EP1" createVehicleLocal [0,0,0]; // PARENT marker on pole if ((isNil "PP_Marks") && !_toggle) then {
_obj setPosASL [_center select 0, _center select 1, _center select 2];
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; local _radius = DZE_PlotPole select 0; // plot radius
_axis = _obj; local _density = 3; // helper density per ring
_obj setVectorUp [0, 0, 0]; local _count = round((2 * pi * _radius) / _density); // initial count per ring
PP_Marks set [count PP_Marks, _obj]; local _segments = _count - (_count % 8); // adjust count for improved symmetry
_angle = 0; local _hemi = _segments / 2; // ignore helpers that coincide with equatorial ring
for "_idx" from 0 to _count do { local _quad = _segments / 4; // ignore helpers that coincide with polar/equatorial rings
_a = (_center select 0) + (sin(_angle)*_radius); local _delta = 360 / _segments; // amount of angular change
_b = (_center select 1) + (cos(_angle)*_radius); local _angle = 0; // initialize
_obj = _model createVehicleLocal [0,0,0]; local _sin45 = sin 45; // setup polar diagonals
_obj setPosASL [_a, _b, _center select 2]; local _color = [DZE_plotGreen, DZE_plotGreen]; // [<= height limit, > height limit];
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; local _col = []; // color index
_obj attachTo [_axis];
PP_Marks set [count PP_Marks, _obj]; if (DZE_BuildHeightLimit > 0 && DZE_HeightLimitColor) then {
_a = (_center select 0) + (sin(_angle)*_radius); _color set [1, DZE_plotRed]; // red color if too high
_b = (_center select 2) + (cos(_angle)*_radius);
_obj = _model createVehicleLocal [0,0,0];
_obj setPosASL [_a, _center select 1, _b];
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"];
_obj attachTo [_axis];
PP_Marks set [count PP_Marks, _obj];
_angle = _angle + (360/_count);
}; };
_angle = (360/_count);
for "_idx" from 0 to (_count - 2) do { local _obj = "Sign_sphere25cm_EP1" createVehicleLocal [0,0,0];
_a = (_center select 1) + (sin(_angle)*_radius); _obj setObjectTexture DZE_plotGreen; // add color
_b = (_center select 2) + (cos(_angle)*_radius); _obj setPos ([_plot] call FNC_getPos); // move
_obj = _model createVehicleLocal [0,0,0];
_obj setPosASL [_center select 0, _a, _b]; PP_Marks = []; // global array to record plot pole helpers
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; PP_Marks set [0, _obj]; // record parent object
_obj attachTo [_axis];
PP_Marks set [count PP_Marks, _obj]; ///////////////////////////////////////////////////////////////////////////////////////////
_angle = _angle + (360/_count); //
}; // calculate ring vectors
_angle = (360/_count); //
_axis setDir 45; ///////////////////////////////////////////////////////////////////////////////////////////
for "_idx" from 0 to (_count - 2) do {
_a = (_center select 0) + (sin(_angle)*_radius); for "_i" from 0 to (_segments -1) do { // loop through each point on the ring
_b = (_center select 2) + (cos(_angle)*_radius);
_obj = _model createVehicleLocal [0,0,0]; local _a = (sin _angle) * _radius; // increasing offset
_obj setPosASL [_a, _center select 1, _b]; local _b = (cos _angle) * _radius; // decreasing offset
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"];
_obj attachTo [_axis]; local _v = [[_a, _b, 0]]; // equatorial ring
PP_Marks set [count PP_Marks, _obj];
_a = (_center select 1) + (sin(_angle)*_radius); if ((_i + _quad) % _hemi != 0) then { // ignore equator
_b = (_center select 2) + (cos(_angle)*_radius);
_obj = _model createVehicleLocal [0,0,0]; _v = _v + [[_a, 0, _b]]; // longitudinal Y ring
_obj setPosASL [_center select 0, _a, _b];
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; if (_i % _hemi != 0) then { // longitudinal X ring + polar diagonals. ignore equator and poles
_obj attachTo [_axis]; local _d = _sin45 * _a; // polar diagonals +/-45°
PP_Marks set [count PP_Marks, _obj];
_angle = _angle + (360/_count); _v = _v + [[0, _a, _b], [_d, _d, _b], [-_d, _d, _b]];
};
};
///////////////////////////////////////////////////////////////////////////
//
// realign and draw each ring
//
///////////////////////////////////////////////////////////////////////////
{
local _vN = _plot modelToWorld _x; // realign
local _height = _vN select 2; // ATL Z
if (_height > -0.5) then { // if aboveground
_obj = "Sign_sphere100cm_EP1" createVehicleLocal [0,0,0]; // create
_col = _color select (_height > DZE_BuildHeightLimit); // if too high
_obj setObjectTexture _col; // change color
_obj setPosASL (ATLToASL _vN); // move
PP_Marks set [count PP_Marks, _obj]; // record object
};
} forEach _v;
_angle = _angle + _delta; // aggregate radial angle
}; };
}; };

View File

@@ -1,132 +1,245 @@
//Checks if item is near a plot, if the player is plot owner or friendly, if there are too many items, and if the player has required tools ///////////////////////////////////////////////////////////////////////////////////////////////////
private ["_isAdmin","_requireplot","_distance","_canBuild","_friendlies","_nearestPole","_ownerID","_pos","_item","_classname","_isPole","_isLandFireDZ","_IsNearPlot","_buildables","_center","_toolCheck","_plotcheck","_buildcheck","_isfriendly","_isowner","_require","_text","_near","_plotPoles"]; //
// Updated by: Victor the Cleaner
// Date: August 2021
//
// Performs 10 different build checks
//
// 1) You are not allowed to build here a "Trader" is nearby.
// 2) You cannot build a plot pole within "_distance" of an existing plot.
// 3) You can only own "DZE_limitPlots" plot pole(s)
// 4) This item needs a "Plot Pole" within "_distance" meters
// 5) You do not have access to build on this plot.
// 6) Building is restricted above "DZE_BuildHeightLimit" meter(s).
// 7) You cannot build. There are too many objects within "DZE_maintainRange" m.
// 8) You can't build a "displayName" within "_distance" meters of a safe zone.
// 9) You can't build a "displayName" within "DZE_NoBuildNearDistance" meters of a "class".
// 10) Tool Check (silent)
//
// Input values = [position, classname, toolcheck];
// Return values = [_canBuild, _isPole, _nearestPole]; // added _nearestPole
//
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Initialize
//
///////////////////////////////////////////////////////////////////////////////////////////////////
local _pos = _this select 0;
local _item = _this select 1;
local _toolCheck = _this select 2;
_pos = _this select 0; local _classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
_item = _this select 1; local _isPole = (_classname == "Plastic_Pole_EP1_DZ");
_toolCheck = _this select 2; local _isLandFireDZ = (_classname == "Land_Fire_DZ");
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); local _isAdmin = dayz_playerUID in DZE_PlotManagementAdmins;
_requireplot = DZE_requireplot; local _canBuild = false;
_isAdmin = dayz_playerUID in DZE_PlotManagementAdmins; local _plotPoles = 0;
// "Unable to build trader nearby." local _radius = DZE_PlotPole select 0;
if (!canbuild) exitWith {dayz_actionInProgress = false; format[localize "STR_EPOCH_PLAYER_136",localize "STR_EPOCH_TRADER"] call dayz_rollingMessages; [false, false];}; local _minDistance = DZE_PlotPole select 1;
local _requireplot = DZE_requireplot;
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then { if (isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot"); _requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
}; };
local _plotcheck = [player, _isPole] call FNC_find_plots;
local _distance = _plotcheck select 0;
local _isNearPlot = _plotcheck select 1;
local _nearestPole = _plotcheck select 2; // object or objNull
_checkClass = {
private ["_checkOK","_distance"];
_checkOK = false; ///////////////////////////////////////////////////////////////////////////////////////////////////
_distance = DZE_SafeZoneNoBuildDistance; //
// 1) You are not allowed to build here a "Trader" is nearby.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (!canbuild) exitWith {
dayz_actionInProgress = false;
format[localize "STR_EPOCH_PLAYER_136", localize "STR_EPOCH_TRADER"] call dayz_rollingMessages;
[_canBuild, _isPole, _nearestPole];
};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 2) You cannot build a plot pole within "_distance" of an existing plot.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (_isPole && _isNearPlot > 0) exitWith {
dayz_actionInProgress = false;
format[localize "str_epoch_player_44", _distance] call dayz_rollingMessages;
[_canBuild, _isPole, _nearestPole];
};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 3) You can only own "DZE_limitPlots" plot pole(s)
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (_isPole && !_isAdmin && DZE_limitPlots > 0) then {
{ {
if (typeName _x == "ARRAY") then { if (_x getVariable["ownerPUID","0"] == dayz_playerUID || (_x getVariable["CharacterID","0"] == dayz_characterID)) then {
if (_x select 0 == _classname) then {_checkOK = true; _distance = _x select 1;}; _plotPoles = _plotPoles + 1;
} else {
if (_x == _className) then {_checkOK = true};
}; };
if (_checkOK) exitWith {}; } count (entities "Plastic_Pole_EP1_DZ"); // all plot poles on the map owned by player
} count DZE_SafeZoneNoBuildItems; };
if ((DZE_limitPlots > 0) && (_plotPoles >= DZE_LimitPlots)) exitWith {
[_checkOK,_distance] dayz_actionInProgress = false;
format[localize "STR_EPOCH_PLAYER_133", DZE_limitPlots] call dayz_rollingMessages;
[_canBuild, _isPole, _nearestPole];
}; };
_isPole = (_classname == "Plastic_Pole_EP1_DZ");
_isLandFireDZ = (_classname == "Land_Fire_DZ");
_canBuild = false; ///////////////////////////////////////////////////////////////////////////////////////////////////
_plotPoles = 0; //
_nearestPole = objNull; // 4) This item needs a "Plot Pole" within "_distance" meters
_ownerID = 0; //
_friendlies = []; ///////////////////////////////////////////////////////////////////////////////////////////////////
if (_isNearPlot == 0) then {
if (_isPole) then { if (_requireplot == 0 || _isLandFireDZ) then {
_plotcheck = [player, true] call FNC_find_plots;
_distance = DZE_PlotPole select 1;
if (DZE_limitPlots > 0 && !_isAdmin) then {
{
if (_x getVariable["ownerPUID","0"] == dayz_playerUID || (_x getVariable["CharacterID","0"] == dayz_characterID)) then {
_plotPoles = _plotPoles +1;
};
} count (entities "Plastic_Pole_EP1_DZ");
};
} else {
_plotcheck = [player, false] call FNC_find_plots;
_distance = DZE_PlotPole select 0;
};
_IsNearPlot = _plotcheck select 1;
_nearestPole = _plotcheck select 2;
if (_isPole && {_IsNearPlot > 0}) exitWith {dayz_actionInProgress = false; format[localize "str_epoch_player_44",_distance] call dayz_rollingMessages; [_canBuild, _isPole];};
if (DZE_limitPlots > 0 && {_plotPoles >= DZE_LimitPlots}) exitWith {dayz_actionInProgress = false; format[localize "STR_EPOCH_PLAYER_133",DZE_limitPlots] call dayz_rollingMessages; [_canBuild, _isPole];};
if (_IsNearPlot == 0) then {
if (_requireplot == 0 || {_isLandFireDZ}) then {
_canBuild = true; _canBuild = true;
}; };
} else { };
_ownerID = _nearestPole getVariable["CharacterID","0"]; if (_isNearPlot == 0 && !_canBuild) exitWith {
dayz_actionInProgress = false;
format[localize "STR_EPOCH_PLAYER_135", localize "str_epoch_player_246", _distance] call dayz_rollingMessages;
[_canBuild, _isPole, _nearestPole];
};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 5) You do not have access to build on this plot.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (_isNearPlot > 0) then {
local _ownerID = _nearestPole getVariable["CharacterID","0"];
if (dayz_characterID == _ownerID) then { if (dayz_characterID == _ownerID) then {
_canBuild = true; _canBuild = true;
} else { } else {
if (DZE_permanentPlot) then { if (DZE_permanentPlot) then {
_buildcheck = [player, _nearestPole] call FNC_check_access; local _accessCheck = [player, _nearestPole] call FNC_check_access;
_isowner = _buildcheck select 0; local _isowner = _accessCheck select 0;
_isfriendly = ((_buildcheck select 1) or (_buildcheck select 3)); local _isfriendly = ((_accessCheck select 1) || (_accessCheck select 3));
if (_isowner || _isfriendly) then { if (_isowner || _isfriendly) then {
_canBuild = true; _canBuild = true;
}; };
} else { } else {
_friendlies = player getVariable ["friendlyTo",[]]; local _friendlies = player getVariable ["friendlyTo",[]];
if (_ownerID in _friendlies) then { if (_ownerID in _friendlies) then {
_canBuild = true; _canBuild = true;
}; };
}; };
}; };
}; };
if (_isNearPlot > 0 && !_canBuild) exitWith {
if (!_canBuild) exitWith {
dayz_actionInProgress = false; dayz_actionInProgress = false;
if (_isNearPlot == 0) then { localize "STR_EPOCH_PLAYER_134" call dayz_rollingMessages;
format[localize "STR_EPOCH_PLAYER_135",localize "str_epoch_player_246",_distance] call dayz_rollingMessages; [_canBuild, _isPole, _nearestPole];
} else {
localize "STR_EPOCH_PLAYER_134" call dayz_rollingMessages;
};
[_canBuild, _isPole];
}; };
if (DZE_BuildHeightLimit > 0 && {([player] call fnc_getPos) select 2 > DZE_BuildHeightLimit}) exitWith {dayz_actionInProgress = false; format[localize "STR_EPOCH_PLAYER_168",DZE_BuildHeightLimit] call dayz_rollingMessages; [false, _isPole];};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 6) Building is restricted above "DZE_BuildHeightLimit" meter(s).
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (DZE_BuildHeightLimit > 0 && ((_pos select 2) > DZE_BuildHeightLimit)) exitWith {
dayz_actionInProgress = false;
format[localize "STR_EPOCH_PLAYER_168", DZE_BuildHeightLimit] call dayz_rollingMessages;
[false, _isPole, _nearestPole];
};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 7) You cannot build. There are too many objects within "DZE_maintainRange" m.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
// Also count safes, lockboxes, vanilla buildables, tents and stashes against DZE_BuildingLimit // Also count safes, lockboxes, vanilla buildables, tents and stashes against DZE_BuildingLimit
_buildables = DZE_maintainClasses + DZE_LockableStorage + ["DZ_storage_base"]; local _buildables = DZE_maintainClasses + DZE_LockableStorage + ["DZ_storage_base"];
_center = if (isNull _nearestPole) then {_pos} else {_nearestPole}; local _center = if (isNull _nearestPole) then {
if ((count (nearestObjects [_center,_buildables,_distance])) >= DZE_BuildingLimit) exitWith {dayz_actionInProgress = false; format[localize "str_epoch_player_41",_distance] call dayz_rollingMessages; [false, _isPole];}; _pos; // player's position
} else {
_nearestPole;
};
if ((count (nearestObjects [_center, _buildables, DZE_maintainRange])) >= DZE_BuildingLimit) exitWith {
_text = getText (configFile >> 'CfgMagazines' >> _item >> 'displayName'); dayz_actionInProgress = false;
format[localize "str_epoch_player_41", floor DZE_maintainRange] call dayz_rollingMessages;
_buildCheck = call _checkClass; [false, _isPole, _nearestPole];
if (_buildCheck select 0 && !_isAdmin) then {
_canBuild = !([player,_buildCheck select 1] call DZE_SafeZonePosCheck);
}; };
if !(_canBuild) exitWith {dayz_actionInProgress = false; format [localize "STR_EPOCH_PLAYER_166",_text,_buildCheck select 1] call dayz_rollingMessages; [false, _isPole];};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 8) You can't build a "displayName" within "_distance" meters of a safe zone.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
local _text = getText (configFile >> "CfgMagazines" >> _item >> "displayName");
local _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;
if (_checkOK && !_isAdmin) then {
_canBuild = !([player, _distance] call DZE_SafeZonePosCheck);
};
if (!_canBuild) exitWith {
dayz_actionInProgress = false;
format [localize "STR_EPOCH_PLAYER_166", _text, _distance] call dayz_rollingMessages;
[_canBuild, _isPole, _nearestPole];
};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 9) You can't build a "displayName" within "DZE_NoBuildNearDistance" meters of a "class".
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (count DZE_NoBuildNear > 0 && !_isAdmin) then { if (count DZE_NoBuildNear > 0 && !_isAdmin) then {
_near = (nearestObjects [_pos,DZE_NoBuildNear,DZE_NoBuildNearDistance]); local _near = (nearestObjects [_pos, DZE_NoBuildNear, DZE_NoBuildNearDistance]);
if ((count _near) > 0) then { _canBuild = false; };
if ((count _near) > 0) then {
_canBuild = false;
};
};
if (!_canBuild) exitWith {
dayz_actionInProgress = false;
format [localize "STR_EPOCH_PLAYER_167", _text, DZE_NoBuildNearDistance, typeOf (_near select 0)] call dayz_rollingMessages;
[_canBuild, _isPole, _nearestPole];
}; };
if !(_canBuild) exitWith {dayz_actionInProgress = false; format [localize "STR_EPOCH_PLAYER_167",_text,DZE_NoBuildNearDistance,typeOf (_near select 0)] call dayz_rollingMessages; [false, _isPole];};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 10) Tool Check (silent)
//
///////////////////////////////////////////////////////////////////////////////////////////////////
if (_toolCheck) then { if (_toolCheck) then {
_require = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> "Build" >> "require"); local _require = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> "Build" >> "require");
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); _classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
_canBuild = [_item, _require, _classname] call dze_requiredItemsCheck; _canBuild = [_item, _require, _classname] call dze_requiredItemsCheck;
}; };
//When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if (!(_canBuild select 0)) exitWith{}; // When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if !(_canBuild select 0) exitWith{};
[_canBuild, _isPole]; [_canBuild, _isPole, _nearestPole];

View File

@@ -1,26 +1,28 @@
// Find Plots by RimBlock (http://epochmod.com/forum/index.php?/user/12612-rimblock/) ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Find Plots by RimBlock (http://epochmod.com/forum/index.php?/user/12612-rimblock/)
// Updated by: Victor the Cleaner
// Date: August 2021
//
///////////////////////////////////////////////////////////////////////////////////////////////////
private ["_player","_isPole","_IsNearPlot","_nearestPole","_distance","_findNearestPoles","_findNearestPole","_friendly","_return","_pos"]; local _player = _this select 0; // object
local _isPole = _this select 1; // bool
local _pos = [vehicle _player] call FNC_getPos;
local _radius = DZE_PlotPole select 0; // plot radius
local _minDistance = DZE_PlotPole select 1; // minimum distance between plot poles
local _nearestPole = objNull; // default
local _distance = _radius; // default
_player = _this select 0; if (_isPole) then {
_isPole = _this select 1; _distance = _minDistance;
_IsNearPlot = 0;
_nearestPole = "";
_findNearestPole = [];
if(_isPole) then {
_distance = DZE_PlotPole select 1;
}else{
_distance = DZE_PlotPole select 0;
}; };
_pos = [vehicle _player] call FNC_getPos;
// check for near plot // check for near plot
_findNearestPole = _pos nearEntities ["Plastic_Pole_EP1_DZ", _distance]; local _findNearestPole = _pos nearEntities ["Plastic_Pole_EP1_DZ", _distance];
_IsNearPlot = count (_findNearestPole); local _isNearPlot = count _findNearestPole;
if (_IsNearPlot > 0) then{_nearestPole = _findNearestPole select 0;}else{_nearestPole = objNull;};
_return = [_distance, _IsNearPlot, _nearestPole]; if (_isNearPlot > 0) then { // found one or more
_return _nearestPole = _findNearestPole select 0; // get first entry
};
[_distance, _isNearPlot, _nearestPole];