I found myself stuck with one of my trigger, maybe I'm just not making it the good way...
I have 20 point on my map (I made an array variable and set all the point via trigger). All these point are spawn point that randomly
activate for 15 seconds and randomly rotate. In fact, every 15 seconds 4 spawn point activate and then shut down after 15 seconds, making 4 new one activate and it goes on like this.
I made a boolean array for each point, so that when a point is randomly chosen, it is set to 'true' and thus start spawning units. After 15 sec, all spawn point
are set back to 'false' and 4 new are chosen. Thats theorically how it should work, but I does absolutely not... Why?
What it does is activate only one spawnpoint at a time...
MasterTriggerEventsGame-MapinitializationLocalVariablesConditionsActions------- This trigger should activate all trigger in the good order so point are chosen, they spawn units for 15 sec and then shut down. ------- I think the problem is in the timing, event or boolean trigger.Trigger-TurnPointRandomizerOnTrigger-RunPointRandomizer(CheckConditions,Don't Wait until it finishes)Trigger-TurnMeatCreatureSpawnerOnTrigger-RunMeatCreatureSpawner(CheckConditions,Don't Wait until it finishes)General-Wait14.5GameTimesecondsTrigger-TurnMeatCreatureStopperOn
PointRandomizerEventsLocalVariablesConditionsActions------- This trigger choose 4 random value from 'Meat Creature Spawner Boolean' and turn them to true. ------- This should activate the spawn point related to them.General-Repeat(Actions)foreverActionsVariable-SetMeatCreatureSpawnerBoolean[(Randomintegerbetween1and20)]=trueVariable-SetMeatCreatureSpawnerBoolean[(Randomintegerbetween1and20)]=trueVariable-SetMeatCreatureSpawnerBoolean[(Randomintegerbetween1and20)]=trueVariable-SetMeatCreatureSpawnerBoolean[(Randomintegerbetween1and20)]=trueGeneral-Wait15.0GameTimeseconds
MeatCreatureSpawnerEventsLocalVariablesConditionsActions------- This trigger should activate the spawn point accordingly to the 4 randomly chosen boolean. Spawn point activate for 15 sec.General-Repeat(Actions)foreverActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfMeatCreatureSpawnerBoolean[1]==trueThenGeneral-Repeat(Actions)30timesActionsUnit-Create1MEAT-Fleshling(Blood)forplayer15at(BloodFountain1facing270.0degrees)facing(Randomangle)degrees(NoOptions)General-Wait0.5GameTimesecondsElse
MeatCreatureStopperEventsLocalVariablesConditionsActions------- This trigger should turn off all spawn point just before 4 new are randomly chosenGeneral-Repeat(Actions)foreverActionsVariable-SetMeatCreatureSpawnerBoolean[1]=falseVariable-SetMeatCreatureSpawnerBoolean[2]=falseVariable-SetMeatCreatureSpawnerBoolean[3]=falseVariable-SetMeatCreatureSpawnerBoolean[4]=falseVariable-SetMeatCreatureSpawnerBoolean[5]=falseVariable-SetMeatCreatureSpawnerBoolean[6]=falseVariable-SetMeatCreatureSpawnerBoolean[7]=falseVariable-SetMeatCreatureSpawnerBoolean[8]=falseVariable-SetMeatCreatureSpawnerBoolean[9]=falseVariable-SetMeatCreatureSpawnerBoolean[10]=falseVariable-SetMeatCreatureSpawnerBoolean[11]=falseVariable-SetMeatCreatureSpawnerBoolean[12]=falseVariable-SetMeatCreatureSpawnerBoolean[13]=falseVariable-SetMeatCreatureSpawnerBoolean[14]=falseVariable-SetMeatCreatureSpawnerBoolean[15]=falseVariable-SetMeatCreatureSpawnerBoolean[16]=falseVariable-SetMeatCreatureSpawnerBoolean[17]=falseVariable-SetMeatCreatureSpawnerBoolean[18]=falseVariable-SetMeatCreatureSpawnerBoolean[19]=falseVariable-SetMeatCreatureSpawnerBoolean[20]=falseGeneral-Wait15.0GameTimeseconds
+ 2 Global variable
Meat Creature Spawner Point = No Point <Point[20]>
In the meat Creatue Spawner trigger, what you see on the forum post is multiplied by 20 (one for each point).
Also... Am I missing events? All there trigger are initially off, but I want them to run constantly so the Boolean is always verified and shut up and down
spawn point accordingly.
it will only work for point 1, also instead of setting 20 different variables, why not use a loop?
Also
Trigger - Turn Meat Creature Stopper On
that action doesn't run a trigger, it just turns it on. You still need an event for it to run.
IMO you're better off with a periodic event instead of 4 triggers
First of all, never use Repeat forever loops. Use While loops instead. Repeat forever loops cause a tremendous amount of lag compared to While loops even though the two can accomplish the same things.
How to set up an infinitely repeating while loop:
1. Create a local boolean variable called TRUE with the default value set to true.
2. Create a WHILE action
3. Under conditions, use "TRUE == true"
4. Set up your actions
5. When your actions are done, add a WAIT 0.1 seconds action within the loop below the actions you just created.
6. When you want the trigger to run, use the Run Trigger (ignoring conditions) action from another trigger (usually the one that occurs at the start of the game.)
Secondly, you don't need to make these triggers initially off if there aren't any events that cause them to fire.
Third, when setting up a system that spans over multiple triggers, it's generally better to make use of timers rather than wait times.
Finally, with these things in mind, you should consider rewriting the whole system. If I were to make a simple repeating spawn system, here's what I would do:
First of all, I would create a variable region (or point, however you set it up) array to store all of my spawn points in. Let's call it SpawnZone. Since there are 20 spawn points in your map, set the max of the array to 20.
Create a timer variable called SpawnInterval.
Create a boolean variable array called SpawnActive with an array count of 20 (one for each spawn point)
Now, in your map initialization trigger, manually set each spawn point location as a member of the SpawnZone array.
Set SpawnZone[1] = ClifftopSpawn
Set SpawnZone[2] = WalkwaySpawn
etc...
Doing this will make it a lot easier later on and will take up less space in your triggers.
Next, the first trigger. This will spawn the units.
No events. This will be executed by the next trigger we will make.
Create a local integer variable called "Select"
Actions:
For each integer Select from 1 to 20 with interval 1
This will set up which locations are chosen to be spawn points and sets up our timer.
Set the event to Timer Expires and use the timer variable you created.
Create a new local integer variable called PickSpawnPoint
Set all of the SpawnActive variables to false. The easiest way to do this is by setting up a For Each Integer loop using PickSpawnPoint as the variable, 1 as the starting integer, and 20 as the ending integer. Or you can just copy and paste 20 times and manually set each index to false.
Pick 4 spawn points at random like you did before and set them to true.
Run the first trigger we made, ignoring conditions.
Remember the timer variable you made? Now's the time to put it to use. Start SpawnInterval as a One-shot timer with duration 15 seconds.
Oh, one last thing. When you want the spawns to start, simply start the timer you made. If you want it to be instant, set it to like 0.5 seconds. This will initiate the looping sequence. You'll need to add other switches and conditions if you want the spawns to stop at any point (or simply turn off the relevant triggers.)
It's working better, but still not like it should. First thing first, I will make sure we see the same stuff.
I have 20 point on my map
Every 15 sec, 4 points are randomly chosen, spawning 30 unit in 15 second time laps and then turning off
4 new point are chosen randomly, same thing happen and goes off until game end
Just makinge sure we understood the same thing.
I'm pretty certain I made mistake while following your orders, which lead to the result I have right now. Every 0.5 sec, more than 50 units are spawned at point 1. After 15 sec, it start over, but at the exact same place. Here is the trigger I made.
UnitSpawntimerandrandomengineEventsTimer-SpawnIntervalexpiresLocalVariablesPickSpawnPoint=0<Integer>ConditionsActionsGeneral-ForeachintegerPickSpawnPointfrom1to20withincrement1,do(Actions)ActionsVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueTrigger-RunUnitSpawn(IgnoreConditions,Don't Wait until it finishes)Timer-StartSpawnIntervalasaOneShottimerthatwillexpirein15.0GameTimeseconds
It seem I can't understand which part make the boolean point go back to false after 15 sec of activation. I see other stuff that I can'T understand right now, but it 's probably because I messed up.
Also, you need to pick EVERY SpawnActive variable in the array and set it to false before randomly choosing 4 of them to make true. To do this, set up another For Each Integer loop using the Pick Spawn Point variable you made. Your code for the "Unit Spawn timer and random engine" should then look like this:
EventsTimer-SpawnIntervalexpiresLocalVariablesPickSpawnPoint=0<Integer>ConditionsActionsGeneral-ForeachintegerPickSpawnPointfrom1to20withincrement1,do(Actions)ActionsVariable-SetSpawnActive[PickSpawnPoint]=falseVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueVariable-SetSpawnActive[(Randomintegerbetween1and20)]=trueTrigger-RunUnitSpawn(IgnoreConditions,Don't Wait until it finishes)Timer-StartSpawnIntervalasaOneShottimerthatwillexpirein15.0GameTimeseconds
Notice how I moved the other actions outside of the For Each Integer loop? These actions don't rely on the Pick Spawn Point variable you made, so putting them in the loop will cause undesirable effects and clutter up your game with unnecessary code.
Strangely 3 spwn point are always grouped together and the 1 one is always alone. Also, it takes a couple of turn before more than just one or two spawn point are active.
Il work a bit more on the map and make another one with only this trigger on it so i can work on it more easely. I'll post it on this forum to.
Not even sure I understand everything... How do you set the picm spawn point local variable as behing all the point integer from 1 to 20?
Does it do it automatically if you leave it as a blank integer?
Also, General - For each integer Select from 1 to 20 with increment 1, do (Actions)
How does the editor know what select integer is? We havn't set the variable anywhere....
Strangely 3 spwn point are always grouped together and the 1 one is always alone. Also, it takes a couple of turn before more than just one or two spawn point are active.
It does that because of the way you are randomly selecting spawn points to enable. A good way to avoid this is to check if the selected Spawn Active variable is set to True first. To do that you need another local integer variable to act as a counter. So delete the four actions you used to randomly select spawn points and do this:
#Firstcreateanewintegervariableinthe"Unit Spawn timer and random engine"trigger#called"Counter"#Second,createanotherintegervariablecalled"Random"#NowcreateaSetVariableactionafterandoutsideofyourForEachIntegerloop#andsetCounterto0:General-ForeachintegerPickSpawnPointfrom1to20withincrement1,do(Actions)ActionsVariable-SetSpawnActive[PickSpawnPoint]=falseVariable-SetCounter=0#ThenputthisWhileloopimmediatelyafter:WhileConditionsCounter<=3ActionsSetRandom=Randomintegerbetween1and20IfSpawnActive[Random]=falseThenSetSpawnActive[Random]=trueSetCounter=Counter+1Else#Oncefinished,yourtriggershouldlooklikethis:EventsTimer-SpawnIntervalexpiresLocalVariablesPickSpawnPoint=0<Integer>Counter=0<Integer>Random=0<Integer>ConditionsActionsGeneral-ForeachintegerPickSpawnPointfrom1to20withincrement1,do(Actions)ActionsVariable-SetSpawnActive[PickSpawnPoint]=falseVariable-SetCounter=0WhileConditionsCounter<=3ActionsSetRandom=Randomintegerbetween1and20IfSpawnActive[Random]=falseThenSetSpawnActive[Random]=trueSetCounter=Counter+1ElseTrigger-RunUnitSpawn(IgnoreConditions,Don't Wait until it finishes)Timer-StartSpawnIntervalasaOneShottimerthatwillexpirein15.0GameTimeseconds
Not even sure I understand everything... How do you set the picm spawn point local variable as behing all the point integer from 1 to 20? Does it do it automatically if you leave it as a blank integer?
The For Each Integer loop does that. It takes every index from 1 to 20 and repeats the same action for each. That's why you need to select a variable for the loop to use.
Also, General - For each integer Select from 1 to 20 with increment 1, do (Actions)
How does the editor know what select integer is? We havn't set the variable anywhere....
Oh, but you have! You set it when you added the variable to the trigger. Then when the loop uses the variable, it sets the integer to 1, executes the actions in the loop, then goes back and sets the integer to 2 and repeats, over and over again until it reaches 20.
I hope that helps. Let me know if you still have problems.
Hello guys,
I found myself stuck with one of my trigger, maybe I'm just not making it the good way...
I have 20 point on my map (I made an array variable and set all the point via trigger). All these point are spawn point that randomly activate for 15 seconds and randomly rotate. In fact, every 15 seconds 4 spawn point activate and then shut down after 15 seconds, making 4 new one activate and it goes on like this.
I made a boolean array for each point, so that when a point is randomly chosen, it is set to 'true' and thus start spawning units. After 15 sec, all spawn point are set back to 'false' and 4 new are chosen. Thats theorically how it should work, but I does absolutely not... Why?
What it does is activate only one spawnpoint at a time...
How would you theorically set up suck a trigger?
I'll put my trigger online in a sec
+ 2 Global variable
Meat Creature Spawner Point = No Point <Point[20]>
Meat Creature Spawner Boolean = false <Boolean[20]>
In the meat Creatue Spawner trigger, what you see on the forum post is multiplied by 20 (one for each point).
Also... Am I missing events? All there trigger are initially off, but I want them to run constantly so the Boolean is always verified and shut up and down spawn point accordingly.
@Claymuffin: Go
Meat Creature Spawner Boolean[1] == true
it will only work for point 1, also instead of setting 20 different variables, why not use a loop?
Also
Trigger - Turn Meat Creature Stopper On
that action doesn't run a trigger, it just turns it on. You still need an event for it to run. IMO you're better off with a periodic event instead of 4 triggers
A couple of things:
First of all, never use Repeat forever loops. Use While loops instead. Repeat forever loops cause a tremendous amount of lag compared to While loops even though the two can accomplish the same things.
How to set up an infinitely repeating while loop:
1. Create a local boolean variable called TRUE with the default value set to true.
2. Create a WHILE action
3. Under conditions, use "TRUE == true"
4. Set up your actions
5. When your actions are done, add a WAIT 0.1 seconds action within the loop below the actions you just created.
6. When you want the trigger to run, use the Run Trigger (ignoring conditions) action from another trigger (usually the one that occurs at the start of the game.)
Secondly, you don't need to make these triggers initially off if there aren't any events that cause them to fire.
Third, when setting up a system that spans over multiple triggers, it's generally better to make use of timers rather than wait times.
Finally, with these things in mind, you should consider rewriting the whole system. If I were to make a simple repeating spawn system, here's what I would do:
First of all, I would create a variable region (or point, however you set it up) array to store all of my spawn points in. Let's call it SpawnZone. Since there are 20 spawn points in your map, set the max of the array to 20.
Create a timer variable called SpawnInterval.
Create a boolean variable array called SpawnActive with an array count of 20 (one for each spawn point)
Now, in your map initialization trigger, manually set each spawn point location as a member of the SpawnZone array.
Set SpawnZone[1] = ClifftopSpawn
Set SpawnZone[2] = WalkwaySpawn
etc...
Doing this will make it a lot easier later on and will take up less space in your triggers.
Next, the first trigger. This will spawn the units.
No events. This will be executed by the next trigger we will make.
Create a local integer variable called "Select"
Actions:
For each integer Select from 1 to 20 with interval 1
- Actions:
- - - If
- - - - - SpawnActive[Select] == True
- - - Then
- - - - - Repeat 30 times
- - - - - - Create 1 monster thingy at SpawnZone[Select]
- - - - - - Wait 0.5 seconds
Create a new trigger.
This will set up which locations are chosen to be spawn points and sets up our timer.
Set the event to Timer Expires and use the timer variable you created.
Create a new local integer variable called PickSpawnPoint
Set all of the SpawnActive variables to false. The easiest way to do this is by setting up a For Each Integer loop using PickSpawnPoint as the variable, 1 as the starting integer, and 20 as the ending integer. Or you can just copy and paste 20 times and manually set each index to false.
Pick 4 spawn points at random like you did before and set them to true.
Run the first trigger we made, ignoring conditions.
Remember the timer variable you made? Now's the time to put it to use. Start SpawnInterval as a One-shot timer with duration 15 seconds.
Oh, one last thing. When you want the spawns to start, simply start the timer you made. If you want it to be instant, set it to like 0.5 seconds. This will initiate the looping sequence. You'll need to add other switches and conditions if you want the spawns to stop at any point (or simply turn off the relevant triggers.)
That should do it.
Ok I'm doing it over and posting the result tonight
O lawl, I suck XD
It's working better, but still not like it should. First thing first, I will make sure we see the same stuff.
I have 20 point on my map Every 15 sec, 4 points are randomly chosen, spawning 30 unit in 15 second time laps and then turning off 4 new point are chosen randomly, same thing happen and goes off until game end
Just makinge sure we understood the same thing.
I'm pretty certain I made mistake while following your orders, which lead to the result I have right now. Every 0.5 sec, more than 50 units are spawned at point 1. After 15 sec, it start over, but at the exact same place. Here is the trigger I made.
Global variables :
Spawn zone = No Point <Point[20]>
Spawn Interval = (New timer) <Timer>
Spawn Active = false <Boolean[20]>
It seem I can't understand which part make the boolean point go back to false after 15 sec of activation. I see other stuff that I can'T understand right now, but it 's probably because I messed up.
I don't understand what both local variable do.
You're close, but you missed something in your Unit Spawn trigger.
This:
Should be this:
Also, you need to pick EVERY SpawnActive variable in the array and set it to false before randomly choosing 4 of them to make true. To do this, set up another For Each Integer loop using the Pick Spawn Point variable you made. Your code for the "Unit Spawn timer and random engine" should then look like this:
Notice how I moved the other actions outside of the For Each Integer loop? These actions don't rely on the Pick Spawn Point variable you made, so putting them in the loop will cause undesirable effects and clutter up your game with unnecessary code.
Strangely 3 spwn point are always grouped together and the 1 one is always alone. Also, it takes a couple of turn before more than just one or two spawn point are active.
Il work a bit more on the map and make another one with only this trigger on it so i can work on it more easely. I'll post it on this forum to.
Not even sure I understand everything... How do you set the picm spawn point local variable as behing all the point integer from 1 to 20? Does it do it automatically if you leave it as a blank integer?
Also, General - For each integer Select from 1 to 20 with increment 1, do (Actions)
How does the editor know what select integer is? We havn't set the variable anywhere....
It does that because of the way you are randomly selecting spawn points to enable. A good way to avoid this is to check if the selected Spawn Active variable is set to True first. To do that you need another local integer variable to act as a counter. So delete the four actions you used to randomly select spawn points and do this:
The For Each Integer loop does that. It takes every index from 1 to 20 and repeats the same action for each. That's why you need to select a variable for the loop to use.
Oh, but you have! You set it when you added the variable to the trigger. Then when the loop uses the variable, it sets the integer to 1, executes the actions in the loop, then goes back and sets the integer to 2 and repeats, over and over again until it reaches 20.
I hope that helps. Let me know if you still have problems.