From dc77489a3900d730a5ab7b3918bdfdedefb831bb Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 8 Jul 2024 23:24:41 +0200 Subject: [PATCH 01/10] Refactor safemode --- addons/safemode/CfgEventHandlers.hpp | 1 - addons/safemode/XEH_PREP.hpp | 3 +- addons/safemode/XEH_postInit.sqf | 17 ++- addons/safemode/functions/fnc_lockSafety.sqf | 102 +++++++++++------- .../functions/fnc_playChangeFiremodeSound.sqf | 18 ++-- .../functions/fnc_setSafeModeVisual.sqf | 8 +- .../functions/fnc_setWeaponSafety.sqf | 16 +-- .../safemode/functions/fnc_unlockSafety.sqf | 92 +++++++--------- 8 files changed, 136 insertions(+), 121 deletions(-) diff --git a/addons/safemode/CfgEventHandlers.hpp b/addons/safemode/CfgEventHandlers.hpp index 6c29240403a..f6503c2479b 100644 --- a/addons/safemode/CfgEventHandlers.hpp +++ b/addons/safemode/CfgEventHandlers.hpp @@ -1,4 +1,3 @@ - class Extended_PreStart_EventHandlers { class ADDON { init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); diff --git a/addons/safemode/XEH_PREP.hpp b/addons/safemode/XEH_PREP.hpp index 2f23aa02c9e..9a4e2622014 100644 --- a/addons/safemode/XEH_PREP.hpp +++ b/addons/safemode/XEH_PREP.hpp @@ -1,6 +1,5 @@ - PREP(lockSafety); PREP(playChangeFiremodeSound); PREP(setSafeModeVisual); -PREP(unlockSafety); PREP(setWeaponSafety); +PREP(unlockSafety); diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf index db922f9b35d..2e168a60036 100644 --- a/addons/safemode/XEH_postInit.sqf +++ b/addons/safemode/XEH_postInit.sqf @@ -4,18 +4,25 @@ if (!hasInterface) exitWith {}; -["ACE3 Weapons", QGVAR(safeMode), localize LSTRING(SafeMode), { +["ACE3 Weapons", QGVAR(safeMode), LLSTRING(SafeMode), { // Conditions: canInteract if !([ACE_player, objNull, ["isNotEscorting", "isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false}; + + (weaponState ACE_player) params ["_currentWeapon", "_currentMuzzle"]; + // Conditions: specific - if !([ACE_player] call CBA_fnc_canUseWeapon && {currentWeapon ACE_player != binocular ACE_player} && {currentWeapon ACE_player != ""}) exitWith {false}; + if !(ACE_player call CBA_fnc_canUseWeapon && {_currentWeapon != ""} && {_currentWeapon != binocular ACE_player}) exitWith {false}; // Statement - [ACE_player, currentWeapon ACE_player, currentMuzzle ACE_player] call FUNC(lockSafety); + [ACE_player, _currentWeapon, _currentMuzzle] call FUNC(lockSafety); + true }, {false}, [DIK_GRAVE, [false, true, false]], false] call CBA_fnc_addKeybind; ["unit", { - private _weaponSafe = currentWeapon ACE_player in (ACE_player getVariable [QGVAR(safedWeapons), []]); - [!_weaponSafe] call FUNC(setSafeModeVisual); + (weaponState ACE_player) params ["_currentWeapon", "_currentMuzzle"]; + + private _weaponSafe = (((ACE_player getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, []]) findIf {_x select 0 == _currentMuzzle} != -1); + + !_weaponSafe call FUNC(setSafeModeVisual); }] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/safemode/functions/fnc_lockSafety.sqf b/addons/safemode/functions/fnc_lockSafety.sqf index 6c617c18989..bbbbb8d6adc 100644 --- a/addons/safemode/functions/fnc_lockSafety.sqf +++ b/addons/safemode/functions/fnc_lockSafety.sqf @@ -1,13 +1,13 @@ #include "..\script_component.hpp" /* - * Author: commy2 - * Put weapon on safety, or take it off safety if safety is already put on. + * Author: commy2, johnb43 + * Puts weapon on safety, or take it off safety if safety is already put on. * * Arguments: * 0: Unit * 1: Weapon * 2: Muzzle - * 3: Show hint + * 3: Show hint (default: true) * * Return Value: * None @@ -18,67 +18,89 @@ * Public: No */ -params ["_unit", "_weapon", "_muzzle", ["_hint", true, [true]]]; +params ["_unit", "_weapon", "_muzzle", ["_hint", true]]; -private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; +private _safedWeapons = _unit getVariable QGVAR(safedWeapons); -if (_weapon in _safedWeapons) exitWith { - _this call FUNC(unlockSafety); +if (isNil "_safedWeapons") then { + _safedWeapons = createHashMap; + + _unit setVariable [QGVAR(safedWeapons), _safedWeapons]; +}; + +_weapon = _weapon call EFUNC(common,baseWeapon); + +// See if the current weapon has locked muzzled +private _safedWeaponMuzzles = _safedWeapons getOrDefault [_weapon, [], true]; + +// If muzzle is locked, unlock it (toggle) +if (_safedWeaponMuzzles findIf {_x select 0 == _muzzle} != -1) exitWith { + [_unit, _weapon, _muzzle, _hint] call FUNC(unlockSafety); }; -_safedWeapons pushBack _weapon; +(_unit weaponState _muzzle) params ["_currentWeapon", "_currentMuzzle", "_firemode"]; + +// If selection is a different weapon or muzzle, take the first firemode available for new weapon/muzzle +if (_currentWeapon != _weapon || {_currentMuzzle != _muzzle}) then { + private _config = configFile >> "CfgWeapons" >> _weapon; -_unit setVariable [QGVAR(safedWeapons), _safedWeapons]; + if (_weapon != _muzzle) then { + _config = _config >> _muzzle; + }; + + _firemode = ((getArray (_config >> "modes")) select {getNumber (_config >> _x >> "showToPlayer") == 1}) param [0, ""]; + + // The alt syntax of selectWeapon doesn't mess with gun lights and lasers + _unit selectWeapon [_weapon, _muzzle, _firemode]; +}; + +// Store new muzzle & firemode +_safedWeaponMuzzles pushBack [_muzzle, _firemode]; -if (_unit getVariable [QGVAR(actionID), -1] == -1) then { +// Lock muzzle +if (isNil {_unit getVariable QGVAR(actionID)}) then { _unit setVariable [QGVAR(actionID), [ _unit, "DefaultAction", { + params ["", "_unit"]; + if ( - [_this select 1] call CBA_fnc_canUseWeapon - && { - if (currentMuzzle (_this select 1) in ((_this select 1) getVariable [QGVAR(safedWeapons), []])) then { + _unit call CBA_fnc_canUseWeapon && { + (weaponState _unit) params ["_currentWeapon", "_currentMuzzle"]; + + _currentWeapon = _currentWeapon call EFUNC(common,baseWeapon); + + // Block firing the muizzle in safe mode + if (((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, []]) findIf {_x select 0 == _currentMuzzle} != -1) then { if (inputAction "nextWeapon" > 0) exitWith { - [_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety); + [_unit, _currentWeapon, _currentMuzzle] call FUNC(unlockSafety); + false }; + true - } else {false} + } else { + false + } } ) then { - // player hud - [false] call FUNC(setSafeModeVisual); + // Player hud + false call FUNC(setSafeModeVisual); + true } else { - // player hud - [true] call FUNC(setSafeModeVisual); + // Player hud + true call FUNC(setSafeModeVisual); + false }; }, {} ] call EFUNC(common,addActionEventHandler)]; }; -if (_muzzle isEqualType "") then { - private _laserEnabled = _unit isIRLaserOn _weapon || {_unit isFlashlightOn _weapon}; - - _unit selectWeapon _muzzle; - - if ( - _laserEnabled - && { - _muzzle == primaryWeapon _unit // prevent UGL switch - || {"" == primaryWeapon _unit} // Arma switches to primary weapon if exists - } - ) then { - {_unit action [_x, _unit]} forEach ["GunLightOn", "IRLaserOn"]; - }; -}; - -// play fire mode selector sound +// Play fire mode selector sound [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound); -// show info box unless disabled +// Show info box unless disabled if (_hint) then { - private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); - [localize LSTRING(PutOnSafety), _picture] call EFUNC(common,displayTextPicture); + [LLSTRING(PutOnSafety), getText (configFile >> "CfgWeapons" >> _weapon >> "picture")] call EFUNC(common,displayTextPicture); }; - diff --git a/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf index 257e5864f6b..115da8d2fc0 100644 --- a/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf +++ b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: commy2 - * Play weapon firemode change sound. + * Plays weapon firemode change sound. * * Arguments: * 0: Unit @@ -21,21 +21,21 @@ params ["_unit", "_weapon"]; private _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound"); if (_sound isEqualTo []) exitWith { - playSound "ACE_Sound_Click"; + playSoundUI ["ACE_Sound_Click"]; }; -// get position where to play the sound (position of the weapon) -private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand"); - -_sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]]; +_sound params [["_filename", ""], ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]]; if (_filename == "") exitWith { - playSound "ACE_Sound_Click"; + playSoundUI ["ACE_Sound_Click"]; }; -// add file extension .wss as default +// Add file extension .wss as default if !(toLowerANSI (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then { _filename = format ["%1.wss", _filename]; }; -playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance]; +// Get position where to play the sound (position of the weapon) +private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand"); + +playSound3D [_filename, objNull, insideBuilding _unit >= 0.5, _position, _volume, _soundPitch, _distance]; diff --git a/addons/safemode/functions/fnc_setSafeModeVisual.sqf b/addons/safemode/functions/fnc_setSafeModeVisual.sqf index d62a542b9d7..12b7f864ef3 100644 --- a/addons/safemode/functions/fnc_setSafeModeVisual.sqf +++ b/addons/safemode/functions/fnc_setSafeModeVisual.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: commy2 - * Show firemode indicator, representing safety lock + * Shows firemode indicator, representing safety lock. * * Arguments: * 0: Show firemode @@ -10,7 +10,7 @@ * None * * Example: - * [true] call ace_safemode_fnc_setSafeModeVisual + * true call ace_safemode_fnc_setSafeModeVisual * * Public: No */ @@ -27,8 +27,8 @@ if (_show) then { private _config = configFile >> "RscInGameUI" >> "RscUnitInfoSoldier" >> "WeaponInfoControlsGroupLeft" >> "controls" >> "CA_ModeTexture"; _control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")]; - _control ctrlCommit 0; } else { _control ctrlSetPosition [0, 0, 0, 0]; - _control ctrlCommit 0; }; + +_control ctrlCommit 0; diff --git a/addons/safemode/functions/fnc_setWeaponSafety.sqf b/addons/safemode/functions/fnc_setWeaponSafety.sqf index d80e1d8c38f..df9547df934 100644 --- a/addons/safemode/functions/fnc_setWeaponSafety.sqf +++ b/addons/safemode/functions/fnc_setWeaponSafety.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* - * Author: Brostrom.A - * Safe or unsafe the given weapon based on weapon state; locked or unlocked. + * Author: Brostrom.A, johnb43 + * Lock or unlock the given weapon based on weapon state. * * Arguments: * 0: Unit @@ -27,12 +27,12 @@ params [ if (_weapon == "") exitWith {}; -private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; +private _currentMuzzle = (_unit weaponState _weapon) select 1; -_weapon = configName (configFile >> "CfgWeapons" >> _weapon); +// Weapon is not available +if (_currentMuzzle == "") exitWith {}; -private _muzzle = currentMuzzle _unit; +// If the weapon is already in the desired state, don't do anything +if (_state == (((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_weapon, []]) findIf {_x select 0 == _currentMuzzle} != -1)) exitWith {}; -if (_state isNotEqualTo (_weapon in _safedWeapons)) then { - [_unit, _weapon, _muzzle, _hint] call FUNC(lockSafety); -}; +[_unit, _weapon, _currentMuzzle, _hint] call FUNC(lockSafety); diff --git a/addons/safemode/functions/fnc_unlockSafety.sqf b/addons/safemode/functions/fnc_unlockSafety.sqf index 10372f1a2ef..3e1ee0514cb 100644 --- a/addons/safemode/functions/fnc_unlockSafety.sqf +++ b/addons/safemode/functions/fnc_unlockSafety.sqf @@ -1,13 +1,13 @@ #include "..\script_component.hpp" /* - * Author: commy2 - * Take weapon of safety lock. + * Author: commy2, johnb43 + * Takes the weapon safety lock off. * * Arguments: * 0: Unit * 1: Weapon * 2: Muzzle - * 3: Show hint + * 3: Show hint (default: true) * * Return Value: * None @@ -18,67 +18,55 @@ * Public: No */ -params ["_unit", "_weapon", "_muzzle", ["_hint", true, [true]]]; +params ["_unit", "_weapon", "_muzzle", ["_hint", true]]; -private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; -_safedWeapons deleteAt (_safedWeapons find _weapon); +private _safedWeaponMuzzles = (_unit getVariable QGVAR(safedWeapons)) get _weapon; +(_safedWeaponMuzzles deleteAt (_safedWeaponMuzzles findIf {_x select 0 == _muzzle})) params ["", "_firemode"]; -_unit setVariable [QGVAR(safedWeapons), _safedWeapons]; +private _ehID = _unit getVariable QGVAR(actionID); -// remove action if all weapons have put their safety on -if (_safedWeapons isEqualTo []) then { - [_unit, "DefaultAction", _unit getVariable [QGVAR(actionID), -1]] call EFUNC(common,removeActionEventHandler); - _unit setVariable [QGVAR(actionID), -1]; +// Remove action if all weapons have put their safety on +if (_safedWeaponMuzzles isEqualTo []) then { + (_unit getVariable QGVAR(safedWeapons)) deleteAt _weapon; + + if (!isNil "_ehID") then { + [_unit, "DefaultAction", _ehID] call EFUNC(common,removeActionEventHandler); + + _unit setVariable [QGVAR(actionID), nil]; + }; }; -private _laserEnabled = _unit isIRLaserOn _weapon || {_unit isFlashlightOn _weapon}; +private _nextMode = inputAction "nextWeapon" > 0; -_unit selectWeapon _muzzle; +(_unit weaponState _muzzle) params ["_currentWeapon", "_currentMuzzle"]; -if ( - _laserEnabled - && { - _muzzle == primaryWeapon _unit // prevent UGL switch - || {"" == primaryWeapon _unit} // Arma switches to primary weapon if exists - } -) then { - {_unit action [_x, _unit]} forEach ["GunLightOn", "IRLaserOn"]; -}; +// If selection is a different weapon or muzzle, take the first firemode available for new weapon/muzzle +if (_currentWeapon != _weapon || {_currentMuzzle != _muzzle} || _nextMode) then { + private _config = configFile >> "CfgWeapons" >> _weapon; + + if (_weapon != _muzzle) then { + _config = _config >> _muzzle; + }; + + if (_nextMode) then { + private _modes = (getArray (_config >> "modes")) select {getNumber (_config >> _x >> "showToPlayer") == 1}; -if (inputAction "nextWeapon" > 0) then { - // switch to the last mode to roll over to first after the default nextWeapon action - // get weapon modes - private _modes = []; - { - if (getNumber (configFile >> "CfgWeapons" >> _weapon >> _x >> "showToPlayer") == 1) then { - _modes pushBack _x; - }; - if (_x == "this") then { - _modes pushBack _weapon; - }; - } forEach getArray (configFile >> "CfgWeapons" >> _weapon >> "modes"); - - // select last mode - private _mode = _modes select (count _modes - 1); - - // switch to last mode - private _index = 0; - while { - _index < 299 && {currentMuzzle _unit != _weapon || {currentWeaponMode _unit != _mode}} - } do { - _unit action ["SwitchWeapon", _unit, _unit, _index]; - _index = _index + 1; + _firemode = _modes param [(_modes find _firemode) + 1, ""]; }; -} else { - // play fire mode selector sound + + // The alt syntax of selectWeapon doesn't mess with gun lights and lasers + _unit selectWeapon [_weapon, _muzzle, _firemode]; +}; + +// Play fire mode selector sound +if (!_nextMode) then { [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound); }; -// player hud -[true] call FUNC(setSafeModeVisual); +// Player hud +true call FUNC(setSafeModeVisual); -// show info box unless disabled +// Show info box unless disabled if (_hint) then { - private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); - [localize LSTRING(TookOffSafety), _picture] call EFUNC(common,displayTextPicture); + [LLSTRING(TookOffSafety), getText (configFile >> "CfgWeapons" >> _weapon >> "picture")] call EFUNC(common,displayTextPicture); }; From 678de5b1d9c2eea4639a6eff1ef9e5232898fbee Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:46:54 +0200 Subject: [PATCH 02/10] Further improvements and fixes --- addons/safemode/functions/fnc_lockSafety.sqf | 31 ++++--------- .../functions/fnc_setWeaponSafety.sqf | 44 ++++++++++++++++--- .../safemode/functions/fnc_unlockSafety.sqf | 38 +++++----------- 3 files changed, 56 insertions(+), 57 deletions(-) diff --git a/addons/safemode/functions/fnc_lockSafety.sqf b/addons/safemode/functions/fnc_lockSafety.sqf index bbbbb8d6adc..9e1f931b80f 100644 --- a/addons/safemode/functions/fnc_lockSafety.sqf +++ b/addons/safemode/functions/fnc_lockSafety.sqf @@ -28,34 +28,21 @@ if (isNil "_safedWeapons") then { _unit setVariable [QGVAR(safedWeapons), _safedWeapons]; }; -_weapon = _weapon call EFUNC(common,baseWeapon); - // See if the current weapon has locked muzzled -private _safedWeaponMuzzles = _safedWeapons getOrDefault [_weapon, [], true]; +private _safedWeaponMuzzles = _safedWeapons getOrDefault [_weapon, createHashMap, true]; // If muzzle is locked, unlock it (toggle) -if (_safedWeaponMuzzles findIf {_x select 0 == _muzzle} != -1) exitWith { +if (_muzzle in _safedWeaponMuzzles) exitWith { [_unit, _weapon, _muzzle, _hint] call FUNC(unlockSafety); }; -(_unit weaponState _muzzle) params ["_currentWeapon", "_currentMuzzle", "_firemode"]; - -// If selection is a different weapon or muzzle, take the first firemode available for new weapon/muzzle -if (_currentWeapon != _weapon || {_currentMuzzle != _muzzle}) then { - private _config = configFile >> "CfgWeapons" >> _weapon; - - if (_weapon != _muzzle) then { - _config = _config >> _muzzle; - }; +private _firemode = (_unit weaponState _muzzle) select 2; - _firemode = ((getArray (_config >> "modes")) select {getNumber (_config >> _x >> "showToPlayer") == 1}) param [0, ""]; - - // The alt syntax of selectWeapon doesn't mess with gun lights and lasers - _unit selectWeapon [_weapon, _muzzle, _firemode]; -}; +// This syntax of selectWeapon doesn't mess with gun lights and lasers +_unit selectWeapon [_weapon, _muzzle, _firemode]; // Store new muzzle & firemode -_safedWeaponMuzzles pushBack [_muzzle, _firemode]; +_safedWeaponMuzzles set [_muzzle, _firemode]; // Lock muzzle if (isNil {_unit getVariable QGVAR(actionID)}) then { @@ -67,11 +54,9 @@ if (isNil {_unit getVariable QGVAR(actionID)}) then { _unit call CBA_fnc_canUseWeapon && { (weaponState _unit) params ["_currentWeapon", "_currentMuzzle"]; - _currentWeapon = _currentWeapon call EFUNC(common,baseWeapon); - // Block firing the muizzle in safe mode - if (((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, []]) findIf {_x select 0 == _currentMuzzle} != -1) then { - if (inputAction "nextWeapon" > 0) exitWith { + if (_currentMuzzle in ((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, createHashMap])) then { + if (inputAction "nextWeapon" > 0 || {inputAction "prevWeapon" > 0}) exitWith { [_unit, _currentWeapon, _currentMuzzle] call FUNC(unlockSafety); false diff --git a/addons/safemode/functions/fnc_setWeaponSafety.sqf b/addons/safemode/functions/fnc_setWeaponSafety.sqf index df9547df934..c5b57ed9a49 100644 --- a/addons/safemode/functions/fnc_setWeaponSafety.sqf +++ b/addons/safemode/functions/fnc_setWeaponSafety.sqf @@ -8,6 +8,7 @@ * 1: Weapon * 2: State * 3: Show hint (default: true) + * 4: Muzzle (default: current muzzle of weapon) * * Return Value: * None @@ -22,17 +23,48 @@ params [ ["_unit", objNull, [objNull]], ["_weapon", "", [""]], ["_state", true, [true]], - ["_hint", true, [true]] + ["_hint", true, [true]], + ["_muzzle", nil, [""]] ]; -if (_weapon == "") exitWith {}; +private _isMuzzleDefined = !isNil "_muzzle"; -private _currentMuzzle = (_unit weaponState _weapon) select 1; +if (_weapon == "" || {_isMuzzleDefined && {_muzzle == ""}}) exitWith {}; + +// Invalid muzzle +if (_isMuzzleDefined && { + private _configWeapon = configFile >> "CfgWeapons" >> _weapon; + + // Get config case muzzle names + private _muzzles = (getArray (_configWeapon >> "muzzles")) apply { + if (_x == "this") then { + configName _configWeapon + } else { + configName (_configWeapon >> _x) + }; + }; + + private _index = _muzzles findIf {_x == _muzzle}; + + if (_index == -1) exitWith { + true + }; + + // Make sure that muzzle is in the proper case + _muzzle = _muzzles select _index; + + false +}) exitWith {}; + +// Get current weapon muzzle if not defined +if (!_isMuzzleDefined) then { + _muzzle = (_unit weaponState _weapon) select 1; +}; // Weapon is not available -if (_currentMuzzle == "") exitWith {}; +if (_muzzle == "") exitWith {}; // If the weapon is already in the desired state, don't do anything -if (_state == (((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_weapon, []]) findIf {_x select 0 == _currentMuzzle} != -1)) exitWith {}; +if (_state == (_muzzle in ((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_weapon, createHashMap]))) exitWith {}; -[_unit, _weapon, _currentMuzzle, _hint] call FUNC(lockSafety); +[_unit, _weapon, _muzzle, _hint] call FUNC(lockSafety); diff --git a/addons/safemode/functions/fnc_unlockSafety.sqf b/addons/safemode/functions/fnc_unlockSafety.sqf index 3e1ee0514cb..d31f650740a 100644 --- a/addons/safemode/functions/fnc_unlockSafety.sqf +++ b/addons/safemode/functions/fnc_unlockSafety.sqf @@ -21,45 +21,27 @@ params ["_unit", "_weapon", "_muzzle", ["_hint", true]]; private _safedWeaponMuzzles = (_unit getVariable QGVAR(safedWeapons)) get _weapon; -(_safedWeaponMuzzles deleteAt (_safedWeaponMuzzles findIf {_x select 0 == _muzzle})) params ["", "_firemode"]; +private _firemode = _safedWeaponMuzzles deleteAt _muzzle; -private _ehID = _unit getVariable QGVAR(actionID); - -// Remove action if all weapons have put their safety on -if (_safedWeaponMuzzles isEqualTo []) then { +// Remove action if all weapons have removed their safeties +if (_safedWeaponMuzzles isEqualTo createHashMap) then { (_unit getVariable QGVAR(safedWeapons)) deleteAt _weapon; - if (!isNil "_ehID") then { + private _ehID = _unit getVariable QGVAR(actionID); + + if (!isNil "_ehID" && {(_unit getVariable QGVAR(safedWeapons)) isEqualTo createHashMap}) then { [_unit, "DefaultAction", _ehID] call EFUNC(common,removeActionEventHandler); _unit setVariable [QGVAR(actionID), nil]; }; }; -private _nextMode = inputAction "nextWeapon" > 0; - -(_unit weaponState _muzzle) params ["_currentWeapon", "_currentMuzzle"]; - -// If selection is a different weapon or muzzle, take the first firemode available for new weapon/muzzle -if (_currentWeapon != _weapon || {_currentMuzzle != _muzzle} || _nextMode) then { - private _config = configFile >> "CfgWeapons" >> _weapon; - - if (_weapon != _muzzle) then { - _config = _config >> _muzzle; - }; - - if (_nextMode) then { - private _modes = (getArray (_config >> "modes")) select {getNumber (_config >> _x >> "showToPlayer") == 1}; - - _firemode = _modes param [(_modes find _firemode) + 1, ""]; - }; - - // The alt syntax of selectWeapon doesn't mess with gun lights and lasers +// Let engine handle switching to next firemode/muzzle +if (inputAction "nextWeapon" == 0 && {inputAction "prevWeapon" == 0}) then { + // This syntax of selectWeapon doesn't mess with gun lights and lasers _unit selectWeapon [_weapon, _muzzle, _firemode]; -}; -// Play fire mode selector sound -if (!_nextMode) then { + // Play fire mode selector sound [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound); }; From ab44dc34cdc17ddb2cd536ff54543c58c94bf7a9 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:48:51 +0200 Subject: [PATCH 03/10] Update XEH_postInit.sqf --- addons/safemode/XEH_postInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf index 2e168a60036..5d21a0e3627 100644 --- a/addons/safemode/XEH_postInit.sqf +++ b/addons/safemode/XEH_postInit.sqf @@ -22,7 +22,7 @@ if (!hasInterface) exitWith {}; ["unit", { (weaponState ACE_player) params ["_currentWeapon", "_currentMuzzle"]; - private _weaponSafe = (((ACE_player getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, []]) findIf {_x select 0 == _currentMuzzle} != -1); + private _weaponSafe = _currentMuzzle in ((ACE_player getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, createHashMap]); !_weaponSafe call FUNC(setSafeModeVisual); }] call CBA_fnc_addPlayerEventHandler; From 57a045cc67c39639a2226631ebbc1c0ae1d7c812 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:35:38 +0200 Subject: [PATCH 04/10] Don't allow binoculars to be set to safe --- addons/safemode/XEH_postInit.sqf | 1 + addons/safemode/functions/fnc_lockSafety.sqf | 8 ++++---- addons/safemode/functions/fnc_setWeaponSafety.sqf | 3 +++ addons/safemode/functions/fnc_unlockSafety.sqf | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf index 5d21a0e3627..c80c08c28fd 100644 --- a/addons/safemode/XEH_postInit.sqf +++ b/addons/safemode/XEH_postInit.sqf @@ -24,5 +24,6 @@ if (!hasInterface) exitWith {}; private _weaponSafe = _currentMuzzle in ((ACE_player getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, createHashMap]); + // Player HUD !_weaponSafe call FUNC(setSafeModeVisual); }] call CBA_fnc_addPlayerEventHandler; diff --git a/addons/safemode/functions/fnc_lockSafety.sqf b/addons/safemode/functions/fnc_lockSafety.sqf index 9e1f931b80f..28adb42df91 100644 --- a/addons/safemode/functions/fnc_lockSafety.sqf +++ b/addons/safemode/functions/fnc_lockSafety.sqf @@ -28,7 +28,7 @@ if (isNil "_safedWeapons") then { _unit setVariable [QGVAR(safedWeapons), _safedWeapons]; }; -// See if the current weapon has locked muzzled +// See if the current weapon has locked muzzles private _safedWeaponMuzzles = _safedWeapons getOrDefault [_weapon, createHashMap, true]; // If muzzle is locked, unlock it (toggle) @@ -54,7 +54,7 @@ if (isNil {_unit getVariable QGVAR(actionID)}) then { _unit call CBA_fnc_canUseWeapon && { (weaponState _unit) params ["_currentWeapon", "_currentMuzzle"]; - // Block firing the muizzle in safe mode + // Block firing the muzzle in safe mode if (_currentMuzzle in ((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, createHashMap])) then { if (inputAction "nextWeapon" > 0 || {inputAction "prevWeapon" > 0}) exitWith { [_unit, _currentWeapon, _currentMuzzle] call FUNC(unlockSafety); @@ -68,12 +68,12 @@ if (isNil {_unit getVariable QGVAR(actionID)}) then { } } ) then { - // Player hud + // Player HUD false call FUNC(setSafeModeVisual); true } else { - // Player hud + // Player HUD true call FUNC(setSafeModeVisual); false diff --git a/addons/safemode/functions/fnc_setWeaponSafety.sqf b/addons/safemode/functions/fnc_setWeaponSafety.sqf index c5b57ed9a49..457bcb182f6 100644 --- a/addons/safemode/functions/fnc_setWeaponSafety.sqf +++ b/addons/safemode/functions/fnc_setWeaponSafety.sqf @@ -31,6 +31,9 @@ private _isMuzzleDefined = !isNil "_muzzle"; if (_weapon == "" || {_isMuzzleDefined && {_muzzle == ""}}) exitWith {}; +// Check if weapon is a binocular +if ((_weapon call EFUNC(common,getItemType)) select 1 == "binocular") exitWith {}; + // Invalid muzzle if (_isMuzzleDefined && { private _configWeapon = configFile >> "CfgWeapons" >> _weapon; diff --git a/addons/safemode/functions/fnc_unlockSafety.sqf b/addons/safemode/functions/fnc_unlockSafety.sqf index d31f650740a..97716025dc6 100644 --- a/addons/safemode/functions/fnc_unlockSafety.sqf +++ b/addons/safemode/functions/fnc_unlockSafety.sqf @@ -45,7 +45,7 @@ if (inputAction "nextWeapon" == 0 && {inputAction "prevWeapon" == 0}) then { [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound); }; -// Player hud +// Player HUD true call FUNC(setSafeModeVisual); // Show info box unless disabled From aa69936ada3c8ea894827aa11323f56f74fbfef7 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:58:01 +0200 Subject: [PATCH 05/10] Add API for getting weapon safety status --- .../common/functions/fnc_getWeaponMuzzles.sqf | 23 +++++++--- .../overheating/functions/fnc_jamWeapon.sqf | 8 ++-- addons/safemode/XEH_PREP.hpp | 1 + addons/safemode/XEH_postInit.sqf | 4 +- .../functions/fnc_getWeaponSafety.sqf | 45 +++++++++++++++++++ .../functions/fnc_setWeaponSafety.sqf | 38 ++++------------ .../functions/fnc_selectWeaponMode.sqf | 6 +-- 7 files changed, 82 insertions(+), 43 deletions(-) create mode 100644 addons/safemode/functions/fnc_getWeaponSafety.sqf diff --git a/addons/common/functions/fnc_getWeaponMuzzles.sqf b/addons/common/functions/fnc_getWeaponMuzzles.sqf index 11fffaf1960..06c7722bb48 100644 --- a/addons/common/functions/fnc_getWeaponMuzzles.sqf +++ b/addons/common/functions/fnc_getWeaponMuzzles.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* - * Author: commy2 + * Author: commy2, johnb43 * Get the muzzles of a weapon. * * Arguments: @@ -10,19 +10,30 @@ * All weapon muzzles * * Example: - * ["gun"] call ace_common_fnc_getWeaponMuzzles + * "arifle_AK12_F" call ace_common_fnc_getWeaponMuzzles * * Public: Yes */ params [["_weapon", "", [""]]]; -private _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); +private _config = configFile >> "CfgWeapons" >> _weapon; +if (isNull _config) exitWith { + [] // return +}; + +private _muzzles = []; + +// Get config case muzzle names { if (_x == "this") then { - _muzzles set [_forEachIndex, configName (configFile >> "CfgWeapons" >> _weapon)]; + _muzzles pushBack (configName _config); + } else { + if (!isNull (_config >> _x)) then { + _muzzles pushBack (configName (_config >> _x)); + }; }; -} forEach _muzzles; +} forEach getArray (_config >> "muzzles"); -_muzzles +_muzzles // return diff --git a/addons/overheating/functions/fnc_jamWeapon.sqf b/addons/overheating/functions/fnc_jamWeapon.sqf index 9a5b8b10491..1fb40bf741a 100644 --- a/addons/overheating/functions/fnc_jamWeapon.sqf +++ b/addons/overheating/functions/fnc_jamWeapon.sqf @@ -80,9 +80,11 @@ if (_unit getVariable [QGVAR(JammingActionID), -1] == -1) then { private _condition = { private _unit = _this select 1; - [_unit] call CBA_fnc_canUseWeapon - && {currentMuzzle _unit in (_unit getVariable [QGVAR(jammedWeapons), []])} - && {!(currentMuzzle _unit in (_unit getVariable [QEGVAR(safemode,safedWeapons), []]))} + (weaponState _unit) params ["_currentWeapon", "_currentMuzzle"] + + _unit call CBA_fnc_canUseWeapon + && {_currentMuzzle in (_unit getVariable [QGVAR(jammedWeapons), []])} + && {!([_unit, _currentWeapon, _currentMuzzle] call EFUNC(safemode,getWeaponSafety))} }; private _statement = { diff --git a/addons/safemode/XEH_PREP.hpp b/addons/safemode/XEH_PREP.hpp index 9a4e2622014..499ae808670 100644 --- a/addons/safemode/XEH_PREP.hpp +++ b/addons/safemode/XEH_PREP.hpp @@ -1,3 +1,4 @@ +PREP(getWeaponSafety); PREP(lockSafety); PREP(playChangeFiremodeSound); PREP(setSafeModeVisual); diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf index c80c08c28fd..79064789d54 100644 --- a/addons/safemode/XEH_postInit.sqf +++ b/addons/safemode/XEH_postInit.sqf @@ -13,7 +13,7 @@ if (!hasInterface) exitWith {}; // Conditions: specific if !(ACE_player call CBA_fnc_canUseWeapon && {_currentWeapon != ""} && {_currentWeapon != binocular ACE_player}) exitWith {false}; - // Statement + // Statement: Toggle weapon safety [ACE_player, _currentWeapon, _currentMuzzle] call FUNC(lockSafety); true @@ -22,7 +22,7 @@ if (!hasInterface) exitWith {}; ["unit", { (weaponState ACE_player) params ["_currentWeapon", "_currentMuzzle"]; - private _weaponSafe = _currentMuzzle in ((ACE_player getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_currentWeapon, createHashMap]); + private _weaponSafe = [ACE_player, _currentWeapon, _currentMuzzle] call FUNC(getWeaponSafety); // Player HUD !_weaponSafe call FUNC(setSafeModeVisual); diff --git a/addons/safemode/functions/fnc_getWeaponSafety.sqf b/addons/safemode/functions/fnc_getWeaponSafety.sqf new file mode 100644 index 00000000000..4d509711ba7 --- /dev/null +++ b/addons/safemode/functions/fnc_getWeaponSafety.sqf @@ -0,0 +1,45 @@ +#include "..\script_component.hpp" +/* + * Author: johnb43 + * Getter for weapon safety state. + * + * Arguments: + * 0: Unit + * 1: Weapon + * 2: Muzzle (default: current muzzle of weapon) + * + * Return Value: + * None + * + * Example: + * [ACE_player, currentWeapon ACE_player] call ace_safemode_fnc_getWeaponSafety + * + * Public: Yes + */ + +params [ + ["_unit", objNull, [objNull]], + ["_weapon", "", [""]], + ["_muzzle", nil, [""]] +]; + +if (_weapon == "" || {!(_unit hasWeapon _weapon)}) exitWith {false}; + +// Check if weapon is a binocular +if ((_weapon call EFUNC(common,getItemType)) select 1 == "binocular") exitWith {false}; + +// Check for invalid muzzles +_muzzle = if (isNil "_muzzle") then { + // Get current weapon muzzle if not defined + (_unit weaponState _weapon) select 1 +} else { + // Get config case muzzle names + private _muzzles = _weapon call EFUNC(common,getWeaponMuzzles); + + _muzzles param [_muzzles findIf {_x == _muzzle}, ""] +}; + +// Weapon is not available +if (_muzzle == "") exitWith {false}; + +_muzzle in ((_unit getVariable [QGVAR(safedWeapons), createHashMap]) getOrDefault [_weapon, createHashMap]) // return diff --git a/addons/safemode/functions/fnc_setWeaponSafety.sqf b/addons/safemode/functions/fnc_setWeaponSafety.sqf index 457bcb182f6..3db0033bf8f 100644 --- a/addons/safemode/functions/fnc_setWeaponSafety.sqf +++ b/addons/safemode/functions/fnc_setWeaponSafety.sqf @@ -27,41 +27,21 @@ params [ ["_muzzle", nil, [""]] ]; -private _isMuzzleDefined = !isNil "_muzzle"; - -if (_weapon == "" || {_isMuzzleDefined && {_muzzle == ""}}) exitWith {}; +// Don't allow to set weapon safety if unit doesn't have one (but allow removing safety, in case unit doesn't have weapon anymore) +if (_weapon == "" || {_state && {!(_unit hasWeapon _weapon)}}) exitWith {}; // Check if weapon is a binocular if ((_weapon call EFUNC(common,getItemType)) select 1 == "binocular") exitWith {}; -// Invalid muzzle -if (_isMuzzleDefined && { - private _configWeapon = configFile >> "CfgWeapons" >> _weapon; - +// Check for invalid muzzles +_muzzle = if (isNil "_muzzle") then { + // Get current weapon muzzle if not defined + (_unit weaponState _weapon) select 1 +} else { // Get config case muzzle names - private _muzzles = (getArray (_configWeapon >> "muzzles")) apply { - if (_x == "this") then { - configName _configWeapon - } else { - configName (_configWeapon >> _x) - }; - }; - - private _index = _muzzles findIf {_x == _muzzle}; - - if (_index == -1) exitWith { - true - }; - - // Make sure that muzzle is in the proper case - _muzzle = _muzzles select _index; - - false -}) exitWith {}; + private _muzzles = _weapon call EFUNC(common,getWeaponMuzzles); -// Get current weapon muzzle if not defined -if (!_isMuzzleDefined) then { - _muzzle = (_unit weaponState _weapon) select 1; + _muzzles param [_muzzles findIf {_x == _muzzle}, ""] }; // Weapon is not available diff --git a/addons/weaponselect/functions/fnc_selectWeaponMode.sqf b/addons/weaponselect/functions/fnc_selectWeaponMode.sqf index f2810bb512c..e9bef6ed167 100644 --- a/addons/weaponselect/functions/fnc_selectWeaponMode.sqf +++ b/addons/weaponselect/functions/fnc_selectWeaponMode.sqf @@ -24,9 +24,9 @@ if (currentWeapon _unit != _weapon) exitWith { _unit selectWeapon _weapon; }; -// unlock safety -if (_weapon in (_unit getVariable [QEGVAR(safemode,safedWeapons), []])) exitWith { - [_unit, _weapon, _weapon] call EFUNC(safemode,unlockSafety); +// Unlock safety +if ([_unit, _weapon] call EFUNC(safemode,getWeaponSafety)) exitWith { + [_unit, _weapon, false] call EFUNC(safemode,setWeaponSafety); }; private _muzzles = [_weapon] call EFUNC(common,getWeaponMuzzles); From 45b7d3120b5a1c6cdf373354f008bc2164bf8e82 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:19:29 +0200 Subject: [PATCH 06/10] Update fnc_jamWeapon.sqf --- addons/overheating/functions/fnc_jamWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/overheating/functions/fnc_jamWeapon.sqf b/addons/overheating/functions/fnc_jamWeapon.sqf index 1fb40bf741a..01d9d80d6e4 100644 --- a/addons/overheating/functions/fnc_jamWeapon.sqf +++ b/addons/overheating/functions/fnc_jamWeapon.sqf @@ -80,7 +80,7 @@ if (_unit getVariable [QGVAR(JammingActionID), -1] == -1) then { private _condition = { private _unit = _this select 1; - (weaponState _unit) params ["_currentWeapon", "_currentMuzzle"] + (weaponState _unit) params ["_currentWeapon", "_currentMuzzle"]; _unit call CBA_fnc_canUseWeapon && {_currentMuzzle in (_unit getVariable [QGVAR(jammedWeapons), []])} From 871db286d962200fb1507a60149afbd7bec0ba33 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:36:39 +0200 Subject: [PATCH 07/10] Added doc --- .../common/functions/fnc_getWeaponMuzzles.sqf | 4 +- .../functions/fnc_getWeaponSafety.sqf | 2 +- docs/wiki/framework/safemode-framework.md | 58 +++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 docs/wiki/framework/safemode-framework.md diff --git a/addons/common/functions/fnc_getWeaponMuzzles.sqf b/addons/common/functions/fnc_getWeaponMuzzles.sqf index 06c7722bb48..0184a0c8c83 100644 --- a/addons/common/functions/fnc_getWeaponMuzzles.sqf +++ b/addons/common/functions/fnc_getWeaponMuzzles.sqf @@ -19,7 +19,7 @@ params [["_weapon", "", [""]]]; private _config = configFile >> "CfgWeapons" >> _weapon; -if (isNull _config) exitWith { +if (!isClass _config) exitWith { [] // return }; @@ -30,7 +30,7 @@ private _muzzles = []; if (_x == "this") then { _muzzles pushBack (configName _config); } else { - if (!isNull (_config >> _x)) then { + if (isClass (_config >> _x)) then { _muzzles pushBack (configName (_config >> _x)); }; }; diff --git a/addons/safemode/functions/fnc_getWeaponSafety.sqf b/addons/safemode/functions/fnc_getWeaponSafety.sqf index 4d509711ba7..b171d974e4d 100644 --- a/addons/safemode/functions/fnc_getWeaponSafety.sqf +++ b/addons/safemode/functions/fnc_getWeaponSafety.sqf @@ -9,7 +9,7 @@ * 2: Muzzle (default: current muzzle of weapon) * * Return Value: - * None + * Safety status * * Example: * [ACE_player, currentWeapon ACE_player] call ace_safemode_fnc_getWeaponSafety diff --git a/docs/wiki/framework/safemode-framework.md b/docs/wiki/framework/safemode-framework.md new file mode 100644 index 00000000000..540254fdfa1 --- /dev/null +++ b/docs/wiki/framework/safemode-framework.md @@ -0,0 +1,58 @@ +--- +layout: wiki +title: Safemode Framework +description: Explains how to use the weapon safety API. +group: framework +order: 5 +parent: wiki +mod: ace +version: + major: 3 + minor: 0 + patch: 0 +--- + +## 1. Scripting + +### 1.1 Setting weapon safety status + +`ace_safemode_fnc_setWeaponSafety` +If you want the state of the currently selected muzzle, either pass the muzzle by name or leave it blank (= `nil`). +If the unit doesn't have a weapon, its safety can't be locked, but it can be unlocked. + +```sqf + * Lock or unlock the given weapon based on weapon state. + * + * Arguments: + * 0: Unit + * 1: Weapon + * 2: State + * 3: Show hint (default: true) + * 4: Muzzle (default: current muzzle of weapon) + * + * Return Value: + * None + * + * Example: + * [ACE_player, currentWeapon ACE_player, true] call ace_safemode_fnc_setWeaponSafety +``` + +### 1.2 Getting weapon safety status + +`ace_safemode_fnc_getWeaponSafety` +If you want the state of the currently selected muzzle, either pass the muzzle by name or leave it blank (= `nil`). + +```sqf + * Getter for weapon safety state. + * + * Arguments: + * 0: Unit + * 1: Weapon + * 2: Muzzle (default: current muzzle of weapon) + * + * Return Value: + * Safety status + * + * Example: + * [ACE_player, currentWeapon ACE_player] call ace_safemode_fnc_getWeaponSafety +``` From 0fc586f6f193b92764a834906937a6ffca4b9226 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:25:05 +0200 Subject: [PATCH 08/10] Update fnc_playChangeFiremodeSound.sqf --- addons/safemode/functions/fnc_playChangeFiremodeSound.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf index 115da8d2fc0..1edc2363340 100644 --- a/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf +++ b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf @@ -39,3 +39,5 @@ if !(toLowerANSI (_filename select [count _filename - 4]) in [".wav", ".ogg", ". private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand"); playSound3D [_filename, objNull, insideBuilding _unit >= 0.5, _position, _volume, _soundPitch, _distance]; + +nil // return From 4cd46fac6e2b3429a6a6958802fcab270879851d Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:13:36 +0200 Subject: [PATCH 09/10] Update addons/overheating/functions/fnc_jamWeapon.sqf Co-authored-by: PabstMirror --- addons/overheating/functions/fnc_jamWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/overheating/functions/fnc_jamWeapon.sqf b/addons/overheating/functions/fnc_jamWeapon.sqf index 01d9d80d6e4..afe6d15e975 100644 --- a/addons/overheating/functions/fnc_jamWeapon.sqf +++ b/addons/overheating/functions/fnc_jamWeapon.sqf @@ -84,7 +84,7 @@ if (_unit getVariable [QGVAR(JammingActionID), -1] == -1) then { _unit call CBA_fnc_canUseWeapon && {_currentMuzzle in (_unit getVariable [QGVAR(jammedWeapons), []])} - && {!([_unit, _currentWeapon, _currentMuzzle] call EFUNC(safemode,getWeaponSafety))} + && {!(["ace_safemode"] call EFUNC(common,isModLoaded)) || {!([_unit, _currentWeapon, _currentMuzzle] call EFUNC(safemode,getWeaponSafety))}} }; private _statement = { From 0a30b3e6d78e090661776de52fca9ebb49cc3084 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:13:45 +0200 Subject: [PATCH 10/10] Update addons/weaponselect/functions/fnc_selectWeaponMode.sqf Co-authored-by: PabstMirror --- addons/weaponselect/functions/fnc_selectWeaponMode.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/weaponselect/functions/fnc_selectWeaponMode.sqf b/addons/weaponselect/functions/fnc_selectWeaponMode.sqf index d87e28b1e12..3a63e1097fa 100644 --- a/addons/weaponselect/functions/fnc_selectWeaponMode.sqf +++ b/addons/weaponselect/functions/fnc_selectWeaponMode.sqf @@ -28,7 +28,7 @@ if (currentWeapon _unit != _weapon) exitWith { }; // Unlock safety -if ([_unit, _weapon] call EFUNC(safemode,getWeaponSafety)) exitWith { +if ((["ace_safemode"] call EFUNC(common,isModLoaded)) && {[_unit, _weapon] call EFUNC(safemode,getWeaponSafety)}) exitWith { [_unit, _weapon, false] call EFUNC(safemode,setWeaponSafety); };