From 005b2aef140e5ef85dbc45211d02f15c000a2fb9 Mon Sep 17 00:00:00 2001 From: GhostIsSpooky <69561145+Salluci@users.noreply.github.com> Date: Tue, 12 Oct 2021 19:10:18 -0300 Subject: [PATCH] Arsenal - Stop deleting unique belt items (#8483) * prevent belt items from being deleted * fix wrong index * fix gps not being selected * & fix UAV terminals not being selected * add comments, delete extra line * use getUnitLoadout for assignedItems --- addons/arsenal/defines.hpp | 7 ++++ .../arsenal/functions/fnc_onArsenalOpen.sqf | 37 ++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index 5e1bda07d1..70292c3e7c 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -176,6 +176,13 @@ #define IDX_VIRT_VEST 5 #define IDX_VIRT_BACKPACK 6 #define IDX_VIRT_GOGGLES 7 +#define IDX_VIRT_NVG 8 +#define IDX_VIRT_BINO 9 +#define IDX_VIRT_MAP 10 +#define IDX_VIRT_COMPASS 11 +#define IDX_VIRT_RADIO 12 +#define IDX_VIRT_WATCH 13 +#define IDX_VIRT_COMMS 14 #define SYMBOL_ITEM_NONE "−" #define SYMBOL_ITEM_REMOVE "×" diff --git a/addons/arsenal/functions/fnc_onArsenalOpen.sqf b/addons/arsenal/functions/fnc_onArsenalOpen.sqf index 7c1f30baa5..34243a49f6 100644 --- a/addons/arsenal/functions/fnc_onArsenalOpen.sqf +++ b/addons/arsenal/functions/fnc_onArsenalOpen.sqf @@ -60,8 +60,11 @@ GVAR(statsPagesLeft) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; GVAR(statsPagesRight) = [0, 0, 0, 0, 0, 0, 0, 0]; GVAR(statsInfo) = [true, 0, controlNull, nil, nil]; +// Cache assignedItems +private _assignedItems = (getUnitLoadout GVAR(center)) select 9; + // Add the items the player has to virtualItems -for "_index" from 0 to 10 do { +for "_index" from 0 to 14 do { switch (_index) do { // primary, secondary, handgun weapons case IDX_VIRT_WEAPONS: { @@ -109,6 +112,14 @@ for "_index" from 0 to 10 do { } forEach _magsArray; }; + // Assigned items + case IDX_VIRT_MAP: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 0) }; + case IDX_VIRT_COMMS: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 1) }; + case IDX_VIRT_RADIO: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 2) }; + case IDX_VIRT_COMPASS: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 3) }; + case IDX_VIRT_WATCH: { (GVAR(virtualItems) select _index) pushBackUnique (_assignedItems select 4) }; + + // Inventory items case IDX_VIRT_ITEMS_ALL: { call FUNC(updateUniqueItemsList); @@ -164,18 +175,24 @@ for "_index" from 0 to 15 do { }; { - private _simulationType = getText (configFile >> "CfgWeapons" >> _x >> "simulation"); - - if (_simulationType != "NVGoggles") then { - if (_simulationType == "ItemGps" || _simulationType == "Weapon") then { + switch (_forEachIndex) do { + case 0: { // Map + GVAR(currentItems) set [10, _x]; + }; + case 1: { // GPS GVAR(currentItems) set [14, _x]; - } else { - - private _index = 10 + (["itemmap", "itemcompass", "itemradio", "itemwatch"] find (tolower _simulationType)); - GVAR(currentItems) set [_index, _x]; + }; + case 2: { // Radio + GVAR(currentItems) set [12, _x]; + }; + case 3: { // Compass + GVAR(currentItems) set [11, _x]; + }; + case 4: { // Watch + GVAR(currentItems) set [13, _x]; }; }; -} forEach (assignedItems GVAR(center)); +} forEach _assignedItems; GVAR(currentWeaponType) = switch true do { case (currentWeapon GVAR(center) == GVAR(currentItems) select 0): {0};