From f8461d247e924872df588d5ca5f99a895db5b6e1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Wed, 26 Jul 2017 21:38:33 -0500 Subject: [PATCH] Fix snapping with Vector Tilt I feel crazy after this one. --- .../compile/building/EPOCH_staticMove.sqf | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf b/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf index ebbf61c7..55648219 100644 --- a/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf +++ b/Sources/epoch_code/compile/building/EPOCH_staticMove.sqf @@ -215,6 +215,10 @@ if (_class != "") then { { _nearestObject = _x; _isSnap = false; + + // Vector + Snapping + _snapMemoryPoint = ""; + _snapPosition = [0, 0, 0]; if (!isNull _nearestObject) then { _snapConfig = _cfgBaseBuilding >> (typeOf _nearestObject); @@ -237,6 +241,9 @@ if (_class != "") then { _isSnap = true; _snapPosition = _snapPos; _snapType = _type; + + // Vector + Snapping + _snapMemoryPoint = _x; }; }; } forEach _snapPoints; @@ -256,15 +263,7 @@ if (_class != "") then { _direction = 0; }; if (EPOCH_snapDirection > 0) then { - if (EPOCH_snapDirection == 1) then { - _direction = _direction + 90; - }; - if (EPOCH_snapDirection == 2) then { - _direction = _direction + 180; - }; - if (EPOCH_snapDirection == 3) then { - _direction = _direction + 270; - }; + _direction = _direction + (EPOCH_snapDirection * 90); }; if (_direction > 360) then { _direction = _direction - ((floor (_direction/360))*360); @@ -275,7 +274,12 @@ if (_class != "") then { { detach _x; } forEach attachedObjects player; - _dir2 = [vectorDir _nearestObject, _direction] call BIS_fnc_returnVector; + + // Vector + Snapping + _vectorDir = vectorDir _nearestObject; + _vectorUp = vectorup _nearestObject; + + _dir2 = [_vectorDir, _direction] call BIS_fnc_returnVector; if (_pos2 select 2 > _maxHeight) then { _pos2 set[2, _maxHeight]; }; @@ -284,6 +288,22 @@ if (_class != "") then { }; _currentTarget setVectorDirAndUp[_dir2, (vectorUp _nearestObject)]; _currentTarget setposATL _snapPosition; + + // Vector + Snapping + if(!(_vectorUp select 0 == 0) || !(_vectorUp select 1 == 0) || !( _vectorUp select 2 == 1)) then{ + if(_snapType isEqualTo "perp")then{ + if(_snapMemoryPoint in ["W","E"])then{ + _nearestObject setDir ((getDir _nearestObject) + (EPOCH_snapDirection * 90)); + }; + }; + _newDir = vectorDir _nearestObject; + _nearestObject setVectorDirAndUp [_vectorDir,_vectorUp]; + _vectorDir = _newDir; + _currentTarget setposATL _snapPosition; + _currentTarget setDir ((getDir _currentTarget) + (EPOCH_snapDirection * 90)); + _currentTarget setVectorDirAndUp [_vectorDir,_vectorUP]; + }; + _snapped = true; _arr_snapPoints = []; EPOCH_arr_snapPoints = [];