diff --git a/addons/advanced_fatigue/XEH_PREP.hpp b/addons/advanced_fatigue/XEH_PREP.hpp index 1ec7705695..c6250516f5 100644 --- a/addons/advanced_fatigue/XEH_PREP.hpp +++ b/addons/advanced_fatigue/XEH_PREP.hpp @@ -5,6 +5,6 @@ PREP(getMetabolicCosts); PREP(handleEffects); PREP(handlePlayerChanged); PREP(handleStaminaBar); +PREP(mainLoop); PREP(moduleSettings); -PREP(pfhMain); PREP(removeDutyFactor); diff --git a/addons/advanced_fatigue/XEH_postInit.sqf b/addons/advanced_fatigue/XEH_postInit.sqf index ba733b33e1..d566e3b042 100644 --- a/addons/advanced_fatigue/XEH_postInit.sqf +++ b/addons/advanced_fatigue/XEH_postInit.sqf @@ -37,8 +37,8 @@ if (!hasInterface) exitWith {}; }] call FUNC(addDutyFactor); }; - // - Add main PFH ------------------------------------------------------------- - [FUNC(pfhMain), 1, []] call CBA_fnc_addPerFrameHandler; + // - Add main loop at 1 second interval ------------------------------------------------------------- + [FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute; }] call CBA_fnc_addEventHandler; ["ace_settingChanged", { diff --git a/addons/advanced_fatigue/functions/fnc_pfhMain.sqf b/addons/advanced_fatigue/functions/fnc_mainLoop.sqf similarity index 91% rename from addons/advanced_fatigue/functions/fnc_pfhMain.sqf rename to addons/advanced_fatigue/functions/fnc_mainLoop.sqf index 9e7ad381d6..6430643cac 100644 --- a/addons/advanced_fatigue/functions/fnc_pfhMain.sqf +++ b/addons/advanced_fatigue/functions/fnc_mainLoop.sqf @@ -1,6 +1,6 @@ /* * Author: BaerMitUmlaut - * Main perFrameHandler that updates fatigue values. + * Main looping function that updates fatigue values. * * Arguments: * None @@ -9,7 +9,9 @@ * None */ #include "script_component.hpp" -if (!alive ACE_player) exitWith {}; // Dead people don't breath, Will also handle null (Map intros) +if (!alive ACE_player) exitWith { // Dead people don't breath, Will also handle null (Map intros) + [FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute; +}; private _currentWork = REE; private _currentSpeed = (vectorMagnitude (velocity ACE_player)) min 6; @@ -61,3 +63,5 @@ private _perceivedFatigue = 1 - (_anReservePercentage min _aeReservePercentage); if (GVAR(enableStaminaBar)) then { [GVAR(anReserve) / AN_MAXRESERVE] call FUNC(handleStaminaBar); }; + +[FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute;