LibPlayerSpellInfo-1.0

This project has become inactive.

This project is inactive and its default file will likely not work with the most recent version of World of Warcraft. The author may have abandoned it, or it may have outlived its usefulness.

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

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Oct 08, 2010
Category
Last update
Nov 13, 2010
Development stage
Inactive
Language
  • enUS
License
LPS Style BSD
Curse link
LibPlayerSpellInfo-1.0
Downloads
1,370
Recent files
  • R: Release-r7 for 4.0.1 Nov 13, 2010
  • A: r7 for 4.0.1 Nov 13, 2010
  • A: r6 for 4.0.1 Oct 13, 2010
  • A: r5 for 4.0.1 Oct 08, 2010
  • A: r4 for 4.0.1 Oct 08, 2010

Authors