2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: KoffeinFlummi, commy2
|
|
|
|
* Handles deafness due to large-caliber weapons going off near the player.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-03-15 21:40:47 +00:00
|
|
|
* 0: Unit - Object the event handler is assigned to <OBJECT>
|
|
|
|
* 1: Firer: Object - Object which fires a weapon near the unit <OBJECT>
|
|
|
|
* 2: Distance - Distance in meters between the unit and firer <NUMBER>
|
|
|
|
* 3: weapon - Fired weapon <STRING>
|
|
|
|
* 4: muzzle - Muzzle that was used <STRING>
|
|
|
|
* 5: mod - Current mode of the fired weapon <STRING>
|
|
|
|
* 6: ammo - Ammo used <STRING>
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-03-15 21:40:47 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [clientFiredNearEvent] call ace_hearing_fnc_firedNear
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-14 01:41:53 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-04-30 08:50:49 +00:00
|
|
|
private ["_silencer", "_audibleFireCoef", "_audibleFire", "_loudness", "_strength", "_vehAttenuation"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-04-11 03:16:33 +00:00
|
|
|
PARAMS_7(_object,_firer,_distance,_weapon,_muzzle,_mode,_ammo);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-04-11 03:16:33 +00:00
|
|
|
//Only run if combatDeafness enabled:
|
|
|
|
if (!GVAR(enableCombatDeafness)) exitWith {};
|
|
|
|
//Only run if firedNear object is player or player's vehicle:
|
2015-04-11 04:51:07 +00:00
|
|
|
if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
if (_weapon in ["Throw", "Put"]) exitWith {};
|
2015-04-11 04:21:54 +00:00
|
|
|
|
2015-04-20 07:18:46 +00:00
|
|
|
_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-04-11 03:16:33 +00:00
|
|
|
if (_distance < 1) then {_distance = 1;};
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_silencer = switch (_weapon) do {
|
2015-04-20 07:18:46 +00:00
|
|
|
case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0};
|
|
|
|
case (secondaryWeapon _firer) : {(secondaryWeaponItems _firer) select 0};
|
|
|
|
case (handgunWeapon _firer) : {(handgunItems _firer) select 0};
|
2015-03-15 21:40:47 +00:00
|
|
|
default {""};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_audibleFireCoef = 1;
|
|
|
|
if (_silencer != "") then {
|
2015-03-15 21:40:47 +00:00
|
|
|
_audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire");
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_audibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire");
|
|
|
|
|
|
|
|
_loudness = _audibleFireCoef * _audibleFire / 64;
|
2015-04-11 04:51:07 +00:00
|
|
|
_strength = _vehAttenuation * (_loudness - (_loudness/50 * _distance)); // linear drop off
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if (_strength < 0.01) exitWith {};
|
|
|
|
|
2015-04-11 03:16:33 +00:00
|
|
|
[{_this call FUNC(earRinging)}, [ACE_player, _strength], 0.2, 0] call EFUNC(common,waitAndExecute);
|