Skip to content

Commit

Permalink
Merge pull request #238 from MissHeda/dev-Tomcat
Browse files Browse the repository at this point in the history
Low SpO2, stamina lose change
  • Loading branch information
Tomcat-SG authored Jan 19, 2023
2 parents 8060b4a + 4fe8200 commit e6eb5dc
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 47 deletions.
3 changes: 2 additions & 1 deletion addons/breathing/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ PREP(treatmentAdvanced_pulseoximeterLocal);
PREP(treatmentAdvanced_removePulseoximeter);
PREP(treatmentAdvanced_tensionpneumothorax);
PREP(treatmentAdvanced_tensionpneumothoraxLocal);
PREP(listenLungs);
PREP(listenLungs);
PREP(lowSpO2pp);
1 change: 1 addition & 0 deletions addons/breathing/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
[QGVAR(hemopneumothoraxLocal), LINKFUNC(treatmentAdvanced_hemopneumothoraxLocal)] call CBA_fnc_addEventHandler;
[QGVAR(tensionpneumothoraxLocal), LINKFUNC(treatmentAdvanced_tensionpneumothoraxLocal)] call CBA_fnc_addEventHandler;
[QGVAR(cyanosisLocal), LINKFUNC(treatmentAdvanced_CyanosisLocal)] call CBA_fnc_addEventHandler;
[QGVAR(lowSpO2pp), LINKFUNC(lowSpO2pp)] call CBA_fnc_addEventHandler;

[QACEGVAR(medical,woundReceived),LINKFUNC(handlePulmoHit)] call CBA_fnc_addEventHandler;
54 changes: 8 additions & 46 deletions addons/breathing/functions/fnc_handleBreathing.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if (!local _unit) then {
[QGVAR(handleBreathing), [_unit], _unit] call CBA_fnc_targetEvent;
};

if (!(_unit getVariable [QGVAR(lowSpO2ppActive), false]) && hasInterface && ACE_Player == _unit) then {
[QGVAR(lowSpO2pp), [_unit], _unit] call CBA_fnc_targetEvent;
};

[{
params ["_args", "_idPFH"];
_args params ["_unit"];
Expand Down Expand Up @@ -146,58 +150,16 @@ if (!local _unit) then {
if (!(_unit getVariable ["ACE_isUnconscious",false]) && {_finalOutput <= GVAR(SpO2_unconscious)}) then {
[QACEGVAR(medical,CriticalVitals), _unit] call CBA_fnc_localEvent;
};

if (GVAR(enableSPO2Flashing)) then {
if (!(_unit getVariable ["ACE_isUnconscious",false]) && {_finalOutput <= GVAR(lowSPO2Level)}) then {
["ColorCorrections", 1500, [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]]] spawn
{
params ["_name", "_priority", "_effect", "_handle"];
while {
_handle = ppEffectCreate [_name, _priority];
_handle < 0
} do {
_priority = _priority + 1;
};
_handle ppEffectEnable true;
_handle ppEffectAdjust _effect;
_handle ppEffectCommit 0.7;

[{ params["_handle"];
ppEffectCommitted _handle
},
{ params["_handle"];
_handle ppEffectAdjust [1, 1, 0, [0, 0, 0, 0.9], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]];
_handle ppEffectCommit 0.7;

[{ params["_handle"];
ppEffectCommitted _handle
},
{ params["_handle"];
_handle ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]];
_handle ppEffectCommit 1.6;

[{ params["_handle"];
ppEffectCommitted _handle
},
{ params["_handle"];
_handle ppEffectEnable false;
ppEffectDestroy _handle;
}, [_handle]] call CBA_fnc_waitUntilAndExecute;

}, [_handle]] call CBA_fnc_waitUntilAndExecute;

}, [_handle]] call CBA_fnc_waitUntilAndExecute;
};
};
};


if(GVAR(staminaLossAtLowSPO2)) then {
if (!(_unit getVariable ["ACE_isUnconscious",false]) && {_finalOutput <= GVAR(lowSPO2Level)}) then {
if (ACEGVAR(advanced_fatigue,enabled)) then {
ACEGVAR(advanced_fatigue,anReserve) = ACEGVAR(advanced_fatigue,anReserve) - 30;
["LSDF", 1.5] call ACEFUNC(advanced_fatigue,addDutyFactor);
} else {
_unit setStamina(getStamina _unit - 3);
};
} else {
["LSDF"] call ACEFUNC(advanced_fatigue,removeDutyFactor);
};
};

Expand Down
73 changes: 73 additions & 0 deletions addons/breathing/functions/fnc_lowSpO2pp.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "script_component.hpp"
/*
* Author: Miss Heda, Digii
* Triggers the low SPO2 visual effect.
*
* Arguments:
* 0: Target <object>
*
*
* Return Value:
* None
*
* Example:
* [player] call kat_breathing_fnc_lowSpO2pp
*
* Public: No
*/

params ["_target"];

_target setVariable [QGVAR(lowSpO2ppActive), true, true];

[{

params ["_args", "_idPFH"];
_args params ["_target"];

_currentSpO2 = _target getVariable [QGVAR(airwayStatus), 100];
if (!(alive _target) || !([_target] call ACEFUNC(common,isAwake)) || _currentSpO2 > GVAR(lowSPO2Level)) exitWith {
_target setVariable [QGVAR(lowSpO2ppActive), false, true];
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

["ColorCorrections", 1500, [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]]] spawn
{
params ["_name", "_priority", "_effect", "_handle"];
while {
_handle = ppEffectCreate [_name, _priority];
_handle < 0
} do {
_priority = _priority + 1;
};
_handle ppEffectEnable true;
_handle ppEffectAdjust _effect;
_handle ppEffectCommit 0.7;

[{ params["_handle"];
ppEffectCommitted _handle
},
{ params["_handle"];
_handle ppEffectAdjust [1, 1, 0, [0, 0, 0, 0.9], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]];
_handle ppEffectCommit 0.7;

[{ params["_handle"];
ppEffectCommitted _handle
},
{ params["_handle"];
_handle ppEffectAdjust [1, 1, 0, [0, 0, 0, 0.1], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]];
_handle ppEffectCommit 1.6;

[{ params["_handle"];
ppEffectCommitted _handle
},
{ params["_handle"];
_handle ppEffectEnable false;
ppEffectDestroy _handle;
}, [_handle]] call CBA_fnc_waitUntilAndExecute;

}, [_handle]] call CBA_fnc_waitUntilAndExecute;

}, [_handle]] call CBA_fnc_waitUntilAndExecute;
};
}, 3, [_target]] call CBA_fnc_addPerFrameHandler;

0 comments on commit e6eb5dc

Please sign in to comment.