ACE3/addons/hearing/functions/fnc_updateVolume.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05:00

64 lines
2.1 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: commy2 and esteldunedain and Ruthberg
* Updates and applies the current deafness. Called every 1 sec from a PFEH.
*
* Arguments:
* 0: Args <ARRAY>
* 0: Just update volume (skip ringing/recovery) <BOOL> (default: false)
*
* Return Value:
* None
*
* Example:
* [] call ace_hearing_fnc_updateVolume
*
* Public: No
*/
if (!alive ACE_player) exitWith {
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
TRACE_1("dead - removing hearing effects",ACE_player);
[QUOTE(ADDON), 1, true] call EFUNC(common,setHearingCapability);
};
(_this select 0) params [["_justUpdateVolume", false]];
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));
if (!_justUpdateVolume) then {
// 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 {
if (CBA_missionTime - GVAR(time3) < 3) exitWith {};
GVAR(time3) = CBA_missionTime;
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));
};
};
GVAR(deafnessPrior) = GVAR(deafnessDV);
// 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;
};
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
private _volume = GVAR(volume);
// Earplugs and headgear can attenuate hearing
_volume = _volume min GVAR(volumeAttenuation);
// Reduce volume if player is unconscious
if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
_volume = _volume min GVAR(UnconsciousnessVolume);
};
[QUOTE(ADDON), _volume, true] call EFUNC(common,setHearingCapability);