In this tutorial, you will learn how to make a visible timer using the trigger editor. The timer will have a countdown, and the timer window will disappear when the time runs out, or the objective is complete. The tutorial is made for people new to triggers, and will cover creating, formatting, and working with Timers.
Reference 1 Shows the location of Point 001 and Point 002
This tutorial is using points as an example. When we're done, the timer will start when any unit comes close to Point 001, and stop if a unit comes close to Point 002.
Select Points from the top menu, and create two points with some distance between.
You should have the points Point 001 and Point 002 when you're done.
Creating a Timer
Our first trigger is the one creating the timer. Right click the white field to the left, and click New Trigger (Ctrl + T). Give it a fitting name, IE Create Timer.
Now, create a New Event (Ctrl + E).
Click the Unit filter, and then select Unit Enters/Leaves Point.
You may now edit the Event as you like. I've set Distance to 2, and Point to Point 001 (see reference 1).
Before we continue with the trigger, go ahead and rightclick the field to the left again. This time, select the New Variable (Ctrl + B). We will need our variables later on in the triggers. Name it Timer, and select Timer in the Type field. Create another variable, and name it Timer Window. Select Timer Window in the Type field. We are now done with our variables, and may continue to create our trigger.
Select the previously created trigger. It is now time to create the Actions, which are the ones creating the timer. Click New Action (Ctrl + R), and search for "start timer". Select Start Timer and hit OK. You may edit the attributes, just like the Event we created. However, Timer and Repeating should always be set to New Timer and One Shot respectively.
Create a new action, and select the Set Variable action. Set our Timer variable as the variable, and (Last Started Timer) as the value. This value can be found by clicking the Function radio button. Create another Action, and select Create Timer Window by searching for its name. Set Timer to the Timer variable we created, and type "Time Remaining:" in the Title field. This shows up beside the remaining time of our Timer. Create another Set Variable action, and set the Variable field to Set Timer Window. Set the value to (Last Created Timer Window), which again can be found by clicking Function. Now, the timer is created when a unit enters our point. But, to prevent multiple timers to start, create a new Action, and search for Turn Trigger On/Off. Leave the actions' fields as default.
Create a New Trigger (Ctrl + T), and name it "Timer Expires". Click New Event (Ctrl + E), and search for Timer Expires. Set the timer attribute to Any Timer. In order to check, if the expired timer is ours, go ahead and make a New Condition (Ctrl + K). Double-click Value 1 and click the Variable radio button. Select our Timer and hit OK. Set Value 2 to (Triggering Timer). Now, Create an Destroy Timer Window Action, and set the window field to our Timer Window variable.
Create our last trigger, by hitting New Trigger (Ctrl + T). Name it Point Reach, and create an Event. We will use the same Event as in our first trigger, however, the Point attribute should be set to Point 002 (see reference 1). Create a new action, and search for Pause/Unpause Timer. Set Timer to our Timer variable. Create an Destroy Timer Window action, and set the window field to our Timer Window variable. Create two Turn Trigger On/Off Actions, and leave the first Action as default. In the second Action, select our Timer Expires trigger.
Now, go back to our Create Timer trigger. Create two new Turn Trigger On/Off Actions. Set the first Action to Timer Expires, and the second Action to Point Reach. Set both Actions' State field to On. Select our Timer Expires trigger, and create two new Actions, both being Turn Trigger On/Off. Leave the first one as default, and change the *Trigger* field to our Point Reach trigger. Both State fields should be set to *Off*.
We are now done creating our timer. Launch the game, to check if you've made any mistakes. This is how it should look like ingame.
Now that we have created our timer, it is time to improve its layout and add some formatting.
This part of the tutorial is not required, and can be followed loosly if you want to. Strictly following the tutorial will give the result below.
Go to our Create Timer trigger, and edit the Create Timer Window's Title field. You can insert colors and text styles to change the visual of the text. You may insert below code, as an example.
To change the timers' color, create a new Action and search for Set Timer Window Color. Change the color to whatever you like. I've set the color to (100%, 50%, 50%) and set transparency to 0%.
You may want to change the layout of the timer, like I did in the image above. Go ahead and create a new Action. Search for Set Style for Timer Window. Leave the Elapsed field as default, and change the Style field as you like. I've chosen Vertical Title and Time in the image above.
At last, you may also want to change the time format. Create a New Action, and search for Set Time Format for Timer Window. This may be useful in some cases, where you do not need to show remaining Hours and/or Minutes.
Working with Timers
If you do not want your timer to trigger when a unit enters a set range around a point, you may edit the Events to match your needs.
Here are some examples of events:
It is also possible to make the timer repeat again and again, like an income/spawn timer. To do that, simply change the Start Timer actions' Repeating field to Repeating, instead of One-Shot.
You should now have a basic knowledge of the trigger editor and timers. Screenshots of triggers are attached below, aswell as the test map.
If you are looking for more trigger tutorials, click here. If you have any suggestions or questions to this tutorial, feel free to either comment or send me a PM.
Check out BorgDragon's Texture tutorial!
Blade with whom I have lived, blade with whom I now die, serve right and justice one last time, seek one last heart of evil, still one last life of pain, cut well old friend, and then farewell.
Is there a safe way to move the timer window to the existing in-game timer window? Or even replace it?
The "move timer window" is a dangerous fix because it relies on pixels, and different people will have different resolutions, and if you play on windowed mode, that will also influence the position of the timer window.
Perhaps what you did was create a local variable in the "Local Variables" tab rather than set a variable in the "actions" tab.
FYI: When you create a variable in the "Local Variables" tab, its default type will be "Integer". If you want to set it to a Timer related function, such as "Last Started Timer", you must change its type to "Timer".