• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

So what's the best alternative to "wait" function?

Status
Not open for further replies.
Level 20
Joined
Aug 13, 2013
Messages
1,696
Use shadowing globals by locals if you don't want periodic. But it is not recommended anymore. Using waits do not cause leaks and bugs.. it is only brokening the MUI'ness of the trigger or spell ( Multi Unit Instanceability ) Waits are inaccurate and it can only have 0.27 seconds. You can use short waits for the loop but if it is very long waits been used then it will appear the brokening of the MUI. Shadowing globals look like this:
JASS:
local unit u = GetTriggerUnit ( )
set udg_YOUR_UNIT = u

Writing wait in 0.03 seconds will look like this:
JASS:
call TriggerSleepAction ( 0.03 )
// --> Will transform to: 
call TriggerSleepAction ( 0.27 )

You can read many tutorials in here about using artificial waits.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
What? locals aren't accurate? You must mean TSAs/sleeps a.k.a. Waits...
Sleeps don't pause with the game timer because it delays the execution of code on the thread using a different timing system (I don't know if it is the system clock or CPU clock).

it is only brokening the MUI'ness of the trigger or spell
No it does not, when a trigger fires and execute code, the local variables in that instance of execution are allocated a seperate and unique space in memory, it's localized for that execution alone.

The reason it breaks instancing is because of the use of a global variable, not the suggested reason...

Waits weren't used because it causes handleId allocation to get messed up, and it only happens when you remove the action on a trigger handle and then destroy it. A testmap is available on wc3c.net, I don't think I remember it correctly.

Short explanation: Waits mess up dynamic triggers.
 
Status
Not open for further replies.
Top