Personal tools

ADVERTISEMENT

Triggers

From The StarCraft 2 Wiki

Jump to: navigation, search
A trigger is a function or series of functions that are programmed to happen in a map. Warcraft III triggers have 3 parts: Events, Conditions, and Actions; StarCraft triggers have a similar structure, but events are integrated directly into conditions and instead triggers include a list of which players the triggers are applied to. Triggers are the backbone of all map creation, whether it is a normal map, or a custom map, triggers are the structure that defines maps and allows the creation of intense battle scenes, to fun mini-games, to incredibly beautiful cinematic works of art.

[edit] Trigger Uses

Triggers, when combined with Variables correctly, can also create Dialog Menus, Score boards, Quests and Victory or Defeat Conditions. It is a general rule in mapmaking, that when using triggers for the first time, that the person starts out with something simple. A good example of a simple trigger is the following:

Untitled Trigger 001
    Events
        Unit - Barracks 0001 <gen> Dies
    Conditions
    Actions
        Game - Victory Player 1 (Red) (Show dialogs, Show scores)
The trigger above tells the game, that when the Barracks dies or is destroyed, that the game is now over, and Player 1 wins.

Here is an example of a more advanced trigger in 4 parts:
Begin Water Tint Setup
    Events
        Map initialization
    Conditions
    Actions
        Wait 1.00 seconds
        Set Water_Tint_Red = 100.00
        Set Water_Tint_Green = 100.00
        Set Water_Tint_Blue = 100.00
        Wait 5.00 seconds
        Trigger - Turn on Water Tint Change R <gen>
        Trigger - Turn on Water Tint Change G <gen>
        Trigger - Turn on Water Tint Change B <gen>
Water Tint Change Red
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        Set Water_Tint_Red = (Water_Tint_Red - 1.00)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Water_Tint_Red Less than or equal to 50.00
            Then - Actions
                Trigger - Turn off Water Tint Change R <gen>
            Else - Actions
                Do nothing
Water Tint Change Green
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        Set Water_Tint_Green = (Water_Tint_Green - 1.00)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Water_Tint_Green Less than or equal to 0.00
            Then - Actions
                Trigger - Turn off Water Tint Change G <gen>
            Else - Actions
                Do nothing
Water Tint Change Blue
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        Set Water_Tint_Blue = (Water_Tint_Blue - 1.00)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Water_Tint_Blue Less than or equal to 0.00
            Then - Actions
                Trigger - Turn off Water Tint Change B <gen>
            Else - Actions
                Do nothing

The four trigger examples above, are a way to change the tinting of water over a short duration of time, the end result color is a dark red color. The above can be done for fog coloring as well. This is also a good example of how Triggers and Variables can work together.