2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
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
|
|
|
|
*
|
2016-02-21 17:08:07 +00:00
|
|
|
* Example:
|
|
|
|
* [player, "AmovPercMstpSnonWnonDnon_exerciseKata", 1] call ace_common_fnc_doAnimation
|
|
|
|
*
|
2015-09-20 20:16:51 +00:00
|
|
|
* Public: Yes
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
|
|
|
|
2016-10-05 22:54:57 +00:00
|
|
|
params ["_unit", "_animation", ["_priority", 0]];
|
2019-04-27 13:05:29 +00:00
|
|
|
TRACE_3("params",_unit,_animation,_priority);
|
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 {};
|
|
|
|
|
2016-02-21 17:08:07 +00:00
|
|
|
TRACE_2("",local _unit,vehicle _unit);
|
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 {
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(playMove), [_unit, _animation], _unit] call CBA_fnc_targetEvent;
|
2015-05-14 18:06:06 +00:00
|
|
|
} else {
|
2016-10-05 22:54:57 +00:00
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have local effects when executed on remote machines inside vehicles.
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(playMove), [_unit, _animation]] call CBA_fnc_globalEvent;
|
2015-05-14 18:06:06 +00:00
|
|
|
};
|
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 {
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(playMoveNow), [_unit, _animation], _unit] call CBA_fnc_targetEvent;
|
2015-05-14 18:06:06 +00:00
|
|
|
} else {
|
2016-10-05 22:54:57 +00:00
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have local effects when executed on remote machines inside vehicles.
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(playMoveNow), [_unit, _animation]] call CBA_fnc_globalEvent;
|
2015-05-14 18:06:06 +00:00
|
|
|
};
|
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 {
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(playMoveNow), [_unit, _animation], _unit] call CBA_fnc_targetEvent;
|
2015-09-17 10:23:56 +00:00
|
|
|
} else {
|
2016-10-05 22:54:57 +00:00
|
|
|
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have local effects when executed on remote machines inside vehicles.
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(playMoveNow), [_unit, _animation]] call CBA_fnc_globalEvent;
|
2015-09-17 10:23:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// if animation doesn't respond, do switchMove
|
|
|
|
if (animationState _unit != _animation) then {
|
2016-02-21 17:08:07 +00:00
|
|
|
TRACE_1("did not respond to playMoveNow",animationState _unit);
|
2015-09-17 10:23:56 +00:00
|
|
|
// Execute on all machines. SwitchMove has local effects.
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(switchMove), [_unit, _animation]] call CBA_fnc_globalEvent;
|
2015-09-17 10:23:56 +00:00
|
|
|
};
|
2015-05-14 18:06:06 +00:00
|
|
|
};
|
|
|
|
default {};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|