Mercurial > wow > ouroloot
comparison core.lua @ 146:543fcf15add7
Handle new itemstring format for item variants.
Heroic, warforged, etc, are now additional fields in the itemstring rather
than separate item IDs as in the last few expansions. This fixes the tooltip
displays for such items; there's nothing yet in place for determining the
exact variations (need to finish the list of bonus codes).
Some minor efficiency tweaks.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Tue, 30 Dec 2014 17:52:30 -0500 |
parents | 375059a11c1d |
children | e1a90e398231 |
comparison
equal
deleted
inserted
replaced
145:e4bfe7a8b1c9 | 146:543fcf15add7 |
---|---|
1 local nametag, addon = ... | 1 local nametag, addon = ... |
2 | 2 |
3 --[==[ | 3 --[==[ |
4 g_loot's numeric indices are loot entries (including titles, separators, | 4 g_loot's numeric indices are <Loot> entries (including titles, separators, |
5 etc); its named indices are: | 5 etc); its named indices are: |
6 - forum saved text from forum markup window, default nil | 6 - forum saved text from forum markup window, default nil |
7 - attend saved text from raid attendence window, default nil | 7 - attend saved text from raid attendence window, default nil |
8 - printed.FOO last loot index formatted into text window FOO, default 0 | 8 - printed.FOO last loot index formatted into text window FOO, default 0 |
9 - raiders accumulating raid roster data as we see raid members; indexed | 9 - raiders accumulating raid roster data as we see raid members; indexed |
53 will be classID-style (e.g., DEATHKNIGHT) | 53 will be classID-style (e.g., DEATHKNIGHT) |
54 - person_realm recipient's realm if different from the player's; missing | 54 - person_realm recipient's realm if different from the player's; missing |
55 otherwise | 55 otherwise |
56 - itemname not including square brackets | 56 - itemname not including square brackets |
57 - id itemID as number | 57 - id itemID as number |
58 - itemstring "item:nnnnn" string | |
58 - itemlink full clickable link | 59 - itemlink full clickable link |
59 - itexture icon path (e.g., Interface\Icons\INV_Misc_Rune_01) | 60 - itexture icon path (e.g., Interface\Icons\INV_Misc_Rune_01) |
60 - quality [LE_]ITEM_QUALITY_* number | 61 - quality [LE_]ITEM_QUALITY_* number |
61 - unique an almost-certainly-unique string, content meaningless | 62 - unique an almost-certainly-unique string, content meaningless |
62 - disposition offspec/gvault/shard; missing otherwise; can be set from | 63 - disposition offspec/gvault/shard; missing otherwise; can be set from |
63 the extratext field | 64 the extratext field |
64 - count e.g., "x3"; missing otherwise; can be set/removed from | 65 - count e.g., "x3"; missing otherwise; can be set/removed from |
65 extratext; triggers only for a stack of items, not "the boss | 66 extratext; triggers only for a stack of items, not "the boss |
66 dropped double axes today" | 67 dropped double axes today" |
67 - variant 1 = heroic item, 2 = LFR item; missing otherwise | 68 - variant 1 = heroic item, 2 = LFR item; missing otherwise |
69 XXX CHANGED FOR WoD: for now, if present at all, some kind | |
70 of heroic/warforged/something-extra; missing otherwise | |
68 - cache_miss if GetItemInfo failed; SHOULD be missing (changes other fields) | 71 - cache_miss if GetItemInfo failed; SHOULD be missing (changes other fields) |
69 - bcast_from player's name if received rebroadcast from that player; | 72 - bcast_from player's name if received rebroadcast from that player; |
70 missing otherwise; can be deleted as a result of in-game | 73 missing otherwise; can be deleted as a result of in-game |
71 fiddling of loot data | 74 fiddling of loot data |
72 - extratext text in Note column, including disposition and rebroadcasting; | 75 - extratext text in Note column, including disposition and rebroadcasting; |
387 | 390 |
388 local type, select, next, pairs, ipairs, tinsert, tremove, tostring, tonumber, wipe = | 391 local type, select, next, pairs, ipairs, tinsert, tremove, tostring, tonumber, wipe = |
389 type, select, next, pairs, ipairs, table.insert, table.remove, tostring, tonumber, table.wipe | 392 type, select, next, pairs, ipairs, table.insert, table.remove, tostring, tonumber, table.wipe |
390 | 393 |
391 local pprint, tabledump = addon.pprint, flib.tabledump | 394 local pprint, tabledump = addon.pprint, flib.tabledump |
392 local CopyTable = CopyTable | 395 local strsplit, CopyTable = strsplit, CopyTable |
393 local GetNumGroupMembers = GetNumGroupMembers | 396 local GetNumGroupMembers = GetNumGroupMembers |
394 local IsInRaid = IsInRaid | 397 local IsInRaid = IsInRaid |
395 -- En masse forward decls of symbols defined inside local blocks | 398 -- En masse forward decls of symbols defined inside local blocks |
396 local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas | 399 local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas |
397 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision | 400 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision |
468 mousebutton: "LeftButton", "MiddleButton", "RightButton" | 471 mousebutton: "LeftButton", "MiddleButton", "RightButton" |
469 | 472 |
470 amusingly, print()'ing the fullstring below as a debugging aid yields | 473 amusingly, print()'ing the fullstring below as a debugging aid yields |
471 another clickable link, yay data reproducability | 474 another clickable link, yay data reproducability |
472 ]] | 475 ]] |
473 local strsplit = strsplit | |
474 DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, fullstring, mousebutton) | 476 DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, fullstring, mousebutton) |
475 local ltype, arg = strsplit(":",link) | 477 local ltype, arg = strsplit(":",link) |
476 if ltype ~= "OuroLoot" then return end | 478 if ltype ~= "OuroLoot" then return end |
477 arg = tonumber(arg) | 479 arg = tonumber(arg) |
478 local f = func_map[text_map[arg]] | 480 local f = func_map[text_map[arg]] |
943 | 945 |
944 KeyBindingFrame_LoadUI() | 946 KeyBindingFrame_LoadUI() |
945 local btn = CreateFrame("Button", "OuroLootBindingOpen", nil, "SecureActionButtonTemplate") | 947 local btn = CreateFrame("Button", "OuroLootBindingOpen", nil, "SecureActionButtonTemplate") |
946 btn:SetAttribute("type", "macro") | 948 btn:SetAttribute("type", "macro") |
947 btn:SetAttribute("macrotext", "/ouroloot toggle") | 949 btn:SetAttribute("macrotext", "/ouroloot toggle") |
948 if SetBindingClick(opts.keybinding_text, "OuroLootBindingOpen") then | 950 if SetBindingClick (opts.keybinding_text, "OuroLootBindingOpen") then |
949 -- a simple SaveBindings(GetCurrentBindingSet()) occasionally fails when | 951 -- a simple SaveBindings(GetCurrentBindingSet()) occasionally fails when |
950 -- GCBS() decides to return neither 1 nor 2 during load, for reasons nobody | 952 -- GCBS() decides to return neither 1 nor 2 during load, for reasons nobody |
951 -- has ever learned | 953 -- has ever learned |
952 local c = GetCurrentBindingSet() | 954 local c = GetCurrentBindingSet() |
953 if c == ACCOUNT_BINDINGS or c == CHARACTER_BINDINGS then | 955 if c == _G.ACCOUNT_BINDINGS or c == _G.CHARACTER_BINDINGS then |
954 SaveBindings(c) | 956 SaveBindings(c) |
955 end | 957 end |
956 else | 958 else |
957 self:Print("Error registering '%s' as a keybinding, check spelling!", | 959 self:Print("Error registering '%s' as a keybinding, check spelling!", |
958 opts.keybinding_text) | 960 opts.keybinding_text) |
964 The five loot format patterns of interest, changed into relatively tight | 966 The five loot format patterns of interest, changed into relatively tight |
965 string match patterns. Done at enable-time rather than load-time against | 967 string match patterns. Done at enable-time rather than load-time against |
966 the slim chance that one of the non-US "delocalizers" needs to mess with | 968 the slim chance that one of the non-US "delocalizers" needs to mess with |
967 the global patterns before we transform them. | 969 the global patterns before we transform them. |
968 | 970 |
969 The SELF variants can be replaced with LOOT_ITEM_PUSHED_SELF[_MULTIPLE] to | 971 The SELF patterns can be replaced with LOOT_ITEM_PUSHED_SELF[_MULTIPLE] to |
970 trigger on 'receive item' instead, which would detect extracting stuff | 972 trigger on 'receive item' instead, which would detect extracting stuff |
971 from mail, or s/PUSHED/CREATED/ for things like healthstones and guild | 973 from mail, or s/PUSHED/CREATED/ for things like healthstones and guild |
972 cauldron flasks. | 974 cauldron flasks. |
973 ]] | 975 ]] |
974 | 976 |
1035 _b:SetScript("OnShow",nil) | 1037 _b:SetScript("OnShow",nil) |
1036 end) | 1038 end) |
1037 InterfaceOptions_AddCategory(bliz) | 1039 InterfaceOptions_AddCategory(bliz) |
1038 | 1040 |
1039 -- Maybe load up g_uniques now? | 1041 -- Maybe load up g_uniques now? |
1042 -- Calling the memory-querying APIs while in combat instantly triggers | |
1043 -- the "script ran too long" error, see | |
1044 -- http://www.wowinterface.com/forums/showthread.php?t=44812 | |
1040 if opts.precache_history_uniques and not InCombatLockdown() then | 1045 if opts.precache_history_uniques and not InCombatLockdown() then |
1041 -- Calling the memory-querying APIs while in combat instantly | |
1042 -- triggers the "script ran too long" error, see | |
1043 -- http://www.wowinterface.com/forums/showthread.php?t=44812 | |
1044 self:_cache_history_uniques() | 1046 self:_cache_history_uniques() |
1045 end | 1047 end |
1046 self._cache_history_uniques = nil | 1048 self._cache_history_uniques = nil |
1047 | 1049 |
1048 self:_scan_LOD_modules() | 1050 self:_scan_LOD_modules() |
1061 - opts: (OUT) Pointer to plugin's "db.profile" subtable. | 1063 - opts: (OUT) Pointer to plugin's "db.profile" subtable. |
1062 | 1064 |
1063 Inherited unchanged: | 1065 Inherited unchanged: |
1064 - _add_loot_disposition | 1066 - _add_loot_disposition |
1065 | 1067 |
1066 Inherited module variants: | 1068 Inherited module variations: |
1067 - OnInitialize, OnEnable | 1069 - OnInitialize, OnEnable |
1068 - register_text_generator, register_tab_control: also flag plugin as | 1070 - register_text_generator, register_tab_control: also flag plugin as |
1069 a text-generating module in main addon | 1071 a text-generating module in main addon |
1070 ]] | 1072 ]] |
1071 local prototype = {} | 1073 local prototype = {} |
1108 self:BuildMainDisplay('opt',uniqueval) | 1110 self:BuildMainDisplay('opt',uniqueval) |
1109 end | 1111 end |
1110 end | 1112 end |
1111 function addon:OnModuleCreated (plugin) | 1113 function addon:OnModuleCreated (plugin) |
1112 local token, code = self.format_hypertext (plugin.moduleName, | 1114 local token, code = self.format_hypertext (plugin.moduleName, |
1113 --[[heirloom]]7, "ModulePrefixClick") | 1115 LE_ITEM_QUALITY_LEGENDARY, "ModulePrefixClick") |
1114 chat_prefixes[plugin] = token | 1116 chat_prefixes[plugin] = token |
1115 chat_codes[code] = plugin | 1117 chat_codes[code] = plugin |
1116 -- remove the libraries' embedded pointers so that the prototype | 1118 -- remove the libraries' embedded pointers so that the prototype |
1117 -- can be inherited | 1119 -- can be inherited |
1118 plugin.Print = nil | 1120 plugin.Print = nil |
1250 -- interesting happens, because a nontrivial amount of work happens "soon" | 1252 -- interesting happens, because a nontrivial amount of work happens "soon" |
1251 -- after the interesting event: cleanups/fixups, improvs from network, | 1253 -- after the interesting event: cleanups/fixups, improvs from network, |
1252 -- etc. So firing a callback is delayed ever so briefly by human scales. | 1254 -- etc. So firing a callback is delayed ever so briefly by human scales. |
1253 -- | 1255 -- |
1254 -- For data safety, we replace any table arguments with read-only proxies | 1256 -- For data safety, we replace any table arguments with read-only proxies |
1255 -- before passing them to the callbacks. The goal is to prevent accidents, | 1257 -- before passing them to the callbacks. It's not supposed to be securing |
1256 -- not fraud. | 1258 -- the data against tampering; the goal is to prevent accidents, not fraud. |
1257 local unpack, setmetatable = unpack, setmetatable | 1259 local unpack, setmetatable = unpack, setmetatable |
1258 local mtnewindex = function() --[[local]]error("This table is read-only", 3) end | 1260 local mtnewindex = function() --[[local]]error("This table is read-only", 3) end |
1259 local function make_readonly (t) | 1261 local function make_readonly (t) |
1260 return setmetatable({}, { | 1262 return setmetatable({}, { |
1261 __newindex = mtnewindex, | 1263 __newindex = mtnewindex, |
1292 _G.OuroLootSV_log = nil | 1294 _G.OuroLootSV_log = nil |
1293 ReloadUI() | 1295 ReloadUI() |
1294 end | 1296 end |
1295 function addon:PLAYER_LOGOUT() | 1297 function addon:PLAYER_LOGOUT() |
1296 -- Can these still fire at the very last instant? | 1298 -- Can these still fire at the very last instant? |
1297 self:UnregisterEvent("GROUP_ROSTER_UPDATE") | 1299 --self:UnregisterEvent("GROUP_ROSTER_UPDATE") |
1298 self:UnregisterEvent("PLAYER_ENTERING_WORLD") | 1300 --self:UnregisterEvent("PLAYER_ENTERING_WORLD") |
1301 self.LOGGING_OUT = true -- kludge this instead | |
1299 | 1302 |
1300 local worth_saving = #g_loot > 0 or next(g_loot.raiders) | 1303 local worth_saving = #g_loot > 0 or next(g_loot.raiders) |
1301 if not worth_saving then for text in self:registered_textgen_iter() do | 1304 if not worth_saving then for text in self:registered_textgen_iter() do |
1302 worth_saving = worth_saving or g_loot.printed[text] > 0 | 1305 worth_saving = worth_saving or g_loot.printed[text] > 0 |
1303 end end | 1306 end end |
1426 end | 1429 end |
1427 end | 1430 end |
1428 end | 1431 end |
1429 | 1432 |
1430 function addon:GROUP_ROSTER_UPDATE (event) | 1433 function addon:GROUP_ROSTER_UPDATE (event) |
1434 if self.LOGGING_OUT then return end | |
1431 if not IsInRaid() then | 1435 if not IsInRaid() then |
1432 if was_in_raid then | 1436 if was_in_raid then |
1433 -- Leaving a raid group. | 1437 -- Leaving a raid group. |
1434 self.dprint('flow', "no longer in raid group") | 1438 self.dprint('flow', "no longer in raid group") |
1435 was_in_raid = false | 1439 was_in_raid = false |
1612 wipe(candidates) | 1616 wipe(candidates) |
1613 wipe(sigmap) | 1617 wipe(sigmap) |
1614 end | 1618 end |
1615 local recent_loot = create_new_cache ('loot', comm_cleanup_ttl+3, prefer_local_loots) | 1619 local recent_loot = create_new_cache ('loot', comm_cleanup_ttl+3, prefer_local_loots) |
1616 | 1620 |
1617 local strsplit, GetItemInfo, GetItemIcon, UnitClass = strsplit, GetItemInfo, GetItemIcon, UnitClass | 1621 local GetItemInfo, GetItemIcon, UnitClass = GetItemInfo, GetItemIcon, UnitClass |
1618 | 1622 |
1623 -- 'item' can be any of things passable to GetItemInfo, so we make no | |
1624 -- assumptions but rather base all information off of returns from | |
1625 -- GetItemInfo, including re-extracting the itemstring | |
1626 -- (in the case of local messages, 'item' is an itemstring) | |
1619 -- 'from' only present if this is triggered by a broadcast | 1627 -- 'from' only present if this is triggered by a broadcast |
1620 function _do_loot (self, local_override, recipient, unique, itemid, count, from, extratext) | 1628 function _do_loot (self, local_override, recipient, unique, item, count, from, extratext) |
1629 if unique == 0 then unique = nil end | |
1621 local prefix = "_do_loot[" .. counter() .. "]" | 1630 local prefix = "_do_loot[" .. counter() .. "]" |
1622 local itexture = GetItemIcon(itemid) | 1631 |
1623 local iname, ilink, iquality = GetItemInfo(itemid) | 1632 --[[ |
1624 local cache_miss | 1633 iname: Hearthstone |
1634 iquality: integer | |
1635 ilink: clickable formatted link | |
1636 itemstring: item:6948:.... | |
1637 ]] | |
1638 local cache_miss, itemid | |
1639 local iname, ilink, iquality, | |
1640 -- ilvl, minlvl, type, subtype, stacksize, equiploc, texture, sellprice | |
1641 _, _, _, _, _, _, itexture = GetItemInfo(item) | |
1642 if not itexture then | |
1643 -- Fun fact, GetItemIcon behaves oddly on a nil argument, and may | |
1644 -- or may not always work on a non-numerical-itemID argument | |
1645 itemid = tonumber(item) | |
1646 if (itemid) then | |
1647 itexture = GetItemIcon(itemid) | |
1648 end | |
1649 end | |
1625 if (not iname) or (not itexture) then | 1650 if (not iname) or (not itexture) then |
1626 cache_miss = true | 1651 cache_miss = true |
1627 iname, ilink, iquality, itexture = | 1652 iname, ilink, iquality, itexture = |
1628 UNKNOWN..': '..itemid, 'item:6948', LE_ITEM_QUALITY_COMMON, [[Interface\ICONS\INV_Misc_QuestionMark]] | 1653 UNKNOWN..': '..item, 'item:6948', LE_ITEM_QUALITY_COMMON, |
1654 [[Interface\ICONS\INV_Misc_QuestionMark]] | |
1629 end | 1655 end |
1630 self.dprint('loot',">>"..prefix, "R:", recipient, "U:", unique, "I:", | 1656 self.dprint('loot',">>"..prefix, "R:", recipient, "U:", unique, "I:", |
1631 itemid, "C:", count, "frm:", from, "ex:", extratext, "q:", iquality) | 1657 item, "C:", count, "frm:", from, "ex:", extratext, |
1632 | 1658 "q:", iquality, "tex:", itexture) |
1633 itemid = tonumber(ilink:match("item:(%d+)") or 0) | 1659 |
1660 -- Get a known-good string and integer out of the returned link. | |
1661 local itemstring = ilink:match("item[%-?%d:]+") | |
1662 itemid = tonumber(itemstring:match("^item:(%d+)") or 0) | |
1634 | 1663 |
1635 -- This is only a 'while' to make jumping out of it easy. | 1664 -- This is only a 'while' to make jumping out of it easy. |
1636 local i, unique_okay, replacement, ret1, ret2 | 1665 local i, unique_okay, replacement, ret1, ret2 |
1637 while local_override | 1666 while local_override |
1638 or ((iquality >= self.threshold) and not opts.itemfilter[itemid]) | 1667 or ((iquality >= self.threshold) and not opts.itemfilter[itemid]) |
1655 break | 1684 break |
1656 end | 1685 end |
1657 end | 1686 end |
1658 | 1687 |
1659 if (self.rebroadcast and (not from)) and not local_override then | 1688 if (self.rebroadcast and (not from)) and not local_override then |
1660 self:vbroadcast('loot', recipient, unique, itemid, count) | 1689 self:vbroadcast('loot', recipient, unique, itemstring, count) |
1661 end | 1690 end |
1662 if (not self.enabled) and (not local_override) then break end | 1691 if (not self.enabled) and (not local_override) then break end |
1663 | 1692 |
1664 local oldersig = recipient .. iname .. (count or "") | 1693 local oldersig = recipient .. iname .. (count or "") |
1665 local signature, seenit | 1694 local signature, seenit |
1701 person_realm= g_loot.raiders[recipient].realm, | 1730 person_realm= g_loot.raiders[recipient].realm, |
1702 cache_miss = cache_miss, | 1731 cache_miss = cache_miss, |
1703 quality = iquality, | 1732 quality = iquality, |
1704 itemname = iname, | 1733 itemname = iname, |
1705 id = itemid, | 1734 id = itemid, |
1706 itemlink = ilink, | 1735 itemstring = itemstring, |
1736 itemlink = ilink, -- determines the GUI tooltip | |
1707 itexture = itexture, | 1737 itexture = itexture, |
1708 unique = replacement or unique, | 1738 unique = replacement or unique, |
1709 count = (count and count ~= "") and count or nil, | 1739 count = (count and count ~= "") and count or nil, |
1710 bcast_from = from, | 1740 bcast_from = from, |
1711 extratext = extratext, | 1741 extratext = extratext, |
1712 variant = self:is_variant_item(ilink), | 1742 variant = self:is_variant_item(itemstring), |
1713 } | 1743 } |
1714 if opts.itemvault[itemid] then | 1744 if opts.itemvault[itemid] then |
1715 i.disposition = 'gvault' | 1745 i.disposition = 'gvault' |
1716 elseif recipient == self.sharder then | 1746 elseif recipient == self.sharder then |
1717 i.disposition = 'shard' | 1747 i.disposition = 'shard' |
1755 -- displaying any errors. | 1785 -- displaying any errors. |
1756 local match = string.match | 1786 local match = string.match |
1757 function addon:CHAT_MSG_LOOT (event, ...) | 1787 function addon:CHAT_MSG_LOOT (event, ...) |
1758 if (not self.rebroadcast) and (not self.enabled) and (event ~= "manual") then return end | 1788 if (not self.rebroadcast) and (not self.enabled) and (event ~= "manual") then return end |
1759 | 1789 |
1760 --[[ | |
1761 iname: Hearthstone | |
1762 iquality: integer | |
1763 ilink: clickable formatted link | |
1764 itemstring: item:6948:.... | |
1765 itexture: inventory icon texture | |
1766 ]] | |
1767 | |
1768 if event == "CHAT_MSG_LOOT" then | 1790 if event == "CHAT_MSG_LOOT" then |
1769 local msg = ... | 1791 local msg = ... |
1770 local person, itemstring, count | 1792 local person, itemlink, count |
1771 --ChatFrame2:AddMessage("original string: >"..(msg:gsub("\124","\124\124")).."<") | 1793 --ChatFrame2:AddMessage("original string: >"..(msg:gsub("\124","\124\124")).."<") |
1772 | 1794 |
1773 -- test in most likely order: other people get more loot than "you" do | 1795 -- test in most likely order: other people get more loot than "you" do |
1774 person, itemstring, count = match(msg,g_LOOT_ITEM_MULTIPLE_sss) | 1796 person, itemlink, count = match(msg,g_LOOT_ITEM_MULTIPLE_sss) |
1775 if not person then | 1797 if not person then |
1776 person, itemstring = match(msg,g_LOOT_ITEM_ss) | 1798 person, itemlink = match(msg,g_LOOT_ITEM_ss) |
1777 end | 1799 end |
1778 if not person then | 1800 if not person then |
1779 -- Could only do this text if in an LFR... but the restriction | 1801 -- Could only do this text if in an LFR... but the restriction |
1780 -- might apply elsewhere soon enough. | 1802 -- might apply elsewhere soon enough. |
1781 person, itemstring = match(msg,g_LOOT_ITEM_WHILE_PLAYER_INELIGIBLE_ss) | 1803 person, itemlink = match(msg,g_LOOT_ITEM_WHILE_PLAYER_INELIGIBLE_ss) |
1782 end | 1804 end |
1783 if not person then | 1805 if not person then |
1784 itemstring, count = match(msg,g_LOOT_ITEM_SELF_MULTIPLE_ss) | 1806 itemlink, count = match(msg,g_LOOT_ITEM_SELF_MULTIPLE_ss) |
1785 if not itemstring then | 1807 if not itemlink then |
1786 itemstring = match(msg,g_LOOT_ITEM_SELF_s) | 1808 itemlink = match(msg,g_LOOT_ITEM_SELF_s) |
1787 end | 1809 end |
1788 end | 1810 end |
1789 | 1811 |
1790 if not itemstring then return end -- "PlayerX selected Greed", etc, not looting | 1812 if not itemlink then return end -- "PlayerX selected Greed", etc, not looting |
1791 self.dprint('loot', "CHAT_MSG_LOOT, person is", person, | 1813 self.dprint('loot', "CHAT_MSG_LOOT, person is", person, |
1792 ", itemstring is", itemstring, ", count is", count) | 1814 ", itemlink is", itemlink, ", count is", count) |
1793 | 1815 |
1794 -- Name might be colorized, remove the highlighting | 1816 -- Name might be colorized, remove the highlighting |
1795 if person then | 1817 if person then |
1796 person = match(person,"|c%x%x%x%x%x%x%x%x(%S+)") or person | 1818 person = match(person,"|c%x%x%x%x%x%x%x%x(%S+)") or person |
1797 else | 1819 else |
1798 person = my_name -- UNIT_YOU / You | 1820 person = my_name -- UNIT_YOU / You |
1799 end | 1821 end |
1800 | 1822 |
1801 --local id = tonumber(itemstring:match('|Hitem:(%d+):')) | 1823 return _do_loot (self, --[[override=]]false, person, unique, |
1802 local id,unique,_ | 1824 match(itemlink,"item[%-?%d:]+"), count) |
1803 _,id,_,_,_,_,_,_,unique = strsplit (":", itemstring) | |
1804 if unique == 0 then unique = nil end | |
1805 | |
1806 return _do_loot (self, false, person, unique, id, count) | |
1807 | 1825 |
1808 elseif event == "broadcast" then | 1826 elseif event == "broadcast" then |
1809 return _do_loot(self, false, ...) | 1827 return _do_loot (self, --[[override=]]false, ...) |
1810 | 1828 |
1811 elseif event == "manual" then | 1829 elseif event == "manual" then |
1812 local r,i,n = ... | 1830 local recip,item,text = ... |
1813 return _do_loot(self, true, r, --[[unique=]]nil, i, | 1831 return _do_loot (self, --[[override=]]true, recip, |
1814 --[[count=]]nil, --[[from=]]nil, n) | 1832 --[[unique=]]nil, item, --[[count=]]nil, --[[from=]]nil, text) |
1815 end | 1833 end |
1816 end | 1834 end |
1817 end | 1835 end |
1818 | 1836 |
1819 -- This only triggers on entering combat after a registered boss kill. | 1837 -- This only triggers on entering combat after a registered boss kill. |
1871 elseif cmd == "fake" then -- maybe comment this out for real users | 1889 elseif cmd == "fake" then -- maybe comment this out for real users |
1872 self:_mark_boss_kill (self._addBossEntry{ | 1890 self:_mark_boss_kill (self._addBossEntry{ |
1873 kind='boss',reason='kill',bossname="Baron Steamroller",duration=0 | 1891 kind='boss',reason='kill',bossname="Baron Steamroller",duration=0 |
1874 }) | 1892 }) |
1875 self:CHAT_MSG_LOOT ('manual', my_name, 54797) | 1893 self:CHAT_MSG_LOOT ('manual', my_name, 54797) |
1894 self:CHAT_MSG_LOOT ('manual', my_name, 'item:109948:0:0:0:0:0:0:0:100:0:2:2:499:524') | |
1876 if self.display then | 1895 if self.display then |
1877 self:redisplay() | 1896 self:redisplay() |
1878 end | 1897 end |
1879 self:Print "Baron Steamroller has been slain. Congratulations on your rug." | 1898 self:Print "Baron Steamroller has been slain. Congratulations on your rug." |
1880 | 1899 |
2282 return nextr, t, 0 | 2301 return nextr, t, 0 |
2283 end | 2302 end |
2284 end | 2303 end |
2285 | 2304 |
2286 do | 2305 do |
2287 local itt | 2306 --[[local itt |
2288 local function create() | 2307 local function create() |
2289 local tip, lefts = CreateFrame("GameTooltip"), {} | 2308 local tip, lefts = CreateFrame("GameTooltip"), {} |
2290 for i = 1, 2 do -- scanning idea here also snagged from Talented | 2309 for i = 1, 2 do -- scanning idea here also snagged from Talented |
2291 local L,R = tip:CreateFontString(), tip:CreateFontString() | 2310 local L,R = tip:CreateFontString(), tip:CreateFontString() |
2292 L:SetFontObject(GameFontNormal) | 2311 L:SetFontObject(GameFontNormal) |
2305 local t = itt.lefts[2]:GetText() | 2324 local t = itt.lefts[2]:GetText() |
2306 itt:Hide() | 2325 itt:Hide() |
2307 return (t == ITEM_HEROIC and 1) | 2326 return (t == ITEM_HEROIC and 1) |
2308 or (t == RAID_FINDER and 2) -- no ITEM_ for this, apparently | 2327 or (t == RAID_FINDER and 2) -- no ITEM_ for this, apparently |
2309 or nil | 2328 or nil |
2329 end | |
2330 ]] | |
2331 local bcodes = { | |
2332 [448] = "Warforged", -- and 499? | |
2333 [449] = "Heroic", -- 524? | |
2334 [450] = "Mythic", | |
2335 [451] = "LFR", | |
2336 [15] = "Epic", | |
2337 [171] = "Rare", | |
2338 } | |
2339 function addon:is_variant_item(istr) | |
2340 --flib.safeiprint(strsplit (":", istr)) | |
2341 --flib.safeiprint(select (13, strsplit (":", istr)) ) | |
2342 local bonuses = { select (13, strsplit (":", istr)) } | |
2343 if #bonuses < 1 then | |
2344 return -- nil for no bonus | |
2345 end | |
2346 local n = tonumber(bonuses[1]) or 0 | |
2347 if n < 1 then | |
2348 return -- nil for no bonus | |
2349 end | |
2350 --@debug@ | |
2351 print("bonuses has", #bonuses, "entries, size entry is", bonuses[1], "for", istr) | |
2352 table.remove (bonuses, 1) | |
2353 assert (n == #bonuses, "test for variant item on " .. | |
2354 istr .. " extracted count " .. (n or "nil?") .. | |
2355 " but table size is " .. #bonuses) | |
2356 for i = 1, #bonuses do | |
2357 local b = tonumber(bonuses[i]) | |
2358 print(" bonus ", b, bcodes[b]) | |
2359 bonuses[i] = b | |
2360 end | |
2361 --@end-debug@ | |
2362 return 42 -- will figure out meaningful value later | |
2310 end | 2363 end |
2311 end | 2364 end |
2312 | 2365 |
2313 -- Called at the end of OnInit, and then also when a 'clear' is being | 2366 -- Called at the end of OnInit, and then also when a 'clear' is being |
2314 -- performed. If SV's are present then g_restore_p will be true. | 2367 -- performed. If SV's are present then g_restore_p will be true. |
2836 local iname, ilink, iquality, _,_,_,_,_,_, itexture = GetItemInfo(borked_id) | 2889 local iname, ilink, iquality, _,_,_,_,_,_, itexture = GetItemInfo(borked_id) |
2837 if iname then | 2890 if iname then |
2838 local msg = [[ Entry %d patched up with %s.]] | 2891 local msg = [[ Entry %d patched up with %s.]] |
2839 e.quality = iquality | 2892 e.quality = iquality |
2840 e.itemname = iname | 2893 e.itemname = iname |
2841 e.id = tonumber(ilink:match("item:(%d+)")) | 2894 e.itemstring = ilink:match("item[%-?%d:]+") |
2895 e.id = tonumber(e.itemstring:match("^item:(%d+)") or 0) | |
2842 e.itemlink = ilink | 2896 e.itemlink = ilink |
2843 e.itexture = itexture | 2897 e.itexture = itexture |
2844 e.cache_miss = nil | 2898 e.cache_miss = nil |
2845 if e.unique then | 2899 if e.unique then |
2846 local gu = g_uniques[e.unique] | 2900 local gu = g_uniques[e.unique] |
3765 end | 3819 end |
3766 | 3820 |
3767 | 3821 |
3768 ------ Player communication | 3822 ------ Player communication |
3769 do | 3823 do |
3770 local select, tconcat, strsplit, unpack = select, table.concat, strsplit, unpack | 3824 local select, tconcat, unpack = select, table.concat, unpack |
3771 local function assemble(t,...) | 3825 local function assemble(t,...) |
3772 local n = select('#',...) | 3826 local n = select('#',...) |
3773 if n > 0 then | 3827 if n > 0 then |
3774 local msg = {t,...} | 3828 local msg = {t,...} |
3775 -- tconcat requires strings, but T is known to be one already | 3829 -- tconcat requires strings, but T is known to be one already |