-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: johnb432 <[email protected]> Co-authored-by: Grim <[email protected]> Co-authored-by: LinkIsGrim <[email protected]>
- Loading branch information
1 parent
2f9b700
commit 1649422
Showing
20 changed files
with
206 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CfgWeapons { | ||
class H_HelmetB; | ||
class H_PilotHelmetFighter_B: H_HelmetB { | ||
GVAR(oxygenSupply) = QUOTE(vehicle _this isKindOf 'Plane' || vehicle _this isKindOf 'Helicopter'); | ||
}; | ||
class Vest_Camo_Base; | ||
class V_RebreatherB: Vest_Camo_Base { | ||
GVAR(oxygenSupply) = QUOTE(eyePos _this select 2 < 0); // will only work for sea-level water | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
PREP(handleUnitVitals); | ||
PREP(scanConfig); | ||
PREP(updateHeartRate); | ||
PREP(updateOxygen); | ||
PREP(updatePainSuppress); | ||
PREP(updatePeripheralResistance); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
#include "script_component.hpp" | ||
|
||
#include "XEH_PREP.hpp" | ||
|
||
GVAR(oxygenSupplyConditionCache) = createHashMap; | ||
|
||
call FUNC(scanConfig); | ||
|
||
GVAR(oxygenSupplyConditionCache) = compileFinal GVAR(oxygenSupplyConditionCache); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ class CfgPatches { | |
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "CfgWeapons.hpp" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: LinkIsGrim | ||
* Cache a hashmap of all oxygen-providing items for SpO2 simulation | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
private _filter = toString {getText (_x >> QGVAR(oxygenSupply)) != ""}; | ||
|
||
{ | ||
private _cfgRoot = configFile >> _x; | ||
{ | ||
private _condition = compile getText (_x >> QGVAR(oxygenSupply)); | ||
GVAR(oxygenSupplyConditionCache) set [configName _x, _condition]; | ||
} forEach (_filter configClasses _cfgRoot); | ||
} forEach ["CfgWeapons", "CfgGoggles"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Brett Mayson | ||
* Update the oxygen levels | ||
* | ||
* Arguments: | ||
* 0: The Unit <OBJECT> | ||
* 1: Time since last update <NUMBER> | ||
* 2: Sync value? <BOOL> | ||
* | ||
* ReturnValue: | ||
* Current SPO2 <NUMBER> | ||
* | ||
* Example: | ||
* [player, 1, false] call ace_medical_vitals_fnc_updateOxygen | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit", "_deltaT", "_syncValue"]; | ||
|
||
if (!GVAR(simulateSpO2)) exitWith {}; // changing back to default is handled in initSettings.inc.sqf | ||
|
||
#define IDEAL_PPO2 0.255 | ||
|
||
private _current = GET_SPO2(_unit); | ||
private _heartRate = GET_HEART_RATE(_unit); | ||
|
||
private _altitude = EGVAR(common,mapAltitude) + ((getPosASL _unit) select 2); | ||
private _po2 = if (missionNamespace getVariable [QEGVAR(weather,enabled), false]) then { | ||
private _temperature = _altitude call EFUNC(weather,calculateTemperatureAtHeight); | ||
private _pressure = _altitude call EFUNC(weather,calculateBarometricPressure); | ||
[_temperature, _pressure, EGVAR(weather,currentHumidity)] call EFUNC(weather,calculateOxygenDensity) | ||
} else { | ||
// Rough approximation of the partial pressure of oxygen in the air | ||
0.25725 * (_altitude / 1000 + 1) | ||
}; | ||
|
||
private _oxygenSaturation = (IDEAL_PPO2 min _po2) / IDEAL_PPO2; | ||
|
||
// Check gear for oxygen supply | ||
[goggles _unit, headgear _unit, vest _unit] findIf { | ||
_x in GVAR(oxygenSupplyConditionCache) && | ||
{ACE_player call (GVAR(oxygenSupplyConditionCache) get _x)} && | ||
{ // Will only run this if other conditions are met due to lazy eval | ||
_oxygenSaturation = 1; | ||
_po2 = IDEAL_PPO2; | ||
true | ||
} | ||
}; | ||
|
||
// Base oxygen consumption rate | ||
private _negativeChange = BASE_OXYGEN_USE; | ||
|
||
// Fatigue & exercise will demand more oxygen | ||
// Assuming a trained male in midst of peak exercise will have a peak heart rate of ~180 BPM | ||
// Ref: https://academic.oup.com/bjaed/article-pdf/4/6/185/894114/mkh050.pdf table 2, though we don't take stroke volume change into account | ||
if (_unit == ACE_player && {missionNamespace getVariable [QEGVAR(advanced_fatigue,enabled), false]}) then { | ||
_negativeChange = _negativeChange - ((1 - EGVAR(advanced_fatigue,aeReservePercentage)) * 0.1) - ((1 - EGVAR(advanced_fatigue,anReservePercentage)) * 0.05); | ||
}; | ||
|
||
// Effectiveness of capturing oxygen | ||
// increases slightly as po2 starts lowering | ||
// but falls off quickly as po2 drops further | ||
private _capture = 1 max ((_po2 / IDEAL_PPO2) ^ (-_po2 * 3)); | ||
private _positiveChange = _heartRate * 0.00368 * _oxygenSaturation * _capture; | ||
|
||
private _breathingEffectiveness = 1; | ||
|
||
private _rateOfChange = _negativeChange + (_positiveChange * _breathingEffectiveness); | ||
|
||
private _spo2 = (_current + (_rateOfChange * _deltaT)) max 0 min 100; | ||
|
||
_unit setVariable [VAR_OXYGEN_DEMAND, _negativeChange - BASE_OXYGEN_USE]; | ||
_unit setVariable [VAR_SPO2, _spo2, _syncValue]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
QGVAR(simulateSpO2), | ||
"CHECKBOX", | ||
[LSTRING(simulateSpO2_DisplayName), LSTRING(simulateSpO2_Description)], | ||
[ELSTRING(medical,Category), LSTRING(SubCategory)], | ||
true, | ||
1, | ||
{ | ||
if (_this) exitWith {}; // skip if true | ||
{ | ||
_x setVariable [VAR_OXYGEN_DEMAND, 0, true]; | ||
_x setVariable [VAR_SPO2, DEFAULT_SPO2, true]; | ||
} forEach (allUnits select {local _x}) | ||
} // reset oxygen demand on setting change | ||
] call CBA_fnc_addSetting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="ACE"> | ||
<Package name="Medical_Vitals"> | ||
<Key ID="STR_ACE_Medical_Vitals_SubCategory"> | ||
<English>Vitals</English> | ||
<Portuguese>Vitais</Portuguese> | ||
</Key> | ||
<Key ID="STR_ACE_Medical_Vitals_simulateSpO2_DisplayName"> | ||
<English>Enable SpO2 Simulation</English> | ||
</Key> | ||
<Key ID="STR_ACE_Medical_Vitals_simulateSpO2_Description"> | ||
<English>Enables oxygen saturation simulation, providing variable heart rate and oxygen demand based on physical activity and altitude. Required for Airway Management.</English> | ||
</Key> | ||
</Package> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Brett Mayson | ||
* Calculates the oxygen density | ||
* | ||
* Arguments: | ||
* 0: Temperature - °C <NUMBER> | ||
* 1: Pressure - hPa <NUMBER> | ||
* 2: Relative humidity - value between 0.0 and 1.0 <NUMBER> | ||
* | ||
* Return Value: | ||
* Density of oxygen - kg * m^(-3) <NUMBER> | ||
* | ||
* Example: | ||
* [0, 1020] call ace_weather_fnc_calculateOxygenDensity | ||
* | ||
* Public: No | ||
*/ | ||
|
||
(_this call FUNC(calculateAirDensity)) * 0.21 |