Skip to content

Commit 6e32fc1

Browse files
authored
Hearing - Add earplugs only if not present (#9987)
Only add earplugs if not present
1 parent 3b80629 commit 6e32fc1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

addons/hearing/functions/fnc_addEarPlugs.sqf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ if !(EGVAR(common,settingsInitFinished)) exitWith {
2020
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addEarPlugs), _this];
2121
};
2222

23+
// Exit if hearing is disabled or if autoAdd is disabled
24+
if (!GVAR(enableCombatDeafness) || {GVAR(autoAddEarplugsToUnits) == 0}) exitWith {};
25+
2326
params ["_unit"];
2427
TRACE_2("params",_unit,typeOf _unit);
2528

26-
// Exit if hearing is disabled OR autoAdd is disabled OR soldier has earplugs already in (persistence scenarios)
27-
if (!GVAR(enableCombatDeafness) || {GVAR(autoAddEarplugsToUnits) == 0} || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};
29+
// Exit if the unit already has earplugs (in ears (persistence scenarios) or inventory)
30+
if (_unit call FUNC(hasEarPlugsIn) || {[_unit, "ACE_EarPlugs"] call EFUNC(common,hasItem)}) exitWith {};
2831

2932
// Add earplugs if enabled for everyone or if the soldier has a rocket launcher
3033
if (GVAR(autoAddEarplugsToUnits) == 2 || {(secondaryWeapon _unit) != ""}) exitWith {

0 commit comments

Comments
 (0)