diff --git a/addons/medical/dev/watchVariable.sqf b/addons/medical/dev/watchVariable.sqf index 4eeee668b0..c0edacd97f 100644 --- a/addons/medical/dev/watchVariable.sqf +++ b/addons/medical/dev/watchVariable.sqf @@ -75,7 +75,7 @@ _return pushBack format ["%1 [Time On: %2]", ALL_SELECTIONS select _tPartNum, (CBA_missionTime - _x) toFixed 1]; }; { - _x params ["", "_medClassname", "_medPartNum"]; + _x params ["_medPartNum", "_medClassname"]; if (_medPartNum == _tPartNum) then { _return pushBack format [" - Occluded Med: %1", _medClassname]; }; diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index d9ac161ffc..4eca095dbc 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -10,13 +10,13 @@ if (isServer) then { }; // treatment events -[QGVAR(treatmentBandageLocal), FUNC(treatmentBandageLocal)] call CBA_fnc_addEventHandler; -[QGVAR(treatmentTourniquetLocal), FUNC(treatmentTourniquetLocal)] call CBA_fnc_addEventHandler; -[QGVAR(treatmentMedicationLocal), FUNC(treatmentMedicationLocal)] call CBA_fnc_addEventHandler; -[QGVAR(treatmentIVLocal), FUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; +[QGVAR(bandageLocal), FUNC(bandageLocal)] call CBA_fnc_addEventHandler; +[QGVAR(tourniquetLocal), FUNC(tourniquetLocal)] call CBA_fnc_addEventHandler; +[QGVAR(medicationLocal), FUNC(medicationLocal)] call CBA_fnc_addEventHandler; +[QGVAR(ivBagLocal), FUNC(ivBagLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentFullHealLocal), FUNC(treatmentFullHealLocal)] call CBA_fnc_addEventHandler; -[QGVAR(treatmentSplintLocal), FUNC(splintLocal)] call CBA_fnc_addEventHandler; +[QGVAR(splintLocal), FUNC(splintLocal)] call CBA_fnc_addEventHandler; // action events [QGVAR(checkPulseLocal), FUNC(checkPulseLocal)] call CBA_fnc_addEventHandler; diff --git a/addons/medical_treatment/functions/fnc_bandageLocal.sqf b/addons/medical_treatment/functions/fnc_bandageLocal.sqf index 1a81670dd8..a27eaa511c 100644 --- a/addons/medical_treatment/functions/fnc_bandageLocal.sqf +++ b/addons/medical_treatment/functions/fnc_bandageLocal.sqf @@ -42,13 +42,15 @@ _openWounds set [_woundIndex, _wound]; _patient setVariable [QEGVAR(medical,openWounds), _openWounds, true]; +[_patient] call EFUNC(medical_status,updateWoundBloodLoss); + // Handle the reopening of bandaged wounds if (_impact > 0 && {GVAR(advancedBandages) && {GVAR(woundReopening)}}) then { [_patient, _impact, _partIndex, _woundIndex, _wound, _bandage] call FUNC(handleBandageOpening); }; // Check if we fixed limping from this treatment -if ((EGVAR(medical,limping) == 1) && {_partIndex > 3} && {_amountOf <= 0} && {_target getVariable [QEGVAR(medical,isLimping), false]}) then { +if ((EGVAR(medical,limping) == 1) && {_partIndex > 3} && {_amountOf <= 0} && {_patient getVariable [QEGVAR(medical,isLimping), false]}) then { [_patient] call EFUNC(medical_engine,updateDamageEffects); }; diff --git a/addons/medical_treatment/functions/fnc_checkResponse.sqf b/addons/medical_treatment/functions/fnc_checkResponse.sqf index c95eabd978..0fe0bbd60e 100644 --- a/addons/medical_treatment/functions/fnc_checkResponse.sqf +++ b/addons/medical_treatment/functions/fnc_checkResponse.sqf @@ -21,4 +21,4 @@ params ["_medic", "_patient"]; private _output = [LSTRING(Check_Response_Unresponsive), LSTRING(Check_Response_Responsive)] select (_patient call EFUNC(common,isAwake)); [[_output, _patient call EFUNC(common,getName)], 2] call EFUNC(common,displayTextStructured); -[_patient, "quick_view", _output, [[_target, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); +[_patient, "quick_view", _output, [[_patient, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); diff --git a/addons/medical_treatment/functions/fnc_createLitter.sqf b/addons/medical_treatment/functions/fnc_createLitter.sqf index e202a3daa8..587648de49 100644 --- a/addons/medical_treatment/functions/fnc_createLitter.sqf +++ b/addons/medical_treatment/functions/fnc_createLitter.sqf @@ -29,7 +29,7 @@ if (vehicle _medic != _medic || {vehicle _patient != _patient}) exitWith {}; // Determine if treated body part is bleeding private _index = ALL_BODY_PARTS find toLower _bodyPart; private _isBleeding = (_patient getVariable [QEGVAR(medical,openWounds), []]) findIf { - _x params ["", "", "_bodyPartN", "_amountOf", "_bleeding"]; + _x params ["", "_bodyPartN", "_amountOf", "_bleeding"]; _bodyPartN == _index && {_amountOf * _bleeding > 0} } != -1; diff --git a/addons/medical_treatment/functions/fnc_medicationLocal.sqf b/addons/medical_treatment/functions/fnc_medicationLocal.sqf index de11cf317e..6a0fce8842 100644 --- a/addons/medical_treatment/functions/fnc_medicationLocal.sqf +++ b/addons/medical_treatment/functions/fnc_medicationLocal.sqf @@ -21,6 +21,7 @@ #define MORPHINE_PAIN_SUPPRESSION 0.6 params ["_patient", "_bodyPart", "_classname"]; +TRACE_3("medicationLocal",_patient,_bodyPart,_classname); // Medication has no effects on dead units if (!alive _patient) exitWith {}; @@ -37,11 +38,14 @@ if (!GVAR(advancedMedication)) exitWith { }; }; }; +TRACE_1("Running treatmentMedicationLocal with Advanced configuration for", _target); + // Handle tourniquet on body part blocking blood flow at injection site private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; if (HAS_TOURNIQUET_APPLIED_ON(_patient,_partIndex)) exitWith { + TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets); private _occludedMedications = _patient getVariable [QEGVAR(medical,occludedMedications), []]; _occludedMedications pushBack [_partIndex, _classname]; _patient setVariable [QEGVAR(medical,occludedMedications), _occludedMedications, true]; @@ -62,8 +66,13 @@ private _hrIncreaseHigh = GET_ARRAY(_medicationConfig >> "hrIncreaseHigh private _incompatableMedication = GET_ARRAY(_medicationConfig >> "incompatableMedication",getArray (_defaultConfig >> "incompatableMedication")); private _heartRate = GET_HEART_RATE(_patient); -private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNorm, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55)); +private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNormal, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55)); _hrIncrease params ["_minIncrease", "_maxIncrease"]; private _heartRateChange = _minIncrease + random (_maxIncrease - _minIncrease); -// todo: finish when medication rework PR is complete +// Adjust the medication effects and add the medication to the list +TRACE_3("adjustments",_heartRateChange,_painReduce,_viscosityChange); +[_patient, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment); + +// Check for medication compatiblity +[_patient, _className, _maxDose, _incompatableMedication] call FUNC(onMedicationUsage); diff --git a/addons/medical_treatment/functions/fnc_splint.sqf b/addons/medical_treatment/functions/fnc_splint.sqf index 4ced63109c..ade40a1520 100644 --- a/addons/medical_treatment/functions/fnc_splint.sqf +++ b/addons/medical_treatment/functions/fnc_splint.sqf @@ -22,4 +22,4 @@ TRACE_3("splint",_caller,_target,_bodyPart); private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; -[QGVAR(treatmentSplintLocal), [_caller, _target, _partIndex], _target] call CBA_fnc_targetEvent; +[QGVAR(splintLocal), [_caller, _target, _partIndex], _target] call CBA_fnc_targetEvent; diff --git a/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf b/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf index a9473c43b9..565df32e54 100644 --- a/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf +++ b/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf @@ -26,13 +26,24 @@ private _bandagedWounds = _patient getVariable [QEGVAR(medical,bandagedWounds), private _stitchedWounds = _patient getVariable [QEGVAR(medical,stitchedWounds), []]; // Stop treatment if there are no wounds that can be stitched remaining -if (_bandagedWounds isEqualTo []) exitWith {false}; +if (_bandagedWounds isEqualTo []) exitWith { false }; // Check if enough time has elapsed to stitch another wound if (_totalTime - _elapsedTime <= (count _bandagedWounds - 1) * 5) then { - _stitchedWounds pushBack (_bandagedWounds deleteAt 0); + private _treatedWound = _bandagedWounds deleteAt 0; + _stitchedWounds pushBack _treatedWound; _patient setVariable [QEGVAR(medical,bandagedWounds), _bandagedWounds, true]; _patient setVariable [QEGVAR(medical,stitchedWounds), _stitchedWounds, true]; + TRACE_3("stitched",_treatedWound,count _bandagedWounds,count _stitchedWounds); + + // Check if we fixed limping from this treatment + if ((EGVAR(medical,limping) == 2) && {_patient getVariable [QEGVAR(medical,isLimping), false]}) then { + _treatedWound params ["", "_partN"]; + if (_partN > 3) then { // only for LEG wounds + TRACE_3("updating damage effects",_patient,_partN,local _patient); + [QEGVAR(medical_engine,updateDamageEffects), [_patient], _patient] call CBA_fnc_patientEvent; + }; + }; }; true diff --git a/addons/medical_treatment/functions/fnc_tourniquetLocal.sqf b/addons/medical_treatment/functions/fnc_tourniquetLocal.sqf index cfe8f1596c..4bc803a8a8 100644 --- a/addons/medical_treatment/functions/fnc_tourniquetLocal.sqf +++ b/addons/medical_treatment/functions/fnc_tourniquetLocal.sqf @@ -17,9 +17,12 @@ */ params ["_patient", "_bodyPart"]; +TRACE_2("tourniquetLocal",_patient,_bodyPart); private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; private _tourniquets = GET_TOURNIQUETS(_patient); _tourniquets set [_partIndex, CBA_missionTime]; _patient setVariable [VAR_TOURNIQUET, _tourniquets, true]; + +[_patient] call EFUNC(medical_status,updateWoundBloodLoss); diff --git a/addons/medical_treatment/functions/fnc_tourniquetRemove.sqf b/addons/medical_treatment/functions/fnc_tourniquetRemove.sqf index d219b8456b..50f4c084c0 100644 --- a/addons/medical_treatment/functions/fnc_tourniquetRemove.sqf +++ b/addons/medical_treatment/functions/fnc_tourniquetRemove.sqf @@ -18,6 +18,7 @@ */ params ["_medic", "_patient", "_bodyPart"]; +TRACE_3("tourniquetRemove",_medic,_patient,_bodyPart); // Remove tourniquet from body part, exit if no tourniquet applied private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; @@ -30,6 +31,8 @@ if (_tourniquets select _partIndex == 0) exitWith { _tourniquets set [_partIndex, 0]; _patient setVariable [VAR_TOURNIQUET, _tourniquets, true]; +[_patient] call EFUNC(medical_status,updateWoundBloodLoss); + // Add tourniquet item to medic's inventory // todo: should there be a setting to select who receives the removed tourniquet? [_medic, "ACE_tourniquet", true] call EFUNC(common,addToInventory); @@ -42,6 +45,7 @@ private _arrayModified = false; _x params ["_bodyPartN", "_medication"]; if (_partIndex == _bodyPartN) then { + TRACE_1("delayed medication call after tourniquet removeal",_x); [QGVAR(medicationLocal), [_patient, _bodyPart, _medication], _patient] call CBA_fnc_targetEvent; _occludedMedications set [_forEachIndex, []]; _arrayModified = true;