LibDispellable-1.0

23k Downloads

Abandoned

Rainrider opened this issue ยท 0 comments

commented

The dependency of AdiButtonAuras on LibDispellable-1.0 was removed in AdiAddons/AdiButtonAuras#281. The reasons for this are:

  • AdiButtonAuras' aura cache is more efficient than using the iterators of LD
  • it makes more sense to define dispels in LibPlayerSpells-1.0 rather then splitting it into two libraries
  • AdiButtonAuras uses LibSpellbook-1.0 to check for spells known by the player

Because of this, there are no more reasons for me to keep LD updated.

What is lost

The aura iterators of LD are not ported over to LPS as they don't make sense there. Thus there are no alternatives to:

  • LibDispellable:CanDispel
  • LibDispellable:CanDispelWith

You will also have to check by yourself if you know the dispelling spells.
The rest of LD's API is replaced by LPS as below.

Getting the list of dispels for a given class

local LPS = LibStub('LibPlayerSpells-1.0')
if not LPS then return end
local _, playerClass = UnitClass('player')
for spell, flags, _, _, _, dispelFlags in LPS:IterateSpells('DISPEL', playerClass) do
	-- your code
end
  • spell - number - is the spell id of the dispelling spell (in most case, see below)
  • flags - bitmask - can be used to query targeting information (see below)
  • dispelFlags can be used to get dispel types (see below)

Getting the targeting

Use bit.band with LPS.constants.PERSONAL, LPS.constants.HARMFUL and LPS.constants.HELPFUL to find out if it an offensive, defensive or self-dispel.

if bit.band(flags, LPS.constants.HARMFUL) > 0 then
	-- it is an offensive dispel like Shamans' "Purge" or Mages' "Stellsteal"
end

You can also use LPS.masks.TARGETING if you need to filter the targeting mask out of flags.

Getting the dispel type

Use bit.band with LPS.constants.CURSE, LPS.constants.DISEASE, LPS.constants.ENRAGE, LPS.constants.MAGIC, LPS.constants.POISON.

if bit.band(dispelFlags, LPS.constants.MAGIC) > 0 then
	-- it can dispel magic
end

Limitations

In almost all cases spell from above is the dispelling spell - the one you place on your action bars and cast. Due to spell mechanics and LPS semantincs, there are some exceptions:

  • "Feign Death" is a self-dispel when the honor talent "Survival Tactics" is known and active.
  • "Immolation Aura" is a self-dispel when the honor talent "Cleansed by Flame" is known and active.
    In those cases spell is the spell id of the honor talent.

Basically what LPS tells you is "if you know spell, then you can dispel what's in dispelFlags".

Higher abstraction API

If you'd prefer some higher abstraction API to somewhat mimic LibDispellable, feel free to open an issue for LibPlayerSpells-1.0.