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%)
This commit is contained in:
Nicolás Badano 2015-03-16 20:28:37 -03:00
parent 4c1f7111b5
commit 5b91996c69
7 changed files with 66 additions and 7 deletions

View File

@ -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)}; );
};
};
};

View File

@ -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; };
};
};
};
};
};

Binary file not shown.

View File

@ -7,6 +7,7 @@ PREP(earRinging);
PREP(explosionNear);
PREP(firedNear);
PREP(hasEarPlugsIn);
PREP(moduleHearing);
PREP(putInEarPlugs);
PREP(removeEarPlugs);
PREP(updateVolume);

View File

@ -23,8 +23,20 @@ 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";

View File

@ -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.";

View File

@ -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 {