2018-07-30 09:22:14 +00:00
|
|
|
#include "script_component.hpp"
|
2016-10-05 22:54:57 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Force local unit into ragdoll / unconsciousness animation.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Is unconscious (optional, default: true) <BOOLEAN>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2019-03-30 16:07:54 +00:00
|
|
|
* [player, true] call ace_medical_engine_fnc_setUnconsciousAnim
|
2016-10-05 22:54:57 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params [["_unit", objNull, [objNull]], ["_isUnconscious", true, [false]]];
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_2("setUnconsciousAnim",_unit,_isUnconscious);
|
2016-10-05 22:54:57 +00:00
|
|
|
|
|
|
|
if (!local _unit) exitWith {
|
2019-09-05 20:56:53 +00:00
|
|
|
ERROR_1("Unit %1 not local or null",_unit);
|
2016-10-05 22:54:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_unit setUnconscious _isUnconscious;
|
|
|
|
|
|
|
|
if (_isUnconscious) then {
|
|
|
|
// eject from static weapon
|
2021-04-20 09:59:11 +00:00
|
|
|
if (vehicle _unit isKindOf "StaticWeapon" && {!(vehicle _unit isKindOf "Pod_Heli_Transport_04_crewed_base_F")}) then {
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_2("ejecting from static weapon",_unit,vehicle _unit);
|
2016-10-05 22:54:57 +00:00
|
|
|
[_unit] call EFUNC(common,unloadPerson);
|
|
|
|
};
|
|
|
|
|
|
|
|
// set animation inside vehicles
|
|
|
|
if (vehicle _unit != _unit) then {
|
|
|
|
private _unconAnim = _unit call EFUNC(common,getDeathAnim);
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_2("inVehicle - playing death anim",_unit,_unconAnim);
|
2016-10-05 22:54:57 +00:00
|
|
|
[_unit, _unconAnim] call EFUNC(common,doAnimation);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// reset animation inside vehicles
|
|
|
|
if (vehicle _unit != _unit) then {
|
|
|
|
private _awakeAnim = _unit call EFUNC(common,getAwakeAnim);
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_2("inVehicle - playing awake anim",_unit,_awakeAnim);
|
2016-10-05 22:54:57 +00:00
|
|
|
[_unit, _awakeAnim, 2] call EFUNC(common,doAnimation);
|
|
|
|
} else {
|
|
|
|
// and on foot
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_1("onfoot - playing standard anim",_unit);
|
2020-07-01 13:08:54 +00:00
|
|
|
[_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
2016-10-05 22:54:57 +00:00
|
|
|
|
2016-10-12 23:42:32 +00:00
|
|
|
if (currentWeapon _unit == secondaryWeapon _unit && {currentWeapon _unit != ""}) then {
|
2020-07-01 13:08:54 +00:00
|
|
|
[_unit, "AmovPknlMstpSrasWlnrDnon", 2] call EFUNC(common,doAnimation);
|
2016-10-12 23:42:32 +00:00
|
|
|
};
|
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
[{
|
|
|
|
params ["_unit"];
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_3("after delay",_unit,animationState _unit,lifeState _unit);
|
|
|
|
if (!alive _unit) exitWith {};
|
|
|
|
// Fix unit being in locked animation with switchMove (If unit was unloaded from a vehicle, they may be in deadstate instead of unconscious)
|
2020-07-01 13:08:54 +00:00
|
|
|
private _animation = animationState _unit;
|
2021-11-07 23:15:52 +00:00
|
|
|
if ((_animation == "unconscious" || {_animation == "deadstate" || {_animation find QGVAR(uncon_anim) != -1}}) && {lifeState _unit != "INCAPACITATED"}) then {
|
2016-10-05 22:54:57 +00:00
|
|
|
[_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
2019-09-05 20:56:53 +00:00
|
|
|
TRACE_1("forcing SwitchMove",animationState _unit);
|
2016-10-05 22:54:57 +00:00
|
|
|
};
|
2016-10-12 19:59:32 +00:00
|
|
|
}, _unit, 0.5] call CBA_fnc_waitAndExecute;
|
2016-10-05 22:54:57 +00:00
|
|
|
};
|
|
|
|
};
|