PolledWait or TriggerSleepAction?

luorax

Invasion in Duskwood
Reaction score
67
As the title says, i have a question: Which is better? And why?
-Calling PolledWait( x.x ) or,
-Calling TriggerSleepAction( x.x )?

Thanks in advance.
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
I suggest you avoid both and use timers instead, as they're more accurate.

EDIT: FML.
 

Jedi

New Member
Reaction score
63
TriggerSleepAction and PolledWait both can't be less than 0.10

TriggerSleepAction doesn't pause when a player about to disconnet(waiting for player message)

Use PolledWait because of the above reason.
 

Ashlebede

New Member
Reaction score
43
PolledWait is, indeed, actual game-time. TriggerSleepAction uses only your computer and may be asynchronous and doesn't pause when the game is paused. The best solution, however, is timers.

Minimum for TriggerSleepAction is around .27 secs. No idea for polled wait, but it seems to be the same.
 

luorax

Invasion in Duskwood
Reaction score
67
I just replaced my about 200 lines with TriggerSleepAction >.<

Then i wait some more answers before edit it again, i don't want to edit it after every post (and because it's quite far from release... :D)

EDIT: For periodic events, periodic triggers (For example my hp/mana regen aura trigger... I had to make one to work with my combat-text system) etc i use timers, of course. But my "Arena System" (It's a mortal kombat map, and having a simple "sub-zero" a "sub-zero wins" a "sub-zero wins. flawless victory", and 2 "sub-zero wins. Flawless victory, fatality/brutality (And maybe an animality and babalitiy..) takes much-much space.. so i uses simple sounds, and test the unit's status, and play correct sounds) contains a lot of waits.
 

Laiev

Hey Listen!!
Reaction score
188
use periodic triggers/timer... is much better then any other wait

also you decide when stop the timer and if u will stop it :p
 

tooltiperror

Super Moderator
Reaction score
231
Minimum for TriggerSleepAction is around .27 secs. No idea for polled wait, but it seems to be the same.

That's a myth.

And don't be that afraid of PolledWait. You don't have to use Timers all the time. For example, if you make an -RD Mode in your map precision won't matter if you want to rest a few seconds between picking players.
 

tooltiperror

Super Moderator
Reaction score
231
Well, according to Aceheart and Ghan, it's not, so I recommend not believing it :)
 

luorax

Invasion in Duskwood
Reaction score
67
Well, thank the answers.
I think, I'll use the PolledWait. And of course for periodic event timers.
 

Ashlebede

New Member
Reaction score
43
That's a myth.

And don't be that afraid of PolledWait. You don't have to use Timers all the time. For example, if you make an -RD Mode in your map precision won't matter if you want to rest a few seconds between picking players.

Why would the minimum wait for a [ljass]PolledWait()[/ljass] be any shorter? It even uses [ljass]TriggerSleepAction()[/ljass] in its source code...

JASS:
//===========================================================================
// We can&#039;t do game-time waits, so this simulates one by starting a timer
// and polling until the timer expires.
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if (duration &gt; 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining &lt;= 0

            // If we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            if (timeRemaining &gt; bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction


See? A loop with [ljass]TriggerSleepAction()[/ljass]'s in it (.1 seconds each, so that's about .25). How is that any shorter than just using a [ljass]TriggerSleepAction()[/ljass]?

Edit : And what the hell is -rd mode?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
JASS:
//===========================================================================
// We can&#039;t do game-time waits, so this simulates one by starting a timer
// and polling until the timer expires.
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if (duration &gt; 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining &lt;= 0

            // If we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            if (timeRemaining &gt; bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction


See? A loop with [ljass]TriggerSleepAction()[/ljass]'s in it (.1 seconds each, so that's about .25).

It's only 0.10 seconds if the original wait has 1 second remaining. It's being multiplied by the timeRemaining, in order to get 10% of the original time, not to wait 0.10 seconds in any form.

While there is no real limit for the TriggerSleepAction, it is very unreliable for small wait periods. People report the time limit being '0.27' because '0.10' to '0.30' are close to the lowest values they can get in tests.

In actuality, for any wait period it is very inaccurate, and will often be too long. PolledWait was created for accurate time in cinematics, not to try to be used for low period waits. It's

If you want extreme accuracy, use a timer.
 

Ashlebede

New Member
Reaction score
43
It's only 0.10 seconds if the original wait has 1 second remaining. It's being multiplied by the timeRemaining, in order to get 10% of the original time, not to wait 0.10 seconds in any form.

While there is no real limit for the TriggerSleepAction, it is very unreliable for small wait periods. People report the time limit being '0.27' because '0.10' to '0.30' are close to the lowest values they can get in tests.

In actuality, for any wait period it is very inaccurate, and will often be too long. PolledWait was created for accurate time in cinematics, not to try to be used for low period waits. It's

If you want extreme accuracy, use a timer.

That's what I meant ; both should have the same time "minimum", since they are both based on the [ljass]TriggerSleepAction()[/ljass]. So why did tooltip say that the fact that [ljass]PolledWait()[/ljass] has the same "minimum" waiting time as [ljass]TriggerSleepAction()[/ljass] was a myth?
 

tooltiperror

Super Moderator
Reaction score
231
You keep showing that you are horrible at reading posts correctly.

I said that TriggerSleepAction only being reliable at times over .27 is a myth.
 

Ashlebede

New Member
Reaction score
43
Then it seems I didn't understand what you meant because you didn't understand what I meant. ^_^

What I meant by "Minimum" was the (let's say approximate) minimum pause time of a [ljass]TriggerSleepAction()[/ljass], even with a [ljass].00001[/ljass] parameter.
 

tooltiperror

Super Moderator
Reaction score
231
I'm saying that if you use [LJASS]TriggerSleepAction(.02)[/LJASS] it may wait for .02 seconds. However, it is just as reliable at any time. The chance of [LJASS]TriggerSleepAction(5.00)[/LJASS] waiting for five seconds and [LJASS]TriggerSleepAction(.26)[/LJASS] waiting for .26 seconds is the same. You just don't seem to understand this.
 

Laiev

Hey Listen!!
Reaction score
188
The game randomly selects a bunch of heros, which are "put into" two taverns. In turns, the teams will select characters.

E.g.

First it's Team1 turn to pick 1 hero. Blue will have 20 seconds to select his hero.
Then pink and grey will have 20 secs to pick a hero. And so on.
Team1 1 - Team2 2 - Team1 2 - Team2 2 - Team1 2 - Team2 1
 
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