diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index ce44540b20..7345c2a54e 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -10,6 +10,10 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; ["medical_woundUpdateRequest", FUNC(onWoundUpdateRequest)] call EFUNC(common,addEventHandler); ["interactMenuClosed", {[objNull, false] call FUNC(displayPatientInformation); }] call EFUNC(common,addEventHandler); +//Treatment EventHandlers: +["medical_advMedication", FUNC(treatmentAdvanced_medicationLocal)] call EFUNC(common,addEventHandler); + + ["medical_onUnconscious", { params ["_unit", "_status"]; if (local _unit) then { diff --git a/addons/medical/functions/fnc_actionRemoveTourniquet.sqf b/addons/medical/functions/fnc_actionRemoveTourniquet.sqf index 81412f60c4..84df1acbd8 100644 --- a/addons/medical/functions/fnc_actionRemoveTourniquet.sqf +++ b/addons/medical/functions/fnc_actionRemoveTourniquet.sqf @@ -17,6 +17,7 @@ private ["_part", "_tourniquets", "_output"]; params ["_caller", "_target", "_selectionName"]; +TRACE_3("params",_caller,_target,_selectionName); // grab the required data _part = [_selectionName] call FUNC(selectionNameToNumber); @@ -34,3 +35,21 @@ _target setVariable [QGVAR(tourniquets), _tourniquets, true]; // Adding the tourniquet item to the caller _caller addItem "ACE_tourniquet"; + +//Handle all injected medications now that blood is flowing: +private _delayedMedications = _target getVariable [QGVAR(occludedMedications), []]; +private _updatedArray = false; +TRACE_2("meds",_part,_delayedMedications); +{ + _x params ["", "", "_medPartNum"]; + if (_part == _medPartNum) then { + TRACE_1("delayed medication call after tourniquet removeal",_x); + ["medical_advMedication", [_target], _x] call EFUNC(common,targetEvent); + _delayedMedications set [_forEachIndex, -1]; + _updatedArray = true; + }; +} forEach _delayedMedications; +if (_updatedArray) then { + _delayedMedications = _delayedMedications - [-1]; + _target setVariable [QGVAR(occludedMedications), _delayedMedications, true]; +}; diff --git a/addons/medical/functions/fnc_init.sqf b/addons/medical/functions/fnc_init.sqf index ad58a0126e..868b07fbf4 100644 --- a/addons/medical/functions/fnc_init.sqf +++ b/addons/medical/functions/fnc_init.sqf @@ -24,6 +24,9 @@ _unit setVariable ["ACE_isUnconscious", false, true]; // tourniquets _unit setVariable [QGVAR(tourniquets), [0,0,0,0,0,0], true]; +//Delayed Medications (from tourniquets) +_unit setVariable [QGVAR(occludedMedications), nil, true]; + // wounds and injuries _unit setVariable [QGVAR(openWounds), [], true]; _unit setVariable [QGVAR(bandagedWounds), [], true]; diff --git a/addons/medical/functions/fnc_onMedicationUsage.sqf b/addons/medical/functions/fnc_onMedicationUsage.sqf index 8eb55b3d1b..fc7e8daa2d 100644 --- a/addons/medical/functions/fnc_onMedicationUsage.sqf +++ b/addons/medical/functions/fnc_onMedicationUsage.sqf @@ -20,6 +20,7 @@ private ["_foundEntry", "_allUsedMedication","_allMedsFromClassname", "_usedMeds", "_hasOverDosed", "_med", "_limit", "_decreaseAmount", "_viscosityAdjustment", "_medicationConfig", "_onOverDose"]; params ["_target", "_className", "_variable", "_maxDosage", "_timeInSystem", "_incompatabileMeds", "_viscosityChange", "_painReduce"]; +TRACE_8("params",_target,_className,_variable,_maxDosage,_timeInSystem,_incompatabileMeds,_viscosityChange,_painReduce); _foundEntry = false; _allUsedMedication = _target getVariable [QGVAR(allUsedMedication), []]; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf index 5949f53780..c5643745d7 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf @@ -7,7 +7,7 @@ * 1: The patient * 2: SelectionName * 3: Treatment classname - * + * 4: Items Used * * Return Value: * Succesful treatment started @@ -18,8 +18,11 @@ #include "script_component.hpp" params ["_caller", "_target", "_selectionName", "_className", "_items"]; +TRACE_5("params",_caller,_target,_selectionName,_className,_items); -[[_target, _className], QUOTE(DFUNC(treatmentAdvanced_medicationLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +private _part = [_selectionName] call FUNC(selectionNameToNumber); + +["medical_advMedication", [_target], [_target, _className, _part]] call EFUNC(common,targetEvent); { if (_x != "") then { diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf index 952f245da9..2c3cf4cc41 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf @@ -5,7 +5,7 @@ * Arguments: * 0: The patient * 1: Treatment classname - * + * 2: Injection Site Part Number * * Return Value: * Succesful treatment started @@ -16,7 +16,18 @@ #include "script_component.hpp" private ["_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain", "_resistance", "_hrCallback", "_varName", "_viscosityChange"]; -params ["_target", "_className"]; + +params ["_target", "_className", "_partNumber"]; +TRACE_3("params",_target,_className,_partNumber); + +private _tourniquets = _target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; +if ((_tourniquets select _partNumber) > 0) exitWith { + TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets); + private _delayedMedications = _target getVariable [QGVAR(occludedMedications), []]; + _delayedMedications pushBack _this; + _target setVariable [QGVAR(occludedMedications), _delayedMedications, true]; + true +}; // We have added a new dose of this medication to our system, so let's increase it _varName = format[QGVAR(%1_inSystem), _className];