Skip to content

Commit

Permalink
Rework Version V1
Browse files Browse the repository at this point in the history
Version that is somewhat not realistic but tries to enhance the current experience into a more realistic way.
  • Loading branch information
MissHeda committed Feb 26, 2024
1 parent 314465d commit afb94cf
Show file tree
Hide file tree
Showing 16 changed files with 1,335 additions and 201 deletions.
16 changes: 8 additions & 8 deletions addons/circulation/Blood_Medical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@ class BloodIV;
class BloodIV_O: BloodIV {
displayName = CSTRING(Action_BloodIV_O);
items[] = {"kat_bloodIV_O"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_O_N: BloodIV {
displayName = CSTRING(Action_BloodIV_O_N);
items[] = {"kat_bloodIV_O_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_A: BloodIV {
displayName = CSTRING(Action_BloodIV_A);
items[] = {"kat_bloodIV_A"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_A_N: BloodIV {
displayName = CSTRING(Action_BloodIV_A_N);
items[] = {"kat_bloodIV_A_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_B: BloodIV {
displayName = CSTRING(Action_BloodIV_B);
items[] = {"kat_bloodIV_B"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_B_N: BloodIV {
displayName = CSTRING(Action_BloodIV_B_N);
items[] = {"kat_bloodIV_B_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_AB: BloodIV {
displayName = CSTRING(Action_BloodIV_AB);
items[] = {"kat_bloodIV_AB"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_AB_N: BloodIV {
displayName = CSTRING(Action_BloodIV_AB_N);
items[] = {"kat_bloodIV_AB_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 12] call kat_pharma_fnc_fluid;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; [_patient, 800, 16] call kat_pharma_fnc_fluid;";
};
class BloodIV_500;
class BloodIV_O_500: BloodIV_500 {
Expand Down
2 changes: 1 addition & 1 deletion addons/misc/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ _unit setVariable [QEGVAR(pharma,pH), 1500, true];
_unit setVariable [QEGVAR(pharma,kidneyFail), false, true];
_unit setVariable [QEGVAR(pharma,kidneyArrest), false, true];
_unit setVariable [QEGVAR(pharma,kidneyPressure), false, true];
_unit setVariable [QEGVAR(pharma,coagulationFactor), 10, true];
_unit setVariable [QEGVAR(pharma,coagulationFactor), missionNamespace getVariable [QEGVAR(pharma,coagulation_factor_count), 15], true];

//KAT Surgery

Expand Down
215 changes: 191 additions & 24 deletions addons/misc/functions/fnc_handleRespawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ _unit setVariable [QEGVAR(pharma,pH), 1500, true];
_unit setVariable [QEGVAR(pharma,kidneyFail), false, true];
_unit setVariable [QEGVAR(pharma,kidneyArrest), false, true];
_unit setVariable [QEGVAR(pharma,kidneyPressure), false, true];
_unit setVariable [QEGVAR(pharma,coagulationFactor), missionNamespace getVariable [QEGVAR(pharma,coagulation_factor_count), 15], true];

//KAT Surgery

Expand Down Expand Up @@ -208,51 +209,217 @@ if (EGVAR(pharma,kidneyAction)) then {
}, 20, [_unit]] call CBA_fnc_addPerFrameHandler;
};

// Coagulation PFH

if (EGVAR(pharma,coagulation)) then {

private _fnc_clotWound = {
params ["_unit", "_bodyPart", "_wounds", "_countTXA", "_countEACA"];

{
_x params ["_woundClassID", "_amountOf", "_bleeding", "_damage"];

private _category = _woundClassID % 10;
private _suffix = ["Minor", "Medium", "Large"] select _category;
private _selectionName = localize format [LSTRING(%1), _bodyPart];
private _logString = LSTRING(coagulation_Bandaged);
private _woundClotTime = 0;
private _bandageToUse = "";
private _coagulation_time_minor = missionNamespace getVariable [QEGVAR(pharma,coagulation_time_minor), 15];
private _coagulation_time_medium = missionNamespace getVariable [QEGVAR(pharma,coagulation_time_medium), 30];
private _coagulation_time_large = missionNamespace getVariable [QEGVAR(pharma,coagulation_time_large), 45];
private _factorCoutToRemove = 1

switch (_suffix) do {
case "Minor": {
_woundClotTime = round ((random (_coagulation_time_minor / 2)) + _coagulation_time_minor / 2);
_bandageToUse = "BloodClotMinor";
_factorCoutToRemove = 1;

if !(missionNamespace getVariable [QEGVAR(pharma,coagulation_allow_MinorWounds), true]) then { continue; };
};
case "Medium": {
_woundClotTime = round ((random (_coagulation_time_medium / 2)) + _coagulation_time_medium / 2);
_bandageToUse = "BloodClotMedium";
_factorCoutToRemove = 1.5;

if !(missionNamespace getVariable [QEGVAR(pharma,coagulation_allow_MediumWounds), true]) then { continue; };
};
default {
_woundClotTime = round ((random (_coagulation_time_large / 2)) + _coagulation_time_large / 2);
_bandageToUse = "BloodClotLarge";
_factorCoutToRemove = 2;

if !(missionNamespace getVariable [QEGVAR(pharma,coagulation_allow_LargeWounds), true]) then { continue; };
};
};

if (_amountOf * _bleeding > 0) exitWith {

if (_countTXA > 0 || _countEACA > 0) then {
_logString = LSTRING(coagulation_Bandaged_TXA);

if (_countEACA > 0 && _countTXA > 0) exitWith { // If TXA & EACA are in system at same time use EACA bandage
_woundClotTime = round (_woundClotTime / 3 * 2);
_bandageToUse = _bandageToUse + "EACA";
};

_bandageToUse = _bandageToUse + "TXA";
};

[{
params["_unit", "_bodyPart", "_selectionName", "_bandageToUse", "_logString", "_factorCoutToRemove"];

private _coagulationFactor = _unit getVariable [QEGVAR(pharma,coagulationFactor), 15];
private _openWounds = GET_OPEN_WOUNDS(_unit);
private _openWoundsOnPart = _openWounds getOrDefault [_bodyPart, []];
private _woundIndex = _openWoundsOnPart findIf {(_x select 1) > 0 && (_x select 2) > 0};

if (_coagulationFactor <= 0) exitWith {};
if (_woundIndex == -1) exitWith {};
if ([_unit, _bodyPart] call ACEFUNC(medical_treatment,hasTourniquetAppliedTo) && missionNamespace getVariable [QEGVAR(pharma,coagulation_tourniqueBlock), true]) exitWith {};

_unit setVariable [QEGVAR(pharma,coagulationFactor), (_coagulationFactor - _factorCoutToRemove), true];
[QACEGVAR(medical_treatment,bandageLocal), [_unit, _bodyPart, _bandageToUse], _unit] call CBA_fnc_targetEvent;
[_unit, "activity", _logString, [(toLower _selectionName)]] call ACEFUNC(medical_treatment,addToLog);
},
[_unit, _bodyPart, _selectionName, _bandageToUse, _logString, _factorCoutToRemove], _woundClotTime] call CBA_fnc_waitAndExecute;
};
} forEach _wounds;
};

[{
params ["_args", "_idPFH"];
_args params ["_unit"];
_args params ["_unit", "_fnc_clotWound"];

private _alive = alive _unit;

if !(_alive) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

if (!(EGVAR(pharma,coagulation_allowOnAI)) && ACE_Player != _unit) exitWith { // Check allowOnAI setting to save performance
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

private _openWounds = _unit getVariable [VAR_OPEN_WOUNDS, []];
private _pulse = _unit getVariable [VAR_HEART_RATE, 80];
private _coagulationFactor = _unit getVariable [QEGVAR(pharma,coagulationFactor), 10];
private _coagulationFactor = _unit getVariable [QEGVAR(pharma,coagulationFactor), 15];
private _countTXA = [_unit, "TXA"] call ACEFUNC(medical_status,getMedicationCount);
private _countEACA = [_unit, "EACA"] call ACEFUNC(medical_status,getMedicationCount);
private _hasWoundToBandageArray = [];

if (_openWounds isEqualTo []) exitWith {}; // Exit when hashmap not initialized (Will not work when hashmap is set, cause ace only changes value of "woundCount" to 0)
if (_coagulationFactor <= 0) exitWith {}; // Exit when no coagFactors left
if (_unit getVariable [QACEGVAR(medical,bloodVolume), 6.0] < EGVAR(pharma,coagulation_requireBV)) exitWith {}; // Blood volume check
if ((_pulse < 20) && EGVAR(pharma,coagulation_requireHR)) exitWith {}; // Has pulse & require setting

private _shuffledKeys = keys _openWounds call BIS_fnc_arrayShuffle; // Shuffel Keys to switch bodypart after each bandage for on_all_Bodyparts setting

{
if ([_unit, _x] call ACEFUNC(medical_treatment,hasTourniquetAppliedTo) && missionNamespace getVariable [QEGVAR(pharma,coagulation_tourniqueBlock), true]) then { // Check for tourniqet
continue;
};

if (_openWounds isEqualTo []) exitWith {};
if (_pulse < 20) exitWith {};
if (_coagulationFactor == 0) exitWith {};
{
_x params ["_woundClassID", "_amountOf", "_bleeding", "_damage"];

private _category = _woundClassID % 10;
private _suffix = ["Minor", "Medium", "Large"] select _category;

switch (_suffix) do {
case "Minor": {
if (missionNamespace getVariable [QEGVAR(pharma,coagulation_allow_MinorWounds), true] && _amountOf * _bleeding > 0) then {
_hasWoundToBandageArray pushBack true;
};
};
case "Medium": {
if (missionNamespace getVariable [QEGVAR(pharma,coagulation_allow_MediumWounds), true] && _amountOf * _bleeding > 0) then {
_hasWoundToBandageArray pushBack true;
};
};
default {
if (missionNamespace getVariable [QEGVAR(pharma,coagulation_allow_LargeWounds), true] && _amountOf * _bleeding > 0) then {
_hasWoundToBandageArray pushBack true;
};
};
};
} forEach (_openWounds get _x); // Sets array that specifies if there is a open wound that coag can bandage in body part (here for performance so that the fnc does not get called every time)

private _count = [_unit, "TXA"] call ACEFUNC(medical_status,getMedicationCount);
if (!(EGVAR(pharma,coagulation_on_all_Bodyparts)) && true in _hasWoundToBandageArray) exitWith { // Check if coag should be present on all body party simultaneously, if not use this exitWith to block next interiation of forEach
[_unit, _x, _openWounds get _x, _countTXA, _countEACA] call _fnc_clotWound;
};

if (true in _hasWoundToBandageArray) then { // Check if there is a wound to bandage for coag, if not loop through next interiation of forEach
[_unit, _x, _openWounds get _x, _countTXA, _countEACA] call _fnc_clotWound;
};
} forEach _shuffledKeys;
}, missionNamespace getVariable [QEGVAR(pharma,coagulation_time), 5], [_unit, _fnc_clotWound]] call CBA_fnc_addPerFrameHandler;

if (_count == 0) exitWith {
{
_x params ["", "_bodyPart", "_amount", "_bleeding"];
[{
params ["_args", "_idPFH"];
_args params ["_unit"];

if (_amount * _bleeding > 0) exitWith {
private _part = ALL_BODY_PARTS select _bodyPart;
[QACEGVAR(medical_treatment,bandageLocal), [_unit, _part, "UnstableClot"], _unit] call CBA_fnc_targetEvent;
_unit setVariable [QEGVAR(pharma,coagulationFactor), (_coagulationFactor - 1), true];
};
} forEach _openWounds;
private _alive = alive _unit;

if !(_alive) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

if (_count > 0) exitWith {
{
_x params ["", "_bodyPart", "_amount", "_bleeding"];
if (!(EGVAR(pharma,coagulation_allowOnAI)) && ACE_Player != _unit) exitWith { // Check allowOnAI setting to save performance
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

if (_amount * _bleeding > 0) exitWith {
private _part = ALL_BODY_PARTS select _bodyPart;
[QACEGVAR(medical_treatment,bandageLocal), [_unit, _part, "PackingBandage"], _unit] call CBA_fnc_targetEvent;
_unit setVariable [QEGVAR(pharma,coagulationFactor), (_coagulationFactor - 1), true];
if (_unit getVariable [QACEGVAR(medical,bloodVolume), 6.0] < EGVAR(pharma,coagulation_requireBV)) exitWith {}; // Blood volume check
if ((_pulse < 20) && EGVAR(pharma,coagulation_requireHR)) exitWith {}; // Has pulse & require setting

private _currentCoagFactors = _unit getVariable [QEGVAR(pharma,coagulationFactor), 15];
private _savedCoagFactors = _unit getVariable [QEGVAR(pharma,coagulationSavedFactors), (_unit getVariable [QEGVAR(pharma,coagulationFactor), 15])];
private _limitRegenCoagFactors = missionNamespace getVariable [QEGVAR(pharma,coagulation_factor_count), 15];
private _cooldownON = _unit getVariable [QEGVAR(pharma,coagulationRegenCooldown), false];
private _countTXA = [_unit, "TXA"] call ACEFUNC(medical_status,getMedicationCount);
private _countEACA = [_unit, "EACA"] call ACEFUNC(medical_status,getMedicationCount);
private _ammountToAdd = 1;

if (_currentCoagFactors < _savedCoagFactors) exitWith {
[{
params["_unit"];
_unit setVariable [QEGVAR(pharma,coagulationSavedFactors), _unit getVariable [QEGVAR(pharma,coagulationFactor), 15], true];
},
[_unit], ((missionNamespace getVariable [QEGVAR(pharma,coagulation_factor_regenreate_time), 150]) / 2)] call CBA_fnc_waitAndExecute; // Block regen PFH instance from happening
};

if (_currentCoagFactors == _savedCoagFactors && _currentCoagFactors < _limitRegenCoagFactors) exitWith {

if (_countTXA > 0 || _countEACA > 0) then { // If TXA or EACA are in system add more factors
if (_countTXA > 0 && _countEACA > 0) exitWith {
_ammountToAdd = 4;
};
} forEach _openWounds;
_ammountToAdd = 2;
};

_unit setVariable [QEGVAR(pharma,coagulationFactor), (_currentCoagFactors + _ammountToAdd), true];
_unit setVariable [QEGVAR(pharma,coagulationSavedFactors), (_currentCoagFactors + _ammountToAdd), true];
};

if (_currentCoagFactors > _limitRegenCoagFactors && !(_cooldownON)) exitWith {

if (_countTXA > 0 || _countEACA > 0) exitWith {}; // If TXA or EACA is in system don't remove factor

_unit setVariable [QEGVAR(pharma,coagulationFactor), (_currentCoagFactors - 1), true];
_unit setVariable [QEGVAR(pharma,coagulationSavedFactors), (_currentCoagFactors - 1), true];
_unit setVariable [QEGVAR(pharma,coagulationRegenCooldown), true, true];

[{
params["_unit"];
_unit setVariable [QEGVAR(pharma,coagulationRegenCooldown), false, true];
},
[_unit], missionNamespace getVariable [QEGVAR(pharma,coagulation_factor_regenreate_time), 150]] call CBA_fnc_waitAndExecute;
};
}, 8, [_unit]] call CBA_fnc_addPerFrameHandler;

_unit setVariable [QEGVAR(pharma,coagulationSavedFactors), _currentCoagFactors, true];

}, missionNamespace getVariable [QEGVAR(pharma,coagulation_factor_regenreate_time), 150], [_unit]] call CBA_fnc_addPerFrameHandler;
};

/// Clear Stamina & weapon sway
Expand Down
2 changes: 1 addition & 1 deletion addons/pharma/ACE_Medical_Treatment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ACE_ADDON(Medical_Treatment) {
hrIncreaseLow[] = {0, 0};
hrIncreaseNormal[] = {0, 0};
hrIncreaseHigh[] = {0, 0};
timeInSystem = 120;
timeInSystem = 300;
timeTillMaxEffect = 5;
maxDose = 3;
incompatibleMedication[] = {};
Expand Down
Loading

0 comments on commit afb94cf

Please sign in to comment.