HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

"Wait"

10-11-2008, 10:13 AM#1
maximilianx
Question about the wait action..
when using wait in a spell, what's smarter to use?
wait, or wait game-time?

what exactly is the difference?

thanks.
10-11-2008, 11:08 AM#2
ToukoAozaki
normal wait is native to the engine. it pauses execution of the function for specified period.
game-time wait is a custom function. it uses a timer as its base, and polls the remaining time with normal waits. as timer speed depends on the game speed, game-time wait will reflect the difference with the real time. however, normal waits have precision lower-bound. furthermore, as those game-time waits utilize normal waits, precision is worse (and result is somewhat random).

If you need some precise game-time delay, I suggest using timers (with events or callbacks) instead.
10-11-2008, 12:44 PM#3
Flame_Phoenix
The use of PolledWait is quite better because it uses a timer. However that function leaks, but if you use Vex's optimizer, you can also access PolledWait2 which is an optimized version.

There is no doubt, waits are evil and timers are better.
To know why waits are so bad, check out this link:
http://www.wc3campaigns.net/showthre...ght=waits+evil

___________________________________________________________
rep+ those who help you!
10-11-2008, 02:12 PM#4
DioD
wait cause game to start other thread and then return.

this is against usage of globals.
10-11-2008, 03:03 PM#5
Flame_Phoenix
Quote:
wait cause game to start other thread and then return.
this happens because waits can cause sometimes memory corruption, therefore making the entire application crashing.
They are also inefficient, and have a minimum value of 0.27...
Theses among many other reasons are explained in my post ... just give it a try.
10-11-2008, 05:09 PM#6
the-thingy
Quote:
They are also inefficient, and have a minimum value of 0.27...
AFAIK, that min value stuff isn't true at all, but rather they are just extremely inaccurate. I asked about it in this thread, and there was no mention of 0.27 other than
Quote:
And I'll personally -rep anyone coming with "It's obviously 0.27" or similar.
(Post 10 has most of the good info that may be of interest)
10-11-2008, 05:11 PM#7
Tide-Arc Ephemera
There is some form of minimum value. Try making any normal spell using a loop with waits. It won't work. I tried to make a simple meathook spell using GUI with waits, didn't turn out very well.
10-11-2008, 05:52 PM#8
Flame_Phoenix
Quote:
AFAIK, that min value stuff isn't true at all, but rather they are just extremely inaccurate. I asked about it in this thread, and there was no mention of 0.27 other than
it has min value of 0.27, however this value changes when used inside loops and others.
Also, if you give it a lower value, it will just make it 0.27, per example. I read about this in a tutorial too bad I can't find the link =S
10-11-2008, 06:08 PM#9
the-thingy
This test script says otherwise (NewGen isn't working for me at the moment, so I'm stuck with regular JASS >_<)
Collapse JASS:
function ActionFunc takes nothing returns nothing
    local real time = S2R (GetEventPlayerChatString ())
    local string result
    call DisplayTimedTextToPlayer (Player (0), 0, 0, 2.5, R2S (time))
    call TimerStart (udg_timer, 60., false, null)
    call TriggerSleepAction (time)
    set result = R2S (TimerGetElapsed (udg_timer))
    call DisplayTimedTextToPlayer (Player (0), 0, 0, 2.5, result)
endfunction

function InitTrig_Melee_Initialization takes nothing returns nothing
    local trigger t = CreateTrigger ()
    set udg_timer = CreateTimer ()
    call TriggerRegisterPlayerChatEvent (t, Player (0), "", false)
    call TriggerAddAction (t, function ActionFunc)
endfunction

For values around 0.01, it was displaying values from 0.1 to 0.2
10-11-2008, 07:10 PM#10
PurplePoot
It doesn't have a minimum value at all, but .27 is a good estimate average for .01 second waits.

As for .00 second waits, I've never had them go faster than ~.1 seconds.
10-11-2008, 08:32 PM#11
Flame_Phoenix
Quote:
It doesn't have a minimum value at all, but .27 is a good estimate average for .01 second waits.

As for .00 second waits, I've never had them go faster than ~.1 seconds.
This is strange, THW has tutorials by Daeling saying it has minimum of 0.27...
10-11-2008, 08:39 PM#12
the-thingy
Quote:
Originally Posted by Flame_Phoenix
This is strange, THW has tutorials by Daeling saying it has minimum of 0.27...
Well, maybe that's what people seemed to think at the time, or that was the result of some testing (however it had been tested). And, to be honest, it's all the same in the sense that waits aren't very good for low periods
10-11-2008, 08:40 PM#13
dorreen
You can even try TriggerSleepAction( -1 ) or even TriggerSleepAction( -2 ).
If my memory serves me right -1 was faster than -2.
10-12-2008, 08:53 AM#14
Chocobo
currently if you test TriggerSleepAction duration offline/in LAN/in BNet you will have different results
10-12-2008, 08:55 AM#15
Flame_Phoenix
Quote:
currently if you test TriggerSleepAction duration offline/in LAN/in BNet you will have different results
Yes. Truth is that TSA is quite acceptable in Single Player, but a complete mess in Multi Player.