Timer Check problem

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
i tried to do this:
JASS:
loop
    exitwhen (TimerGetTimeout(t) == 0)             
endloop

to make the trigger wait until the timer ends but it never get past this point can any1 tell me why? :confused: :banghead:

Edit: k i tried now TimerGetElapsed() instead and it worked but still it made my action run once instead of loop only and it's not supposed to be like....
 

Hero

─║╣ero─
Reaction score
250
Edit: k i tried now TimerGetElapsed() instead and it worked but still it made my action run once instead of loop only and it's not supposed to be like....

Re-state that please..what exactly is the problem now?
 

SFilip

Gone but not forgotten
Reaction score
634
Presumably TimerGetRemaining is the function you need.
Though this can easily end up with the thread crashing, what exactly are you trying? Care to post the whole code?
 

Tom Jones

N/A
Reaction score
437
For the record, TimerGetTimeout() returns the initial duration of the timer, and will never be 0 unless the timers duration is 0.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
Re-state that please..what exactly is the problem now?
it works fine and all but in the game it doesn't work and doesn't go past this part....

Presumably TimerGetRemaining is the function you need.
Though this can easily end up with the thread crashing, what exactly are you trying? Care to post the whole code?
i try to make it like:
JASS:
call TimerStart(g,30,false,null)
   loop
      exitwhen (TimerGetRemaining(g) == 0)
      call TriggerSleepAction(0)             
   endloop

so it would simply start a timer and instead of making another trigger and detect expiring timer i simply use this loop to make it like a wait for condition but i never get through this part....
btw what's thread crashing?
Using that code (with TimerGetRemaining) will crash the thread without pardon, unless the timer already is at 0.

JASS:
loop
    exitwhen TimerGetRemaining(t) == 0
    call TriggerSleepAction(0)
endloop

But this is pretty much the same thing as PolledWait so don't start a timer solely for this.
i tried it either as u see above and it still didn't work - GetTimerElapsed() went already better since it passed but i don't think the timer realy ended....

For the record, TimerGetTimeout() returns the initial duration of the timer, and will never be 0 unless the timers duration is 0.
good to know :p
what's TimerGetElapsed is?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
A 5 seconds timer that has been running for 2 seconds already has an "elapsed" of 2, and a "remaining" of 3.

"loop exitwhen <whatever> endloop", that loop runs extremely fast.
If there is no break, i.e. a wait, even 0 seconds, it'll pretty much instantly reach the thread execution limit, at which point the game ends it by force.
(Yep, that's a thread crash)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
"Crash" is not, "I think, maybe, he actually wanted to ..., so, me being the nice one...".
"Crash" means, "WTH? Begone, foul Shade. I'll show you who's cool here!".
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
so is there anyway to make it so it would wait for condition(Remaining time == 0)?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
it makes the same as it made without the wait...
it's not passing this part...
 

SFilip

Gone but not forgotten
Reaction score
634
Your complete code?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
it's not realy nessecery but if u insist:
JASS:
function Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == &#039;AOws&#039;)
endfunction


function filter takes nothing returns boolean
    return (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetFilterUnit()))) and (GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) &gt; 0) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false)
endfunction


function GroupAction takes nothing returns nothing
    local real runY = udg_Y
    local real runX = udg_X
    call SetUnitMoveSpeed(GetEnumUnit(),100)
    call IssuePointOrder(GetEnumUnit(),&quot;move&quot;,runX,runY)
    call GroupAddUnit(bj_groupAddGroupDest,GetEnumUnit())
endfunction


function Region takes real y,real x,integer level returns rect
    return Rect(x-250*level,y-250*level,x+250*level,y+250*level)
endfunction


function Check takes timer t,group g returns boolean
    return (TimerGetRemaining(t) == 0) or (CountUnitsInGroup(g) == 0)
endfunction


function GroupEndAction takes nothing returns nothing
    call SetUnitMoveSpeed(GetEnumUnit(),GetUnitDefaultMoveSpeed(GetEnumUnit()))
endfunction


function Trig_EliteSpark_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local timer t = CreateTimer()
    local real y = GetUnitY(u)
    local real x = GetUnitX(u)
    local group g = CreateGroup()
    local integer level = GetUnitAbilityLevel(u,&#039;AOws&#039;)
    local boolexpr b = Condition(function filter)
    local rect r = Region(y,x,level)
    local real runX = GetRandomReal(GetRectMinX(r), GetRectMaxX(r))
    local real runY = GetRandomReal(GetRectMinY(r), GetRectMaxY(r))
    local timer speed = CreateTimer()
    local unit target
    local real x2
    local real y2
    local location loc
    local location loc2
    local integer i = 0
    set bj_groupAddGroupDest = CreateGroup()
    call SetUnitVertexColor(u,255,255,255,15)
    call SetUnitTimeScale(u,5-level)
    call PolledWait(0.20)
    call TimerStart(t,30,false,null)
    call SetUnitPathing(u,false)
    call SetUnitInvulnerable(u,true)
    call PauseUnit(u,true)
    call GroupEnumUnitsInRange(g,x,y,500*level,b)
    set udg_Y = runY
    set udg_X = runX
    call ForGroup(g,function GroupAction)
      loop
        exitwhen (Check(t,g))
          set target = GroupPickRandomUnit(g)
          set x2 = GetUnitX(target) 
          set y2 = GetUnitY(target)
          call SetUnitPosition(u,x2,y2)
          call SetUnitAnimation(u,&quot;attack&quot;) 
          set loc = Location(x,y)
          set loc2 = Location(x2,y2)
          call SetUnitFacingTimed(u,AngleBetweenPoints(loc,loc2),0.01)
          call RemoveLocation(loc)
          call RemoveLocation(loc2)
          call UnitDamageTarget(u,target,50+(50*level), true, false, ATTACK_TYPE_HERO,DAMAGE_TYPE_ENHANCED,WEAPON_TYPE_METAL_LIGHT_SLICE)
          call AddSpecialEffectTarget(&quot;Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodNecromancer.mdl&quot;,target,&quot;chest&quot;)
          call AddSpecialEffectTarget(&quot;Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl&quot;,u,&quot;origin&quot;)
          call GroupClear(g)
          call TimerStart(speed,105.11-(35*level),false,null)
            loop
              exitwhen (TimerGetRemaining(speed) == 0) //- Problem - it doesn&#039;t work
              call TriggerSleepAction(0)             
            endloop
          call GroupEnumUnitsInRange(g,x,y,500*level,b)
          set runX = GetRandomReal(GetRectMinX(r), GetRectMaxX(r))
          set runY = GetRandomReal(GetRectMinY(r), GetRectMaxY(r))
          set udg_Y = runY
          set udg_X = runX
          call ForGroup(g,function GroupAction)
      endloop
    call SetUnitPathing(u,true)
    call SetUnitInvulnerable(u,false)
    call PauseUnit(u,false)
    call ForGroup(bj_groupAddGroupDest,function GroupEndAction)
    call DestroyGroup(bj_groupAddGroupDest)
    call SetUnitVertexColor(u,255,255,255,255)
    call SetUnitTimeScale(u,1)
    call DestroyGroup(bj_groupAddGroupDest)
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    call DestroyTimer(t)
    call DestroyTimer(speed)
    call RemoveRect(r)
    set bj_groupAddGroupDest = null
    set u = null
    set b = null
    set t = null
    set g = null
    set r = null
    set speed = null
    set target = null
    set loc = null
    set loc2 = null
endfunction

//===========================================================================
function InitTrig_EliteSpark takes nothing returns nothing
    set gg_trg_EliteSpark = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_EliteSpark,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_EliteSpark, Condition(function Conditions))
    call TriggerAddAction(gg_trg_EliteSpark, function Trig_EliteSpark_Actions)
endfunction

"//Problem" is where my problem is
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
but still even though it's comes up so fast it should still be able to move on since that the time remaining is 0 so shouldn't it just go on?
also i need timers because only they can go below 0.27
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> call DestroyGroup(g)
> call GroupEnumUnitsInRange(g,x,y,500*level,b)

You shouldn't use a destroyed group...

"check" also checks for no units in that group.
When exactly is that group empty?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
>You shouldn't use a destroyed group...
so u are saying i should do:
- call DestroyGroup(g)
- call CreateGroup(g)
- call GroupEnumUnitsInRange(g,x,y,500*level,b)
like this?

>"check" also checks for no units in that group.
When exactly is that group empty?

it's using an "or" so if no units around my unit then it will stop or until the timer ends
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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!
    +1
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top