From 2441ef493e1b19200b8c848a9da1cf2b34128411 Mon Sep 17 00:00:00 2001 From: Whigital Date: Mon, 8 Nov 2021 00:15:52 +0100 Subject: [PATCH] Medical Engine - Fix unconscious animation state checks (#8623) --- .../medical_engine/CfgExtendedAnimation.hpp | 8 +-- addons/medical_engine/CfgMoves.hpp | 69 +++++++++++-------- addons/medical_engine/XEH_preInit.sqf | 10 +-- .../functions/fnc_setUnconsciousAnim.sqf | 2 +- addons/medical_engine/script_component.hpp | 3 + 5 files changed, 53 insertions(+), 39 deletions(-) diff --git a/addons/medical_engine/CfgExtendedAnimation.hpp b/addons/medical_engine/CfgExtendedAnimation.hpp index 596418bb7b..03fde9fee4 100644 --- a/addons/medical_engine/CfgExtendedAnimation.hpp +++ b/addons/medical_engine/CfgExtendedAnimation.hpp @@ -1,9 +1,9 @@ class CfgExtendedAnimation { class Revive { - left = QGVAR(faceLeft_unconscious); - right = QGVAR(faceRight_unconscious); - front = QGVAR(faceDown_unconscious); - back = QGVAR(faceUp_unconscious); + left = QUNCON_ANIM(faceLeft); + right = QUNCON_ANIM(faceRight); + front = QUNCON_ANIM(faceDown); + back = QUNCON_ANIM(faceUp); }; }; diff --git a/addons/medical_engine/CfgMoves.hpp b/addons/medical_engine/CfgMoves.hpp index 0bf6ac4b56..7c99321887 100644 --- a/addons/medical_engine/CfgMoves.hpp +++ b/addons/medical_engine/CfgMoves.hpp @@ -8,75 +8,86 @@ class CfgMovesMaleSdr: CfgMovesBasic { weaponIK = 0; }; - class Unconscious; class DeadState; - class ace_unconscious_1: DeadState { + class UNCON_ANIM(1): DeadState { file = QPATHTO_T(data\ace_unconscious_1.rtm); }; - class ace_unconscious_2: ace_unconscious_1 { + + class UNCON_ANIM(2): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_2.rtm); }; - class ace_unconscious_3: ace_unconscious_1 { + + class UNCON_ANIM(3): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_3.rtm); }; - class ace_unconscious_4: ace_unconscious_1 { + + class UNCON_ANIM(4): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_4.rtm); }; - class ace_unconscious_5: ace_unconscious_1 { + + class UNCON_ANIM(5): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_5.rtm); }; - class ace_unconscious_6: ace_unconscious_1 { + + class UNCON_ANIM(6): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_6.rtm); }; - class ace_unconscious_7: ace_unconscious_1 { + + class UNCON_ANIM(7): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_7.rtm); }; - class ace_unconscious_8: ace_unconscious_1 { + + class UNCON_ANIM(8): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_8.rtm); }; - class ace_unconscious_1_1: ace_unconscious_1 { + + class UNCON_ANIM(1_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_1_1.rtm); }; - class ace_unconscious_2_1: ace_unconscious_1 { + + class UNCON_ANIM(2_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_2_1.rtm); }; - class ace_unconscious_3_1: ace_unconscious_1 { + + class UNCON_ANIM(3_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_3_1.rtm); }; - class ace_unconscious_4_1: ace_unconscious_1 { + + class UNCON_ANIM(4_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_4_1.rtm); }; - class ace_unconscious_5_1: ace_unconscious_1 { + + class UNCON_ANIM(5_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_5_1.rtm); }; - class ace_unconscious_6_1: ace_unconscious_1 { + + class UNCON_ANIM(6_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_6_1.rtm); }; - class ace_unconscious_7_1: ace_unconscious_1 { + + class UNCON_ANIM(7_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_7_1.rtm); }; - class ace_unconscious_8_1: ace_unconscious_1 { + + class UNCON_ANIM(8_1): UNCON_ANIM(1) { file = QPATHTO_T(data\ace_unconscious_8_1.rtm); }; + /* added for the "ace_unc" part */ class KIA_passenger_boat_holdleft; - class ace_unconscious_9: KIA_passenger_boat_holdleft { - }; + class UNCON_ANIM(9): KIA_passenger_boat_holdleft {}; + class KIA_driver_boat01; - class ace_unconscious_10: KIA_driver_boat01 { - }; + class UNCON_ANIM(10): KIA_driver_boat01 {}; - class GVAR(faceDown_unconscious): Unconscious { - }; + class Unconscious; + class UNCON_ANIM(faceDown): Unconscious {}; - class GVAR(faceLeft_unconscious): Unconscious { - }; + class UNCON_ANIM(faceLeft): Unconscious {}; - class GVAR(faceRight_unconscious): Unconscious { - }; + class UNCON_ANIM(faceRight): Unconscious {}; - class GVAR(faceUp_unconscious): Unconscious { - }; + class UNCON_ANIM(faceUp): Unconscious {}; class AmovPpneMstpSnonWnonDnon; class ACE_UnconsciousOutProne: AmovPpneMstpSnonWnonDnon { diff --git a/addons/medical_engine/XEH_preInit.sqf b/addons/medical_engine/XEH_preInit.sqf index 71c7a86595..7f9e8b9cdd 100644 --- a/addons/medical_engine/XEH_preInit.sqf +++ b/addons/medical_engine/XEH_preInit.sqf @@ -39,10 +39,10 @@ GVAR(armorCache) = false call CBA_fnc_createNamespace; GVAR(fixedStatics) = []; GVAR(animations) = [] call CBA_fnc_createNamespace; -GVAR(animations) setVariable [QGVAR(faceUp_unconscious), ["ace_unconscious_2","ace_unconscious_2_1","ace_unconscious_7_1","ace_unconscious_8_1","ace_unconscious_5_1","ace_unconscious_6_1"]]; -GVAR(animations) setVariable [QGVAR(faceDown_unconscious), ["ace_unconscious_1", "ace_unconscious_3", "ace_unconscious_4","unconscious","ace_unconscious_9","ace_unconscious_3_1","ace_unconscious_4_1"]]; -GVAR(animations) setVariable [QGVAR(faceLeft_unconscious), ["ace_unconscious_7","ace_unconscious_8","ace_unconscious_1_1","ace_unconscious_7_1","ace_unconscious_8_1"]]; -GVAR(animations) setVariable [QGVAR(faceRight_unconscious), ["ace_unconscious_5","ace_unconscious_6","ace_unconscious_10","ace_unconscious_5_1","ace_unconscious_6_1"]]; +GVAR(animations) setVariable [QUNCON_ANIM(faceUp), [QUNCON_ANIM(2),QUNCON_ANIM(2_1),QUNCON_ANIM(7_1),QUNCON_ANIM(8_1),QUNCON_ANIM(5_1),QUNCON_ANIM(6_1)]]; +GVAR(animations) setVariable [QUNCON_ANIM(faceDown), [QUNCON_ANIM(1),QUNCON_ANIM(3),QUNCON_ANIM(4),"unconscious",QUNCON_ANIM(9),QUNCON_ANIM(3_1),QUNCON_ANIM(4_1)]]; +GVAR(animations) setVariable [QUNCON_ANIM(faceLeft), [QUNCON_ANIM(7),QUNCON_ANIM(8),QUNCON_ANIM(1_1),QUNCON_ANIM(7_1),QUNCON_ANIM(8_1)]]; +GVAR(animations) setVariable [QUNCON_ANIM(faceRight), [QUNCON_ANIM(5),QUNCON_ANIM(6),QUNCON_ANIM(10),QUNCON_ANIM(5_1),QUNCON_ANIM(6_1)]]; private _fnc_fixStatic = { params ["_vehicle"]; @@ -69,7 +69,7 @@ addMissionEventHandler ["Loaded", { // Use object reference to indicate the waitUnit is already running (this prevents issues with respawning units keeping SetVars) if ((_unit getVariable [QGVAR(waitForAnim), objNull]) == _unit) exitWith {}; _unit setVariable [QGVAR(waitForAnim), _unit]; - [{(animationState _this) find QGVAR(face) != -1}, { + [{(animationState _this) find QUNCON_ANIM(face) != -1}, { [_this, animationState _this] call FUNC(applyAnimAfterRagdoll); }, _unit, 20] call CBA_fnc_waitUntilAndExecute; } else { diff --git a/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf b/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf index f71c550add..89de38dbea 100644 --- a/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf +++ b/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf @@ -59,7 +59,7 @@ if (_isUnconscious) then { if (!alive _unit) exitWith {}; // Fix unit being in locked animation with switchMove (If unit was unloaded from a vehicle, they may be in deadstate instead of unconscious) private _animation = animationState _unit; - if ((_animation == "unconscious" || {_animation == "deadstate" || {_animation find "ace_unconscious_" != -1}}) && {lifeState _unit != "INCAPACITATED"}) then { + if ((_animation == "unconscious" || {_animation == "deadstate" || {_animation find QGVAR(uncon_anim) != -1}}) && {lifeState _unit != "INCAPACITATED"}) then { [_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); TRACE_1("forcing SwitchMove",animationState _unit); }; diff --git a/addons/medical_engine/script_component.hpp b/addons/medical_engine/script_component.hpp index e5e03e6d1f..2571883838 100644 --- a/addons/medical_engine/script_component.hpp +++ b/addons/medical_engine/script_component.hpp @@ -36,3 +36,6 @@ // don't change, these reflect hard coded engine behaviour #define DAMAGED_MIN_THRESHOLD 0.45 #define LIMPING_MIN_DAMAGE 0.5 + +#define UNCON_ANIM(var1) DOUBLES(GVAR(uncon_anim),var1) +#define QUNCON_ANIM(var1) QUOTE(UNCON_ANIM(var1))