Okay, this one's a bit difficult to explain... I have an array of regions initialized to 24 indices. The first 8 contain player spawn locations, and every 2 elements that follow define a short group of locations where creeps should spawn. I really enjoy having it set up like this, because I can access any region in the game from a single variable. In terms of optimization, It's worked extremely well for every trigger I've written. But I ran into a logical epidemic, and I need your help...
Here's an example of the way the array is initialized:
BUT HERE'S my problem...
In a For/Loop (1-8), I'm trying to access a random number between 9 and 10 on the first loop, then 11 and 12 on the next, 13 and 14 on the next, and so on...
Here's an example of the way the array is initialized:
-
Melee Initialization
-
Events
- Map initialization
- Conditions
-
Actions
- -------- Hero spawn locations --------
- Set SpawnLocations[1] = P1 <gen>
- Set SpawnLocations[2] = P2 <gen>
- Set SpawnLocations[3] = P3 <gen>
- Set SpawnLocations[4] = P4 <gen>
- Set SpawnLocations[5] = P5 <gen>
- Set SpawnLocations[6] = P6 <gen>
- Set SpawnLocations[7] = P7 <gen>
- Set SpawnLocations[8] = P8 <gen>
- -------- Creep spawn locations (For P1) --------
- Set SpawnLocations[9] = Gate 1 to 5 <gen>
- Set SpawnLocations[10] = Gate 1 to 6 <gen>
- -------- Creep spawn locations (For P2) --------
- Set SpawnLocations[11] = Gate 2 to 5 <gen>
- Set SpawnLocations[12] = Gate 2 to 7 <gen>
- -------- Creep spawn locations (For P3) --------
- Set SpawnLocations[13] = Gate 3 to 6 <gen>
- Set SpawnLocations[14] = Gate 3 to 8 <gen>
- -------- Creep spawn locations (For P4) --------
- Set SpawnLocations[15] = Gate 4 to 7 <gen>
- Set SpawnLocations[16] = Gate 4 to 8 <gen>
- -------- Creep spawn locations (For P5) --------
- Set SpawnLocations[17] = Gate 5 to 1 <gen>
- Set SpawnLocations[18] = Gate 5 to 2 <gen>
- -------- Creep spawn locations (For P6) --------
- Set SpawnLocations[19] = Gate 6 to 1 <gen>
- Set SpawnLocations[20] = Gate 6 to 3 <gen>
- -------- Creep spawn locations (For P7) --------
- Set SpawnLocations[21] = Gate 7 to 2 <gen>
- Set SpawnLocations[22] = Gate 7 to 4 <gen>
- -------- Creep spawn locations (For P8) --------
- Set SpawnLocations[23] = Gate 8 to 3 <gen>
- Set SpawnLocations[24] = Gate 8 to 4 <gen>
-
Events
BUT HERE'S my problem...
In a For/Loop (1-8), I'm trying to access a random number between 9 and 10 on the first loop, then 11 and 12 on the next, 13 and 14 on the next, and so on...
-
Spawn
-
Events
- Time - SpawnTimer expires
- Conditions
-
Actions
- -------- Iterate through each player --------
-
For each (Integer A) from 1 to 8, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- -------- Is this person actually playing? --------
- OnlineUsers[(Integer A)] Equal to True
-
Then - Actions
- -------- Figure out which region to spawn creeps in for this player --------
- Set TempInt = (Random integer number between 0 and 1)
- Set TempRegion = SpawnLocations[( PERHAPS SOME KIND OF MIND-BLOWING ARITHMETIC? (+ TempInt?) )]
- -------- Spawn the creeps --------
- Unit - Create 1 Creeps for Player 9 (Gray) at (Center of TempRegion) facing Default building facing degrees
-
Unit Group - Pick every unit in (Units in TempRegion owned by Player 9 (Gray)) and do (Actions)
-
Loop - Actions
- Unit - Order (Picked unit) to Attack-Move To (Center of SpawnLocations[(Integer A)])
-
Loop - Actions
-
Else - Actions
- Do nothing
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Events