2015-03-15 21:40:47 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: commy2 and esteldunedain
|
2015-03-15 21:40:47 +00:00
|
|
|
* Updates and applys the current deafness. Called every 0.1 sec from a PFEH.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [] call ace_hearing_fnc_updateVolume
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-14 02:16:55 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
#define STRENGHTODEAFNESS 3
|
|
|
|
#define MAXDEAFNESS 1.1
|
|
|
|
|
2015-03-16 23:28:37 +00:00
|
|
|
// Exit if combat deafness is disabled
|
|
|
|
if !(GVAR(enableCombatDeafness)) exitWith {};
|
|
|
|
|
2015-01-14 02:16:55 +00:00
|
|
|
// Check if new noises increase deafness
|
|
|
|
if (GVAR(newStrength) * STRENGHTODEAFNESS > GVAR(currentDeafness)) then {
|
2015-03-15 21:40:47 +00:00
|
|
|
GVAR(currentDeafness) = GVAR(newStrength) * STRENGHTODEAFNESS min MAXDEAFNESS;
|
2015-01-14 02:16:55 +00:00
|
|
|
};
|
|
|
|
GVAR(newStrength) = 0;
|
|
|
|
|
|
|
|
// Recover rate is slower if deafness is severe
|
|
|
|
_recoverRate = 0.01;
|
|
|
|
if (GVAR(currentDeafness) > 0.7) then {
|
2015-03-15 21:40:47 +00:00
|
|
|
_recoverRate = 0.005;
|
|
|
|
if (GVAR(currentDeafness) > 0.9) then {
|
|
|
|
_recoverRate = 0.002;
|
|
|
|
};
|
2015-01-14 02:16:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Deafness recovers with time
|
|
|
|
GVAR(currentDeafness) = GVAR(currentDeafness) - _recoverRate max 0;
|
|
|
|
|
|
|
|
// needed until Bohemia fixes playSound to actually use the second argument
|
|
|
|
_volume = (1 - GVAR(currentDeafness) max 0)^2 max 0.04;
|
|
|
|
|
|
|
|
// Earplugs reduce hearing 50%
|
|
|
|
if ([ACE_player] call FUNC(hasEarPlugsIn)) then {
|
2015-03-16 23:39:49 +00:00
|
|
|
_volume = _volume min GVAR(EarplugsVolume);
|
2015-01-14 02:16:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Reduce volume if player is unconscious
|
|
|
|
if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
|
2015-03-16 23:39:49 +00:00
|
|
|
_volume = _volume min GVAR(UnconsciousnessVolume);
|
2015-01-14 02:16:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!(missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false])) then {
|
2015-03-15 21:40:47 +00:00
|
|
|
0.1 fadeSound _volume;
|
|
|
|
0.1 fadeSpeech _volume;
|
|
|
|
ACE_player setVariable ["tf_globalVolume", _volume];
|
2015-03-16 18:14:45 +00:00
|
|
|
if (!isNil "acre_api_fnc_setGlobalVolume") then {[_volume] call acre_api_fnc_setGlobalVolume;};
|
2015-01-14 02:16:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//hintSilent format ["GVAR(currentDeafness), _Volume = %1, %2", GVAR(currentDeafness), _volume];
|