Triggers - Introduction To Triggers

Tutorial By WolfieeifloW

Introduction To Triggers
Written By: Wolfie[NoCT]

I know TriggerHappy187 has written one of these (over at Clan Mapz).
I read through it and felt that it didn't give a whole explanation of how/what was in the Trigger Editor.
Don't get me wrong, I think it's a good tutorial, but I wanted to further explain how the Trigger Editor works / the functions.
I also believe that my tutorial is also more newb friendly.
With that said, enjoy the tutorial!

So, you've wandered on into the wonderful world of Warcraft III map editing?
You're an amazing terrainer, but don't know anything about triggers?
You've looked around in that scary Trigger Editor, and just sat there staring at a blank screen?
Well then, you've come to the right tutorial.
By the end of this, you'll (hopefully) fully understand how to create and edit triggers.

Here's a quick rundown of what you'll see in this tutorial.

1. Opening The Trigger Editor
2. Parts Of The Trigger Editor
3. Creating A Trigger
4. Ending Words

1. Opening The Trigger Editor
To open the Trigger Editor, you can do one of two things:

• Press F4.
• Click on the 'a', (Image)

You're now in the Trigger Editor, easy right? Right.

2. Parts Of The Trigger Editor
So, you've opened your Trigger Editor, and you're staring at this:
Now, you're at a loss.
This is the part you fear.
You don't know what to do from here.
Well, that's why you're reading this ;) !

What you're looking at is called a "Trigger".
If you look on the left hand side, you'll see what's called a "Treeview".
It lists the names of the triggers you create.

Before we get more into that, you'll notice a folder named "Initialization".
These folders are called "Categories".
As the name implies, they'll help you categorize all your triggers.
This will make it easier to find each trigger you need later on when you have loads of triggers.
For example, you can create a category for "spawning triggers", another category for "spell triggers", and another for "reviving triggers", etc.

Notice how the toolbar you clicked on to enter the Trigger Editor has changed a bit.
There's now a few more buttons then there was before:
In order from left to right, these buttons are:

• Variable Editor
• Create New Category
• Create New Trigger
• Create New Comment Trigger
• Create New Event
• Create New Condition
• Create New Action

I'll explain each of these later.

You'll notice right below the toolbar, there's two check boxes.
One saying "Enabled" and one saying "Initially On".
Don't worry about these two things for now, just leave them checked.

Underneath this, there's a spot for "Trigger Comments".
You can write comments in here that will help you remember what the proceeding trigger is doing/going to do.
I recommend that you comment your triggers, regardless of your skill level.
It'll make things a lot easier for you when you start having more and more triggers.

Fairly basic so far, easy to understand? Good.

Now, remember that cool new toolbar that I said I'd explain later?
Well here we go!

Variable Editor

In simple terms, variables are used to store information.
This stored information can be used to carry information from one trigger to another.
Variables are also used to fix memory leaks, which I won't go into detail about (if you want more info, look here or here) .
For more in-depth looks at variables, there's multiple tutorials:

The keyboard shortcut for the Variable Editor is "CTRL + B".

Create New Category

Remember those "folders" in the Treeview?
They were called categories.
This button will create a new category:
After pressing the button, the new category will come up.
You can now name this category.
Name it something meaningful so that you know what triggers this category contains.
So for example, if this category is going to contain triggers related to spells;
A suitable name for the category would be "Hero Spells" or something of the like.
This way you know what kind of triggers are inside of the category at a quick glance.
To create a category, the keyboard shortcut is "CTRL + G".

Create New Trigger

The mother load of your map.
These are what make your map function.
When you press the Create New Trigger button, this is what you'll see:
Triggers are what will make your map function.
Without them, your map would just sit there.

Notice how I renamed my Category to "Trigger Editor Intro".
You'll also see that "Untitled Trigger 001" is highlighted right after making the trigger.
Rename the trigger according to what it will do.

For example, if the trigger is going to spawn units every couple seconds;
Name the trigger something like "Periodic Spawn".

You can also insert a Trigger Comment now, or you can do it later.

The keyboard shortcut to make a new trigger is "CTRL + T".

Create New Trigger Comment

Trigger Comments can be used to store notes, info, etc.
Upon clicking the New Trigger Comment button, you'll be greeted with this:
You can rename the comment to whatever name is desired, if you want.
These can be useful for certain things, but most of the time the Trigger Comments on the triggers themselves are enough.
Shortcut: "CTRL + M"

Create New Event

Events are what cause the trigger to be fired.
Say for instance, you want the trigger to run through when a unit dies.
You'd use the event "Unit - A unit Dies".
This is what it looks like when you create a new Event:
Notice how I added in a Trigger Comment.
This will help me remember what this trigger does without even having to read the code that I'll be putting in.

Without an event, your trigger will not run.
An event is what makes the trigger fire off.
It's like if you're trying to get a bottle of pop to explode when you open it.
Without shaking it first (which would be our "Event") it would never explode.
As you can see, an event is needed to make the rest of the trigger work.

I'll be explaining how to configure an event and use them in Part 3.
The shortcut for creating a new event is "CTRL + E".

Create New Condition

Conditions are what allow or deny the trigger to run.
If the condition passes (is True), the triggers Actions will run.
If the condition fails (is False), the triggers Actions will NOT run.
This is what it will look like when you create a new condition:
I'll explain conditions in more detail in Part 3.
Shortcut is "CTRL + D".

Create New Action

Actions are all the things that occur when the trigger runs.
They can do almost anything.
Actions are what make your map run;
Without them, your map would just sit there.
Here's what it looks like when you go to create a new action:
Back to the bottle of pop.
Remember how we wanted it to explode?
The action of the pop exploding would be the explosion itself.

Again, look at Part 3 for more of an explanation on Actions.
Oh, and the shortcut for creating a new action is "CTRL + R".

Well now look, you got scared for nothing.
Pretty simple stuff so far? Yes, of course it is.

3. Creating A Trigger
So, you know all the aspects of the Trigger Editor, but now you have to put that knowledge to use.

A couple things you'll need to know before we continue:

• Triggers can have multiple Events, Conditions, and, will most likely, have more then one Action.
• Triggers run instantly* (unless you have waits) .

* - Instantly is actually something like 0.20 seconds.
Even though there's this delay, there's something called "Trigger Queue";
This means when the event occurs again and the trigger fires, if the trigger is already running from a previous fire-up, the first firing of the trigger will be queued and wait to be finished until after the second run-through is done.

When you are configuring your trigger, you'll notice that there's Red and Blue values:
These Red values are "required" values.
They're values that need to be input before you can complete configuring the Event/Condition/Action.
The Blue text is just changeable values.

Reading is never as good as seeing, so let's get right to doing an example.

First off, go to the Melee Initialization trigger and delete this action:
Melee Game - Enforce victory/defeat conditions (for all players)
Which will make your Melee Initialization trigger look like this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Create starting units (for all players)
      • Melee Game - Run melee AI scripts (for computer players)

We delete this action so that we will not get victoried right away as we have no opponents.
Anyways, onto our example.

For our example, we will be making a footman spawn every 1.50 seconds at Player 1's starting location as long as Player 1 is still in the game.

First off, we need to make an event.
What do we use for our event you ask?
Well, since we are spawning a footman every 1.50 seconds, we'll use the event "Time - Periodic Event":

At default, as you can see, the trigger will be set to 2.00.
We want a spawn every 1.50 seconds.
So go ahead and change the 2.00 to 1.50 and then press OK.
This is what your trigger should look like:
  • Periodic Spawn
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
    • Actions
That's it for the event!
That was easy enough wasn't it? Of course it was.

Now, for this trigger we also need a condition.
The condition is "as long as Player 1 is still in the game." as said above.
So, for this condition we'll use a "Player Slot Status Comparison":

A "Slot Status" checks if a certain slot is being used, unused, or has left.
Used would be if the user is playing and in the game.
Unused is when the slot never had a player to begin with.
Has left is when the player has left the game.

Getting back to our condition;
Luckily for us, the condition is already setup for us :) !
This condition is basically saying "If Player 1 is playing".
This is what your trigger should now look like:
  • Periodic Spawn
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions

So, if Player 1 is indeed playing, the Actions will get run.
If Player 1 isn't playing, the rest of the trigger will not get run.
Speaking of Actions, that's what we have to configure next.

The finale!
The big ol' scary actions :eek: !
Well actually, they're not really scary at all.
Let's dissect what we're trying to do here:

• We want to spawn a unit
• We want 1 unit to spawn
• We want that unit to be a Footman
• We want the Footman to be owned by Player 1
• We want the Footman to spawn at Player 1's starting location

So, problem 1: Spawning a unit.
For this, we use the action "Unit - Create Units Facing Angle":

Again, luckily, most of the Action is already setup for us.
You'll notice the action is already ready to create 1 Footman for Player 1 (Red).
However, the action is going to spawn the unit at "(Center of (Playable map area))".
We want the unit to spawn at "(Player 1 (Red) start location)".
So, to change this, click on (Center of (Playable map area)).

This is what will come up:

We don't need the "Center Of Region", we need a "Player Start Location".

So, click on the Function: box, and select Player Start Location:
Again, Player 1 (Red) is already filled in for us, so just click OK.

You'll come back to the menu that used to look like this:

Except it will now look like this:

Click OK on this box to return to the trigger editor window.
You're trigger should now look like this:
  • Periodic Spawn
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing degrees

You can now test your map (CTRL + F9) .
A Footman should spawn every 1.50 seconds at your starting location.

You've just created your first trigger!

4. Ending Words
I hope this tutorial has helped you.
Any comments/suggestions are welcome (as long as their constructive) .
Constructive criticism is allowed, flaming is not.

Here's a little challenge for the people who used this tutorial;
A little note first though:
Please don't post the answers/solutions here.
Just try them yourself, them download the corresponding map.
The maps attached are the answers.
Anyways, here's the challenges:

• Make 2 Footman spawn at a time.
• Make a Footman spawn for Player 2 instead of Player 1 (still at Player 1's start location) .
• Make a Footman spawn for Player 2 at Player 2's starting location.

Enjoy the challenges!

Click here to comment on this tutorial.
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.