ACE3/addons/captives/functions/fnc_handleLocal.sqf

64 lines
2.3 KiB
Plaintext
Raw Normal View History

2016-06-19 22:17:49 +00:00
/*
* Author: esteldunedain
* Called when a unit switched locality
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Is local <BOOL>
*
* ReturnValue:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_local"];
// Make sure that if the unit is captive or surrendered it has a AnimChanged EH running ONLY on the machine that owns it
2016-06-19 22:17:49 +00:00
if (_local) then {
// 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];
};
2016-06-19 22:17:49 +00:00
} else {
2016-06-19 22:17:49 +00:00
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];
};
2016-06-19 22:17:49 +00:00
};