2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2018-09-17 19:03:28 +00:00
|
|
|
/*
|
2024-03-21 21:56:24 +00:00
|
|
|
* Author: mharis001, Blue, Brett Mayson
|
|
|
|
* Returns list of unique items in the target's inventory.
|
2018-09-17 19:03:28 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2024-03-21 21:56:24 +00:00
|
|
|
* 0: Target <OBJECT>
|
|
|
|
* 1: Include magazines <NUMBER>
|
|
|
|
* 0: No (default)
|
|
|
|
* 1: Yes
|
|
|
|
* 2: Only magazines
|
2018-09-17 19:03:28 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Items <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2024-03-21 21:56:24 +00:00
|
|
|
* [player, 2] call ace_common_fnc_uniqueItems
|
2018-09-17 19:03:28 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2024-03-21 21:56:24 +00:00
|
|
|
params ["_target", ["_includeMagazines", 0]];
|
2018-09-17 19:03:28 +00:00
|
|
|
|
|
|
|
private _fnc_getItems = {
|
2024-03-21 21:56:24 +00:00
|
|
|
private _items = [];
|
|
|
|
|
|
|
|
private _inventoryItems = (getItemCargo uniformContainer _target) select 0;
|
|
|
|
_inventoryItems append ((getItemCargo vestContainer _target) select 0);
|
|
|
|
_inventoryItems append ((getItemCargo backpackContainer _target) select 0);
|
|
|
|
|
2024-07-03 15:30:41 +00:00
|
|
|
private _magazines = magazines _target;
|
2018-09-17 19:03:28 +00:00
|
|
|
|
2024-07-03 15:30:41 +00:00
|
|
|
_items set [0, _inventoryItems arrayIntersect _inventoryItems];
|
|
|
|
_items set [1, _magazines arrayIntersect _magazines];
|
|
|
|
|
|
|
|
_items
|
2018-09-17 19:03:28 +00:00
|
|
|
};
|
|
|
|
|
2024-03-21 21:56:24 +00:00
|
|
|
// Cache items list if unit is ACE_player
|
|
|
|
if (_target 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
|
|
|
};
|
2024-03-21 21:56:24 +00:00
|
|
|
|
|
|
|
switch (_includeMagazines) do {
|
|
|
|
case 0: {
|
|
|
|
GVAR(uniqueItemsCache) select 0
|
|
|
|
};
|
|
|
|
case 1: {
|
|
|
|
(GVAR(uniqueItemsCache) select 1) + (GVAR(uniqueItemsCache) select 0)
|
|
|
|
};
|
|
|
|
case 2: {
|
|
|
|
GVAR(uniqueItemsCache) select 1
|
|
|
|
};
|
|
|
|
};
|
2018-09-17 19:03:28 +00:00
|
|
|
} else {
|
2024-03-21 21:56:24 +00:00
|
|
|
if (_target isKindOf "CAManBase") then {
|
|
|
|
private _items = call _fnc_getItems;
|
|
|
|
|
|
|
|
switch (_includeMagazines) do {
|
|
|
|
case 0: {
|
|
|
|
_items select 0
|
|
|
|
};
|
|
|
|
case 1: {
|
|
|
|
(_items select 1) + (_items select 0)
|
|
|
|
};
|
|
|
|
case 2: {
|
|
|
|
_items select 1
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
private _items = switch (_includeMagazines) do {
|
|
|
|
case 0: {
|
|
|
|
itemCargo _target
|
|
|
|
};
|
|
|
|
case 1: {
|
|
|
|
(magazineCargo _target) + (itemCargo _target)
|
|
|
|
};
|
|
|
|
case 2: {
|
|
|
|
magazineCargo _target
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
_items arrayIntersect _items
|
|
|
|
};
|
2018-09-17 19:03:28 +00:00
|
|
|
};
|