Thread Tools Display Modes
07-19-14, 11:35 AM   #1
LeoChen1216
A Defias Bandit
Join Date: Jul 2014
Posts: 3
GetSpellInfo changes in WOD beta

It seems Blizzard changed the return values for GetSpellInfo.
It used to be:
Code:
name, rank, icon, powerCost, isFunnel, powerType, castingTime, minRange, maxRange = GetSpellInfo(...)
Now, the "powerCost, isFunnel, powerType" values are removed. Does anyone know if there is any other API I can call to get these values?

Code:
name, rank, icon, castingTime, minRange, maxRange = GetSpellInfo(...)
 
07-19-14, 10:02 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can use tooltip scanning. Set the spell to a tooltip, and then look at the text in the tooltip. Do a forum search if you need examples; I know there are tons, but I'm too lazy to find them for you right now.

Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
 
07-20-14, 11:17 PM   #3
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
I noticed another oddity with GetSpellInfo. When you call it in WoD with an invalid Spell ID it returns a table of 3 empty strings, while the current live (5.4) returns nil.
 
07-21-14, 12:37 AM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Phanx View Post
Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...
arg2 is no longer rank, it's "spellSubName":
https://github.com/tekkub/wow-ui-sou...rnal.lua#L2291

Oddly enough, the old return values are still present in some code in the latest build, although not used (shaman totem bar):
https://github.com/tekkub/wow-ui-sou...Frame.lua#L963

Last edited by p3lim : 07-21-14 at 12:47 AM.
 
07-21-14, 01:29 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by p3lim View Post
Oddly enough, the old return values are still present in some code in the latest build, although not used (shaman totem bar):
https://github.com/tekkub/wow-ui-sou...Frame.lua#L963
It's not odd at all that they didn't bother updating that code, since the shaman totem bar was removed from the game with the launch of Cataclysm.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
 
07-21-14, 05:30 AM   #6
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Phanx View Post
It's not odd at all that they didn't bother updating that code, since the shaman totem bar was removed from the game with the launch of Cataclysm.
They did update it to the new 1/nil true/false changes to :SetChecked(), but they might have automated that with a script or something.
 
07-21-14, 06:49 PM   #7
LeoChen1216
A Defias Bandit
Join Date: Jul 2014
Posts: 3
Originally Posted by Phanx View Post
You can use tooltip scanning. Set the spell to a tooltip, and then look at the text in the tooltip. Do a forum search if you need examples; I know there are tons, but I'm too lazy to find them for you right now.

Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...
great, thank you!
 
07-22-14, 12:16 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That's a lot of unnecessary overhead...

Code:
local name, some, other, vars, here = GetSpellInfo(12345)
if name and name ~= "" then
    -- carry on
end
Adding a simple equality check is a much better solution than adding two function calls.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
 
10-11-14, 11:17 AM   #9
jlam
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 29
Originally Posted by Phanx View Post
You can use tooltip scanning. Set the spell to a tooltip, and then look at the text in the tooltip. Do a forum search if you need examples; I know there are tons, but I'm too lazy to find them for you right now.

Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...
I'm searching for a way to do this that's locale-independent. The tooltip has the information in a consistent place, but the format of that line differs between locales and also has to deal with singular/plural variations. I'm mostly struggling with the singular/plural part of it. Are there existing examples of getting this spell cost information from the tooltip?
 
10-12-14, 01:05 AM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The common texts in tooltips (X mana, Y rage, Z energy, etc.) all use strings from GlobalStrings.lua, so you can just pick out the strings (Blizzard uses them with string.format) and convert them for use with string.match.

For example, the "X mana" string is contained in the global variable MANA_COST, and I use the following code to make spell tooltips show the mana costs of spells as a percent of my total mana pool instead of as a raw number; the lines I highlighted in green will be the most relevant for you.

Code:
	local MANA_COST_PATTERN = gsub(MANA_COST, "%%d", "([%%d%.,]+)")
	local MANA_COST_TEXT = gsub(MANA_COST, "%%d", "%%d%%%%")

	GameTooltip:HookScript("OnTooltipSetSpell", function()
		for i = 2, 4 do
			local line = _G["GameTooltipTextLeft"..i]
			local text = line:GetText()
			if text then
				local cost = strmatch(text, MANA_COST_PATTERN)
				cost = cost and tonumber((gsub(cost, "%D", "")))
				if cost then
					local pool = UnitPowerMax(UnitInVehicle("player") and "vehicle" or "player")
					if cost > 0 and cost <= pool then
						return line:SetFormattedText(MANA_COST_TEXT, cost / pool * 100 + 0.5)
					end
					return
				end
			end
		end
	end)
Edit: You will need to do a little more work to "patternize" strings with singular/plural variations, but you should be able to figure it out pretty easily by looking at the global strings for each locale (link above).
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 10-12-14 at 01:25 AM.
 
10-12-14, 01:56 AM   #11
jlam
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 29
Ah, having GlobalStrings.lua for all locales will make this easier. Thanks for the link.
 
 

WoWInterface » Site Forums » Archived Beta Forums » WoD Beta archived threads » GetSpellInfo changes in WOD beta

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