API Change Request: Static Spell IDs

#0 - Aug. 3, 2007, 5:33 a.m.
Blizzard Post
Hello folks (mainly Slouken),

I'd like to make the suggestion that static spell IDs be implemented.

First, I'll discuss a couple of problems with the current implementation and why I believe static spell IDs are warranted. After that, I'll provide a couple of possible solutions that would be completely backwards compatible as to not break all the current code.

The first major problem is one of localization. When an addon is looking for a particular spell name, it has to provide that spell name in every language. A library to cache every spell name in every language is easily on the order of 10,000 lines and somewhere in the neighborhood of 800k memory. That's more memory than many entire addons take for something that is surely already available to the client.

The ability to call spell information functions such as GetSpellName() with a static spell ID and having it return the localized spell name would be fantastic as it would get rid of the need to have such large libraries as previously mentioned.

Another issue is with spell textures. Due to the way the current dynamic spell ID system works, you can only get textures for spells that are in your spell book. So, as it stands now, if you want to obtain spell textures for spells that you don't have in your book, you have to resort to maintaining a table of spell name to texture mappings. This eats up even more memory.


In the same manner that you can be assured itemid:6265 is a soul shard on any language client, it would be immensely useful to be able to say spellid:10540 is spell X(Rank y) regardless of the client's language.

2.0 added a step in the right direction with allowing you to specify the spell name directly in most of the API calls, however this leaves the problem of localization.


One possible backward compatible solution is to do something like start all static spell IDs at say 10,000 which should be well above the current range of dynamic spell IDs. Then the API functions could simply do a check to see if the spell ID is a dynamic one (old method) or a static one (new method).


Examples:
-- Since these spell IDs are greater than 10000 the APIs would know you are passing a
-- static spell ID and not a dynamic one from your spell book.
local start, duration, enable = GetSpellCooldown(10540)
local texture = GetSpellTexture(10540)



Another possible backwards compatible solution would be to take a string in the form of "spellid:x" just like the item id functions work.


Example:
local start, duration, enable = GetSpellCooldown("spellid:10540")
local texture = GetSpellTexture("spellid:10540")



If any of you other authors authors out there can see a usefulness for this, or have other suggestions, please feel free to contribute.

Thanks for taking the time to consider this suggestion.


Edited for clarity.
#3 - Aug. 4, 2007, 8:55 p.m.
Blizzard Post
Something like this is on the TODO list for a future patch. Thanks!