-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: ulteq <ulteq@web.de> Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
- Loading branch information
1 parent
cd66f49
commit f86e882
Showing
11 changed files
with
290 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ PREP(handleStaminaBar); | |
PREP(mainLoop); | ||
PREP(moduleSettings); | ||
PREP(removeDutyFactor); | ||
PREP(renderDebugLines); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 49 additions & 29 deletions
78
addons/advanced_fatigue/functions/fnc_getMetabolicCosts.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,74 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: BaerMitUmlaut | ||
* Calculates the current metabolic costs for a unit. | ||
* Author: BaerMitUmlaut, ulteq | ||
* Calculates the current metabolic costs. | ||
* Calculation is done according to the Pandolf/Wojtowicz formulas. | ||
* | ||
* Arguments: | ||
* 0: Unit <OBJECT> | ||
* 1: Speed <NUMBER> | ||
* 0: Duty of animation | ||
* 1: Mass of unit <NUMBER> | ||
* 2: Terrain gradient <NUMBER> | ||
* 3: Terrain factor <NUMBER> | ||
* 4: Speed <NUMBER> | ||
* | ||
* Return Value: | ||
* Metabolic cost <NUMBER> | ||
* | ||
* Example: | ||
* [player, 3.3] call ace_advanced_fatigue_fnc_getMetabolicCosts | ||
* [1, 840, 20, 1, 4] call ace_advanced_fatigue_fnc_getMetabolicCosts | ||
* | ||
* Public: No | ||
*/ | ||
params ["_unit", "_velocity"]; | ||
|
||
private _gearMass = ((_unit getVariable [QEGVAR(movement,totalLoad), loadAbs _unit]) / 22.046) * GVAR(loadFactor); | ||
|
||
private _terrainAngle = asin (1 - ((surfaceNormal getPosASL _unit) select 2)); | ||
private _terrainGradient = (_terrainAngle / 45 min 1) * 5 * GVAR(terrainGradientFactor); | ||
private _duty = GVAR(animDuty); | ||
|
||
{ | ||
if (_x isEqualType 0) then { | ||
_duty = _duty * _x; | ||
} else { | ||
_duty = _duty * (_unit call _x); | ||
}; | ||
} forEach (values GVAR(dutyList)); | ||
|
||
if (GVAR(isSwimming)) then { | ||
_terrainGradient = 0; | ||
}; | ||
params ["_duty", "_gearMass", "_terrainGradient", "_terrainFactor", "_speed"]; | ||
|
||
// Metabolic cost for walking and running is different | ||
if (_velocity > 2) then { | ||
if (_speed > 2) then { | ||
// Running | ||
#ifdef DEBUG_MODE_FULL | ||
private _baseline = 2.1 * SIM_BODYMASS + 4 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2) + (SIM_BODYMASS + _gearMass) * 0.9 * (_speed ^ 2); | ||
private _graded = 2.1 * SIM_BODYMASS + 4 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2) + _terrainFactor * (SIM_BODYMASS + _gearMass) * (0.9 * (_speed ^ 2) + 0.66 * _speed * _terrainGradient); | ||
private _terrainImpact = abs ((_graded / _baseline) - 1); | ||
hintSilent format ["FwdAngle: %1 | SideAngle: %2 \n TerrainFactor: %3 | TerrainGradient: %4 \n TerrainImpact: %5 \n Speed: %6 | CarriedLoad: %7 \n Duty: %8 | Work: %9", | ||
_fwdAngle toFixed 1, | ||
_sideAngle toFixed 1, | ||
_terrainFactor toFixed 2, | ||
_terrainGradient toFixed 1, | ||
_terrainImpact toFixed 2, | ||
_speed toFixed 2, | ||
_gearMass toFixed 1, | ||
_duty toFixed 2, | ||
round (_graded * BIOMECH_EFFICIENCY * _duty) | ||
]; | ||
#endif | ||
|
||
( | ||
2.10 * SIM_BODYMASS | ||
2.1 * SIM_BODYMASS | ||
+ 4 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2) | ||
+ (SIM_BODYMASS + _gearMass) * (0.9 * (_velocity ^ 2) + 0.66 * _velocity * _terrainGradient) | ||
) * 0.23 * _duty | ||
+ _terrainFactor * (SIM_BODYMASS + _gearMass) * (0.9 * (_speed ^ 2) + 0.66 * _speed * _terrainGradient) | ||
) * BIOMECH_EFFICIENCY * _duty | ||
} else { | ||
// Walking | ||
#ifdef DEBUG_MODE_FULL | ||
private _baseline = 1.05 * SIM_BODYMASS + 2 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2) + (SIM_BODYMASS + _gearMass) * 1.15 * (_speed ^ 2); | ||
private _graded = 1.05 * SIM_BODYMASS + 2 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2) + _terrainFactor * (SIM_BODYMASS + _gearMass) * (1.15 * (_speed ^ 2) + 0.66 * _speed * _terrainGradient); | ||
private _terrainImpact = abs ((_graded / _baseline) - 1); | ||
hintSilent format ["FwdAngle: %1 | SideAngle: %2 \n TerrainFactor: %3 | TerrainGradient: %4 \n TerrainImpact: %5 \n Speed: %6 | CarriedLoad: %7 \n Duty: %8 | Work: %9", | ||
_fwdAngle toFixed 1, | ||
_sideAngle toFixed 1, | ||
_terrainFactor toFixed 2, | ||
_terrainGradient toFixed 1, | ||
_terrainImpact toFixed 2, | ||
_speed toFixed 2, | ||
_gearMass toFixed 1, | ||
_duty toFixed 2, | ||
round (_graded * BIOMECH_EFFICIENCY * _duty) | ||
]; | ||
#endif | ||
|
||
( | ||
1.05 * SIM_BODYMASS | ||
+ 2 * (SIM_BODYMASS + _gearMass) * ((_gearMass / SIM_BODYMASS) ^ 2) | ||
+ (SIM_BODYMASS + _gearMass) * (1.15 * (_velocity ^ 2) + 0.66 * _velocity * _terrainGradient) | ||
) * 0.23 * _duty | ||
+ _terrainFactor * (SIM_BODYMASS + _gearMass) * (1.15 * (_speed ^ 2) + 0.66 * _speed * _terrainGradient) | ||
) * BIOMECH_EFFICIENCY * _duty | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.