From 181991ad32939ea7c4129bad1f5a8490b13ff634 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:32:23 +0200 Subject: [PATCH] Stop selecting weapons when setting safemode --- addons/safemode/functions/fnc_lockSafety.sqf | 11 ++++++++--- addons/safemode/functions/fnc_unlockSafety.sqf | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/safemode/functions/fnc_lockSafety.sqf b/addons/safemode/functions/fnc_lockSafety.sqf index 28adb42df91..798a66cbf77 100644 --- a/addons/safemode/functions/fnc_lockSafety.sqf +++ b/addons/safemode/functions/fnc_lockSafety.sqf @@ -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 @@ -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]; @@ -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 { diff --git a/addons/safemode/functions/fnc_unlockSafety.sqf b/addons/safemode/functions/fnc_unlockSafety.sqf index 97716025dc6..9d4897f9a52 100644 --- a/addons/safemode/functions/fnc_unlockSafety.sqf +++ b/addons/safemode/functions/fnc_unlockSafety.sqf @@ -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]; @@ -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 {