From 69bf7468432e865744cd35b5892241266c70d6a7 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 5 Sep 2024 21:10:03 -0500 Subject: [PATCH 1/2] AF - Fix diving and terrain costs when not touching ground --- .../advanced_fatigue/functions/fnc_mainLoop.sqf | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/advanced_fatigue/functions/fnc_mainLoop.sqf b/addons/advanced_fatigue/functions/fnc_mainLoop.sqf index 16d355a424d..991e6870008 100644 --- a/addons/advanced_fatigue/functions/fnc_mainLoop.sqf +++ b/addons/advanced_fatigue/functions/fnc_mainLoop.sqf @@ -27,9 +27,18 @@ if (!alive ACE_player) exitWith { private _velocity = velocity ACE_player; private _normal = surfaceNormal (getPosWorld ACE_player); private _movementVector = vectorNormalized _velocity; -private _sideVector = vectorNormalized (_movementVector vectorCrossProduct _normal); private _fwdAngle = asin (_movementVector select 2); -private _sideAngle = asin (_sideVector select 2); +private _sideAngle = if ((getPosATL ACE_player) select 2 > 0.02) then { + 0 // ignore terrain normal if not touching it +} else { + private _sideVector = vectorNormalized (_movementVector vectorCrossProduct _normal); + asin (_sideVector select 2); +}; +if (GVAR(isSwimming)) then { // ignore when floating + _fwdAngle = 0; + _sideAngle = 0; +}; + private _currentWork = REE; private _currentSpeed = (vectorMagnitude _velocity) min 6; @@ -62,7 +71,7 @@ if (isNull objectParent ACE_player && {_currentSpeed > 0.1} && {isTouchingGround }; // Used to simulate the unevenness/roughness of the terrain - if ((getPosATL ACE_player) select 2 < 0.01) then { + if (_sideAngle != 0) then { private _sideGradient = abs (_sideAngle / 45) min 1; _terrainFactor = 1 + _sideGradient ^ 4; From 94da64c7dbc7f5d9559ece9a4c38574d1e97fc7b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 11 Sep 2024 17:18:27 -0500 Subject: [PATCH 2/2] Update fnc_mainLoop.sqf --- addons/advanced_fatigue/functions/fnc_mainLoop.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advanced_fatigue/functions/fnc_mainLoop.sqf b/addons/advanced_fatigue/functions/fnc_mainLoop.sqf index 991e6870008..e6327a3fa56 100644 --- a/addons/advanced_fatigue/functions/fnc_mainLoop.sqf +++ b/addons/advanced_fatigue/functions/fnc_mainLoop.sqf @@ -28,7 +28,7 @@ private _velocity = velocity ACE_player; private _normal = surfaceNormal (getPosWorld ACE_player); private _movementVector = vectorNormalized _velocity; private _fwdAngle = asin (_movementVector select 2); -private _sideAngle = if ((getPosATL ACE_player) select 2 > 0.02) then { +private _sideAngle = if ((getPosATL ACE_player) select 2 > 0.01) then { 0 // ignore terrain normal if not touching it } else { private _sideVector = vectorNormalized (_movementVector vectorCrossProduct _normal);