firedNear - use new isKindOf

This commit is contained in:
PabstMirror 2015-08-30 01:37:14 -05:00
parent 2f54cfadbc
commit 8307ccea96

View File

@ -7,8 +7,8 @@
* 1: Firer: Object - Object which fires a weapon near the unit <OBJECT> * 1: Firer: Object - Object which fires a weapon near the unit <OBJECT>
* 2: Distance - Distance in meters between the unit and firer <NUMBER> * 2: Distance - Distance in meters between the unit and firer <NUMBER>
* 3: weapon - Fired weapon <STRING> * 3: weapon - Fired weapon <STRING>
* 4: muzzle - Muzzle that was used <STRING> * 4: muzzle - Muzzle that was used (not used) <STRING>
* 5: mod - Current mode of the fired weapon <STRING> * 5: mode - Current mode of the fired weapon (not used) <STRING>
* 6: ammo - Ammo used <STRING> * 6: ammo - Ammo used <STRING>
* *
* Return Value: * Return Value:
@ -16,6 +16,7 @@
* *
* Example: * Example:
* [clientFiredNearEvent] call ace_hearing_fnc_firedNear * [clientFiredNearEvent] call ace_hearing_fnc_firedNear
* [player, player, 10, "arifle_MX_ACO_pointer_F", "arifle_MX_ACO_pointer_F", "single", "B_65x39_Caseless"] call ace_hearing_fnc_firedNear
* *
* Public: No * Public: No
*/ */
@ -24,14 +25,14 @@
//Only run if deafness or ear ringing is enabled: //Only run if deafness or ear ringing is enabled:
if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {}; if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {};
params ["_object", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo"]; params ["_object", "_firer", "_distance", "_weapon", "", "", "_ammo"];
//Only run if firedNear object is player or player's vehicle: //Only run if firedNear object is player or player's vehicle:
if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {}; if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {};
if (_weapon in ["Throw", "Put"]) exitWith {}; if (_weapon in ["Throw", "Put"]) exitWith {};
if (_distance > 50) exitWith {}; if (_distance > 50) exitWith {};
private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_muzzleMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber", "_parentClasses"]; private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_muzzleMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber"];
_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)}; _vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)};
@ -78,21 +79,20 @@ if (_magazine == "") exitWith {};
_initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed"); _initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
_ammoConfig = (configFile >> "CfgAmmo" >> _ammo); _ammoConfig = (configFile >> "CfgAmmo" >> _ammo);
_parentClasses = [_ammoConfig, true] call BIS_fnc_returnParents;
_caliber = getNumber(_ammoConfig >> "ACE_caliber"); _caliber = getNumber(_ammoConfig >> "ACE_caliber");
_caliber = call { _caliber = call {
if ("ShellBase" in _parentClasses) exitWith { 80 }; if (_ammo isKindOf ["ShellBase", (configFile >> "CfgAmmo")]) exitWith { 80 };
if ("RocketBase" in _parentClasses) exitWith { 200 }; if (_ammo isKindOf ["RocketBase", (configFile >> "CfgAmmo")]) exitWith { 200 };
if ("MissileBase" in _parentClasses) exitWith { 600 }; if (_ammo isKindOf ["MissileBase", (configFile >> "CfgAmmo")]) exitWith { 600 };
if ("SubmunitionBase" in _parentClasses) exitWith { 80 }; if (_ammo isKindOf ["SubmunitionBase", (configFile >> "CfgAmmo")]) exitWith { 80 };
if (_caliber <= 0) then { 6.5 } else { _caliber }; if (_caliber <= 0) then { 6.5 } else { _caliber };
}; };
_loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) * _audibleFireCoef / 5; _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) * _audibleFireCoef / 5;
_strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off _strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off
//systemChat format["%1 : %2 : %3", _strength, _initSpeed, _parentClasses]; //systemChat format["%1 : %2", _strength, _initSpeed];
//systemChat format["%1 : %2 : %3", _weapon, _magazine, _initSpeed]; //systemChat format["%1 : %2 : %3", _weapon, _magazine, _initSpeed];
if (_strength < 0.01) exitWith {}; if (_strength < 0.01) exitWith {};
[{_this call FUNC(earRinging)}, [ACE_player, _strength], 0.2, 0] call EFUNC(common,waitAndExecute); [{_this call FUNC(earRinging)}, [ACE_player, _strength], 0.2] call EFUNC(common,waitAndExecute);