diff --git a/addons/hearing/XEH_postInit.sqf b/addons/hearing/XEH_postInit.sqf index 76656bf70b..4dc22efd4f 100644 --- a/addons/hearing/XEH_postInit.sqf +++ b/addons/hearing/XEH_postInit.sqf @@ -1,12 +1,14 @@ #include "script_component.hpp" +if (!hasInterface) exitWith {}; + GVAR(currentDeafness) = 0; GVAR(newStrength) = 0; +GVAR(playerVehAttunation) = 1; // Spawn volume updating process [FUNC(updateVolume), 0.1, [] ] call CBA_fnc_addPerFrameHandler; -GVAR(playerVehAttunation) = 1; - +//Update veh attunation when player veh changes ["playerVehicleChanged", {_this call FUNC(updatePlayerVehicleAttunation);}] call EFUNC(common,addEventHandler); ["playerTurretChanged", {_this call FUNC(updatePlayerVehicleAttunation);}] call EFUNC(common,addEventHandler); diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index bd6a503528..7b50a44a14 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -21,17 +21,17 @@ */ #include "script_component.hpp" -private ["_silencer", "_audibleFireCoef", "_loudness", "_strength"]; +private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation"]; PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo); //Only run if combatDeafness enabled: if (!GVAR(enableCombatDeafness)) exitWith {}; //Only run if firedNear object is player or player's vehicle: -if ((ACE_player != (_this select 0)) && {(vehicle ACE_player) != (_this select 0)}) exitWith {}; +if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {}; if (_weapon in ["Throw", "Put"]) exitWith {}; -_attenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttunation)}; +_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttunation)}; if (_distance < 1) then {_distance = 1;}; @@ -53,7 +53,7 @@ _audibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire"); //_audibleFireTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFireTime"); _loudness = _audibleFireCoef * _audibleFire / 64; -_strength = _attenuation * (_loudness - (_loudness/50 * _distance)); // linear drop off +_strength = _vehAttenuation * (_loudness - (_loudness/50 * _distance)); // linear drop off if (_strength < 0.01) exitWith {}; diff --git a/addons/hearing/functions/fnc_updatePlayerVehicleAttunation.sqf b/addons/hearing/functions/fnc_updatePlayerVehicleAttunation.sqf index bb4899e998..e03fc23d50 100644 --- a/addons/hearing/functions/fnc_updatePlayerVehicleAttunation.sqf +++ b/addons/hearing/functions/fnc_updatePlayerVehicleAttunation.sqf @@ -25,12 +25,11 @@ if (ACE_player == _vehicle) then { } else { _effectType = ""; _turretPath = [ACE_player] call EFUNC(common,getTurretIndex); - systemChat format ["_turretPath %1", _turretPath]; _effectType = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "attenuationEffectType"); - systemChat format ["Veh EffectType %1", _effectType]; + if (!(_turretPath isEqualTo [])) then { _turretConfig = [(configFile >> "CfgVehicles" >> (typeOf _vehicle)), _turretPath] call EFUNC(common,getTurretConfigPath); - + if ((getNumber (_turretConfig >> "disableSoundAttenuation")) == 1) then { _effectType = ""; } else {