Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f8f6931
Initial commit
apo-tle Apr 20, 2024
835605f
Initial commit 2
apo-tle Apr 20, 2024
54b680c
Add ICP tracker
apo-tle Apr 20, 2024
2ad9eea
Change ICP monitorig (redundant, will be removed)
apo-tle May 24, 2024
e566ac0
Initial commit
apo-tle Jun 16, 2024
d344eaa
Add variables
apo-tle Jun 17, 2024
c1ebbf3
Add PFH for brain activity
apo-tle Jun 17, 2024
33b0873
Add more variables
apo-tle Jun 17, 2024
297e52e
Add autoregulation, cerebral blood flow tracker
apo-tle Jun 17, 2024
4eee060
Increase tick speed for autoregulation
apo-tle Jun 17, 2024
cf88d95
Merge branch 'brain_injuries' of https://github.com/apo-tle/KAM into …
apo-tle Jun 17, 2024
43c507c
Add brain oxygen saturation simulation
apo-tle Jun 18, 2024
d7f3025
Add tissue necrosis
apo-tle Jun 18, 2024
833357d
Add CMR tracker
apo-tle Jun 18, 2024
c312d19
Add concussion chances
apo-tle Jun 18, 2024
1e3c0de
Set up concussion PFHs
apo-tle Jun 19, 2024
84ce976
Add concussions that increase ICP
apo-tle Jun 19, 2024
1d4702c
Prevent ICP from exceeding a maximum value depending on concussion se…
apo-tle Jun 19, 2024
fb84d1d
Add ICP decreasing when not swelling
apo-tle Jun 19, 2024
064f33e
Fix CMR tracker
apo-tle Jun 19, 2024
9e1fc3f
Raised ICP causes emesis
apo-tle Jun 19, 2024
d2a9e0e
Add bradycardia side effect from high ICP
apo-tle Jun 19, 2024
8a0e989
Add LOC for low CMR
apo-tle Jun 19, 2024
bb70efe
Migrate handlerespawn functionality to correct addon
apo-tle Jun 19, 2024
7634e9a
Update misc handleRespawn
apo-tle Jun 19, 2024
cc78886
Migrate init file to fullHealLocal
apo-tle Jun 19, 2024
e2609b8
Adjust concussion syntax
apo-tle Aug 12, 2024
7171a76
Merge branch 'KAT-Advanced-Medical:dev-Tomcat' into brain_injuries
apo-tle Aug 12, 2024
1015a40
Initial overwrite of ace_medical_statemachine
apo-tle Aug 14, 2024
9c579eb
Merge branch 'brain_injuries' of https://github.com/apo-tle/KAM into …
apo-tle Aug 14, 2024
e3b5a58
Add seizures to statemachine
apo-tle Aug 14, 2024
3cc2a94
Overwrite localityChangeEH
apo-tle Aug 14, 2024
6dbd8e4
Add logic for entering seizure state
apo-tle Aug 14, 2024
d2a4b37
Add setSeizureState
apo-tle Aug 14, 2024
76b0c6d
Change syntax
apo-tle Oct 8, 2024
89942f6
Merge to 3.0
apo-tle Oct 13, 2024
9f018b2
Merge branch 'dev-Tomcat' into brain_injuries
apo-tle Oct 13, 2024
5c29aac
Remove ICP floors for saline bags
apo-tle Oct 13, 2024
c477676
Add ICP loss multiplier during saline transfusion
apo-tle Oct 13, 2024
871028e
Reduce reversible damage while not swelling
apo-tle Oct 14, 2024
183cad2
Add low cmr effect (non functional)
apo-tle Oct 14, 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
2 changes: 1 addition & 1 deletion addons/airway/functions/fnc_handlePuking.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _unit setVariable ["kat_pukeActive_PFH", true];

if (GVAR(occlusion_cooldownPeriod) > 0 && {(_unit getVariable [QGVAR(clearedTime), 0] > 0) && ((_unit getVariable [QGVAR(clearedTime), 0]) + GVAR(occlusion_cooldownPeriod)) > CBA_missionTime}) exitWith {};

if (random(100) <= GVAR(probability_occluded)) then {
if ((random(100) <= GVAR(probability_occluded)) || (_unit getVariable [QEGVAR(brain,ICP),15] > 25)) then {
if !(_unit getVariable [QGVAR(occluded), false]) then {
_unit setVariable [QGVAR(occluded), true, true];
if (GVAR(checkbox_puking_sound)) then {
Expand Down
1 change: 1 addition & 0 deletions addons/brain/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x\kat\addons\brain
20 changes: 20 additions & 0 deletions addons/brain/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
disableModuload = "true";
};
};

class Extended_Init_EventHandlers {
class CAManBase {
class ADDON {
init = QUOTE([ARR_2((_this select 0),false)] call FUNC(init));
};
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
6 changes: 6 additions & 0 deletions addons/brain/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREP(concussion);
PREP(fullHealLocal);
PREP(handleAutoregulation);
PREP(handleBrainActivity);
PREP(handleRespawn);
PREP(init);
8 changes: 8 additions & 0 deletions addons/brain/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "script_component.hpp"

[QGVAR(handleAutoregulation), LINKFUNC(handleAutoregulation)] call CBA_fnc_addEventHandler;
[QGVAR(handleBrainActivity), LINKFUNC(handleBrainActivity)] call CBA_fnc_addEventHandler;
[QACEGVAR(medical,woundReceived),LINKFUNC(concussion)] call CBA_fnc_addEventHandler;

[QEGVAR(misc,handleRespawn), LINKFUNC(handleRespawn)] call CBA_fnc_addEventHandler;
[QACEGVAR(medical_treatment,fullHealLocalMod), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler;
161 changes: 161 additions & 0 deletions addons/brain/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#define CBA_SETTINGS_CAT "KAT - ADV Medical: Brain Injuries"

//Enable traumatic brain injuries
[
QGVAR(enable),
"CHECKBOX",
LLSTRING(SETTING_enable),
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[true],
true
] call CBA_Settings_fnc_init;

//Amount to reduce ICP by when brain is not actively swelling
[
QGVAR(ICPreduction),
"SLIDER",
[LLSTRING(SETTING_ICPreduction)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[0, 2, 0.3, 1],
true
] call CBA_Settings_fnc_init;

//Multiplier for ICP reduction if saline is being transfused
[
QGVAR(ICPreductionMult),
"SLIDER",
[LLSTRING(SETTING_ICPreductionMult)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[1, 3, 1.3, 1],
true
] call CBA_Settings_fnc_init;

// Minimum CMR to sustain consciousness. Not achieving will prevent awakening
[
QGVAR(stableCMR),
"SLIDER",
[LLSTRING(SETTING_stableCMR)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[0, 100, 80, 1],
true
] call CBA_Settings_fnc_init;

// Minimum CMR required for unit to pass out randomly
[
QGVAR(CMRunconsciousThreshold),
"SLIDER",
[LLSTRING(SETTING_CMRunconsciousThreshold)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[0, 100, 85, 1],
true
] call CBA_Settings_fnc_init;

//Chance for a unit to pass out randomly from low CMR
[
QGVAR(CMRunconsciousChance),
"SLIDER",
[LLSTRING(SETTING_concussionChance)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[0, 100, 20, 1],
true
] call CBA_Settings_fnc_init;

// Minimum ICP required for bradycardia to occur as a result
[
QGVAR(ICPbradycardiaThreshold),
"SLIDER",
[LLSTRING(SETTING_ICPbradycardiaThreshold)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[20, 70, 50, 1],
true
] call CBA_Settings_fnc_init;

//Chance of bradycardia occuring
[
QGVAR(ICPbradycardiaChance),
"SLIDER",
[LLSTRING(SETTING_ICPbradycardiaChance)],
[CBA_SETTINGS_CAT, ELSTRING(GUI,SubCategory_Basic)],
[0, 100, 15, 1],
true
] call CBA_Settings_fnc_init;

//Chance of a concussion occuring
[
QGVAR(concussionChance),
"SLIDER",
[LLSTRING(SETTING_concussionChance)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Concussions)],
[0, 100, 5, 1],
true
] call CBA_Settings_fnc_init;

// Minimum impact damage required to cause healable tissue damage upon receiving a concussion
[
QGVAR(tissueImpactDamage),
"SLIDER",
[LLSTRING(SETTING_tissueImpactDamage)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Concussions)],
[0, 2, 0.3, 1],
true
] call CBA_Settings_fnc_init;

// Minimum impact damage required to cause instant tissue necrosis upon receiving a concussion
[
QGVAR(necrosisImpactDamage),
"SLIDER",
[LLSTRING(SETTING_necrosisImpactDamage)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_Concussions)],
[0, 2, 0.8, 1],
true
] call CBA_Settings_fnc_init;

//How much reversible damage will decrease by every tick
[
QGVAR(reversibleDamageLoss),
"SLIDER",
[LLSTRING(SETTING_reversibleDamageLoss)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_BrainDeath)],
[0, 2, 0.4, 1],
true
] call CBA_Settings_fnc_init;

// Number of ticks required until tissue necrosis begins to occur, ticks occuring every 15 seconds
[
QGVAR(necrosisTicks),
"SLIDER",
[LLSTRING(SETTING_necrosisTicks)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_BrainDeath)],
[1, 60, 10, 0],
true
] call CBA_Settings_fnc_init;

// rO2 value required before necrosis occurs
[
QGVAR(necrosisThreshold),
"SLIDER",
[LLSTRING(SETTING_necrosisThreshold)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_BrainDeath)],
[1, 80, 60, 0],
true
] call CBA_Settings_fnc_init;

//How much necrosis increases each tick
[
QGVAR(necrosisIncrease),
"SLIDER",
[LLSTRING(SETTING_necrosisIncrease)],
[CBA_SETTINGS_CAT, LSTRING(SubCategory_BrainDeath)],
[0, 10, 1.6, 1],
true
] call CBA_Settings_fnc_init;

ADDON = true;
36 changes: 36 additions & 0 deletions addons/brain/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
requiredVersion = REQUIRED_VERSION;
units[] = {};
weapons[] = {};
magazines[] = { };
requiredAddons[] = {
"ace_medical",
"ace_medical_ai",
"ace_medical_blood",
"ace_medical_damage",
"ace_medical_engine",
"ace_medical_feedback",
"ace_medical_gui",
"ace_medical_statemachine",
"ace_medical_status",
"ace_medical_treatment",
"ace_medical_vitals",
"ace_dogtags",
"kat_main",
"kat_airway",
"kat_circulation",
"cba_settings"
};
author = "apo_tle";
authors[] = {"apo_tle"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
//#include "CfgWeapons.hpp"
93 changes: 93 additions & 0 deletions addons/brain/functions/fnc_concussion.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include "..\script_component.hpp"
/*
* Author: apo_tle
* Called when a unit is hit. Handles receiving TBIs and setting up dedicated PFHs to increase ICP.
*
* 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, "Head"], objNull, "BulletBase"] call kat_brain_fnc_concussion
*
* Public: No
*/

params ["_unit", "_allDamages", "", "_ammo"];
_allDamages select 0 params ["_damage", "_bodyPart"];

if (!(GVAR(enable)) || !(_bodyPart isEqualTo "Head")) exitWith {};

// Increase the chance based on how much damage was received
private _chanceIncrease = linearConversion [0,1,_damage,5,30,true];
// Increase the chance of concussions depending on the damage type
private _chanceMultiplier = 1;
if (_ammo in ["vehiclehit","explosive","shell","vehiclecrash"]) then {
_chanceMultiplier = linearConversion [0,3,(["vehiclehit","explosive","shell","vehiclecrash"] find _ammo),1.2,2,true];
};

private _concussionChance = (GVAR(concussionChance) + _chanceIncrease) * _chanceMultiplier;
if (floor (random 100) <= _concussionChance) then {
private _currentSeverity = _unit getVariable [QGVAR(concussionSeverity),0];
if (_damage > _currentSeverity) then { //Replace the current concussion with the more severe one
// Add instantaneous effects from concussions
if (_damage > GVAR(necrosisImpactDamage)) then { // Cause instant necrosis if threshold is surpassed
private _necrosis = _unit getVariable [QGVAR(necrosis),0];
private _newNecrosis = linearConversion [0, 1,_damage,0,7,true]; //Increase tissue necrosis by 7% max on impact
if (_newNecrosis > _necrosis) then { // Prevent reverting existing necrosis levels
_unit setVariable [QGVAR(necrosis),_newNecrosis,true];
};
};
if (_damage > GVAR(tissueImpactDamage)) then { // Cause reversible tissue damage if threshold is surpassed
private _reversibleDamage = _unit getVariable [QGVAR(reversibleDamage),0];
_reversibleDamage = _reversibleDamage + (linearConversion [0,1,_damage,0,25,true]); //Increase reversible damage by max 25% on impact
_unit setVariable [QGVAR(reversibleDamage),_reversibleDamage,true];
};

// Increase ICP to a base level depending on damage taken
private _ICP = _unit getVariable [QGVAR(ICP),10];
private _ICPincrease = linearConversion [0, 1,_damage,1,3,true];
_unit setVariable [QGVAR(ICP),_ICP+_damage,true];

// Set up PFH
if !(_currentSeverity isEqualTo 0) then { //Delete the existing concussion PFH if it exists
private _existingPFH = _unit getVariable [QGVAR(concussionPFH),0];
[_existingPFH] call CBA_fnc_removePerFrameHandler;
};

private _maxICPIncrease = linearConversion [0,1,_damage,0,40];
private _newPFH = [{
params ["_args", "_idPFH"];
_args params ["_unit","_severity","_maxICPIncrease"];
if !(alive _unit) exitWith {
_unit setVariable [QGVAR(concussionPFH),0,true];
_unit setVariable [QGVAR(concussionSeverity),0,true];
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

private _ICP = _unit getVariable [QGVAR(ICP),10];

//Kill the concussion once ICP reaches the limit for the concussion's severity
if (_ICP >= (20+_maxICPIncrease)) exitWith {
_unit setVariable [QGVAR(concussionPFH),0,true];
_unit setVariable [QGVAR(concussionSeverity),0,true];
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

private _ICPincrease = linearConversion [0,1,_severity,0,2,true];
_unit setVariable [QGVAR(ICP),_ICP+_ICPincrease,true]; //Increase ICP by concussion severity

}, 10, [_unit,_damage,_maxICPIncrease]] call CBA_fnc_addPerFrameHandler;

_unit setVariable [QGVAR(concussionPFH),_newPFH,true];
_unit setVariable [QGVAR(concussionSeverity),_damage,true];
}

};
33 changes: 33 additions & 0 deletions addons/brain/functions/fnc_findSaline.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "..\script_component.hpp"
/*
* Author: apo_tle, from _pharma_fnc_salineCheck
* Check for any active saline IV
*
* Arguments:
* 0: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_patient] call kat_pharma_fnc_findSaline;
*
* Public: No
*/

params ["_patient"];

private _fluidCheck = _patient getVariable [QACEGVAR(medical,ivBags), []];
private _check = false;

{
_x params ["_bagVolumeRemaining", "_type"];

if (_type isEqualTo "Saline" && _bagVolumeRemaining >= 30) exitWith {
_check = true;
};
} forEach _fluidCheck;

if (_check) exitWith {true};

false
Loading