Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treatment - cap max animation speed #6995

Merged
merged 4 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/advanced_fatigue/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ PREP_RECOMPILE_END;

GVAR(staminaBarWidth) = 10 * (((safezoneW / safezoneH) min 1.2) / 40);
GVAR(dutyList) = [[], []];
GVAR(setAnimExclusions) = [];

ADDON = true;
10 changes: 7 additions & 3 deletions addons/advanced_fatigue/functions/fnc_handleEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ if (GVAR(ppeBlackoutLast) == 1) then {

// - Physical effects ---------------------------------------------------------
if (GVAR(isSwimming)) exitWith {
_unit setAnimSpeedCoef linearConversion [0.7, 0.9, _fatigue, 1, 0.5, true];

if (GVAR(setAnimExclusions) isEqualTo []) then {
_unit setAnimSpeedCoef linearConversion [0.7, 0.9, _fatigue, 1, 0.5, true];
};
if ((isSprintAllowed _unit) && {_fatigue > 0.7}) then {
[_unit, "blockSprint", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
} else {
Expand All @@ -69,7 +70,10 @@ if (GVAR(isSwimming)) exitWith {
};
};
if ((getAnimSpeedCoef _unit) != 1) then {
_unit setAnimSpeedCoef 1;
if (GVAR(setAnimExclusions) isEqualTo []) then {
TRACE_1("reset",getAnimSpeedCoef _unit);
_unit setAnimSpeedCoef 1;
};
};

if (_overexhausted) then {
Expand Down
5 changes: 4 additions & 1 deletion addons/medical_treatment/functions/fnc_getBandageTime.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* Return Value:
* Time in seconds <NUMBER>
*
* Example:
* [player, cursorTarget, "Head", "FieldDressing"] call ace_medical_treatment_fnc_getBandageTime
*
* Public: No
*/

Expand Down Expand Up @@ -48,4 +51,4 @@ if (_medic == _patient) then {
};

// Nobody can bandage instantly
_bandageTime max 1
_bandageTime max 2
9 changes: 7 additions & 2 deletions addons/medical_treatment/functions/fnc_treatment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ if (vehicle _medic == _medic && {_medicAnim != ""}) then {
[_medic, _endInAnim] call EFUNC(common,doAnimation);
_medic setVariable [QGVAR(endInAnim), _endInAnim];

// Speed up animation based on treatment time
[QEGVAR(common,setAnimSpeedCoef), [_medic, _animDuration / _treatmentTime]] call CBA_fnc_globalEvent;
// 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);
};
};

// Play a random treatment sound globally if defined
Expand Down
3 changes: 3 additions & 0 deletions addons/medical_treatment/functions/fnc_treatmentFailure.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ if (!isNil "_endInAnim") then {

// Reset medic animation speed coefficient
[QEGVAR(common,setAnimSpeedCoef), [_medic, 1]] call CBA_fnc_globalEvent;
if (!isNil QEGVAR(advanced_fatigue,setAnimExclusions)) then {
EGVAR(advanced_fatigue,setAnimExclusions) deleteAt (EGVAR(advanced_fatigue,setAnimExclusions) find QUOTE(ADDON));
};

// Call treatment specific failure callback
GET_FUNCTION(_callbackFailure,configFile >> QGVAR(actions) >> _classname >> "callbackFailure");
Expand Down
3 changes: 3 additions & 0 deletions addons/medical_treatment/functions/fnc_treatmentSuccess.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ if (!isNil "_endInAnim") then {

// Reset medic animation speed coefficient
[QEGVAR(common,setAnimSpeedCoef), [_medic, 1]] call CBA_fnc_globalEvent;
if (!isNil QEGVAR(advanced_fatigue,setAnimExclusions)) then {
EGVAR(advanced_fatigue,setAnimExclusions) deleteAt (EGVAR(advanced_fatigue,setAnimExclusions) find QUOTE(ADDON));
};

// Call treatment specific success callback
GET_FUNCTION(_callbackSuccess,configFile >> QGVAR(actions) >> _classname >> "callbackSuccess");
Expand Down