2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Called on unit initialization. Adds earplugs if the unit is equipped with either a really loud primary weapon or a rocket launcher.
|
2015-01-13 04:17:52 +00:00
|
|
|
*
|
2015-03-15 21:40:47 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: A Soldier <Object>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [guy] call ace_hearing_fnc_addEarPlugs
|
2015-01-13 04:17:52 +00:00
|
|
|
*
|
2015-03-15 21:40:47 +00:00
|
|
|
* 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-06-28 19:25:01 +00:00
|
|
|
PARAMS_1(_unit);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-06-28 19:25:01 +00:00
|
|
|
// Exit if soldier has earplugs already in (persistence scenarios)
|
2015-06-28 20:28:26 +00:00
|
|
|
if ([_unit] call FUNC(hasEarPlugsIn)) exitWith {};
|
2015-06-28 19:25:01 +00:00
|
|
|
|
|
|
|
private ["_launcher"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// add earplugs if the soldier has a rocket launcher
|
|
|
|
_launcher = secondaryWeapon _unit;
|
|
|
|
|
|
|
|
if (_launcher != "") exitWith {
|
2015-03-16 15:56:05 +00:00
|
|
|
_unit addItem "ACE_EarPlugs";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// otherwise add earplugs if the soldier has a big rifle
|
|
|
|
private ["_magazine", "_ammo"];
|
|
|
|
|
|
|
|
_magazine = primaryWeaponMagazine _unit select 0;
|
|
|
|
|
|
|
|
if (isNil "_magazine") exitWith {};
|
|
|
|
|
|
|
|
_ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
|
|
|
|
|
|
|
|
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "audiblefire") > 8) then {
|
2015-03-16 15:56:05 +00:00
|
|
|
_unit addItem "ACE_EarPlugs";
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|