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.
*/
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_52" call dayz_rollingMessages;};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// DayZ Base Building Maintenance
// Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
//
// 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;
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;
s_player_maint_build = 1;
// get cursortarget from addaction
_obj = _this select 3;
local _obj = _this select 3;
// Find objectID
_objectID = _obj getVariable ["ObjectID","0"];
local _objectID = _obj getVariable ["ObjectID","0"];
local _objectUID = _obj getVariable ["ObjectUID","0"];
// Find objectUID
_objectUID = _obj getVariable ["ObjectUID","0"];
if (_objectID == "0" && _objectUID == "0") exitWith {dayz_actionInProgress = false; s_player_maint_build = -1; localize "str_epoch_player_50" call dayz_rollingMessages;};
// 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]];
if (_objectID == "0" && _objectUID == "0") exitWith {
dayz_actionInProgress = false;
s_player_maint_build = -1;
localize "str_epoch_player_50" call dayz_rollingMessages; // Not setup yet.
};
_missingQty = 0;
_missing = "";
local _classname = typeOf _obj;
// 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;
_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 _itemIn = _x select 0;
local _countIn = _x select 1;
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;
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 {};
["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
_temp_removed_array = [];
_removed_total = 0;
_tobe_removed_total = 0;
local _temp_removed_array = [];
local _removed_total = 0;
local _tobe_removed_total = 0;
{
_removed = 0;
_itemIn = _x select 0;
_countIn = _x select 1;
local _removed = 0;
local _itemIn = _x select 0;
local _countIn = _x select 1;
// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
_tobe_removed_total = _tobe_removed_total + _countIn;
{
if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
_num_removed = ([player,_x] call BIS_fnc_invRemove);
_removed = _removed + _num_removed;
_removed_total = _removed_total + _num_removed;
if(_num_removed >= 1) then {
_temp_removed_array set [count _temp_removed_array,_x];
if (_removed < _countIn && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
local _num_removed = ([player, _x] call BIS_fnc_invRemove);
_removed = _removed + _num_removed;
_removed_total = _removed_total + _num_removed;
if (_num_removed > 0) then {
_temp_removed_array set [count _temp_removed_array, _x];
};
};
} forEach magazines player;
} forEach _requirements;
// all parts removed proceed
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";
} else {
{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 {
_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
format[localize "STR_EPOCH_ACTIONS_6",_missingQty, _textMissing] call dayz_rollingMessages;
local _textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
format[localize "STR_EPOCH_ACTIONS_6", _missingQty, _textMissing] call dayz_rollingMessages; // Missing %1 more of %2
};
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"];
_density = 3; // density of markers per ring
_model = "Sign_sphere100cm_EP1"; // marker model to use on rings
// Possible ones to use :: Sign_sphere10cm_EP1 Sign_sphere25cm_EP1 Sign_sphere100cm_EP1
_thePlot = (([player] call FNC_getPos) nearEntities ["Plastic_Pole_EP1_DZ",15]) select 0;
_center = getPosASL _thePlot;
_radius = DZE_PlotPole select 0;
_obj = false;
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Display Plot Boundary Helpers
//
// Author: Victor the Cleaner
// Date: August 2021
//
// - Plot helpers are now displayed in red if they are above DZE_BuildHeightLimit.
// Enabled with DZE_HeightLimitColor. Default: true
// - If the plot pole is on sloping terrain, the red helpers follow the ATL height.
// - 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 (((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;
};
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
_obj setPosASL [_center select 0, _center select 1, _center select 2];
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"];
_axis = _obj;
_obj setVectorUp [0, 0, 0];
PP_Marks set [count PP_Marks, _obj];
_angle = 0;
for "_idx" from 0 to _count do {
_a = (_center select 0) + (sin(_angle)*_radius);
_b = (_center select 1) + (cos(_angle)*_radius);
_obj = _model createVehicleLocal [0,0,0];
_obj setPosASL [_a, _b, _center select 2];
_obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"];
_obj attachTo [_axis];
PP_Marks set [count PP_Marks, _obj];
_a = (_center select 0) + (sin(_angle)*_radius);
_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);
if ((isNil "PP_Marks") && !_toggle) then {
local _radius = DZE_PlotPole select 0; // plot radius
local _density = 3; // helper density per ring
local _count = round((2 * pi * _radius) / _density); // initial count per ring
local _segments = _count - (_count % 8); // adjust count for improved symmetry
local _hemi = _segments / 2; // ignore helpers that coincide with equatorial ring
local _quad = _segments / 4; // ignore helpers that coincide with polar/equatorial rings
local _delta = 360 / _segments; // amount of angular change
local _angle = 0; // initialize
local _sin45 = sin 45; // setup polar diagonals
local _color = [DZE_plotGreen, DZE_plotGreen]; // [<= height limit, > height limit];
local _col = []; // color index
if (DZE_BuildHeightLimit > 0 && DZE_HeightLimitColor) then {
_color set [1, DZE_plotRed]; // red color if too high
};
_angle = (360/_count);
for "_idx" from 0 to (_count - 2) do {
_a = (_center select 1) + (sin(_angle)*_radius);
_b = (_center select 2) + (cos(_angle)*_radius);
_obj = _model createVehicleLocal [0,0,0];
_obj setPosASL [_center select 0, _a, _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);
_axis setDir 45;
for "_idx" from 0 to (_count - 2) do {
_a = (_center select 0) + (sin(_angle)*_radius);
_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];
_a = (_center select 1) + (sin(_angle)*_radius);
_b = (_center select 2) + (cos(_angle)*_radius);
_obj = _model createVehicleLocal [0,0,0];
_obj setPosASL [_center select 0, _a, _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);
local _obj = "Sign_sphere25cm_EP1" createVehicleLocal [0,0,0];
_obj setObjectTexture DZE_plotGreen; // add color
_obj setPos ([_plot] call FNC_getPos); // move
PP_Marks = []; // global array to record plot pole helpers
PP_Marks set [0, _obj]; // record parent object
///////////////////////////////////////////////////////////////////////////////////////////
//
// calculate ring vectors
//
///////////////////////////////////////////////////////////////////////////////////////////
for "_i" from 0 to (_segments -1) do { // loop through each point on the ring
local _a = (sin _angle) * _radius; // increasing offset
local _b = (cos _angle) * _radius; // decreasing offset
local _v = [[_a, _b, 0]]; // equatorial ring
if ((_i + _quad) % _hemi != 0) then { // ignore equator
_v = _v + [[_a, 0, _b]]; // longitudinal Y ring
if (_i % _hemi != 0) then { // longitudinal X ring + polar diagonals. ignore equator and poles
local _d = _sin45 * _a; // polar diagonals +/-45°
_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
};
};