Thread Tools Display Modes
11-01-15, 12:24 PM   #1
mrlelele
A Defias Bandit
Join Date: Nov 2015
Posts: 3
IsSpellInRange

Hello everybody,

I have a little problem:

Code:
local name, rank, icon, castTime, minRange, maxRange = GetSpellInfo(51505) --(lava burst)

inRange = IsSpellInRange(name, "target")


print(inRange)
Some spells work fine but some spells like lava burst only return "nil".

Why wont some Spells work?


Thanks and Greetings
mrlelele

Last edited by mrlelele : 11-01-15 at 08:34 PM.
  Reply With Quote
11-01-15, 07:54 PM   #2
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Check IsSpellInRange.

Normally, if you don't have a target or wrong type target, the action button shouldn't be shown as out of range. So, 0-1-nil three values would be more useful.
  Reply With Quote
11-01-15, 08:42 PM   #3
mrlelele
A Defias Bandit
Join Date: Nov 2015
Posts: 3
edited to be more clear.
  Reply With Quote
11-02-15, 05:56 AM   #4
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
I test it in the game, seems the IsSpellInRange("name", "unit") doesn't work anymore, only IsSpellInRange(index, "bookType", "unit") can be used.

Here is the code

Lua Code:
  1. local i = 1
  2.  
  3. while select(2, GetSpellBookItemInfo(i, "spell")) ~= 51505 do
  4.     i = i + 1
  5. end
  6.  
  7. print(IsSpellInRange(i, "spell", "target"))

Well, I should go to update my lib now, blz just care their "action" type buttons.
  Reply With Quote
11-02-15, 06:27 AM   #5
mrlelele
A Defias Bandit
Join Date: Nov 2015
Posts: 3
Thumbs up

Originally Posted by kurapica.igas View Post
I test it in the game, seems the IsSpellInRange("name", "unit") doesn't work anymore, only IsSpellInRange(index, "bookType", "unit") can be used.

Here is the code

Lua Code:
  1. local i = 1
  2.  
  3. while select(2, GetSpellBookItemInfo(i, "spell")) ~= 51505 do
  4.     i = i + 1
  5. end
  6.  
  7. print(IsSpellInRange(i, "spell", "target"))

Well, I should go to update my lib now, blz just care their "action" type buttons.
Thanks for the answer and good to know.

Have a nice day.
  Reply With Quote
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
07-09-18, 01:00 AM   #7
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
Replying to my own question I think I have an answer as to why IsSpellInRange does not work with Swipe and Thrash and returns -1.

I think the reason is because Swipe and Thrash are not-targetted spells and therefore can be cast without a target, so the game does not make the calculation until and unless you do cast the spell, and then and only then will it check to see if you damage the target(s). But you cannot find out before hand whether casting Swipe/Thrash will actually damage the target(s).

The situation gets much more complex with the talent Balance Affinity which extends the range of your spells by 5 yards, [Luffa Wrappings] which extends Thrash's reach by 25%, [Ekowraith, Creator of Worlds] which increases the Balance Affinity by 75%!

For example to complete the mage Tower challenge (in 2 or 3 tries I think) I had: Mangle at 14 yards, Swipe at 17 yards and Thrash at 21 yards !!!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » IsSpellInRange

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off