Skip to content

Commit

Permalink
Greatly improve weapon enchantment detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonomit committed Sep 26, 2022
1 parent 863e175 commit ce9e577
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
26 changes: 19 additions & 7 deletions Operations/RecognizeLineTypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ local contexts = Addon:MakeLookupTable({
"RequiredLevel",
"SecondaryStat",
"LastSecondaryStat",
"MadeBy",
"SetName",
"setPiece",
"LastSetPiece",
"SetBonus",
"LastSetBonus",
"MadeBy",
"SocketHint",
"SoulboundTradeable",
"Delta",
Expand Down Expand Up @@ -138,7 +138,8 @@ local function SetContext(context, tooltipData, line)
return -1
end

local contextActions = Addon:Map({
local contextActions
contextActions = Addon:Map({
PreTitle = function(i, tooltipData, line)
if line.textLeftText == CURRENTLY_EQUIPPED or line.textLeftText == DESTROY_GEM then
return SetContext(i, tooltipData, line)
Expand Down Expand Up @@ -222,7 +223,7 @@ local contextActions = Addon:Map({
end
end,
Enchant = function(i, tooltipData, line)
if tooltipData.hasEnchant and line.colorLeft == Addon.COLORS.GREEN and not StartsWithAny(line.textLeftTextStripped, ITEM_SPELL_TRIGGER_ONEQUIP, ITEM_SPELL_TRIGGER_ONUSE, ITEM_SPELL_TRIGGER_ONPROC) then
if tooltipData.hasEnchant and line.colorLeft == Addon.COLORS.GREEN then
return SetContext(i, tooltipData, line)
end
end,
Expand All @@ -233,7 +234,18 @@ local contextActions = Addon:Map({
end
end,
WeaponEnchant = function(i, tooltipData, line)
if line.colorLeft == Addon.COLORS.GREEN and not StartsWithAny(line.textLeftTextStripped, ITEM_SPELL_TRIGGER_ONEQUIP, ITEM_SPELL_TRIGGER_ONUSE, ITEM_SPELL_TRIGGER_ONPROC) then
if tooltipData.isWeapon and line.colorLeft == Addon.COLORS.GREEN then
for _, alt in ipairs{
contexts.LastSecondaryStat,
contexts.MadeBy,
contexts.SocketHint,
} do
local increment = contextActions[alt](alt, tooltipData, line)
if increment then
return alt - i + increment
end
end
-- didn't match any other possible green line
return SetContext(i, tooltipData, line)
end
end,
Expand Down Expand Up @@ -280,7 +292,7 @@ local contextActions = Addon:Map({
end
end,
MadeBy = function(i, tooltipData, line)
if MatchesAny(line.textLeftTextStripped, ITEM_CREATED_BY) then
if line.colorLeft == Addon.COLORS.GREEN and MatchesAny(line.textLeftTextStripped, ITEM_CREATED_BY, ITEM_WRITTEN_BY, ITEM_WRAPPED_BY) then
return SetContext(i, tooltipData, line)
end
end,
Expand All @@ -295,14 +307,14 @@ local contextActions = Addon:Map({
end
end,
LastSetBonus = function(i, tooltipData, line)
local prefix = MatchesAny(line.textLeftTextStripped, ITEM_SET_BONUS_GRAY, ITEM_SET_BONUS)
local prefix = (line.colorLeft == Addon.COLORS.GRAY or line.colorLeft == Addon.COLORS.GREEN) and MatchesAny(line.textLeftTextStripped, ITEM_SET_BONUS_GRAY, ITEM_SET_BONUS)
if prefix then
line.prefix = prefix
return SetContext(i-1, tooltipData, line)
end
end,
SocketHint = function(i, tooltipData, line)
if StartsWithAny(line.textLeftTextStripped, ITEM_SOCKETABLE) then
if line.colorLeft == Addon.COLORS.GREEN and StartsWithAny(line.textLeftTextStripped, ITEM_SOCKETABLE) then
return SetContext(i, tooltipData, line)
end
end,
Expand Down
10 changes: 10 additions & 0 deletions Operations/ScanTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ local mathMin = math.min



local weaponInvTypes = {
INVTYPE_WEAPON = true,
INVTYPE_2HWEAPON = true,
INVTYPE_WEAPONMAINHAND = true,
INVTYPE_WEAPONOFFHAND = true,
}


function Addon:PrepareTooltip(tooltip, methodName, ...)
local args = {n = select("#", ...), ...}
return pcall(function()
Expand Down Expand Up @@ -97,6 +105,8 @@ function Addon:ReadTooltip(tooltip, name, link, maxLines)
if strFind(link, "item:%d+:%d+") then
tooltipData.hasEnchant = true
end
local _, _, _, itemEquipLoc = GetItemInfoInstant(tooltipData.id)
tooltipData.isWeapon = weaponInvTypes[itemEquipLoc]

return tooltipData
end
Expand Down
20 changes: 18 additions & 2 deletions ZeraTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ setting to show Heroic tag
example for above settings: https://www.wowhead.com/wotlk/item=51933/shawl-of-nerubian-silk
recognize ITEM_READABLE
enchantment should be found only if the link has an enchantment
measure performance and memory usage with and without caches. maybe only cache particularly expensive operations? like localeExtras
Expand All @@ -28,7 +27,24 @@ reorder races, classes, level
show heroic tag
show ilvl
REFUND_TIME_REMAINING
durability
multiple lines:
SPELL_SCHOOL%d_CAP
or AMMO_SCHOOL_DAMAGE_TEMPLATE
or PLUS_AMMO_SCHOOL_DAMAGE_TEMPLATE
or DAMAGE_TEMPLATE_WITH_SCHOOL
or PLUS_DAMAGE_TEMPLATE_WITH_SCHOOL
or SINGLE_DAMAGE_TEMPLATE_WITH_SCHOOL
or PLUS_SINGLE_DAMAGE_TEMPLATE_WITH_SCHOOL
or AMMO_DAMAGE_TEMPLATE
or PLUS_AMMO_DAMAGE_TEMPLATE
or SINGLE_DAMAGE_TEMPLATE
or PLUS_SINGLE_DAMAGE_TEMPLATE
or DAMAGE_TEMPLATE
or PLUS_DAMAGE_TEMPLATE on the left,
SPEED on the right if it's the first line in the loop (rather "%s %.2f" where %s is SPEED, %f is weapon interval / 1000.0)
if casting disenchant: ITEM_DISENCHANT_NOT_DISENCHANTABLE or ITEM_DISENCHANT_ANY_SKILL or ITEM_DISENCHANT_MIN_SKILL
--]]

Expand Down

0 comments on commit ce9e577

Please sign in to comment.