LibPlayerSpells-1.0 is a library providing data about the spells of the eleven character classes in World of Warcraft. It also includes additional spells derived from racial traits and other sources. The word “spells” is used here in the general sense; it includes active skills as well as passive spells that are found in the players’ spellbook. Buffs and debuffs that are applied by the player from other sources are also covered.
This library is born from the need to centralize similar data used in several addons to reduce the maintenance cost and to have a better consistency across those addons.
It provides answers to questions like:
- Does this spell have a cooldown ?
- Does this spell apply one or several buff(s) or debuff(s) ?
- Is this spell a survival cooldown, or used for dps ?
- Does this spell regenerate mana or some other resource ?
- Is this spell a raid wide buff ?
- What are the survival buffs of all the classes ?
- Which spell interrupt abilities are available ?
Each class has his own data file that can be updated separately from the main code.
Supported classes & specs
Not all classes and specializations are 100% supported yet. However, most interrupts, dispels, survival cooldowns and raid buffs are complete.
If LibPlayerSpells is missing something specific from your class please file a detailed bug on Github or contribute to the project yourself if you are feeling brave! In the second case, be sure to read the contribution guidelines.
Copy the library files in your addon and list the lib.xml file in the TOC file.
LibPlayerSpells-1.0 uses LibStub:
local LibPlayerSpells = LibStub('LibPlayerSpells-1.0')
Querying information from a spell
You can then obtain information about a given spell with GetSpellInfo:
local flags, providers, modifiedSpells[, moreFlags] = LibPlayerSpells:GetSpellinfo(spellId)
spellIdis the numerical spell identifier.
flagsis a bitfield containing data about the spells (see below).
providersis the identifier (or a table of) identifier(s) of the spell(s) to; said otherwise, if the provider is not found in the player’s spellbook, the given spell is unavailable. For example, the provider spell can be a passive spell given by a talent.
modifiedSpellsis the (or a table of) identifier(s) of the spell(s) affected by the given spells.
- if the given spell is a special case (see below),
moreFlagscontains another bitfield.
Querying the spell database
You can iterate the database, looking for certain spells, using IterateSpells:
for spellId, flags, providers, modifiedSpells, moreFlags in LibPlayerSpells:IterateSpells(oneOfFlags, requiredFlags, rejectedFlags) do -- Do something with the loot end
moreFlags have the same meaning as the values returned by GetSpellinfo.
spellId is obviously the numerical identifier of the current spell.
The three method arguments are used to build a filter. They are bitmask specifications. They can be passed as an numerical bitmask computed using
bit.bor and library constants, or an a string containing the flags separated by white spaces or commas. For example,
bit.bor(LibPlayerSpells.constants.HUNTER, LibPlayerSpells.constants.BURST) is the same bitmask as
IterateSpells lists all spells that:
- has at least one of the flags listed by
- and has all flags listed by
- and has none of the flags in
If a bitmask is empty or not provided, the corresponding condition is ignored. With no arguments, all spells are listed.
-- Iterate through spells that have a cooldown, are/apply an aura and are either survival or mana-regenerating skills. for spellId, flags, providers, modifiedSpells, moreFlags in LibPlayerSpells:IterateSpells("SURVIVAL REGEN_MANA", "AURA COOLDOWN") do -- Do something with it ! end
Most spell information is stored in a bitfield to compact storage and easily test or filter spells. The bit value constants are available in the LibPlayerSpells.constants table.
The presence of a specific flag can be tested this way:
if bit.band(flags, LibPlayerSpells.constants.AURA) ~= 0 then -- This spell is an aura, do something meaningful with it. end
However, the library provides a way to easily build flag tests.
Special spell types
These flags indicate special spells, that (will) have additional data.
RAIDBUFF: this is a raid buff; additional data is a bitfield indicating the provided buffs (spell haste, critical strike, ...).
CROWD_CTL: this is a crowd-control spell; no additional data yet.
INTERRUPT: this spell can interrupt spell casts; no additional data yet.
DISPEL: this spell can dispel either allies’ debuffs or enemies’ buffs; no additional data yet.
Raid buff flags
These flags are used in the additional data for raids buffs.
STATS: Strength, Agility and Intellect
ATK_POWER: Attack Power
SPL_POWER: Spell Power
CRITICAL: Critical Strike
MASTERY: Mastery Bonus
BURST_HASTE: Burst Haste (e.g. Bloodlust/Heroism)
These flags indicate the source of the spell. The constants are self-explanatory:
These flags hints about the targeting mechanism of the spell. They are exclusive most of the time.
HELPFUL: The spell can be cast on any ally, including the player and his pet.
HARMFUL: The spell can be cast on any enemy.
PERSONAL: The spell automatically targets the player.
PET: The spell automatically targets the player’s pet.
AURA: The spell applies (or is) a buff on allies, or a debuff on enemies.
UNIQUE_AURA: A given character can have only one instance of this (de)buff at a time, even if several players cast the same spell on it, e.g. Hunter’s Mark.
COOLDOWN: This spell has a meaningful cooldown.
SURVIVAL: This spell is considered a survival skill.
BURST: This spell is considered a burst skill (either damaging or healing).
MANA_REGEN: This spell allows the target to recharge their mana; e.g. Innervate.
POWER_REGEN: This spell allows the target to recharge some kind of alternative resource e.g. Energizing Brew
IMPORTANT: An important spell the player should react to.
INVERT_AURA: The aura logic of this spell is inverted. It applies a debuff on allies or a buff on enemies (this case has yet to be found), e.g. the Weakened Soul applied by Power Word: Shield.
LibPlayerSpells-1.0 is licensed using GPL v3. This means that any addon using it must have a compatible license (see there).
- Date created
- Jan 10, 2014
- Last update
- Feb 27, 2015
- Development stage
- GNU General Public License version 3 (GPLv3)
- Curse link
- Recent files