Skip to content

Commit

Permalink
Move to seperate file
Browse files Browse the repository at this point in the history
  • Loading branch information
mazinskihenry committed Dec 16, 2024
1 parent 9c62c7f commit ce6b958
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 44 deletions.
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
66 changes: 66 additions & 0 deletions addons/breathing/functions/fnc_handleBreathingConditions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "..\script_component.hpp"
/*
* Author: Katalam
* Called when a unit is damaged.
*
* Arguments:
* 0: Unit That Was Hit <OBJECT>
* 1: Damage done to each body part <ARRAY>
* 0: Damage <NUMBER>
* 1: Bodypart <STRING>
* 2: Shooter <OBJECT>
* 3: Ammo classname or damage type <STRING>
*
* Return Value:
* None
*
* Example:
* [cursorTarget, [1, "Body"], objNull, "BulletBase"] call kat_breathing_fnc_handlePulmoHit;
*
* 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);
};
};

if ((_unit getVariable [QGVAR(pneumothorax), 0] > 0) || _unit getVariable [QGVAR(hemopneumothorax), false] || _unit getVariable [QGVAR(tensionpneumothorax), false] || _unit getVariable [QEGVAR(chemical,airPoisoning), false]) then {
if (!(_unit getVariable [QACEGVAR(medical,inCardiacArrest), false]) && !(_unit getVariable [QGVAR(PneumoBreathCooldownOn), false])) then {
_unit setVariable [QGVAR(PneumoBreathCooldownOn), true, true];

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

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

[{
params["_unit"];
_unit setVariable [QGVAR(PneumoBreathCooldownOn), false, true];
},
[_unit], 20] call CBA_fnc_waitAndExecute;
};
};
}, 10, [_unit]] call CBA_fnc_addPerFrameHandler;
45 changes: 1 addition & 44 deletions addons/breathing/functions/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,4 @@ _unit setVariable [QGVAR(PulseOximeter_Volume), true, true];
_unit setVariable [QGVAR(PulseOximeter_VolumePatient), false, true];

_unit setVariable [QGVAR(oxygenMaskActive), false, true];
_unit setVariable [QGVAR(oxygenMaskStatus), [0,0], true];

[{
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);
};
};

if ((_unit getVariable [QGVAR(pneumothorax), 0] > 0) || _unit getVariable [QGVAR(hemopneumothorax), false] || _unit getVariable [QGVAR(tensionpneumothorax), false] || _unit getVariable [QEGVAR(chemical,airPoisoning), false]) then {
if (!(_unit getVariable [QACEGVAR(medical,inCardiacArrest), false]) && !(_unit getVariable [QGVAR(PneumoBreathCooldownOn), false])) then {
_unit setVariable [QGVAR(PneumoBreathCooldownOn), true, true];

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

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

[{
params["_unit"];
_unit setVariable [QGVAR(PneumoBreathCooldownOn), false, true];
},
[_unit], 20] call CBA_fnc_waitAndExecute;
};
};
}, 10, [_unit]] call CBA_fnc_addPerFrameHandler;
_unit setVariable [QGVAR(oxygenMaskStatus), [0,0], true];

0 comments on commit ce6b958

Please sign in to comment.