comparison Gear.lua @ 200:6e8838b231d4 v97

Fixed issue with distinguishing different variants of the same item.
author Yellowfive
date Wed, 13 Jan 2021 13:11:54 -0600
parents 4ccc9ff6e824
children
comparison
equal deleted inserted replaced
199:e34c256739be 200:6e8838b231d4
30 -- one nil and other not, or different id, totally different 30 -- one nil and other not, or different id, totally different
31 if (not item1 and item2) or (item1 and not item2) or item1.id ~= item2.id then 31 if (not item1 and item2) or (item1 and not item2) or item1.id ~= item2.id then
32 return 1000000 32 return 1000000
33 end 33 end
34 34
35 -- different versions of same item (id + bonus ids + suffix + drop level, constitutes a different physical drop) 35 --if item1.guid and item2.guid and item1.guid == item2.guid then
36 if Amr.GetItemUniqueId(item1, true, true) ~= Amr.GetItemUniqueId(item2, true, true) then 36 -- -- these have the same guid, so even if bonus id or something doesn't match for some reason, they are identical items
37 return 100000 37 --else
38 end 38 -- different versions of same item (id + bonus ids + suffix + drop level, constitutes a different physical drop)
39 39 if Amr.GetItemUniqueId(item1, true, true) ~= Amr.GetItemUniqueId(item2, true, true) then
40 -- different upgrade levels of the same item 40 return 100000
41 if item1.upgradeId ~= item2.upgradeId then 41 end
42 return 10000 42
43 end 43 -- different upgrade levels of the same item
44 44 if item1.upgradeId ~= item2.upgradeId then
45 return 10000
46 end
47 --end
48
45 -- a change that requires reforging is considered more different than a change that does not; 49 -- a change that requires reforging is considered more different than a change that does not;
46 -- it is assumed that item1 is how we want the item to be in the end, and item2 is how it currently is 50 -- it is assumed that item1 is how we want the item to be in the end, and item2 is how it currently is
47 local aztReforges = 0 51 local aztReforges = 0
48 local aztSelects = 0 52 local aztSelects = 0
49 53
116 120
117 local found = false 121 local found = false
118 for k,listItem in pairs(list) do 122 for k,listItem in pairs(list) do
119 if listItem then 123 if listItem then
120 local diff = countItemDifferences(item, listItem) 124 local diff = countItemDifferences(item, listItem)
125
121 if diff < bestDiff then 126 if diff < bestDiff then
122 -- each physical item can only be used once, the usedItems table has items we can't use in this search 127 -- each physical item can only be used once, the usedItems table has items we can't use in this search
123 local key = string.format("%s_%s", tableType, k) 128 local key = string.format("%s_%s", tableType, k)
124 if not usedItems[key] then 129 if not usedItems[key] then
125 bestItem = listItem 130 bestItem = listItem
126 bestDiff = diff 131 bestDiff = diff
127 bestLoc = key 132 bestLoc = key
128 found = true 133 end
129 end 134 end
130 end 135
131 if found then break end 136 if bestDiff == 0 then break end
132 end 137 end
133 end 138 end
134 139
135 return bestItem, bestDiff, bestLoc 140 return bestItem, bestDiff, bestLoc
136 end 141 end
1153 1158
1154 new = bestItem 1159 new = bestItem
1155 local diff = countItemDifferences(new, old) 1160 local diff = countItemDifferences(new, old)
1156 1161
1157 if diff > 0 then 1162 if diff > 0 then
1163
1158 list[slotId] = new 1164 list[slotId] = new
1159 if list == itemsToEquip.mh or list == itemsToEquip.oh then 1165 if list == itemsToEquip.mh or list == itemsToEquip.oh then
1160 itemsToEquip.weapons[slotId] = {} 1166 itemsToEquip.weapons[slotId] = {}
1161 end 1167 end
1162 remaining = remaining + 1 1168 remaining = remaining + 1