Skip to content

Commit

Permalink
Chemical - Change Chemical Detector Sound (#659)
Browse files Browse the repository at this point in the history
**When merged this pull request will:**
- Changes the JCAD sound to multiple chimes which change with intensity
- Adds ACE Interact option to turn off chimes

### IMPORTANT

- [Development Guidelines](https://ace3.acemod.org/wiki/development/)
are read, understood and applied.
- Title of this PR uses our standard template `Component -
Add|Fix|Improve|Change|Make|Remove {changes}`.
  • Loading branch information
mazinskihenry authored Dec 16, 2024
1 parent da58eb5 commit 0d926d1
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 32 deletions.
67 changes: 66 additions & 1 deletion addons/chemical/CfgSounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,70 @@ class CfgSounds {
};
titles[] = {};
};

class GVAR(chemBaseChime) {
name = QGVAR(chemBaseChime);
sound[] =
{
QPATHTOF(audio\baseChime.ogg),
2,
1.0,
5
};
titles[] = {};
};
class GVAR(chemSlowChime) {
name = QGVAR(chemSlowChime);
sound[] =
{
QPATHTOF(audio\slowChime.ogg),
2,
1.0,
5
};
titles[] = {};
};
class GVAR(chemNormalChime) {
name = QGVAR(chemNormalChime);
sound[] =
{
QPATHTOF(audio\normalChime.ogg),
2,
1.0,
5
};
titles[] = {};
};
class GVAR(chemFastChime) {
name = QGVAR(chemFastChime);
sound[] =
{
QPATHTOF(audio\fastChime.ogg),
2,
1.0,
5
};
titles[] = {};
};
class GVAR(chemRapidChime) {
name = QGVAR(chemRapidChime);
sound[] =
{
QPATHTOF(audio\rapidChime.ogg),
2,
1.0,
5
};
titles[] = {};
};
class GVAR(chemTone) {
name = QGVAR(chemTone);
sound[] =
{
QPATHTOF(audio\tone.ogg),
2,
1.0,
5
};
titles[] = {};
};
};
39 changes: 35 additions & 4 deletions addons/chemical/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,66 @@ class CfgVehicles {
class KAT_CheckGasMaskDur {
displayName = CSTRING(CheckGasMaskDurability);
condition = QUOTE([_player] call FUNC(hasGasMaskOn));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
exceptions[] = {"isNotSwimming"};
statement = QUOTE(_this call FUNC(checkGasMaskDur));
showDisabled = 0;
icon = QPATHTOF(ui\Gasmask_icon.paa);
};
class KAT_ChangeGasMaskFilter {
displayName = CSTRING(ChangeGasMaskFilter);
condition = QUOTE([_player] call FUNC(canReplaceFilter));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
exceptions[] = {"isNotSwimming"};
statement = QUOTE(_this call FUNC(changeGasMaskFilter));
showDisabled = 0;
icon = QPATHTOF(ui\gasmaskfilter_ca.paa);
};
class KAT_PutOnGasMask {
displayName = CSTRING(PutOnGasMask);
condition = QUOTE([_player] call FUNC(canPutOnGasMask));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
exceptions[] = {"isNotSwimming"};
statement = QUOTE([_player] call FUNC(putOnGasMask));
showDisabled = 0;
icon = QPATHTOF(ui\Gasmask_icon.paa);
};
class KAT_TakeOffGasMask {
displayName = CSTRING(TakeOffGasMask);
condition = QUOTE([_player] call FUNC(canTakeOffGasMask));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"};
exceptions[] = {"isNotSwimming"};
statement = QUOTE([_player] call FUNC(takeOffGasMask));
showDisabled = 0;
icon = QPATHTOF(ui\Gasmask_icon.paa);
};

class KAT_ChemicalDetector {
displayName = CSTRING(ChemicalDetector_Menu);
icon = QPATHTOF(ui\kat_chemicalDet_icon.paa);
exceptions[] = {"isNotSwimming"};

class KAT_ChemicalDetector_Enable {
displayName = CSTRING(EnableDetector);
condition = QUOTE(([_player] call FUNC(hasDetector)) && !(_player getVariable [ARR_2(QQGVAR(detectorEnabled),false)]));
exceptions[] = {"isNotSwimming"};
statement = QUOTE([_player] call FUNC(enableChemDetector));
showDisabled = 0;
icon = QPATHTOF(ui\kat_chemicalDet_icon.paa);
};
class KAT_ChemicalDetector_SoundOn {
displayName = CSTRING(EnableDetectorSound);
condition = QUOTE(!(_player getVariable [ARR_2(QQGVAR(detectorSound),false)]) && ([_player] call FUNC(hasDetector)));
exceptions[] = {"isNotSwimming"};
statement = QUOTE(_player setVariable [ARR_3(QQGVAR(detectorSound),true,true)]);
showDisabled = 0;
icon = QPATHTOF(ui\kat_chemicalDet_icon.paa);
};
class KAT_ChemicalDetector_SoundOff {
displayName = CSTRING(DisableDetectorSound);
condition = QUOTE((_player getVariable [ARR_2(QQGVAR(detectorSound),false)]) && ([_player] call FUNC(hasDetector)));
exceptions[] = {"isNotSwimming"};
statement = QUOTE(_player setVariable [ARR_3(QQGVAR(detectorSound),false,true)]);
showDisabled = 0;
icon = QPATHTOF(ui\kat_chemicalDet_icon.paa);
};
};
};
};
};
Expand Down
2 changes: 2 additions & 0 deletions addons/chemical/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PREP(checkGasMaskDur);
PREP(createSealAction);
PREP(csGrenade);
PREP(displayGasMaskDur);
PREP(enableChemDetector);
PREP(fullHealLocal);
PREP(gasManagerPFH);
PREP(gasmodule);
Expand All @@ -21,6 +22,7 @@ PREP(gui_updateInjuryListGeneral);
PREP(handleFired);
PREP(handleGasMaskDur);
PREP(handleRespawn);
PREP(hasDetector);
PREP(hasGasmask);
PREP(hasGasMaskON);
PREP(hideChemDetector);
Expand Down
5 changes: 5 additions & 0 deletions addons/chemical/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
[QGVAR(handleGasMaskDur), LINKFUNC(handleGasMaskDur)] call CBA_fnc_addEventHandler;
[QGVAR(addSealAction), LINKFUNC(createSealAction)] call CBA_fnc_addEventHandler;

[QGVAR(playTone), {
params ["_unit", "_tone"];
_unit say3D [_tone, 5];
}] call CBA_fnc_addEventHandler;

// ACE Events
[QACEGVAR(medical_gui,updateInjuryListGeneral), LINKFUNC(gui_updateInjuryListGeneral)] call CBA_fnc_addEventHandler;
[QACEGVAR(medical_gui,updateBodyImage), LINKFUNC(gui_updateBodyImage)] call CBA_fnc_addEventHandler;
Expand Down
Binary file added addons/chemical/audio/baseChime.ogg
Binary file not shown.
Binary file added addons/chemical/audio/fastChime.ogg
Binary file not shown.
Binary file added addons/chemical/audio/normalChime.ogg
Binary file not shown.
Binary file added addons/chemical/audio/rapidChime.ogg
Binary file not shown.
Binary file added addons/chemical/audio/slowChime.ogg
Binary file not shown.
Binary file added addons/chemical/audio/tone.ogg
Binary file not shown.
50 changes: 50 additions & 0 deletions addons/chemical/functions/fnc_enableChemDetector.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "..\script_component.hpp"
/*
* Author: Mazinski
* Enables the audio on the Chemical Detector.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call kat_chemical_enableChemDetector
*
* Public: No
*/

params ["_unit"];

_unit setVariable [QGVAR(detectorEnabled), true, true];

[{
params ["_args", "_idPFH"];
_args params ["_unit"];

private _alive = alive _unit;

if (!_alive) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

if !("KAT_ChemicalDetector" in assignedItems _unit) exitWith {
_unit setVariable [QGVAR(detectorEnabled), false, true];
_pfhID call CBA_fnc_removePerFrameHandler;
};

private _detectorSound = _unit getVariable [QGVAR(detectorSound), false];
private _intensity = _unit getVariable [QGVAR(areaIntensity), 0];

if (_detectorSound) then {
switch true do {
case (_intensity > 0.9): { [QGVAR(playTone), [_unit, QGVAR(chemTone)], _unit] call CBA_fnc_targetEvent; };
case (_intensity > 0.7): { [QGVAR(playTone), [_unit, QGVAR(chemRapidChime)], _unit] call CBA_fnc_targetEvent; };
case (_intensity > 0.5): { [QGVAR(playTone), [_unit, QGVAR(chemFastChime)], _unit] call CBA_fnc_targetEvent; };
case (_intensity > 0.3): { [QGVAR(playTone), [_unit, QGVAR(chemNormalChime)], _unit] call CBA_fnc_targetEvent; };
case (_intensity > 0): { [QGVAR(playTone), [_unit, QGVAR(chemSlowChime)], _unit] call CBA_fnc_targetEvent; };
default { [QGVAR(playTone), [_unit, QGVAR(chemBaseChime)], _unit] call CBA_fnc_targetEvent; };
};
};
}, 5, [_unit]] call CBA_fnc_addPerFrameHandler;
7 changes: 1 addition & 6 deletions addons/chemical/functions/fnc_handleRespawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,4 @@ params ["_unit"];

[_unit] call FUNC(fullHealLocal);

"kat_CHEM_DETECTOR" cutRsc ["RscWeaponChemicalDetector", "PLAIN", 1, false];
private _ui = uiNamespace getVariable "RscWeaponChemicalDetector";
private _obj = _ui displayCtrl 101;
_obj ctrlAnimateModel ["Threat_Level_Source", 0, true];

_unit setVariable [QGVAR(lastSoundTime), CBA_missionTime, true];
_unit setVariable [QGVAR(detectorSound), false, true];
24 changes: 24 additions & 0 deletions addons/chemical/functions/fnc_hasDetector.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "..\script_component.hpp"
/*
* Author: DiGii
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Bool
*
* Example:
* [player, cursorTarget] call kat_chemical_fnc_hasGasmask;
*
* Public: No
*/

params ["_unit"];

if ("KAT_ChemicalDetector" in assignedItems _unit) exitWith {
true
};

false
2 changes: 1 addition & 1 deletion addons/chemical/functions/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ if (!local _unit) exitWith {};

[_unit] call FUNC(fullHealLocal);

_unit setVariable [QGVAR(lastSoundTime), CBA_missionTime, true];
_unit setVariable [QGVAR(detectorSound), false, true];
31 changes: 11 additions & 20 deletions addons/chemical/functions/fnc_showChemDetector.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Author: Garth 'L-H' de Wet
* Modified: Mazinski
* Displays the KWatch on screen.
* Displays the JCAD on screen.
*
* Arguments:
* 0: unit <OBJECT>
Expand All @@ -11,7 +11,7 @@
* None
*
* Example:
* [player] call kat_watch_fnc_showKWatch
* [player] call kat_chemical_fnc_showChemDetector
*
* Public: Yes
*/
Expand Down Expand Up @@ -47,30 +47,21 @@ private _exposure = _display displayCtrl 18805;
_pfhID call CBA_fnc_removePerFrameHandler;
};

private _hour = floor dayTime;
private _minute = floor ((dayTime - _hour) * 60);

_time ctrlSetText (format ["%1:%2", [_hour, 2] call CBA_fnc_formatNumber, [_minute, 2] call CBA_fnc_formatNumber]);

private _intensity = _unit getVariable [QGVAR(areaIntensity), 0];

_exposure ctrlSetText (_intensity toFixed 2);
if ((_unit getVariable [QGVAR(detectorEnabled), false])) then {

if (_intensity > 0) then {
private _lastSoundTime = _unit getVariable QGVAR(lastSoundTime);
_unit setVariable [QGVAR(areaIntensity), 0, true];
private _hour = floor dayTime;
private _minute = floor ((dayTime - _hour) * 60);

_time ctrlSetText (format ["%1:%2", [_hour, 2] call CBA_fnc_formatNumber, [_minute, 2] call CBA_fnc_formatNumber]);

if (isNil "_lastSoundTime") then {
TRACE_1("undefined lastSoundTime: setting to current time",_lastSoundTime);
_unit setVariable [QGVAR(lastSoundTime), CBA_missionTime];
};
_exposure ctrlSetText (_intensity toFixed 2);

if (CBA_missionTime - _lastSoundTime > 6) exitWith {
playSound3D [QPATHTOF(audio\chemDetector.ogg), _unit, false, getPosASL _unit, 4, 1, 10];
_unit setVariable [QGVAR(lastSoundTime), CBA_missionTime];
};
_unit setVariable [QGVAR(areaIntensity), _intensity, true];
} else {
_unit setVariable [QGVAR(areaIntensity), 0, true];
_time ctrlSetText (LLSTRING(ChemicalDetector_Off));
_exposure ctrlSetText ("-.--");
};

}, 1, [
Expand Down
15 changes: 15 additions & 0 deletions addons/chemical/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@
<French>Utilisé pour détecter les produits chimiques toxiques KAT</French>
<Japanese>KAT毒性化学物質の検出に使用</Japanese>
</Key>
<Key ID="STR_KAT_Chemical_ChemicalDetector_Off">
<English>OFF</English>
</Key>
<Key ID="STR_KAT_Chemical_giveGasMask_action">
<English>Put on gas mask</English>
<Spanish>Poner mascara de gas</Spanish>
Expand Down Expand Up @@ -797,6 +800,18 @@
<Japanese>ガスマスクを外す</Japanese>
<French>Enlever le masque à gaz</French>
</Key>
<Key ID="STR_KAT_Chemical_ChemicalDetector_Menu">
<English>JCAD</English>
</Key>
<Key ID="STR_KAT_Chemical_EnableDetector">
<English>Turn On Detector</English>
</Key>
<Key ID="STR_KAT_Chemical_EnableDetectorSound">
<English>Enable Warning Tone</English>
</Key>
<Key ID="STR_KAT_Chemical_DisableDetectorSound">
<English>Disable Warning Tone</English>
</Key>
<Key ID="STR_KAT_Chemical_SETTING_dropWeaponChance">
<English>Drop Weapon Chance</English>
</Key>
Expand Down

0 comments on commit 0d926d1

Please sign in to comment.