Medical - Add treating with items from vehicle inventory (#9286)

* allow pulling items from vehicle inventory

* use vehicle items first
This commit is contained in:
Grim 2023-09-05 10:20:56 -04:00 committed by GitHub
parent 938f421ac3
commit aa107ed517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* Checks if one of the given items are present between the medic and patient.
* Does not respect the priority defined by the allowSharedEquipment setting.
* Will check medic first and then patient if shared equipment is allowed.
* If medic or patient are in a vehicle then vehicle's inventory will also be checked.
*
* Arguments:
* 0: Medic <OBJECT>
@ -25,6 +26,10 @@ private _fnc_checkItems = {
params ["_unit"];
private _unitItems = _unit call EFUNC(common,uniqueItems);
private _unitVehicle = objectParent _unit;
if (!isNull _unitVehicle) then {
_unitItems append (itemCargo _unitVehicle);
};
_items findIf {_x in _unitItems} != -1
};

View File

@ -2,6 +2,7 @@
/*
* Author: Glowbal, mharis001
* Uses one of the treatment items. Respects the priority defined by the allowSharedEquipment setting.
* Can use items from vehicle inventory if either unit is in a vehicle.
*
* Arguments:
* 0: Medic <OBJECT>
@ -25,9 +26,14 @@ private _useOrder = [[_patient, _medic], [_medic, _patient], [_medic]] select GV
{
private _unit = _x;
private _unitVehicle = objectParent _unit;
private _unitItems = _x call EFUNC(common,uniqueItems);
{
if (!isNull _unitVehicle && {_x in (itemCargo _unitVehicle)}) then {
_unitVehicle addItemCargoGlobal [_x, -1];
[_unit, _x] breakOut "Main";
};
if (_x in _unitItems) then {
_unit removeItem _x;
[_unit, _x] breakOut "Main";