2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* 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)
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2015-09-20 20:16:51 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-09-20 20:16:51 +00:00
|
|
|
params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// don't overwrite more important animations
|
2015-04-04 18:41:49 +00:00
|
|
|
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// don't go unconscious if the unit isn't unconscious
|
2015-01-21 14:52:11 +00:00
|
|
|
if (_animation == "Unconscious" && {!((_unit getVariable ["ACE_isUnconscious", false]) || (_unit getVariable ["ACE_isDead", false]))}) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// switchMove "" no longer works in dev 1.37
|
|
|
|
if (_animation == "") then {
|
2015-05-14 18:06:06 +00:00
|
|
|
_animation = [_unit] call FUNC(getDefaultAnim);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-09-17 10:23:56 +00:00
|
|
|
//if (_animation == animationState _unit) exitWith {};
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
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 {
|
|
|
|
[_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
|
|
|
} else {
|
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
|
|
|
[_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc);
|
|
|
|
};
|
2015-01-11 16:42:31 +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 {
|
|
|
|
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
|
|
|
} else {
|
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
|
|
|
[_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc);
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
2015-09-20 20:16:51 +00:00
|
|
|
case 2: {
|
2015-09-17 10:23:56 +00:00
|
|
|
// try playMoveNow first
|
|
|
|
if (_unit == vehicle _unit) then {
|
|
|
|
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
|
|
|
} else {
|
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
|
|
|
[_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc);
|
|
|
|
};
|
|
|
|
|
|
|
|
// if animation doesn't respond, do switchMove
|
|
|
|
if (animationState _unit != _animation) then {
|
|
|
|
// Execute on all machines. SwitchMove has local effects.
|
|
|
|
[_unit, format ["{_this switchMove '%1'}", _animation]] call FUNC(execRemoteFnc);
|
|
|
|
};
|
2015-05-14 18:06:06 +00:00
|
|
|
};
|
|
|
|
default {};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|