• 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,253
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.
 
Top