diff --git a/addons/hearing/CfgEventHandlers.hpp b/addons/hearing/CfgEventHandlers.hpp index 9f0acc6c7c..94b1ab0703 100644 --- a/addons/hearing/CfgEventHandlers.hpp +++ b/addons/hearing/CfgEventHandlers.hpp @@ -22,7 +22,7 @@ class Extended_Init_EventHandlers { class Extended_FiredNear_EventHandlers { class CAManBase { class GVAR(FiredNear) { - clientFiredNear = QUOTE( if (_this select 0 == ACE_player) then {_this call FUNC(firedNear)}; ); + clientFiredNear = QUOTE( if (GVAR(enableCombatDeafness) && {_this select 0 == ACE_player}) then {_this call FUNC(firedNear)}; ); }; }; }; @@ -30,7 +30,7 @@ class Extended_FiredNear_EventHandlers { class Extended_Explosion_EventHandlers { class CAManBase { class GVAR(ExplosionNear) { - clientExplosion = QUOTE( if (_this select 0 == ACE_player) then {_this call FUNC(explosionNear)}; ); + clientExplosion = QUOTE( if (GVAR(enableCombatDeafness) && {_this select 0 == ACE_player}) then {_this call FUNC(explosionNear)}; ); }; }; -}; \ No newline at end of file +}; diff --git a/addons/hearing/CfgVehicles.hpp b/addons/hearing/CfgVehicles.hpp index 1f499d88a4..41562e9044 100644 --- a/addons/hearing/CfgVehicles.hpp +++ b/addons/hearing/CfgVehicles.hpp @@ -92,4 +92,27 @@ class CfgVehicles { MACRO_ADDITEM(ACE_EarBuds,12); }; }; + + + class Module_F; + class ACE_ModuleHearing: Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Hearing"; + function = QFUNC(moduleHearing); + scope = 2; + isGlobal = 1; + icon = PATHTOF(UI\IconHearing_ca.paa); + class Arguments { + class EnableCombatDeafness { + displayName = "Enable combat deafness?"; + description = "Enable combat deafness?"; + typeName = "BOOL"; + class values { + class Yes { name = "Yes"; value = 1; default = 1; }; + class No { name = "No"; value = 0; }; + }; + }; + }; + }; }; diff --git a/addons/hearing/UI/IconHearing_ca.paa b/addons/hearing/UI/IconHearing_ca.paa new file mode 100644 index 0000000000..128f08f6f0 Binary files /dev/null and b/addons/hearing/UI/IconHearing_ca.paa differ diff --git a/addons/hearing/XEH_preInit.sqf b/addons/hearing/XEH_preInit.sqf index 95d317b4b1..0785a32aff 100644 --- a/addons/hearing/XEH_preInit.sqf +++ b/addons/hearing/XEH_preInit.sqf @@ -7,6 +7,7 @@ PREP(earRinging); PREP(explosionNear); PREP(firedNear); PREP(hasEarPlugsIn); +PREP(moduleHearing); PREP(putInEarPlugs); PREP(removeEarPlugs); PREP(updateVolume); diff --git a/addons/hearing/config.cpp b/addons/hearing/config.cpp index 4499e647f6..0825573d9f 100644 --- a/addons/hearing/config.cpp +++ b/addons/hearing/config.cpp @@ -23,10 +23,22 @@ class CfgPatches { #include "CfgAmmo.hpp" class ACE_Settings { + class GVAR(EnableCombatDeafness) { + value = 1; + typeName = "BOOL"; + }; + class GVAR(EarplugsVolume) { + value = 0.5; + typeName = "SCALAR"; + }; + class GVAR(UnconsciousnessVolume) { + value = 0.4; + typeName = "SCALAR"; + }; class GVAR(DisableEarRinging) { - default = 1; + value = 0; typeName = "BOOL"; isClientSetable = 1; displayName = "$STR_ACE_Hearing_DisableEarRinging"; }; -}; \ No newline at end of file +}; diff --git a/addons/hearing/functions/fnc_moduleHearing.sqf b/addons/hearing/functions/fnc_moduleHearing.sqf new file mode 100644 index 0000000000..78e79d971e --- /dev/null +++ b/addons/hearing/functions/fnc_moduleHearing.sqf @@ -0,0 +1,20 @@ +/* + * Author: CAA-Picard + * Initializes the Map module. + * + * Arguments: + * Whatever the module provides. (I dunno.) + * + * Return Value: + * None + */ +#include "script_component.hpp" + +_logic = _this select 0; +_activated = _this select 2; + +if !(_activated) exitWith {}; + +[_logic, QGVAR(enableCombatDeafness), "EnableCombatDeafness"] call EFUNC(common,readSettingFromModule); + +diag_log text "[ACE]: Interaction Module Initialized."; diff --git a/addons/hearing/functions/fnc_updateVolume.sqf b/addons/hearing/functions/fnc_updateVolume.sqf index 187d4ce116..48b1befc18 100644 --- a/addons/hearing/functions/fnc_updateVolume.sqf +++ b/addons/hearing/functions/fnc_updateVolume.sqf @@ -4,6 +4,9 @@ #define STRENGHTODEAFNESS 3 #define MAXDEAFNESS 1.1 +// Exit if combat deafness is disabled +if !(GVAR(enableCombatDeafness)) exitWith {}; + // Check if new noises increase deafness if (GVAR(newStrength) * STRENGHTODEAFNESS > GVAR(currentDeafness)) then { GVAR(currentDeafness) = GVAR(newStrength) * STRENGHTODEAFNESS min MAXDEAFNESS; @@ -27,12 +30,12 @@ _volume = (1 - GVAR(currentDeafness) max 0)^2 max 0.04; // Earplugs reduce hearing 50% if ([ACE_player] call FUNC(hasEarPlugsIn)) then { - _volume = _volume min 0.5; + _volume = _volume min GVAR(EarplugsVolume); }; // Reduce volume if player is unconscious if (ACE_player getVariable ["ACE_isUnconscious", false]) then { - _volume = _volume min 0.4; + _volume = _volume min GVAR(UnconsciousnessVolume); }; if (!(missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false])) then {