From 075e9953e71ecb0c28315b9c3889d3aa1652aae9 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 6 Apr 2026 23:11:33 -0500 Subject: [PATCH 1/3] Medical Gui - Prevent firing on sudden menu close --- addons/common/XEH_PREP.hpp | 1 + .../functions/fnc_temporaryBlockFire.sqf | 34 +++++++++++++++++++ addons/medical_gui/functions/fnc_menuPFH.sqf | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 addons/common/functions/fnc_temporaryBlockFire.sqf diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index db068cf1375..f94835a98f7 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -197,6 +197,7 @@ PREP(swayLoop); PREP(switchAttachmentMode); PREP(switchPersistentLaser); PREP(switchToGroupSide); +PREP(temporaryBlockFire); PREP(throttledPublicVariable); PREP(toBin); PREP(toBitmask); diff --git a/addons/common/functions/fnc_temporaryBlockFire.sqf b/addons/common/functions/fnc_temporaryBlockFire.sqf new file mode 100644 index 00000000000..513f6d4d273 --- /dev/null +++ b/addons/common/functions/fnc_temporaryBlockFire.sqf @@ -0,0 +1,34 @@ +#include "..\script_component.hpp" +/* + * Author: PabstMirror + * Temporarily blocks firing of a weapon for player for a specified duration. + * + * Arguments: + * 0: Duration (seconds) (default: 1) + * + * Return Value: + * None + * + * Example: + * [1] call ace_common_fnc_temporaryBlockFire + * + * Public: Yes + */ + +params [["_duration", 1, [0]]]; + +if (!alive ace_player) exitWith {}; +if (!isNil QGVAR(temporaryBlockFireEH)) exitWith {}; // if in-progress temporary block already exists, don't create another one + +private _firedEH = [ACE_player, "DefaultAction", {true}, {true}] call FUNC(addActionEventHandler); +GVAR(temporaryBlockFireEH) = [ace_player, _firedEH]; +TRACE_2("Blocking fire",ace_player,_firedEH); + +[{ + GVAR(temporaryBlockFireEH) params ["_player", "_firedEH"]; + TRACE_2("Unblocking fire",_player,_firedEH); + if (isNull _player) exitWith {}; + [_player, "DefaultAction", _firedEH] call FUNC(removeActionEventHandler); + GVAR(temporaryBlockFireEH) = nil; +}, [], _duration] call CBA_fnc_waitAndExecute; + diff --git a/addons/medical_gui/functions/fnc_menuPFH.sqf b/addons/medical_gui/functions/fnc_menuPFH.sqf index 0e213eaf5ec..e4594c57a49 100644 --- a/addons/medical_gui/functions/fnc_menuPFH.sqf +++ b/addons/medical_gui/functions/fnc_menuPFH.sqf @@ -27,6 +27,8 @@ if !( [[ELSTRING(medical,DistanceToFar), GVAR(target) call EFUNC(common,getName)], 2] call EFUNC(common,displayTextStructured); }; + + [0.5] call EFUNC(common,temporaryBlockFire); // prevent firing from sudden menu closure }; // Get the Medical Menu display From d051390cf86e34cb514df86435e38b6db7ec9323 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 8 May 2026 12:03:20 -0500 Subject: [PATCH 2/3] Apply suggestion from @DartRuffian Co-authored-by: Dart <59131299+DartRuffian@users.noreply.github.com> --- addons/common/functions/fnc_temporaryBlockFire.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/functions/fnc_temporaryBlockFire.sqf b/addons/common/functions/fnc_temporaryBlockFire.sqf index 513f6d4d273..2a0312107da 100644 --- a/addons/common/functions/fnc_temporaryBlockFire.sqf +++ b/addons/common/functions/fnc_temporaryBlockFire.sqf @@ -17,8 +17,8 @@ params [["_duration", 1, [0]]]; -if (!alive ace_player) exitWith {}; -if (!isNil QGVAR(temporaryBlockFireEH)) exitWith {}; // if in-progress temporary block already exists, don't create another one +// If in-progress temporary block already exists, don't create another one +if (!alive ace_player || !isNil QGVAR(temporaryBlockFireEH)) exitWith {}; private _firedEH = [ACE_player, "DefaultAction", {true}, {true}] call FUNC(addActionEventHandler); GVAR(temporaryBlockFireEH) = [ace_player, _firedEH]; From e7cb14cb93dbf2387e2bbdc830ebb026495d057a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 8 May 2026 19:02:55 -0500 Subject: [PATCH 3/3] add to focus switch on uncon-wakeup --- addons/medical_status/functions/fnc_setUnconsciousState.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/medical_status/functions/fnc_setUnconsciousState.sqf b/addons/medical_status/functions/fnc_setUnconsciousState.sqf index b66b08078b9..9a36ce8cea6 100644 --- a/addons/medical_status/functions/fnc_setUnconsciousState.sqf +++ b/addons/medical_status/functions/fnc_setUnconsciousState.sqf @@ -74,6 +74,7 @@ if (_active) then { if (_unit == ACE_player) then { switch EGVAR(medical,windowOnWakeUp) do { case 1: { // Focus + [0.5] call EFUNC(common,temporaryBlockFire); // prevent firing from surprise context switch "ace" callExtension ["window:focus", []]; }; case 2: { // Flash