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.

      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