Arsenal - Fix unique item edge cases and prevent increasing quantity of cargo weapons (#9700)

* Unique weapons fix

* Update fnc_fillRightPanel.sqf

* Update fnc_updateUniqueItemsList.sqf

* Added unique facewear support
This commit is contained in:
johnb432 2023-12-31 14:14:17 +01:00 committed by GitHub
parent 449265c830
commit cb554a3ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 25 deletions

View File

@ -311,15 +311,17 @@ switch (_ctrlIDC) do {
// Unique goggles
{
if !(_x in _items) then {
["CfgGlasses", _x, true] call _fnc_fillRightContainer;
// _y indicates if an item is truly unique or if it's a non-inventory item in a container (e.g. goggles in backpack)
["CfgGlasses", _x, _y] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES));
} forEach (GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES);
// Unknown items
{
if !(_x in _items) then {
["CfgWeapons", _x, !(_x in GVAR(virtualItemsFlat)), true] call _fnc_fillRightContainer;
// _y indicates if an item is truly unique or if it's a non-inventory item in a container (e.g. helmet in backpack)
["CfgWeapons", _x, _y, true] call _fnc_fillRightContainer;
};
} forEach (keys (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS)); // if an item is here but in virtual items, it's just in the wrong place
} forEach (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS); // if an item is here but in virtual items, it's just in the wrong place
};
// Custom buttons
default {
@ -343,11 +345,11 @@ switch (_ctrlIDC) do {
};
// Unique goggles
case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES)): {
["CfgGlasses", _x, true] call _fnc_fillRightContainer;
["CfgGlasses", _x, GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES get _x] call _fnc_fillRightContainer;
};
// Unknown items
case (_x in (GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS)): {
["CfgWeapons", _x, !(_x in GVAR(virtualItemsFlat)), true] call _fnc_fillRightContainer;
["CfgWeapons", _x, GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS get _x, true] call _fnc_fillRightContainer;
};
};
} forEach _items;

View File

@ -137,6 +137,9 @@ private _simulationType = "";
private _configItemInfo = "";
private _hasItemInfo = false;
private _itemInfoType = 0;
private _baseWeapon = "";
private _weapons = GVAR(virtualItems) get IDX_VIRT_WEAPONS;
private _attachments = GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS;
{
_isMagazine = isClass (_cfgMagazines >> _x);
@ -191,7 +194,7 @@ private _itemInfoType = 0;
{!(_x in (GVAR(virtualItems) get IDX_VIRT_EXPLOSIVES))} &&
{!(_x in (GVAR(virtualItems) get IDX_VIRT_ITEMS_ALL))}
) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, true];
};
};
};
@ -205,11 +208,17 @@ private _itemInfoType = 0;
_itemInfoType = if (_hasItemInfo) then {getNumber (_configItemInfo >> "type")} else {0};
_isMiscItem = _x isKindOf ["CBA_MiscItem", _cfgWeapons];
_baseWeapon = if (!_isMiscItem) then {
_x call FUNC(baseWeapon)
} else {
_x
};
switch (true) do {
// Optics
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS) ||
!(_baseWeapon in (_attachments get IDX_VIRT_OPTICS_ATTACHMENTS)) &&
{_baseWeapon in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_OPTICS_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_OPTICS}}}
@ -218,8 +227,8 @@ private _itemInfoType = 0;
};
// Flashlights
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS) ||
!(_baseWeapon in (_attachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS)) &&
{_baseWeapon in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_FLASHLIGHT_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_FLASHLIGHT}}}
@ -228,8 +237,8 @@ private _itemInfoType = 0;
};
// Muzzle attachments
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS) ||
!(_baseWeapon in (_attachments get IDX_VIRT_MUZZLE_ATTACHMENTS)) &&
{_baseWeapon in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_MUZZLE_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_MUZZLE}}}
@ -238,8 +247,8 @@ private _itemInfoType = 0;
};
// Bipods
case (
!(_x in ((GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS)) &&
{_x in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS) ||
!(_baseWeapon in (_attachments get IDX_VIRT_BIPOD_ATTACHMENTS)) &&
{_baseWeapon in ((_configItems get IDX_VIRT_ATTACHMENTS) get IDX_VIRT_BIPOD_ATTACHMENTS) ||
{_hasItemInfo &&
{!_isMiscItem} &&
{_itemInfoType == TYPE_BIPOD}}}
@ -248,7 +257,7 @@ private _itemInfoType = 0;
};
// Misc. items
case (
!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)) &&
!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS)) && // misc. items don't use 'baseWeapon'
{_x in (_configItems get IDX_VIRT_MISC_ITEMS) ||
{_hasItemInfo &&
{_isMiscItem &&
@ -260,16 +269,21 @@ private _itemInfoType = 0;
};
// Unknown
default {
// Don't add items that are part of the arsenal
private _attachments = GVAR(virtualItems) get IDX_VIRT_ATTACHMENTS;
// Don't add attachments or misc. items
if (
!(_x in (_attachments get IDX_VIRT_OPTICS_ATTACHMENTS)) &&
{!(_x in (_attachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS))} &&
{!(_x in (_attachments get IDX_VIRT_MUZZLE_ATTACHMENTS))} &&
{!(_x in (_attachments get IDX_VIRT_BIPOD_ATTACHMENTS))} &&
!(_baseWeapon in (_attachments get IDX_VIRT_OPTICS_ATTACHMENTS)) &&
{!(_baseWeapon in (_attachments get IDX_VIRT_FLASHLIGHT_ATTACHMENTS))} &&
{!(_baseWeapon in (_attachments get IDX_VIRT_MUZZLE_ATTACHMENTS))} &&
{!(_baseWeapon in (_attachments get IDX_VIRT_BIPOD_ATTACHMENTS))} &&
{!(_x in (GVAR(virtualItems) get IDX_VIRT_MISC_ITEMS))}
) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
// If item is a weapon (including binos), make it unique
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x,
_baseWeapon in (_weapons get IDX_VIRT_PRIMARY_WEAPONS) ||
{_baseWeapon in (_weapons get IDX_VIRT_HANDGUN_WEAPONS)} ||
{_baseWeapon in (_weapons get IDX_VIRT_SECONDARY_WEAPONS)} ||
{_baseWeapon in (GVAR(virtualItems) get IDX_VIRT_BINO)}
];
};
};
};
@ -280,13 +294,13 @@ private _itemInfoType = 0;
};
// Facewear
case (isClass (_cfgGlasses >> _x)): {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES) set [_x, nil];
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_GOGGLES) set [_x, !(_x in (GVAR(virtualItems) get IDX_VIRT_GOGGLES))];
};
// Unknown
default {
// Don't add items that are part of the arsenal
if !(_x in GVAR(virtualItemsFlatAll)) then {
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, nil];
(GVAR(virtualItems) get IDX_VIRT_UNIQUE_UNKNOWN_ITEMS) set [_x, true];
};
};
};