• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Round system

Status
Not open for further replies.
Level 6
Joined
Aug 26, 2016
Messages
99
I’ve been suffering for about a week now, I want to make a round system in the map, but I can’t reset triggers, there are waves in the map, and after the player’s death I can’t make the trigger turn off completely and not after all the actions are completed so that without restarting the map, start the game again. Are there any options how to solve this problem?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
I'm guessing you're using Events like Elapsed Time for the Waves and the issue is that they can only happen once?

If so, you need to design your map with more advanced techniques, like the use of Timer variables to manage time.

Here's an example of a simple Wave system that uses Timers for spawning units periodically:
  • Start Waves
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start Wave_Timer as a Repeating timer that will expire in 60.00 seconds
      • Set Variable Wave_Current = 0
Now whenever this Repeating timer expires (every 60 seconds) we increase the current wave by 1 and run the associated wave trigger:
  • Events
    • Time - Wave_Timer expires
  • Conditions
  • Actions
    • Set Variable Wave_Current = (Wave_Current + 1)
    • Trigger - Run Wave_Trigger[Wave_Current] (ignoring conditions)
Wave_Current is an Integer variable and Wave_Trigger is a Trigger array variable.

Of course don't forget to actually setup the Wave_Trigger array with all of your Wave triggers:
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set Variable Wave_Trigger[1] = The trigger that handles the first wave
    • Set Variable Wave_Trigger[2] = The trigger that handles the second wave
    • Set Variable Wave_Trigger[3] = The trigger that handles the third wave
Do that for all of your wave triggers and you'll be good to go. In this case your wave triggers wouldn't have any Events or Conditions, they'd simply contain the Actions for spawning in the Units and whatever else you want to happen when a Wave starts.

Now whenever you want to "restart" the game you simply run the Start Waves trigger again:
  • Actions
    • Trigger - Run Start_Waves (ignoring conditions)
That will reset both Wave_Timer and Wave_Current so you get a fresh start.

Furthermore, you can replace all of your Elapsed Game time events with Timers set to One-shot mode (they stop once they expire). These could go in your Start Waves trigger as well, this way they repeat when you "restart" the game:
  • Start Waves
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start Wave_Timer as a Repeating timer that will expire in 60.00 seconds
      • Set Variable Wave_Current = 0
      • Countdown Timer - Start Alert_Timer1 as a One-shot timer that will expire in 15.00 seconds
      • Countdown Timer - Start Alert_Timer2 as a One-shot timer that will expire in 80.00 seconds
      • Countdown Timer - Start Alert_Timer3 as a One-shot timer that will expire in 200.00 seconds
So those Alert timers could be used for anything that you were previously doing with the Elapsed Time event.

This design can reduce the number of triggers/variables needed and help keep things efficient and organized.
I have a more advanced demonstration of it here: Custom Tower TD


Important Notes:
Starting a Timer that is currently running will reset it. You can Pause a Timer and Resume it whenever you'd like. Timer arrays can be useful but they have a special rule where they need to be initialized in the Variable Editor, which means that their array Size needs to be set to a number large enough to support the largest [index] used (basically, set it to however many of these timers you need). This rule can be avoided if you manually create the Timers yourself using Custom Script. Try to avoid using Waits since those can't be stopped. You can still use them but just make sure you know for a fact that they won't interfere with something else.
 
Last edited:
Status
Not open for further replies.
Top