Thread: IsSpellInRange
View Single Post
07-07-18, 04:33 AM   #6
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
Post

This is an old post but am also having some difficulties with IsSpellInRange(mySpell,"target"). Particularly following a change of spec, many times, IsSpellInRange("Mangle","target") or IsSpellInRange("Swipe","target") return 0 (or nil, either).

This is fixable with a logout and log back in. No other changes and then it magically works again. I had big trouble with "Swipe" (Druid Guardian), "Zeal" (Paladin) etc. It may have to do with talents because it does happen right after you swap specs.

Looking at the code above, it is not easy to get the ID of a spell. Casting "Swipe" in Bear form says that my cast spell was "Swipe" id:213771. However, enumerating the spells in the spell book reveals "Swipe" at
index 55 with an ID of 213764. And looking for "Swipe" in the spell book returns nil, you have to look by index.


local spellName, spellSubname = GetSpellBookItemName(i, BOOKTYPE_SPELL);

with i=55 returns "Swipe" and ""
with "Swipe" returns nil


local _, spellBookSwipeId = GetSpellBookItemInfo("Swipe" or 55, BOOKTYPE_SPELL);

returns nil with "Swipe" and 213764 for 55 (and not 213771 which is what I actually cast)

I would use the IsSpellInRange(55, "spell", "target") in this roundabout way, but even that returns nil.

In the meantime IsSpellInRange(37/"Mangle", "spell", "target") returns 0 for when not in range, ie "Mangle" works correctly either by text or by ID.

Therefore it seems another way is needed to determine if I am in range of Swipe (and Thrash) and other spells.
  Reply With Quote