| 07-07-2004, 05:41 PM | #1 |
I have 6 spawn areas on my td map, and I want the enemies to spawn at 0.5 second intervals, so they will be in a row. However after a lot of expirementation I found out that adding a "wait 0.5 seconds" command inside the loop screws up the loop. I need the loop to run 20 times to generate enemies, however when the wait command is enabled the loop runs 2,3, or 4 times and then stops, it never goes above that. What's with that? Is there a non-buggy jass version of wait command that works with loops? |
| 07-08-2004, 12:05 AM | #2 |
Well, you didn't show us your trigger which makes it difficult to figure out what's wrong. So I'm going explain the way I would do it. First thing I would do is at map initialization, set your 6 spawn points to a point array. The reason for this is to help prevent memory leaks. Second thing I would do is at map init set your different creep unit-types to a unit-type array. Making sure level 1 units are in the array index 1, level 6 units in array index 1, etc, etc. Also create an integer to keep track of the level. Third thing I would do would be created a loop that repeats 20 times and a second nested loop that repeats 6 times. In the second loop I would create 1 creep at each of the spawn points and after the second loop I'd add my wait. Here is my finished trigger. Code:
Spawn Units
Events
Conditions
Actions
For each (Integer A) from 1 to 20, do (Actions)
Loop - Actions
For each (Integer B) from 1 to 6, do (Actions)
Loop - Actions
Unit - Create 1 SpawnedCreepType[CreepLevelInteger] for Neutral Hostile at SpawnPointsArray[(Integer B)] facing Default building facing degrees
Unit - Order (Last created unit) to Attack-Move To (Center of (Playable map area))
Wait 0.50 seconds
|
| 07-08-2004, 05:05 AM | #3 |
Mr. Safety I do have them in the array, and my for loop is identical to yours except that the wait is in the beginning. Also, nathanmx I tried different wait commands (wait game time etc) and it still didn't work. I ended up solving the problem using recursion, it seems to work fine now. I have the spawn trigger call a function that takes an integer and returns nothing and pass it an integer 1, the function makes a unit, waits .5 seconds, then if the integer being passed to it is less than # of monsters I need to spawn (20), it calls itself again passing the integer it received incremented by 1. |
