Skip to content
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

Safemode - Stop selecting weapons when toggling safemode #10406

Merged
merged 1 commit into from
Oct 13, 2024
Merged
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
11 changes: 8 additions & 3 deletions addons/safemode/functions/fnc_lockSafety.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Author: commy2, johnb43
* Puts weapon on safety, or take it off safety if safety is already put on.
* Puts weapon on safety, or takes it off safety if safety is already put on.
*
* Arguments:
* 0: Unit <OBJECT>
Expand Down Expand Up @@ -36,10 +36,13 @@ if (_muzzle in _safedWeaponMuzzles) exitWith {
[_unit, _weapon, _muzzle, _hint] call FUNC(unlockSafety);
};

private _weaponSelected = currentWeapon _unit == _weapon;
private _firemode = (_unit weaponState _muzzle) select 2;

// This syntax of selectWeapon doesn't mess with gun lights and lasers
_unit selectWeapon [_weapon, _muzzle, _firemode];
if (_weaponSelected) then {
_unit selectWeapon [_weapon, _muzzle, _firemode];
};

// Store new muzzle & firemode
_safedWeaponMuzzles set [_muzzle, _firemode];
Expand Down Expand Up @@ -83,7 +86,9 @@ if (isNil {_unit getVariable QGVAR(actionID)}) then {
};

// Play fire mode selector sound
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
if (_weaponSelected) then {
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
};

// Show info box unless disabled
if (_hint) then {
Expand Down
8 changes: 6 additions & 2 deletions addons/safemode/functions/fnc_unlockSafety.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ if (_safedWeaponMuzzles isEqualTo createHashMap) then {
};
};

private _weaponSelected = currentWeapon _unit == _weapon;

// Let engine handle switching to next firemode/muzzle
if (inputAction "nextWeapon" == 0 && {inputAction "prevWeapon" == 0}) then {
if (_weaponSelected && {inputAction "nextWeapon" == 0} && {inputAction "prevWeapon" == 0}) then {
// This syntax of selectWeapon doesn't mess with gun lights and lasers
_unit selectWeapon [_weapon, _muzzle, _firemode];

Expand All @@ -46,7 +48,9 @@ if (inputAction "nextWeapon" == 0 && {inputAction "prevWeapon" == 0}) then {
};

// Player HUD
true call FUNC(setSafeModeVisual);
if (_weaponSelected) then {
true call FUNC(setSafeModeVisual);
};

// Show info box unless disabled
if (_hint) then {
Expand Down
Loading