- Joined
- May 20, 2009
- Messages
- 822
-
Spawner Clock
-
Events
- Time - Every 0.05 seconds of game time
- Conditions
-
Actions
-
For each (Integer Int[0]) from 1 to SpawnerMaxIndex, do (Actions)
-
Loop - Actions
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units of type SpawnerUnit[Int[0]]) and do (Actions)
-
Loop - Actions
- Set Int[1] = (Int[1] + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Unit-type of (Picked unit)) Equal to SpawnerUnit[Int[0]]
-
Then - Actions
- Set _SpawnerUnits[Int[1]] = (Picked unit)
- Set _SpawnerPositions[Int[1]] = (Position of _SpawnerUnits[Int[1]])
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
For each (Integer Int[2]) from 1 to Int[1], do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- _SpawnTimer[Int[2]] Less than SpawnTimer[Int[0]]
-
Then - Actions
- Set _SpawnTimer[Int[2]] = (_SpawnTimer[Int[2]] + 0.05)
- Else - Actions
-
If - Conditions
- Set temp_point[Int[2]] = (_SpawnerPositions[Int[2]] offset by SpawnerRadius[Int[0]] towards 0.00 degrees)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units within SpawnerZone[Int[0]] of _SpawnerPositions[Int[2]] matching ((Unit-type of (Matching unit)) Equal to SpawnType[Int[0]]))) Less than or equal to SpawnMax[Int[0]]
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units within SpawnerZone[Int[0]] of _SpawnerPositions[Int[2]] matching ((Unit-type of (Matching unit)) Equal to SpawnType[Int[0]]))) Equal to 0
-
Then - Actions
- Set _angle[Int[2]] = (Random angle)
- Custom script: call RemoveLocation(udg_temp_point[udg_Int[2]])
- Set temp_point[Int[2]] = (_SpawnerPositions[Int[2]] offset by ((SpawnerRadius[Int[0]] x 2.00) x (Real(_offsetmult[Int[2]]))) towards _angle[Int[2]] degrees)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units within SpawnRadius[Int[0]] of temp_point[Int[2]] matching ((Unit-type of (Matching unit)) Equal to SpawnType[Int[0]]))) Greater than 0
-
Then - Actions
- Set _angle[Int[2]] = (_angle[Int[2]] + (SpawnRadius[Int[0]] / (Real(_offsetmult[Int[2]]))))
- Game - Display to (All players) the text: (String(_angle[Int[2]]))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- _angle[Int[2]] Greater than or equal to 360.00
-
Then - Actions
- Game - Display to (All players) the text: FIRED!
- Set _angle[Int[2]] = 0.00
- Set _offsetmult[Int[2]] = (_offsetmult[Int[2]] + 1)
- Else - Actions
-
If - Conditions
- Custom script: call RemoveLocation(udg_temp_point[udg_Int[2]])
- Set temp_point[Int[2]] = (_SpawnerPositions[Int[2]] offset by ((SpawnRadius[Int[0]] x 2.00) x (Real(_offsetmult[Int[2]]))) towards _angle[Int[2]] degrees)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units within SpawnRadius[Int[0]] of temp_point[Int[2]] matching ((Unit-type of (Matching unit)) Equal to SpawnType[Int[0]]))) Equal to 0
-
Then - Actions
- Game - Display to (All players) the text: FIRED!
- Unit - Create 1 SpawnType[Int[0]] for Player 1 (Red) at temp_point[Int[2]] facing (Random angle) degrees
- Set OreCreated = 1.00
- Set LastCreatedOre = (Last created unit)
- Set OreCreated = 0.00
- Set _SpawnTimer[Int[2]] = 0.00
- Custom script: call RemoveLocation(udg__SpawnerPositions[udg_Int[2]])
- Set _angle[Int[2]] = 0.00
- Set _offsetmult[Int[2]] = 1
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- Set Int[1] = 0
-
Loop - Actions
-
For each (Integer Int[0]) from 1 to SpawnerMaxIndex, do (Actions)
-
Events
Basically what this is trying to do is make something spawn in an order on rings coming off of a main spawner and make it as adjustable as possible. However, this seems to run rather slowly. Video to show what I mean:
It's running slowly because any one that gets destroyed needs to be replaced, so it's always starting from a certain position and working it's way back to where it current is to make sure all holes are filled. Is there a better/faster way to do this? The only other thing I can think of is to register all points from the get-go and check the points to make sure they're all filled, but I'm not sure how to make it do this sequence that way, as it needs to start from the spawner and work outword while also having a timer to delay when the spawns occur.
EDIT: It also seems to break after ~16 spawners are on the map at a time. (Though surprisingly runs kind of smooth, TBH, despite the fact it's running so many freaking loops at one time)
UPDATE: I did one hell of a stress-test with this and it still had passable performance. It was hit, but it wasn't really hit hard. This was with something like 16 spawners that were all spawning 50 spawns in total.
Last edited: