Hey Everybody. I have decided to create a second set of intro tutorials. This time around, I'm going to segment the tutorials for each different editor module. So feel free to check out whichever parts you want! As always, PM me any questions you have or mistakes you find in the tutorial.
Okay. The time has come to actually get started. This paragraph just covers locating & opening the editor. The first thing to do is actually open the galaxy editor. It's located in the same place on your computer as starcraft 2 is. For PC users, this is probably in program files >> starcraft 2. I assume it's similar for Mac users, although I don't own one. Anyways, just open up the editor to get started. You will probably open up the terrain editor by default (normally you will have either an empty, black, map or one with a plain, flat terrain). The galaxy editor is actually made up of several different modules. The most important modules are Terrain, Triggers, and Data. The buttons at the top of the screen will open each of these modules.
The first thing we want to do is make a new map. Your editor may be set up to auto-generate terrain, but we want to be able to set up the map the way we want it. So use file >>> new to make a new map.
Most of this is fairly self explanatory, except for the dependencies. Basically, this tells the editor which set of information to load into your map. For example, the zerg units in campaign are weaker than the ones in multiplayer. So if you use campaign dependencies, the weaker versions will show up in your map. The campaign dependencies also contain models and units only found in campaign, such as Jim Raynor. Set this option to campaign (liberty) and hit ok.
The Layout
There are 3 main sections of the trigger editor. They are called the Trigger List , the Trigger Contents, and the Subview.
Now you can take a look at the menu bar.
New Event
New Condition
New Action
New Comment
Show/Hide Trigger Libraries
Make sure this is turned off (button pushed up)
Show/Hide Subview
Make sure this is turned on (button pushed down)
So what is a trigger? A trigger is an action that is taken when a particular event happens. Every trigger is made up of Events, Conditions, and Actions. When building a game, you must normally write code for it. Thanks to triggers, we don't have to. When we run the map, galaxy editor automatically converts all our triggers into the code that starcraft can read. You don't actually have to worry about that, but just know that's how they work.
Events are what starts the trigger
An event would be something like "Unit Enters Region"
Conditions are statements that must be true in order for the actions to be run
A condition might be "Owner of unit == player 1"
An Action is something that happens as a result of the trigger
An example of an action might be "Kill unit"
Time To Work
Let's go ahead and make a trigger.
Right click in the trigger list and choose "new >> trigger".
Name your trigger whatever you would like, and press Enter.
Look in the trigger contents window
Right click where it says "Events" and choose new event
A list of every event will pop up. Use the search bar to find "Chat Message". Select it and hit okay.
Look in the trigger subview. Because you have selected your event, that trigger's parameters are displayed there.
Underlined words are different paramaters you can set. Ones underlined in red have to be set, or your trigger won't work.
You can click on these underlined values to change them. Click on the red 'text'
Let's take a deeper look at this paramater window.
Functions are things that will return a certain value.
An example of a function would be "name of player". This function will return the name of a player.
Presets are a bit complicated. You don't really have to worry about them, but they're basically pre-made values.
Most of time, you will see presets like "Any unit, all units, or no units"
Variables are values you set yourself. We will explain them later.
Value is a specific value you want to enter.
For example, in this case we could just type in "hello"
Custom script is just that; it's a custom made script
Don't worry about this at all.
In the window, type in "awesome" and hit okay (no spaces or capitalization). Now we have a trigger that runs whenever a player types "awesome".
Let's right click on conditions now, and make a new condition. Select comparison and hit okay. There are different types of conditions, but you will almost always use comparison.
Comparisons check to make sure two values are equal. If the value on the left is the same as the value on the right, the trigger will continue. If not, it will end.
We want to use a comparison to check that the player was player 1. But right now we are checking the owner of a unit. So we have two ways to change this. We can click on either of the red areas shown below.
Go ahead and click either one, it does not matter. In the menu that pops up, choose "triggering player"
Now it should say "triggering player = 1"
Excellent! Now our trigger runs whenever a player types "awesome", but it will only continue if the player was player #1. The problem is that our trigger doesn't actually do anything yet! We need to add some actions.
Right click on actions, and then hit new action.
Choose "text message" and hit okay.
Now we need to set the parameters for this action.
Remeber, the paramaters are the colored, underlined text in the subview .
Click on the message parameter. In the parameter window that pops up, type "Congradulations! You made your first trigger!" and hit okay.
You now have a working trigger. When player 1 types 'awesome' in the chat, the message "congratulations!" will appear.
Variables
Basics of Variables
So what's a variable? A variable is sort of like a box. We can put any value we want inside of the box, but only 1 value can fit inside each variable. Luckily, we can replace this value at any time. We can also reference this box from our triggers. Why would we need this? Because we don't always know what a value will be in advance. For example, we can make a variable called "winning player". At the start of the map, the box is empty. There is no value. Then player 1 wins, and we run a trigger that sets "winning player" to 1. Now the value 1 is 'inside' the box. In another trigger, we may tell the game to show a message to the winning player. We can say
DisplayMessage"Congradulations! You win!"toplayer(winningplayer)insubtitlearea
Since we refer to our winning player variable in the trigger, it will check the contents of our winning player variable, and use whatever value is inside of it. If player 2 was the winner, he would see the message, If it was 3, he would see the message, etc...
Local Variables VS Global Variables
There are 2 types of variables; Global, and Local. They are both useful for certain situations. Global variables are located in the trigger list , along with your triggers. Local variables are located inside a trigger.
So what's the difference? Global variables can be accessed by any trigger, at any time. For those just starting off, most of your variables will be global variables. Local variables can only be accessed by the trigger that they are used in. Think of them as "temporary" variables. Say we have a trigger that kills units that walk into a region. We can make a local variable called 'unit1' and then store the unit that walked into the region inside it. Then later in the trigger, we can say to kill unit1. But we don't need to remember this value for all of eternity; we no longer have a use for it, because that unit is dead.
Local variables 're-set' each time a trigger is run. This means that if you have multiple instances of a trigger running at the same time ( like if 2 units walked into the region at the exact same instant, then the trigger would run once for each unit) the variables wont get mixed up.
Arrays
Arrays are a bit more complex They are, however, incredibly useful. Let's go back to our box example. If a variable is a box, an array is a box with dividers inside. Remember how variables can only hold 1 value at a time? Arrays are 1 variable that has multiple "slots" which you can place values in. To make an array, just select any variable and check the box that says array. You will see several boxes light up. The first says 1, and the rest say 0. For now, leave everything but the first box alone. You can set this value to how many 'slots' you want the array to have. If I set the size to 50, I get a giant box with 50 different slots. Keep in mind that the more slots you give an array, the memory the use (even if you don't put a value inside, the slots still use memory). So if you make an array with a huge amount of slots, your going to be wasting a lot of space. Your triggers must initialize these variables right on map start-up, and this can take some time. Because of this, if you use way to many variables, your map script can stop working. But don't worry too much- in order to hit that limit, you need to use a seriously outrageous number of gigantic arrays.
When would you want to use arrays. Well say we want to keep track of every player's score. We could make 15 different variables (1 for each player). But it would be much easier to make 1 variable with 15 'slots'.
Variable Types
Every variable must have a certain type assigned to it. Only values of that specific type can fit inside the variable. By default, variables store integers. You can change this by using the drop down menu when you select a variable. A unit variable can store units, an integer variable can store integers, a player group variable stores player groups, etc...
Here's the most common types you will use:
Integers are any number (both negative and positive)
Integers can NOT have a decimal value
Example: 3
Reals are any number (negative or positive) that DO have a decimal value
Example: 5.892
Booleans can store only 2 values: True, or False
Example: True
Unit variables store a specific unit
That one, specific, marine standing over there
Unit type variables store a type of unit
Example: Marines
String variables store strings
Strings are just text; no formatting (color, size, etc...) allowed.
Example: "I am a string"
Text variables store text (duh)
Unlike strings, you can format text with colors, fonts, and more
Example:I am text text
Important! You can convert a string to text, but it is impossible to convert text to a string
Why is this? Ask blizzard. O.o
Conclusion
Well, after reading this, you should (hopefully) have a good understand on what triggers are, and how they work. Please send me a PM if you find any mistakes, have a question or suggestion, or need clarification on something. Oh, and one more thing.
Random Fact of the day: The elephant is the only animal with 4 knees.
Ty for that Zelda, for some it might look like stupid to explain these things, but for ppl that do not have english as their first language, it make the first approach SOOOO much more enjoyable. Yet, I haven't learned anything new after reading that, but god only knows how much I would have liked to find such a post a year ago..
lol :D Yeah, it's pretty basic, not intended for anybody that really know's what they're doing. I remember being pretty confused back when I was starting with Wc3, which is why I'm always making these newbie tutorials. And the old versions were poorly written, with no screenshots, and outdated. I'm surprised you read it :D
I have an Action/Function Definition tutorial available here. In the future I'd like to get a more "everything and anything you need for triggers" type series going at some point.
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
To post a comment, please login or register a new account.
Foreword
Hey Everybody. I have decided to create a second set of intro tutorials. This time around, I'm going to segment the tutorials for each different editor module. So feel free to check out whichever parts you want! As always, PM me any questions you have or mistakes you find in the tutorial.
Table Of Contents
Getting to Know Your Data [Not Finished]
Intro To Terrain
Learning the Trigger Editor [This]
Old Getting Started Tutorial Series[ Here ]
Orientation
Okay. The time has come to actually get started. This paragraph just covers locating & opening the editor. The first thing to do is actually open the galaxy editor. It's located in the same place on your computer as starcraft 2 is. For PC users, this is probably in program files >> starcraft 2. I assume it's similar for Mac users, although I don't own one. Anyways, just open up the editor to get started. You will probably open up the terrain editor by default (normally you will have either an empty, black, map or one with a plain, flat terrain). The galaxy editor is actually made up of several different modules. The most important modules are Terrain, Triggers, and Data. The buttons at the top of the screen will open each of these modules.
The first thing we want to do is make a new map. Your editor may be set up to auto-generate terrain, but we want to be able to set up the map the way we want it. So use file >>> new to make a new map.
Most of this is fairly self explanatory, except for the dependencies. Basically, this tells the editor which set of information to load into your map. For example, the zerg units in campaign are weaker than the ones in multiplayer. So if you use campaign dependencies, the weaker versions will show up in your map. The campaign dependencies also contain models and units only found in campaign, such as Jim Raynor. Set this option to campaign (liberty) and hit ok.
The Layout
There are 3 main sections of the trigger editor. They are called the Trigger List , the Trigger Contents, and the Subview.
Now you can take a look at the menu bar.
So what is a trigger? A trigger is an action that is taken when a particular event happens. Every trigger is made up of Events, Conditions, and Actions. When building a game, you must normally write code for it. Thanks to triggers, we don't have to. When we run the map, galaxy editor automatically converts all our triggers into the code that starcraft can read. You don't actually have to worry about that, but just know that's how they work.
Time To Work
Let's go ahead and make a trigger.
Let's take a deeper look at this paramater window.
You now have a working trigger. When player 1 types 'awesome' in the chat, the message "congratulations!" will appear.
Variables
Basics of Variables
So what's a variable? A variable is sort of like a box. We can put any value we want inside of the box, but only 1 value can fit inside each variable. Luckily, we can replace this value at any time. We can also reference this box from our triggers. Why would we need this? Because we don't always know what a value will be in advance. For example, we can make a variable called "winning player". At the start of the map, the box is empty. There is no value. Then player 1 wins, and we run a trigger that sets "winning player" to 1. Now the value 1 is 'inside' the box. In another trigger, we may tell the game to show a message to the winning player. We can say
Since we refer to our winning player variable in the trigger, it will check the contents of our winning player variable, and use whatever value is inside of it. If player 2 was the winner, he would see the message, If it was 3, he would see the message, etc...
Local Variables VS Global Variables
There are 2 types of variables; Global, and Local. They are both useful for certain situations. Global variables are located in the trigger list , along with your triggers. Local variables are located inside a trigger.
So what's the difference? Global variables can be accessed by any trigger, at any time. For those just starting off, most of your variables will be global variables. Local variables can only be accessed by the trigger that they are used in. Think of them as "temporary" variables. Say we have a trigger that kills units that walk into a region. We can make a local variable called 'unit1' and then store the unit that walked into the region inside it. Then later in the trigger, we can say to kill unit1. But we don't need to remember this value for all of eternity; we no longer have a use for it, because that unit is dead.
Local variables 're-set' each time a trigger is run. This means that if you have multiple instances of a trigger running at the same time ( like if 2 units walked into the region at the exact same instant, then the trigger would run once for each unit) the variables wont get mixed up.
Arrays
Arrays are a bit more complex They are, however, incredibly useful. Let's go back to our box example. If a variable is a box, an array is a box with dividers inside. Remember how variables can only hold 1 value at a time? Arrays are 1 variable that has multiple "slots" which you can place values in. To make an array, just select any variable and check the box that says array. You will see several boxes light up. The first says 1, and the rest say 0. For now, leave everything but the first box alone. You can set this value to how many 'slots' you want the array to have. If I set the size to 50, I get a giant box with 50 different slots. Keep in mind that the more slots you give an array, the memory the use (even if you don't put a value inside, the slots still use memory). So if you make an array with a huge amount of slots, your going to be wasting a lot of space. Your triggers must initialize these variables right on map start-up, and this can take some time. Because of this, if you use way to many variables, your map script can stop working. But don't worry too much- in order to hit that limit, you need to use a seriously outrageous number of gigantic arrays.
When would you want to use arrays. Well say we want to keep track of every player's score. We could make 15 different variables (1 for each player). But it would be much easier to make 1 variable with 15 'slots'.
Variable Types
Every variable must have a certain type assigned to it. Only values of that specific type can fit inside the variable. By default, variables store integers. You can change this by using the drop down menu when you select a variable. A unit variable can store units, an integer variable can store integers, a player group variable stores player groups, etc...
Here's the most common types you will use:
Conclusion
Well, after reading this, you should (hopefully) have a good understand on what triggers are, and how they work. Please send me a PM if you find any mistakes, have a question or suggestion, or need clarification on something. Oh, and one more thing.
Random Fact of the day: The elephant is the only animal with 4 knees.
Reserved Space
Ty for that Zelda, for some it might look like stupid to explain these things, but for ppl that do not have english as their first language, it make the first approach SOOOO much more enjoyable. Yet, I haven't learned anything new after reading that, but god only knows how much I would have liked to find such a post a year ago..
@Claymuffin: Go
lol :D Yeah, it's pretty basic, not intended for anybody that really know's what they're doing. I remember being pretty confused back when I was starting with Wc3, which is why I'm always making these newbie tutorials. And the old versions were poorly written, with no screenshots, and outdated. I'm surprised you read it :D
@zeldarules28: Go
Can we get more on Records/Presets/Custom Actions,Function,Events,Conditions?
@EdwardSolomon: Go
I have an Action/Function Definition tutorial available here. In the future I'd like to get a more "everything and anything you need for triggers" type series going at some point.