ACE3/addons/captives/functions/fnc_setHandcuffed.sqf

67 lines
2.1 KiB
Plaintext
Raw Normal View History

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>
*
* Return Value:
* Nothing
*
* Example:
2015-02-06 23:03:56 +00:00
* [bob, true] call ACE_captives_fnc_setHandcuffed;
2015-02-03 02:04:50 +00:00
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_unit,_state);
2015-02-07 04:24:27 +00:00
// We only want this function to work on local machines
if (!local _unit) exitwith {
[_this, QUOTE(FUNC(setHandcuffed)), _unit] call EFUNC(common,execRemoteFnc);
TRACE_2("running setHandcuffed on remote unit",_unit,_state);
2015-02-05 22:39:45 +00:00
};
2015-02-03 02:04:50 +00:00
2015-02-07 04:24:27 +00:00
if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) then {
LOG("setHandcuffed: current state same as new");
2015-02-05 22:39:45 +00:00
};
if (_state) then {
_unit setVariable [QGVAR(isHandcuffed), true, true];
if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop
2015-02-16 00:19:01 +00:00
[_unit, false] call FUNC(surrender);
};
2015-02-06 09:38:27 +00:00
[_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
2015-02-07 04:24:27 +00:00
_unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true];
if (_unit == ACE_player) then {
showHUD false;
};
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-02-06 09:38:27 +00:00
PARAMS_1(_unit);
if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then {
[_unit] call EFUNC(common,fixLoweredRifleAnimation);
2015-02-07 04:24:27 +00:00
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
2015-02-04 05:13:44 +00:00
};
2015-02-07 04:24:27 +00:00
}, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute);
2015-02-03 02:04:50 +00:00
} else {
2015-02-05 22:39:45 +00:00
_unit setVariable [QGVAR(isHandcuffed), false, true];
2015-02-06 09:38:27 +00:00
[_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus);
if ((vehicle _unit) == _unit) then {
2015-02-07 04:24:27 +00:00
//Break out of hands up animation loop (doAnimation handles Unconscious prioity)
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 {
showHUD true;
};
2015-02-03 02:04:50 +00:00
};