Leonardo
Leonardo

Reputation: 1901

WoW Lua - How to get the spell rank in 1.13 (Classic)

I'm trying to get the rank of a spell, but GetSpellInfo does not return the second parameter (rank). If I run:

/dump GetSpellInfo( 5782 )

I get

[1]="Fear"
[3]="136813"
[4]="1500"
[5]="0"
[6]="20"
[7]="5782"

Each combination of spell and rank seem to have a unique ID:

5185 = Healing Touch (rank1)
5186 = Healing Touch (rank2)
5187 = Healing Touch (rank3)
5188 = Healing Touch (rank4)
5189 = Healing Touch (rank5)
6778 = Healing Touch (rank6)
8903 = Healing Touch (rank7)
9758 = Healing Touch (rank8)

How do I get the spell rank given an ID?

The mod I'm working on (LunarSphere) gets a drag from the spellbook.

I'm using that with a button SetAttribute:

self:SetAttribute("*spell-S01", "Healing Touch")

For the highest rank or

self:SetAttribute("*spell-S01", "Healing Touch(rank 3)")

For a specific rank

Thanks!

Upvotes: 1

Views: 2496

Answers (1)

Beeeaaar
Beeeaaar

Reputation: 1035

They are just different spells. It makes it awkward for certain things where we tend to see them as different ranks of the same spell.

You will likely have to make a DB of the ranked spells and do a lookup in your own tables as part of the overall service provided by your addon.

https://wowwiki.fandom.com/wiki/API_GetSpellInfo

rank (string) - The rank line from the tooltip of the spell, e.g. "Rank 2". Returns some other classification (like "Summon" for a summoning spell) or an empty string if there is no rank.

So that "rank" is for just displaying the extra line in the UI, if they wanted to add one for that spell.

Like many things in the UI API, they are just there to support the UI and mostly pragmatic and just what's necessary to display or do WoW UI functionality.

local subTextOrRank = GetSpellSubtext(spellId)

This gets the display line for rank which newer engines may not return with spell info. 'GetSpellSubtext' may or may not return the rank text if the spell is cached on the client or not, or maybe you end up seeing it works every time.

I have used this spell list for quick reference in the past:

http://kyle.13th-floor.org/wow/spells/spells_2_4_0.txt

For answering many questions about the data the client has available statically:

https://wow.tools/dbc/

Here is an example of the client SpellName table from a current version of WoW Classic:

https://wow.tools/dbc/?dbc=spellname&build=1.13.3.32836#search=&page=1

Here is the Spell table from the same WoW Classic version:

https://wow.tools/dbc/?dbc=spell&build=1.13.3.32836#search=&page=1

ID, NameSubtext_lang, Description_lang, AuraDescription_lang
1
3
4
5, , Instantly Kills the target. I hope you feel good about yourself now.....
7
10, Rank 1, Ice shards pelt the target area doing $o1 Frost damage over $d.
11

Here you can see that they literally made a table of what the UI needed for display and its no more complicated or deep than that.

And if you read down the list can see or imagine it's basically done by hand, and thus can have mistakes or may have text that helps the rank description field but breaks the consistency. This is important to note that if you are going to rely on table string fields for programmatic purposes where you will need to be aware of and add exceptions to your test for rank.


You could attempt to roll through the spell list on load and build a rank list on the fly, but be aware that there are 21,000 spells in that table. If you are only worried about player spells you could make a mini pre-built list stored as a table for your own addon, and it would be a table only in the hundreds. You could have the base English name and a min and max field for rank.

I think 'GetSpellSubtext' in a loop to spit out a Lua table on your local client, in combination with the tables and rolling a small DB may break the log jam for you.

Upvotes: 1

Related Questions