• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Limited reinforcement waves

Level 23
Joined
Nov 20, 2005
Messages
1,255
Hello. I have a problem with triggers in the map I'm creating, where you lead an army of mixed units, and a scoreboard displays how many remaining additional waves you have before Game Over, sort of acting like a "Player Life" counter on screen.
  • When you have 6 remaining units, a new wave spawns at the starting point of the map.
  • When you destroy gates to advance into the next sector, 2 additional waves are added to the HUD scoreboard and the variable that stores the number of available waves.
  • When you reach 1 waves, that's the last reinforcement wave you get, before it turns to 0, then when all units get killed it's Game Over.

Now, what's the problem? I get only 1 additional wave, but by the time that new wave dies, it's game over.
Anyone can help me to build an accurate working system for this, please?
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,295
To track waves remaining, use an integer global variable (which are just regular variables in GUI). If your map is multiplayer and you want this mechanic to apply to many players, then turn that integer global variable into an array where the array index is the player slot, mapping player slot number to their units remaining.

  • At map initialisation you set the integer variable to the number of additional waves the players should start with.
  • Another trigger adds 2 to the integer variable in response to the gates being destroyed. If this is a team game you might need to loop through all relevant, allied, players and add 2 to the integer for them.
  • An on unit death trigger counts how many appropriate units a player has remaining. When units remaining is less than or equal to 6 and the integer variable is greater than 0 run your reinforcement wave logic which spawns the new units and reduces the integer variable by 1. If units remaining is 0, run your defeat logic. Be aware that counting units typically involves unit groups which are prone to resource leaks, I strongly recommend you read up about this and add the appropriate clean up code to prevent such leaks.
 
Level 23
Joined
Nov 20, 2005
Messages
1,255
At map initialisation you set the integer variable to the number of additional waves the players should start with.
First off, thank you so much for the help! 🙏
This is the only step that I seemingly haven't accurately done: setting the integer variable to the number of additional waves the players should start with.
I did it out of map initialisation.
Everything else has been set exactly as you explained. The matter about the units counting which involves resource leaks is something that I need to address as well.
Also, it looks like whenever I want to increase or decrease the waves variable, it increases/decreases by 2 instead of 1. I still haven't understood why. There appear to be no more than 1 trigger to handle that function.
I just tested the map and it successfully gave me reinforcement 2 times, before I managed to complete it.
It's a campaign map, so it doesn't involve teams or other human players.
 
Level 23
Joined
Nov 20, 2005
Messages
1,255
Would you be able to share your triggers? It sounds like you're on the right track, but the trigger may be running multiple times. But it is hard for us to tell without knowing the code.

Otherwise we could come up with a sample map that you could use, if that helps to compare your code against.
Yes, I agree. I'm gonna do this tomorrow; I'm in serious hurry of going to sleep now! 😅🥱
 
Top