From a09ca8fb80876456c761862bdf4e28fdeec8ee4d Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 17 Sep 2015 12:23:56 +0200 Subject: [PATCH] tweak doAnimation switchMove to do no akward camera jumps whenever possible, fix #2474 --- addons/common/functions/fnc_doAnimation.sqf | 17 +++++++++++++++-- .../medical/functions/fnc_treatment_failure.sqf | 1 + .../medical/functions/fnc_treatment_success.sqf | 5 +++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/addons/common/functions/fnc_doAnimation.sqf b/addons/common/functions/fnc_doAnimation.sqf index 81301ce1dc..5b7a1ed1bf 100644 --- a/addons/common/functions/fnc_doAnimation.sqf +++ b/addons/common/functions/fnc_doAnimation.sqf @@ -44,6 +44,8 @@ if (_animation == "") then { _animation = [_unit] call FUNC(getDefaultAnim); }; +//if (_animation == animationState _unit) exitWith {}; + switch (_priority) do { case 0 : { if (_unit == vehicle _unit) then { @@ -62,8 +64,19 @@ switch (_priority) do { }; }; case 2 : { - // Execute on all machines. SwitchMove has local effects. - [_unit, format ["{_this switchMove '%1'}", _animation]] call FUNC(execRemoteFnc); + // try playMoveNow first + if (_unit == vehicle _unit) then { + [_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc); + } else { + // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles. + [_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc); + }; + + // if animation doesn't respond, do switchMove + if (animationState _unit != _animation) then { + // Execute on all machines. SwitchMove has local effects. + [_unit, format ["{_this switchMove '%1'}", _animation]] call FUNC(execRemoteFnc); + }; }; default {}; }; diff --git a/addons/medical/functions/fnc_treatment_failure.sqf b/addons/medical/functions/fnc_treatment_failure.sqf index e943485e0e..4aac0eda6a 100644 --- a/addons/medical/functions/fnc_treatment_failure.sqf +++ b/addons/medical/functions/fnc_treatment_failure.sqf @@ -35,6 +35,7 @@ if (vehicle _caller == _caller) then { case "ainvppnemstpslaywpstdnon_medic": {_lastAnim = "AinvPpneMstpSlayWpstDnon"}; case "ainvpknlmstpslaywpstdnon_medic": {_lastAnim = "AmovPknlMstpSrasWpstDnon"}; }; + [_caller, _lastAnim, 2] call EFUNC(common,doAnimation); }; _caller setvariable [QGVAR(treatmentPrevAnimCaller), nil]; diff --git a/addons/medical/functions/fnc_treatment_success.sqf b/addons/medical/functions/fnc_treatment_success.sqf index bf183e24db..c2347c59ee 100644 --- a/addons/medical/functions/fnc_treatment_success.sqf +++ b/addons/medical/functions/fnc_treatment_success.sqf @@ -19,7 +19,7 @@ private ["_config", "_callback", "_weaponSelect", "_lastAnim"]; params ["_args"]; -_args params ["_caller", "_target","_selectionName","_className", "_items", "_usersOfItems"]; +_args params ["_caller", "_target", "_selectionName", "_className", "_items", "_usersOfItems"]; if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then { _caller removeWeapon "ACE_FakePrimaryWeapon"; @@ -28,13 +28,14 @@ if (vehicle _caller == _caller) then { _lastAnim = _caller getvariable [QGVAR(treatmentPrevAnimCaller), ""]; //Don't play another medic animation (when player is rapidily treating) TRACE_2("Reseting to old animation", animationState player, _lastAnim); - switch (tolower _lastAnim) do { + switch (toLower _lastAnim) do { case "ainvpknlmstpslaywrfldnon_medic": {_lastAnim = "AmovPknlMstpSrasWrflDnon"}; case "ainvppnemstpslaywrfldnon_medic": {_lastAnim = "AmovPpneMstpSrasWrflDnon"}; case "ainvpknlmstpslaywnondnon_medic": {_lastAnim = "AmovPknlMstpSnonWnonDnon"}; case "ainvppnemstpslaywpstdnon_medic": {_lastAnim = "AinvPpneMstpSlayWpstDnon"}; case "ainvpknlmstpslaywpstdnon_medic": {_lastAnim = "AmovPknlMstpSrasWpstDnon"}; }; + [_caller, _lastAnim, 2] call EFUNC(common,doAnimation); }; _caller setvariable [QGVAR(treatmentPrevAnimCaller), nil];