Skip to content

Commit

Permalink
Medical Engine - Synchronize random unconscious anims (acemod#8671)
Browse files Browse the repository at this point in the history
* Medical Engine - Synchronize random unconscious anims

* Update addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf

Co-authored-by: mharis001 <[email protected]>

* Update addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf

Co-authored-by: mharis001 <[email protected]>

Co-authored-by: mharis001 <[email protected]>
  • Loading branch information
2 people authored and AndreasBrostrom committed Dec 3, 2021
1 parent 3a1a5c2 commit 59f00dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
*/

params ["_unit", "_anim"];
TRACE_2("applyAnimAfterRagdoll",_unit,_unconsciousAnimation);
TRACE_2("applyAnimAfterRagdoll",_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, [""]]);
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 {
// not a valid animation found
Expand All @@ -33,4 +36,5 @@ if (_unconsciousAnimation isEqualTo "") exitWith {
// 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
TRACE_2("switchMove",_unit,_unconsciousAnimation);
_unit switchMove _unconsciousAnimation;

0 comments on commit 59f00dd

Please sign in to comment.