diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index b4a120bc22..8bd97b0b58 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -7,6 +7,7 @@ class CfgVehicles { distance = 4; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canApplyHandcuffs)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(doApplyHandcuffs)); + exceptions[] = {}; showDisabled = 0; priority = 2.4; icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); @@ -17,7 +18,7 @@ class CfgVehicles { distance = 4; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canRemoveHandcuffs)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(doRemoveHandcuffs)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; + exceptions[] = {}; showDisabled = 0; priority = 2.4; icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); @@ -27,8 +28,8 @@ class CfgVehicles { displayName = "$STR_ACE_Captives_EscortCaptive"; distance = 4; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canEscortCaptive)); - statement = QUOTE([ARR_3(_target, _target, true)] call FUNC(doEscortCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; + statement = QUOTE([ARR_3(_player, _target, true)] call FUNC(doEscortCaptive)); + exceptions[] = {}; showDisabled = 0; icon = QUOTE(PATHTOF(UI\captive_ca.paa)); priority = 2.3; @@ -39,7 +40,7 @@ class CfgVehicles { distance = 4; condition = QUOTE([ARR_2(_player, _target)] call FUNC(canStopEscorting)); statement = QUOTE([ARR_3(_player,_target, false)] call FUNC(doEscortCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; + exceptions[] = {QGVAR(isNotEscorting)}; showDisabled = 0; icon = QUOTE(PATHTOF(UI\captive_ca.paa)); priority = 2.3; @@ -50,7 +51,7 @@ class CfgVehicles { distance = 4; condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive)); statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(loadCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; + exceptions[] = {QGVAR(isNotEscorting)}; showDisabled = 0; icon = QUOTE(PATHTOF(UI\captive_ca.paa)); priority = 2.2; @@ -73,7 +74,7 @@ class CfgVehicles { displayName = "$STR_ACE_Captives_StopEscorting"; condition = QUOTE([ARR_2(_player, objNull)] call FUNC(canStopEscorting)); statement = QUOTE([ARR_3(_player,objNull, false)] call FUNC(doEscortCaptive)); - exceptions[] = {"ACE_Interaction_isNotEscorting"}; + exceptions[] = {QGVAR(isNotEscorting)}; showDisabled = 0; priority = 2.3; hotkey = "C"; @@ -82,7 +83,7 @@ class CfgVehicles { displayName = "$STR_ACE_Captives_LoadCaptive"; condition = "[_player, objNull, objNull] call ACE_Captives_fnc_canLoadCaptiveIntoVehicle"; statement = "[_player, objNull, objNull] call ACE_Captives_fnc_loadCaptiveIntoVehicle"; - exceptions[] = {"ACE_Interaction_isNotEscorting"}; + exceptions[] = {QGVAR(isNotEscorting)}; showDisabled = 0; priority = 2.2; hotkey = "K"; @@ -97,7 +98,7 @@ class CfgVehicles { distance = 4; \ condition = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(canLoadCaptive)); \ statement = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(loadCaptive)); \ - exceptions[] = {"ACE_Interaction_isNotEscorting"}; \ + exceptions[] = {QGVAR(isNotEscorting)}; \ showDisabled = 0; \ priority = 1.2; \ hotkey = "L"; \ diff --git a/addons/captives/functions/fnc_canEscortCaptive.sqf b/addons/captives/functions/fnc_canEscortCaptive.sqf index 9bcb1d258a..2d2fd5abe4 100644 --- a/addons/captives/functions/fnc_canEscortCaptive.sqf +++ b/addons/captives/functions/fnc_canEscortCaptive.sqf @@ -18,6 +18,8 @@ PARAMS_2(_unit,_target); +//Alive, handcuffed, not being escored, and not unconsious + (_target getVariable [QGVAR(isHandcuffed), false]) && {isNull (attachedTo _target)} && {alive _target} && diff --git a/addons/captives/functions/fnc_canStopEscorting.sqf b/addons/captives/functions/fnc_canStopEscorting.sqf index 66cf12c9fc..bb48244a25 100644 --- a/addons/captives/functions/fnc_canStopEscorting.sqf +++ b/addons/captives/functions/fnc_canStopEscorting.sqf @@ -23,7 +23,7 @@ private ["_isAttached"]; if (isNull _target) then { - _target = _unit getVariable ["ACE_escortedUnit", objNull]; + _target = _unit getVariable [QGVAR(escortedUnit), objNull]; }; if (isNull _target) exitWith { diff --git a/addons/captives/functions/fnc_doEscortCaptive.sqf b/addons/captives/functions/fnc_doEscortCaptive.sqf index d782bd8c62..72a0cd0c6c 100644 --- a/addons/captives/functions/fnc_doEscortCaptive.sqf +++ b/addons/captives/functions/fnc_doEscortCaptive.sqf @@ -19,38 +19,37 @@ PARAMS_3(_unit,_target,_state); -if !("ACE_Handcuffed" in ([_target] call EFUNC(common,getCaptivityStatus))) exitWith { - [localize "STR_ACE_Captives_NoCaptive"] call EFUNC(common,displayTextStructured); -}; - if (_state) then { - if (_unit getVariable [QGVAR(isEscorting), false]) exitWith {}; + if (_unit getVariable [QGVAR(isEscorting), false]) exitWith {}; - [_unit, _target] call EFUNC(common,claim); - _unit setVariable [QGVAR(isEscorting), true, true]; + [_unit, _target] call EFUNC(common,claim); + _unit setVariable [QGVAR(isEscorting), true, true]; - _target attachTo [_unit, [0, 1, 0]]; + _target attachTo [_unit, [0, 1, 0]]; - _unit setVariable ["ACE_escortedUnit", _target, true]; - _actionID = _unit addAction [format ["%1", localize "STR_ACE_Captives_StopEscorting"], "[_unit getVariable ['ACE_escortedUnit', objNull], false] call ACE_Captives_fnc_escortCaptive;", nil, 20, false, true, "", "!isNull (_unit getVariable ['ACE_escortedUnit', objNull])"]; + _unit setVariable [QGVAR(escortedUnit), _target, true]; - [_target, _actionID] spawn { - _target = _this select 0; - _actionID = _this select 1; + //Add Actionmenu to release captive + _actionID = _unit addAction [format ["%1", localize "STR_ACE_Captives_StopEscorting"], + {[(_this select 0), ((_this select 0) getVariable [QGVAR(escortedUnit), objNull]), false] call FUNC(doEscortCaptive);}, + nil, 20, false, true, "", QUOTE(!isNull (GETVAR(_target,QGVAR(escortedUnit),objNull)))]; - while {_unit getVariable [QGVAR(isEscorting), false]} do { - sleep 0.2; + [_unit, _target, _actionID] spawn { + PARAMS_3(_unit,_target,_actionID); - if (!alive _target || {!alive _unit} || {!canStand _target} || {!canStand _unit} || {_target getVariable ["ACE_isUnconscious", false]} || {_unit getVariable ["ACE_isUnconscious", false]} || {!isNull (attachedTo _unit)}) then { - _unit setVariable [QGVAR(isEscorting), false, true]; - }; + while {_unit getVariable [QGVAR(isEscorting), false]} do { + sleep 0.2; + + if (!alive _target || {!alive _unit} || {!canStand _target} || {!canStand _unit} || {_target getVariable ["ACE_isUnconscious", false]} || {_unit getVariable ["ACE_isUnconscious", false]} || {!isNull (attachedTo _unit)}) then { + _unit setVariable [QGVAR(isEscorting), false, true]; + }; + }; + [objNull, _target] call EFUNC(common,claim); + + detach _target; + _unit removeAction _actionID; }; - [objNull, _target] call EFUNC(common,claim); - - detach _target; - _unit removeAction _actionID; - }; } else { - _unit setVariable [QGVAR(isEscorting), false, true]; - _unit setVariable ["ACE_escortedUnit", objNull, true]; + _unit setVariable [QGVAR(isEscorting), false, true]; + _unit setVariable [QGVAR(escortedUnit), objNull, true]; }; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 94967dfb20..c28a26909f 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -18,14 +18,11 @@ PARAMS_2(_unit,_state); -systemChat format ["set %1", _this]; if (!local _unit) exitWith { ERROR("setHandcuffed unit not local"); }; -systemChat format ["set %1 %2 ", _state, (_unit getVariable [QGVAR(isHandcuffed), false])]; - if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) exitWith { ERROR("new state equals current"); }; @@ -50,7 +47,7 @@ if (_state) then { }; } else { _unit setVariable [QGVAR(isHandcuffed), false, true]; - [_unit, "ACE_Handcuffed", false] call EFUNC(common,setCaptivityStatus); + [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); if (vehicle _unit == _unit) then { [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); }; diff --git a/addons/interaction/XEH_clientInit.sqf b/addons/interaction/XEH_clientInit.sqf index bcc3f47def..71be601ac7 100644 --- a/addons/interaction/XEH_clientInit.sqf +++ b/addons/interaction/XEH_clientInit.sqf @@ -20,7 +20,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenu", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(isNull (findDisplay 1713999)) exitWith {false}; @@ -38,7 +38,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenu", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false}; @@ -56,7 +56,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenuSelf", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(isNull (findDisplay 1713999)) exitWith {false}; @@ -74,7 +74,7 @@ GVAR(isOpeningDoor) = false; localize "STR_ACE_Interaction_InteractionMenuSelf", { // Conditions: canInteract - _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", "ACE_Interaction_isNotEscorting", "ACE_Interaction_isNotSwimming"]; + _exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"]; if !(_exceptions call EGVAR(common,canInteract)) exitWith {false}; // Conditions: specific if !(!isNull (findDisplay 1713999) && {profileNamespace getVariable [QGVAR(AutoCloseMenu), 0] > 0}) exitWith {false};