• 🏆 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!

How to create a sucessfull timer.

Level 10
Joined
Aug 19, 2008
Messages
491
How to create a succesfull timer.
This tutorial will show you how to make a succesfull timer window using GUI.

The Main Idea
I have noticed when playing games online that many of the windows never dissapeared.
This may be caused by, for example, using

  • Level 1
    • Events
      • Time - Timer[1] expires
    • Conditions
    • Actions
      • Time - Destroy (Last created timer window)
In this case it refers to (Last created timer window) which can be another timer, meant for ressurecting a hero for example, and it can get very troublesome...
I wish to help you with this :thumbs_up:

This particular timer tutorial is mainly used for Hero Siege, possibly Tower Defence as well.
It will make the creeps spawn at the starting location of a player, if he/she/it is playing.


Theese triggers will make it easy for you to create more levels to you Tower Defence or Hero Siege.

Words that might come in handy:
GUI Trigger
  • GUI Trigger
    • Events
    • Conditions
    • Actions
Variable
A variable origins from math. It's originally a holder for a number, like (X=2)
In this case, variable X is equal to 2, so when calculating 2+X it would be the same as 2+2

Variables in The World Editor is not always a number (although it can be number), it can keep track of, for example, a Hero,
a player or in this case, a timer window.

Using [ ]
I use [ ] to represent variables and similiar stuff which is supposed to be read as one string. Very useful when reading lots of texts.


Tutorial Start


Step 1
Creating Variables

(To create a variable, go to [Trigger Editor->Variables])
Variable.JPG


Create theese variables:

Current_Level
Integer
0 (Default)

Next_Level_Timer
Timer
New Timer (Default)

Timer_Window_Level
Timer Window Array (1)
- None -

Explenations:
The first variable is used, combined with the third, to tell the editor which timerwindow to destory later on.

The second is the timer itself, used to trigger the next level of your map.

The third is used, combined with the first, to tell the editor which timerwindow to destory later on.

Step 2
Creating the triggers

Create the following triggers:

  • Variable Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Current_Level = 0
  • First Level Initialization
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start Next_Level_Timer as a One-shot timer that will expire in 29.oo seconds
      • Countdown Timer - Create a timer window for Next_Level_Timer with the title Level 1 in...
      • Countdown Timer - Show (Last created timer window)
      • Set Timer_Window_Level[1] = (Last created timer window)
  • Level 1
    • Events
      • Time - Next_Level_Timer expires
    • Conditions
    • Actions
      • Set Current_Level = (Current_Level + 1)
      • Trigger - Turn off (This trigger)
      • Player Group - Pick every player in (All Players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • -------- The units to be created ------
              • Unit - Create 5 Grunt for Player 10 (Light Blue) at ((Picked player) start location) facing Default building facing degrees
              • -------- Endfunction ------
            • Else - Actions
              • Do nothing
    • Countdown Timer - Hide Timer_Window_Level[(Current_Level)]
    • Countdown Timer - Destroy Timer_Window_Level[(Current_Level)]
    • -------- Next Level ------
    • Countdown Timer - Start Next_Level_Timer as a One-shot timer that will expire in 30.00 seconds
    • Countdown Timer - Create a timer window for Next_Level_Timer with the title Level 2 in...
    • -------- Endfunction ------
    • Countdown Timer - Show (Last created timer window)
    • Set Timer_Window_Level[(Current_Level + 1)] = (Last created timer window)
    • Wait 2.00 seconds
    • -------- Turn on next level --------
    • Trigger - Turn on Level 2 <gen>
    • -------- Endfunction ------


Step 3
Making new levels

It is very simple:
1: Ctrl + C "Level 1"
2: Rename to "Level 2"
3: Change the actions wraped around comments:

  • Actions
    • -------- Next Level ------
    • Countdown Timer - Start Next_Level_Timer as a One-shot timer that will expire in 30.00 seconds
    • Countdown Timer - Create a timer window for Next_Level_Timer with the title Level 2 in...
    • -------- Endfunction ------
  • Actions
    • -------- The units to be created ------
    • Unit - Create 5 Grunt for Player 10 (Light Blue) at ((Picked player) start location) facing Default building facing degrees
    • -------- Endfunction ------
  • Actions
    • -------- Turn on next level ------
    • Trigger - Turn on Level 2 <gen>
    • -------- Endfunction ------

Summary


If you examine the triggers you will see that almost everything is done automaticly
For example:
Each level sets [Current_Level] to [(Current_Level + 1)], which makes the World Editor know that "Aha! This is a new level!"
Each level also creates a new timer window and sets it to [(Current Level + 1)].

So, for example, if [Current_Level] Equal to 1, then, when a timer expires, it will Destroy [Timer_Window_Level[1]], beacuse it is supposed to destroy [Timer_Window_Level[(Current_Level)]]
Then, it will set the new created timer window to [Timer_Windo_Level[(Current_Level) + 1]], so that next time a timerwindow is destroyed, it will destroy the right one.


The End


I do hope you will find the tutorial helpfull.
The only thing I find annoying is that we'll have to change "...with the title Level # in..."
 
Last edited:
Top