Quantcast Spell cost - WoWInterface
Thread Tools Display Modes
03-12-18, 06:51 PM   #1
doofus
A Cyclonian
Join Date: Feb 2018
Posts: 49
Spell cost

How do I find out the cost in mana/energy/whatever of a spell? Outside of their base cost, some buffs or conditions change the cost of a spell. I typically use "IsUsableSpell("my spell");" but in this case I want to know whether I will be able to cast two different spells so I need to know their cost and then compare it to available mana. Is there an API function that might tell me?
  Reply With Quote
03-15-18, 01:05 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,616
Code:
/dump GetSpellPowerCost(2061)
{
	{
		cost = 10,
		costPercent = 3,
		costPerSec = 0,
		hasRequiredAura = false,
		minCost = 10,
		name = "MANA",
		requiredAuraID = 0,
		type = 0,
	}
}
  • Yes, that's a table inside a table
  • I assume type is the power type index (0 is MANA; see PowerTypeColor)
  • costPercent appears to be rounded up to the nearest whole percent; the character on which the above example was returned has 355 mana, and 10 / 355 = 0.028 (2.8%)

I would log into Wowpedia and add documentation there, but since the Curse/Twitch merger it's an inception-level disaster of third-party cookies and iframes, and I'm unwilling to spend any time tweaking my adblock and browser security settings to deal with it.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!

Last edited by Phanx : 03-15-18 at 01:09 AM.
  Reply With Quote
03-15-18, 06:42 AM   #3
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Originally Posted by Phanx View Post
Yes, that's a table inside a table
So, does GetSpellPowerCost actually return a nested table result? If so, would there be any reason to do so? or would it be a mistake by dev team?

Last edited by Eungavi : 03-15-18 at 08:28 AM.
  Reply With Quote
03-15-18, 03:11 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,503
According to the UI source, it's not a nested table.

ex., https://github.com/tomrus88/Blizzard...teBar.lua#L148
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-15-18, 03:14 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,616
Originally Posted by Eungavi View Post
So, does GetSpellPowerCost actually return a nested table result?
Yes, that's why I posted it.

Originally Posted by Eungavi View Post
If so, would there be any reason to do so? or would it be a mistake by dev team?
Unclear. I can't test, but maybe there's a second table for something like an enhancement shaman's Healing Surge which costs mana but can additionally consume maelstrom to become instant cast?
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
03-15-18, 03:16 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,616
Originally Posted by Seerah View Post
According to the UI source, it's not a nested table.

ex., https://github.com/tomrus88/Blizzard...teBar.lua#L148
Look again. The line you highlights assigns the returned outer table to a variable, and then the very next line loops over the inner table(s).
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
03-15-18, 06:39 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,503
You're right. I can't read.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-21-18, 03:38 AM   #8
aallkkaa
A Theradrim Guardian
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 62
Originally Posted by Phanx View Post
I assume type is the power type index (0 is MANA; see PowerTypeColor)
Just checked it for Enhancement Shaman's Stormstrike:
Code:
Dump: value=GetSpellPowerCost(17364)
[1]={
  [1]={
    hasRequiredAura=false,
    type=11,
    name="MAELSTROM",
    cost=40,
    minCost=40,
    requiredAuraID=0,
    costPercent=0,
    costPerSec=0
  }
}
Matches the values in the link you provided:
Code:
PowerBarColor[11] = PowerBarColor["MAELSTROM"];

Originally Posted by Phanx View Post
Unclear. I can't test, but maybe there's a second table for something like an enhancement shaman's Healing Surge which costs mana but can additionally consume maelstrom to become instant cast?
Also tested:
Code:
Dump: value=GetSpellPowerCost(188070)
[1]={
  [1]={
    hasRequiredAura=false,
    type=0,
    name="MANA",
    cost=48400,
    minCost=48400,
    requiredAuraID=0,
    costPercent=22,
    costPerSec=0
  }
}
Not in this case.

BUT, for a Feral Druid's Ferocious Bite:
Code:
Dump: value=GetSpellPowerCost(22568)
[1]={
  [1]={
    hasRequiredAura=false,
    type=3,
    name="ENERGY",
    cost=25,
    minCost=25,
    requiredAuraID=0,
    costPercent=0,
    costPerSec=0
  },
  [2]={
    hasRequiredAura=false,
    type=4,
    name="COMBO_POINTS",
    cost=5,
    minCost=1,
    requiredAuraID=0,
    costPercent=0,
    costPerSec=0
  }
}
EDIT: Also, the costPercent value is probably always zero unless the resource is MANA.

Last edited by aallkkaa : 03-21-18 at 03:53 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Spell cost

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