ACE3/addons/common/functions/fnc_doAnimation.sqf

76 lines
2.9 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
* Execute an animation. This is used to not break things like the unconsciousness animation.
*
2015-09-20 20:16:51 +00:00
* Arguments:
* 0: Unit <OBJECT>
* 1: Animation <STRING>
* 2: Priority of the animation. (default: 0) <NUMBER>
* 0 = PlayMove
* 1 = PlayMoveNow
* 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1)
* 3: Force overwritting unconscious (default: false) <BOOL>
*
2015-09-20 20:16:51 +00:00
* Return Value:
* None
*
* Example:
* [player, "AmovPercMstpSnonWnonDnon_exerciseKata", 1] call ace_common_fnc_doAnimation
*
2015-09-20 20:16:51 +00:00
* Public: Yes
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-20 20:16:51 +00:00
params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
TRACE_4("params",_unit,_animation,_priority,_force);
// don't overwrite more important animations
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
// don't go unconscious if the unit isn't unconscious
if (_animation == "Unconscious" && {!((_unit getVariable ["ACE_isUnconscious", false]) || (_unit getVariable ["ACE_isDead", false]))}) exitWith {};
// switchMove "" no longer works in dev 1.37
if (_animation == "") then {
2015-05-14 18:06:06 +00:00
_animation = [_unit] call FUNC(getDefaultAnim);
};
//if (_animation == animationState _unit) exitWith {};
TRACE_2("",local _unit,vehicle _unit);
switch (_priority) do {
2015-09-20 20:16:51 +00:00
case 0: {
2015-05-14 18:06:06 +00:00
if (_unit == vehicle _unit) then {
["playMove", _unit, [_unit, _animation]] call FUNC(objectEvent);
2015-05-14 18:06:06 +00:00
} else {
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
["playMove", [_unit, _animation]] call FUNC(globalEvent);
2015-05-14 18:06:06 +00:00
};
};
2015-09-20 20:16:51 +00:00
case 1: {
2015-05-14 18:06:06 +00:00
if (_unit == vehicle _unit) then {
["playMoveNow", _unit, [_unit, _animation]] call FUNC(objectEvent);
2015-05-14 18:06:06 +00:00
} else {
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
["playMoveNow", [_unit, _animation]] call FUNC(globalEvent);
2015-05-14 18:06:06 +00:00
};
};
2015-09-20 20:16:51 +00:00
case 2: {
// try playMoveNow first
if (_unit == vehicle _unit) then {
["playMoveNow", _unit, [_unit, _animation]] call FUNC(objectEvent);
} else {
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
["playMoveNow", [_unit, _animation]] call FUNC(globalEvent);
};
// if animation doesn't respond, do switchMove
if (animationState _unit != _animation) then {
TRACE_1("did not respond to playMoveNow",animationState _unit);
// Execute on all machines. SwitchMove has local effects.
["switchMove", [_unit, _animation]] call FUNC(globalEvent);
};
2015-05-14 18:06:06 +00:00
};
default {};
};