Timer Not Starting?

Expelliarmus

Where to change the sig?
Reaction score
48
JASS:
private struct Data 
    unit caster
    group dummy
    real speed
    
    static method create takes nothing returns Data
        local Data d = Data.allocate()
        set d.caster = GetTriggerUnit()
        set d.dummy = CreateGroup()
        
        return d
    endmethod
endstruct

globals    
    private timer time = CreateTimer()
    private integer Total = 0
    private Data array Ar
    private boolean Boolean = false
    private group Nothing = CreateGroup()
    private unit Temp_Unit = null
    private unit FoG = null
endglobals

function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == AbilID
endfunction

function Stun takes nothing returns boolean
    local unit u = GetFilterUnit()
    local unit d

    if not Boolean and IsUnitEnemy(u, GetOwningPlayer(Temp_Unit)) == true  then
     
        set Boolean = true
        set d = CreateUnit(  GetOwningPlayer(Temp_Unit),  DummyCID, GetUnitX(u), GetUnitY(u), bj_UNIT_FACING )
        call UnitApplyTimedLife( d, Generic, 1.00 )
        call UnitAddAbility( d, StunID  )
        call IssueTargetOrder( d, Order, u )
    endif
    set u = null
    return false
endfunction

function handlerFunc takes nothing returns nothing
    local Data d 
    local integer i = 0
    local real x
    local real y
    local real xx
    local real yy
    local real angle
    local group dummy = CreateGroup()
    set Temp_Unit = d.caster
    call BJDebugMsg("callback") //not at all showing this
    loop
        exitwhen i >= Total
            set d = Ar<i>
            call GroupAddGroup(d.dummy, dummy)    
                
                loop
                    set FoG = FirstOfGroup(dummy)
                    set Boolean = false
                    exitwhen FoG == null
                    call GroupRemoveUnit(dummy, FoG) 
                    set xx = GetUnitX(FoG)- GetUnitX(Temp_Unit)
                    set yy = GetUnitY(FoG) - GetUnitY(Temp_Unit)
                    set angle = Atan2(yy,xx) + Increment * bj_DEGTORAD
                    debug call BJDebugMsg(R2S(angle))
                // movement
            
                    set x = GetUnitX(d.caster) + Distance * Cos(angle )
                    set y = GetUnitY(d.caster) + Distance * Sin(angle )
                    call SetUnitPosition(FoG, x, y)
            
                // Stun
                    call GroupEnumUnitsInRange(Nothing, GetUnitX(FoG), GetUnitY(FoG), Radius, Condition(function Stun))
                        if Boolean then
                            call KillUnit(FoG)
                            call GroupRemoveUnit(d.dummy, FoG)
                        endif
                endloop
        set i = i + 1
        call BJDebugMsg(I2S(i))
    endloop
    
    if Total - 1 == 0 then
          call PauseTimer(time)
    endif
    
    set FoG = null
    set Temp_Unit  = null
    call DestroyGroup(dummy)
    set dummy = null
endfunction

function Actions takes nothing returns nothing
    local Data d = Data.create()
   
    local integer i  = 1
    local real angle
    local real x
    local real y
    local unit dummy
 
    set d.speed = 360.0 / Rocks(GetUnitAbilityLevel( d.caster, AbilID))
    
    loop
        exitwhen i &gt; Rocks(GetUnitAbilityLevel( d.caster, AbilID)) 
        set angle =  i * d.speed 
        set x = GetUnitX(d.caster) + Distance * Cos(angle * bj_DEGTORAD)
        set y = GetUnitY(d.caster) + Distance * Sin(angle * bj_DEGTORAD)
        set dummy = CreateUnit( GetOwningPlayer(d.caster), DummyID, x, y, angle )
        call UnitApplyTimedLife( dummy, Generic , Duration )
        call SetUnitPathing(  dummy, false )
        call GroupAddUnit( d.dummy, dummy)
        
        set i = i + 1
    endloop
    
    set Total = Total + 1
    set Ar[Total - 1] = d
    
    if Total - 1 == 0 then
          call TimerStart(time, Interval, true, function handlerFunc)
          call BJDebugMsg(&quot;First instance timer&quot;)
    endif
    
endfunction</i>


thanks
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
put a debug message that tells you the value of "total" then you will know if the comparasion is true or false.
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
You actully compare if Total - 1 is is the same value as 0. Therefore a comparasion.

What you should do is comparing if Total - 1 == 0.
So, print out the value of Total - 1 and then you will see if your if will return true or false.
 

Artificial

Without Intelligence
Reaction score
326
JASS:
local Data d 
[...]
set Temp_Unit = d.caster
That's from the callback function. You've never set d to anything before using it.
And you really should tell a bit more when wanting help with some code. It would've eg. been nice to know earlier whether "First instance timer" displays or not, as that kinda determines where to look for the mistake... :p

Edit: @Gwy below:
> Arti he actully sets it in his create method
d isn't pointing to anything in the callback function before it's used. That hasn't got anything to do with the create method. ^_^
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
try setting d.caster in the action trigger instead of the create method.

Null values sometimes makes the thread crash.

Edit: Arti he actully sets it in his create method :p Btw Arti, get on the chat :p
 

Expelliarmus

Where to change the sig?
Reaction score
48
isn't that much of a problem description
true, true, =P
That's from the callback function. You've never set d to anything.
- But shouldn't the DebugMsg run in the callback? There's no condition for it to run.
- I set d in the loop
JASS:
loop
        exitwhen i &gt;= Total
            set d = Ar<i>
             ...
            set i = i + 1</i>
 

Artificial

Without Intelligence
Reaction score
326
If you use a variable that has no value, the trigger usually stops running. You use d before it has a value. Temp_Unit should be set to d.caster inside the loop.
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
I think I found your problem, you never attach 'd' so you try to work with null values meaning the thread crashes before your debug msg.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top