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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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