Medical Engine - Synchronize random unconscious anims (#8671)

* Medical Engine - Synchronize random unconscious anims

* Update addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf

Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>

* Update addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf

Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>

Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com>
This commit is contained in:
PabstMirror 2021-11-11 16:34:56 -06:00 committed by GitHub
parent 3492fadd90
commit 2cd935acbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,13 +17,16 @@
*/ */
params ["_unit", "_anim"]; params ["_unit", "_anim"];
TRACE_2("applyAnimAfterRagdoll",_unit,_unconsciousAnimation); TRACE_2("applyAnimAfterRagdoll",_unit,_anim);
if !(IS_UNCONSCIOUS(_unit) && // do not run if unit is conscious if !(IS_UNCONSCIOUS(_unit) && // do not run if unit is conscious
{alive _unit && // do not run if unit is dead {alive _unit && // do not run if unit is dead
{isNull objectParent _unit}}) exitWith {}; // do not run if unit in any vehicle {isNull objectParent _unit}}) exitWith {}; // do not run if unit in any vehicle
private _unconsciousAnimation = selectRandom (GVAR(animations) getVariable [_anim, [""]]); private _animsArray = GVAR(animations) getVariable [_anim, [""]];
private _random = (toArray (hashValue _unit)) param [0, 0];
private _index = _random % (count _animsArray);
private _unconsciousAnimation = _animsArray select _index;
if (_unconsciousAnimation isEqualTo "") exitWith { if (_unconsciousAnimation isEqualTo "") exitWith {
// not a valid animation found // not a valid animation found
@ -33,4 +36,5 @@ if (_unconsciousAnimation isEqualTo "") exitWith {
// Apply the animation only locally on the machine and do not broadcast it to others // 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 // 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 // Not synced animations are preferred over units snapping from one to another animation
TRACE_2("switchMove",_unit,_unconsciousAnimation);
_unit switchMove _unconsciousAnimation; _unit switchMove _unconsciousAnimation;