Mercurial > wow > askmrrobot
comparison AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 185:a7f2ba17c39a v90
Shadowlands pre-patch update.
| author | yellowfive |
|---|---|
| date | Tue, 13 Oct 2020 10:49:07 -0700 |
| parents | c6369f8f277c |
| children | 180cb1458674 |
comparison
equal
deleted
inserted
replaced
| 184:f374d84470db | 185:a7f2ba17c39a |
|---|---|
| 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", 86 | 3 local MAJOR, MINOR = "AskMrRobot-Serializer", 90 |
| 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, | 159 Nathria = 2296 |
| 160 Dazar = 2070, | |
| 161 Storms = 2096, | |
| 162 Palace = 2164, | |
| 163 Nyalotha = 2217 | |
| 164 } | 160 } |
| 165 | 161 |
| 166 -- instances that AskMrRobot currently supports logging for | 162 -- instances that AskMrRobot currently supports logging for |
| 167 Amr.SupportedInstanceIds = { | 163 Amr.SupportedInstanceIds = { |
| 168 [1861] = true, | 164 [2296] = true |
| 169 [2070] = true, | |
| 170 [2096] = true, | |
| 171 [2164] = true, | |
| 172 [2217] = true | |
| 173 } | 165 } |
| 174 | 166 |
| 175 | 167 |
| 176 ---------------------------------------------------------------------------------------- | 168 ---------------------------------------------------------------------------------------- |
| 177 -- Public Utility Methods | 169 -- Public Utility Methods |
| 206 item.gemIds = { tonumber(parts[3]) or 0, tonumber(parts[4]) or 0, tonumber(parts[5]) or 0, tonumber(parts[6]) or 0 } | 198 item.gemIds = { tonumber(parts[3]) or 0, tonumber(parts[4]) or 0, tonumber(parts[5]) or 0, tonumber(parts[6]) or 0 } |
| 207 item.suffixId = math.abs(tonumber(parts[7]) or 0) -- convert suffix to positive number, that's what we use in our code | 199 item.suffixId = math.abs(tonumber(parts[7]) or 0) -- convert suffix to positive number, that's what we use in our code |
| 208 -- part 8 is some unique ID... we never really used it | 200 -- part 8 is some unique ID... we never really used it |
| 209 -- part 9 is current player level | 201 -- part 9 is current player level |
| 210 -- part 10 is player spec | 202 -- part 10 is player spec |
| 211 local upgradeIdType = tonumber(parts[11]) or 0 -- part 11 indicates what kind of upgrade ID is just after the bonus IDs | 203 -- unsure what 11 is now --local upgradeIdType = tonumber(parts[11]) or 0 -- part 11 indicates what kind of upgrade ID is just after the bonus IDs |
| 212 -- part 12 is instance difficulty id | 204 -- part 12 is instance difficulty id |
| 213 | 205 |
| 206 -- 13 is num bonus IDs, followed by bonus IDs | |
| 214 local numBonuses = tonumber(parts[13]) or 0 | 207 local numBonuses = tonumber(parts[13]) or 0 |
| 215 local offset = numBonuses | 208 local offset = numBonuses |
| 216 if numBonuses > 0 then | 209 if numBonuses > 0 then |
| 217 item.bonusIds = readBonusIdList(parts, 14, 13 + numBonuses) | 210 item.bonusIds = readBonusIdList(parts, 14, 13 + numBonuses) |
| 218 end | 211 end |
| 219 | 212 |
| 220 item.upgradeId = 0 | 213 item.upgradeId = 0 |
| 221 item.level = 0 | 214 item.level = 0 |
| 222 | 215 |
| 223 -- the next part after bonus IDs depends on the upgrade id type | 216 -- part 14 + numBonuses, unsure what this is... sometimes it is "2" |
| 224 if upgradeIdType == 4 then | 217 -- part 15 + numBonuses, unsure what this is... may indicate what part 16 will mean? |
| 225 item.upgradeId = tonumber(parts[14 + offset]) or 0 | 218 -- part 16 + numBonuses, is player level at drop when applicable |
| 226 elseif upgradeIdType == 512 then | 219 -- part 17 + numBonuses, unsure what this is... |
| 227 item.level = tonumber(parts[14 + offset]) or 0 | 220 -- part 18 + numBonuses, unsure what this is... |
| 228 elseif #parts > 16 + offset then | 221 -- part 19 + numBonuses, relic info would be here for legion artifacts |
| 222 | |
| 223 local someNumber = tonumber(parts[15 + offset]) or 0 | |
| 224 if someNumber ~= 0 then | |
| 225 local lvl = tonumber(parts[16 + offset]) or 0 | |
| 226 if lvl <= 60 then | |
| 227 item.level = lvl | |
| 228 end | |
| 229 end | |
| 230 | |
| 231 -- we don't need relic information anymore | |
| 232 --[[elseif #parts > 19 + offset then | |
| 229 -- check for relic info | 233 -- check for relic info |
| 230 item.relicBonusIds = { nil, nil, nil } | 234 item.relicBonusIds = { nil, nil, nil } |
| 231 numBonuses = tonumber(parts[16 + offset]) | 235 numBonuses = tonumber(parts[16 + offset]) |
| 232 if numBonuses then | 236 if numBonuses then |
| 233 if numBonuses > 0 then | 237 if numBonuses > 0 then |
| 252 end | 256 end |
| 253 end | 257 end |
| 254 end | 258 end |
| 255 end | 259 end |
| 256 end | 260 end |
| 257 end | 261 end]] |
| 258 | 262 |
| 259 return item | 263 return item |
| 260 end | 264 end |
| 261 | 265 |
| 262 local AZERITE_EMPOWERED_BONUS_ID = 4775 | 266 local AZERITE_EMPOWERED_BONUS_ID = 4775 |
| 385 else | 389 else |
| 386 return tostring(o) | 390 return tostring(o) |
| 387 end | 391 end |
| 388 end | 392 end |
| 389 | 393 |
| 394 --[[ | |
| 390 -- read azerite powers on the item in loc and put it on itemData | 395 -- read azerite powers on the item in loc and put it on itemData |
| 391 function Amr.ReadAzeritePowers(loc) | 396 function Amr.ReadAzeritePowers(loc) |
| 392 local ret = {} | 397 local ret = {} |
| 393 local hasSome = false | 398 local hasSome = false |
| 394 | 399 |
| 407 return ret | 412 return ret |
| 408 else | 413 else |
| 409 return nil | 414 return nil |
| 410 end | 415 end |
| 411 end | 416 end |
| 417 ]] | |
| 412 | 418 |
| 413 -- get currently equipped items, store with currently active spec | 419 -- get currently equipped items, store with currently active spec |
| 414 local function readEquippedItems(ret) | 420 local function readEquippedItems(ret) |
| 415 local equippedItems = {}; | 421 local equippedItems = {}; |
| 416 local loc = ItemLocation.CreateEmpty() | 422 local loc = ItemLocation.CreateEmpty() |
| 418 local slotId = Amr.SlotIds[slotNum] | 424 local slotId = Amr.SlotIds[slotNum] |
| 419 local itemLink = GetInventoryItemLink("player", slotId) | 425 local itemLink = GetInventoryItemLink("player", slotId) |
| 420 if itemLink then | 426 if itemLink then |
| 421 local itemData = Amr.ParseItemLink(itemLink) | 427 local itemData = Amr.ParseItemLink(itemLink) |
| 422 if itemData then | 428 if itemData then |
| 429 --[[ | |
| 423 -- see if this is an azerite item and read azerite power ids | 430 -- see if this is an azerite item and read azerite power ids |
| 424 loc:SetEquipmentSlot(slotId) | 431 loc:SetEquipmentSlot(slotId) |
| 425 if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(loc) then | 432 if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(loc) then |
| 426 local powers = Amr.ReadAzeritePowers(loc) | 433 local powers = Amr.ReadAzeritePowers(loc) |
| 427 if powers then | 434 if powers then |
| 428 itemData.azerite = powers | 435 itemData.azerite = powers |
| 429 end | 436 end |
| 430 end | 437 end |
| 438 ]] | |
| 431 | 439 |
| 432 equippedItems[slotId] = itemData | 440 equippedItems[slotId] = itemData |
| 433 end | 441 end |
| 434 end | 442 end |
| 435 end | 443 end |
| 436 | 444 |
| 437 -- store last-seen equipped gear for each spec | 445 -- store last-seen equipped gear for each spec |
| 438 ret.Equipped[GetSpecialization()] = equippedItems | 446 ret.Equipped[GetSpecialization()] = equippedItems |
| 439 end | 447 end |
| 440 | 448 |
| 449 --[[ | |
| 441 local function readHeartOfAzerothLevel(ret) | 450 local function readHeartOfAzerothLevel(ret) |
| 442 local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem(); | 451 local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem(); |
| 443 if azeriteItemLocation then | 452 if azeriteItemLocation then |
| 444 local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation); | 453 local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation); |
| 445 ret.HeartOfAzerothLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation) | 454 ret.HeartOfAzerothLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation) |
| 446 else | 455 else |
| 447 ret.HeartOfAzerothLevel = 0 | 456 ret.HeartOfAzerothLevel = 0 |
| 448 end | 457 end |
| 449 end | 458 end |
| 459 ]] | |
| 450 | 460 |
| 451 -- Get just the player's currently equipped gear | 461 -- Get just the player's currently equipped gear |
| 452 function Amr:GetEquipped() | 462 function Amr:GetEquipped() |
| 453 local ret= {} | 463 local ret= {} |
| 454 ret.Equipped = {} | 464 ret.Equipped = {} |
| 475 ret.Realm = GetRealmName() | 485 ret.Realm = GetRealmName() |
| 476 ret.Name = UnitName("player") | 486 ret.Name = UnitName("player") |
| 477 ret.Guild = GetGuildInfo("player") | 487 ret.Guild = GetGuildInfo("player") |
| 478 ret.ActiveSpec = GetSpecialization() | 488 ret.ActiveSpec = GetSpecialization() |
| 479 ret.Level = UnitLevel("player"); | 489 ret.Level = UnitLevel("player"); |
| 480 readHeartOfAzerothLevel(ret) | 490 --readHeartOfAzerothLevel(ret) |
| 481 | 491 |
| 482 local _, clsEn = UnitClass("player") | 492 local _, clsEn = UnitClass("player") |
| 483 ret.Class = clsEn; | 493 ret.Class = clsEn; |
| 484 | 494 |
| 485 local _, raceEn = UnitRace("player") | 495 local _, raceEn = UnitRace("player") |
| 498 ret.Specs = {} | 508 ret.Specs = {} |
| 499 ret.Talents = {} | 509 ret.Talents = {} |
| 500 readSpecs(ret) | 510 readSpecs(ret) |
| 501 | 511 |
| 502 -- these get updated later, since need to cache info for inactive specs | 512 -- these get updated later, since need to cache info for inactive specs |
| 503 ret.UnlockedEssences = {} | 513 --ret.UnlockedEssences = {} |
| 504 ret.Essences = {} | 514 --ret.Essences = {} |
| 505 | 515 |
| 506 ret.Equipped = {} | 516 ret.Equipped = {} |
| 507 readEquippedItems(ret) | 517 readEquippedItems(ret) |
| 508 | 518 |
| 509 return ret | 519 return ret |
| 549 local prevGemId = 0 | 559 local prevGemId = 0 |
| 550 local prevEnchantId = 0 | 560 local prevEnchantId = 0 |
| 551 local prevUpgradeId = 0 | 561 local prevUpgradeId = 0 |
| 552 local prevBonusId = 0 | 562 local prevBonusId = 0 |
| 553 local prevLevel = 0 | 563 local prevLevel = 0 |
| 554 local prevAzeriteId = 0 | 564 --local prevAzeriteId = 0 |
| 555 local prevRelicBonusId = 0 | 565 local prevRelicBonusId = 0 |
| 556 for i, itemData in ipairs(itemObjects) do | 566 for i, itemData in ipairs(itemObjects) do |
| 557 local itemParts = {} | 567 local itemParts = {} |
| 558 | 568 |
| 559 table.insert(itemParts, itemData.id - prevItemId) | 569 table.insert(itemParts, itemData.id - prevItemId) |
| 574 table.insert(itemParts, "b" .. (bValue - prevBonusId)) | 584 table.insert(itemParts, "b" .. (bValue - prevBonusId)) |
| 575 prevBonusId = bValue | 585 prevBonusId = bValue |
| 576 end | 586 end |
| 577 end | 587 end |
| 578 | 588 |
| 589 --[[ | |
| 579 if itemData.azerite then | 590 if itemData.azerite then |
| 580 for aIndex, aValue in ipairs(itemData.azerite) do | 591 for aIndex, aValue in ipairs(itemData.azerite) do |
| 581 table.insert(itemParts, "a" .. (aValue - prevAzeriteId)) | 592 table.insert(itemParts, "a" .. (aValue - prevAzeriteId)) |
| 582 prevAzeriteId = aValue | 593 prevAzeriteId = aValue |
| 583 end | 594 end |
| 584 end | 595 end |
| 585 | 596 ]] |
| 597 | |
| 586 if itemData.gemIds[1] ~= 0 then | 598 if itemData.gemIds[1] ~= 0 then |
| 587 table.insert(itemParts, "x" .. (itemData.gemIds[1] - prevGemId)) | 599 table.insert(itemParts, "x" .. (itemData.gemIds[1] - prevGemId)) |
| 588 prevGemId = itemData.gemIds[1] | 600 prevGemId = itemData.gemIds[1] |
| 589 end | 601 end |
| 590 if itemData.gemIds[2] ~= 0 then | 602 if itemData.gemIds[2] ~= 0 then |
| 669 raceval = Amr.FactionIds[data.Faction] | 681 raceval = Amr.FactionIds[data.Faction] |
| 670 if raceval == nil then raceval = 1 end | 682 if raceval == nil then raceval = 1 end |
| 671 table.insert(fields, raceval) | 683 table.insert(fields, raceval) |
| 672 | 684 |
| 673 table.insert(fields, data.Level) | 685 table.insert(fields, data.Level) |
| 674 table.insert(fields, data.HeartOfAzerothLevel) | 686 |
| 675 | |
| 676 local profs = {} | 687 local profs = {} |
| 677 local noprofs = true | 688 local noprofs = true |
| 678 if data.Professions then | 689 if data.Professions then |
| 679 for k, v in pairs(data.Professions) do | 690 for k, v in pairs(data.Professions) do |
| 680 local profval = Amr.ProfessionIds[k] | 691 local profval = Amr.ProfessionIds[k] |
| 696 for spec = 1, 4 do | 707 for spec = 1, 4 do |
| 697 if data.Specs[spec] and (complete or spec == data.ActiveSpec) then | 708 if data.Specs[spec] and (complete or spec == data.ActiveSpec) then |
| 698 table.insert(fields, ".s" .. spec) -- indicates the start of a spec block | 709 table.insert(fields, ".s" .. spec) -- indicates the start of a spec block |
| 699 table.insert(fields, data.Specs[spec]) | 710 table.insert(fields, data.Specs[spec]) |
| 700 table.insert(fields, data.Talents[spec] or "") | 711 table.insert(fields, data.Talents[spec] or "") |
| 701 | 712 table.insert(fields, data.ActiveSoulbinds and data.ActiveSoulbinds[spec] or "0") |
| 713 | |
| 714 --[[ | |
| 702 local essences = {} | 715 local essences = {} |
| 703 if data.Essences and data.Essences[spec] then | 716 if data.Essences and data.Essences[spec] then |
| 704 for i, ess in ipairs(data.Essences[spec]) do | 717 for i, ess in ipairs(data.Essences[spec]) do |
| 705 table.insert(essences, table.concat(ess, ".")) | 718 table.insert(essences, table.concat(ess, ".")) |
| 706 end | 719 end |
| 707 end | 720 end |
| 708 table.insert(fields, table.concat(essences, "_")) | 721 table.insert(fields, table.concat(essences, "_")) |
| 722 ]] | |
| 709 end | 723 end |
| 710 end | 724 end |
| 711 | 725 |
| 712 -- export equipped gear | 726 -- export equipped gear |
| 713 if data.Equipped then | 727 if data.Equipped then |
| 724 appendItemsToExport(fields, itemObjects) | 738 appendItemsToExport(fields, itemObjects) |
| 725 end | 739 end |
| 726 end | 740 end |
| 727 end | 741 end |
| 728 | 742 |
| 743 -- export soulbind tree info | |
| 744 if data.Soulbinds then | |
| 745 table.insert(fields, ".sol") | |
| 746 for soulbindId, soulbindData in pairs(data.Soulbinds) do | |
| 747 table.insert(fields, string.format("u.%s.%s", soulbindId, soulbindData.UnlockedTier)) | |
| 748 for tier, node in pairs(soulbindData.Nodes) do | |
| 749 table.insert(fields, table.concat(node, ".")) | |
| 750 end | |
| 751 end | |
| 752 end | |
| 753 | |
| 754 -- export unlocked conduits | |
| 755 if data.UnlockedConduits then | |
| 756 table.insert(fields, ".con") | |
| 757 for i, conduit in ipairs(data.UnlockedConduits) do | |
| 758 table.insert(fields, table.concat(conduit, ".")) | |
| 759 end | |
| 760 end | |
| 761 | |
| 762 --[[ | |
| 729 -- export unlocked essences | 763 -- export unlocked essences |
| 730 if data.UnlockedEssences then | 764 if data.UnlockedEssences then |
| 731 table.insert(fields, ".ess") | 765 table.insert(fields, ".ess") |
| 732 for i, ess in ipairs(data.UnlockedEssences) do | 766 for i, ess in ipairs(data.UnlockedEssences) do |
| 733 table.insert(fields, table.concat(ess, "_")) | 767 table.insert(fields, table.concat(ess, "_")) |
| 734 end | 768 end |
| 735 end | 769 end |
| 736 | 770 ]] |
| 771 | |
| 737 -- if doing a complete export, include bank/bag items too | 772 -- if doing a complete export, include bank/bag items too |
| 738 if complete then | 773 if complete then |
| 739 | 774 |
| 740 local itemObjects = {} | 775 local itemObjects = {} |
| 741 if data.BagItems then | 776 if data.BagItems then |
