From d70a900fc999741b45fc4a18f7f5c23dbade23ef Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Fri, 27 Dec 2024 11:45:39 -0800 Subject: [PATCH 1/3] Airway Start --- .../airway/ACE_Medical_Treatment_Actions.hpp | 35 ++++++++++----- addons/airway/functions/fnc_airwayStatus.sqf | 44 +++++++++++++++++++ addons/airway/functions/fnc_fullHealLocal.sqf | 22 +++++++--- .../fnc_gui_updateInjuryListGeneral.sqf | 2 +- .../fnc_gui_updateInjuryListPart.sqf | 2 +- .../airway/functions/fnc_handleAirwayHit.sqf | 33 ++++++++++++++ addons/airway/functions/fnc_handlePuking.sqf | 24 ++++++---- 7 files changed, 133 insertions(+), 29 deletions(-) create mode 100644 addons/airway/functions/fnc_airwayStatus.sqf create mode 100644 addons/airway/functions/fnc_handleAirwayHit.sqf diff --git a/addons/airway/ACE_Medical_Treatment_Actions.hpp b/addons/airway/ACE_Medical_Treatment_Actions.hpp index 521ca2d6b..c6a175fe4 100644 --- a/addons/airway/ACE_Medical_Treatment_Actions.hpp +++ b/addons/airway/ACE_Medical_Treatment_Actions.hpp @@ -66,6 +66,19 @@ class ACE_Medical_Treatment_Actions { callbackProgress = ""; sounds[] = {{QPATHTO_R(sounds\accuvac_start.wav),6,1,15}}; }; + class SurgicalAccuvac: Larynxtubus { + displayName = CSTRING(AccuvacTreatment_displayName); + treatmentTime = QGVAR(Accuvac_time); + items[] = {"kat_accuvac"}; + condition = QUOTE(!([_patient] call ACEFUNC(common,isAwake)) && (missionNamespace getVariable [ARR_2(QQGVAR(enable),true)]) && !(_patient getVariable [ARR_2(QQGVAR(recovery),false)]) && !(_patient getVariable [ARR_2(QQGVAR(airway_item),'')] == 'Larynxtubus')); + icon = QPATHTOF(ui\accuvac.paa); + consumeItem = 0; + medicRequired = QGVAR(medLvl_Accuvac); + callbackStart = QFUNC(treatmentAdvanced_AccuvacStart); + callbackSuccess = QUOTE([ARR_6(_medic,_patient,_bodyPart,'Accuvac','','kat_accuvac')] call FUNC(treatmentAdvanced_accuvac)); //Need to manuelly call fnc due to ACE not providing _itemName when consumeItem == 0 + callbackProgress = ""; + sounds[] = {{QPATHTO_R(sounds\accuvac_start.wav),6,1,15}}; + }; class Suction: Accuvac { displayName = CSTRING(SuctionTreatment_displayName); treatmentTime = QGVAR(Suction_time); @@ -76,6 +89,16 @@ class ACE_Medical_Treatment_Actions { callbackSuccess = QFUNC(treatmentAdvanced_accuvac); sounds[] = {{QPATHTO_R(sounds\manualpump_start.wav),6,1,15}}; }; + class SurgicalSuction: Accuvac { + displayName = CSTRING(SuctionTreatment_displayName); + treatmentTime = QGVAR(Suction_time); + items[] = {"kat_suction"}; + icon = QPATHTOF(ui\suction.paa); + consumeItem = 1; + medicRequired = QGVAR(medLvl_Suction); + callbackSuccess = QFUNC(treatmentAdvanced_accuvac); + sounds[] = {{QPATHTO_R(sounds\manualpump_start.wav),6,1,15}}; + }; class HyperextendHead: Larynxtubus { displayName = CSTRING(Hyperextend_displayName); displayNameProgress = CSTRING(Hyperextend_progress); @@ -88,18 +111,6 @@ class ACE_Medical_Treatment_Actions { callbackProgress = ""; callbackCondition = "useCondition"; }; - class BeginHeadTurning: Larynxtubus { - displayName = CSTRING(headTurning_begin); - displayNameProgress = ""; - treatmentTime = 0.01; - medicRequired = 0; - items[] = {}; - icon = ""; - condition = QUOTE(!([_patient] call ACEFUNC(common,isAwake)) && (missionNamespace getVariable [ARR_2(QQGVAR(enable),true)]) && !(_patient getVariable [ARR_2(QQGVAR(recovery),false)]) && !(_patient getVariable [ARR_2(QQGVAR(airway_item),'')] == 'Larynxtubus') && (!(_patient getVariable [ARR_2(QQGVAR(airway_item),'')] == 'Guedeltubus') || !(missionNamespace getVariable [ARR_2(QQGVAR(block_headTurning_ifAirwayItem),true)]))); - callbackSuccess = QFUNC(startHeadTurning); - callbackProgress = ""; - sounds[] = {}; - }; class RecoveryPosition: Larynxtubus { displayName = CSTRING(RecoveryPosition_displayName); displayNameProgress = CSTRING(RecoveryPosition_displayNameProgress); diff --git a/addons/airway/functions/fnc_airwayStatus.sqf b/addons/airway/functions/fnc_airwayStatus.sqf new file mode 100644 index 000000000..6e17f5156 --- /dev/null +++ b/addons/airway/functions/fnc_airwayStatus.sqf @@ -0,0 +1,44 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Checks or not whether the airway is clear + * + * Arguments: + * 0: Unit + * + * Return Value: + * Airway Clearance + * + * Example: + * [player] call kat_airway_fnc_airwayStatus; + * + * Public: No + */ + +params ["_patient"]; + +private _occulsion = _patient getVariable [QGVAR(occlusion), 0, true]; +private _surgical = _patient getVariable [QGVAR(airwaySurgical), false, true]; +private _obstruction = _patient getVariable [QGVAR(obstruction), [false, false, false], true]; + +_return = false; + +private _obstructonCount = count[_obstruction select { _x isEqualTo false }]; + +// If a surgical airway is present, then the oral and upper airway obstructions are disregarded +if (_surgical = false) then { + + // The worse the occlusion is, the fewer parts of the airway need to be obstructed for an airway blockage to occur + switch (_occulsion) do { + case 4: { _return = false; }; // Full occlusion, surgical + case 3: { _return = false; }; // Full occlusion + case 2: { _return = (_obstructionCount < 1); }; // Moderate occlusion + case 1: { _return = (_obstructionCount < 2); }; // Mild occlusion + default: { _return = (_obstructionCount < 3); }; // No occlusion, obstruction needs 3 parts + }; +} else { + // Only check lower airway obstruction when a surgical airway is present + _return = !(_obstruction select 2); +}; + +_patient setVariable [QGVAR(airwayClear), _return, true]; \ No newline at end of file diff --git a/addons/airway/functions/fnc_fullHealLocal.sqf b/addons/airway/functions/fnc_fullHealLocal.sqf index b78449275..ae9327cf2 100644 --- a/addons/airway/functions/fnc_fullHealLocal.sqf +++ b/addons/airway/functions/fnc_fullHealLocal.sqf @@ -18,11 +18,21 @@ params ["_patient"]; TRACE_1("fullHealLocal",_patient); +/* +0 = No Stenosis (Grade 1) +1 = Light Stenosis (Grade 2) +2 = Heavy Stenosis (Grade 3) +3 = Full Stenosis/Removable (Grade 4) +4 = Full Stenosis/Not Removable (Surgical Grade 4) +*/ +_patient setVariable [QGVAR(occlusion), 0, true]; +_patient setVariable [QGVAR(airwaySurgical), false, true]; + +// Oral Obstruction, Upper Obstruction, Lower Obstruction +_patient setVariable [QGVAR(obstruction), [false, false, false], true]; +_patient setVariable [QGVAR(airwayClear), true, true]; + _patient setVariable [QGVAR(airway_item), "", true]; -_patient setVariable [QGVAR(airway), false, true]; -_patient setVariable [QGVAR(clearedTime), 0, true]; -_patient setVariable [QGVAR(obstruction), false, true]; -_patient setVariable [QGVAR(occluded), false, true]; -_patient setVariable [QGVAR(overstretch), false, true]; + +_patient setVariable [QGVAR(headTilt), false, true]; _patient setVariable [QGVAR(recovery), false, true]; -_patient setVariable [QGVAR(wasOccluded), false]; diff --git a/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf b/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf index ea56a0e93..8f748601b 100644 --- a/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf +++ b/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf @@ -21,5 +21,5 @@ params ["_ctrl", "_target", "_selectionN", "_entries"]; if (_target getVariable [QGVAR(recovery), false]) then { - _entries pushBack [LLSTRING(RecoveryPosition), [0.1, 1, 1, 1]]; + _entries pushback [LLSTRING(RecoveryPosition), [0.1, 1, 1, 1]]; }; diff --git a/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf b/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf index 92b2ed4f9..e2e8b7881 100644 --- a/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf +++ b/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf @@ -28,6 +28,6 @@ if (_target getVariable [QGVAR(airway), false] && _selectionN isEqualTo 0) then private _a = _target getVariable [QGVAR(airway_item), ""]; if !(_a isEqualTo "") then { private _text = format [LSTRING(%1_Display), _a]; - _entries pushBack [localize _text, [0.1, 1, 1, 1]]; + _entries pushback [localize _text, [0.1, 1, 1, 1]]; }; }; diff --git a/addons/airway/functions/fnc_handleAirwayHit.sqf b/addons/airway/functions/fnc_handleAirwayHit.sqf new file mode 100644 index 000000000..c77d5a5f2 --- /dev/null +++ b/addons/airway/functions/fnc_handleAirwayHit.sqf @@ -0,0 +1,33 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Called when a unit is damaged. + * + * Arguments: + * 0: Unit That Was Hit + * 1: Damage done to each body part + * 0: Damage + * 1: Bodypart + * 2: Shooter + * 3: Ammo classname or damage type + * + * Return Value: + * None + * + * Example: + * [cursorTarget, [1, "Body"], objNull, "BulletBase"] call kat_airway_fnc_handleAirwayHit; + * + * Public: No + */ + +params ["_unit", "_allDamages", "", "_ammo"]; +_allDamages select 0 params ["_damage", "_bodyPart"]; + +if (!(GVAR(enable)) || !(_bodyPart isEqualTo "Head") || !(_ammo isKindOF "BulletBase")) exitWith {}; + +if (floor (random 100) < GVAR(airwayDamageChance)) then { + private _occlusion = _unit getVariable (QGVAR(occlusion), 0); + _occlusion = ((_occlusion + 1) min 4); + + _unit setVariable (QGVAR(occlusion), _occlusion, true); +}; diff --git a/addons/airway/functions/fnc_handlePuking.sqf b/addons/airway/functions/fnc_handlePuking.sqf index 4ee49ae4e..f3103a651 100644 --- a/addons/airway/functions/fnc_handlePuking.sqf +++ b/addons/airway/functions/fnc_handlePuking.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: Katalam, edited by MiszczuZPolski - * Called when a unit enters the unconscious state. Will add a FrameHandler for puking while unconscious. + * Called when a unit enters the unconscious state. Will add a FrameHandler for aspirating while unconscious. * * Arguments: * 0: Unit @@ -18,7 +18,7 @@ params ["_unit"]; //Other mods can utilise KAT_Occlusion_Exclusion variable to prevent occlusions from happening -if ((_unit getVariable ["kat_pukeActive_PFH", false]) || !(GVAR(enable)) || (_unit getVariable ["KAT_Occlusion_Exclusion", false])) exitWith {}; +if ((_unit getVariable ["kat_pukeActive_PFH", false]) || !(GVAR(enable)) || (_unit getVariable ["KAT_Obstruction_Exclusion", false])) exitWith {}; _unit setVariable ["kat_pukeActive_PFH", true]; [{ @@ -27,20 +27,26 @@ _unit setVariable ["kat_pukeActive_PFH", true]; private _isUnconscious = _unit getVariable ["ACE_isUnconscious", false]; private _recovery = _unit getVariable [QGVAR(recovery), false]; + private _obstruction = _unit getVariable [QGVAR(obstruction), [false, false, false]]; + _obstruction params ["_oral", "_upper", "_lower"]; - if ((!(alive _unit)) || !_isUnconscious || (_unit getVariable [QGVAR(airway_item), ""] isEqualTo "Larynxtubus") || _recovery) exitWith { + if ((!(alive _unit)) || !_isUnconscious) exitWith { [_idPFH] call CBA_fnc_removePerFrameHandler; _unit setVariable ["kat_pukeActive_PFH", nil]; }; - if (GVAR(occlusion_cooldownPeriod) > 0 && {(_unit getVariable [QGVAR(clearedTime), 0] > 0) && ((_unit getVariable [QGVAR(clearedTime), 0]) + GVAR(occlusion_cooldownPeriod)) > CBA_missionTime}) exitWith {}; + if (GVAR(obstruction_cooldownPeriod) > 0 && {(_unit getVariable [QGVAR(clearedTime), 0] > 0) && ((_unit getVariable [QGVAR(clearedTime), 0]) + GVAR(obstruction_cooldownPeriod)) > CBA_missionTime}) exitWith {}; + + if (random(100) <= GVAR(probability_obstructed)) then { + if !(_upper) then { + _upper = true; - if (random(100) <= GVAR(probability_occluded)) then { - if !(_unit getVariable [QGVAR(occluded), false]) then { - _unit setVariable [QGVAR(occluded), true, true]; if (GVAR(checkbox_puking_sound)) then { - playSound3D [selectRandom [QPATHTOF_SOUND(sounds\puking1.wav),QPATHTOF_SOUND(sounds\puking2.wav),QPATHTOF_SOUND(sounds\puking3.wav)], _unit, false, getPosASL _unit, 8, 1, 15]; + playsound3D [selectRandom [QPATHTOF_SOUND(sounds\puking1.wav),QPATHTOF_SOUND(sounds\puking2.wav),QPATHTOF_SOUND(sounds\puking3.wav)], _unit, false, getPosASL _unit, 8, 1, 15]; }; + } else { + _upper = false; + _lower = true; }; }; -}, GVAR(occlusion_repeatTimer), [_unit]] call CBA_fnc_addPerFrameHandler; +}, GVAR(obstruction_repeatTimer), [_unit]] call CBA_fnc_addPerFrameHandler; From ed28a21cf6be843ec415602f284e4c7d7156102c Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Mon, 13 Jan 2025 17:21:22 -0800 Subject: [PATCH 2/3] Syntax --- addons/airway/functions/fnc_airwayStatus.sqf | 2 +- addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf | 2 +- addons/airway/functions/fnc_gui_updateInjuryListPart.sqf | 4 ++-- addons/airway/functions/fnc_handleAirwayHit.sqf | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/airway/functions/fnc_airwayStatus.sqf b/addons/airway/functions/fnc_airwayStatus.sqf index 6e17f5156..7184d1d41 100644 --- a/addons/airway/functions/fnc_airwayStatus.sqf +++ b/addons/airway/functions/fnc_airwayStatus.sqf @@ -26,7 +26,7 @@ _return = false; private _obstructonCount = count[_obstruction select { _x isEqualTo false }]; // If a surgical airway is present, then the oral and upper airway obstructions are disregarded -if (_surgical = false) then { +if !(_surgical) then { // The worse the occlusion is, the fewer parts of the airway need to be obstructed for an airway blockage to occur switch (_occulsion) do { diff --git a/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf b/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf index 8f748601b..ea56a0e93 100644 --- a/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf +++ b/addons/airway/functions/fnc_gui_updateInjuryListGeneral.sqf @@ -21,5 +21,5 @@ params ["_ctrl", "_target", "_selectionN", "_entries"]; if (_target getVariable [QGVAR(recovery), false]) then { - _entries pushback [LLSTRING(RecoveryPosition), [0.1, 1, 1, 1]]; + _entries pushBack [LLSTRING(RecoveryPosition), [0.1, 1, 1, 1]]; }; diff --git a/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf b/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf index e2e8b7881..e88947569 100644 --- a/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf +++ b/addons/airway/functions/fnc_gui_updateInjuryListPart.sqf @@ -20,7 +20,7 @@ params ["_ctrl", "_target", "_selectionN", "_entries"]; -if (_target getVariable [QGVAR(overstretch), false] && _selectionN isEqualTo 0) then { +if (_target getVariable [QGVAR(headTilt), false] && _selectionN isEqualTo 0) then { _entries pushBack [LLSTRING(Hyperextended), [0.1, 1, 1, 1]]; }; @@ -28,6 +28,6 @@ if (_target getVariable [QGVAR(airway), false] && _selectionN isEqualTo 0) then private _a = _target getVariable [QGVAR(airway_item), ""]; if !(_a isEqualTo "") then { private _text = format [LSTRING(%1_Display), _a]; - _entries pushback [localize _text, [0.1, 1, 1, 1]]; + _entries pushBack [localize _text, [0.1, 1, 1, 1]]; }; }; diff --git a/addons/airway/functions/fnc_handleAirwayHit.sqf b/addons/airway/functions/fnc_handleAirwayHit.sqf index c77d5a5f2..c0255f47d 100644 --- a/addons/airway/functions/fnc_handleAirwayHit.sqf +++ b/addons/airway/functions/fnc_handleAirwayHit.sqf @@ -26,8 +26,8 @@ _allDamages select 0 params ["_damage", "_bodyPart"]; if (!(GVAR(enable)) || !(_bodyPart isEqualTo "Head") || !(_ammo isKindOF "BulletBase")) exitWith {}; if (floor (random 100) < GVAR(airwayDamageChance)) then { - private _occlusion = _unit getVariable (QGVAR(occlusion), 0); + private _occlusion = _unit getVariable [QGVAR(occlusion), 0]; _occlusion = ((_occlusion + 1) min 4); - _unit setVariable (QGVAR(occlusion), _occlusion, true); + _unit setVariable [QGVAR(occlusion), _occlusion, true]; }; From 9799fe8df105ad2eddb37fd5ba06ef96b2882799 Mon Sep 17 00:00:00 2001 From: mazinskihenry <33608576+mazinskihenry@users.noreply.github.com> Date: Mon, 13 Jan 2025 17:24:43 -0800 Subject: [PATCH 3/3] Update fnc_airwayStatus.sqf --- addons/airway/functions/fnc_airwayStatus.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/airway/functions/fnc_airwayStatus.sqf b/addons/airway/functions/fnc_airwayStatus.sqf index 7184d1d41..383ca0cc9 100644 --- a/addons/airway/functions/fnc_airwayStatus.sqf +++ b/addons/airway/functions/fnc_airwayStatus.sqf @@ -34,7 +34,7 @@ if !(_surgical) then { case 3: { _return = false; }; // Full occlusion case 2: { _return = (_obstructionCount < 1); }; // Moderate occlusion case 1: { _return = (_obstructionCount < 2); }; // Mild occlusion - default: { _return = (_obstructionCount < 3); }; // No occlusion, obstruction needs 3 parts + default { _return = (_obstructionCount < 3); }; // No occlusion, obstruction needs 3 parts }; } else { // Only check lower airway obstruction when a surgical airway is present