Mercurial > wow > askmrrobot
comparison AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 195:4ccc9ff6e824 v95
Update item parsing for new item link format changes.
author | Yellowfive |
---|---|
date | Tue, 24 Nov 2020 16:20:10 -0600 |
parents | cb7eb9b9cc24 |
children | 23b740b4c93a |
comparison
equal
deleted
inserted
replaced
194:02bbbf5ef3db | 195:4ccc9ff6e824 |
---|---|
1 -- AskMrRobot-Serializer will serialize and communicate character data between users. | 1 -- AskMrRobot-Serializer will serialize and communicate character data between users. |
2 | 2 |
3 local MAJOR, MINOR = "AskMrRobot-Serializer", 94 | 3 local MAJOR, MINOR = "AskMrRobot-Serializer", 95 |
4 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) | 4 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
5 | 5 |
6 if not Amr then return end -- already loaded by something else | 6 if not Amr then return end -- already loaded by something else |
7 | 7 |
8 -- event and comm used for player snapshotting on entering combat | 8 -- event and comm used for player snapshotting on entering combat |
154 ["Alliance"] = 1, | 154 ["Alliance"] = 1, |
155 ["Horde"] = 2 | 155 ["Horde"] = 2 |
156 } | 156 } |
157 | 157 |
158 Amr.InstanceIds = { | 158 Amr.InstanceIds = { |
159 Uldir = 1861, | |
160 Dazar = 2070, | |
161 Storms = 2096, | |
162 Palace = 2164, | |
163 Nyalotha = 2217, | |
164 Nathria = 2296 | 159 Nathria = 2296 |
165 } | 160 } |
166 | 161 |
167 -- instances that AskMrRobot currently supports logging for | 162 -- instances that AskMrRobot currently supports logging for |
168 Amr.SupportedInstanceIds = { | 163 Amr.SupportedInstanceIds = { |
169 [1861] = true, | |
170 [2070] = true, | |
171 [2096] = true, | |
172 [2164] = true, | |
173 [2217] = true, | |
174 [2296] = true | 164 [2296] = true |
175 } | 165 } |
176 | 166 |
177 | 167 |
178 ---------------------------------------------------------------------------------------- | 168 ---------------------------------------------------------------------------------------- |
186 end | 176 end |
187 table.sort(ret) | 177 table.sort(ret) |
188 return ret | 178 return ret |
189 end | 179 end |
190 | 180 |
191 -- 1 2 3 4 5 6 7 8 9 10 11 12 | 181 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
192 -- itemId:ench:gem1 :gem2 :gem3 :gem4:suf:uid:lvl:spec:flags :instdiffid:numbonusIDs:bonusIDs1...n :varies:?:relic bonus ids | 182 -- itemId:ench:gem1 :gem2 :gem3 :gem4:suf:uid:lvl:spec:flags :instdiffid:numbonusIDs:bonusIDs1...n :varies:? :relic bonus ids |
193 --|cffe6cc80|Hitem:128866: :152046:147100:152025: : : :110:66 :16777472:9 :4 :736:1494:1490:1495:709 :1:3:3610:1472:3528:3:3562:1483:3528:3:3610:1477:3336|h[Truthguard]|h|r | 183 --|cffe6cc80|Hitem:128866: :152046:147100:152025: : : :110:66 :16777472:9 :4 :736:1494:1490:1495:709 :1 :3:3610:1472:3528:3:3562:1483:3528:3:3610:1477:3336|h[Truthguard]|h|r |
194 -- | 184 --|cff1eff00|Hitem:175722: : : : : : : :57 :102 : :11 :1 :6707 :2 :28:1340:9 :54:::|h[name]|h|r |
195 -- get an object with all of the parts of the item link format that we care about | 185 -- get an object with all of the parts of the item link format that we care about |
196 function Amr.ParseItemLink(itemLink) | 186 function Amr.ParseItemLink(itemLink) |
197 if not itemLink then return nil end | 187 if not itemLink then return nil end |
198 | 188 |
199 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|") | 189 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|") |
220 item.bonusIds = readBonusIdList(parts, 14, 13 + numBonuses) | 210 item.bonusIds = readBonusIdList(parts, 14, 13 + numBonuses) |
221 end | 211 end |
222 | 212 |
223 item.upgradeId = 0 | 213 item.upgradeId = 0 |
224 item.level = 0 | 214 item.level = 0 |
225 | 215 item.stat1 = 0 |
226 -- part 14 + numBonuses, unsure what this is... sometimes it is "2" | 216 item.stat2 = 0 |
227 -- part 15 + numBonuses, unsure what this is... may indicate what part 16 will mean? | 217 |
228 -- part 16 + numBonuses, is player level at drop when applicable | 218 -- part 14 + numBonuses, seems to be the number of prop-value "pairs" that will follow, |
229 -- part 17 + numBonuses, unsure what this is... | 219 -- for now we just parse the properties that we care about |
230 -- part 18 + numBonuses, unsure what this is... | 220 local numProps = tonumber(parts[14 + offset]) or 0 |
231 -- part 19 + numBonuses, relic info would be here for legion artifacts | 221 if numProps > 0 then |
232 | 222 for i = 15 + offset, 14 + offset + numProps * 2, 2 do |
233 local someNumber = tonumber(parts[15 + offset]) or 0 | 223 local prop = tonumber(parts[i]) or 0 |
234 if someNumber ~= 0 then | 224 local propVal = tonumber(parts[i + 1]) or 0 |
235 local lvl = tonumber(parts[16 + offset]) or 0 | 225 if prop == 9 then |
236 if lvl <= 60 then | 226 item.level = propVal |
237 item.level = lvl | 227 elseif prop == 29 then |
228 item.stat1 = propVal | |
229 elseif prop == 30 then | |
230 item.stat2 = propVal | |
231 end | |
238 end | 232 end |
239 end | 233 end |
240 | 234 |
241 -- we don't need relic information anymore | 235 -- we don't need relic information anymore |
242 --[[elseif #parts > 19 + offset then | 236 --[[elseif #parts > 19 + offset then |
289 ret = ret .. "s" .. item.suffixId | 283 ret = ret .. "s" .. item.suffixId |
290 end | 284 end |
291 if not noUpgrade and item.upgradeId ~= 0 then | 285 if not noUpgrade and item.upgradeId ~= 0 then |
292 ret = ret .. "u" .. item.upgradeId | 286 ret = ret .. "u" .. item.upgradeId |
293 end | 287 end |
294 if item.level ~= 0 then | 288 if item.level and item.level ~= 0 then |
295 ret = ret .. "v" .. item.level | 289 ret = ret .. "v" .. item.level |
290 end | |
291 if item.stat1 and item.stat1 ~= 0 then | |
292 ret = ret .. "j" .. item.stat1 | |
293 end | |
294 if item.stat2 and item.stat2 ~= 0 then | |
295 ret = ret .. "k" .. item.stat2 | |
296 end | 296 end |
297 return ret | 297 return ret |
298 end | 298 end |
299 | 299 |
300 -- returns true if this is an instance that AskMrRobot supports for logging | 300 -- returns true if this is an instance that AskMrRobot supports for logging |
593 --if itemData.suffixId ~= 0 then table.insert(itemParts, "f" .. itemData.suffixId) end | 593 --if itemData.suffixId ~= 0 then table.insert(itemParts, "f" .. itemData.suffixId) end |
594 if itemData.upgradeId ~= 0 then | 594 if itemData.upgradeId ~= 0 then |
595 table.insert(itemParts, "u" .. (itemData.upgradeId - prevUpgradeId)) | 595 table.insert(itemParts, "u" .. (itemData.upgradeId - prevUpgradeId)) |
596 prevUpgradeId = itemData.upgradeId | 596 prevUpgradeId = itemData.upgradeId |
597 end | 597 end |
598 if itemData.level ~= 0 then | 598 if itemData.level and itemData.level ~= 0 then |
599 table.insert(itemParts, "v" .. (itemData.level - prevLevel)) | 599 table.insert(itemParts, "v" .. (itemData.level - prevLevel)) |
600 prevLevel = itemData.level | 600 prevLevel = itemData.level |
601 end | 601 end |
602 if itemData.bonusIds then | 602 if itemData.bonusIds then |
603 for bIndex, bValue in ipairs(itemData.bonusIds) do | 603 for bIndex, bValue in ipairs(itemData.bonusIds) do |
604 table.insert(itemParts, "b" .. (bValue - prevBonusId)) | 604 table.insert(itemParts, "b" .. (bValue - prevBonusId)) |
605 prevBonusId = bValue | 605 prevBonusId = bValue |
606 end | 606 end |
607 end | 607 end |
608 | 608 |
609 if itemData.stat1 and itemData.stat1 ~= 0 then | |
610 table.insert(itemParts, "j" .. itemData.stat1) | |
611 end | |
612 if itemData.stat2 and itemData.stat2 ~= 0 then | |
613 table.insert(itemParts, "k" .. itemData.stat2) | |
614 end | |
615 | |
609 --[[ | 616 --[[ |
610 if itemData.azerite then | 617 if itemData.azerite then |
611 for aIndex, aValue in ipairs(itemData.azerite) do | 618 for aIndex, aValue in ipairs(itemData.azerite) do |
612 table.insert(itemParts, "a" .. (aValue - prevAzeriteId)) | 619 table.insert(itemParts, "a" .. (aValue - prevAzeriteId)) |
613 prevAzeriteId = aValue | 620 prevAzeriteId = aValue |
650 if itemData.relicBonusIds and itemData.relicBonusIds[3] ~= nil then | 657 if itemData.relicBonusIds and itemData.relicBonusIds[3] ~= nil then |
651 for bIndex, bValue in ipairs(itemData.relicBonusIds[3]) do | 658 for bIndex, bValue in ipairs(itemData.relicBonusIds[3]) do |
652 table.insert(itemParts, "r" .. (bValue - prevRelicBonusId)) | 659 table.insert(itemParts, "r" .. (bValue - prevRelicBonusId)) |
653 prevRelicBonusId = bValue | 660 prevRelicBonusId = bValue |
654 end | 661 end |
655 end | 662 end |
656 | 663 |
657 if itemData.guid then | 664 if itemData.guid then |
658 table.insert(itemParts, "!" .. itemData.guid) | 665 table.insert(itemParts, "!" .. itemData.guid) |
659 end | 666 end |
660 | 667 |