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

Breathing - Re-add sounds for Breathing/Chemical conditions #658

Merged
merged 11 commits into from
Dec 16, 2024
1 change: 1 addition & 0 deletions addons/breathing/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PREP(gui_updateBodyImage);
PREP(gui_updateInjuryListPart);
PREP(gui_updateInjuryListWounds);
PREP(handleBreathing);
PREP(handleBreathingConditions);
PREP(handlePneumothoraxDeterioration);
PREP(handlePulmoHit);
PREP(handleRespawn);
Expand Down
2 changes: 2 additions & 0 deletions addons/breathing/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

[QEGVAR(misc,handleRespawn), LINKFUNC(handleRespawn)] call CBA_fnc_addEventHandler;

[QACEGVAR(medical_status,initialized), LINKFUNC(handleBreathingConditions)] call CBA_fnc_addEventHandler;

[QACEGVAR(medical_gui,updateInjuryListPart), LINKFUNC(gui_updateInjuryListPart)] call CBA_fnc_addEventHandler;
[QACEGVAR(medical_gui,updateInjuryListWounds), LINKFUNC(gui_updateInjuryListWounds)] call CBA_fnc_addEventHandler;
[QACEGVAR(medical_gui,updateBodyImage), LINKFUNC(gui_updateBodyImage)] call CBA_fnc_addEventHandler;
Expand Down
43 changes: 43 additions & 0 deletions addons/breathing/functions/fnc_handleBreathingConditions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "..\script_component.hpp"
/*
* Author: Mazinski
* Monitors breathing conditions.
*
* Arguments:
mazinskihenry marked this conversation as resolved.
Show resolved Hide resolved
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call kat_breathing_fnc_handleBreathingConcidtions;
*
* Public: No
*/

params ["_unit"];

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

private _alive = alive _unit;

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

private _spo2 = GET_KAT_SPO2(_unit);

if (GVAR(staminaLossAtLowSPO2)) then {
if (!(_unit getVariable ["ACE_isUnconscious",false]) && {_spo2 <= GVAR(lowSPO2Level)}) then {
if (ACEGVAR(advanced_fatigue,enabled)) then {
["kat_LSDF", 1.5] call ACEFUNC(advanced_fatigue,addDutyFactor);
} else {
_unit setStamina(getStamina _unit - 3);
};
} else {
["kat_LSDF"] call ACEFUNC(advanced_fatigue,removeDutyFactor);
};
};
}, 10, [_unit]] call CBA_fnc_addPerFrameHandler;
33 changes: 33 additions & 0 deletions addons/chemical/CfgSounds.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
class CfgSounds {
class GVAR(cough_0) {
name = QGVAR(cough_0);
sound[] =
{
QPATHTOF(audio\cough_0.ogg),
2,
1,
10
};
titles[] = {};
};
class GVAR(cough_1) {
name = QGVAR(cough_1);
sound[] =
Expand All @@ -10,6 +21,28 @@ class CfgSounds {
};
titles[] = {};
};
class GVAR(cough_2) {
name = QGVAR(cough_2);
sound[] =
{
QPATHTOF(audio\cough_2.ogg),
2,
1,
10
};
titles[] = {};
};
class GVAR(cough_3) {
name = QGVAR(cough_3);
sound[] =
{
QPATHTOF(audio\cough_3.ogg),
2,
1,
10
};
titles[] = {};
};

class GVAR(mask_breath_1) {
name = QGVAR(mask_breath_1);
Expand Down
Binary file added addons/chemical/audio/cough_0.ogg
Binary file not shown.
Binary file modified addons/chemical/audio/cough_1.ogg
Binary file not shown.
Binary file added addons/chemical/audio/cough_2.ogg
Binary file not shown.
Binary file added addons/chemical/audio/cough_3.ogg
Binary file not shown.
3 changes: 2 additions & 1 deletion addons/chemical/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ _patient setVariable [QGVAR(gasmask_durability), 10, true];
_patient setVariable [QGVAR(CSGas), 0, true];
_patient setVariable [QGVAR(airPoisoning), false, true];
_patient setVariable [QGVAR(infectionTime), missionNamespace getVariable [QGVAR(infectionTime), 60], true];
_patient setVariable [QGVAR(infectionArray), [], true];
_patient setVariable [QGVAR(infectionArray), [], true];
_patient setVariable [QGVAR(CoughCooldown), false, true];
4 changes: 4 additions & 0 deletions addons/chemical/functions/fnc_poison.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ if (_currentInfection != _newTime) then {

// Exit if infection reaches 0
if (_newTime <= 0) then {
if !(_unit getVariable [QGVAR(airPoisoning), false]) then {
[QEGVAR(breathing,playCough), [_unit], _unit] call CBA_fnc_targetEvent;
};

_unit setVariable [QGVAR(airPoisoning), true, true];
};
1 change: 1 addition & 0 deletions addons/feedback/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PREP(effectBreathingWheeze);
PREP(effectCoughing);
PREP(effectLowSpO2);
PREP(effectOpioid);
Expand Down
37 changes: 37 additions & 0 deletions addons/feedback/functions/fnc_effectBreathingWheeze.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "..\script_component.hpp"
/*
* Author: Mazinski
* Triggers the wheezing effect.
*
* Arguments:
* 0: Enable <BOOL>
* 1: Intensity <NUMBER>
* 2: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [true, 0.5, player] call kat_feedback_fnc_effectBreathingWheeze;
*
* Public: No
*/

params ["_enable", "_effected", "_unit"];
if (!_enable || !_effected) exitWith { false };

if (!(_unit getVariable [QEGVAR(breathing,PneumoBreathCooldownOn), false])) then {
_unit setVariable [QEGVAR(breathing,PneumoBreathCooldownOn), true, true];

private _soundTargets = allPlayers inAreaArray [ASLToAGL getPosASL _unit, 15, 15, 0, false, 15];

if !(_soundTargets isEqualTo []) then {
[QEGVAR(breathing,playCough), [_unit], _soundTargets] call CBA_fnc_targetEvent;
};

[{
params["_unit"];
_unit setVariable [QEGVAR(breathing,PneumoBreathCooldownOn), false, true];
},
[_unit], 20] call CBA_fnc_waitAndExecute;
};
28 changes: 23 additions & 5 deletions addons/feedback/functions/fnc_effectCoughing.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,48 @@
* Arguments:
* 0: Enable <BOOL>
* 1: Intensity <NUMBER>
* 2: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [true, 0.5] call kat_feedback_fnc_effectCoughing;
* [true, 0.5, player] call kat_feedback_fnc_effectCoughing;
*
* Public: No
*/

params ["_enable", "_poisoned"];
params ["_enable", "_poisoned", "_unit"];
if (!_enable || !_poisoned) exitWith {
if (GVAR(airPoisoning) != -1) then { GVAR(airPoisoning) ppEffectEnable false; };
};
if (GVAR(airPoisoning) != -1) then { GVAR(airPoisoning) ppEffectEnable true; };

if (!(_unit getVariable [QEGVAR(chemical,CoughCooldown), false])) then {
_unit setVariable [QEGVAR(chemical,CoughCooldown), true, true];

private _random = floor (random 4);
switch (_random) do {
case 0: { _unit say3D QEGVAR(chemical,cough_0); };
case 1: { _unit say3D QEGVAR(chemical,cough_1); };
case 2: { _unit say3D QEGVAR(chemical,cough_2); };
case 3: { _unit say3D QEGVAR(chemical,cough_3); };
};

addCamShake [3, 4, 0];

[{
params["_unit"];
_unit setVariable [QEGVAR(chemical,CoughCooldown), false, true];
},
[_unit], 7] call CBA_fnc_waitAndExecute;
};

// Trigger effect every 2s
private _showNextTick = missionNamespace getVariable [QGVAR(showCoughNextTick), true];
GVAR(showCoughNextTick) = !_showNextTick;
if (_showNextTick) exitWith {};

_unit say3D QEGVAR(chemical,cough_1);
addCamShake [3, 4, 0];

private _initialAdjust = [];
private _delayedAdjust = [];

Expand Down
5 changes: 3 additions & 2 deletions addons/feedback/functions/fnc_handleEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ private _spO2 = GET_KAT_SPO2(ACE_player);
private _unconscious = IS_UNCONSCIOUS(ACE_player);
private _poisoned = IS_AIRPOISONED(ACE_player);
private _tear = IN_TEARGAS(ACE_player);
private _wheeze = ((ACE_player getVariable [QGVAR(pneumothorax), 0] > 0) || ACE_player getVariable [QGVAR(hemopneumothorax), false] || ACE_player getVariable [QGVAR(tensionpneumothorax), false] || ACE_player getVariable [QEGVAR(chemical,airPoisoning), false]);

// - Visual effects -----------------------------------------------------------

Expand All @@ -39,8 +40,8 @@ private _tear = IN_TEARGAS(ACE_player);
linearConversion [GVAR(effectLowSpO2), EGVAR(breathing,SpO2_dieValue), _spO2, 0, 1, true]
] call FUNC(effectLowSpO2);

[!_unconscious, _poisoned] call FUNC(effectCoughing);
[!_unconscious, _poisoned, ACE_player] call FUNC(effectCoughing);
[!_unconscious, _tear] call FUNC(effectTearHaze);

[!_unconscious, _wheeze, ACE_player] call (effectBreathingWheeze);

END_COUNTER(handleEffects);
Loading