Medical - Add unconscious animations (#7363)

* Add custom anim entries

* Switch to SQF based animation detection

* Add time out to CBA_fnc_waitUntilAndExecute

* Remove unneeded comments or defines

* Restore line break

* Styling and removal of not needed code

* Move waitForAnime and make it local nil

* Extended comment

* Add Kola to authors file

* Small bug fix in terms of animation names

* Add custom anim entries


Switch to SQF based animation detection


Add time out to CBA_fnc_waitUntilAndExecute


Remove unneeded comments or defines


Restore line break


Styling and removal of not needed code


Move waitForAnime and make it local nil


Extended comment


Add Kola to authors file


Small bug fix in terms of animation names

* Move animations into data folder

* add uppercase on sqf command

* Rename animation config names and files

* fix physx uncon fix

* Change initial after ragdoll animation name
This commit is contained in:
diwako 2020-07-01 15:08:54 +02:00 committed by GitHub
parent 444ee88f08
commit b16ca5c204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 138 additions and 9 deletions

View File

@ -105,6 +105,7 @@ Karneck <dschultz26@hotmail.com>
Kavinsky <nmunozfernandez@gmail.com> Kavinsky <nmunozfernandez@gmail.com>
Keithen <Keithen.Neu@gmail.com> Keithen <Keithen.Neu@gmail.com>
Kllrt <kllrtik@gmail.com> Kllrt <kllrtik@gmail.com>
KokaKolaA3
legman <juicemelon@msn.com> legman <juicemelon@msn.com>
Legolasindar "Viper" <legolasindar@gmail.com> Legolasindar "Viper" <legolasindar@gmail.com>
licht-im-Norden87 <lichtimnorden87@gmail.com> licht-im-Norden87 <lichtimnorden87@gmail.com>

View File

@ -1,10 +1,9 @@
// we want the face down animation every time
class CfgExtendedAnimation { class CfgExtendedAnimation {
class Revive { class Revive {
left = "Unconscious"; left = QGVAR(faceLeft_unconscious);
right = "Unconscious"; right = QGVAR(faceRight_unconscious);
front = "Unconscious"; front = QGVAR(faceDown_unconscious);
back = "Unconscious"; back = QGVAR(faceUp_unconscious);
}; };
}; };

View File

@ -8,6 +8,76 @@ class CfgMovesMaleSdr: CfgMovesBasic {
weaponIK = 0; 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 AmovPpneMstpSnonWnonDnon;
class ACE_UnconsciousOutProne: AmovPpneMstpSnonWnonDnon { class ACE_UnconsciousOutProne: AmovPpneMstpSnonWnonDnon {
//file = "\A3\anims_f\Data\Anim\Sdr\dth\pne\stp\ras\Rfl\AdthPpneMstpSrasWrflDnon_1"; //file = "\A3\anims_f\Data\Anim\Sdr\dth\pne\stp\ras\Rfl\AdthPpneMstpSrasWrflDnon_1";

View File

@ -6,3 +6,4 @@ PREP(setStructuralDamage);
PREP(setUnconsciousAnim); PREP(setUnconsciousAnim);
PREP(getHitpointArmor); PREP(getHitpointArmor);
PREP(getItemArmor); PREP(getItemArmor);
PREP(applyAnimAfterRagdoll);

View File

@ -66,7 +66,7 @@
// Fixes units being stuck in unconscious animation when being knocked over by a PhysX object // Fixes units being stuck in unconscious animation when being knocked over by a PhysX object
["CAManBase", "AnimDone", { ["CAManBase", "AnimDone", {
params ["_unit", "_anim"]; 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); [_unit, false] call FUNC(setUnconsciousAnim);
}; };
}] call CBA_fnc_addClassEventHandler; }] call CBA_fnc_addClassEventHandler;

View File

@ -36,6 +36,12 @@ GVAR(armorCache) = false call CBA_fnc_createNamespace;
// with handle damage not returning full results. // with handle damage not returning full results.
GVAR(fixedStatics) = []; 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 = { private _fnc_fixStatic = {
params ["_vehicle"]; params ["_vehicle"];
private _type = typeOf _vehicle; private _type = typeOf _vehicle;
@ -55,4 +61,21 @@ addMissionEventHandler ["Loaded", {
} forEach GVAR(fixedStatics); } 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; ADDON = true;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,34 @@
#include "script_component.hpp"
/*
* Author: diwako
* Apply a fitting unconscious animation to a knocked out unit
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Animation <STRING>
*
* 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;

View File

@ -47,10 +47,10 @@ if (_isUnconscious) then {
} else { } else {
// and on foot // and on foot
TRACE_1("onfoot - playing standard anim",_unit); 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 { 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); TRACE_3("after delay",_unit,animationState _unit,lifeState _unit);
if (!alive _unit) exitWith {}; 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) // 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); [_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
TRACE_1("forcing SwitchMove",animationState _unit); TRACE_1("forcing SwitchMove",animationState _unit);
}; };