Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 (!alive ace_player) exitWith {};
if (!isNil QGVAR(temporaryBlockFireEH)) exitWith {}; // if in-progress temporary block already exists, don't create another one
Comment thread
PabstMirror marked this conversation as resolved.
Outdated

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
Loading