Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hearing - Add Electronic Hearing Protection #10476

Merged
merged 25 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e43b8d7
Refactor hearing capability, add fade duration
BaerMitUmlaut Oct 19, 2024
f09e784
Remove hasEarPlugsIn function
BaerMitUmlaut Oct 19, 2024
10d4c0d
Add base electronic hearing protection implementation
BaerMitUmlaut Oct 23, 2024
709abdc
Update macro
BaerMitUmlaut Oct 27, 2024
a77e8b5
Update docs
BaerMitUmlaut Oct 27, 2024
c165e91
Fix typo
BaerMitUmlaut Oct 27, 2024
62b2b72
Handle vehicle explosions
BaerMitUmlaut Nov 3, 2024
fa7d83e
Use effects volume again for ear ringing
BaerMitUmlaut Nov 3, 2024
92c69b6
Copy remaining functionality and docs from earplugs
BaerMitUmlaut Nov 3, 2024
123ed1e
Fix EHP muting with built in EHP
BaerMitUmlaut Nov 3, 2024
0eb6881
Fix docs
BaerMitUmlaut Nov 3, 2024
f915ba1
Remove hasEarPlugsIn again
BaerMitUmlaut Nov 4, 2024
cb2c68f
Remove outdated comment
BaerMitUmlaut Nov 4, 2024
b645624
Fix indentation
BaerMitUmlaut Nov 4, 2024
a093489
Lowercase ID for backwards compatibility
BaerMitUmlaut Nov 4, 2024
3b4d92e
Merge remote-tracking branch 'origin' into ehp
LinkIsGrim Dec 14, 2024
48c8bc3
fix stringtable
LinkIsGrim Dec 14, 2024
9616207
update logical order
LinkIsGrim Dec 16, 2024
9c3f6b4
add Field Manual stringtables
LinkIsGrim Dec 16, 2024
d0354eb
Merge remote-tracking branch 'origin' into ehp
LinkIsGrim Dec 16, 2024
b517d88
fix field manual
LinkIsGrim Dec 16, 2024
f29958c
arsenal stats
LinkIsGrim Dec 16, 2024
19382d6
fix field manual
LinkIsGrim Dec 16, 2024
3b172f0
Merge remote-tracking branch 'origin' into ehp
LinkIsGrim Dec 17, 2024
926d02a
stats
LinkIsGrim Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ACE_COUNTERS = [];

GVAR(statusEffects) = createHashMap;

GVAR(setHearingCapabilityMap) = [];
GVAR(setHearingCapabilityMap) = createHashMap;
BaerMitUmlaut marked this conversation as resolved.
Show resolved Hide resolved

[] call FUNC(setupLocalUnitsHandler); // Add local units event handlers (ace_common_localUnits)

Expand Down
43 changes: 15 additions & 28 deletions addons/common/functions/fnc_setHearingCapability.sqf
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "..\script_component.hpp"
/*
* Author: Glowbal
* Author: Glowbal, BaerMitUmlaut
* Handle set volume calls. Will use the lowest available volume setting.
*
* Arguments:
* 0: ID <STRING>
* 1: Settings <NUMBER>
* 2: Add (true) or remove (false) <BOOL> (default: true)
* 3: Volume fade duration <NUMBER> (default: 0)
*
* Return Value:
* None
Expand All @@ -17,40 +18,26 @@
* Public: Yes
*/

params ["_id", "_setting", ["_add", true]];
params ["_id", "_setting", ["_add", true], ["_fadeDuration", 0]];
BaerMitUmlaut marked this conversation as resolved.
Show resolved Hide resolved

private _exists = false;
private _lowestVolume = 1;
_id = toLowerANSI _id;

GVAR(setHearingCapabilityMap) = GVAR(setHearingCapabilityMap) select {
_x params ["_xID", "_xSetting"];
if (_id == _xID) then {
_exists = true;
if (_add) then {
_x set [1, _setting];
_lowestVolume = _lowestVolume min _setting;
true
} else {
false
};
} else {
_lowestVolume = _lowestVolume min _xSetting;
true
};
// Save setting
if (_add) then {
GVAR(setHearingCapabilityMap) set [_id, _setting];
} else {
GVAR(setHearingCapabilityMap) deleteAt _id;
};

if (!_exists && _add) then {
_lowestVolume = _lowestVolume min _setting;
GVAR(setHearingCapabilityMap) pushBack [_id, _setting];
};
private _lowestVolume = selectMin values GVAR(setHearingCapabilityMap);

// in game sounds
0 fadeSound _lowestVolume;
0 fadeRadio _lowestVolume;
// In-game sounds
_fadeDuration fadeSound _lowestVolume;
_fadeDuration fadeRadio _lowestVolume;
if (GVAR(allowFadeMusic)) then {
0 fadeMusic _lowestVolume;
_fadeDuration fadeMusic _lowestVolume;
};

// Set Radio mod variables.
// Set radio mod variables
ACE_player setVariable ["tf_globalVolume", _lowestVolume];
if (!isNil "acre_api_fnc_setGlobalVolume") then { [_lowestVolume^0.33] call acre_api_fnc_setGlobalVolume; };
44 changes: 26 additions & 18 deletions addons/fieldmanual/CfgHints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,68 +106,76 @@ class CfgHints {
description = CSTRING(Items_EarPlugs_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/hearing'>Hearing Wiki</a>";
};
class ACE_EntrenchingTool: ACE_FieldManual_Base {
class ACE_EHP: ACE_FieldManual_Base {
logicalOrder = 11;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_EHP' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_EHP_ShortName);
description = CSTRING(Items_EHP_Description);
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
tip = "<a href='https://ace3.acemod.org/wiki/feature/hearing'>Hearing Wiki</a>";
};
class ACE_EntrenchingTool: ACE_FieldManual_Base {
logicalOrder = 12;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_EntrenchingTool' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_EntrenchingTool_ShortName);
description = CSTRING(Items_EntrenchingTool_Description);
};
class ACE_Flashlights: ACE_FieldManual_Base {
logicalOrder = 12;
logicalOrder = 13;
displayName = CSTRING(Items_Flashlights_DisplayName);
displayNameShort = CSTRING(Items_Flashlights_ShortName);
description = CSTRING(Items_Flashlights_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/flashlights'>Flashlights Wiki</a>";
};
class ACE_FortifyTool: ACE_FieldManual_Base {
logicalOrder = 13;
logicalOrder = 14;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_Fortify' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_FortifyTool_ShortName);
description = CSTRING(Items_FortifyTool_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/fortify'>Fortify Wiki</a>";
};
class ACE_HuntIR_Monitor: ACE_FieldManual_Base {
logicalOrder = 14;
logicalOrder = 15;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_HuntIR_monitor' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_HuntIR_Monitor_ShortName);
description = CSTRING(Items_HuntIR_Monitor_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/huntir'>HuntIR Wiki</a>";
};
class ACE_IR_Strobe: ACE_FieldManual_Base {
logicalOrder = 15;
logicalOrder = 16;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_IR_Strobe_Item' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_IR_Strobe_ShortName);
description = CSTRING(Items_IR_Strobe_Description);
};
class ACE_Kestrel4500: ACE_FieldManual_Base {
logicalOrder = 16;
logicalOrder = 17;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_Kestrel4500' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_Kestrel4500_ShortName);
description = CSTRING(Items_Kestrel4500_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/kestrel4500'>Kestrel 4500 Wiki</a>";
};
class ACE_Lockpick: ACE_FieldManual_Base {
logicalOrder = 17;
logicalOrder = 18;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_key_lockpick' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_Lockpick_ShortName);
description = CSTRING(Items_Lockpick_Description);
tip = "<a href='https://ace3.acemod.org/wiki/framework/vehiclelock-framework.html'>Vehicle Lock Wiki</a>";
};
class ACE_MapTools: ACE_FieldManual_Base {
logicalOrder = 18;
logicalOrder = 19;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_MapTools' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_MapTools_ShortName);
description = CSTRING(Items_MapTools_Description);
};
class ACE_MicroDAGR: ACE_FieldManual_Base {
logicalOrder = 19;
logicalOrder = 20;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_microDAGR' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_MicroDAGR_ShortName);
Expand All @@ -176,66 +184,66 @@ class CfgHints {
};
// Combine all range tables under one roof [mortar, artillery, rifle]
class ACE_RangeTables: ACE_FieldManual_Base {
logicalOrder = 20;
logicalOrder = 21;
displayName = CSTRING(Items_RangeTables_DisplayName);
displayNameShort = CSTRING(Items_RangeTables_ShortName);
description = CSTRING(Items_RangeTables_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/rangecard'>Rangecard Wiki</a>";
};
class ACE_Ropes: ACE_FieldManual_Base {
logicalOrder = 21;
logicalOrder = 22;
displayName = CSTRING(Items_Ropes_DisplayName);
displayNameShort = CSTRING(Items_Ropes_ShortName);
description = CSTRING(Items_Ropes_Description);
};
class ACE_Sandbag: ACE_FieldManual_Base {
logicalOrder = 22;
logicalOrder = 23;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_Sandbag_empty' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_Sandbag_ShortName);
description = CSTRING(Items_Sandbag_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/sandbags'>Sandbag Wiki</a>";
};
class ACE_SpareBarrels: ACE_FieldManual_Base {
logicalOrder = 23;
logicalOrder = 24;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_SpareBarrel_Item' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_SpareBarrels_ShortName);
description = CSTRING(Items_SpareBarrels_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/overheating'>Overheating Wiki</a>";
};
class ACE_SprayPaint: ACE_FieldManual_Base {
logicalOrder = 24;
logicalOrder = 25;
displayName = CSTRING(Items_SprayPaint_DisplayName);
displayNameShort = CSTRING(Items_SprayPaint_ShortName);
description = CSTRING(Items_SprayPaint_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/tagging'>Tagging Wiki</a>";
};
class ACE_Tripod: ACE_FieldManual_Base {
logicalOrder = 25;
logicalOrder = 26;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_Tripod' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_Tripod_ShortName);
description = CSTRING(Items_Tripod_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/tripod'>Tripod Wiki</a>";
};
class ACE_UAVBattery: ACE_FieldManual_Base {
logicalOrder = 26;
logicalOrder = 27;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_UAVBattery' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_UAVBattery_ShortName);
description = CSTRING(Items_UAVBattery_Description);
tip = "<a href='https://ace3.acemod.org/wiki/feature/logistics-uavbattery'>UAV Battery Wiki</a>";
};
class ACE_VehicleKey: ACE_FieldManual_Base {
logicalOrder = 27;
logicalOrder = 28;
displayName = CSTRING(Items_VehicleKey_DisplayName);
displayNameShort = CSTRING(Items_VehicleKey_ShortName);
description = CSTRING(Items_VehicleKey_Description);
tip = "<a href='https://ace3.acemod.org/wiki/framework/vehiclelock-framework.html'>Vehicle Lock Wiki</a>";
};
class ACE_Wirecutter: ACE_FieldManual_Base {
logicalOrder = 28;
logicalOrder = 29;
arguments[] = {BASE_ARGUMENTS, QUOTE('ACE_wirecutter' call FUNC(getItemName))};
displayName = "%14";
displayNameShort = CSTRING(Items_Wirecutter_ShortName);
Expand Down
8 changes: 7 additions & 1 deletion addons/fieldmanual/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
<Korean>청력을 보호합니다</Korean>
<Japanese>聴覚の保護</Japanese>
</Key>
<Key ID="STR_ACE_FieldManual_Items_EHP_Description">
<English>%3Electronic Hearing Protection (EHP)%4 helps prevent hearing damage from repeat loud noises near a soldier. Differently from %3Ear Plugs%4, volume is only reduced when necessary. %3EHP%4 can also be built-in to certain types of %3Headgear%4 and %3Facewear%4.&lt;br/&gt;&lt;br/&gt;%3Usage:%4&lt;br/&gt;%2Use [%3%12%4] and select %3Equipment%4.&lt;br/&gt;%2Put on Electronic Hearing Protection%4.</English>
</Key>
<Key ID="STR_ACE_FieldManual_Items_EHP_ShortName">
<English>Protect Your Hearing, Electronically</English>
</Key>
<Key ID="STR_ACE_FieldManual_Items_EntrenchingTool_Description">
<English>The %3Entrenching Tool%4 allows soldiers to dig trenches to help defend their position. The soldier must be on soil in order to dig a trench.&lt;br/&gt;&lt;br/&gt;%3Usage:%4&lt;br/&gt;%2Equip an %3Entrenching Tool%4.&lt;br/&gt;%2Use [%3%12%4] and select %3Equipment%4.&lt;br/&gt;%2Select the type of trench you wish to build.</English>
<Spanish>La %3Pala de Trincheras%4 permite a los soldados excavar trincheras para ayudarles a defender su posición. El soldado debe estar sobre tierra para poder excavar una trinchera.&lt;br/&gt;&lt;br/&gt;%3Uso:%4&lt;br/&gt;%2Equipar la %3Pala de Trincheras%4.&lt;br/&gt;%2Usar [%3%12%4] y seleccionar %3Equipamiento%4.&lt;br/&gt;%2Seleccionar el tipo de trinchera que quieres construir.</Spanish>
Expand Down Expand Up @@ -440,7 +446,7 @@
<Japanese>三角測量で位置を特定</Japanese>
</Key>
<Key ID="STR_ACE_FieldManual_Items_MicroDAGR_Description">
<English>The %3MicroDAGR GPS%4 is an advanced version of the %3DAGR%4. It provides position, navigation, and timing (PNT) data to include:&lt;br/&gt;%2Compass and heading&lt;br/&gt;%2Date and hour synced to the mission&lt;br/&gt;%2Elevation (relative to sea level)&lt;br/&gt;%2Current speed&lt;br/&gt;%2GPS with topographic and satellite view&lt;br/&gt;%2Creating, naming, and deleting waypoints&lt;br/&gt;%2Friendly identification (Requires ACE BLUFOR Tracker Setting)&lt;br/&gt;Connection to the Vector-21 Rangefinder for data import (waypoint creation and grid reference of ranged targets)&lt;br/&gt;&lt;br/&gt;%3Usage:%4&lt;br/&gt;%2For usage instructions, please visit the dedicated %3MicroDAGR%4 wiki.</English>
<English>The %3MicroDAGR GPS%4 is an advanced version of the %3DAGR%4. It provides position, navigation, and timing (PNT) data to include:&lt;br/&gt;%2Compass and heading&lt;br/&gt;%2Date and hour synced to the mission&lt;br/&gt;%2Elevation (relative to sea level)&lt;br/&gt;%2Current speed&lt;br/&gt;%2GPS with topographic and satellite view&lt;br/&gt;%2Creating, naming, and deleting waypoints&lt;br/&gt;%2Friendly identification (Requires ACE BLUFOR Tracker Setting)&lt;br/&gt;%2Connection to the Vector-21 Rangefinder for data import (waypoint creation and grid reference of ranged targets)&lt;br/&gt;&lt;br/&gt;%3Usage:%4&lt;br/&gt;%2For usage instructions, please visit the dedicated %3MicroDAGR%4 wiki.</English>
<Spanish>El %3GPS MicroDAGR%4 es una versión avanzada del %3DAGR%4. Provee de posicionamiento, navegación y datos de temporización (PNT) que incluye:&lt;br/&gt;%2Brújula y dirección&lt;br/&gt;%2Fecha y hora sincronizada con la misión&lt;br/&gt;%2Elevación (relativa al nivel del mar)&lt;br/&gt;%2Velocidad actual&lt;br/&gt;%2GPS con vista topográfica y satelital&lt;br/&gt;%2Creación, nombrado y borrado de puntos de ruta&lt;br/&gt;%2Identificación de aliados (Requiere la opción de ACE BLUFOR Tracker)&lt;br/&gt;Conexión con el telémetro Vector-21 para importación de datos (creación de puntos de ruta y referenciado en eje de coordenada para objetivos a distancia)&lt;br/&gt;&lt;br/&gt;%3Uso:%4&lt;br/&gt;%2Para instrucciones de uso, por favor visita la Wiki dedicada de %3MicroDAGR%4.</Spanish>
<Italian>Il %3GPS MicroDAGR%4 è una versione avanzata del %3DAGR%4. Esso mostra dati su posizione, navigazione e tempismo (PNT), includendo:&lt;br/&gt;%2Bussola e azimut&lt;br/&gt;%2Data e ora sincronizzate con la missione&lt;br/&gt;%2Elevazione (dal livello del mare)&lt;br/&gt;%2Velocità attuale&lt;br/&gt;%2GPS con visuale topografica e satellitare&lt;br/&gt;%2Creazione, rinomina e rimozione di waypoint&lt;br/&gt;%2Identificazione di alleati (Richiede Impostazioni ACE BLUFOR Tracker)&lt;br/&gt;Connessione al Telemetro Vector-21 per importazione di dati (creazione waypoint e indicazione di griglia su bersagli puntati)&lt;br/&gt;&lt;br/&gt;%3Utilizzo:%4&lt;br/&gt;%2Per informazioni sull'utilizzo sei pregato di visitare la pagina wiki dedicata al %3MicroDAGR%4.</Italian>
<Polish>%3MicroDAGR GPS%4 jest zaawansowaną wersją %3DAGR%4. Dostarcza dane oparte o pozycję, nawigację, i czas (PNT): &lt;br/&gt;%2Kompas i kierunek&lt;br/&gt;%2Datę i godzinę zsynchronizowaną z misją&lt;br/&gt;%2Elewację (relatywną do poziomu morza)&lt;br/&gt;%2Obecną prędkość&lt;br/&gt;%2GPS z widokiem topograficznym i satelitarnym&lt;br/&gt;%2Tworzenie, nazywanie oraz usuwanie waypointów&lt;br/&gt;%2Identyfikację sojuszników (Wymaga ACE BLUFOR Tracker)&lt;br/&gt;Połączenie do dalmierza Vector-21 w celu importu danych (waypointy i współrzędne zmierzonego celu)&lt;br/&gt;&lt;br/&gt;%3Użycie: %4&lt;br/&gt;%2Po instrukcję użycia odwiedź %3MicroDAGR%4 wiki.</Polish>
Expand Down
16 changes: 10 additions & 6 deletions addons/hearing/ACE_Arsenal_Stats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ class EGVAR(arsenal,stats) {
class ACE_hearingProtection: statBase {
scope = 2;
priority = 2;
stats[] = {QGVAR(protection)};
displayName= CSTRING(statHearingProtection);
stats[] = {QGVAR(protection), QGVAR(hasEHP)};
displayName = CSTRING(statHearingProtection);
showBar = 1;
barStatement = QUOTE([ARR_3((_this select 0) select 0,_this select 1,[ARR_3([ARR_2(0,1)],[ARR_2(0.01,1)],false)])] call EFUNC(arsenal,statBarStatement_default));
tabs[] = {{6}, {}};
condition = QUOTE([ARR_2(_this select 0,_this select 1)] call EFUNC(arsenal,statCondition_existsAny));
barStatement = QUOTE([ARR_2(_this select 0,_this select 1)] call FUNC(statBarStatement_hearingProtection));
showText = 1;
textStatement = QUOTE(_this select 1 call FUNC(statTextStatement_hearingProtection));
tabs[] = {{6, 7}, {}};
};
class ACE_volumeMuffling: statBase {
scope = 2;
priority = 1.75;
stats[] = {QGVAR(lowerVolume)};
displayName= CSTRING(statHearingLowerVolume);
displayName = CSTRING(statHearingLowerVolume);
showBar = 1;
condition = QUOTE([ARR_2(_this select 0,_this select 1)] call EFUNC(arsenal,statCondition_existsAll));
barStatement = QUOTE([ARR_3((_this select 0) select 0,_this select 1,[ARR_3([ARR_2(0,1)],[ARR_2(0.01,1)],false)])] call EFUNC(arsenal,statBarStatement_default));
tabs[] = {{6}, {}};
tabs[] = {{6, 7}, {}};
};
};
33 changes: 33 additions & 0 deletions addons/hearing/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,36 @@ class Extended_Respawn_EventHandlers {
};
};
};

class Extended_Killed_EventHandlers {
class Car {
class ADDON {
killed = QUOTE(_this call FUNC(handleVehicleKilled));
};
};
class Tank {
class ADDON {
killed = QUOTE(_this call FUNC(handleVehicleKilled));
};
};
class Motorcycle {
class ADDON {
killed = QUOTE(_this call FUNC(handleVehicleKilled));
};
};
class Helicopter {
class ADDON {
killed = QUOTE(_this call FUNC(handleVehicleKilled));
};
};
class Plane {
class ADDON {
killed = QUOTE(_this call FUNC(handleVehicleKilled));
};
};
class Ship_F {
class ADDON {
killed = QUOTE(_this call FUNC(handleVehicleKilled));
};
};
};
Loading
Loading