Channeling Not Working

NeuroToxin

New Member
Reaction score
46
Okay, so heres my spell:
The Witch Doctor can channel for 120 seconds to gain +5 attributes to all stats; since the Witch Doctor can gather souls, each soul reduces the channel time by 10 seconds. My problem? It doesn't work. At all, and my channel ability only needs one level. Heres my code
JASS:

scope Attributegain initializer Init
    globals
        private timer ChannelTime = CreateTimer()
        private integer TimeLeft = 120
        private boolean FinishedCast = false
        private unit Caster = null
    endglobals
    
    private function ReduceTime takes nothing returns nothing
        if TimeLeft <= 1 then
            call SetHeroAgi( Caster, GetHeroAgi(Caster, false) + 5, true)
            call SetHeroStr( Caster, GetHeroStr(Caster, false) + 5, true)
            call SetHeroInt( Caster, GetHeroInt(Caster, false) + 5, true)
            set FinishedCast = true
            call PauseTimer(ChannelTime)
            call IssueImmediateOrder( Caster, "Stop")
            set TimeLeft = 120
        else
            set TimeLeft = TimeLeft - 1
        endif
    endfunction

    private function StartSpell takes nothing returns boolean
        if GetSpellAbilityId() == 'A01L'  and FinishedCast == true then
            set Caster = GetTriggerUnit()
                if COUNT > 12 then
                    set COUNT = COUNT - 12
                    set TimeLeft = 1
                elseif COUNT < 12 then
                    set TimeLeft = TimeLeft - (COUNT * 10)
                    set COUNT = 0
                endif
            call TimerStart( ChannelTime, 1, true, function ReduceTime)
        elseif GetSpellAbilityId() == 'A01L' and FinishedCast == false then
            call TimerStart( ChannelTime, 1, true, function ReduceTime)
        endif
        return false
    endfunction
    
    private function CancelSpell takes nothing returns boolean
        if GetTriggerUnit() == Caster then
            call PauseTimer(ChannelTime)
        endif
    return false
    endfunction
    //===========================================================================
    function Init takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition( t, Condition(function StartSpell))
        
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
        call TriggerAddCondition( t, Condition(function CancelSpell))
    endfunction
endscope
 

BlackRose

Forum User
Reaction score
239
Did you actually try debugging it yourself? Perhaps by checking of Caster had a value assigned to it or checking the value of "TimeLeft" in the timer callback function?

Anyways, seeing as you initialize the boolean "FinishedCast" as false, the first spell instance will run this following piece of code:

JASS:
        elseif GetSpellAbilityId() == 'A01L' and FinishedCast == false then
            call TimerStart( ChannelTime, 1, true, function ReduceTime)
        endif


What's bad? In your "ReduceTime" function, you reference Caster like so:

JASS:
.
    private function ReduceTime takes nothing returns nothing
        if TimeLeft <= 1 then
            call SetHeroAgi( Caster, GetHeroAgi(Caster, false) + 5, true)


Your variable "Caster" is not defined. Therefore, nothing happens.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top