2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-07-15 10:23:47 +00:00
|
|
|
/*
|
2019-06-03 15:31:46 +00:00
|
|
|
* Author: Glowbal, mharis001
|
|
|
|
* Uses one of the treatment items. Respects the priority defined by the allowSharedEquipment setting.
|
2023-09-05 14:20:56 +00:00
|
|
|
* Can use items from vehicle inventory if either unit is in a vehicle.
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Medic <OBJECT>
|
|
|
|
* 1: Patient <OBJECT>
|
2019-06-03 15:31:46 +00:00
|
|
|
* 2: Items <ARRAY>
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
2019-06-03 15:31:46 +00:00
|
|
|
* Return Value:
|
2024-04-07 01:11:51 +00:00
|
|
|
* User and Item and Litter Created<ARRAY>
|
2019-06-03 15:31:46 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2020-04-25 06:41:45 +00:00
|
|
|
* [player, cursorObject, ["bandage"]] call ace_medical_treatment_fnc_useItem
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
2019-03-30 16:07:54 +00:00
|
|
|
* Public: No
|
2016-07-15 10:23:47 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
params ["_medic", "_patient", "_items"];
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2023-11-20 21:52:29 +00:00
|
|
|
if (_medic isEqualTo player && {!isNull findDisplay 312}) exitWith {
|
|
|
|
[_medic, _items select 0]
|
|
|
|
};
|
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
scopeName "Main";
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
private _useOrder = [[_patient, _medic], [_medic, _patient], [_medic]] select GVAR(allowSharedEquipment);
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
{
|
2024-03-21 21:56:24 +00:00
|
|
|
private _unit = _x;
|
2023-09-05 14:20:56 +00:00
|
|
|
private _unitVehicle = objectParent _unit;
|
2024-03-21 21:56:24 +00:00
|
|
|
private _unitItems = [_x, 0] call EFUNC(common,uniqueItems);
|
|
|
|
private _unitMagazines = [_x, 2] call EFUNC(common,uniqueItems);
|
|
|
|
private _vehicleItems = itemCargo _unitVehicle; // [] for objNull
|
|
|
|
private _vehicleMagazines = magazineCargo _unitVehicle; // same
|
2016-09-29 17:31:48 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
{
|
2024-03-21 21:56:24 +00:00
|
|
|
switch (true) do {
|
|
|
|
case (_x in _vehicleItems): {
|
|
|
|
_unitVehicle addItemCargoGlobal [_x, -1];
|
2024-04-07 01:11:51 +00:00
|
|
|
[_unit, _x, false] breakOut "Main";
|
2024-03-21 21:56:24 +00:00
|
|
|
};
|
|
|
|
case (_x in _vehicleMagazines): {
|
|
|
|
[_unitVehicle, _x] call EFUNC(common,adjustMagazineAmmo);
|
2024-04-07 01:11:51 +00:00
|
|
|
[_unit, _x, false] breakOut "Main";
|
2024-03-21 21:56:24 +00:00
|
|
|
};
|
|
|
|
case (_x in _unitItems): {
|
|
|
|
_unit removeItem _x;
|
2024-04-07 01:11:51 +00:00
|
|
|
[_unit, _x, true] breakOut "Main";
|
2024-03-21 21:56:24 +00:00
|
|
|
};
|
|
|
|
case (_x in _unitMagazines): {
|
2024-04-07 01:11:51 +00:00
|
|
|
private _magsStart = count magazines _unit;
|
2024-03-21 21:56:24 +00:00
|
|
|
[_unit, _x] call EFUNC(common,adjustMagazineAmmo);
|
2024-04-07 01:11:51 +00:00
|
|
|
private _magsEnd = count magazines _unit;
|
|
|
|
[_unit, _x, (_magsEnd < _magsStart)] breakOut "Main";
|
2024-03-21 21:56:24 +00:00
|
|
|
};
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
2019-06-03 15:31:46 +00:00
|
|
|
} forEach _items;
|
|
|
|
} forEach _useOrder;
|
2016-07-15 10:23:47 +00:00
|
|
|
|
2024-04-07 01:11:51 +00:00
|
|
|
[objNull, "", false]
|