• 🏆 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] Simple Trigger Tutorials

Easy yet Commonly Asked About Tutorials

1.1: Teleporting a Unit
This section of the tutorial will teach you how to teleport your units. Also how to make a special effect on the units to make it look like a teleportation.
First you must make your Region in the world editor.
Regions.PNG

This is the basic teleportation trigger, it tells that when a unit enters your region, it will be moved to the next.

  • Teleportation
    • Events
      • Unit - A unit enters Rect 000 Copy 2 <gen>
    • Conditions
    • Actions
      • -------- Moves the unit instantly --------
      • Unit - Move (Triggering unit) instantly to (Center of Rect 000 <gen>)
Now, if you would like to have a special effect on the unit, such as the blink effect, here is what your trigger should look like.

  • Teleportation
    • Events
      • Unit - A unit enters Rect 000 Copy 2 <gen>
    • Conditions
    • Actions
      • -------- Adds the effect model to the unit --------
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
      • -------- Moves the unit instantly --------
      • Unit - Move (Triggering unit) instantly to (Center of Rect 000 <gen>)
      • Wait 1.00 seconds
      • -------- Destroys the effect so lag doesn't occur --------
      • Special Effect - Destroy (Last created special effect)

2.1: Quest Menu
This section will tell you the trigger to setup your quest menu

  • Quest Trigger
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Creates a Required Quest --------
      • Quest - Create a Required quest titled Required with the description This is a required ..., using icon path ReplaceableTextures\CommandButtons\BTNSelectHeroOff.blp
      • -------- Creates an Optional Quest --------
      • Quest - Create a Optional quest titled Optional with the description This is an optional..., using icon path ReplaceableTextures\CommandButtons\BTNSelectHeroOff.blp
      • -------- Creates a quest announcement --------
      • Quest - Display to (All players) the Simple Hint message: Check Your Quest Lo...


 

Attachments

  • Quest Log.PNG
    Quest Log.PNG
    519.2 KB · Views: 7,638
Last edited:
Level 10
Joined
Aug 15, 2008
Messages
720
Design is nice, though triggers in center style are quite awkward. Also are 3.1 triggers to give idea or they are made as real working examples? Because there isn't any event in last 3.1 trigger which would point at triggering unit. To be honest there are many tutorials like this, but it's up to mod if this is approved or not.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Umm, I don't really like this to be honest.
They're really the most basic you can possibly get (teleporting and killing units) and the trigger in 3.1 is weird.

If you use waits and want to kill a unit, why not use this trigger?
  • Regular with Waits
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Unit - Create 3 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Wait 2.00 seconds
      • Unit - Kill (Triggering unit)
This section will teach you an alternative to wait, that way you have less leaks.
You really don't have less leaks with your method, you do need 1 more trigger and I wouldn't call that a positive thing.
The actual leak is the "(Center of (Playable map area))", which you didn't fix.
The first trigger also leaks a location, might as well fix that while you're on it...


This is what I would call a basic GUI tutorial (but of course, what is "Basic"?)

Triggering (GUI)


Basics

One of the first things you need to know is how to fix leaks, though I will go over something else first.
Variables.

You will need variables in every map you make, the only exceptions are melee-maps.
Variables are needed to count kills, remember heroes, fix leaks, basically everything that you need to recall.

The variable editor can be opened by pressing CTRL + B inside the trigger editor (or by pressing the yellow 'X' on top of the screen).
Now you can create variables by pressing the green 'X'-button, after that you can create any variable you wish.
Variables you will need in every map are:
Point variable (name doesn't matter) with an array
Group variable without array
Player Group variable without array
(these are to fix leaks)


Leaks cause lag and can crash your maps, so it's important to fix them.

For information on what leaks, check This tutorial
I would suggest reading this tutorial completely, you will get used to fixing them after a while.

Efficient Triggering

If you have triggers like:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 2 (Blue) at (Player 2 (Blue) start location) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 3 (Teal) at (Player 3 (Teal) start location) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 4 (Purple) at (Player 4 (Purple) start location) facing Default building facing degrees
      • Unit - Create 1 Footman for Player 5 (Yellow) at (Player 5 (Yellow) start location) facing Default building facing degrees
Then you are doing something terribly wrong...
The better option would be:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each LoopInt from 1 to 5, do (Actions)
        • Loop - Actions
          • Set loc[1] = ((Player(LoopInt)) start location)
          • Unit - Create 1 Footman for (Player(LoopInt)) at loc[1] facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_loc[1])
Where "loc" is a point variable with array.
This does exactly the same, but the difference is that this is easier and it does not create lag (the other trigger does).

For Each Integer X info: this action will set integer X (can be any integer) from the starting value (in this case 1) to the end value (5).
Every time the integer increases, it will trigger the actions in it, so this trigger will activate 5 times, but every time it does something slightly different.
In more general terms, they're called "loops".
Note: Variable loops (like in this example, where you don't use the standard Integer A/B, but a pre-made integer variable) are more efficient.

As you can see, loops are very useful for efficiency, but there is more...
The If/Then/Else-function is also very useful when talking about efficiency.

I will explain this with dialogs (if you do not know what dialogs are, or how to form them, Check this tutorial.
Note: the tutorial given above is not efficient, I will do it otherwise - the tutorial is just to show what it is and how it's formed!


I will skip the dialog init trigger and just go straight to the dialog buttons trigger.
Let's just say the dialog is a hero-choose dialog with 3 buttons (Ranger, Warrior, Mage).


  • Dialog Buttons
    • Events
      • Dialog - A dialog button is clicked for Dialog
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to DialogButton[1]
        • Then - Actions
          • Set loc[1] = (Center of (Playable map area))
          • Unit - Create 1 Ranger for (Triggering player) at loc[1] facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_loc[1])
          • Game - Display to (All players) for 8.00 seconds the text: (|c00444488 + ((Name of (Triggering player)) + '|r has chosen the Ranger))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to DialogButton[2]
        • Then - Actions
          • Set loc[1] = (Center of (Playable map area))
          • Unit - Create 1 Warrior for (Triggering player) at loc[1] facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_loc[1])
          • Game - Display to (All players) for 8.00 seconds the text: (|c00444488 + ((Name of (Triggering player)) + '|r has chosen the Warrior))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to DialogButton[3]
        • Then - Actions
          • Set loc[1] = (Center of (Playable map area))
          • Unit - Create 1 Mage for (Triggering player) at loc[1] facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_loc[1])
          • Game - Display to (All players) for 8.00 seconds the text: (|c00444488 + ((Name of (Triggering player)) + '|r has chosen the Mage))
        • Else - Actions
As you can see, I can combine all dialog buttons for all dialogs into 1 trigger, making it a lot easier to scroll through the triggers...
(Triggering Player is the player clicking the dialog).



Kick-triggers are often done like this by newbs:

  • Kick
    • Events
      • Player - Player 1 (Red) types a chat message containing -kick blue as An exact match
    • Conditions
    • Actions
      • Game - Defeat Player 2 (Blue) with the message: LOLOL NOOB!!!!
  • Kick
    • Events
      • Player - Player 1 (Red) types a chat message containing -kick teal as An exact match
    • Conditions
    • Actions
      • Game - Defeat Player 3 (Teal) with the message: LOLOL NOOB!!!!
  • Kick
    • Events
      • Player - Player 1 (Red) types a chat message containing -kick purple as An exact match
    • Conditions
    • Actions
      • Game - Defeat Player 4 (Purple) with the message: LOLOL NOOB!!!!
And this for every player...

As you can see, there are 2 mistakes:
  1. You will need a lot of stupid triggers for this
  2. "LOLOL NOOB!!!!" makes the map look like crap

I prefer one of these methods:

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Color[1] = blue
      • Set Color[2] = teal
      • Set Color[3] = purple
      • Set Color[4] = yellow
      • Set Color[5] = orange
      • Set Color[6] = green
This sets up the colors... obviously (it's best to merge this with an already existing map init trigger)

  • Kick
    • Events
      • Player - Player 1 (Red) types a chat message containing -kick as A substring
    • Conditions
    • Actions
      • For each (Integer i) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (-kick + Color[i])
            • Then - Actions
              • Game - Defeat (Player((i + 1))) with the message: You have been kicked
              • Game - Display to (All players) for 7.00 seconds the text: (|c00444488 + ((Name of (Player((i + 1)))) + |r has been kicked))
            • Else - Actions
And this is the kick-trigger, if the message is -kick + (color defined in map init), then the player matching that color will be kicked.
Easy and efficient...


This method is even easier, but a bit different: red will have to say -kick X (where X is a number)
  • Kick
    • Events
      • Player - Player 1 (Red) types a chat message containing -kick as A substring
    • Conditions
    • Actions
      • For each (Integer i) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to (-kick + (String((i + 1))))
            • Then - Actions
              • Game - Defeat (Player((i + 1))) with the message: You have been kicked
              • Game - Display to (All players) for 7.00 seconds the text: (|c00444488 + ((Name of (Player((i + 1)))) + |r has been kicked))
            • Else - Actions
That's it... the entire kick-trigger, that's easy, right?
 
Great design, but I'm afraid that isn't enough. It needs more triggers/explanations. It also leaks locations (center of <rect>).

The alternative to waits also is done the same way if you were to just use a normal wait without the other trigger. It doesn't make a physical difference. =)

I was shocked by the neatness of the design, it looked very awesome at first, but sadly it doesn't have enough material and is a bit lacking.

Notify me if you are going to update this eventually or just update it in general. Else it will go to the graveyard after a week.
 
Well at least add more triggers, I mean show example from each part of triggers:
*If then else function
*for each integer from x to y do function
*Animation trigger (how to change unit color)
*Destructible trigger (how to open/close gate)
*Unit (add hp or mana, reduce same, kill, move etc)
*Unit Group (same as above)
*Player (add gold, lumber, turn on/off bounty, change name etc)
*Player Group (same as above)
*Special Effect (create/destroy)
*Sound (how to play sound, music show how to use sound editor)
etc etc

I hope you understand what I wanted to say, tutorial is 2 short and triggers have memory leaks (you can create normal ones just like that above, and advanced for users that want to learn more :thumbs_up:)

*colored text = examples
 
Level 4
Joined
May 19, 2010
Messages
119
Better explanation is needed. but okay, I will wait for your update. and the Centered-Triggers? not a good Idea.
 
Top