ACE3/addons/medical_engine/functions/fnc_applyAnimAfterRagdoll.sqf
Grim 59af3e1f6d
General - Change CBA Namespaces to HashMap (#8801)
* medical_treatment

* advanced_throwing

* common, csw

* Update fnc_replaceRegisteredItems.sqf

* Sanitised numerous components

* Update XEH_postInit.sqf

* Update XEH_postInit.sqf

* FUNC -> LINKFUNC

* Changed tagging hashmap

* Reverted some changes

* Reverted some changes

* Update XEH_clientInit.sqf

* Tweaks and fixes

* Fix number replacements

* Minor cleanup

* Update fnc_getMagazineName.sqf

* Update fnc_getMagazineName.sqf

* Minor improvement

* Made factions case-sensitive and added `toLowerANSI` to be safe

* Update fnc_getDetectedObject.sqf

* Update addons/common/functions/fnc_actionKeysNamesConverted.sqf

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Throw error if item doesn't exist

---------

Co-authored-by: Salluci <69561145+Salluci@users.noreply.github.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-06-11 12:34:32 -03:00

41 lines
1.4 KiB
Plaintext

#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"];
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 _animsArray = GVAR(animations) getOrDefault [_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
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
// 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;