Posted by marshbum on Sun, 12 Dec 2010 14:25:58
My Addon, "Noob report", tries to keep track of when you gain a level, and gives you an on-screen propmt IF you need to visit your class trainer to learn new spells. This helps new players remember to visit their class trainer.
With the release of Cataclysm (and the patch that changed the world), character's no longer train in a steady pattern of every other level.
The method I employed prior to the new release was to keep track of your level (odd or even) and just remind you to train upon gaining an even level. That is not accurate now.
I think I need to use a combination of UNITLEVEL and SPELLSCHANGED but I have noticed that you can gain spells in your book without visiting your class trainer in some cases. So SPELLS_CHANGED is not fool proof either as an indicator to go visit your trainer.
I was wondering first if there may be a new "event" that may have come out for Cataclysm related to leveling or your spell book (or a complete list of new events) that could help with this task. Otherwise, I would be interested to hear if anybody has an idea of how to accomplish this now.
Thanks in advance for the thoughts and info.
Posted by marshbum on Sun, 12 Dec 2010 14:27:19
SO SORRY for the repeat posts :( IE was burping on me. Please forgive me.
Posted by Cladhaire on Sun, 12 Dec 2010 19:45:13
I would look at the spellbook FrameXML code. When there is a new spell to be learned, its shown in the spellbook and there's a border around it to show that there is something that needs to be learned (or at least its coloured differently).
As far as I am aware, you will not have a new spell become unlocked via any means other than levelling, since talents give you the spell automatically. You could use the level up event, and then scan the spellbook to see if there are any spells that are available but not learned.
Posted by marshbum on Sat, 18 Dec 2010 17:55:55
Thanks to the feedback on this post and some reserach, I have a method that is working well. Used a combination of
GetSpellBookItemInfo(). Here is a snipet of code in case anyone is interested:
if event == "SPELLS_CHANGED" or event == "UNIT_LEVEL" then -- This will loop through all spellbook tabs and all spell slots look to see if there is something to learn from your class trainer. for i = 1, 4 do local _, _, spellSlotOffset, numSlots = GetSpellTabInfo(i); for ii = spellSlotOffset+1, spellSlotOffset+numSlots do local spellLevel = GetSpellAvailableLevel(ii, "spell"); local spellType, _ = GetSpellBookItemInfo(ii, "spell"); if spellLevel <= PLAYER_LEVEL and spellType == "FUTURESPELL" then NEEDS_TO_TRAIN = 1; return; end end end end
Posted by jnwhiteh on Sun, 19 Dec 2010 00:42:05
To be 'correct', you should really use the GetNumSpellbookTabs or whatever that function is, making your code a bit more future proof. Anytime you have 'magic' constants like '4' in your code, its best to figure out how or where those are defined.
Posted by marshbum on Mon, 20 Dec 2010 10:11:41
Excellent point and good catch. I guess I was so excited about getting this resolved, I took a shortcut that could end up biting me. I will make that change, and thanks for pointing it out.