Code cleanup of Hearing module

This commit is contained in:
jokoho48 2015-08-13 23:42:20 +02:00
parent 7c60375105
commit c6fbdb420c
10 changed files with 25 additions and 31 deletions

View File

@ -15,7 +15,7 @@ GVAR(time4) = 0;
["SettingsInitialized", {
// Spawn volume updating process
[FUNC(updateVolume), 1, [false] ] call CBA_fnc_addPerFrameHandler;
[FUNC(updateVolume), 1, [false]] call CBA_fnc_addPerFrameHandler;
}] call EFUNC(common,addEventHandler);
//Update veh attunation when player veh changes

View File

@ -14,8 +14,7 @@
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
// Exit if hearing is disabled or soldier has earplugs already in (persistence scenarios)
if (!GVAR(enableCombatDeafness) || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};

View File

@ -15,8 +15,7 @@
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_unit,_strength);
params ["_unit", "_strength"];
if (_unit != ACE_player) exitWith {};
if (_strength < 0.05) exitWith {};

View File

@ -19,7 +19,7 @@
//Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
PARAMS_2(_unit,_damage);
params ["_unit", "_damage"];
private ["_strength"];
_strength = 0 max _damage;

View File

@ -24,7 +24,7 @@
//Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo);
params ["_object", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo"];
//Only run if firedNear object is player or player's vehicle:
if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {};
@ -37,11 +37,11 @@ _vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_p
_distance = 1 max _distance;
_silencer = switch (_weapon) do {
case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0};
case (secondaryWeapon _firer) : {(secondaryWeaponItems _firer) select 0};
case (handgunWeapon _firer) : {(handgunItems _firer) select 0};
default {""};
_silencer = call {
if (primaryWeapon _firer) exitWith {(primaryWeaponItems _firer) select 0};
if (secondaryWeapon _firer) exitWith {(secondaryWeaponItems _firer) select 0};
if (handgunWeapon _firer) exitWith {(handgunItems _firer) select 0};
""
};
_audibleFireCoef = 1;
@ -58,7 +58,7 @@ if (count _weaponMagazines == 0) then {
_muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines");
_weaponMagazines append _muzzleMagazines;
};
} forEach _muzzles;
} count _muzzles;
{
_ammoType = getText(configFile >> "CfgMagazines" >> _x >> "ammo");
_weaponMagazines set [_forEachIndex, [_x, _ammoType]];
@ -68,11 +68,11 @@ if (count _weaponMagazines == 0) then {
_magazine = "";
{
EXPLODE_2_PVT(_x,_magazineType,_ammoType);
params ["_magazineType", "_ammoType"];
if (_ammoType == _ammo) exitWith {
_magazine = _magazineType;
};
} forEach _weaponMagazines;
} count _weaponMagazines;
if (_magazine == "") exitWith {};
@ -80,14 +80,12 @@ _initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed")
_ammoConfig = (configFile >> "CfgAmmo" >> _ammo);
_parentClasses = [_ammoConfig, true] call BIS_fnc_returnParents;
_caliber = getNumber(_ammoConfig >> "ACE_caliber");
_caliber = switch (true) do {
case ("ShellBase" in _parentClasses): { 80 };
case ("RocketBase" in _parentClasses): { 200 };
case ("MissileBase" in _parentClasses): { 600 };
case ("SubmunitionBase" in _parentClasses): { 80 };
default {
if (_caliber <= 0) then { 6.5 } else { _caliber };
};
_caliber = call {
if ("ShellBase" in _parentClasses) exitWith { 80 };
if ("RocketBase" in _parentClasses) exitWith { 200 };
if ("MissileBase" in _parentClasses) exitWith { 600 };
if ("SubmunitionBase" in _parentClasses) exitWith { 80 };
if (_caliber <= 0) then { 6.5 } else { _caliber };
};
_loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) * _audibleFireCoef / 5;
_strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off

View File

@ -14,7 +14,6 @@
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_unit);
params ["_unit"];
_unit getVariable ["ACE_hasEarPlugsin", false]

View File

@ -9,8 +9,7 @@
* None
*/
#include "script_component.hpp"
PARAMS_3(_logic,_units,_activated);
params ["_logic", "_units", "_activated"];
if !(_activated) exitWith {};

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
PARAMS_1(_player);
params ["_player"];
// Plugs in inventory, putting them in
_player removeItem "ACE_EarPlugs";

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
PARAMS_1(_player);
params ["_player"];
if !(_player canAdd "ACE_EarPlugs") exitWith { // inventory full
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);

View File

@ -19,9 +19,9 @@
//Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
EXPLODE_1_PVT((_this select 0),_justUpdateVolume);
private["_volume", "_soundTransitionTime"];
(_this select 0) params ["_justUpdateVolume"];
GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0;