Medical Engine - Prevent issues with respawning and ragdoll animations (#7796)

This commit is contained in:
PabstMirror 2020-07-22 10:25:47 -05:00 committed by GitHub
parent d751aca8ba
commit 46f3c55758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -64,12 +64,12 @@ addMissionEventHandler ["Loaded", {
["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];
};
// 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}, {
[_this, animationState _this] call FUNC(applyAnimAfterRagdoll);
}, _unit, 20] call CBA_fnc_waitUntilAndExecute;
} else {
_unit setVariable [QGVAR(waitForAnim), nil];
if (local _unit) then {

View File

@ -17,6 +17,8 @@
*/
params ["_unit", "_anim"];
TRACE_2("applyAnimAfterRagdoll",_unit,_unconsciousAnimation);
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
@ -25,7 +27,7 @@ private _unconsciousAnimation = selectRandom (GVAR(animations) getVariable [_ani
if (_unconsciousAnimation isEqualTo "") exitWith {
// not a valid animation found
ERROR("No valid animation found!");
ERROR_1("No valid animation found! [from anim: %1]",_anim);
};
// Apply the animation only locally on the machine and do not broadcast it to others