WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Spell cost (https://www.wowinterface.com/forums/showthread.php?t=56092)

doofus 03-12-18 06:51 PM

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?

Phanx 03-15-18 01:05 AM

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. :(

Eungavi 03-15-18 06:42 AM

Quote:

Originally Posted by Phanx (Post 327256)
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?

Seerah 03-15-18 03:11 PM

According to the UI source, it's not a nested table.

ex., https://github.com/tomrus88/Blizzard...teBar.lua#L148

Phanx 03-15-18 03:14 PM

Quote:

Originally Posted by Eungavi (Post 327258)
So, does GetSpellPowerCost actually return a nested table result?

Yes, that's why I posted it. :p

Quote:

Originally Posted by Eungavi (Post 327258)
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?

Phanx 03-15-18 03:16 PM

Quote:

Originally Posted by Seerah (Post 327264)
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).

Seerah 03-15-18 06:39 PM

You're right. :o I can't read. :rolleyes:

aallkkaa 03-21-18 03:38 AM

Quote:

Originally Posted by Phanx (Post 327256)
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"];

Quote:

Originally Posted by Phanx (Post 327265)
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.


All times are GMT -6. The time now is 01:40 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI