From 749425dfb796b54c5ceb6bfb533ef537b9848bd5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 16 Feb 2016 12:58:42 -0600 Subject: [PATCH] Settings Category, Minor Cleanup --- addons/hearing/ACE_Settings.hpp | 6 ++++++ addons/hearing/XEH_postInit.sqf | 4 ++++ addons/hearing/functions/fnc_earRinging.sqf | 12 +++++------- addons/hearing/functions/fnc_explosionNear.sqf | 2 +- addons/hearing/functions/fnc_firedNear.sqf | 2 +- addons/hearing/functions/fnc_updateVolume.sqf | 13 ++++--------- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/addons/hearing/ACE_Settings.hpp b/addons/hearing/ACE_Settings.hpp index 047a84d9c9..dcae85fa25 100644 --- a/addons/hearing/ACE_Settings.hpp +++ b/addons/hearing/ACE_Settings.hpp @@ -1,19 +1,23 @@ class ACE_Settings { class GVAR(EnableCombatDeafness) { + category = CSTRING(Module_DisplayName); value = 1; typeName = "BOOL"; displayName = CSTRING(EnableCombatDeafness_DisplayName); description = CSTRING(EnableCombatDeafness_Description); }; class GVAR(EarplugsVolume) { + category = CSTRING(Module_DisplayName); value = 0.5; typeName = "SCALAR"; }; class GVAR(UnconsciousnessVolume) { + category = CSTRING(Module_DisplayName); value = 0.4; typeName = "SCALAR"; }; class GVAR(DisableEarRinging) { + category = CSTRING(Module_DisplayName); value = 0; typeName = "BOOL"; isClientSettable = 1; @@ -21,12 +25,14 @@ class ACE_Settings { description = CSTRING(DisableEarRinging_Description); }; class GVAR(enabledForZeusUnits) { + category = CSTRING(Module_DisplayName); value = 1; typeName = "BOOL"; displayName = CSTRING(enabledForZeusUnits_DisplayName); description = CSTRING(enabledForZeusUnits_Description); }; class GVAR(autoAddEarplugsToUnits) { + category = CSTRING(Module_DisplayName); value = 1; typeName = "BOOL"; displayName = CSTRING(autoAddEarplugsToUnits_DisplayName); diff --git a/addons/hearing/XEH_postInit.sqf b/addons/hearing/XEH_postInit.sqf index eb62c37bf4..8153a55dbd 100644 --- a/addons/hearing/XEH_postInit.sqf +++ b/addons/hearing/XEH_postInit.sqf @@ -12,6 +12,10 @@ GVAR(playerVehAttenuation) = 1; GVAR(time3) = 0; ["SettingsInitialized", { + TRACE_1("settingInit",GVAR(EnableCombatDeafness)); + // Only run if combat deafness is enabled + if (!GVAR(EnableCombatDeafness)) exitWith {}; + // Spawn volume updating process [FUNC(updateVolume), 1, [false]] call CBA_fnc_addPerFrameHandler; }] call EFUNC(common,addEventHandler); diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index cda5fa508e..0bd94943a7 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -1,10 +1,9 @@ /* * Author: KoffeinFlummi, commy2, Rocko, Rommel, Ruthberg - * Ear ringing PFH + * Handle new sound souce near player and apply hearing damage * * Arguments: - * 0: unit - * 1: strength of ear ringing (Number between 0 and 1) + * 0: strength of ear ringing (Number between 0 and 1) * * Return Value: * None @@ -15,9 +14,8 @@ * Public: No */ #include "script_component.hpp" -params ["_unit", "_strength"]; +params ["_strength"]; -if (_unit != ACE_player) exitWith {}; if (_strength < 0.05) exitWith {}; if (!isNull curatorCamera) exitWith {}; if ((!GVAR(enabledForZeusUnits)) && {player != ACE_player}) exitWith {}; @@ -27,9 +25,9 @@ if (_unit getVariable ["ACE_hasEarPlugsin", false]) then { }; //headgear hearing protection -if(headgear _unit != "") then { +if (headgear _unit != "") then { private _protection = (getNumber (configFile >> "CfgWeapons" >> (headgear _unit) >> QGVAR(protection))) min 1; - if(_protection > 0) then { + if (_protection > 0) then { _strength = _strength * (1 - _protection); }; }; diff --git a/addons/hearing/functions/fnc_explosionNear.sqf b/addons/hearing/functions/fnc_explosionNear.sqf index 338d9c26e3..799de52320 100644 --- a/addons/hearing/functions/fnc_explosionNear.sqf +++ b/addons/hearing/functions/fnc_explosionNear.sqf @@ -30,4 +30,4 @@ _strength = (0 max _damage) * 30; if (_strength < 0.01) exitWith {}; // Call inmediately, as it will get pick up later anyway by the update thread -[ACE_player, _strength] call FUNC(earRinging); +[_strength] call FUNC(earRinging); diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index 5b5b4db181..f583ab0050 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -98,4 +98,4 @@ TRACE_1("result",_strength); if (_strength < 0.01) exitWith {}; // Call inmediately, as it will get pick up later anyway by the update thread -[ACE_player, _strength] call FUNC(earRinging); +[_strength] call FUNC(earRinging); diff --git a/addons/hearing/functions/fnc_updateVolume.sqf b/addons/hearing/functions/fnc_updateVolume.sqf index e24fbf9d2d..4467cbf14c 100644 --- a/addons/hearing/functions/fnc_updateVolume.sqf +++ b/addons/hearing/functions/fnc_updateVolume.sqf @@ -16,12 +16,8 @@ */ #include "script_component.hpp" -// Only run if combat deafness is enabled -if (!GVAR(EnableCombatDeafness)) exitWith {}; - (_this select 0) params ["_justUpdateVolume"]; - GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0; GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0.05; TRACE_3("",GVAR(volume),GVAR(deafnessDV),GVAR(deafnessDV) - GVAR(deafnessPrior)); @@ -46,7 +42,7 @@ if (!_justUpdateVolume) then { GVAR(deafnessDV) = (GVAR(deafnessDV) - (0.5 * (GVAR(volume) max 0.1))) max 0; }; -if ((missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) || {!GVAR(enableCombatDeafness)}) exitWith {}; +if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {}; private _volume = GVAR(volume); @@ -56,10 +52,9 @@ if ([ACE_player] call FUNC(hasEarPlugsIn)) then { }; // Headgear can reduce hearing -if(headgear ACE_player != "") then { - private ["_lowerVolume"]; - _lowerVolume = (getNumber (configFile >> "CfgWeapons" >> (headgear ACE_player) >> QGVAR(lowerVolume))) min 1; - if(_lowerVolume > 0) then { +if (headgear ACE_player != "") then { + private _lowerVolume = (getNumber (configFile >> "CfgWeapons" >> (headgear ACE_player) >> QGVAR(lowerVolume))) min 1; + if (_lowerVolume > 0) then { _volume = _volume min (1 - _lowerVolume); }; };