Files
DayZ-Epoch/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf
A Man bb968698e6 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
2021-09-19 18:41:52 +02:00

106 lines
4.1 KiB
Plaintext

///////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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 _plot) < 10) then {_toggle = true}; // if helpers exist
{deleteVehicle _x;} count PP_Marks; // remove helpers
PP_Marks = nil;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// initialize
//
///////////////////////////////////////////////////////////////////////////////////////////////////
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
};
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
};
};