From 51e83ba0fa1046f4218c05c625cb691bd38a267b Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 9 Jun 2015 18:52:12 +0200 Subject: [PATCH] Handle kileld and disconnect while sitting --- addons/sitting/CfgEventHandlers.hpp | 9 ++++++- addons/sitting/XEH_clientInit.sqf | 4 ++++ addons/sitting/XEH_preInit.sqf | 1 + .../sitting/functions/fnc_handleInterrupt.sqf | 24 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 addons/sitting/functions/fnc_handleInterrupt.sqf diff --git a/addons/sitting/CfgEventHandlers.hpp b/addons/sitting/CfgEventHandlers.hpp index c19217fb29..1e804e8cc9 100644 --- a/addons/sitting/CfgEventHandlers.hpp +++ b/addons/sitting/CfgEventHandlers.hpp @@ -4,9 +4,16 @@ class Extended_PreInit_EventHandlers { }; }; - class Extended_PostInit_EventHandlers { class ADDON { clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); }; }; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call DFUNC(handleInterrupt)); + }; + }; +}; diff --git a/addons/sitting/XEH_clientInit.sqf b/addons/sitting/XEH_clientInit.sqf index bbe81b27c7..eea6e7108c 100644 --- a/addons/sitting/XEH_clientInit.sqf +++ b/addons/sitting/XEH_clientInit.sqf @@ -1,3 +1,7 @@ #include "script_component.hpp" +// Add interaction menu exception ["isNotSitting", {!((_this select 0) getVariable [QGVAR(isSitting), false])}] call EFUNC(common,addCanInteractWithCondition); + +// Handle falling unconscious +["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler); diff --git a/addons/sitting/XEH_preInit.sqf b/addons/sitting/XEH_preInit.sqf index ced588299a..86912ada6b 100644 --- a/addons/sitting/XEH_preInit.sqf +++ b/addons/sitting/XEH_preInit.sqf @@ -5,6 +5,7 @@ ADDON = false; PREP(canSit); PREP(canStand); PREP(getRandomAnimation); +PREP(handleInterrupt); PREP(moduleInit); PREP(sit); PREP(stand); diff --git a/addons/sitting/functions/fnc_handleInterrupt.sqf b/addons/sitting/functions/fnc_handleInterrupt.sqf new file mode 100644 index 0000000000..81ed96d005 --- /dev/null +++ b/addons/sitting/functions/fnc_handleInterrupt.sqf @@ -0,0 +1,24 @@ +/* + * Author: Jonpas + * Handles interruptions of sitting, like killed or unconsciousness. + * + * Arguments: + * 0: Player + * + * Return Value: + * None + * + * Example: + * [player] call ace_sitting_fnc_handleInterrupt; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_1(_player); + +if (_player getVariable [QGVAR(isSitting), false]) then { + _player setVariable [QGVAR(isSitting), nil]; + GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true]; + QGVAR(seat) = nil; +};