Timer not starting?

Matemeo

New Member
Reaction score
20
I have this here code.

JASS:
scope ImpaleMadness

    globals
        private constant integer SPELL_ID = 'A003'
        private constant integer DUMMY_ID = 'n001'
        private constant integer IMPALE_ID = 'A004'
        unit caster
        integer ticks
    endglobals

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction
    
    private function callback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local real Cx = GetUnitX(caster)
        local real Cy = GetUnitY(caster)
        local real Rx = Cx + GetRandomReal(1.0,400.0) * Cos(GetRandomReal(0,360.0))
        local real Ry = Cy + GetRandomReal(1.0,400.0) * Sin(GetRandomReal(0,360.0))
        local unit dummy = CreateUnit(GetOwningPlayer(caster),DUMMY_ID,Cx,Cy,270.0)
        
        call BJDebugMsg("inside of callback")
        call UnitAddAbility(dummy,IMPALE_ID)
        call UnitApplyTimedLife(dummy,'BTLF',1.0)
        call IssuePointOrder(dummy,"impale",Rx,Ry)
        
        set ticks = ticks - 1
        
        if ticks <= 0 then
            call BJDebugMsg("ticks <= 0, destroying timer")
            call PauseTimer(t)
            call DestroyTimer(t)
        endif
        
        set t = null
        set dummy = null
    endfunction

    private function Actions takes nothing returns nothing
    local timer t = CreateTimer()
    call BJDebugMsg("Inside of actions, condition was passed")
    set ticks = 10
    call TimerStart(t, .5, true, function callback)
    
    endfunction

    //===========================================================================
   public function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition(t, Condition( function Conditions ) )
        call TriggerAddAction(t, function Actions )
    endfunction
endscope


I placed BJDebugMsg's to check how far it gets. I get a, "inside of actions, condition passed" message, but nothing else after that. I'm almost positive I did this right, and I've never had this happen before. :eek: Any thoughts? It's really bugging me.

Thanks in advance.
 

gref

New Member
Reaction score
33
Nothing I can see that wouldn't at least let you see the second message...

Reopen World Editor? Every now and then I get a situation which just doesn't work even when the code is correct, and I reopen and it works.
 

Matemeo

New Member
Reaction score
20
I've reopened a few times, just to see if that was it.

Yeah...it should at least print callback once:confused:
 

Matemeo

New Member
Reaction score
20
Although your InitTrig function shouldn't be public.

Why not? Been told to do it that way by Cohadar, not a nice guy to disagree to, hehe :D.

Plus, it's always worked before (5-10 custom spells)

EDIT: In fact, I just tested without public prefix, and it wont even show first message now.
 

Tom Jones

N/A
Reaction score
437
You properly haven't changed the GUI trigger name after removing the public keyword.
 

Matemeo

New Member
Reaction score
20
It fails because caster isn't set.

Badass, ok, works now.

Didn't realize I hadn't set caster :banghead:

I'm assuming when I tried to get the UnitX of a nulled unit, it just decided to die, and exit. (Am I close? hehe)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top