Hearing - Code cleanup (#10041)

* Hearing cleanup

* Update fnc_updateHearingProtection.sqf

* Fixes + tweaks

* Update initSettings.inc.sqf

* Update fnc_removeEarplugs.sqf
This commit is contained in:
johnb432 2024-05-29 19:01:39 +02:00 committed by GitHub
parent be61424fed
commit e535988479
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 146 additions and 109 deletions

View File

@ -1,4 +1,3 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));

View File

@ -5,7 +5,7 @@ class CfgVehicles {
class ACE_Equipment {
class ACE_PutInEarplugs {
displayName = CSTRING(EarPlugs_On);
condition = QUOTE(GVAR(EnableCombatDeafness) && {!([_player] call FUNC(hasEarPlugsIn)) && {'ACE_EarPlugs' in items _player}});
condition = QUOTE(GVAR(enableCombatDeafness) && {!(_player call FUNC(hasEarPlugsIn)) && {[ARR_2(_player,'ACE_EarPlugs')] call EFUNC(common,hasItem)}});
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
statement = QUOTE([ARR_2(_player,true)] call FUNC(putInEarPlugs));
showDisabled = 0;
@ -13,7 +13,7 @@ class CfgVehicles {
};
class ACE_RemoveEarplugs {
displayName = CSTRING(EarPlugs_Off);
condition = QUOTE(GVAR(EnableCombatDeafness) && {[_player] call FUNC(hasEarPlugsIn)});
condition = QUOTE(GVAR(enableCombatDeafness) && {_player call FUNC(hasEarPlugsIn)});
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
statement = QUOTE([ARR_2(_player,true)] call FUNC(removeEarPlugs));
showDisabled = 0;

View File

@ -80,7 +80,7 @@ class CfgWeapons {
class H_HelmetO_ocamo: H_HelmetB {
HEARING_PROTECTION_PELTOR;
}; // Defender and Assasin Helmet inherit.
}; // Defender and Assassin Helmet inherit.
class H_HelmetO_ViperSP_hex_f: H_HelmetB {
HEARING_PROTECTION_PELTOR;

View File

@ -1,4 +1,3 @@
PREP(addEarPlugs);
PREP(earRinging);
PREP(explosionNear);

View File

@ -2,9 +2,10 @@
if (isServer) then {
["CBA_settingsInitialized", {
TRACE_1("settingInit - server",GVAR(EnableCombatDeafness));
TRACE_1("settingInit - server",GVAR(enableCombatDeafness));
// Only install event handler if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};
if (!GVAR(enableCombatDeafness)) exitWith {};
["CAManBase", "Init", LINKFUNC(addEarPlugs), true, [], true] call CBA_fnc_addClassEventHandler;
}] call CBA_fnc_addEventHandler;
@ -26,18 +27,20 @@ GVAR(volumeAttenuation) = 1;
GVAR(lastPlayerVehicle) = objNull;
["CBA_settingsInitialized", {
TRACE_1("settingInit",GVAR(EnableCombatDeafness));
TRACE_1("settingInit",GVAR(enableCombatDeafness));
// Only run PFEH and install event handlers if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};
if (!GVAR(enableCombatDeafness)) exitWith {};
// Spawn volume updating process
[LINKFUNC(updateVolume), 1, [false]] call CBA_fnc_addPerFrameHandler;
[LINKFUNC(updateVolume), 1, false] call CBA_fnc_addPerFrameHandler;
[QGVAR(updateVolume), LINKFUNC(updateVolume)] call CBA_fnc_addEventHandler;
// Update veh attunation when player veh changes
["vehicle", {
params ["_player", "_vehicle"];
TRACE_2("vehicle change",_player,_vehicle);
_this call FUNC(updatePlayerVehAttenuation);
@ -48,6 +51,7 @@ GVAR(lastPlayerVehicle) = objNull;
GVAR(lastPlayerVehicle) = objNull;
TRACE_2("removed veh eh",_firedEH,GVAR(lastPlayerVehicle));
};
if ((!isNull _vehicle) && {_player != _vehicle}) then {
private _firedEH = _vehicle addEventHandler ["FiredNear", {call FUNC(firedNear)}];
_vehicle setVariable [QGVAR(firedEH), _firedEH];
@ -55,8 +59,8 @@ GVAR(lastPlayerVehicle) = objNull;
TRACE_2("added veh eh",_firedEH,GVAR(lastPlayerVehicle));
};
}, true] call CBA_fnc_addPlayerEventHandler;
["turret", LINKFUNC(updatePlayerVehAttenuation), false] call CBA_fnc_addPlayerEventHandler;
["turret", LINKFUNC(updatePlayerVehAttenuation), false] call CBA_fnc_addPlayerEventHandler;
// Reset deafness on respawn (or remote control player switch)
["unit", {
@ -67,9 +71,11 @@ GVAR(lastPlayerVehicle) = objNull;
private _firedEH = _oldPlayer getVariable [QGVAR(firedEH), -1];
_oldPlayer removeEventHandler ["FiredNear", _firedEH];
_oldPlayer setVariable [QGVAR(firedEH), nil];
private _explosionEH = _oldPlayer getVariable [QGVAR(explosionEH), -1];
_oldPlayer removeEventHandler ["Explosion", _explosionEH];
_oldPlayer setVariable [QGVAR(explosionEH), nil];
TRACE_3("removed unit eh",_oldPlayer,_firedEH,_explosionEH);
};
// Don't add a new EH if the unit respawned
@ -77,17 +83,21 @@ GVAR(lastPlayerVehicle) = objNull;
if ((getNumber (configOf _player >> "isPlayableLogic")) == 1) exitWith {
TRACE_1("skipping playable logic",typeOf _player); // VirtualMan_F (placeable logic zeus / spectator)
};
private _firedEH = _player addEventHandler ["FiredNear", {call FUNC(firedNear)}];
_player setVariable [QGVAR(firedEH), _firedEH];
private _explosionEH = _player addEventHandler ["Explosion", {call FUNC(explosionNear)}];
_player setVariable [QGVAR(explosionEH), _explosionEH];
TRACE_3("added unit eh",_player,_firedEH,_explosionEH);
};
GVAR(deafnessDV) = 0;
GVAR(deafnessPrior) = 0;
GVAR(time3) = 0;
[] call FUNC(updateHearingProtection);
call FUNC(updateHearingProtection);
}, true] call CBA_fnc_addPlayerEventHandler;
// Update protection on possible helmet change

View File

@ -10,18 +10,20 @@ PREP_RECOMPILE_END;
["CBA_loadoutSet", {
params ["_unit", "_loadout", "_extendedInfo"];
if (_extendedInfo getOrDefault ["ace_earplugs", false]) then {
_unit setVariable ["ACE_hasEarPlugsIn", true, true];
// Only force update volume if unit is a player (including remote controlled)
if (_unit call EFUNC(common,isPlayer)) then {
[QGVAR(updateVolume), [[true]], _unit] call CBA_fnc_targetEvent;
[QGVAR(updateVolume), true, _unit] call CBA_fnc_targetEvent;
};
};
}] call CBA_fnc_addEventHandler;
["CBA_loadoutGet", {
params ["_unit", "_loadout", "_extendedInfo"];
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then {
_extendedInfo set ["ace_earplugs", true]
};

View File

@ -1,24 +1,25 @@
#include "..\script_component.hpp"
/*
* Author: KoffeinFlummi, commy2, Rocko, Rommel, Ruthberg
* Handle new sound souce near ace_player and apply hearing damage
* Handle new sound souce near ace_player and apply hearing damage.
*
* Arguments:
* 0: strength of ear ringing <NUMBER>
* 0: Strength of ear ringing <NUMBER>
*
* Return Value:
* None
*
* Example:
* [_strength] call ace_hearing_fnc_earRinging
* 10 call ace_hearing_fnc_earRinging
*
* Public: No
*/
params ["_strength"];
if (_strength < 0.05) exitWith {};
if (!isNull curatorCamera) exitWith {};
if ((!GVAR(enabledForZeusUnits)) && {player != ACE_player}) exitWith {};
if (!GVAR(enabledForZeusUnits) && {player != ACE_player}) exitWith {};
TRACE_2("adding",_strength * GVAR(damageCoefficent),GVAR(deafnessDV));

View File

@ -4,8 +4,8 @@
* Handles deafness due to explosions going off near the player.
*
* Arguments:
* 0: vehicle - Object the event handler is assigned to (player) <OBJECT>
* 1: damage - Damage inflicted to the object <NUMBER>
* 0: Unit <OBJECT>
* 1: Damage inflicted to the unit <NUMBER>
*
* Return Value:
* None
@ -22,5 +22,5 @@ TRACE_2("explosion near player",_unit,_damage);
private _strength = (0 max _damage) * 30;
// Call inmediately, as it will get pick up later anyway by the update thread
[_strength] call FUNC(earRinging);
// Call immediately, as it will get picked up later by the update thread anyway
_strength call FUNC(earRinging);

View File

@ -59,5 +59,5 @@ private _strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance))
TRACE_1("result",_strength);
// Call inmediately, as it will get pick up later anyway by the update thread
[_strength] call FUNC(earRinging);
// Call immediately, as it will get picked up later by the update thread anyway
_strength call FUNC(earRinging);

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Reset earplugs on respawn, and then re-add if appropriate
* Reset earplugs on respawn, and then re-add if appropriate.
*
* Arguments:
* 0: Unit <OBJECT>
@ -10,29 +10,29 @@
* None
*
* Example:
* [player] call ACE_hearing_fnc_handleRespawn;
* player call ace_hearing_fnc_handleRespawn;
*
* Public: No
*/
// Do not add or remove earplugs if gear should be preserved
if (missionNamespace getVariable [QEGVAR(respawn,savePreDeathGear), false]) exitWith {};
params ["_unit"];
TRACE_2("params",_unit,typeOf _unit);
if (!local _unit) exitWith {}; //XEH should only be called on local units
//Do not add or remove earplugs if gear should be preserved
if (missionNamespace getVariable [QEGVAR(respawn,SavePreDeathGear), false]) exitWith {};
if (!local _unit) exitWith {}; // XEH should only be called on local units
private _respawn = [0] call BIS_fnc_missionRespawnType;
//if respawn is not Group or side:
// If respawn is not group or side:
if (_respawn <= 3) then {
//Remove earplugs if they have them:
// Remove earplugs if they have them:
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then {
TRACE_1("had EarPlugs in - removing",_unit);
_unit setVariable ["ACE_hasEarPlugsin", false, true];
};
};
//Re-add if they need them:
[_unit] call FUNC(addEarPlugs);
// Re-add if they need them
_unit call FUNC(addEarPlugs);

View File

@ -4,16 +4,17 @@
* Check if the unit has earplugs put in.
*
* Arguments:
* 0: Unit (player) <OBJECT>
* 0: Unit <OBJECT>
*
* Return Value:
* Have Earplugs in <BOOL>
* Has Earplugs in <BOOL>
*
* Example:
* [ace_player] call ace_hearing_fnc_hasEarPlugsIn
* player call ace_hearing_fnc_hasEarPlugsIn
*
* Public: No
*/
params ["_unit"];
_unit getVariable ["ACE_hasEarPlugsin", false]

View File

@ -10,7 +10,7 @@
* None
*
* Example:
* [player] call ACE_hearing_fnc_moduleHearing
* player call ace_hearing_fnc_moduleHearing
*
* Public: No
*/
@ -23,6 +23,8 @@ params ["_logic"];
if ((_logic getVariable "DisableEarRinging") != -1) then {
[_logic, QGVAR(DisableEarRinging), "DisableEarRinging"] call EFUNC(common,readSettingFromModule);
};
[_logic, QGVAR(enabledForZeusUnits), "enabledForZeusUnits"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(autoAddEarplugsToUnits), "autoAddEarplugsToUnits"] call EFUNC(common,readSettingFromModule);
INFO("Hearing Module Initialized.");

View File

@ -1,38 +1,35 @@
#include "..\script_component.hpp"
/*
* Author: Hope Johnson and commy2
* Author: Hope Johnson, commy2
* Puts in earplugs.
*
* Arguments:
* 0: Unit (player) <OBJECT>
* 0: Unit <OBJECT>
* 1: Display hint <BOOL> (default: false)
*
* Return Value:
* None
*
* Example:
* [ace_player, false] call ace_hearing_fnc_putInEarplugs
* [player, false] call ace_hearing_fnc_putInEarplugs
*
* Public: No
*/
params ["_player", ["_displayHint", false, [false]]];
if (!GVAR(enableCombatDeafness)) exitWith {};
if (!GVAR(EnableCombatDeafness)) exitWith {};
params ["_unit", ["_displayHint", false]];
// Plugs in inventory, putting them in
_player removeItem "ACE_EarPlugs";
_unit removeItem "ACE_EarPlugs";
_player setVariable ["ACE_hasEarPlugsIn", true, true];
_unit setVariable ["ACE_hasEarPlugsIn", true, true];
if (_displayHint) then {
[localize LSTRING(EarPlugs_Are_On)] call EFUNC(common,displayTextStructured);
[LLSTRING(EarPlugs_Are_On)] call EFUNC(common,displayTextStructured);
};
//Force an immediate fast volume update:
[[true]] call FUNC(updateVolume);
// Force an immediate volume update
true call FUNC(updateVolume);
// No Earplugs in inventory, telling user
//[localize LSTRING(NoPlugs)] call EFUNC(common,displayTextStructured);
[] call FUNC(updateHearingProtection);
call FUNC(updateHearingProtection);

View File

@ -1,39 +1,40 @@
#include "..\script_component.hpp"
/*
* Author: Hope Johnson and commy2
* Author: Hope Johnson, commy2
* Takes out earplugs.
*
* Arguments:
* 0: Unit (player) <OBJECT>
* 1: Display hint <BOOL> (default false)
* 0: Unit <OBJECT>
* 1: Display hint <BOOL> (default: false)
*
* Return Value:
* None
*
* Example:
* [ace_player, false] call ace_hearing_fnc_removeEarplugs
* [player, false] call ace_hearing_fnc_removeEarplugs
*
* Public: No
*/
params ["_player", ["_displayHint", false, [false]]];
if (!GVAR(enableCombatDeafness)) exitWith {};
if (!GVAR(EnableCombatDeafness)) exitWith {};
params ["_unit", ["_displayHint", false]];
if !([_player, "ACE_EarPlugs"] call CBA_fnc_canAddItem) exitWith { // inventory full
// Inventory full
if !([_unit, "ACE_EarPlugs"] call CBA_fnc_canAddItem) exitWith {
[LELSTRING(common,Inventory_Full)] call EFUNC(common,displayTextStructured);
};
// Plugs already in and removing them.
_player addItem "ACE_EarPlugs";
_unit addItem "ACE_EarPlugs";
_player setVariable ["ACE_hasEarPlugsIn", false, true];
_unit setVariable ["ACE_hasEarPlugsIn", false, true];
if (_displayHint) then {
[localize LSTRING(EarPlugs_Are_Off)] call EFUNC(common,displayTextStructured);
[LLSTRING(EarPlugs_Are_Off)] call EFUNC(common,displayTextStructured);
};
//Force an immediate fast volume update:
[[true]] call FUNC(updateVolume);
// Force an immediate volume update
true call FUNC(updateVolume);
[] call FUNC(updateHearingProtection);
call FUNC(updateHearingProtection);

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Updates the hearing protection and volume attenuation for player on earbuds/helmet change
* Updates the hearing protection and volume attenuation for player on earbuds/helmet change.
*
* Arguments:
* None
@ -10,12 +10,12 @@
* None
*
* Example:
* [] call ace_hearing_fnc_updateHearingProtection
* call ace_hearing_fnc_updateHearingProtection
*
* Public: No
*/
TRACE_1("params",_this);
LOG("updateHearingProtection");
if (isNull ACE_player) exitWith {
GVAR(damageCoefficent) = 0;
@ -23,22 +23,32 @@ if (isNull ACE_player) exitWith {
};
// Handle Earplugs
private _hasEarPlugsIn = [ACE_player] call FUNC(hasEarPlugsIn);
private _hasEarPlugsIn = ACE_player call FUNC(hasEarPlugsIn);
GVAR(damageCoefficent) = [1, 0.25] select _hasEarPlugsIn;
GVAR(volumeAttenuation) = [1, GVAR(EarplugsVolume)] select _hasEarPlugsIn;
GVAR(volumeAttenuation) = [1, GVAR(earplugsVolume)] select _hasEarPlugsIn;
// Handle Headgear
if (headgear ACE_player != "") then {
private _protection = getNumber (configFile >> "CfgWeapons" >> headgear ACE_player >> QGVAR(protection)) min 1;
private _headgear = headgear ACE_player;
if (_headgear != "") then {
private _heargearConfig = configFile >> "CfgWeapons" >> _headgear;
private _protection = getNumber (_heargearConfig >> QGVAR(protection)) min 1;
GVAR(damageCoefficent) = GVAR(damageCoefficent) * (1 - _protection);
private _attenuation = getNumber (configFile >> "CfgWeapons" >> headgear ACE_player >> QGVAR(lowerVolume)) min 1;
private _attenuation = getNumber (_heargearConfig >> QGVAR(lowerVolume)) min 1;
GVAR(volumeAttenuation) = GVAR(volumeAttenuation) * (1 - _attenuation);
};
// Handle Goggles
if (goggles ACE_player != "") then {
private _protection = getNumber (configFile >> "CfgGlasses" >> goggles ACE_player >> QGVAR(protection)) min 1;
private _goggles = goggles ACE_player;
if (_goggles != "") then {
private _gogglesConfig = configFile >> "CfgGlasses" >> _goggles;
private _protection = getNumber (_gogglesConfig >> QGVAR(protection)) min 1;
GVAR(damageCoefficent) = GVAR(damageCoefficent) * (1 - _protection);
private _attenuation = getNumber (configFile >> "CfgGlasses" >> goggles ACE_player >> QGVAR(lowerVolume)) min 1;
private _attenuation = getNumber (_gogglesConfig >> QGVAR(lowerVolume)) min 1;
GVAR(volumeAttenuation) = GVAR(volumeAttenuation) * (1 - _attenuation);
};

View File

@ -7,10 +7,10 @@
* None
*
* Return Value:
* Ammount that unit can hear outside <NUMBER>
* Amount that unit can hear outside <NUMBER>
*
* Example:
* [] call ace_hearing_fnc_updatePlayerVehAttenuation
* call ace_hearing_fnc_updatePlayerVehAttenuation
*
* Public: No
*/
@ -20,12 +20,14 @@ private _vehicle = vehicle ACE_player;
if (isNull _vehicle) exitWith {};
private _newAttenuation = 1;
if (ACE_player != _vehicle) then {
private _turretPath = [ACE_player] call EFUNC(common,getTurretIndex);
private _effectType = getText (configOf _vehicle >> "attenuationEffectType");
private _vehicleConfig = configOf _vehicle;
private _turretPath = _vehicle unitTurret ACE_player;
private _effectType = getText (_vehicleConfig >> "attenuationEffectType");
if (_turretPath isNotEqualTo []) then {
private _turretConfig = [(configOf _vehicle), _turretPath] call EFUNC(common,getTurretConfigPath);
private _turretConfig = [_vehicleConfig, _turretPath] call EFUNC(common,getTurretConfigPath);
if ((getNumber (_turretConfig >> "disableSoundAttenuation")) == 1) then {
_effectType = "";
@ -40,7 +42,7 @@ if (ACE_player != _vehicle) then {
case (_effectType == ""): {1};
case (_effectType == "CarAttenuation");
case (_effectType == "RHS_CarAttenuation"): { // Increase protection for armored cars
private _armor = getNumber (configOf _vehicle >> "HitPoints" >> "HitBody" >> "armor");
private _armor = getNumber (_vehicleConfig >> "HitPoints" >> "HitBody" >> "armor");
linearConversion [2, 8, _armor, 0.5, 0.3, true];};
case (_effectType == "OpenCarAttenuation"): {1};
case (_effectType == "TankAttenuation"): {0.1};

View File

@ -1,55 +1,60 @@
#include "..\script_component.hpp"
/*
* Author: commy2 and esteldunedain and Ruthberg
* Author: commy2, esteldunedain, Ruthberg
* Updates and applies the current deafness. Called every 1 sec from a PFEH.
*
* Arguments:
* 0: Args <ARRAY>
* - 0: Just update volume (skip ringing/recovery) <BOOL> (default: false)
* 0: Update volume only (skip ringing/recovery) <BOOL> (default: false)
*
* Return Value:
* None
*
* Example:
* [] call ace_hearing_fnc_updateVolume
* call ace_hearing_fnc_updateVolume
*
* Public: No
*/
if (!alive ACE_player) exitWith {
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
if (missionNamespace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
TRACE_1("dead - removing hearing effects",ACE_player);
[QUOTE(ADDON), 1, true] call EFUNC(common,setHearingCapability);
};
(_this select 0) params [["_justUpdateVolume", false]];
params [["_updateVolumeOnly", false]];
GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
GVAR(volume) = (1 - (GVAR(deafnessDV) / 20)) max 0.05;
TRACE_3("",GVAR(volume),GVAR(deafnessDV),GVAR(deafnessDV) - GVAR(deafnessPrior));
if (!_justUpdateVolume) then {
if (!_updateVolumeOnly) then {
// Ring if we got a big increase in the last second or enough accumulated damage
if (GVAR(deafnessDV) - GVAR(deafnessPrior) > 1 ||
GVAR(deafnessDV) > 10) then {
if (CBA_missionTime - GVAR(time3) < 3) exitWith {};
GVAR(time3) = CBA_missionTime;
if (!isGameFocused) exitWith {};
if (GVAR(deafnessDV) > 19.75) then {
playSound (["ACE_Combat_Deafness_Heavy", "ACE_Combat_Deafness_Heavy_NoRing"] select GVAR(DisableEarRinging));
playSound (["ACE_Combat_Deafness_Heavy", "ACE_Combat_Deafness_Heavy_NoRing"] select GVAR(disableEarRinging));
} else {
playSound (["ACE_Combat_Deafness_Medium", "ACE_Combat_Deafness_Medium_NoRing"] select GVAR(DisableEarRinging));
playSound (["ACE_Combat_Deafness_Medium", "ACE_Combat_Deafness_Medium_NoRing"] select GVAR(disableEarRinging));
};
};
GVAR(deafnessPrior) = GVAR(deafnessDV);
// Hearing takes longer to return to normal after it hits rock bottom
GVAR(deafnessDV) = (GVAR(deafnessDV) - (0.5 * (GVAR(volume) max 0.1))) max 0;
GVAR(deafnessDV) = (GVAR(deafnessDV) - (0.5 * (GVAR(volume) max 0.1))) max 0;
};
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
if (missionNamespace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
private _volume = GVAR(volume);
@ -57,8 +62,8 @@ private _volume = GVAR(volume);
_volume = _volume min GVAR(volumeAttenuation);
// Reduce volume if player is unconscious
if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
_volume = _volume min GVAR(UnconsciousnessVolume);
if (lifeState ACE_player == "INCAPACITATED") then {
_volume = _volume min GVAR(unconsciousnessVolume);
};
[QUOTE(ADDON), _volume, true] call EFUNC(common,setHearingCapability);

View File

@ -2,14 +2,17 @@
// Conditions: specific
if !([ACE_player, objNull, ["isNotSwimming", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false};
if (GVAR(EnableCombatDeafness) && {!([ACE_player] call FUNC(hasEarPlugsIn))} && {[ACE_player, "ACE_EarPlugs"] call EFUNC(common,hasItem)}) exitWith {
if (GVAR(enableCombatDeafness) && {!(ACE_player call FUNC(hasEarPlugsIn))} && {[ACE_player, "ACE_EarPlugs"] call EFUNC(common,hasItem)}) exitWith {
[ACE_player, true] call FUNC(putInEarPlugs);
true
};
if (GVAR(EnableCombatDeafness) && {[ACE_player] call FUNC(hasEarPlugsIn)}) exitWith {
[ACE_player, true] call FUNC(removeEarPlugs);
true
true // return
};
false
if (GVAR(enableCombatDeafness) && {ACE_player call FUNC(hasEarPlugsIn)}) exitWith {
[ACE_player, true] call FUNC(removeEarPlugs);
true // return
};
false // return
}] call CBA_fnc_addKeybind; // UNBOUND

View File

@ -1,7 +1,8 @@
private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)];
private _category = format ["ACE %1", LLSTRING(Module_DisplayName)];
[
QGVAR(enableCombatDeafness), "CHECKBOX",
QGVAR(enableCombatDeafness),
"CHECKBOX",
[LSTRING(EnableCombatDeafness_DisplayName), LSTRING(EnableCombatDeafness_Description)],
_category,
true,
@ -11,7 +12,8 @@ private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)];
] call CBA_fnc_addSetting;
[
QGVAR(earplugsVolume), "SLIDER",
QGVAR(earplugsVolume),
"SLIDER",
[LSTRING(earplugsVolume_DisplayName), LSTRING(earplugsVolume_Description)],
_category,
[0, 1, 0.5, 1],
@ -19,7 +21,8 @@ private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)];
] call CBA_fnc_addSetting;
[
QGVAR(unconsciousnessVolume), "SLIDER",
QGVAR(unconsciousnessVolume),
"SLIDER",
[LSTRING(unconsciousnessVolume_DisplayName), LSTRING(unconsciousnessVolume_Description)],
_category,
[0, 1, 0.4, 1],
@ -27,15 +30,16 @@ private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)];
] call CBA_fnc_addSetting;
[
QGVAR(disableEarRinging), "CHECKBOX",
QGVAR(disableEarRinging),
"CHECKBOX",
[LSTRING(DisableEarRinging_DisplayName), LSTRING(DisableEarRinging_Description)],
_category,
false,
0
false
] call CBA_fnc_addSetting;
[
QGVAR(enabledForZeusUnits), "CHECKBOX",
QGVAR(enabledForZeusUnits),
"CHECKBOX",
[LSTRING(enabledForZeusUnits_DisplayName), LSTRING(enabledForZeusUnits_Description)],
_category,
true,
@ -43,7 +47,8 @@ private _category = format ["ACE %1", localize LSTRING(Module_DisplayName)];
] call CBA_fnc_addSetting;
[
QGVAR(autoAddEarplugsToUnits), "LIST",
QGVAR(autoAddEarplugsToUnits),
"LIST",
[LSTRING(autoAddEarplugsToUnits_DisplayName), LSTRING(autoAddEarplugsToUnits_Description)],
_category,
[[0, 1, 2], [ELSTRING(common,Disabled), LSTRING(heavyWeaponUnits), ELSTRING(common,Enabled)], 1],