mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-04 07:12:55 +03:00
Update snapping to fix certain reported bugs
Made by @Victor-the-Cleaner and thanks to @DeandlDernai for reporting
This commit is contained in:
@@ -580,14 +580,13 @@ if (_canBuild) then {
|
|||||||
|
|
||||||
local _detach = {
|
local _detach = {
|
||||||
detach _objectHelper; // release object
|
detach _objectHelper; // release object
|
||||||
|
|
||||||
DZE_memDir = getDir _objectHelper; // get current Z rotation
|
DZE_memDir = getDir _objectHelper; // get current Z rotation
|
||||||
|
|
||||||
if (DZE_memLeftRight == 0) then { // if object is not banked (left/right)
|
if (DZE_memLeftRight == 0) then { // if object is not banked (left/right)
|
||||||
|
|
||||||
local _absMem = abs DZE_memForBack;
|
local _absMem = abs DZE_memForBack;
|
||||||
|
|
||||||
if ((_absMem >= 90) && (_absMem < 270)) then { // but is pitched upside down (forward/back)
|
if (_absMem >= 90 && {_absMem < 270}) then { // but is pitched upside down (forward/back)
|
||||||
DZE_memDir = DZE_memDir + 180; // prevent flipping around X axis
|
DZE_memDir = DZE_memDir + 180; // prevent flipping around X axis
|
||||||
};
|
};
|
||||||
} else { // if object is banked (left/right)
|
} else { // if object is banked (left/right)
|
||||||
@@ -616,9 +615,9 @@ if (_canBuild) then {
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
local _update = {
|
local _update = {
|
||||||
DZE_memForBack = DZE_memForBack % 360; // clamp rotation angles
|
DZE_memForBack = (DZE_memForBack + 360) % 360; // clamp rotation angles
|
||||||
DZE_memLeftRight = DZE_memLeftRight % 360;
|
DZE_memLeftRight = (DZE_memLeftRight + 360) % 360;
|
||||||
DZE_memDir = DZE_memDir % 360;
|
DZE_memDir = (DZE_memDir + 360) % 360;
|
||||||
|
|
||||||
[_objectHelper, [DZE_memForBack, DZE_memLeftRight, DZE_memDir]] call fnc_SetPitchBankYaw;
|
[_objectHelper, [DZE_memForBack, DZE_memLeftRight, DZE_memDir]] call fnc_SetPitchBankYaw;
|
||||||
|
|
||||||
@@ -985,7 +984,7 @@ if (_canBuild) then {
|
|||||||
local _bz = abs (_b0 select 2) + abs (_b1 select 2);
|
local _bz = abs (_b0 select 2) + abs (_b1 select 2);
|
||||||
local _diag = sqrt (_bx^2 + _by^2 + _bz^2); // get diagonal of boundingBox
|
local _diag = sqrt (_bx^2 + _by^2 + _bz^2); // get diagonal of boundingBox
|
||||||
|
|
||||||
DZE_snapRadius = _diag * 0.5 + 9; // 9 is half the largest bounding box diagonal (rounded up) of the largest snappable objects in the game; currently the Land_WarfareBarrier10xTall_DZ and the MetalContainer2D_DZ.
|
DZE_snapRadius = ceil ((_diag * 0.5) + (DZE_maxSnapObjectDiag * 0.5)); // snap radius is the sum of half the bounding box diagonals of both the current object and the largest object in the game; currently the Land_WarfareBarrier10xTall_DZ
|
||||||
_refreshDist = DZE_snapRadius * 0.5; // distance object moves before the snap auto-refresh triggers
|
_refreshDist = DZE_snapRadius * 0.5; // distance object moves before the snap auto-refresh triggers
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1595,7 +1594,6 @@ if (_canBuild) then {
|
|||||||
_builtObject spawn player_fireMonitor;
|
_builtObject spawn player_fireMonitor;
|
||||||
} else {
|
} else {
|
||||||
_builtObject setVariable ["ownerPUID", dayz_playerUID, true];
|
_builtObject setVariable ["ownerPUID", dayz_playerUID, true];
|
||||||
|
|
||||||
if (_isPole) then {
|
if (_isPole) then {
|
||||||
|
|
||||||
_friendsArr = [[dayz_playerUID, toArray (name player)]];
|
_friendsArr = [[dayz_playerUID, toArray (name player)]];
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fnc_snapActionCleanup = {
|
|||||||
player removeAction s_player_toggleSnapSelect;
|
player removeAction s_player_toggleSnapSelect;
|
||||||
s_player_toggleSnapSelect = -1;
|
s_player_toggleSnapSelect = -1;
|
||||||
|
|
||||||
{player removeAction _x;} count s_player_toggleSnapSelectPoint;
|
{player removeAction _x;} forEach s_player_toggleSnapSelectPoint;
|
||||||
s_player_toggleSnapSelectPoint = [];
|
s_player_toggleSnapSelectPoint = [];
|
||||||
snapActions = -1;
|
snapActions = -1;
|
||||||
|
|
||||||
@@ -71,40 +71,44 @@ fnc_initSnapPoints = {
|
|||||||
_x resize 3; // remove text element
|
_x resize 3; // remove text element
|
||||||
_objectSnapGizmo attachTo [_object, _x];
|
_objectSnapGizmo attachTo [_object, _x];
|
||||||
snapGizmos set [count snapGizmos, _objectSnapGizmo];
|
snapGizmos set [count snapGizmos, _objectSnapGizmo];
|
||||||
} count _points;
|
} forEach _points;
|
||||||
};
|
};
|
||||||
|
|
||||||
fnc_initSnapPointsNearby = {
|
fnc_initSnapPointsNearby = {
|
||||||
local _object = _this select 0;
|
local _object = _this select 0;
|
||||||
local _findObjects = nearestObjects [_object, [], DZE_snapRadius] - [_object];
|
local _findObjects = nearestObjects [_object, [], DZE_snapRadius] - [_object];
|
||||||
|
|
||||||
{deleteVehicle _x;} count snapGizmosNearby; // clean up previous radius
|
{deleteVehicle _x;} forEach snapGizmosNearby; // clean up previous radius
|
||||||
snapGizmosNearby = [];
|
snapGizmosNearby = [];
|
||||||
{
|
{
|
||||||
local _nearbyObject = _x;
|
local _nearbyObject = _x;
|
||||||
local _typeOf = typeOf _x;
|
local _typeOf = typeOf _nearbyObject;
|
||||||
|
|
||||||
local _pointsNearby = getArray (configFile >> "SnapBuilding" >> _typeOf >> "points");
|
local _pointsNearby = getArray (configFile >> "SnapBuilding" >> _typeOf >> "points");
|
||||||
local _displayName = getText (configFile >> "CfgVehicles" >> _typeOf >> "displayName");
|
local _displayName = getText (configFile >> "CfgVehicles" >> _typeOf >> "displayName");
|
||||||
{
|
|
||||||
local _objectSnapGizmo = DZE_SNAP_HELPER_CLASS createVehicleLocal [0,0,0];
|
|
||||||
_objectSnapGizmo setObjectTexture DZE_SNAP_POINT_RESET; // green
|
|
||||||
_objectSnapGizmo setDir (_nearbyObject getVariable["memDir",0]);
|
|
||||||
_objectSnapGizmo setVariable ["snappoint", [_displayName, _x select 3], false]; // store object and snapping point display names
|
|
||||||
|
|
||||||
_x resize 3; // remove text element
|
if (count _pointsNearby > 0) then {
|
||||||
_objectSnapGizmo attachTo [_nearbyObject, _x];
|
local _memDir = _nearbyObject getVariable ["memDir",0];
|
||||||
|
{
|
||||||
|
local _objectSnapGizmo = DZE_SNAP_HELPER_CLASS createVehicleLocal [0,0,0];
|
||||||
|
_objectSnapGizmo setObjectTexture DZE_SNAP_POINT_RESET; // green
|
||||||
|
_objectSnapGizmo setPosATL (getPosATL _nearbyObject);
|
||||||
|
_objectSnapGizmo setVariable ["snappoint", [_displayName, _x select 3, _memDir], false]; // store object display name, snapping point text, and direction
|
||||||
|
|
||||||
snapGizmosNearby set [count snapGizmosNearby, _objectSnapGizmo]; // rebuild helper list
|
_x resize 3; // remove text element
|
||||||
} count _pointsNearby;
|
_objectSnapGizmo attachTo [_nearbyObject, _x];
|
||||||
|
|
||||||
|
snapGizmosNearby set [count snapGizmosNearby, _objectSnapGizmo]; // rebuild helper list
|
||||||
|
} forEach _pointsNearby;
|
||||||
|
};
|
||||||
} forEach _findObjects;
|
} forEach _findObjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
fnc_initSnapPointsCleanup = {
|
fnc_initSnapPointsCleanup = {
|
||||||
{deleteVehicle _x;} count snapGizmos;
|
{deleteVehicle _x;} forEach snapGizmos;
|
||||||
snapGizmos = [];
|
snapGizmos = [];
|
||||||
|
|
||||||
{deleteVehicle _x;} count snapGizmosNearby;
|
{deleteVehicle _x;} forEach snapGizmosNearby;
|
||||||
snapGizmosNearby = [];
|
snapGizmosNearby = [];
|
||||||
|
|
||||||
snapActionState = localize "STR_EPOCH_ACTION_SNAP_OFF";
|
snapActionState = localize "STR_EPOCH_ACTION_SNAP_OFF";
|
||||||
@@ -123,7 +127,7 @@ fnc_snapDistanceCheck = {
|
|||||||
_snapObject = {
|
_snapObject = {
|
||||||
_objectHelper setPosASL (getPosASL _closestNearCurr); // snap object
|
_objectHelper setPosASL (getPosASL _closestNearCurr); // snap object
|
||||||
|
|
||||||
DZE_memDir = getDir _closestNearCurr;
|
DZE_memDir = (_closestNearCurr getVariable ["snappoint", ["","",0]]) select 2;
|
||||||
[_objectHelper, [DZE_memForBack, DZE_memLeftRight, DZE_memDir]] call fnc_SetPitchBankYaw;
|
[_objectHelper, [DZE_memForBack, DZE_memLeftRight, DZE_memDir]] call fnc_SetPitchBankYaw;
|
||||||
|
|
||||||
waitUntil {uiSleep 0.1; !helperDetach};
|
waitUntil {uiSleep 0.1; !helperDetach};
|
||||||
@@ -227,7 +231,7 @@ fnc_snapDistanceCheck = {
|
|||||||
_closestHeldCurr = _x; // update current
|
_closestHeldCurr = _x; // update current
|
||||||
_closestNearCurr = _nearCurr; // paired points
|
_closestNearCurr = _nearCurr; // paired points
|
||||||
};
|
};
|
||||||
} count snapGizmos;
|
} forEach snapGizmos;
|
||||||
} forEach snapGizmosNearby;
|
} forEach snapGizmosNearby;
|
||||||
|
|
||||||
if ((isNull _closestHeldCurr) || {_closestHeldCurr != _closestHeldPrev}) then {
|
if ((isNull _closestHeldCurr) || {_closestHeldCurr != _closestHeldPrev}) then {
|
||||||
|
|||||||
@@ -321,12 +321,13 @@ if (!isDedicated) then {
|
|||||||
DZE_WaterSources = ["Land_pumpa","Land_Barrel_water","Land_Misc_Well_C_EP1","Land_Misc_Well_L_EP1","land_smd_water_pump","Watertank_DZE","Watertower_DZE","Land_water_tank","MAP_water_tank"];
|
DZE_WaterSources = ["Land_pumpa","Land_Barrel_water","Land_Misc_Well_C_EP1","Land_Misc_Well_L_EP1","land_smd_water_pump","Watertank_DZE","Watertower_DZE","Land_water_tank","MAP_water_tank"];
|
||||||
|
|
||||||
// Helper Colors Require Reformatting
|
// Helper Colors Require Reformatting
|
||||||
|
DZE_maxSnapObjectDiag = 18; // Internal diagonal distance of the largest buildable & snappable object in the game, currently the Land_WarfareBarrier10xTall_DZ. DO NOT MODIFY THIS!
|
||||||
DZE_helperSize = [[3,"Sign_sphere100cm_EP1"],[2,"Sign_sphere25cm_EP1"],[1,"Sign_sphere10cm_EP1"]]; // array of helper sizes and corresponding class. Keep in reverse order for optimized lookup
|
DZE_helperSize = [[3,"Sign_sphere100cm_EP1"],[2,"Sign_sphere25cm_EP1"],[1,"Sign_sphere10cm_EP1"]]; // array of helper sizes and corresponding class. Keep in reverse order for optimized lookup
|
||||||
DZE_helperSizeDefault = 3; // default to large sphere
|
DZE_helperSizeDefault = 3; // default to large sphere
|
||||||
DZE_NoRefundTransparency = 0.5; // Red Basebuilding Helper Transparency. min = 0.1, max = 1
|
DZE_NoRefundTransparency = 0.5; // Red Basebuilding Helper Transparency. min = 0.1, max = 1
|
||||||
DZE_removeTransparency = 0.5; // Green Basebuilding Helper Transparency. min = 0.1, max = 1
|
DZE_removeTransparency = 0.5; // Green Basebuilding Helper Transparency. min = 0.1, max = 1
|
||||||
DZE_deconstructTransparency = 0.5; // Blue Basebuilding Helper Transparency. min = 0.1, max = 1
|
DZE_deconstructTransparency = 0.5; // Blue Basebuilding Helper Transparency. min = 0.1, max = 1
|
||||||
DZE_largeObjects = ["MetalContainer2D_DZ","MetalContainer1G_DZ","MetalContainer1B_DZ","MetalContainer1A_DZ","DragonTeeth_DZ","DragonTeethBig_DZ","MetalFloor4x_DZ","Land_metal_floor_2x2_wreck","WoodFloor4x_DZ","Land_wood_floor_2x2_wreck","Scaffolding_DZ","CinderGateFrame_DZ","CinderGate_DZ","CinderGateLocked_DZ","WoodGateFrame_DZ","Land_DZE_WoodGate","Land_DZE_WoodGateLocked","WoodRamp_DZ","Metal_Drawbridge_DZ","Metal_DrawbridgeLocked_DZ","Land_WarfareBarrier10x_DZ","Land_WarfareBarrier10xTall_DZ","SandNestLarge_DZ"]; // adjust _allowedDistance in fn_selfActions.sqf for large modular/crafted objects
|
DZE_largeObjects = ["Watertower_DZE","DeerStand_DZ","MetalContainer2D_DZ","MetalContainer1G_DZ","MetalContainer1B_DZ","MetalContainer1A_DZ","DragonTeeth_DZ","DragonTeethBig_DZ","MetalFloor4x_DZ","Land_metal_floor_2x2_wreck","WoodFloor4x_DZ","Land_wood_floor_2x2_wreck","Scaffolding_DZ","CinderGateFrame_DZ","CinderGate_DZ","CinderGateLocked_DZ","WoodGateFrame_DZ","Land_DZE_WoodGate","Land_DZE_WoodGateLocked","WoodRamp_DZ","Metal_Drawbridge_DZ","Metal_DrawbridgeLocked_DZ","Land_WarfareBarrier10x_DZ","Land_WarfareBarrier10xTall_DZ","SandNestLarge_DZ"]; // adjust _allowedDistance in fn_selfActions.sqf for large modular/crafted objects
|
||||||
|
|
||||||
DZE_NoRefundTexture = [0, format["#(argb,8,8,3)color(1.00,0.00,0.00,%1,ca)", (DZE_NoRefundTransparency max 0.1)] ]; // red
|
DZE_NoRefundTexture = [0, format["#(argb,8,8,3)color(1.00,0.00,0.00,%1,ca)", (DZE_NoRefundTransparency max 0.1)] ]; // red
|
||||||
DZE_removeTexture = [0, format["#(argb,8,8,3)color(0.15,1.00,0.40,%1,ca)", (DZE_removeTransparency max 0.1)] ]; // green
|
DZE_removeTexture = [0, format["#(argb,8,8,3)color(0.15,1.00,0.40,%1,ca)", (DZE_removeTransparency max 0.1)] ]; // green
|
||||||
|
|||||||
Reference in New Issue
Block a user