Merge pull request #7549 from acemod/clamp-TreatmentAnimationSpeedModifiers

Medical Treatment - Prevent extremely slow or fast animations
This commit is contained in:
commy2 2020-02-23 16:10:56 +01:00 committed by GitHub
commit 2715ef954a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -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;
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);
};

View File

@ -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 2.5