diff --git a/addons/captives/CfgEventHandlers.hpp b/addons/captives/CfgEventHandlers.hpp index 9d1a69f4fd..4d12dc10c4 100644 --- a/addons/captives/CfgEventHandlers.hpp +++ b/addons/captives/CfgEventHandlers.hpp @@ -25,14 +25,6 @@ class Extended_GetOut_EventHandlers { }; }; }; -//reset captivity and escorting status when getting killed -class Extended_Killed_EventHandlers { - class CAManBase { - class GVAR(AutoDetachCaptive) { - killed = QUOTE(_this call FUNC(handleKilled)); - }; - }; -}; //mission start class Extended_InitPost_EventHandlers { class CAManBase { diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index d2b5b615bb..b59249b937 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -19,7 +19,6 @@ PREP(doUnloadCaptive); PREP(findEmptyNonFFVCargoSeat); PREP(handleGetIn); PREP(handleGetOut); -PREP(handleKilled); PREP(handleOnUnconscious); PREP(handlePlayerChanged); PREP(handleRespawn); diff --git a/addons/captives/functions/fnc_handleKilled.sqf b/addons/captives/functions/fnc_handleKilled.sqf deleted file mode 100644 index f7b15ec117..0000000000 --- a/addons/captives/functions/fnc_handleKilled.sqf +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Author: PabstMirror - * Handles when a unit is kill. Reset captivity and escorting status - * - * Arguments: - * 0: _oldUnit - * - * Return Value: - * None - * - * Example: - * [bob1] call ACE_captives_fnc_handleKilled - * - * Public: No - */ -#include "script_component.hpp" - -params ["_oldUnit"]; - -if (!local _oldUnit) exitWith {}; - -if (_oldUnit getVariable [QGVAR(isHandcuffed), false]) then { - [_oldUnit, false] call FUNC(setHandcuffed); -}; - -if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { - _oldUnit setVariable [QGVAR(isEscorting), false, true]; -}; - -if (_oldUnit getVariable [QGVAR(isSurrendering), false]) then { - [_oldUnit, false] call FUNC(setSurrendered); -}; diff --git a/addons/captives/functions/fnc_handleRespawn.sqf b/addons/captives/functions/fnc_handleRespawn.sqf index 6f68aea2fe..7e97501576 100644 --- a/addons/captives/functions/fnc_handleRespawn.sqf +++ b/addons/captives/functions/fnc_handleRespawn.sqf @@ -20,20 +20,34 @@ params ["_unit","_dead"]; if (!local _unit) exitWith {}; -//With respawn="group", we could be respawning into a unit that is handcuffed/captive -//If they are, reset and rerun the SET function -//if not, make sure to explicity disable the setCaptivityStatus, because captiveNum does not work correctly on respawn +// Group and side respawn can potentially respawn you as a captive unit +// Base and instant respawn cannot, so captive should be entirely reset +// So we explicity account for the respawn type +private ["_respawn"]; +_respawn = [0] call BIS_fnc_missionRespawnType; -if (_unit getVariable [QGVAR(isHandcuffed), false]) then { - _unit setVariable [QGVAR(isHandcuffed), false]; - [_unit, true] call FUNC(setHandcuffed); +if (_respawn > 3) then { + if (_unit getVariable [QGVAR(isHandcuffed), false]) then { + _unit setVariable [QGVAR(isHandcuffed), false]; + [_unit, true] call FUNC(setHandcuffed); + }; + + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + _unit setVariable [QGVAR(isSurrendering), false]; + [_unit, true] call FUNC(setSurrendered); + }; } else { + if (_unit getVariable [QGVAR(isHandcuffed), false]) then { + [_unit, false] call FUNC(setHandcuffed); + }; [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); -}; -if (_unit getVariable [QGVAR(isSurrendering), false]) then { - _unit setVariable [QGVAR(isSurrendering), false]; - [_unit, true] call FUNC(setSurrendered); -} else { + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + [_unit, false] call FUNC(setSurrendered); + }; [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + + if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { + _oldUnit setVariable [QGVAR(isEscorting), false, true]; + }; };