2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
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>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2016-06-19 22:17:49 +00:00
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, true] call ACE_captives_fnc_handleLocal
|
|
|
|
*
|
2016-06-19 22:17:49 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit", "_local"];
|
|
|
|
|
2016-06-19 23:15:51 +00:00
|
|
|
// 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 {
|
2016-06-19 23:15:51 +00:00
|
|
|
|
|
|
|
// 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
|
2018-05-30 22:39:28 +00:00
|
|
|
private _animChangedEHID = _unit addEventHandler ["AnimChanged", {call FUNC(handleAnimChangedHandcuffed)}];
|
2016-06-19 23:15:51 +00:00
|
|
|
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
|
2018-05-30 22:39:28 +00:00
|
|
|
private _animChangedEHID = _unit addEventHandler ["AnimChanged", {call FUNC(handleAnimChangedSurrendered)}];
|
2016-06-19 23:15:51 +00:00
|
|
|
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
|
|
|
_unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID];
|
|
|
|
};
|
|
|
|
|
2016-06-19 22:17:49 +00:00
|
|
|
} else {
|
2016-06-19 23:15:51 +00:00
|
|
|
|
2016-06-19 22:17:49 +00:00
|
|
|
private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
|
2016-06-19 23:15:51 +00:00
|
|
|
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
|
|
|
|
|
|
|
};
|