2015-03-15 21:40:47 +00:00
|
|
|
/*
|
2015-06-13 15:16:18 +00:00
|
|
|
* Author: commy2 and esteldunedain and Ruthberg
|
2016-01-20 23:19:08 +00:00
|
|
|
* Updates and applys the current deafness. Called every 1 sec from a PFEH.
|
2015-03-15 21:40:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-07-12 02:00:40 +00:00
|
|
|
* 0: Args <ARRAY>
|
|
|
|
* -----0: Just update volume (skip ringing/recovery) <BOOL><OPTIONAL>
|
2015-03-15 21:40:47 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [] call ace_hearing_fnc_updateVolume
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-14 02:16:55 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-13 21:42:20 +00:00
|
|
|
(_this select 0) params ["_justUpdateVolume"];
|
|
|
|
|
2015-07-12 02:00:40 +00:00
|
|
|
GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
|
2016-02-06 16:59:31 +00:00
|
|
|
GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0.05;
|
2016-02-06 17:11:18 +00:00
|
|
|
TRACE_3("",GVAR(volume),GVAR(deafnessDV),GVAR(deafnessDV) - GVAR(deafnessPrior));
|
2015-03-16 23:28:37 +00:00
|
|
|
|
2015-07-12 02:00:40 +00:00
|
|
|
if (!_justUpdateVolume) then {
|
2016-02-06 16:59:31 +00:00
|
|
|
// Ring if we got a big increase in the last second or enough accumulated damage
|
|
|
|
if (GVAR(deafnessDV) - GVAR(deafnessPrior) > 1 ||
|
|
|
|
GVAR(deafnessDV) > 10) then {
|
2015-01-14 02:16:55 +00:00
|
|
|
|
2016-02-06 16:59:31 +00:00
|
|
|
if (ACE_time - GVAR(time3) < 3) exitWith {};
|
|
|
|
GVAR(time3) = ACE_time;
|
2015-07-12 02:00:40 +00:00
|
|
|
|
2016-02-06 16:59:31 +00:00
|
|
|
if (GVAR(deafnessDV) > 19.75) then {
|
|
|
|
playSound (["ACE_Combat_Deafness_Heavy", "ACE_Combat_Deafness_Heavy_NoRing"] select GVAR(DisableEarRinging));
|
|
|
|
} else {
|
|
|
|
playSound (["ACE_Combat_Deafness_Medium", "ACE_Combat_Deafness_Medium_NoRing"] select GVAR(DisableEarRinging));
|
2015-07-12 02:00:40 +00:00
|
|
|
};
|
2015-03-15 21:40:47 +00:00
|
|
|
};
|
2016-02-06 16:59:31 +00:00
|
|
|
GVAR(deafnessPrior) = GVAR(deafnessDV);
|
2015-01-14 02:16:55 +00:00
|
|
|
|
2015-07-12 02:00:40 +00:00
|
|
|
// 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;
|
|
|
|
};
|
2015-07-11 02:01:32 +00:00
|
|
|
|
2016-02-16 18:58:42 +00:00
|
|
|
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
|
2015-01-14 02:16:55 +00:00
|
|
|
|
2016-01-20 23:19:08 +00:00
|
|
|
private _volume = GVAR(volume);
|
2015-01-14 02:16:55 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
};
|
|
|
|
|
2015-07-01 19:21:09 +00:00
|
|
|
// Headgear can reduce hearing
|
2016-02-16 18:58:42 +00:00
|
|
|
if (headgear ACE_player != "") then {
|
|
|
|
private _lowerVolume = (getNumber (configFile >> "CfgWeapons" >> (headgear ACE_player) >> QGVAR(lowerVolume))) min 1;
|
|
|
|
if (_lowerVolume > 0) then {
|
2015-07-01 19:21:09 +00:00
|
|
|
_volume = _volume min (1 - _lowerVolume);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2016-01-20 23:19:08 +00:00
|
|
|
private _soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1};
|
2015-01-14 02:16:55 +00:00
|
|
|
|
2015-07-12 02:00:40 +00:00
|
|
|
_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;};
|