From 3f32627d617572c6ece079ca6d215d55bb90a9cd Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 10 Mar 2015 11:08:15 -0500 Subject: [PATCH] Implement Unconc Event Handler --- addons/captives/XEH_postInit.sqf | 11 ++---- addons/captives/XEH_preInit.sqf | 3 +- .../functions/fnc_handleKnockedOut.sqf | 25 ------------- .../functions/fnc_handleOnUnconscious.sqf | 36 +++++++++++++++++++ .../captives/functions/fnc_handleWokeUp.sqf | 23 ------------ 5 files changed, 39 insertions(+), 59 deletions(-) delete mode 100644 addons/captives/functions/fnc_handleKnockedOut.sqf create mode 100644 addons/captives/functions/fnc_handleOnUnconscious.sqf delete mode 100644 addons/captives/functions/fnc_handleWokeUp.sqf diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index ac86d71915..7b06770fd3 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -27,12 +27,5 @@ if (isServer) then { ["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler); ["SetSurrendered", {_this call FUNC(setSurrendered)}] call EFUNC(common,addEventHandler); -//TODO: Medical Integration Events??? - -// [_unit, "knockedOut", { -// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleKnockedOut}; -// }] call ACE_Core_fnc_addCustomEventhandler; - -// [_unit, "wokeUp", { -// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleWokeUp}; -// }] call ACE_Core_fnc_addCustomEventhandler; +//Medical Integration Events??? +["medical_onUnconscious", {_this call ACE_Captives_fnc_handleOnUnconscious}] call EFUNC(common,addEventHandler); diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index 34c9bca910..c09f81e51b 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -19,10 +19,9 @@ PREP(doUnloadCaptive); PREP(handleGetIn); PREP(handleGetOut); PREP(handleKilled); -PREP(handleKnockedOut); +PREP(handleOnUnconscious); PREP(handlePlayerChanged); PREP(handleUnitInitPost); -PREP(handleWokeUp); PREP(handleZeusDisplayChanged); PREP(moduleSurrender); PREP(setHandcuffed); diff --git a/addons/captives/functions/fnc_handleKnockedOut.sqf b/addons/captives/functions/fnc_handleKnockedOut.sqf deleted file mode 100644 index 1cd969807d..0000000000 --- a/addons/captives/functions/fnc_handleKnockedOut.sqf +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Author: commy2, PabstMirror - * Handles when a unit gets knocked out. Ends surrendering. - * - * Arguments: - * 0: Unit - * - * Return Value: - * Nothing - * - * Example: - * [bob, true] call ACE_captives_fnc_handleKnockedOut - * - * Public: No - */ -#include "script_component.hpp" - - -//ToDo: Waiting on medical integration - -PARAMS_1(_unit); - -if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop - [_unit, false] call FUNC(setSurrendered); -}; diff --git a/addons/captives/functions/fnc_handleOnUnconscious.sqf b/addons/captives/functions/fnc_handleOnUnconscious.sqf new file mode 100644 index 0000000000..9b73d34485 --- /dev/null +++ b/addons/captives/functions/fnc_handleOnUnconscious.sqf @@ -0,0 +1,36 @@ +/* + * Author: commy2, PabstMirror + * Handles the "medical_onUnconscious" event + * + * Arguments: + * 0: Unit + * 0: Is Unconsisisiouses + * + * Return Value: + * Nothing + * + * Example: + * [bob, true] call ACE_captives_fnc_handleOnUnconscious + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_unit,_isUnconc); + +if (!local _unit) exitWith {}; + +systemChat format ["med: %1", _this]; + +if (_isUnconc) then { + //Knocked out: If surrendering, stop + if (_unit getVariable [QGVAR(isSurrendering), false]) then { + [_unit, false] call FUNC(setSurrendered); + }; +} else { + //Woke up: if handcuffed, goto animation + if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { + [_unit] call EFUNC(common,fixLoweredRifleAnimation); + [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + }; +}; diff --git a/addons/captives/functions/fnc_handleWokeUp.sqf b/addons/captives/functions/fnc_handleWokeUp.sqf deleted file mode 100644 index 9bf2e1a2bc..0000000000 --- a/addons/captives/functions/fnc_handleWokeUp.sqf +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Author: commy2 - * TODO - * - * Arguments: - * 0: _unit - * - * Return Value: - * The return value - * - * Example: - * [bob] call ACE_captives_fnc_handleWokeUp - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_1(_unit); - -if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { - [_unit] call EFUNC(common,fixLoweredRifleAnimation); - [_unit, "ACE_AmovPercMstpScapWnonDnon", 0] call EFUNC(common,doAnimation); -};