mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-17 17:20:26 +03:00
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:
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user