2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2018-09-17 19:03:28 +00:00
|
|
|
/*
|
|
|
|
* Author: mharis001
|
|
|
|
* Returns list of unique items in a unit's inventory.
|
|
|
|
* Items are cached if unit is ACE_player.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Items <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2019-05-13 22:20:01 +00:00
|
|
|
* [player] call ace_common_fnc_uniqueItems
|
2018-09-17 19:03:28 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit"];
|
|
|
|
|
|
|
|
private _fnc_getItems = {
|
|
|
|
private _items = (getItemCargo uniformContainer _unit) select 0;
|
|
|
|
_items append ((getItemCargo vestContainer _unit) select 0);
|
|
|
|
_items append ((getItemCargo backpackContainer _unit) select 0);
|
|
|
|
|
|
|
|
_items arrayIntersect _items
|
|
|
|
};
|
|
|
|
|
|
|
|
// Use cached items list if unit is ACE_player
|
|
|
|
if (_unit isEqualTo ACE_player) then {
|
2019-05-13 22:20:01 +00:00
|
|
|
if (isNil QGVAR(uniqueItemsCache)) then {
|
|
|
|
GVAR(uniqueItemsCache) = call _fnc_getItems;
|
2018-09-17 19:03:28 +00:00
|
|
|
};
|
2019-05-13 22:20:01 +00:00
|
|
|
+GVAR(uniqueItemsCache)
|
2018-09-17 19:03:28 +00:00
|
|
|
} else {
|
|
|
|
call _fnc_getItems;
|
|
|
|
};
|