by Drome | 09/07/2007 17:32:46

This is especially annoying creating buttons targeted to a unit with spells Power Word: Shield (PWS) and Blessing of Protection (BOP) in eXtremeUnitButtons.
The Issue: For some spells IsUsableSpell returns nil if the "Target" is not valid. This is not consistent across all spells but is true for PWS and BOP. In the end I will have many buttons that cast a spell against their assigned unit which is usually not the "Target" and i need some way of knowing if the spell is castable.
example:
myUsable, myNoMana = IsUsableSpell("Power Word: Shield");
returns
myUsable = 1 when no target, or when a party member is targeted; and nil when an NPC or non-party member is selected.
Other Spells in game do not exhibit this reliance on the "Target" for IsSpellUsable. For example "Lesser Heal" returns myUsable = 1 no matter what is targeted (party, NPC, NPC for other Faction).
I created a simple addon with the following functions; then create a macro that calls IUS_test_all().
function IUS_test_all() myClass = UnitClass("Player"); if myClass == "Priest" then IUS_TestSpell("Power Word: Shield"); IUS_TestSpell("Lesser Heal"); elseif myClass == "Paladin" then IUS_TestSpell("Blessing of Protection"); IUS_TestSpell("Holy Light"); IUS_TestSpell("Holy Shock"); end DEFAULT_CHAT_FRAME:AddMessage(" "); end
function IUS_TestSpell(mySpell) local myUsable; local myNoMana; myUsable, myNoMana = IsUsableSpell(mySpell); if myUsable == nil then myUsable = "nil" end; if myNoMana == nil then myNoMana = "nil" end; DEFAULT_CHAT_FRAME:AddMessage(" For " .. mySpell .. " myUsable = " .. myUsable .. ", myNoMana = " .. myNoMana); end |