mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Also handle the surrendering AnimChanged EH
This commit is contained in:
parent
ac144ca248
commit
dc1c312288
@ -15,6 +15,7 @@ PREP(doRemoveHandcuffs);
|
||||
PREP(doUnloadCaptive);
|
||||
PREP(findEmptyNonFFVCargoSeat);
|
||||
PREP(handleAnimChangedHandcuffed);
|
||||
PREP(handleAnimChangedSurrendered);
|
||||
PREP(handleGetIn);
|
||||
PREP(handleGetOut);
|
||||
PREP(handleLocal);
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: Nic547, commy2
|
||||
* Restart the surrendering animation if it got interrupted. Called from a AnimChanged EH.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Unit <OBJECT>
|
||||
* 1: New animation <STRING>
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_newAnimation"];
|
||||
|
||||
TRACE_2("AnimChanged",_unit,_newAnimation);
|
||||
if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
|
||||
TRACE_1("Surrender animation interrupted",_newAnimation);
|
||||
[_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation);
|
||||
};
|
@ -17,24 +17,47 @@
|
||||
|
||||
params ["_unit", "_local"];
|
||||
|
||||
// Make sure that if the unit is captive it has a AnimChanged EH running ONLY on the machine that owns it
|
||||
// Make sure that if the unit is captive or surrendered it has a AnimChanged EH running ONLY on the machine that owns it
|
||||
if (_local) then {
|
||||
// If the unit is not handcuffed there's nothing to do
|
||||
if !(_unit getVariable [QGVAR(isHandcuffed), false]) exitWith {};
|
||||
// If the unit already has an AnimChanged EH here then there's nothing to do either
|
||||
if (_unit getVariable [QGVAR(handcuffAnimEHID), -1] != -1) exitWith {};
|
||||
|
||||
// Otherwise, restart the AnimChanged EH in the new machine
|
||||
_animChangedEHID = _unit addEventHandler ["AnimChanged", DFUNC(handleAnimChanged)];
|
||||
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
||||
_unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID];
|
||||
// If the unit is handcuffed
|
||||
if (_unit getVariable [QGVAR(isHandcuffed), false]) then {
|
||||
// If the unit already has an AnimChanged EH here then there's nothing to do either
|
||||
if (_unit getVariable [QGVAR(handcuffAnimEHID), -1] != -1) exitWith {};
|
||||
|
||||
// Otherwise, restart the AnimChanged EH in the new machine
|
||||
private _animChangedEHID = _unit addEventHandler ["AnimChanged", DFUNC(handleAnimChangedHandcuffed)];
|
||||
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
||||
_unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID];
|
||||
};
|
||||
|
||||
// If the unit is surrendering
|
||||
if (_unit getVariable [QGVAR(isSurrendering), false]) then {
|
||||
// If the unit already has an AnimChanged EH here then there's nothing to do either
|
||||
if (_unit getVariable [QGVAR(surrenderAnimEHID), -1] != -1) exitWith {};
|
||||
|
||||
// Otherwise, restart the AnimChanged EH in the new machine
|
||||
private _animChangedEHID = _unit addEventHandler ["AnimChanged", DFUNC(handleAnimChangedSurrendered)];
|
||||
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
||||
_unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
|
||||
};
|
||||
|
||||
} else {
|
||||
private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
|
||||
// If the unit didn't have an AnimChanged EH here, do nothing
|
||||
if (_animChangedEHID == -1) exitWith {};
|
||||
|
||||
// If the unit had a AnimChanged EH in the old machine then remove it
|
||||
TRACE_1("Removing animChanged EH",_animChangedEHID);
|
||||
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
||||
_unit setVariable [QGVAR(handcuffAnimEHID), -1];
|
||||
private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
|
||||
if (_animChangedEHID != -1) then {
|
||||
// If the unit had a AnimChanged EH for handcuffing in the old machine then remove it
|
||||
TRACE_1("Removing animChanged EH",_animChangedEHID);
|
||||
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
||||
_unit setVariable [QGVAR(handcuffAnimEHID), -1];
|
||||
};
|
||||
|
||||
_animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
|
||||
if (_animChangedEHID != -1) then {
|
||||
// If the unit had a AnimChanged EH for handcuffing in the old machine then remove it
|
||||
TRACE_1("Removing animChanged EH",_animChangedEHID);
|
||||
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
||||
_unit setVariable [QGVAR(surrenderAnimEHID), -1];
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -73,7 +73,7 @@ if (_state) then {
|
||||
TRACE_1("removing animChanged EH",_animChangedEHID);
|
||||
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
||||
};
|
||||
_animChangedEHID = _unit addEventHandler ["AnimChanged", DFUNC(handleAnimChanged)];
|
||||
_animChangedEHID = _unit addEventHandler ["AnimChanged", DFUNC(handleAnimChangedHandcuffed)];
|
||||
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
||||
_unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID];
|
||||
|
||||
|
@ -64,13 +64,7 @@ if (_state) then {
|
||||
TRACE_1("removing animChanged EH",_animChangedEHID);
|
||||
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
||||
};
|
||||
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
|
||||
params ["_unit", "_newAnimation"];
|
||||
if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
|
||||
TRACE_1("Surrender animation interrupted",_newAnimation);
|
||||
[_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation);
|
||||
};
|
||||
}];
|
||||
_animChangedEHID = _unit addEventHandler ["AnimChanged", DFUNC(handleAnimChangedSurrendered)];
|
||||
_unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
|
||||
};
|
||||
}, [_unit], 0.01] call CBA_fnc_waitAndExecute;
|
||||
|
Loading…
Reference in New Issue
Block a user