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

Vitals - Fluid Shift and Recovery Position fixes #622

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
acd85e3
Fluid Shift and Recovery Position fixes
mazinskihenry Oct 14, 2024
d635ead
Final watch fix
mazinskihenry Oct 14, 2024
12b0ae3
Update fnc_handleUnitVitals.sqf
mazinskihenry Oct 14, 2024
c98fa2a
Update RscTitles.hpp
mazinskihenry Oct 15, 2024
4e9232f
Merge branch '3.0.3-Fixes' of https://github.com/mazinskihenry/KAM in…
mazinskihenry Oct 15, 2024
0da5df5
Merge branch 'dev-Tomcat' into 3.0.3-Fixes
mazinskihenry Oct 15, 2024
617822d
AI Medical Fix
mazinskihenry Oct 15, 2024
1bd9277
Merge branch '3.0.3-Fixes' of https://github.com/mazinskihenry/KAM in…
mazinskihenry Oct 15, 2024
18f72a8
Update fnc_handleRespawn.sqf
mazinskihenry Oct 15, 2024
8d53744
Update fnc_fullHealLocal.sqf
mazinskihenry Oct 15, 2024
fb05492
Update fnc_handleUnitVitals.sqf
mazinskihenry Oct 15, 2024
2b97c96
Update fnc_fullHealLocal.sqf
mazinskihenry Oct 15, 2024
d2d1f27
Update fnc_handleRespawn.sqf
mazinskihenry Oct 15, 2024
9574c93
Update XEH_preInit.sqf
mazinskihenry Oct 15, 2024
f2216f4
Update fnc_handleUnitVitals.sqf
mazinskihenry Oct 15, 2024
de38c52
Update fnc_handleUnitVitals.sqf
mazinskihenry Oct 15, 2024
38e686d
Update fnc_getBloodVolumeChange.sqf
mazinskihenry Oct 15, 2024
332db4f
Update fnc_getBloodVolumeChange.sqf
mazinskihenry Oct 15, 2024
89d1a9d
Update stringtable.xml
mazinskihenry Oct 15, 2024
36b14ab
Update fnc_handleUnitVitals.sqf
mazinskihenry Oct 15, 2024
1c86203
Update fnc_handleUnitVitals.sqf
mazinskihenry Oct 15, 2024
97d8291
Update stringtable.xml
mazinskihenry Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 48 additions & 25 deletions addons/pharma/functions/fnc_getBloodVolumeChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
private _bloodLoss = [_unit] call ACEFUNC(medical_status,getBloodLoss);
private _internalBleeding = GET_INTERNAL_BLEEDING(_unit);
private _lossVolumeChange = (-_deltaT * ((_bloodLoss + _internalBleeding * (GET_HEART_RATE(_unit) / DEFAULT_HEART_RATE)) / GET_VASOCONSTRICTION(_unit)));
private _enableFluidShift = EGVAR(vitals,enableFluidShift);
mazinskihenry marked this conversation as resolved.
Show resolved Hide resolved
private _fluidVolume = GET_BODY_FLUID(_unit);
private _SRBCChange = 0;
_fluidVolume params ["_ECP","_ECB","_SRBC","_ISP","_fullVolume"];
_fluidVolume params ["_ECB","_ECP","_SRBC","_ISP","_fullVolume"];

_ECP = _ECP + (_lossVolumeChange * LITERS_TO_ML) / 2;
_ECB = _ECB + (_lossVolumeChange * LITERS_TO_ML) / 2;

_SRBCChange = if (_SRBC > 100 && _ECB < DEFAULT_ECB) then { ((DEFAULT_ECB - _ECB) min (abs ((_lossVolumeChange * LITERS_TO_ML)) / 2 + 1)) } else { 0 };
_ECB = _ECB + _SRBCChange;

if (!isNil {_unit getVariable [QACEGVAR(medical,ivBags),[]]}) then {
private _bloodBags = _unit getVariable [QACEGVAR(medical,ivBags), []];
private _IVarray = _unit getVariable [QGVAR(IV), [0,0,0,0,0,0]];
Expand Down Expand Up @@ -68,7 +65,16 @@
// Plasma adds to ECP. Saline splits between the ECP and ISP. Blood adds to ECB
switch (true) do {
case(_type == "Plasma"): { _ECP = _ECP + _bagChange; _lossVolumeChange = _lossVolumeChange + (_bagChange / ML_TO_LITERS); };
case(_type == "Saline"): { _ECP = _ECP + _bagChange / 2; _ISP = _ISP + _bagChange / 2; _lossVolumeChange = _lossVolumeChange + (_bagChange / 2000); };
case(_type == "Saline"): {
if (_enableFluidShift) then {
_ECP = _ECP + _bagChange / 2;
_ISP = _ISP + _bagChange / 2;
_lossVolumeChange = _lossVolumeChange + (_bagChange / 2000);
} else {
_ECP = _ECP + _bagChange;
_lossVolumeChange = _lossVolumeChange + (_bagChange / ML_TO_LITERS);
};
};
case(_type == "Blood"): { _ECB = _ECB + _bagChange; _lossVolumeChange = _lossVolumeChange + (_bagChange / ML_TO_LITERS); };
};
};
Expand All @@ -88,7 +94,7 @@
_unit setVariable [QACEGVAR(medical,ivBags), _bloodBags, _syncValues];
};

// Incoming fluids impacting internal temperature
// Incoming fluids impacting internal temperature
if (_hypothermia) then {
{ _fluidHeat = _fluidHeat + _x; } forEach _incomingVolumeChange;

Expand All @@ -102,27 +108,44 @@
};
};

// Movement and recovery of interstital fluid
private _shiftValue = 0;
switch (true) do {
case (((_ECB + _ECP) > (_ISP * 0.6)) && ((_ECB + _ECP) > 4500)): {
// Negative shifts only happen above 4500ml of blood volume, to prevent issues with falling back into arrest/unconsciousness
_shiftValue = (2 min ((_ECP + _ECB) - (_ISP * 0.6)));
_ECP = _ECP - _shiftValue;
_ISP = _ISP + _shiftValue;
};
case ((_ECB + _ECP) < (_ISP * 0.6)): {
_shiftValue = (2 min ((_ISP * 0.6) - (_ECP + _ECB)));
_ECP = _ECP + _shiftValue;
_ISP = _ISP - _shiftValue;
// Movement and recovery of interstital fluid and SRBC collection
private _SRBCChange = 0;

if (_enableFluidShift) then {
private _shiftValue = 0;
private _defaultShift = false;

_SRBCChange = if ((_SRBC > 0) && (_ECB < DEFAULT_ECB)) then { 0.5 } else { 0 };

Check notice on line 118 in addons/pharma/functions/fnc_getBloodVolumeChange.sqf

View workflow job for this annotation

GitHub Actions / build

assignment to if can be replaced with select

use select
MiszczuZPolski marked this conversation as resolved.
Show resolved Hide resolved
_ECB = _ECB + (_SRBCChange * _deltaT);
_SRBC = _SRBC - (_SRBCChange * _deltaT);

switch (true) do {
case (((_ECB + _ECP) > (_ISP * 0.6)) && ((_ECB + _ECP) > 4500)): {
// Negative shifts only happen above 4500ml of blood volume, to prevent patients from falling back into arrest/unconsciousness
_shiftValue = (1 min ((_ECP + _ECB) - (_ISP * 0.6))) * _deltaT;

_ECP = _ECP - _shiftValue;
_ISP = _ISP + _shiftValue;
};
case ((_ECB + _ECP) < (_ISP * 0.6)): {
_shiftValue = (1 min ((_ISP * 0.6) - (_ECP + _ECB))) *_deltaT;

if (_shiftValue < 0.1) exitWith { _defaultShift = true; };

_ECP = _ECP + _shiftValue;
_ISP = _ISP - _shiftValue;
};
default {
_defaultShift = true;
};
};
default {
// If no shift is required, fluids begin returning to baseline in both ISP and SRBC volumes
_ISP = _ISP + ((DEFAULT_ISP - _ISP) min 2);
_SRBC = _SRBC + ((DEFAULT_SRBC - _SRBC) min 1);

if (_defaultShift) then {
_ISP = _ISP + ((((DEFAULT_ISP - _ISP) max -2) min 2) *_deltaT);
_SRBC = _SRBC + ((((DEFAULT_SRBC - _SRBC) max -1) min 1) * _deltaT);
};
};

_unit setVariable [QEGVAR(circulation,bodyFluid), [_ECP, _ECB, (_SRBC - _SRBCChange), _ISP, (_ECP + _ECB)], _syncValues];
_unit setVariable [QEGVAR(circulation,bodyFluid), [_ECB, _ECP, _SRBC, _ISP, (_ECP + _ECB)], _syncValues];
mazinskihenry marked this conversation as resolved.
Show resolved Hide resolved

((_lossVolumeChange + GET_BLOOD_VOLUME_LITERS(_unit)) max 0.01)
1 change: 1 addition & 0 deletions addons/vitals/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PREP(addMedicationAdjustment);
PREP(fullHealLocal);
PREP(handleUnitVitals);
PREP(handleSimpleVitals);
PREP(handleCardiacFunction);
Expand Down
1 change: 1 addition & 0 deletions addons/vitals/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"

[QEGVAR(misc,handleRespawn), LINKFUNC(handleRespawn)] call CBA_fnc_addEventHandler;
[QACEGVAR(medical_treatment,fullHealLocalMod), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler;
11 changes: 10 additions & 1 deletion addons/vitals/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ PREP_RECOMPILE_END;
#define CBA_SETTINGS_CAT "KAT - ADV Medical: Vitals"

[
QGVAR(simpleMedical),
QGVAR(enableSimpleMedical),
"CHECKBOX",
[LLSTRING(SIMPLEMED_ENABLE), LLSTRING(SIMPLEMED_ENABLE_DESC)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[false],
true
] call CBA_Settings_fnc_init;

[
QGVAR(enableFluidShift),
"CHECKBOX",
LLSTRING(FLUID_SHIFT),
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[true],
true
] call CBA_Settings_fnc_init;

ADDON = true;
24 changes: 24 additions & 0 deletions addons/vitals/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "..\script_component.hpp"
/*
* Author: MiszczuZPolski
* Local callback for fully healing a patient.
*
* Arguments:
* 0: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call kat_vitals_fnc_fullHealLocal
*
* Public: No
*/

params ["_patient"];

_patient setVariable [QGVAR(simpleMedical), false, true];

if (GVAR(enableSimpleMedical)) then {
_patient setVariable [QGVAR(simpleMedical), true, true];
};
4 changes: 3 additions & 1 deletion addons/vitals/functions/fnc_handleOxygenFunction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ if (EGVAR(pharma,kidneyAction)) then {

// Fractional Oxygen when breathing normal air is 0.21, 1 when breathing 100% Oxygen, and 0 when no air is being brought into the lungs
private _fio2 = switch (true) do {
case ((_unit getVariable [QEGVAR(airway,occluded), false]) || (_unit getVariable [QEGVAR(airway,obstruction), false])): { 0 };
case ((_unit getVariable [QEGVAR(airway,occluded), false]) || (_unit getVariable [QEGVAR(airway,obstruction), false])): {
[0, DEFAULT_FIO2] select ((_unit getVariable [QEGVAR(airway,recovery), false]) || (_unit getVariable [QEGVAR(airway,overstretch), false]))
};
case ((_unit getVariable [QEGVAR(chemical,airPoisoning), false]) || (_unit getVariable [QEGVAR(breathing,tensionpneumothorax), false]) || (_unit getVariable [QEGVAR(breathing,hemopneumothorax), false])): { 0 };
case (_unit getVariable [QEGVAR(breathing,oxygenTankConnected), false]): { 1 };
default { DEFAULT_FIO2 };
Expand Down
6 changes: 5 additions & 1 deletion addons/vitals/functions/fnc_handleRespawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@

params ["_patient"];

if (!(isPlayer _unit) && GVAR(simpleMedical)) then { _patient setVariable [QGVAR(simpleMedical), true, true] };
_patient setVariable [QGVAR(simpleMedical), false, true];

if (GVAR(enableSimpleMedical)) then {
_patient setVariable [QGVAR(simpleMedical), true, true];
};
2 changes: 1 addition & 1 deletion addons/vitals/functions/fnc_handleSimpleVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if !(_adjustments isEqualTo []) then {
private _heartRate = [_unit, _hrTargetAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updateHeartRate); //Rename
[_unit, _painSupressAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updatePainSuppress); //Leave alone

private _bloodPressure = [120,80];
private _bloodPressure = [80,120];
_unit setVariable [VAR_BLOOD_PRESS, _bloodPressure, _syncValues];

// Statements are ordered by most lethal first.
Expand Down
14 changes: 7 additions & 7 deletions addons/vitals/functions/fnc_handleUnitVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

params ["_unit"];

if (!(isPlayer _unit) && (_unit getVariable [QEGVAR(circulation,simpleMedical), false])) exitWith { [_unit] call FUNC(handleSimpleVitals) };
if ((!(isPlayer _unit)) && (_unit getVariable [QGVAR(simpleMedical),false])) exitWith { [_unit] call FUNC(handleSimpleVitals); };

private _lastTimeUpdated = _unit getVariable [QACEGVAR(medical_vitals,lastTimeUpdated), 0];
private _deltaT = (CBA_missionTime - _lastTimeUpdated) min 10;
Expand Down Expand Up @@ -147,29 +147,29 @@ _unit setVariable [VAR_BLOOD_PRESS, _bloodPressure, _syncValues];
_bloodPressure params ["_bloodPressureL", "_bloodPressureH"];

// Statements are ordered by most lethal first.
// Add SpO2 reactions to switch statement ---------------------------------------------------------------------
switch (true) do {
case (_spo2 < EGVAR(breathing,SpO2_dieValue) && EGVAR(breathing,SpO2_dieActive)): {
switch (true) do {
case ((_spo2 < EGVAR(breathing,SpO2_dieValue)) && EGVAR(breathing,SpO2_dieActive)): {
TRACE_3("O2 Fatal",_unit,EGVAR(breathing,SpO2_dieValue),_spo2);
[QACEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent;
[QACEGVAR(medical,Death), _unit] call CBA_fnc_localEvent; // We have to call the Death state because if FatalInjuries is disabled, the patient won't actually die and just go into arrest
MiszczuZPolski marked this conversation as resolved.
Show resolved Hide resolved
};
case (_bloodVolume < BLOOD_VOLUME_FATAL): {
TRACE_3("BloodVolume Fatal",_unit,BLOOD_VOLUME_FATAL,_bloodVolume);
[QACEGVAR(medical,Bleedout), _unit] call CBA_fnc_localEvent;
};
case (IN_CRDC_ARRST(_unit)): {}; // if in cardiac arrest just break now to avoid throwing unneeded events
case (_spo2 < EGVAR(breathing,SpO2_cardiacValue) && EGVAR(breathing,SpO2_cardiacActive)): {
case ((_spo2 < EGVAR(breathing,SpO2_cardiacValue)) && EGVAR(breathing,SpO2_cardiacActive)): {
[QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent;
};
case (_hemorrhage == 4): {
TRACE_3("Class IV Hemorrhage",_unit,_hemorrhage,_bloodVolume);
[QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent;
};
case (_heartRate < 20 || {_heartRate > 220}): {
case (_heartRate < 20 || _heartRate > 220): {
MiszczuZPolski marked this conversation as resolved.
Show resolved Hide resolved
TRACE_2("heartRate Fatal",_unit,_heartRate);
[QACEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent;
};
case (_bloodPressureL < 20 || {_bloodPressureL > 180}): {
case (_bloodPressureL < 20 || _bloodPressureL > 180): {
MiszczuZPolski marked this conversation as resolved.
Show resolved Hide resolved
TRACE_2("bloodPressure L above or below limits",_unit,_bloodPressureL);
[QACEGVAR(medical,CriticalVitals), _unit] call CBA_fnc_localEvent;
};
Expand Down
2 changes: 1 addition & 1 deletion addons/vitals/functions/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

params ["_patient"];

if (!(isPlayer _unit) && GVAR(simpleMedical)) then { _patient setVariable [QGVAR(simpleMedical), true, true] };
[_patient] call FUNC(fullHealLocal);
5 changes: 5 additions & 0 deletions addons/vitals/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
<Japanese>AI用単純化医療を有効化</Japanese>
</Key>
</Package>
<Package name="Vitals">
<Key ID="STR_KAT_Vitals_FLUID_SHIFT">
<English>Enable Patient Fluid Shift</English>
</Key>
</Package>
</Project>
Loading
Loading