Skip to content

Commit

Permalink
Advanced Fatigue - Minor cleanup (#10442)
Browse files Browse the repository at this point in the history
* Minor cleanup

* Update fnc_getMetabolicCosts.sqf

* Update fnc_getMetabolicCosts.sqf

* update header example

---------

Co-authored-by: PabstMirror <[email protected]>
  • Loading branch information
johnb432 and PabstMirror authored Oct 21, 2024
1 parent de975d4 commit 5afc1d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
24 changes: 17 additions & 7 deletions addons/advanced_fatigue/functions/fnc_getMetabolicCosts.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@
* Calculation is done according to the Pandolf/Wojtowicz formulas.
*
* Arguments:
* 0: Duty of animation
* 1: Mass of unit <NUMBER>
* 2: Terrain gradient <NUMBER>
* 3: Terrain factor <NUMBER>
* 4: Speed <NUMBER>
* 0: Mass of unit <NUMBER>
* 1: Terrain gradient <NUMBER>
* 2: Terrain factor <NUMBER>
* 3: Speed <NUMBER>
*
* Return Value:
* Metabolic cost <NUMBER>
*
* Example:
* [1, 840, 20, 1, 4] call ace_advanced_fatigue_fnc_getMetabolicCosts
* [840, 20, 1, 4] call ace_advanced_fatigue_fnc_getMetabolicCosts
*
* Public: No
*/

params ["_duty", "_gearMass", "_terrainGradient", "_terrainFactor", "_speed"];
params ["_gearMass", "_terrainGradient", "_terrainFactor", "_speed"];

// Get the current duty
private _duty = GVAR(animDuty);

{
_duty = if (_x isEqualType 0) then {
_duty * _x
} else {
_duty * (ACE_player call _x)
};
} forEach (values GVAR(dutyList));

// Metabolic cost for walking and running is different
if (_speed > 2) then {
Expand Down
13 changes: 1 addition & 12 deletions addons/advanced_fatigue/functions/fnc_mainLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ if (GVAR(isProne)) then {
_currentSpeed = _currentSpeed min 1.5;
};

// Get the current duty
private _duty = GVAR(animDuty);

{
if (_x isEqualType 0) then {
_duty = _duty * _x;
} else {
_duty = _duty * (ACE_player call _x);
};
} forEach (values GVAR(dutyList));

private _terrainGradient = abs _fwdAngle;
private _terrainFactor = 1;
private _gearMass = 0 max (((ACE_player getVariable [QEGVAR(movement,totalLoad), loadAbs ACE_player]) / 22.046 - UNDERWEAR_WEIGHT) * GVAR(loadFactor));
Expand All @@ -79,7 +68,7 @@ if (isNull objectParent ACE_player && {_currentSpeed > 0.1} && {isTouchingGround
};

// Add a scaling factor of 0.1 to reduce excessive stamina consumption on default settings (see #10361)
_currentWork = [_duty, _gearMass, _terrainGradient * GVAR(terrainGradientFactor) * 0.1, _terrainFactor, _currentSpeed] call FUNC(getMetabolicCosts);
_currentWork = [_gearMass, _terrainGradient * GVAR(terrainGradientFactor) * 0.1, _terrainFactor, _currentSpeed] call FUNC(getMetabolicCosts);
_currentWork = _currentWork max REE;
};

Expand Down

0 comments on commit 5afc1d9

Please sign in to comment.