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

[Solved] Trigger cooldown of an abiliy

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
I want to make an ability based off of searing arrow with a 15 second cooldown. The problem is if u hit stop and let the hero auto attack the units, the cooldown will not trigger. Is there a way to manually run the cooldown? was experimenting with ways to disable autocast, but none of them worked. (If theres a way to disable autocast, that'd work too)

(I need searing arrow because its the only ability that deals weapon-based damage and applys a buff)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
there is way to do it even in GUI and in Jass very easily, but I dont know the order Ids and Im not going to find them, also didnt find nestharus' library which has those :/

You can just detect the order of Autocast On for the ability, and then Issue the unit to autocast off(it should be autocaston + 1 for ID) and that should turn the ability off
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
You can just detect the order of Autocast On for the ability, and then Issue the unit to autocast off(it should be autocaston + 1 for ID) and that should turn the ability off

tried and never worked

JASS:
function Trig_No_Autocast_Fierce_Blow_Conditions takes nothing returns boolean
    if GetIssuedOrderId() == OrderId("coldarrows") or GetIssuedOrderId() == OrderId("corporealform")  then
        return true
    endif
    return false
endfunction

function Trig_No_Autocast_Fierce_Blow_Actions takes nothing returns nothing
    call IssueImmediateOrder( GetTriggerUnit(), "uncoldarrows" )
    call IssueImmediateOrder( GetTriggerUnit(), "uncorporealform" )
    endfunction

//===========================================================================
function InitTrig_No_Autocast_Fierce_Blow takes nothing returns nothing
    set gg_trg_No_Autocast_Fierce_Blow = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_No_Autocast_Fierce_Blow, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( gg_trg_No_Autocast_Fierce_Blow, Condition( function Trig_No_Autocast_Fierce_Blow_Conditions ) )
    call TriggerAddAction( gg_trg_No_Autocast_Fierce_Blow, function Trig_No_Autocast_Fierce_Blow_Actions )
endfunction
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Ive tested it, you must delay it, here is what Ive done:

JASS:
scope Test initializer init
    
    globals
        private hashtable hash = InitHashtable()
    endglobals
    
    private function onExpire takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local unit u = LoadUnitHandle(hash, GetHandleId(t), 0)
        call IssueImmediateOrderById(u, 852175)
        set u = null
        call FlushChildHashtable(hash, GetHandleId(t))
        call DestroyTimer(t)
        set t = null
    endfunction

    private function handler takes nothing returns boolean
        local timer t
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 15, I2S(GetIssuedOrderId()) + "\n")
        if GetIssuedOrderId() == 852174 then
            set t = CreateTimer()
            call SaveUnitHandle(hash, GetHandleId(t), 0, GetTriggerUnit())
            call TimerStart(t, 0., false, function onExpire)
        endif
        set t = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
        call TriggerAddCondition(t, Condition(function handler))
        set t = null
    endfunction

endscope

works every time

for shortage of time, I couldnt import anything like TimerUtils, but you can do it

852174 is ID for searingarrowson, 852175 is for off
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Ive tested it, you must delay it, here is what Ive done:


works every time

for shortage of time, I couldnt import anything like TimerUtils, but you can do it

852174 is ID for searingarrowson, 852175 is for off

Thanks, works great! (though i had to change it because i said i used searing arrows but im using cold arrows, but no proble, 852244/852245)
 
Status
Not open for further replies.
Top