diff --git a/AUTHORS.txt b/AUTHORS.txt index 6756c0bec3..418140dda3 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -105,6 +105,7 @@ Karneck Kavinsky Keithen Kllrt +KokaKolaA3 legman Legolasindar "Viper" licht-im-Norden87 diff --git a/addons/medical_engine/CfgExtendedAnimation.hpp b/addons/medical_engine/CfgExtendedAnimation.hpp index 8f9525f0a5..596418bb7b 100644 --- a/addons/medical_engine/CfgExtendedAnimation.hpp +++ b/addons/medical_engine/CfgExtendedAnimation.hpp @@ -1,10 +1,9 @@ -// we want the face down animation every time class CfgExtendedAnimation { class Revive { - left = "Unconscious"; - right = "Unconscious"; - front = "Unconscious"; - back = "Unconscious"; + left = QGVAR(faceLeft_unconscious); + right = QGVAR(faceRight_unconscious); + front = QGVAR(faceDown_unconscious); + back = QGVAR(faceUp_unconscious); }; }; diff --git a/addons/medical_engine/CfgMoves.hpp b/addons/medical_engine/CfgMoves.hpp index d7d304c7f8..0bf6ac4b56 100644 --- a/addons/medical_engine/CfgMoves.hpp +++ b/addons/medical_engine/CfgMoves.hpp @@ -8,6 +8,76 @@ class CfgMovesMaleSdr: CfgMovesBasic { weaponIK = 0; }; + class Unconscious; + class DeadState; + class ace_unconscious_1: DeadState { + file = QPATHTO_T(data\ace_unconscious_1.rtm); + }; + class ace_unconscious_2: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_2.rtm); + }; + class ace_unconscious_3: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_3.rtm); + }; + class ace_unconscious_4: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_4.rtm); + }; + class ace_unconscious_5: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_5.rtm); + }; + class ace_unconscious_6: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_6.rtm); + }; + class ace_unconscious_7: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_7.rtm); + }; + class ace_unconscious_8: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_8.rtm); + }; + class ace_unconscious_1_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_1_1.rtm); + }; + class ace_unconscious_2_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_2_1.rtm); + }; + class ace_unconscious_3_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_3_1.rtm); + }; + class ace_unconscious_4_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_4_1.rtm); + }; + class ace_unconscious_5_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_5_1.rtm); + }; + class ace_unconscious_6_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_6_1.rtm); + }; + class ace_unconscious_7_1: ace_unconscious_1 { + file = QPATHTO_T(data\ace_unconscious_7_1.rtm); + }; + class ace_unconscious_8_1: ace_unconscious_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 KIA_driver_boat01; + class ace_unconscious_10: KIA_driver_boat01 { + }; + + class GVAR(faceDown_unconscious): Unconscious { + }; + + class GVAR(faceLeft_unconscious): Unconscious { + }; + + class GVAR(faceRight_unconscious): Unconscious { + }; + + class GVAR(faceUp_unconscious): Unconscious { + }; + class AmovPpneMstpSnonWnonDnon; class ACE_UnconsciousOutProne: AmovPpneMstpSnonWnonDnon { //file = "\A3\anims_f\Data\Anim\Sdr\dth\pne\stp\ras\Rfl\AdthPpneMstpSrasWrflDnon_1"; diff --git a/addons/medical_engine/XEH_PREP.hpp b/addons/medical_engine/XEH_PREP.hpp index a47b03447f..cb6874c5b6 100644 --- a/addons/medical_engine/XEH_PREP.hpp +++ b/addons/medical_engine/XEH_PREP.hpp @@ -6,3 +6,4 @@ PREP(setStructuralDamage); PREP(setUnconsciousAnim); PREP(getHitpointArmor); PREP(getItemArmor); +PREP(applyAnimAfterRagdoll); diff --git a/addons/medical_engine/XEH_postInit.sqf b/addons/medical_engine/XEH_postInit.sqf index 878ebb4441..0467202b88 100644 --- a/addons/medical_engine/XEH_postInit.sqf +++ b/addons/medical_engine/XEH_postInit.sqf @@ -66,7 +66,7 @@ // Fixes units being stuck in unconscious animation when being knocked over by a PhysX object ["CAManBase", "AnimDone", { params ["_unit", "_anim"]; - if (local _unit && {_anim == "unconscious" && {lifeState _unit != "INCAPACITATED"}}) then { + if (local _unit && {_anim find QGVAR(face) != -1 && {lifeState _unit != "INCAPACITATED"}}) then { [_unit, false] call FUNC(setUnconsciousAnim); }; }] call CBA_fnc_addClassEventHandler; diff --git a/addons/medical_engine/XEH_preInit.sqf b/addons/medical_engine/XEH_preInit.sqf index 033136a2a3..87a74dd7aa 100644 --- a/addons/medical_engine/XEH_preInit.sqf +++ b/addons/medical_engine/XEH_preInit.sqf @@ -36,6 +36,12 @@ GVAR(armorCache) = false call CBA_fnc_createNamespace; // with handle damage not returning full results. 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"]]; + private _fnc_fixStatic = { params ["_vehicle"]; private _type = typeOf _vehicle; @@ -55,4 +61,21 @@ addMissionEventHandler ["Loaded", { } forEach GVAR(fixedStatics); }]; +["ace_unconscious", { + params ["_unit", "_active"]; + if (_active) then { + if (_unit getVariable [QGVAR(waitForAnim), true]) then { + [{(animationState _this) find QGVAR(face) != -1}, { + [_this, animationState _this] call FUNC(applyAnimAfterRagdoll); + }, _unit, 20] call CBA_fnc_waitUntilAndExecute; + _unit setVariable [QGVAR(waitForAnim), false]; + }; + } else { + _unit setVariable [QGVAR(waitForAnim), nil]; + if (local _unit) then { + [_unit, _active] call FUNC(setUnconsciousAnim); + }; + }; +}] call CBA_fnc_addEventhandler; + ADDON = true; diff --git a/addons/medical_engine/data/ace_unconscious_1.rtm b/addons/medical_engine/data/ace_unconscious_1.rtm new file mode 100644 index 0000000000..8480d5381f Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_1_1.rtm b/addons/medical_engine/data/ace_unconscious_1_1.rtm new file mode 100644 index 0000000000..0dc232fad7 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_1_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_2.rtm b/addons/medical_engine/data/ace_unconscious_2.rtm new file mode 100644 index 0000000000..c6d539ce65 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_2.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_2_1.rtm b/addons/medical_engine/data/ace_unconscious_2_1.rtm new file mode 100644 index 0000000000..8f44925a2d Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_2_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_3.rtm b/addons/medical_engine/data/ace_unconscious_3.rtm new file mode 100644 index 0000000000..8eedf66e5f Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_3.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_3_1.rtm b/addons/medical_engine/data/ace_unconscious_3_1.rtm new file mode 100644 index 0000000000..110e048697 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_3_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_4.rtm b/addons/medical_engine/data/ace_unconscious_4.rtm new file mode 100644 index 0000000000..9f10d57b81 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_4.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_4_1.rtm b/addons/medical_engine/data/ace_unconscious_4_1.rtm new file mode 100644 index 0000000000..814049bfbc Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_4_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_5.rtm b/addons/medical_engine/data/ace_unconscious_5.rtm new file mode 100644 index 0000000000..08d5bd81df Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_5.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_5_1.rtm b/addons/medical_engine/data/ace_unconscious_5_1.rtm new file mode 100644 index 0000000000..ba46efca6a Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_5_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_6.rtm b/addons/medical_engine/data/ace_unconscious_6.rtm new file mode 100644 index 0000000000..6d967d036d Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_6.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_6_1.rtm b/addons/medical_engine/data/ace_unconscious_6_1.rtm new file mode 100644 index 0000000000..98cd1c3a49 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_6_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_7.rtm b/addons/medical_engine/data/ace_unconscious_7.rtm new file mode 100644 index 0000000000..b276105072 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_7.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_7_1.rtm b/addons/medical_engine/data/ace_unconscious_7_1.rtm new file mode 100644 index 0000000000..acd0020704 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_7_1.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_8.rtm b/addons/medical_engine/data/ace_unconscious_8.rtm new file mode 100644 index 0000000000..26602d26c8 Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_8.rtm differ diff --git a/addons/medical_engine/data/ace_unconscious_8_1.rtm b/addons/medical_engine/data/ace_unconscious_8_1.rtm new file mode 100644 index 0000000000..a80c72c32b Binary files /dev/null and b/addons/medical_engine/data/ace_unconscious_8_1.rtm differ diff --git a/addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf b/addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf new file mode 100644 index 0000000000..5d45d35a43 --- /dev/null +++ b/addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf @@ -0,0 +1,34 @@ +#include "script_component.hpp" +/* + * Author: diwako + * Apply a fitting unconscious animation to a knocked out unit + * + * Arguments: + * 0: Unit + * 1: Animation + * + * Return Value: + * None + * + * Example: + * [_unit, _anim] call ace_medical_engine_fnc_applyAnimAfterRagdoll; + * + * Public: No + */ + +params ["_unit", "_anim"]; +if !(IS_UNCONSCIOUS(_unit) && // do not run if unit is conscious + {alive _unit && // do not run if unit is dead + {isNull objectParent _unit}}) exitWith {}; // do not run if unit in any vehicle + +private _unconsciousAnimation = selectRandom (GVAR(animations) getVariable [_anim, [""]]); + +if (_unconsciousAnimation isEqualTo "") exitWith { + // not a valid animation found + ERROR("No valid animation found!"); +}; + +// Apply the animation only locally on the machine and do not broadcast it to others +// Reason is the nature of setUnconscious' end of ragdoll animation is not synced on all machines either +// Not synced animations are preferred over units snapping from one to another animation +_unit switchMove _unconsciousAnimation; diff --git a/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf b/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf index 0cc61c418d..27ed364bf5 100644 --- a/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf +++ b/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf @@ -47,10 +47,10 @@ if (_isUnconscious) then { } else { // and on foot TRACE_1("onfoot - playing standard anim",_unit); - [_unit, "AmovPpneMstpSnonWnonDnon"] call EFUNC(common,doAnimation); + [_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); if (currentWeapon _unit == secondaryWeapon _unit && {currentWeapon _unit != ""}) then { - [_unit, "AmovPknlMstpSrasWlnrDnon"] call EFUNC(common,doAnimation); + [_unit, "AmovPknlMstpSrasWlnrDnon", 2] call EFUNC(common,doAnimation); }; [{ @@ -58,7 +58,8 @@ if (_isUnconscious) then { TRACE_3("after delay",_unit,animationState _unit,lifeState _unit); 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) - if (((animationState _unit == "unconscious") || {animationState _unit == "deadstate"}) && {lifeState _unit != "INCAPACITATED"}) then { + private _animation = animationState _unit; + if ((_animation == "unconscious" || {_animation == "deadstate" || {_animation find "ace_unconscious_" != -1}}) && {lifeState _unit != "INCAPACITATED"}) then { [_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); TRACE_1("forcing SwitchMove",animationState _unit); };