From 5b91996c69d066b4e9a4ff0b8f5e3bc80f864035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Mon, 16 Mar 2015 20:28:37 -0300 Subject: [PATCH] Add hearing module and additional customization parameters: - Enable/Disable combat deafness altogether (default on) - Volume when using earbuds (default 50%) - Volume when unconscious (default 40%) --- addons/hearing/CfgEventHandlers.hpp | 6 ++--- addons/hearing/CfgVehicles.hpp | 23 ++++++++++++++++++ addons/hearing/UI/IconHearing_ca.paa | Bin 0 -> 5625 bytes addons/hearing/XEH_preInit.sqf | 1 + addons/hearing/config.cpp | 16 ++++++++++-- .../hearing/functions/fnc_moduleHearing.sqf | 20 +++++++++++++++ addons/hearing/functions/fnc_updateVolume.sqf | 7 ++++-- 7 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 addons/hearing/UI/IconHearing_ca.paa create mode 100644 addons/hearing/functions/fnc_moduleHearing.sqf 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 0000000000000000000000000000000000000000..128f08f6f01b5ec82dd4ffa2cc70a453948304b2 GIT binary patch literal 5625 zcmdT|4NM!?9X}^2DJ>Al$F#;UgJYF8Q?fKxPp#6{&^cg4p`l6BkSSAuG*QxGM_NTP zG0)JHxlz*`q1z(VQfsML_n~Pfb1$k;YtppDA|GVw$7~!Jq{L(-fSCie#~p9)o&A4z zxhQkcmPvg&!~O36{=fgn`@fI7dr)z4;iexJZ!TQGFwE4{RFQviR9B`?6`;M)fgYncp!@ zv1HFJb^+i2J70(?X?g9#y&AAzKID^p1FUT)cacv3mxjHf-(5@NpKqL<=)x%j`Fta) z{ZxTV!_&4AzKY7Vzr#Iawj0pDe8>?d_oR{74MTicaFMVO@c%j=n7?X8opl!Y2S#J$ zRtI>c2Sq+Vnoj*SFqRfWNs9sG|E)g;rleWPx9UX9Hp^SJz&|jGA_#E=Ci3CV@pIzm zfahvI&B@nl`I@gmzjQe2BKM?8T%(Q~_v<#$`K#~5gI8B0fIN%fMtdLNeq1kxl6SKK z@9W2MA9{=8ag3XCXn!Now;Us4$=*JqU;Zl1r^IiO%1e?PPeg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nfYZFJZC70l^(Q0T`lr5j`ScuR9%)&bwUI6pn*{cz z-RQySUyhV-siF416FdI?qyN}W@g|}1rrqRT=3eqy^dXMjlj7T425vmm-1O#!9q!*# p%rzZ&Z0C;m05>zQH+6lc&j-8!uc$bmTbCc1r}1az!sGa${u@mGGnxPZ literal 0 HcmV?d00001 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 {