• 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.

Check if Spell is off Cooldown

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2011
Messages
460
So, is there any way for me to do this? I need a way to check if any/all of a specific unit's hero spells are off or on cooldown. Any ideas?
Edit: Just had a thought. When one of the spells is cast I can start a timer that has the length of the spell's duration and check if that timer expired. I'll try and whip something up, unless someone has a system like this laying around on their HD or is bored and want's to do it (please jass/vJass, otherwise nu :p).
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Mmmm yeah, I think the timer option is the best. Another way would be creating a dummy with an expiration timer and checking if the unit is alive.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You could basically save all the abilities into a variable array and set their = to the cooldown. With another function start a timer on ability cast based on that ability. Most vJassers do it all the time with anything :p

-Kobas- made an Ability Level Up system that woks in a real similar way.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
A great way to learn is checking how other spells are implemented, and how they work. Move a value here and there... And moving on from there.
 
A timer loop with dynamic indexing... I never said you cannot use it in JASS/vJASS... you can learn it in GUI then port it in vJASS if you really need a tutorial for it... or take a look at vJASS spells that use dynamic indexing...

it would also be better if you use dynamic indexing + maybe hashtable [just to save the indexes used by a unit] for easier retrieval of data...
 
In vJASS we usually use timer systems because they are the easiest to deal with. You can also do indexing, but with timer systems you have that ease of modification and it is overall a lot easier to understand.

To learn more about timers and vJASS, I highly recommend this tutorial:
http://www.thehelper.net/forums/showthread.php/162408-How-to-Use-Timers-in-JASS

It is a bit outdated because it doesn't have CTL and that jazz, but those systems all work 100% and are still used in several systems created today.
 
Level 9
Joined
Apr 23, 2011
Messages
460
I read through some other scripts and was able to create this, but it's most likely 70% wrong.
This doesn't really have much to do with cooldowns, but it's the structure i'm using for dynamic indexing. Sorry for any confusion. Cooldowns come later.
JASS:
library AxelBoost
    struct AxelBoost extends array
        private static integer spell = 'axel'
        private static unit array Caster
        private static integer heroType = 'omiz'
        private static integer AtkNeed = 5
        private static integer array Attacks
        private static real array Stun 
        private static real array boost 
        /*
        *   Dynamic Indexing Variables
        */
        private static integer array rn
        private static integer ic = 0
        
        /*
        *   Dynamic Indexing Functions
        */
        private static method allocate takes nothing returns thistype
            local thistype this = rn[0]
            if this == 0 then
                set ic = ic + 1
                set thistype.Attacks[this] = 0
                set .Caster[this] = GetTriggerUnit()
                set Stun[this] = GetUnitAbilityLevel(Caster[this], spell)
                set .boost[this] = GetUnitAbilityLevel(Caster[this], spell)
                return ic
            endif
            set rn[0] = rn[this]
            return this
        endmethod
        
        private method deallocate takes nothing returns nothing
            set rn[this] = rn[0]
            set rn[0] = this
        endmethod
        
        private static method AxelBuff takes thistype this returns nothing
        endmethod
        
        /*
        *   Attack Counter
        */
        private static method CountAttack takes thistype this returns nothing
            if GetUnitTypeId(GetAttacker()) == heroType then
                if Attacks[this] == AtkNeed then
                    call AxelBuff(this)
                    return
                endif
                set Attacks[this] = Attacks[this] + 1
            endif
        endmethod
    endstruct
endlibrary
 
Status
Not open for further replies.
Top