casualshammy / NameplateCooldowns

This addon for World of Warcraft will show you cooldowns of an enemies above their nameplates
https://wow.curseforge.com/projects/nameplatecooldowns
Other
5 stars 3 forks source link

Potential new isHealer check #159

Closed rbgdevx closed 4 days ago

rbgdevx commented 1 week ago

WoW version Retail

Describe the feature you'd like to be implemented Hey 👋🏼 I think i have a new way to check if someone is a healer.

In 10.1.5 if you remember they added the spec to the tooltip on hover of characters. This code i have working in my project right now and haven't had an issue yet, lmk what you think but if it works for you it could replace the dependency on LibHealerCheck. Worth noting i could not find the source of LibHealerCheck or how that lib came to be.

local HEALER_SPECS = {
  ["Restoration Druid"] = true,
  ["Restoration Shaman"] = true,
  ["Mistweaver Monk"] = true,
  ["Holy Priest"] = true,
  ["Holy Paladin"] = true,
  ["Discipline Priest"] = true,
  ["Preservation Evoker"] = true,
}
local isHealer = false
local data = GetUnitTooltip(unit)
if data then
  if data.lines then
    for _, line in pairs(data.lines) do
      if line.type == Enum.TooltipDataLineType.None then
        if HEALER_SPECS[line.leftText] then
          local unitGUID = UnitGUID(unit)
          if unitGUID then
            isHealer = true
            break
          end
        end
      end
    end
  end
end

There may be a dynamic way to get spec names to store as a reference table but i don't know it.

casualshammy commented 6 days ago

Hi, Thank you for suggestion. But I personally prefer not to parse strings in UI:

  1. Localization required.
  2. Strings can (and will) be changed in any language without any notice.
  3. It's unreliable, because sometimes spec info in tooltip is just stuck with "Retrieving information..."
rbgdevx commented 5 days ago

oh okay i wasn't aware of the 3rd one, thats good to know.

thanks for the response!

Do you know where the source of LibHealerCheck came from btw? i couldn't find it anywhere

casualshammy commented 5 days ago

LibHealerCheck? I don't know. NameplateCooldowns uses LibHealerTracker. IIRC I've wrote it.

rbgdevx commented 5 days ago

oh sorry yea i meant LibHealerTracker, oh okay awesome!

Just out of curiosity, and for my learning (im new to wow api + lua), for that lib how come you've moved away from using the UPDATE_BATTLEFIELD_SCORE method you have commented out?

casualshammy commented 4 days ago

Sorry, I don't remember. 😅 Maybe GetBattlefieldScore method was returned irrelevant data... BTW, this code is primitive and straightforward. As you can see, there is 'reset' of healer status only on PLAYER_ENTERING_WORLD event. Please consider it if you'll use this code.

rbgdevx commented 4 days ago

okay good to know, thanks again!