-
Notifications
You must be signed in to change notification settings - Fork 758
Medical Gui - Prevent firing on sudden menu close #11344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| 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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.