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:
|
|
|
|
* User and Item <ARRAY>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
{
|
|
|
|
private _unit = _x;
|
2023-09-05 14:20:56 +00:00
|
|
|
private _unitVehicle = objectParent _unit;
|
2019-06-03 15:31:46 +00:00
|
|
|
private _unitItems = _x call EFUNC(common,uniqueItems);
|
2016-09-29 17:31:48 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
{
|
2023-09-05 14:20:56 +00:00
|
|
|
if (!isNull _unitVehicle && {_x in (itemCargo _unitVehicle)}) then {
|
|
|
|
_unitVehicle addItemCargoGlobal [_x, -1];
|
|
|
|
[_unit, _x] breakOut "Main";
|
|
|
|
};
|
2019-06-03 15:31:46 +00:00
|
|
|
if (_x in _unitItems) then {
|
|
|
|
_unit removeItem _x;
|
|
|
|
[_unit, _x] breakOut "Main";
|
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
|
|
|
|
2019-06-03 15:31:46 +00:00
|
|
|
[objNull, ""]
|