From b6a710d282342a2553f0cc5b08ccdb9f7cf63006 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 13 Jun 2015 18:32:48 +0200 Subject: [PATCH] Implemented a proper magazine lookup routine --- addons/hearing/CfgSounds.hpp | 2 +- addons/hearing/functions/fnc_firedNear.sqf | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/addons/hearing/CfgSounds.hpp b/addons/hearing/CfgSounds.hpp index 8c6d6965df..2d757041be 100644 --- a/addons/hearing/CfgSounds.hpp +++ b/addons/hearing/CfgSounds.hpp @@ -12,7 +12,7 @@ class CfgSounds { titles[] = {}; }; class ACE_Combat_Deafness { - sound[] = {QUOTE(PATHTOF(sounds\deafness.ogg)),2,1}; + sound[] = {QUOTE(PATHTOF(sounds\deafness.ogg)),3,1}; titles[] = {}; }; class ACE_Ring_Backblast { diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index d62fe17892..0ae736ee32 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -21,7 +21,7 @@ */ #include "script_component.hpp" -private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_initSpeed", "_ammoConfig", "_caliber", "_parentClasses"]; +private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber", "_parentClasses"]; PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo); @@ -47,7 +47,24 @@ if (_silencer != "") then { _audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire"); }; -_magazine = (getArray(configFile >> "CfgWeapons" >> _weapon >> "magazines")) select 0; +_magazine = ""; +_muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); +_weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"); +{ + if (_x != "this") then { + _muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines"); + _weaponMagazines append _muzzleMagazines; + }; +} forEach _muzzles; +{ + _ammoType = getText(configFile >> "CfgMagazines" >> _x >> "ammo"); + if (_ammoType == _ammo) exitWith { + _magazine = _x; + }; +} forEach _weaponMagazines; + +if (_magazine == "") exitWith {}; + _initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed"); _ammoConfig = (configFile >> "CfgAmmo" >> _ammo); _parentClasses = [_ammoConfig, true] call BIS_fnc_returnParents; @@ -65,6 +82,7 @@ _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) * _audibleFireCoef / 5; _strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off //systemChat format["%1 : %2 : %3", _strength, _initSpeed, _parentClasses]; +//systemChat format["%1 : %2 : %3", _weapon, _magazine, _initSpeed]; if (_strength < 0.01) exitWith {};