mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
#2833 - Add earplugs based on loudness (+MGs)
Use same loudness calc as firedNear (replacing old audibleFire) Give ear plugs to machine gunners (depends on magzine size)
This commit is contained in:
parent
28738517e8
commit
845909f8af
@ -14,29 +14,40 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
// Exit if hearing is disabled or soldier has earplugs already in (persistence scenarios)
|
// Exit if hearing is disabled or soldier has earplugs already in (persistence scenarios)
|
||||||
if (!GVAR(enableCombatDeafness) || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};
|
if (!GVAR(enableCombatDeafness) || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};
|
||||||
|
|
||||||
private ["_launcher"];
|
|
||||||
|
|
||||||
// add earplugs if the soldier has a rocket launcher
|
// add earplugs if the soldier has a rocket launcher
|
||||||
_launcher = secondaryWeapon _unit;
|
if ((secondaryWeapon _unit) != "") exitWith {
|
||||||
|
|
||||||
if (_launcher != "") exitWith {
|
|
||||||
_unit addItem "ACE_EarPlugs";
|
_unit addItem "ACE_EarPlugs";
|
||||||
};
|
};
|
||||||
|
|
||||||
// otherwise add earplugs if the soldier has a big rifle
|
// otherwise add earplugs if the soldier has a big rifle
|
||||||
private ["_magazine", "_ammo"];
|
if ((primaryWeapon _unit) == "") exitWith {};
|
||||||
|
|
||||||
_magazine = primaryWeaponMagazine _unit select 0;
|
(primaryWeaponMagazine _unit) params [["_magazine", ""]];
|
||||||
|
if (_magazine == "") exitWith {};
|
||||||
|
|
||||||
if (isNil "_magazine") exitWith {};
|
local _initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
|
||||||
|
local _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
|
||||||
|
local _count = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
|
||||||
|
|
||||||
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
|
local _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_caliber");
|
||||||
|
_caliber = call {
|
||||||
|
if (_ammo isKindOf ["ShellBase", (configFile >> "CfgAmmo")]) exitWith { 80 };
|
||||||
|
if (_ammo isKindOf ["RocketBase", (configFile >> "CfgAmmo")]) exitWith { 200 };
|
||||||
|
if (_ammo isKindOf ["MissileBase", (configFile >> "CfgAmmo")]) exitWith { 600 };
|
||||||
|
if (_ammo isKindOf ["SubmunitionBase", (configFile >> "CfgAmmo")]) exitWith { 80 };
|
||||||
|
if (_caliber <= 0) then { 6.5 } else { _caliber };
|
||||||
|
};
|
||||||
|
local _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) / 5;
|
||||||
|
|
||||||
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "audiblefire") > 8) then {
|
//If unit has a machine gun boost effective loudness 50%
|
||||||
|
if (_count >= 50) then {_loudness = _loudness * 1.5};
|
||||||
|
|
||||||
|
if (_loudness > 0.2) then {
|
||||||
_unit addItem "ACE_EarPlugs";
|
_unit addItem "ACE_EarPlugs";
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user