From 5ca3465b8a931698d94a1b0a281f085421ca8bc4 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 6 Apr 2024 20:11:51 -0500 Subject: [PATCH] Medical Treatment - Only create litter on empty container (#9924) --- .../medical_treatment/functions/fnc_treatment.sqf | 4 ++-- .../functions/fnc_treatmentSuccess.sqf | 6 ++++-- addons/medical_treatment/functions/fnc_useItem.sqf | 14 ++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf index b7ebbfd8b0..4222d69a4b 100644 --- a/addons/medical_treatment/functions/fnc_treatment.sqf +++ b/addons/medical_treatment/functions/fnc_treatment.sqf @@ -52,7 +52,7 @@ private _userAndItem = if (GET_NUMBER_ENTRY(_config >> "consumeItem") == 1) then [objNull, ""]; // Treatment does not require items to be consumed }; -_userAndItem params ["_itemUser", "_usedItem"]; +_userAndItem params ["_itemUser", "_usedItem", "_createLitter"]; private _isInZeus = !isNull findDisplay 312; @@ -161,7 +161,7 @@ if (_callbackProgress isEqualTo {}) then { [ _treatmentTime, - [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem], + [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _createLitter], FUNC(treatmentSuccess), FUNC(treatmentFailure), getText (_config >> "displayNameProgress"), diff --git a/addons/medical_treatment/functions/fnc_treatmentSuccess.sqf b/addons/medical_treatment/functions/fnc_treatmentSuccess.sqf index 96f0d11ead..a400fa98dc 100644 --- a/addons/medical_treatment/functions/fnc_treatmentSuccess.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentSuccess.sqf @@ -11,6 +11,7 @@ * 3: Treatment * 4: Item User * 5: Used Item + * 6: Create Litter * * Return Value: * None @@ -19,7 +20,8 @@ */ params ["_args"]; -_args params ["_medic", "_patient", "_bodyPart", "_classname", "_itemUser", "_usedItem"]; +_args params ["_medic", "_patient", "_bodyPart", "_classname", "_itemUser", "_usedItem", "_createLitter"]; +TRACE_7("",_medic,_patient,_bodyPart,_classname,_itemUser,_usedItem,_createLitter); // Switch medic to end animation immediately private _endInAnim = _medic getVariable QGVAR(endInAnim); @@ -45,7 +47,7 @@ GET_FUNCTION(_callbackSuccess,configFile >> QGVAR(actions) >> _classname >> "cal _args call _callbackSuccess; // Call litter creation handler -_args call FUNC(createLitter); +if (_createLitter) then { _args call FUNC(createLitter); }; // Emit local event for medical API ["ace_treatmentSucceded", [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem]] call CBA_fnc_localEvent; diff --git a/addons/medical_treatment/functions/fnc_useItem.sqf b/addons/medical_treatment/functions/fnc_useItem.sqf index 9bba3d1c90..33ac9f98f4 100644 --- a/addons/medical_treatment/functions/fnc_useItem.sqf +++ b/addons/medical_treatment/functions/fnc_useItem.sqf @@ -10,7 +10,7 @@ * 2: Items * * Return Value: - * User and Item + * User and Item and Litter Created * * Example: * [player, cursorObject, ["bandage"]] call ace_medical_treatment_fnc_useItem @@ -40,22 +40,24 @@ private _useOrder = [[_patient, _medic], [_medic, _patient], [_medic]] select GV switch (true) do { case (_x in _vehicleItems): { _unitVehicle addItemCargoGlobal [_x, -1]; - [_unit, _x] breakOut "Main"; + [_unit, _x, false] breakOut "Main"; }; case (_x in _vehicleMagazines): { [_unitVehicle, _x] call EFUNC(common,adjustMagazineAmmo); - [_unit, _x] breakOut "Main"; + [_unit, _x, false] breakOut "Main"; }; case (_x in _unitItems): { _unit removeItem _x; - [_unit, _x] breakOut "Main"; + [_unit, _x, true] breakOut "Main"; }; case (_x in _unitMagazines): { + private _magsStart = count magazines _unit; [_unit, _x] call EFUNC(common,adjustMagazineAmmo); - [_unit, _x] breakOut "Main"; + private _magsEnd = count magazines _unit; + [_unit, _x, (_magsEnd < _magsStart)] breakOut "Main"; }; }; } forEach _items; } forEach _useOrder; -[objNull, ""] +[objNull, "", false]