mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #3382 from acemod/doAnimEvents
ObjectEvent Func, swap execRemoteFnc in doAnim
This commit is contained in:
commit
52108b1737
@ -241,6 +241,7 @@ PREP(fixCrateContent);
|
|||||||
PREP(globalEvent);
|
PREP(globalEvent);
|
||||||
PREP(_handleNetEvent);
|
PREP(_handleNetEvent);
|
||||||
PREP(addEventHandler);
|
PREP(addEventHandler);
|
||||||
|
PREP(objectEvent);
|
||||||
PREP(targetEvent);
|
PREP(targetEvent);
|
||||||
PREP(serverEvent);
|
PREP(serverEvent);
|
||||||
PREP(localEvent);
|
PREP(localEvent);
|
||||||
|
@ -149,6 +149,9 @@ if (isServer) then {
|
|||||||
["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler);
|
["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler);
|
||||||
["selectLeader", {(_this select 0) selectLeader (_this select 1)}] call FUNC(addEventHandler);
|
["selectLeader", {(_this select 0) selectLeader (_this select 1)}] call FUNC(addEventHandler);
|
||||||
["setVelocity", {(_this select 0) setVelocity (_this select 1)}] call FUNC(addEventHandler);
|
["setVelocity", {(_this select 0) setVelocity (_this select 1)}] call FUNC(addEventHandler);
|
||||||
|
["playMove", {(_this select 0) playMove (_this select 1)}] call FUNC(addEventHandler);
|
||||||
|
["playMoveNow", {(_this select 0) playMoveNow (_this select 1)}] call FUNC(addEventHandler);
|
||||||
|
["switchMove", {(_this select 0) switchMove (_this select 1)}] call FUNC(addEventHandler);
|
||||||
|
|
||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
|
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2
|
* Author: commy2
|
||||||
*
|
|
||||||
* Execute an animation. This is used to not break things like the unconsciousness animation.
|
* Execute an animation. This is used to not break things like the unconsciousness animation.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -10,15 +9,20 @@
|
|||||||
* 0 = PlayMove
|
* 0 = PlayMove
|
||||||
* 1 = PlayMoveNow
|
* 1 = PlayMoveNow
|
||||||
* 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1)
|
* 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1)
|
||||||
|
* 3: Force overwritting unconscious (default: false) <BOOL>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
|
* Example:
|
||||||
|
* [player, "AmovPercMstpSnonWnonDnon_exerciseKata", 1] call ace_common_fnc_doAnimation
|
||||||
|
*
|
||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
|
params ["_unit", "_animation", ["_priority", 0], ["_force", false]];
|
||||||
|
TRACE_4("params",_unit,_animation,_priority,_force);
|
||||||
|
|
||||||
// don't overwrite more important animations
|
// don't overwrite more important animations
|
||||||
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
|
if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {};
|
||||||
@ -33,36 +37,38 @@ if (_animation == "") then {
|
|||||||
|
|
||||||
//if (_animation == animationState _unit) exitWith {};
|
//if (_animation == animationState _unit) exitWith {};
|
||||||
|
|
||||||
|
TRACE_2("",local _unit,vehicle _unit);
|
||||||
switch (_priority) do {
|
switch (_priority) do {
|
||||||
case 0: {
|
case 0: {
|
||||||
if (_unit == vehicle _unit) then {
|
if (_unit == vehicle _unit) then {
|
||||||
[_unit, format ["{_this playMove '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
["playMove", _unit, [_unit, _animation]] call FUNC(objectEvent);
|
||||||
} else {
|
} else {
|
||||||
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
// 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);
|
["playMove", [_unit, _animation]] call FUNC(globalEvent);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
case 1: {
|
case 1: {
|
||||||
if (_unit == vehicle _unit) then {
|
if (_unit == vehicle _unit) then {
|
||||||
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
["playMoveNow", _unit, [_unit, _animation]] call FUNC(objectEvent);
|
||||||
} else {
|
} else {
|
||||||
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
// 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);
|
["playMoveNow", [_unit, _animation]] call FUNC(globalEvent);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
case 2: {
|
case 2: {
|
||||||
// try playMoveNow first
|
// try playMoveNow first
|
||||||
if (_unit == vehicle _unit) then {
|
if (_unit == vehicle _unit) then {
|
||||||
[_unit, format ["{_this playMoveNow '%1'}", _animation], _unit] call FUNC(execRemoteFnc);
|
["playMoveNow", _unit, [_unit, _animation]] call FUNC(objectEvent);
|
||||||
} else {
|
} else {
|
||||||
// Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles.
|
// 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);
|
["playMoveNow", [_unit, _animation]] call FUNC(globalEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
// if animation doesn't respond, do switchMove
|
// if animation doesn't respond, do switchMove
|
||||||
if (animationState _unit != _animation) then {
|
if (animationState _unit != _animation) then {
|
||||||
|
TRACE_1("did not respond to playMoveNow",animationState _unit);
|
||||||
// Execute on all machines. SwitchMove has local effects.
|
// Execute on all machines. SwitchMove has local effects.
|
||||||
[_unit, format ["{_this switchMove '%1'}", _animation]] call FUNC(execRemoteFnc);
|
["switchMove", [_unit, _animation]] call FUNC(globalEvent);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
default {};
|
default {};
|
||||||
|
34
addons/common/functions/fnc_objectEvent.sqf
Normal file
34
addons/common/functions/fnc_objectEvent.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Execute an event where object is local.
|
||||||
|
* If local there is no network traffic/delay (Unlike targetEvent)
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Event name (STRING)
|
||||||
|
* 1: Event target <OBJECT>
|
||||||
|
* 2: Event args <ANY>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ["doThing", vehicle player, []] call ace_common_fnc_objectEvent
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_eventName", "_eventTarget", "_eventArgs"];
|
||||||
|
|
||||||
|
#ifdef DEBUG_EVENTS
|
||||||
|
ACE_LOGINFO_2("* Object Event: %1 - %2",_eventName,_eventTarget);
|
||||||
|
ACE_LOGINFO_1(" args=%1",_eventArgs);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (local _eventTarget) then {
|
||||||
|
[_eventName, _eventArgs] call FUNC(localEvent);
|
||||||
|
} else {
|
||||||
|
_this call FUNC(targetEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
nil
|
Loading…
Reference in New Issue
Block a user