Help with looping triggers

T

Tojso09

Guest
I'm making this map where you fight in an arena and have ten waves of enemies. I don't want to have to write triggers for each wave so I tried to loop them using a few switches, but it doesn't work right.

As a custom in most games, the wave or level of the player is represented in ore and for some reason it jumps by odd intervals of 5 or 7.

My triggers are supposed to set a custom score for a player you don't control and as the score goes up, so does the time for each wave and the enemies within it. I have not yet gotten to spawning enemies yet because of the timer.

Please post if this is confusing to you or if you would like to see my triggers.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Well, you can't tell the game to create a variable # of units within a trigger, the units created count must be a constant value.
You have to trigger each wave separately.
 
T

Tojso09

Guest
I understand that the unit variable must be a constant, but I also have discovered that functions such as x^3 have a constant in them. so what if I used multiple scores, and using triggers to increase/decrease values to get the desired unit count? Would that work?
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
No matter what you do, you have to have different triggers. It's what you have to put up with when you don't have inner-actionbox if/then/else options.


And I don't have any clue what the constant I was refering to has to do with the 4 possible constants in a cubic function...
 
T

Tojso09

Guest
The reason i mentioned that constant was because i wanted to show that it is possible to use constants to get funtions such as x^3.

And what I was going for was something like the level scheme in the premade "Defenders of the Galaxy" map that comes with the game. I was wondering if anyone had a easy explanation for it instead of having to follow all 30-odd switches in the triggers.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
If its just a level based thing, why use switches? Why not use a number-based counter like a neutral player's gas resources or something?
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Don't be lazy, its so much easier to create seperate triggers, although it will be much harder to edit if you make a mistake ;P
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
anarki, if it was possible to use variable values, THAT is what would be easy. Just set the value once instead of doing a 30x CnP.
 
T

Tojso09

Guest
So... is that it for help on this topic? just wondering. I would like to know if anyone is really good at looping triggers for situations such as these.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Well, nobody is good at looping triggers for this stuff because triggers where the constants change each time (which exception to the player number integer) aren't looping, it's several triggers.
 
T

Tojso09

Guest
I know that it takes several triggers and switches to loop, and for the constant, just use a nonplayable character's resources to keep a constant or to keep it looping.

I'm not sure if this works, but this is what I'm talking about.

Conditions:
Always
Actions:
Clear 'loop'

Conditions:
'loop' is cleared
Actions:
Set ore for all players. Add 1
Set ore and gas for nonplayable character. Set to 0
Set 'loop'
preserve trigger

Conditions:
'loop' is set
Actions:
Spawn x zerglings at location 'wherever'
Set gas for nonplayable character. Add 1
preserve trigger

Conditions:
nonplayable character accumulates 30 gas
Actions:
Set gas for nonplayable character. Set to 0
Set ore for nonplayable character. Add 1
preserve trigger

Conditions:
nonplayable character has least ore
Actions:
set 'loop'
preserve trigger

Conditions:
nonplayable character has most ore
Actions:
clear 'loop'
preserve trigger

Conditions:
nonplayable character accumulates 10 ore
Enemies command 0 men
Actions:
End scenario in victory for current player

As you can see, I did use multiple triggers, a constant (accumulates 30 gas), and it might be able to loop
 
T

Tojso09

Guest
coded triggers above to test and prove that it does work

public class starcraftTrigger//anything after the slashes, //, use starcraft trigger jargon to help explain what is going on{
//note:this only works for one type of enemy spawning at a time

static boolean victory=false,loop=false;
//booleans are basically switches, false means cleared, and true means set

static int P2Ore=0, allopOre=0, p2gas=0;
//resources used (could be called "variables")

static int x=0,y=0;
//x is enemies in the wave, y is total enemies faced, both are used for data collection only, DO NOT TRY TO PUT INTO TRIGGER EDITOR, WILL NOT WORK

public static void main(String[] args)
{

/*Trigger 1*/

loop=false;
//this line is a trigger, but it is not preserved and the condition is always

while(!victory){
//unitl victory is declared in triggers, the program will keep going through triggers 2-7

/*Trigger 2*/

if(!loop){
//means if loop is cleared

allopOre++;
//means add 1 Ore to all players
P2Ore=1;
//continues previous statement

p2gas=0;
//sets player 2's gas to 0

loop=true;
//means set loop

y+=x;
x=0;}
//for data collection purposes

/*Trigger 3*/

if(loop){
//means if loop is set

x+=5;
//use spawn enemies at location with the x value in place

p2gas++;}

/*Trigger 4*/

if(p2gas>=30){
//means if player 2 accumulates at least 30 gas, also, the 30 can be changed into a smaller number to show how many times you want the enemy to spawn at the location in each wave

p2gas=0;
//sets player 2's gas to 0

P2Ore++;}

/*Trigger 5*/

if(P2Ore<allopOre)
//means if player 2 has least Ore

{loop=true;}
//means set loop

/*Trigger 6*/

if(P2Ore>allopOre)
//means if player 2 has most Ore
{loop=false;}
//means clear loop

/*Trigger 7*/

if(allopOre==100)
//the 100 can be changed to whatever amount of waves you wish

{victory=true;}
//means end scenario in victory for current player

/*Data Collection*/
System.out.println("Player 2 Ore:"+P2Ore+"\t\tPlayer 2 Gas:"+p2gas+"\t\tEnemies"+x+"\t\tEveryone else's Ore:"+allopOre+"\t\tTotal Enemies Fought:"+y);
// ^ prints out data collected in triggers in each iteration while no victory is declared ^

//under these settings you face almost 750000 enemies with up to 15000 per wave, TAKES A VERY VERY LONG TIME TO GO THROUGH
//by wave 40 over 100000 enemies are faced total with over 5000 enemies in wave

}}}
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top