diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf index 93c9877ad7..76d56f4b1c 100644 --- a/addons/medical_treatment/functions/fnc_treatment.sqf +++ b/addons/medical_treatment/functions/fnc_treatment.sqf @@ -95,6 +95,21 @@ if (binocular _medic != "" && {binocular _medic == currentWeapon _medic}) then { // Play treatment animation for medic and determine the ending animation if (vehicle _medic == _medic && {_medicAnim != ""}) then { + // Speed up animation based on treatment time (but cap max to prevent odd animiations/cam shake) + private _animRatio = (_animDuration / _treatmentTime) min 3; + TRACE_3("setAnimSpeedCoef",_animRatio,_animDuration,_treatmentTime); + + // Don't slow down animation too much to prevent it looking funny. + if (_animRatio < ANIMATION_SPEED_MIN_COEFFICIENT) then { + _animRatio = ANIMATION_SPEED_MIN_COEFFICIENT; + }; + + // Skip animation enitrely if progress bar too quick. + if (_animRatio > ANIMATION_SPEED_MAX_COEFFICIENT) exitWith {}; + + [QEGVAR(common,setAnimSpeedCoef), [_medic, _animRatio]] call CBA_fnc_globalEvent; + + // Play animation private _endInAnim = "AmovP[pos]MstpS[stn]W[wpn]Dnon"; private _pos = ["knl", "pne"] select (stance _medic == "PRONE"); @@ -112,11 +127,6 @@ if (vehicle _medic == _medic && {_medicAnim != ""}) then { [_medic, _endInAnim] call EFUNC(common,doAnimation); _medic setVariable [QGVAR(endInAnim), _endInAnim]; - // Speed up animation based on treatment time (but cap max to prevent odd animiations/cam shake) - private _animRatio = (_animDuration / _treatmentTime) min 3; - TRACE_3("setAnimSpeedCoef",_animRatio,_animDuration,_treatmentTime); - [QEGVAR(common,setAnimSpeedCoef), [_medic, _animRatio]] call CBA_fnc_globalEvent; - if (!isNil QEGVAR(advanced_fatigue,setAnimExclusions)) then { EGVAR(advanced_fatigue,setAnimExclusions) pushBack QUOTE(ADDON); }; diff --git a/addons/medical_treatment/script_component.hpp b/addons/medical_treatment/script_component.hpp index bed5241f85..c25b39e98d 100644 --- a/addons/medical_treatment/script_component.hpp +++ b/addons/medical_treatment/script_component.hpp @@ -48,3 +48,9 @@ #define LITTER_CLEANUP_CHECK_DELAY 30 #define BODY_CLEANUP_CHECK_DELAY 20 + +// Animations that would be played slower than this are instead played exactly as slow as this. (= Progress bar will take longer than the slowed down animation). +#define ANIMATION_SPEED_MIN_COEFFICIENT 0.5 + +// Animations that would be played faster than this are instead skipped. (= Progress bar too quick for animation). +#define ANIMATION_SPEED_MAX_COEFFICIENT 3