From dac3047fcaf426a2e9a135dab304621fd195d833 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 10 Apr 2015 22:16:33 -0500 Subject: [PATCH] Use AllVehicles Instead of CAManBase --- addons/hearing/CfgEventHandlers.hpp | 4 ++-- addons/hearing/functions/fnc_firedNear.sqf | 24 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/hearing/CfgEventHandlers.hpp b/addons/hearing/CfgEventHandlers.hpp index 94b1ab0703..cfe71fe01d 100644 --- a/addons/hearing/CfgEventHandlers.hpp +++ b/addons/hearing/CfgEventHandlers.hpp @@ -20,9 +20,9 @@ class Extended_Init_EventHandlers { }; class Extended_FiredNear_EventHandlers { - class CAManBase { + class AllVehicles { class GVAR(FiredNear) { - clientFiredNear = QUOTE( if (GVAR(enableCombatDeafness) && {_this select 0 == ACE_player}) then {_this call FUNC(firedNear)}; ); + clientFiredNear = QUOTE(_this call FUNC(firedNear);); }; }; }; diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index c66361801e..2351afe3c5 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -21,23 +21,23 @@ */ #include "script_component.hpp" -private ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_silencer", "_audibleFireCoef", "_loudness", "_strength"]; +private ["_silencer", "_audibleFireCoef", "_loudness", "_strength"]; -_unit = _this select 0; -_firer = _this select 1; -_distance = (_this select 2) max 1; -_weapon = _this select 3; -_muzzle = _this select 4; -_mode = _this select 5; -_ammo = _this select 6; +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 (_weapon in ["Throw", "Put"]) exitWith {}; if (_unit != vehicle _unit && {!([_unit] call EFUNC(common,isTurnedOut))}) exitWith {}; +if (_distance < 1) then {_distance = 1;}; + _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}; +case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0}; +case (secondaryWeapon _firer) : {(secondaryWeaponItems _firer) select 0}; +case (handgunWeapon _firer) : {(handgunItems _firer) select 0}; default {""}; }; @@ -56,4 +56,4 @@ _strength = _loudness - (_loudness/50 * _distance); // linear drop off if (_strength < 0.01) exitWith {}; -[{_this call FUNC(earRinging)}, [_unit, _strength], 0.2, 0] call EFUNC(common,waitAndExecute); +[{_this call FUNC(earRinging)}, [ACE_player, _strength], 0.2, 0] call EFUNC(common,waitAndExecute);