Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a factor to scale fatigue up and downhill #4492

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions addons/advanced_fatigue/functions/fnc_getMetabolicCosts.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_velocity"];
params ["_unit", "_speed"];

private _virtualLoad = 0;
{
Expand All @@ -32,6 +32,14 @@ private _gearMass = ((loadAbs _unit + _virtualLoad) * 0.1 / 2.2046) * GVAR(loadF
private _terrainFactor = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_terrainFactor -> dead code?

private _terrainAngle = asin (1 - ((surfaceNormal getPosASL _unit) select 2));
private _terrainGradient = (_terrainAngle / 45 min 1) * 5 * GVAR(terrainGradientFactor);
private _terrainAltitude = getPosASL _unit;
private _terrainAltitudeDelta = getTerrainHeightASL _terrainAltitude - getTerrainHeightASL (_terrainAltitude vectorDiff vectorNormalized velocity _unit);
private _terrainAltitudeFactor = 2 * abs _terrainAltitudeDelta min 1;

if (_terrainAltitudeDelta < -0.1) then {
_terrainAltitudeFactor = _terrainAltitudeFactor / 4;
};

private _duty = GVAR(animDuty);

{
Expand All @@ -46,16 +54,16 @@ if (GVAR(isSwimming)) then {
_terrainGradient = 0;
};

if (_velocity > 2) then {
if (_speed > 2) then {
(
2.10 * SIM_BODYMASS
+ 4 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2)
+ _terrainFactor * (SIM_BODYMASS + _gearMass) * (0.90 * (_velocity ^ 2) + 0.66 * _velocity * _terrainGradient)
+ _terrainFactor * (SIM_BODYMASS + _gearMass) * (0.90 * (_speed ^ 2) + 0.66 * _speed * _terrainGradient * _terrainAltitudeFactor)
) * 0.23 * _duty
} else {
(
1.05 * SIM_BODYMASS
+ 4 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2)
+ _terrainFactor * (SIM_BODYMASS + _gearMass) * (1.15 * (_velocity ^ 2) + 0.66 * _velocity * _terrainGradient)
+ _terrainFactor * (SIM_BODYMASS + _gearMass) * (1.15 * (_speed ^ 2) + 0.66 * _speed * _terrainGradient * _terrainAltitudeFactor)
) * 0.23 * _duty
};