ACE3/addons/hearing/functions/fnc_addEarPlugs.sqf

37 lines
844 B
Plaintext
Raw Normal View History

/*
* 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
*
* Argument:
* 0: A Soldier (Object)
2015-01-13 04:17:52 +00:00
*
* Return value:
* Nothing
*/
2015-01-14 01:41:53 +00:00
#include "script_component.hpp"
private ["_unit", "_launcher"];
_unit = _this select 0;
// add earplugs if the soldier has a rocket launcher
_launcher = secondaryWeapon _unit;
if (_launcher != "") exitWith {
2015-01-13 04:17:52 +00:00
_unit addItem "ACE_EarBuds";
};
// 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-01-13 04:17:52 +00:00
_unit addItem "ACE_EarBuds";
};