2018-07-30 09:22:14 +00:00
|
|
|
#include "script_component.hpp"
|
2016-07-15 10:23:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Use Equipment items if any is available. Priority: 1) Medic, 2) Patient. If in vehicle: 3) Crew
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Medic <OBJECT>
|
|
|
|
* 1: Patient <OBJECT>
|
|
|
|
* 2: Items <ARRAY<STRING>>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Return Value:
|
2016-09-29 17:31:48 +00:00
|
|
|
* 0: success <BOOL>
|
|
|
|
* 1: Unit <OBJECT>
|
2016-07-15 10:23:47 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2019-03-30 16:07:54 +00:00
|
|
|
* [unit, patient, ["bandage"]] call ace_medical_treatment_fnc_useItems
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
2019-03-30 16:07:54 +00:00
|
|
|
* Public: No
|
2016-07-15 10:23:47 +00:00
|
|
|
*/
|
|
|
|
|
2018-07-29 21:43:14 +00:00
|
|
|
#define HAS_USED_ITEM(itemUsedInfo) (itemUsedInfo select 0)
|
|
|
|
#define GET_ITEM_USED_BY(itemUsedInfo) (itemUsedInfo select 1)
|
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
params ["_medic", "_patient", "_items"];
|
|
|
|
|
|
|
|
private _itemsUsedBy = [];
|
2016-09-29 17:31:48 +00:00
|
|
|
|
2016-07-15 10:23:47 +00:00
|
|
|
{
|
|
|
|
// handle a one of type use item
|
|
|
|
if (_x isEqualType []) then {
|
|
|
|
{
|
|
|
|
private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem);
|
2016-09-29 17:31:48 +00:00
|
|
|
|
2018-07-29 21:43:14 +00:00
|
|
|
if (HAS_USED_ITEM(_itemUsedInfo)) exitWith {
|
|
|
|
_itemsUsedBy pushBack [GET_ITEM_USED_BY(_itemUsedInfo), _x];
|
2016-09-29 17:31:48 +00:00
|
|
|
};
|
2016-07-15 10:23:47 +00:00
|
|
|
} forEach _x;
|
|
|
|
};
|
|
|
|
|
|
|
|
// handle required item
|
|
|
|
if (_x isEqualType "") then {
|
|
|
|
private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem);
|
2016-09-29 17:31:48 +00:00
|
|
|
|
2018-07-29 21:43:14 +00:00
|
|
|
if (HAS_USED_ITEM(_itemUsedInfo)) exitWith {
|
|
|
|
_itemsUsedBy pushBack [GET_ITEM_USED_BY(_itemUsedInfo), _x];
|
2016-09-29 17:31:48 +00:00
|
|
|
};
|
2016-07-15 10:23:47 +00:00
|
|
|
};
|
|
|
|
} forEach _items;
|
|
|
|
|
|
|
|
[count _items == count _itemsUsedBy, _itemsUsedBy];
|