Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical Engine - Synchronize random unconscious anims #8671

Merged
merged 3 commits into from
Nov 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;