• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

get mana cost

Status
Not open for further replies.
Level 1
Joined
Aug 20, 2007
Messages
2
In a trigger I need a function to be able to return (in integer or real) the mana cost value of a spell. The spell being refered can be any spell (spell cast by casting unit). What do i do?
 
Level 4
Joined
Jul 12, 2007
Messages
116
First make an dummy unit that has the spell.

  • Warlords trigger
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Unit - Set mana of Dummy unit <gen> to 100.00%
      • Unit - Order Dummy unit to Your spell
      • Wait Xcasting timeX seconds
      • Set Mana_cost = ((Integer((Max mana of Dummy unit))) - (Integer((Dummy unit))))
      • Unit - Set mana of Dummy unit to 100.00%
If you still don`t know what to do just ask. :thumbs_up:

(Mana_cost is an integer)
 
Level 4
Joined
Jul 12, 2007
Messages
116
And i would recommend to use this

  • Warlords trigger
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Dummy unit) and do (Actions)
        • Loop - Actions
          • Animation - Change (Picked unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency
trigger,

and add to your dummy unit locust.
 
Level 1
Joined
Aug 20, 2007
Messages
2
The first post answered my question, i was planning on doing it that way, I just wanted to know if there was a function for Integer values to find the exact cost of a spell without going through all of that; also making a dummy unit will force me to retool how the mechanic works for this particular spell
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Warlord's first post is (one of) the best ways to do that. Ideally, you would use a gamecache with all of the mana costs stored in it, but for GUI, the above suffices. There's no magic JASS function to get mana cost :)

Another way to do it, though, would be to set one of the ability's fields that it doesn't use (eg: Art - Area of Effect) to its value (eg "100") (must be an art field), then retrieve that value with GetAbilityEffect and I2S. However, this isn't a GUI thing, so if you don't want to muddle with JASS then Warlord's way is ideal.
 
Status
Not open for further replies.
Top