• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Artifact cooldown

At least during one time you had to give the item an unit ability to show the cooldown and the ability needed to be
first on the list in the Object editor for the active ability and display cooldown to work.
 
Code:
function UseRingOfLuck takes unit u returns nothing
    local integer i = 0
    local item it
    loop
        exitwhen i >= 6
        set it = UnitItemInSlot(u, i)
        if it != null and GetItemTypeId(it) == 'RLUC' then
            call UnitUseItem(u, it)
            return
        endif
        set i = i + 1
    endloop
endfunction

OK this works.
But how can i make artifact non-clickable.
I want to invoke artifact cooldown with jass only
 
Code:
function UseRingOfLuck takes unit u returns nothing
    local integer i = 0
    local item it
    loop
        exitwhen i >= 6
        set it = UnitItemInSlot(u, i)
        if it != null and GetItemTypeId(it) == 'RLUC' then
            call UnitUseItem(u, it)
            return
        endif
        set i = i + 1
    endloop
endfunction

OK this works.
But how can i make artifact non-clickable.
I want to invoke artifact cooldown with jass only
This seems overly complicated. Why not just use Object Editor ability cooldown then use a simple trigger to start the cooldown? Then you can still invoke the artifact ability with this JASS code, I suppose.
 
Since units gain items' abilities upon picking item, you can start cooldown for an ability on the unit and it will show on the item.
For example: Health Stone. It's ability is "Item Healing (Greater)" so doing the following will put the ability on cooldown and the cooldown will display on the Health Stone item:
  • Unit - For Unit some_unit, start cooldown of ability Item Healing (Greater) " over "10.00 seconds.
 
This seems overly complicated. Why not just use Object Editor ability cooldown then use a simple trigger to start the cooldown? Then you can still invoke the artifact ability with this JASS code, I suppose.
You can make your artifact non‑clickable by unchecking Usable in the Object Editor (Stats-Actively Used=false ). This prevents players from clicking it, but UnitUseItem will still work.

Then you can create a dummy ability based on channel with the desired CD. Then you can either hide it in a spellbook or change its position to -1 if that is what you aim for. If you do want it visible, place it in a spellbook on your UI – the cooldown swirl will appear there.

In your JASS function, before using the item, check if that ability is off cooldown. If yes, use the item and then manually start its cooldown.

But why would u go on this type of overkill lol :vw_death:

JASS:
function UseArtifact takes unit u returns nothing
    local integer i = 0
    local item it
    local integer abilId = 'A000' // rawcode of your dummy ability

    // Check cooldown
    if BlzGetUnitAbilityCooldownRemaining(u, abilId) > 0 then
        return   // still on cooldown
    endif

    loop
        exitwhen i >= 6
        set it = UnitItemInSlot(u, i)
        if it != null and GetItemTypeId(it) == 'yourItemID' then
            call UnitUseItem(u, it)            // activates the artifact
            call BlzStartUnitAbilityCooldown(u, abilId, 60.0) // start cooldown
            return
        endif
        set i = i + 1
    endloop
endfunction
 
Works well! Thank you guys!

Now, how can I achieve a similar thing for the normal hero ability?
I want ability to be non-clickable kinda passive. But i want to trigger its cooldown via triggers so that the countown timer is visible...
You can’t really make a passive show cooldown, but a "clean" workaround is to use two abilities with the same icon. Keep the real one as passive, and swap it with a dummy active ability when it procs. Start the cooldown on the dummy, then swap back when it finishes. That way the player sees the cooldown but can’t interact with it. And then in jass you'll need timers + some way to track each unit (hashtable/indexing) so it doesn’t break with multiple heroes xd
 
You can’t really make a passive show cooldown, but a "clean" workaround is to use two abilities with the same icon. Keep the real one as passive, and swap it with a dummy active ability when it procs. Start the cooldown on the dummy, then swap back when it finishes. That way the player sees the cooldown but can’t interact with it. And then in jass you'll need timers + some way to track each unit (hashtable/indexing) so it doesn’t break with multiple heroes xd
Another idea is maybe i can make ability disabled. Then enable and start a timer and then disable back.
 
Placing a floating text right over the ability button on the UI if that is what you want, that's tricky because you can't get the screen coordinates of the button from triggers without custom UI frames (BlzCreateFrame). You could approximate it with a fixed offset on the screen, but it's messy. I would stick to simpler solutions, a simple floating text above the hero is much easier.
 
Back
Top