LibPlayerSpellInfo-1.0

Abandoned
A library to provide extended information regarding player spell action/macro cast requirements.

A library to provide extended information regarding player spell action/macro cast requirements (such as reagent, equipment and form requirements).

Includes:
  • Spell requirement API's that determine if a spell meets equipment, form, and/or reagent requirements.
    • There are also API's for parsing entire macrotext objects and determining if a spell name/link/id is a valid player spell/companion/mount.
  • Cast requirement API's (basically beefier IsUsableSpell/Action/Item functions) that determine nearly all1 casting requirements for any given spell/item/action.

1 Excluded parameters are whether the player has control of their character (which can be determined with LibUnitControl-1.0) and whether the player's target is within LOS, which is currently impossible to discern.

Usage

Here's a relatively simple display hook for use with the default blizzard actionbars that improves color indication of a whether a spell can be cast:

local lps = LibStub("LibPlayerSpellInfo-1.0")

local hook_ActionButton_OnUpdate = ActionButton_OnUpdate
function ActionButton_OnUpdate(button, elapsed)
  if button.rangeTimer and ( button.rangeTimer - elapsed <= 0 ) then
    ActionButton_UpdateUsable(button)
  end
  hook_ActionButton_OnUpdate(button, elapsed)
end

function ActionButton_UpdateUsable(button)

  local name = button:GetName()
  local icon, texture = _G[name.."Icon"], _G[name.."NormalTexture"]
  
  local isKnown, hasReact, _, inRange, hasUnit, _, hasMana
    hasEquip, hasReagent, inForm = lps:ActionUseInfo(button.action)
  
  if ( not inForm ) then -- Green overlay
    icon:SetVertexColor(0, 0.4, 0.2)
    texture:SetVertexColor(0, 0.4, 0.2)
  elseif ( not hasEquip ) or ( not hasReagent ) then -- Orange overlay
    icon:SetVertexColor(0.4, 0.2, 0)
    texture:SetVertexColor(0.4, 0.2, 0)
  elseif ( not hasMana ) then -- Blue overlay
    icon:SetVertexColor(0.2, 0.3, 0.7)
    texture:SetVertexColor(0.2, 0.3, 0.7)
  elseif ( hasUnit and not inRange ) then -- Red overlay
    icon:SetVertexColor(0.7, 0.15, 0.15)
    texture:SetVertexColor(0.7, 0.15, 0.15)
  elseif ( isKnown and not hasReact ) then -- Gray overlay
    icon:SetVertexColor(0.4, 0.4, 0.4);
    texture:SetVertexColor(1.0, 1.0, 1.0)
  else -- No overlay
    icon:SetVertexColor(1.0, 1.0, 1.0)
    texture:SetVertexColor(1.0, 1.0, 1.0)
  end
  
end

The LibPlayerSpellInfo-1.0 Team

profile avatar
Owner
  • 3
    Projects
  • 27.0K
    Downloads

More from draake