2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-03 02:04:50 +00:00
|
|
|
/*
|
|
|
|
* Author: Nic547, commy2
|
2015-02-07 04:24:27 +00:00
|
|
|
* Handcuffs a unit.
|
2015-02-03 02:04:50 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: True to take captive, false to release captive <BOOL>
|
2021-09-03 19:38:49 +00:00
|
|
|
* 2: Caller <OBJECT>
|
2015-02-03 02:04:50 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-02-03 02:04:50 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2021-09-03 19:38:49 +00:00
|
|
|
* [bob, true, dave] call ACE_captives_fnc_setHandcuffed;
|
2015-02-03 02:04:50 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2021-09-03 19:38:49 +00:00
|
|
|
params ["_unit", "_state", ["_caller", objNull]];
|
|
|
|
TRACE_3("params",_unit,_state,_caller);
|
2015-02-17 00:03:09 +00:00
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if (!local _unit) exitWith {
|
2016-09-13 21:52:51 +00:00
|
|
|
WARNING("running setHandcuffed on remote unit");
|
2015-02-05 22:39:45 +00:00
|
|
|
};
|
2016-02-20 14:57:47 +00:00
|
|
|
|
|
|
|
if !(missionNamespace getVariable [QGVAR(captivityEnabled), false]) exitWith {
|
|
|
|
// It's to soon to call this function, delay it
|
|
|
|
if (EGVAR(common,settingsInitFinished)) then {
|
|
|
|
// Settings are already initialized, but the small wait isn't over
|
2016-05-22 13:27:24 +00:00
|
|
|
[DFUNC(setHandCuffed), _this, 0.05] call CBA_fnc_waitAndExecute;
|
2016-02-20 14:57:47 +00:00
|
|
|
} else {
|
|
|
|
// Settings are not initialized yet
|
|
|
|
[DFUNC(setHandCuffed), _this] call EFUNC(common,runAfterSettingsInit);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-02-17 00:03:09 +00:00
|
|
|
if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith {
|
2016-09-13 21:52:51 +00:00
|
|
|
WARNING("setHandcuffed: current state same as new");
|
2015-02-05 22:39:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_state) then {
|
|
|
|
_unit setVariable [QGVAR(isHandcuffed), true, true];
|
2016-01-19 15:34:59 +00:00
|
|
|
[_unit, "setCaptive", QGVAR(Handcuffed), true] call EFUNC(common,statusEffect_set);
|
2021-09-25 16:16:15 +00:00
|
|
|
[_unit, "blockRadio", QGVAR(Handcuffed), true] call EFUNC(common,statusEffect_set);
|
2015-04-15 16:46:01 +00:00
|
|
|
|
2015-02-15 20:55:17 +00:00
|
|
|
if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop
|
2015-02-17 00:03:09 +00:00
|
|
|
[_unit, false] call FUNC(setSurrendered);
|
2015-02-15 20:55:17 +00:00
|
|
|
};
|
2015-04-15 16:46:01 +00:00
|
|
|
|
2015-02-17 00:03:09 +00:00
|
|
|
//Set unit cargoIndex (will be -1 if dismounted)
|
2015-02-07 04:24:27 +00:00
|
|
|
_unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true];
|
|
|
|
|
|
|
|
if (_unit == ACE_player) then {
|
2018-07-21 23:03:00 +00:00
|
|
|
["captive", [false, false, false, false, false, false, false, false, false, true]] call EFUNC(common,showHud);
|
2015-02-07 04:24:27 +00:00
|
|
|
};
|
2015-02-03 02:04:50 +00:00
|
|
|
|
2015-02-04 05:13:44 +00:00
|
|
|
// fix anim on mission start (should work on dedicated servers)
|
2015-02-07 04:24:27 +00:00
|
|
|
[{
|
2015-08-04 23:15:20 +00:00
|
|
|
params ["_unit"];
|
2015-08-15 02:29:01 +00:00
|
|
|
if (!(_unit getVariable [QGVAR(isHandcuffed), false])) exitWith {};
|
|
|
|
|
|
|
|
if ((vehicle _unit) == _unit) then {
|
2015-02-06 09:38:27 +00:00
|
|
|
[_unit] call EFUNC(common,fixLoweredRifleAnimation);
|
2015-02-07 04:24:27 +00:00
|
|
|
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
|
2015-08-20 09:20:46 +00:00
|
|
|
} else {
|
|
|
|
[_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation);
|
|
|
|
[_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation);
|
2015-08-15 02:29:01 +00:00
|
|
|
};
|
2015-04-15 16:46:01 +00:00
|
|
|
|
2015-08-15 02:29:01 +00:00
|
|
|
//Adds an animation changed eh
|
|
|
|
//If we get a change in animation then redo the animation (handles people vaulting to break the animation chain)
|
2015-11-17 16:43:07 +00:00
|
|
|
private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
|
2015-10-23 18:11:11 +00:00
|
|
|
if (_animChangedEHID != -1) then {
|
|
|
|
TRACE_1("removing animChanged EH",_animChangedEHID);
|
|
|
|
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
|
|
|
};
|
2018-05-30 22:39:28 +00:00
|
|
|
_animChangedEHID = _unit addEventHandler ["AnimChanged", {call FUNC(handleAnimChangedHandcuffed)}];
|
2015-08-23 07:29:51 +00:00
|
|
|
TRACE_2("Adding animChangedEH",_unit,_animChangedEHID);
|
2015-08-15 02:29:01 +00:00
|
|
|
_unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID];
|
2015-04-15 16:46:01 +00:00
|
|
|
|
2016-05-22 13:27:24 +00:00
|
|
|
}, [_unit], 0.01] call CBA_fnc_waitAndExecute;
|
2015-02-03 02:04:50 +00:00
|
|
|
} else {
|
2015-02-05 22:39:45 +00:00
|
|
|
_unit setVariable [QGVAR(isHandcuffed), false, true];
|
2016-01-19 15:34:59 +00:00
|
|
|
[_unit, "setCaptive", QGVAR(Handcuffed), false] call EFUNC(common,statusEffect_set);
|
2021-09-25 16:16:15 +00:00
|
|
|
[_unit, "blockRadio", QGVAR(Handcuffed), false] call EFUNC(common,statusEffect_set);
|
2015-04-15 16:46:01 +00:00
|
|
|
|
|
|
|
//remove AnimChanged EH
|
2015-11-17 16:43:07 +00:00
|
|
|
private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
|
2015-08-23 07:29:51 +00:00
|
|
|
TRACE_1("removing animChanged EH",_animChangedEHID);
|
2015-02-17 23:05:07 +00:00
|
|
|
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
|
|
|
|
_unit setVariable [QGVAR(handcuffAnimEHID), -1];
|
2015-04-15 16:46:01 +00:00
|
|
|
|
2015-03-13 05:45:12 +00:00
|
|
|
if (((vehicle _unit) == _unit) && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
|
|
|
|
//Break out of hands up animation loop
|
2015-02-04 05:13:44 +00:00
|
|
|
[_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
|
|
|
};
|
2015-02-03 02:04:50 +00:00
|
|
|
|
2015-02-06 09:38:27 +00:00
|
|
|
if (_unit getVariable [QGVAR(CargoIndex), -1] != -1) then {
|
|
|
|
_unit setVariable [QGVAR(CargoIndex), -1, true];
|
2015-02-04 05:13:44 +00:00
|
|
|
};
|
2015-02-03 02:04:50 +00:00
|
|
|
|
2015-02-04 05:13:44 +00:00
|
|
|
if (_unit == ACE_player) then {
|
2015-10-16 03:45:35 +00:00
|
|
|
["captive", []] call EFUNC(common,showHud); //same as showHud true;
|
2015-02-04 05:13:44 +00:00
|
|
|
};
|
2015-02-03 02:04:50 +00:00
|
|
|
};
|
2015-09-29 15:17:17 +00:00
|
|
|
|
|
|
|
//Global Event after changes:
|
2021-09-03 19:38:49 +00:00
|
|
|
["ace_captiveStatusChanged", [_unit, _state, "SetHandcuffed", _caller]] call CBA_fnc_globalEvent;
|