• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

GUI for the common man.

Level 17
Joined
Jun 17, 2010
Messages
2,275
Hello, This is a tutorial to show You, the common man, how to understand and create your own triggers.

We will begin by going through the simplest Events, Conditions, and Actions.

1.0 Introduction

GUI is split off into 3 sections:
  • Events
  • Conditions
  • Actions

These govern what the trigger does. An Event is the bases of the trigger. The event is what happens in the game, to activate 1 trigger loop. Once a trigger loop is started, it goes into Conditions to make sure the trigger loop meets the conditions before it can continue. Once the conditions, which are like a criteria for the trigger, are checked and they all match with the activation they move on to the actions. The actions can do many things. But we will stick to simple things. An action is the action of the loop. It tells the game what to do when the loop happens.

1.1 Re-spawn

Now we will cover re-spawning as our first section. Re-spawning is when a unit is created to replace a unit that has died.

  • Events
    • Unit - A unit Generic Event

The unit Generic event is maybe one of the most commonly used events. It holds a variety of variations to it. For now we will use

  • Unit - A unit Dies

When a unit dies. The loop for our trigger begins. We can add a condition. The simplest is Boolean.

  • (Triggering unit) is a hero equal to true
this saying that, the triggering unit (the one that dies) has to be a hero. To negate this and say that the dying unit cannot be a hero you change True to False. It is important that you use (Triggering Unit) Instead of (Dying unit) because Dying unit takes up more memory then Triggering Unit.

Now the action is the most important of this trigger. Because you cant do anything with a event and a condition on their own. Now this is the part that can have alot of different choices. You could place a region beforehand and use it for the respawn, if this is the case then the action would look like this.

  • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (<Your region>)) facing Default building facing degrees
***Be aware that using
  • Hero - Revive hero instantly
is what you would use, but for the sake of the tutorial we will use this. Reviving the hero saved all the stats, creating a new one, basicly creates a new one.***


This states that the trigger will create 1 unit that is the same type of the unit that died. This is the 3rd bulletin from the top. The second part makes the unit for the person who owned the unit who died. This is also the 3rd bullet point under the arrow.

Now lets put it all together.
  • Events
    • Unit - A unit Dies
    • Conditions
      • (Triggering Unit) is a Hero equal to True
    • Actions
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
1.2 Variables

Now one of the most useful features of GUI, variables. Variables allow you to store data. Similar to hashtables, but somewhat simpler.

First we will cover how to make a variable. There are 2 ways but i will show you the way i prefer.

setvariable.jpg


Start out by going to actions and set variables as shown in the picture.

editvariables.jpg


Now click on the thing that says Variable And then click on Edit Variables as shown in the picture.

makevariable.jpg


Now Click on the Green X to make a new variable.

variable.jpg


Now Pick a name, then select the drop down arrow and choose integer. Then hit enter twice.

setingvariable.jpg


Now you will see this. Click on Value and find Arithmetic, it should be the fourth one down from the second drop down arrow. You will see Value + 1 Click on Value and choose the variable you just created.

Once you have done this, hit enter 3 times. Now you should see this
  • Events
  • Conditions
  • Actions
    • Set My_Variable = (My Variable + 1)
This is saying that every time there is a trigger loop, then the number in My_Variable will increase by 1.

Now that we have this set up, Lets incorporate it into the previous trigger we made.

  • Events
    • Unit - A unit Dies
  • Conditions
    • (triggering unit) is a hero equal to true
  • Actions
    • Set My_Variable = (My_Variable + 1)
    • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
Now every time a hero dies, this increases the variables number.

1.3 If, Then, Else

Now we will cover, If Then Else multiple functions, there is a if then else single function, but i personally thing its a waste, considering it requires a "Else" and using Do Nothing takes up memory. Choose a new action and go down a few in the drop arrow and you will see If Then Else, multiple functions, choose this and it will show up as:

  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
      • Then - Actions
      • Else - Actions
Now this is pretty self explanatory, If a condtion is true, Then do Then actions, Else do Else actions. Pretty much saying do this or do that based on the condition.

We will take the trigger we made before, and change it up a little to show you how this works.

  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (triggering unit) is a hero equal to true
      • Then - Actions
        • Set My_Variable = (My_Variable + 1)
        • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
Now leaving "Else - Actions" Blank is what you are supposed to do if you have no action you want to happen if the unit isnt a hero. But lets use it for this, and take the opportunity to create another variable. Take the steps you took before and use a different name.

  • Set My_Variable_2 = (My_Variable_2 + 1)
Is what we will add into else actions. So now it will be saying that if whatever dies is not a hero, than it will count it. So 1 variable counts heroes dying, the other counts units dying. So the whole trigger will look like this.

  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (triggering unit) is a hero equal to true
      • Then - Actions
        • Set My_Variable = (My_Variable + 1)
        • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
          • Set My_Variable_2 = (My_Variable_2 + 1)
1.4 Indexing

Now that we have learned how to use variables, lets learn about indexing. Indexing is basically, creating multiple versions of a single variable that have their own settings. In example:
  • Events
    • Unit - Unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Triggering unit) is a Hero equal to true
      • Then - Actions
        • Set My_Variable[0] = (My_Variable[0] + 1)
        • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
          • Set My_Variable[1] = (My_Variable[1] + 1)
As you can see, this is the same trigger used before, but if you notice, both of the variables are the same. Well not exactly, the variable counting hero deaths is index 0 but the variable counting normal unit deaths is index 1. Indexing is normally turned off by default but to turn it on takes 1 simple step:
variable.jpg

Where it says [] Array, check mark that box. Now your indexing is turned on, and you will notice it wont allow you to accept the variable unless you have set an index to it. You will also see that the grayed out box that says Size and a number next to it becomes dark and changeable. Ignore it because that is saying, what size do you want the index to go to, leaving it as 1 lets the index hit max possible size. You don't want to do this that is why we are going to learn how to recycle indexes.


1.5 Player Association

Now that we have established a basic kill counting system, lets attach players to those kills.

First we will need to create a variable for the player. Head back to edit variables and create a new variable. Make that variable an integer and check the array box.
  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (triggering unit) is a hero equal to true
      • Then - Actions
        • Set My_Variable = (My_Variable + 1)
        • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
          • Set My_Variable_2 = (My_Variable_2 + 1)

**This is incomplete, i ran out of time and couldnt finish the whole tutorial, I will add more onto it when i come back.***
 
Last edited:
Level 11
Joined
Sep 12, 2008
Messages
657
Nice job infiniate..
you'r sort of crazy..
doing 3 hard things at once..
1. working on an rpg.
2. taking requests in your request thread
3. making a tutorial o.o
that has to be insanity! ;p
anyways, good job, i guess people will find this usefull..

if i am not mistaken said:
The one we have at tutorial section
is a "BIT" more advanced then this 1, and it doesnt touch variables, either leaks.
so i guess this is slightly better..
 
Level 30
Joined
Jan 31, 2010
Messages
3,551
Well, that way, you can inform what new things have been applied to get the subscribers opinion. Right now, I can't remember a thing that could/has been changed. It's usually a good think to pick it down to hidden tag, where you can inform about the progress of your tutorial.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Umm...at the start of the tutorial,you say like: event fires the trigger "loop",which isn't really correct and might confuse readers about what loops are since loops are repeating actions.
Also the Indexing part should explain how to make MUI triggers using Paladon's indexing system. You've just explained how to use arrays...
 
Top