2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
|
|
|
* Execute an animation. This is used to not break things like the unconsciousness animation.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Unit (Object)
|
|
|
|
* 1: Animation (String)
|
|
|
|
* 2: Priority of the animation. (Number, optional default: 0)
|
|
|
|
* 0: PlayMove
|
|
|
|
* 1: PlayMoveNow
|
|
|
|
* 2: SwitchMove (no transitional animation, doesn't overwrite priority 1)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Nothing
|
|
|
|
*/
|
2015-01-13 19:56:02 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
private ["_unit", "_animation", "_priority", "_force"];
|
|
|
|
|
|
|
|
_unit = _this select 0;
|
|
|
|
_animation = _this select 1;
|
|
|
|
_priority = _this select 2;
|
|
|
|
_force = False;
|
|
|
|
|
|
|
|
// no animation given
|
|
|
|
if (isNil "_animation") exitWith {
|
2015-01-12 04:02:33 +00:00
|
|
|
diag_log format ["[ACE] ERROR: No animation specified in %1", _fnc_scriptNameParent];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (isNil "_priority") then {
|
|
|
|
_priority = 0;
|
|
|
|
};
|
|
|
|
if (count _this > 3) then {
|
|
|
|
_force = _this select 3;
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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-01-11 18:20:14 +00:00
|
|
|
_animation = [_unit] call FUNC(getDefaultAnim);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
switch (_priority) do {
|
|
|
|
case 0 : {
|
|
|
|
if (_unit == vehicle _unit) then {
|
2015-01-11 18:20:14 +00:00
|
|
|
[_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
2015-01-11 18:20:14 +00:00
|
|
|
[_unit, format ["{_this playMove '%1'}", _animation]] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
case 1 : {
|
|
|
|
if (_unit == vehicle _unit) then {
|
2015-01-11 18:20:14 +00:00
|
|
|
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
2015-01-11 18:20:14 +00:00
|
|
|
[_unit, format ["{_this playMoveNow '%1'}", _animation]] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
case 2 : {
|
|
|
|
// Execute on all machines. SwitchMove has local effects.
|
2015-01-11 18:20:14 +00:00
|
|
|
[_unit, format ["{_this switchMove '%1'}", _animation]] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
default {};
|
|
|
|
};
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
["Anim", [_priority, _animation]] call FUNC(log);
|