Handle enableCombatDeafness and/or ringing enabled

This commit is contained in:
PabstMirror 2015-07-11 21:00:40 -05:00
parent 040f4a92a0
commit 05d98370e4
7 changed files with 66 additions and 59 deletions

View File

@ -4,6 +4,7 @@ if (!hasInterface) exitWith {};
GVAR(deafnessDV) = 0;
GVAR(deafnessPrior) = 0;
GVAR(volume) = 1;
GVAR(playerVehAttenuation) = 1;
GVAR(beep) = false;
@ -13,12 +14,8 @@ GVAR(time3) = 0;
GVAR(time4) = 0;
["SettingsInitialized", {
//If not enabled, dont't add draw eventhandler or PFEH (for performance)
if (!GVAR(enableCombatDeafness)) exitWith {};
// Spawn volume updating process
[FUNC(updateVolume), 1, [] ] call CBA_fnc_addPerFrameHandler;
[FUNC(updateVolume), 1, [false] ] call CBA_fnc_addPerFrameHandler;
}] call EFUNC(common,addEventHandler);
//Update veh attunation when player veh changes

View File

@ -16,8 +16,6 @@
*/
#include "script_component.hpp"
if (!GVAR(enableCombatDeafness)) exitWith {};
PARAMS_2(_unit,_strength);
if (_unit != ACE_player) exitWith {};

View File

@ -16,8 +16,8 @@
*/
#include "script_component.hpp"
//Only run if combatDeafness enabled:
if (!GVAR(enableCombatDeafness)) exitWith {};
//Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
PARAMS_2(_unit,_damage);

View File

@ -21,8 +21,8 @@
*/
#include "script_component.hpp"
//Only run if combatDeafness enabled:
if (!GVAR(enableCombatDeafness)) exitWith {};
//Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo);

View File

@ -24,5 +24,8 @@ _player setVariable ["ACE_hasEarPlugsIn", true, true];
[localize LSTRING(EarPlugs_Are_On)] call EFUNC(common,displayTextStructured);
//Force an immediate fast volume update:
[[true]] call FUNC(updateVolume);
/*// No Earplugs in inventory, telling user
[localize LSTRING(NoPlugs)] call EFUNC(common,displayTextStructured);*/

View File

@ -27,3 +27,6 @@ _player addItem "ACE_EarPlugs";
_player setVariable ["ACE_hasEarPlugsIn", false, true];
[localize LSTRING(EarPlugs_Are_Off)] call EFUNC(common,displayTextStructured);
//Force an immediate fast volume update:
[[true]] call FUNC(updateVolume);

View File

@ -3,7 +3,8 @@
* Updates and applys the current deafness. Called every 0.1 sec from a PFEH.
*
* Arguments:
* None
* 0: Args <ARRAY>
* -----0: Just update volume (skip ringing/recovery) <BOOL><OPTIONAL>
*
* Return Value:
* None
@ -15,10 +16,17 @@
*/
#include "script_component.hpp"
private["_Volume"];
//Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
EXPLODE_1_PVT((_this select 0),_justUpdateVolume);
private["_volume", "_soundTransitionTime"];
GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0;
if (!_justUpdateVolume) then {
//If we got a big increase in the last second:
if ((GVAR(deafnessDV) - GVAR(deafnessPrior)) > 2) then {
if (ACE_time > GVAR(time3)) then {
@ -32,7 +40,6 @@ if ((GVAR(deafnessDV) - GVAR(deafnessPrior)) > 2) then {
};
GVAR(deafnessPrior) = GVAR(deafnessDV);
GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0;
if (GVAR(deafnessDV) > 19.75) then {
ACE_player setvariable [QGVAR(deaf), true];
@ -60,8 +67,9 @@ if (GVAR(deafnessDV) > 10) then {
// Hearing takes longer to return to normal after it hits rock bottom
GVAR(deafnessDV) = (GVAR(deafnessDV) - (0.5 * (GVAR(volume) max 0.1))) max 0;
};
TRACE_3("tick", GVAR(deafnessPrior), GVAR(deafnessDV), GVAR(volume));
if ((missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) || {!GVAR(enableCombatDeafness)}) exitWith {};
_volume = GVAR(volume);
@ -84,11 +92,9 @@ if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
_volume = _volume min GVAR(UnconsciousnessVolume);
};
if (!(missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false])) then {
1 fadeSound _volume;
1 fadeSpeech _volume;
_soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1};
_soundTransitionTime fadeSound _volume;
_soundTransitionTime fadeSpeech _volume;
ACE_player setVariable ["tf_globalVolume", _volume];
if (!isNil "acre_api_fnc_setGlobalVolume") then {[_volume^(0.33)] call acre_api_fnc_setGlobalVolume;};
};
//hintSilent format ["GVAR(currentDeafness), _Volume = %1, %2", GVAR(currentDeafness), _volume];