- Joined
- May 21, 2008
- Messages
- 218
GUI Complete Trigger Tutorial by Zypher-
What will this tutorial teach you?
A trigger is something that happens when something happens in a warcraft game.
Ex: A unit dies Then do this: Create unit for Player 1 Red
A trigger consists of 3 parts:
Event-Something that happens that makes the trigger activate/go.
Condition-If this isn't met then the trigger won't run.
Action--What happens when your trigger runs and the condition(s) are met.
An analogy for a trigger would be:
Imagine there is a marble a track and a hole it has to go into to come out the other side.An event is like putting the marble down on the track, a condition is the marble will only go out the other side if the hole is big enough, the action is going out the hole and whatever happens after that.
Example:
I will explain how this works.
Event-This trigger runs everytime a unit dies
Condition-If this is met then the actions will run (In this case if the dying unit is a footman then the action will run.)
Action-In this trigger when executed it creates a footman for player 1 red at the center of the playable map area(the map) facing 0 degrees (left)
An event is something that happens that makes a trigger run. These include the following. Bolded text is changeable to equel, not equel, greater than, less than, greater than or equel to, less than or equel to. The underlined text is changed to your variable, a preset, or a raw id(selecting something). Astricks (*) are the exception for bold text.
General Event
-Map initialization (start of map)
Destructible Event
-Destructible dies (a killable doodad dies)
-Destructible within reigon dies (unit dies in a preset reigion (reigion pallete))
Dialog Event
-A dialog button is clicked for dialog (player clicks a dialog button for a created dialog)
Game Event
-The in-game time of day becomes Equal to Time (Time = time of virtual day in wc3)
-Variable becomes equal to Number (a precreated real variable becomes equal to a number)
-A saved game is loaded (campains, just what it says)
-The game is about to be saved (player trys to save the game)
-The hero abilities button is clicked (the red plus on a learning hero is clicked)
-The build structure button is clicked (the hammer icon on a builder (exeon) is clicked)
-The tournament game must end now (0.o no idea what this is)
Player Event
-Player types a chat message containing text as an Exact Match* (just what it says)
-Player skips a cinematic sequence (player presses escape key (useable outside of cinematics))
-Player selects* a unit (a player selects any unit)
-Player presses* the left* arrow key (player presses an arrow key)
-Player's current gold * becomes equal to Number (does what it says)
-Player changes Alliance settings (player changes alliance via the alliance menu)
-Player changes Alliance (non-aggression) settings (same as above?)
-Player leaves the game with a victory (player wins)
-Player leaves the game with a defeat (player loses)
-Player leaves the game (player leaves)
Time Event
-Elapsed game time is number seconds (time thats gone by is equal to (number) seconds)
-Every number seconds of game time (periodic event that fires every x number of seconds)
-timer expires ( a created timer expires)
Unit event
-Unit Dies*(specific) (a specific unit dies)
-A unit owned by Player Dies*(generic) (a unit owned by a player dies)
-A unit Dies*(generic) (does what it says)
-A unit enters Reigon(generic) (a unit enters a premade reigion (reigion pallete))
-A unit leaves Reigon(generic) (a unit leaves a premade reigion (reigion pallete))
-A unit comes within Number of Unit(generic) ( a unit comes within range of a specific unit)
-Unit's life becomes Less than Number(specific) ( a units life becomes less than x)
-Unit's mana becomes Less than Number ( a units mana becomes less than x)
A condition is something that a trigger checks before it runs it's actions. If the condition is met then the actions run and the trigger does something. These include the following. Bolded text is changeable to equel, not equel, greater than, less than, greater than or equel to, less than or equel to. Titles of conditions are bolded so you can see them better. The underlined text is changed to your variable, a preset, or a raw id(selecting something). Astricks (*) are the exception for bold text.
Boolean comparison
-checks for something and can come back true or false
Ability comparison
-checks what ability is being cast Ex: Acid Bomb
Buff comparison
-checks to see if a buff variable is a certain buff Ex:Bloodlust
Destructible comparison
-checks to see if a destrucible is equal to a variable or other destructible. Ex: Summer Tree wall
Destructible type comparison
-checks to see if the destructible is a certain type Ex: Summer Tree Wall
Dialog button comparison
-checks to see if the clicked dialog button is a certain dialog button
Game difficulty comparison
-checks game difficulty to see if it is a certain difficulty Ex: easy
Game speed comparison
-checks the game speed to see if it's a certain game speed Ex:fast
Hero Skill Comparison
-checks to see if the learned hero skill is a certain skill Ex:Holy Light
Integer Comparison
-checks to see if an integer is equal to a Number
Item Comparison
-checks to see if an item being dropped, manipulated, or aquired ect. is a certain item
Item Class Comparison
-checks to see if an item class is a certain class Ex: Power-Up
Item Type Comparison
-checks to see if an item type is a certain item type Ex: Talismen of Evasion
Melee AI Comparison
-checks to see if a computer player's level is a certain level Ex: easy,normal,insane
Order Comparison
-checks to see if an order is a certain order
Player Comparison
-Many different variations on this one, I'll list a few. Owner of unit, Owner of Item, Picked player, Triggering player is a certain player Exlayer 1 Red
Player Color Comparison
-checks if the color of Player is a certain color
Player Controller Comparison
-checks to see the controller of a player Ex: computer, neutral, player
Player Slot Status Comparison
-checks to see if a player's slot status is a certain slot status Ex: Playing, Unused, Left
Race comparison
-checks to see if a players race is a certain race Ex: Human, Undead
Real comparison
-Checks to see if a Number is equal to a Number
String Comparison
-checks a string(text) to see if it is a certain string Ex:-save
Tech-Type Comparison
-checks to see if the researched tech-type is a certain tech type
Terrain Type Comparison
-checks to see if the terrain type at a Point is a certain terrain type.
Trigger Comparison
-checks to see if a trigger is a certain trigger(variable)
Unit Comparison
-checks to see if a unit is a certain unit Ex: Picked unit equal to casting unit
Unit Type Comparison
-checks to see if a unit is a certain type Ex: Footman
And(multiple conditions)
-Only used when using the or state ment so you could do condition or condition and condition
Or(multiple conditions)
-Used so If any of the conditions are true the actions run
An action is the part of a trigger that does something, an action only runs if the conditions are met. For the sake of time I am only going to post catagories of actions as it is not completely necessary for me to spend an hour writing down all the actions. On request I will write them down in this tutorial. The following are action catagories.
AI
Animation
Camera
Cinematic
Countdown Timer
Destructible
Dialog
Enviroment
Floating Text
Game
Game cashe
Hero
Item
Image
Leaderboard
Lightning
Melee Game
Multiboard
Neutral Building
Player
Player Group
Quest
Reigon
Selection
Sound
Special Effect
Trigger
Unit
Unit Group
Ubersplat
Visibility
If you combine these events, conditions,and actions you can do just about anything in warcraft 3. Heres an example trigger just for you to look at and guess at what it does.
A variable is a reference to data stored in the computer's memory, variables are used to store values and get them back (in the case you want to use them again). A variable can be a number, unit, destructable, terrain type, ect...
You can create a variable by using the variable editor in the trigger section. Just click the green x to adda variable. Pick a type and a name. When using variable it should look a bit like this.
It can be set to anything using the set variable = Something action.
Setting a variable
A loop is something that keeps going until through or cleared. Loops are another tricky thing to understand but in my opinion are by far the most useful, time-saving action/function in warcraft 3. LOOPS ARE ALSO YOUR FRIENDS (I know this personally because I used to make long ass triggers instead of using loops). Heres an example trigger for a loop.
Defeating a computer empty slot status player
The best GUI tool ever. Leak check.
-----------------------------------------------------------------------------------
This is what I used and now use in all my triggers ^
There is no such thing as GUI expert , now it's time you start learning jass.
The rest is up to you, have fun creating maps with triggers. If you still don't get it and need help creating a trigger then just ask and I'll be happy to help. Some other talents of mine include: loading screens, loading minimap, any graphic design Ex:skinning. If you need any of those I will probably be willing to help. In conclusion I hope everyone who read this learned a little something about triggering. I also hope the 4 hours I put into this tutorial don't go to waste.My warcraft 3 account is named Zypher and I am in no way aphiliated with the other Zypher that lurks THW, just a coincidence. Happy triggering.
-Zypher
By Zypher
What will this tutorial teach you?
- -------------------
- Beginner
- What is a trigger?
- What is an event?
- What is a condition?
- What is an action?
- How can I make these work to my advantage?
- --------------------
- Intermediate
- What is a variable?
- What is an array?
- What is a loop?
- What is a memory leak?
- Side Notes to remember.
- --------------------
- Expert
- There is no such thing as GUI expert , now it's time you start learning jass.
Beginner
What is a trigger?
A trigger is something that happens when something happens in a warcraft game.Ex: A unit dies Then do this: Create unit for Player 1 Red
A trigger consists of 3 parts:
Event-Something that happens that makes the trigger activate/go.
Condition-If this isn't met then the trigger won't run.
Action--What happens when your trigger runs and the condition(s) are met.
An analogy for a trigger would be:
Imagine there is a marble a track and a hole it has to go into to come out the other side.An event is like putting the marble down on the track, a condition is the marble will only go out the other side if the hole is big enough, the action is going out the hole and whatever happens after that.
Example:
-
A trigger
-
Events
- Unit - A unit Dies
-
Conditions
- (Unit-type of (Dying unit)) Equal to Footman
-
Actions
- Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
-
Events
I will explain how this works.
Event-This trigger runs everytime a unit dies
Condition-If this is met then the actions will run (In this case if the dying unit is a footman then the action will run.)
Action-In this trigger when executed it creates a footman for player 1 red at the center of the playable map area(the map) facing 0 degrees (left)
What is an event?
An event is something that happens that makes a trigger run. These include the following. Bolded text is changeable to equel, not equel, greater than, less than, greater than or equel to, less than or equel to. The underlined text is changed to your variable, a preset, or a raw id(selecting something). Astricks (*) are the exception for bold text.
General Event
-Map initialization (start of map)
Destructible Event
-Destructible dies (a killable doodad dies)
-Destructible within reigon dies (unit dies in a preset reigion (reigion pallete))
Dialog Event
-A dialog button is clicked for dialog (player clicks a dialog button for a created dialog)
Game Event
-The in-game time of day becomes Equal to Time (Time = time of virtual day in wc3)
-Variable becomes equal to Number (a precreated real variable becomes equal to a number)
-A saved game is loaded (campains, just what it says)
-The game is about to be saved (player trys to save the game)
-The hero abilities button is clicked (the red plus on a learning hero is clicked)
-The build structure button is clicked (the hammer icon on a builder (exeon) is clicked)
-The tournament game must end now (0.o no idea what this is)
Player Event
-Player types a chat message containing text as an Exact Match* (just what it says)
-Player skips a cinematic sequence (player presses escape key (useable outside of cinematics))
-Player selects* a unit (a player selects any unit)
-Player presses* the left* arrow key (player presses an arrow key)
-Player's current gold * becomes equal to Number (does what it says)
-Player changes Alliance settings (player changes alliance via the alliance menu)
-Player changes Alliance (non-aggression) settings (same as above?)
-Player leaves the game with a victory (player wins)
-Player leaves the game with a defeat (player loses)
-Player leaves the game (player leaves)
Time Event
-Elapsed game time is number seconds (time thats gone by is equal to (number) seconds)
-Every number seconds of game time (periodic event that fires every x number of seconds)
-timer expires ( a created timer expires)
Unit event
-Unit Dies*(specific) (a specific unit dies)
-A unit owned by Player Dies*(generic) (a unit owned by a player dies)
-A unit Dies*(generic) (does what it says)
-A unit enters Reigon(generic) (a unit enters a premade reigion (reigion pallete))
-A unit leaves Reigon(generic) (a unit leaves a premade reigion (reigion pallete))
-A unit comes within Number of Unit(generic) ( a unit comes within range of a specific unit)
-Unit's life becomes Less than Number(specific) ( a units life becomes less than x)
-Unit's mana becomes Less than Number ( a units mana becomes less than x)
What is a condition
A condition is something that a trigger checks before it runs it's actions. If the condition is met then the actions run and the trigger does something. These include the following. Bolded text is changeable to equel, not equel, greater than, less than, greater than or equel to, less than or equel to. Titles of conditions are bolded so you can see them better. The underlined text is changed to your variable, a preset, or a raw id(selecting something). Astricks (*) are the exception for bold text.
Boolean comparison
-checks for something and can come back true or false
Ability comparison
-checks what ability is being cast Ex: Acid Bomb
Buff comparison
-checks to see if a buff variable is a certain buff Ex:Bloodlust
Destructible comparison
-checks to see if a destrucible is equal to a variable or other destructible. Ex: Summer Tree wall
Destructible type comparison
-checks to see if the destructible is a certain type Ex: Summer Tree Wall
Dialog button comparison
-checks to see if the clicked dialog button is a certain dialog button
Game difficulty comparison
-checks game difficulty to see if it is a certain difficulty Ex: easy
Game speed comparison
-checks the game speed to see if it's a certain game speed Ex:fast
Hero Skill Comparison
-checks to see if the learned hero skill is a certain skill Ex:Holy Light
Integer Comparison
-checks to see if an integer is equal to a Number
Item Comparison
-checks to see if an item being dropped, manipulated, or aquired ect. is a certain item
Item Class Comparison
-checks to see if an item class is a certain class Ex: Power-Up
Item Type Comparison
-checks to see if an item type is a certain item type Ex: Talismen of Evasion
Melee AI Comparison
-checks to see if a computer player's level is a certain level Ex: easy,normal,insane
Order Comparison
-checks to see if an order is a certain order
Player Comparison
-Many different variations on this one, I'll list a few. Owner of unit, Owner of Item, Picked player, Triggering player is a certain player Exlayer 1 Red
Player Color Comparison
-checks if the color of Player is a certain color
Player Controller Comparison
-checks to see the controller of a player Ex: computer, neutral, player
Player Slot Status Comparison
-checks to see if a player's slot status is a certain slot status Ex: Playing, Unused, Left
Race comparison
-checks to see if a players race is a certain race Ex: Human, Undead
Real comparison
-Checks to see if a Number is equal to a Number
String Comparison
-checks a string(text) to see if it is a certain string Ex:-save
Tech-Type Comparison
-checks to see if the researched tech-type is a certain tech type
Terrain Type Comparison
-checks to see if the terrain type at a Point is a certain terrain type.
Trigger Comparison
-checks to see if a trigger is a certain trigger(variable)
Unit Comparison
-checks to see if a unit is a certain unit Ex: Picked unit equal to casting unit
Unit Type Comparison
-checks to see if a unit is a certain type Ex: Footman
And(multiple conditions)
-Only used when using the or state ment so you could do condition or condition and condition
Or(multiple conditions)
-Used so If any of the conditions are true the actions run
What is an action?
An action is the part of a trigger that does something, an action only runs if the conditions are met. For the sake of time I am only going to post catagories of actions as it is not completely necessary for me to spend an hour writing down all the actions. On request I will write them down in this tutorial. The following are action catagories.
AI
Animation
Camera
Cinematic
Countdown Timer
Destructible
Dialog
Enviroment
Floating Text
Game
Game cashe
Hero
Item
Image
Leaderboard
Lightning
Melee Game
Multiboard
Neutral Building
Player
Player Group
Quest
Reigon
Selection
Sound
Special Effect
Trigger
Unit
Unit Group
Ubersplat
Visibility
How can I make these work to my advantage?
If you combine these events, conditions,and actions you can do just about anything in warcraft 3. Heres an example trigger just for you to look at and guess at what it does.
-
Player Leaves Game Gold Division
-
Events
- Player 1 Red leaves the game
- Player 2 Blue leaves the game
- Player 3 Teal leaves the game
- Player 4 Purple leaves the game
- Player 5 Yellow leaves the game
- Player 6 Orange leaves the game
- Player 7 Green leaves the game
- Player 8 Pink leaves the game
- Player 9 Grey leaves the game
- Player 10 LightBlue leaves the game
- Player 11 Brown leaves the game
- Player 12 DarkGreen leaves the game
- Conditions
-
Actions
- Set LeavingPlayer = (Triggering player)
- Set LeavingPlayersGold = (LeavingPlayer Current gold)
- Set LeavingPlayersLumber = (LeavingPlayer Current lumber)
- Set AllPlayers = (All players)
- Player Group - Remove LeavingPlayer from AllPlayers
-
Player Group - Pick every player in AllPlayers and do (Actions)
-
Loop - Actions
- Player - Add (LeavingPlayersGold / (Number of players in AllPlayers)) to (Picked player) Current gold
- Player - Add (LeavingPlayersLumber / (Number of players in AllPlayers)) to (Picked player) Current lumber
-
Loop - Actions
- Set LeavingPlayersGold = 0
- Set LeavingPlayersLumber = 0
- Custom script: Call DestroyForce (udg_AllPlayers)
-
Events
Intermediate
What is a variable?
A variable is a reference to data stored in the computer's memory, variables are used to store values and get them back (in the case you want to use them again). A variable can be a number, unit, destructable, terrain type, ect...You can create a variable by using the variable editor in the trigger section. Just click the green x to adda variable. Pick a type and a name. When using variable it should look a bit like this.
It can be set to anything using the set variable = Something action.
Setting a variable
-
Events
- Your Event
-
Conditions
- Your Condition
-
Actions
- Set My_Unit_Type = Footman
-
Makemehaunit
-
Events
- Time - Elapsed game time is 0.01 seconds
- Conditions
-
Actions
- Set temp_player = Player 1 (Red)
- Set temp_point = (Center of (Playable map area))
- Set temp_unittype = Peasant
- Unit - Create 1 temp_unittype for temp_player at temp_point facing 270.00 degrees
- Set temp_unit = (Last created unit)
-
Events
What is an array?
An array is a group of more that one variable. You have to test this out yourself to understand it, but heres an explanation anyway. An array stores things just like a variable does but when making an array you must set the size. In order to find out which part of the array you are refering to the variable array needs an index number to refer to the variable in the variable array that you are trying to access. Heres an example trigger. Setting a variable array-
Events
- Map initialization
- Conditions
-
Actions
- Set PlayingPlayers[1] = Player 1 (Red)
- Set PlayingPlayers[2] = Player 2 (Blue)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (PlayingPlayers[1] controller) Equal to User
- (PlayingPlayers[1] slot status) Equal to Is playing
-
Then - Actions
- Do nothing
-
Else - Actions
- Game - Defeat PlayingPlayers[1] with the message: Defeat!
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (PlayingPlayers[2] controller) Equal to User
- (PlayingPlayers[2] slot status) Equal to Is playing
-
Then - Actions
- Do nothing
-
Else - Actions
- Game - Defeat PlayingPlayers[2] with the message: Defeat!
-
If - Conditions
What is a loop?
A loop is something that keeps going until through or cleared. Loops are another tricky thing to understand but in my opinion are by far the most useful, time-saving action/function in warcraft 3. LOOPS ARE ALSO YOUR FRIENDS (I know this personally because I used to make long ass triggers instead of using loops). Heres an example trigger for a loop.
Defeating a computer empty slot status player
-
Events
- Map initialization
- Conditions
-
Actions
- Set PlayingPlayers[1] = Player 1 (Red)
- Set PlayingPlayers[2] = Player 2 (Blue)
- Set PlayingPlayers[3] = Player 3 (Teal)
- Set PlayingPlayers[4] = Player 4 (Purple)
- Set PlayingPlayers[5] = Player 5 (Yellow)
- Set PlayingPlayers[6] = Player 6 (Orange)
- Set PlayingPlayers[7] = Player 7 (Green)
- Set PlayingPlayers[8] = Player 8 (Pink)
- Set PlayingPlayers[9] = Player 9 (Gray)
- Set PlayingPlayers[10] = Player 10 (Light Blue)
- Set PlayingPlayers[11] = Player 11 (Dark Green)
- Set PlayingPlayers[12] = Player 12 (Brown)
-
For each (Integer A) from 1 to 12, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (PlayingPlayers[(Integer A)] slot status) Equal to Is playing
- (PlayingPlayers[(Integer A)] controller) Equal to User
-
Then - Actions
- Do nothing
-
Else - Actions
- Game - Defeat PlayingPlayers[(Integer A)] with the message: Defeat!
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
What is a memory leak?
A memory leak happens when the game uses something and forgets about it. This creates lagg over time if enough of them pile up. I will post a link to what I consider the most helpful memory leak tutorial.The best GUI tool ever. Leak check.
~~emjlr3's Memory Leak / Custom Script Guide~~
-----------------------------------------------------------------------------------
This is what I used and now use in all my triggers ^
Side Notes
- Do not use Do Nothing as it basically compiles to a blank function call that does its name and wastes processor time.
- A global variable stores a value so that it can be used at a later point in time, even if that point is near immediatly.
- Also for the array, the size parameter that the globals editor provides mostly does nothing and so can be ignored but the true maximum size on an array is 8191.
Expert
There is no such thing as GUI expert , now it's time you start learning jass.
The rest is up to you, have fun creating maps with triggers. If you still don't get it and need help creating a trigger then just ask and I'll be happy to help. Some other talents of mine include: loading screens, loading minimap, any graphic design Ex:skinning. If you need any of those I will probably be willing to help. In conclusion I hope everyone who read this learned a little something about triggering. I also hope the 4 hours I put into this tutorial don't go to waste.My warcraft 3 account is named Zypher and I am in no way aphiliated with the other Zypher that lurks THW, just a coincidence. Happy triggering.
-Zypher
Last edited by a moderator: