• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

question about waits

Status
Not open for further replies.
Level 6
Joined
Jul 21, 2011
Messages
139
can someone please explain to me whats so bad about waits? i already read somewhere that if you make a spell with waits, that means that a second unit wouldnt be able to use that spells as well or have trouble with it, so could this be solved by simply not giving that spell to other unit?, also what other problems would waits cause? thanks
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
1. It would cause "bugs" to spell that is not instant (well, since you used "Wait", the spell is not instant anymore - therefore bugs).
2. It would cause "bugs" if used within loops (For each Integer A, bla bla bla...)
3. It SHOULD NOT AT ALL be used to a system/spell that is intended to be used by multiple units at once.
4. Good to be used in Cinematics, greatly needed.
5. You can use Wait and still be MUI, with exception, local variable.

To counter with said issues, use either Indexing method or Hashtable, you have to learn this - and practice.
It's not just a simple read from tutorials.

Oh, you also can make the spell become MUI with the use of local variable.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
While a Wait is processing, other triggers or other running instances of the same trigger are not locked, they work simultaneously. Thus, they might overwrite global variables meanwhile or create states you have not accounted for. That is not only the case for Waits but also when you have actions in the middle of the trigger that fire other events because these events will be handled first.

Basically, to avoid this, you need to store your data distinctly in independent memory areas. As defskull stated, one method would be local variables. They are bound to the instance of the call of the function they are declared in, means everytime you run the trigger, there is another variable. Hashtable and global structures are better for timers instead of Waits because after a Wait there is not a good way to identify the instance you are in. A timer presents itself as event response, so you can attach data to its handle id for example.

For GUI users, it might be better to use Waits + local variables (which must be realized by single jass lines though, use the Custom Script action) for better readability and less different jass lines. As you advance in jass, you normally get rid of Waits in the very most cases.
 
Status
Not open for further replies.
Top