From 811530f18000eae5b1dc47b455236f0aad84ad7e Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 26 Mar 2015 00:53:02 -0500 Subject: [PATCH 1/3] Ensure captiveNum is reset for respawning unit --- addons/captives/CfgEventHandlers.hpp | 8 ++++++ addons/captives/XEH_preInit.sqf | 1 + .../captives/functions/fnc_handleRespawn.sqf | 25 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 addons/captives/functions/fnc_handleRespawn.sqf diff --git a/addons/captives/CfgEventHandlers.hpp b/addons/captives/CfgEventHandlers.hpp index 0ce09280a7..9d1a69f4fd 100644 --- a/addons/captives/CfgEventHandlers.hpp +++ b/addons/captives/CfgEventHandlers.hpp @@ -41,3 +41,11 @@ class Extended_InitPost_EventHandlers { }; }; }; +//make sure captiveNum is reset on respawn +class Extended_Respawn_EventHandlers { + class CAManBase { + class ADDON { + respawn = QUOTE(_this call FUNC(handleRespawn)); + }; + }; +}; diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index c09f81e51b..bc6a61bc4f 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -21,6 +21,7 @@ PREP(handleGetOut); PREP(handleKilled); PREP(handleOnUnconscious); PREP(handlePlayerChanged); +PREP(handleRespawn); PREP(handleUnitInitPost); PREP(handleZeusDisplayChanged); PREP(moduleSurrender); diff --git a/addons/captives/functions/fnc_handleRespawn.sqf b/addons/captives/functions/fnc_handleRespawn.sqf new file mode 100644 index 0000000000..fe2bc0a968 --- /dev/null +++ b/addons/captives/functions/fnc_handleRespawn.sqf @@ -0,0 +1,25 @@ +/* + * Author: commy2 PabstMirror + * Fix, because captiveNum doesn't reset properly on respawn + * + * Arguments: + * 0: Unit + * 1: Corpse + * + * Return Value: + * Nothing + * + * Example: + * [alive, body] call ACE_captives_fnc_handleRespawn; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_dead); + +if (!local _unit) exitWith {}; + +[_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); +[_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + From d4d0a0a6de53f9f688eaaf6d05d856371ec0c72e Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 26 Mar 2015 00:53:38 -0500 Subject: [PATCH 2/3] Make sure to remove animEH --- addons/captives/functions/fnc_handleKilled.sqf | 4 ++-- addons/captives/functions/fnc_handleRespawn.sqf | 1 - addons/captives/functions/fnc_setSurrendered.sqf | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/captives/functions/fnc_handleKilled.sqf b/addons/captives/functions/fnc_handleKilled.sqf index 9e9c5e1ac8..720bde9df7 100644 --- a/addons/captives/functions/fnc_handleKilled.sqf +++ b/addons/captives/functions/fnc_handleKilled.sqf @@ -18,7 +18,7 @@ PARAMS_1(_oldUnit); if (_oldUnit getVariable [QGVAR(isHandcuffed), false]) then { - _oldUnit setVariable [QGVAR(isHandcuffed), false, true]; + [_oldUnit, false] call FUNC(setSurrendered); }; if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { @@ -26,5 +26,5 @@ if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { }; if (_oldUnit getVariable [QGVAR(isSurrendering), false]) then { - _oldUnit setVariable [QGVAR(isSurrendering), false, true]; + [_oldUnit, false] call FUNC(setSurrendered); }; diff --git a/addons/captives/functions/fnc_handleRespawn.sqf b/addons/captives/functions/fnc_handleRespawn.sqf index fe2bc0a968..8a475f860d 100644 --- a/addons/captives/functions/fnc_handleRespawn.sqf +++ b/addons/captives/functions/fnc_handleRespawn.sqf @@ -22,4 +22,3 @@ if (!local _unit) exitWith {}; [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); - diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index 3a7436abc7..73451863dd 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -75,6 +75,7 @@ if (_state) then { }; }; + if (!alive _unit) exitWith {}; if (_unit getVariable ["ACE_isUnconscious", false]) exitWith {}; //don't touch animations if unconscious //if we are in "hands up" animationState, crack it now From 14cbceef9755e9ee4e1cafe46f07f15e65b145b0 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 26 Mar 2015 14:21:26 -0500 Subject: [PATCH 3/3] Rerun set func when respawn into captive unit --- .../captives/functions/fnc_handleRespawn.sqf | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/addons/captives/functions/fnc_handleRespawn.sqf b/addons/captives/functions/fnc_handleRespawn.sqf index 8a475f860d..02888c27a0 100644 --- a/addons/captives/functions/fnc_handleRespawn.sqf +++ b/addons/captives/functions/fnc_handleRespawn.sqf @@ -20,5 +20,20 @@ PARAMS_2(_unit,_dead); if (!local _unit) exitWith {}; -[_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); -[_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); +//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 + +if (_unit getVariable [QGVAR(isHandcuffed), false]) then { + _unit setVariable [QGVAR(isHandcuffed), false]; + [_unit, true] call FUNC(setHandcuffed); +} else { + [_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 { + [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); +};