• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] How would I call the mana cost of a spell?

Status
Not open for further replies.
Level 1
Joined
Sep 6, 2008
Messages
2
I recently started using JASS for triggering, and I want to make a passive that heals the hero for a % of the mana cost of the spell. However, I can't seem to find a function (I checked the API on sourceforge.net, although there's a good chance that I was looking in the wrong place) that would call the mana cost of the spell, and I would hate to have to go through and have to make a separate function for each level for each possible spell being cast.

For reference, I currently have this.

Code:
function Trig_Magic_Mastery_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'E000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Magic_Mastery_Actions takes nothing returns nothing
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( 0.75 * 1 ) ) )
    call SetUnitManaBJ( GetTriggerUnit(), ( 
endfunction

//===========================================================================
function InitTrig_Magic_Mastery takes nothing returns nothing
    set gg_trg_Magic_Mastery = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Magic_Mastery, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Magic_Mastery, Condition( function Trig_Magic_Mastery_Conditions ) )
    call TriggerAddAction( gg_trg_Magic_Mastery, function Trig_Magic_Mastery_Actions )
endfunction

But I want to replace the 1 with the mana cost of the spell.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Nope. It is rather simple.
I will go through the basics:
For your passive ability make 2 triggers.
First one should have the event a unit begins casting an ability, condition should check if the casting unit has your passive ability, actions should store* the current mana of the triggering unit.
Second trigger should have the event a unit finishes casting an ability, condition should check if it has your passive ability, actions should substract the hero's current mana from the stored amount. Then do whatever you want with that amount.
* How to store is up to you. Game Cache is the simplest way to do it. But be careful with using Gama cache. First make sure you know everything you need to know about it
 
Status
Not open for further replies.
Top