Unlike the Data Editor which determines the general behavior of the game elements, the triggers dictate the events and actions that occur at specific points within a Starcraft II map. By setting an appropriate event, some acquirable conditions, and a few actions, you can easily make anything change or happen.
The first thing you need to know about the trigger editor, is how to open the window. There are a couple ways to do this.
- Pushing F6 will open the window for you.
- Going to Modules > Triggers
Now that the trigger window is open, you'll see quite a few areas.
The picture on the right could be what your trigger window may look like, depending on how far into a project you are.
There are four main parts to a trigger:
- Events: An event is what must happen before a trigger can run. You'll find plenty of these, such as "A unit enters an area", "A unit is attacked/Killed", "A Player pressed a Key", and plenty of other. What this means is that any time this event occurs, this trigger will run and perform what it was written to do.
- Conditions: It wouldn't be sensible to have all types of one event always run a trigger, even if we don't want it to. For instance, we may want a trigger that only runs when a player has a unit in an area and that unit is killed. If we do either event, it wont check to see if the other one is met though. This is why conditions were made. They are simple comparative statements that must be true to let the trigger continue to run. In this case, we could say to run the trigger on the event that a unit is killed, and the condition that the unit is in the specified area.
- Variables: Remember back to algebra class, when we would say that X is some variable for an unknown value? This is the same concept, except that we specify it's contents, which can range from numbers to units to triggers to... just about anything! In fact, there are about 70 different types of variables, all for some sort of data in StarCraft II. These can be defined to be global variables outside of the triggers, accesable by all triggers, or local variables within a trigger, meaning each one can only be used inside of whichever trigger it was created.
- Actions: Actions are what are performed assuming both the event runs the trigger and the conditions are met to allow the trigger to continue. These can be anything from doing actions with units, with resources, with the camera, the game, the environment, you name it. Pretty much anything in the game you can think of can be changed with these actions.
- Comments: Comments are inconsequential to the function of the map, and only serve as a reminder or description of the trigger.
Triggers are run in the given order, Events -> Conditions -> Actions. An event must start the trigger, it's conditions must pass, and then the actions can take place.
Trigger Window Hotkeys
- Ctrl + T creates a new trigger.
- Ctrl + E creates a new event.
- Ctrl + K creates a new condition.
- Ctrl + R creates a new action.
- Ctrl + B creates a new variable.
- Ctrl + W creates a copy of the selected 'type' if on the left menu. For example, if you currently have a Variable selected, it'll create a new Var. It does the same for Folders, Triggers, etc. If in the right menu, it'll either create a new Event, Condition, Variable or Action based on the field you have selected. This is a very useful hotkey, as you can see.