2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-04-11 04:21:54 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
2015-04-20 07:17:47 +00:00
|
|
|
* Gets the sound attenuation of a player to the outside.
|
2015-04-11 04:21:54 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-04-20 07:17:47 +00:00
|
|
|
* None
|
2015-04-11 04:21:54 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Ammount that unit can hear outside <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-04-20 07:17:47 +00:00
|
|
|
* [] call ace_hearing_fnc_updatePlayerVehAttenuation
|
2015-04-11 04:21:54 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2017-01-09 18:10:52 +00:00
|
|
|
private _vehicle = vehicle ACE_player;
|
2015-04-11 04:21:54 +00:00
|
|
|
|
|
|
|
if (isNull _vehicle) exitWith {};
|
|
|
|
|
2017-01-09 18:10:52 +00:00
|
|
|
private _newAttenuation = 1;
|
2015-04-20 07:17:47 +00:00
|
|
|
if (ACE_player != _vehicle) then {
|
2017-01-09 18:10:52 +00:00
|
|
|
private _turretPath = [ACE_player] call EFUNC(common,getTurretIndex);
|
2021-02-18 18:58:08 +00:00
|
|
|
private _effectType = getText (configOf _vehicle >> "attenuationEffectType");
|
2015-04-11 04:51:07 +00:00
|
|
|
|
2021-02-27 17:05:05 +00:00
|
|
|
if (_turretPath isNotEqualTo []) then {
|
2021-02-18 18:58:08 +00:00
|
|
|
private _turretConfig = [(configOf _vehicle), _turretPath] call EFUNC(common,getTurretConfigPath);
|
2015-04-11 04:51:07 +00:00
|
|
|
|
2015-04-11 04:21:54 +00:00
|
|
|
if ((getNumber (_turretConfig >> "disableSoundAttenuation")) == 1) then {
|
|
|
|
_effectType = "";
|
|
|
|
} else {
|
|
|
|
if (isText (_turretConfig >> "soundAttenuationTurret")) then {
|
|
|
|
_effectType = getText (_turretConfig >> "soundAttenuationTurret");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-04-20 07:18:46 +00:00
|
|
|
|
2015-04-11 04:21:54 +00:00
|
|
|
_newAttenuation = switch (true) do {
|
2015-04-20 07:18:46 +00:00
|
|
|
case (_effectType == ""): {1};
|
2017-01-09 18:10:52 +00:00
|
|
|
case (_effectType == "CarAttenuation");
|
|
|
|
case (_effectType == "RHS_CarAttenuation"): { // Increase protection for armored cars
|
2021-02-18 18:58:08 +00:00
|
|
|
private _armor = getNumber (configOf _vehicle >> "HitPoints" >> "HitBody" >> "armor");
|
2017-01-09 18:10:52 +00:00
|
|
|
linearConversion [2, 8, _armor, 0.5, 0.3, true];};
|
2015-04-20 07:18:46 +00:00
|
|
|
case (_effectType == "OpenCarAttenuation"): {1};
|
|
|
|
case (_effectType == "TankAttenuation"): {0.1};
|
2020-05-01 01:01:34 +00:00
|
|
|
case (_effectType == "MrapAttenuation"): {0.2};
|
2015-04-20 07:18:46 +00:00
|
|
|
case (_effectType == "HeliAttenuation"): {0.3};
|
|
|
|
case (_effectType == "OpenHeliAttenuation"): {0.9};
|
2020-05-01 01:01:34 +00:00
|
|
|
case (_effectType == "SemiOpenCarAttenuation");
|
|
|
|
case (_effectType == "SemiOpenCarAttenuation2");
|
2015-04-20 07:18:46 +00:00
|
|
|
case (_effectType == "SemiOpenHeliAttenuation"): {0.6};
|
|
|
|
case (_effectType == "HeliAttenuationGunner"): {0.85};
|
|
|
|
case (_effectType == "HeliAttenuationRamp"): {0.85};
|
2015-04-11 04:21:54 +00:00
|
|
|
default {1};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-20 07:17:47 +00:00
|
|
|
TRACE_2("New vehicle attenuation",_vehicle,_newAttenuation);
|
|
|
|
|
|
|
|
GVAR(playerVehAttenuation) = _newAttenuation;
|