Triggers - Basic Guide

Tutorial By Husky

Husky_003's Guide to Trigger Basics

Firstly, before I go into the details, I just have to say that; Triggers are usually straight forward but a lot of newbies think they are much harder than they appear.
The problem is: Ususally they don't try the trigger before they ask how to do it, they just blurt out: How do I do this, how do I do that. If you are quite new, i'm telling you, look through the trigger list, what the triggers say are usually what they do.

Okay here are the details of the 3 types of triggers (Events, Conditions, Actions)

THE 3 TRIGGERS SIMPLIFED
Events - If something happens it will will set off the Action (Checking Conditions if there are any)
Conditions- These check that a unit is a colour is in a region etc. The Action will not set off unless these are all correct (are used).
Actions - These are the core, this will do what you want to happen.

THE 3 TRIGGERS IN MORE DETAIL
EVENTS:
To put it simply an Event is what sets a trigger off. You can do pretty much what you want here.
E.G: You want a unit to be killed if it enters a region. You would use the Event:
Trigger:
  • Unit - A Unit enters *Your region*.


Thats the basic event and it should get your job done. There are easy events like that and other more complex ones like: Dialog - A Dialog button is clicked. Do get this to work you would have to create a trigger that creates your Dialog with its buttons and use Variables, which would store your button and yur dialog ( I will get more complex stuff like this later on).

CONDITIONS:
Conditions play a major part in triggers, and are similarily linked to Events, as an Action will not set off unless all Conditions are "True".
Some common Conditions are as followed:
Trigger:
  • Conditions
    • #1(Unit-type of (Triggering unit)) Equal to *Your Unit*
    • #2(Ability being cast) Equal to *Your Ability*
    • #3(Item-type of (Item being Manipulated)) Equal to *Your item*


So for #1 the trigger would only fire if that type of unit was in (whatever you event was, in this case we'll say he had to be in a certain area of the map) a certain region.

ACTIONS:
As I said in the simplified section, Actions are the core of a trigger, here is where you do what you want to happen. There are hunderds of different actions, so on the most part, you should find what you want here.

A FEW BASIC TRIGGERS

Lets say someone asks:

"How do I create a unit at a place in the map!?!"

This is extremely easy. Heres how to do it:

•Create a region (under the Region Pallete in the terrain editor). it can be however big or small you want.
•Once created its reccomemnded that you name it, and if you have lots of regions: Colour Code them (right-click the region and choose: Edit Region Properties.
•Now enter the wierd and wonderful world of the trigger editor and create a new trigger labbeled something like: Create Unit, your choice.
•Now You must create an Event. It's reccomended that you go look for the event and then come back here to check if its the right one (that's the way to learn) NOTE: This event is one that you might not have first thought.
Anyway the event is:
Trigger:
  • Elapsed Game Time Equal to *Your Seconds*.


•Most triggers that don't really need an Event will usually use that Event.
•Ok what conditions? Well in this case were not really going to need one, as its a pretty staright forward trigger.
•Ok, the Action should be much easier to guess than the Event. It is:
Trigger:
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees


So you should have a final trigger like this:
Trigger:
  • Trigger Basics
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees


Of course yours will be modified accordingly.

Here's another one. Lets say you wanted a unit to die if he walks into some sinking sand or a swump you made somewhere in your map.

•Ok, Obviously your going to have to create a region. Make this region over your swamp/sinkinh sand, whatever.
•The Event is pretty straight forward.
Trigger:
  • Unit - A Unit enters *your region*

•We'll leave Conditions out for this one.
•The Actions are also pretty staright forward for this one.
Trigger:
  • Unit - Kill (Triggering Unit)


SPECIAL NOTE: If noticed in that trigger I had (Triggering Unit) (which is there by default). It is commonly used for triggers like this, as Triggering Unit means the unit that did whatever you wanted it to do.
If you go back to that same trigger and click the (Triggering Unit) a new window appears and there is a pull down menu by the word:
Trigger:
  • Function: Event Reponse - Triggering Unit
.
If you click that pull down menu a whole list of options will appear, most of them make perfect sense if you just read them straight off.

So for the above trigger instead of using:
Trigger:
  • Unit - Kill (Triggering Unit)

We could also use:
Trigger:
  • Unit - Kill (Entering Unit)


It should have the same desired effect, becuase its the Unit entering the region.

Final Trigger:
Trigger:
  • Trigger Basics
    • Events
      • Unit - A unit enters *your region*
    • Conditions
    • Actions
      • Unit - Kill (Triggering unit)


So it aint particualry hard is it?

Of course that trigger is extremely basic, we could use something a lot more complex like this:
This trigger is meant to simulate: If a unit walks over the sinking the sand 3 times he is killed, the unit must be a Paladin, and he has to have the Item:Claws of Attack.

Since this is quite complex it has to be set into more than one trigger.

In this trigger, we are making it so that if he walks over it it will ad +1 to the total number of times walked over it. A variable was used for this so its not a very easy trigger to make.
Anyway here it is:

Trigger:
  • Quote:
    • Swamp
    • Events
    • Unit - A unit enters Swamp <gen>
    • Conditions
    • (Unit-type of (Entering unit)) Equal to Paladin
    • ((Entering unit) has an item of type Claws of Attack +15) Equal to True
    • Actions
    • Set Walk_Over_Swamp = (Walk_Over_Swamp + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
      • (Walk_Over_Swamp Equal to 3)
      • Then - Actions
      • (Unit - Kill (Entering unit))
      • Else - Actions
      • (Do nothing)


So it had for everytime he enters that region it adds +1 to the total, if the total equals 3, he's dead.

GENERAL MAPPING & TRIGGER NOTES

Triggers are your best friend and your worst enemy at the same time. They can do nearly anything you want them to do, but at the same time, getting them to work is a whole different story.

For newbies, do not start a huge mapping project (a TD, the greatest Hero War out there, an awsome RPG) straight off, start small, make a small mini-game map, maybe a very small Hero War, with only a few triggers a custom unit or two. Quality not Quantity!

A few helpful hints:
•If your stuck on a trigger thehelper.net is your best friend. But read the rules first.
•Save your map as often as you can be bothered (and every so often under a different name, so you don't lose all your hardwork).
•As mentioned above dont start a big project straight off.
•Test often.
•If you do finish a map and want to post it up here, eradicate as many bugs as possible before you do.
•The World Editor is huge, it can go to unbeliveable depths. Recreating a Blizzard campaign is not very hard.
•Plan out maps before creating them.
•Search the Forum before posting up your question. Theres 200 pages of threads on this site, your question is bound to be there somewhere.
•Check out the Free Trigger Code Thread, there are some great triggers there.
•Check out http://www.wc3sear.ch. There are some great custom models/icons/skins you name it there. But read the tutorials on how to import stuff first.
•<===== Over that-a-ways there is a link bar to one of the best world editor tutorials site out there.

I will add, more triggers to this guide as soon as I can, I will leave an update message aswell so you know when somethings been added.

Happy Mapping,
-husky_003

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.