Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ PREP(swayLoop);
PREP(switchAttachmentMode);
PREP(switchPersistentLaser);
PREP(switchToGroupSide);
PREP(temporaryBlockFire);
PREP(throttledPublicVariable);
PREP(toBin);
PREP(toBitmask);
Expand Down
34 changes: 34 additions & 0 deletions addons/common/functions/fnc_temporaryBlockFire.sqf
Original file line number Diff line number Diff line change
@@ -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) <NUMBER> (default: 1)
*
* Return Value:
* None
*
* Example:
* [1] call ace_common_fnc_temporaryBlockFire
*
* Public: Yes
*/

params [["_duration", 1, [0]]];

// 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];
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;

2 changes: 2 additions & 0 deletions addons/medical_gui/functions/fnc_menuPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[0.5] call EFUNC(common,temporaryBlockFire); // prevent firing from sudden menu closure
[0.5] call EFUNC(common,temporaryBlockFire); // prevent firing from sudden menu closure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During testing I found that I was often shooting despite this safeguard. I tried increasing it to 2 seconds just to test and was able to fire immediately upon menu closure, so it looks like it doesn't intercept all mouse events in time.

I think 0.5 seconds is not enough for me at least. You mentioned adding a setting - imo having a slider that would allow players to set the timeout themselves would be the best option, as it could also allow them to disable it.

};

// Get the Medical Menu display
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

@johnb432 johnb432 May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the likelihood of this actually doing something? Players are usually in the unconscious animation and need to unholster their weapon before they can shoot, which is longer than 0.5 seconds.

"ace" callExtension ["window:focus", []];
};
case 2: { // Flash
Expand Down
Loading