• 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,256
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,296
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,256
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.
 
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.
 
Level 23
Joined
Nov 20, 2005
Messages
1,256
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! 😅🥱
 
Level 23
Joined
Nov 20, 2005
Messages
1,256
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.
As suggested from @Dr Super Good , I've reset the value of OrcAvailableWaves to 0, and set it via trigger in the map initialization.
It was initially set to 4, directly through the variables tab, but for some reason the value would display as 5 in the leaderboard.

screenshot-2025-06-08-121741-png.536606


This is the trigger👇 that detects when the current wave you command drops to/under 6 elements.

screenshot-2025-06-08-121847-png.536607


This is the trigger👇 that activates when all units in the current wave are dead, and therefore when waves are down to 0 (otherwise the "6 remaining elements" threshold would trigger instead).

screenshot-2025-06-08-115027-png.536605


I've double-checked and there are no additional triggers that raise the amount of OrcAvailableWaves together with the ones whenever a gate is destroyed. Once again, this value seems to increase by 2 instead of 1.

I haven't tested the map with the updated function in the Map Initialization. I shall give it another go later and report.
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,296
You can use actions that display messages to help debug triggers. For example you can print one every time the decrement action runs, and print values such as number of units in the wave.

Although really poor compared to more professional debuggers such as in StarCraft II, it still is good enough to give some insight into the order and values of logic being run.
 
Top