(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Tutorials > Trigger (GUI) Editor Tutorials

Trigger (GUI) Editor Tutorials Contains tutorials concerning the usage of GUI features.
Read the Rules before posting.

Reply
 
LinkBack Thread Tools Display Modes
Old 08-20-2007, 02:33 PM   #1 (permalink)

I own you. Get over it.
 
Join Date: Aug 2005
Posts: 2,410

Eleandor is just really nice (288)Eleandor is just really nice (288)Eleandor is just really nice (288)Eleandor is just really nice (288)Eleandor is just really nice (288)


Hero Selection Systems

As Tonks has left the Hive, I decided to recreate this tutorial.

Introduction:
This tutorial will show you various methods of hero selection systems.
Many AoS or orpg's use hero selection systems which allow you to pick a hero out of one of the various heroes available in the game. In this tutorial I'll try to explain as good as possible on how to create such a system.
A map will be attached with all triggers. They work so you can test them yourself.
Proceed to the Contents to see the index of this tutorial.
Every trigger is written in GUI (pro's: easy to understand for everybody, cons: possible lag) on the exception of a few custom scripts.

VERY IMPORTANT: these triggers have not been de-leaked. The thought behind this is that if you need a tutorial for something as simple as this, you probably don't bother about them anyway. In any way, you can check out a tutorial on leaks on this website to learn more about them.


Index:
Hero Taverns
Description: If you ever played an AoS (such as Defence of the Ancients), you have certainly seen this system. Basically, you have a circle of power near a tavern. In this tavern you can select one of the various heroes. Every tavern can only sell up to 12 heroes, but you can add multiple taverns to your map ofcourse.
Important note: This system is slightly different from those seen in the AoS maps. In case you want to add randomize modes etc., I recommend you to download the DotA template at thehelper.net
tut1.jpg


Recommended: Basic knowledge of both the trigger editor and the Object editor. Works well with 12 or more heroes.

Part 1: The Tavern Tutorial

The Object Data:


We will start with editing the necessary object data.

First, we create our first hero and we change the following values:
* Stats - Food Cost: 0
* Stats - Gold Cost: 0
* Stats - Lumber Cost: 0
* Stats - Stock Maximum: 1
* Stats - Stock Replenish Interval: 0
* Stats - Stock Start Delay: 0
We repeat this process for every hero in the game. In this tutorial, I'll do this to 4 heroes: The 4 human heroes.
tut2.jpg

Next we will create a new Tavern. We create a new unit and base it on the Tavern. The unit is located under "Neutral, Building".
We change the following value:
Techtree - Units Sold: Add all heroes to this value. If you have more than 12 heroes, simply create a second tavern and repeat this tutorial after finishing it.
tut3.jpg


The Map Data:

You need to place the tavern you just made on your map. Now add circles of power (they're located in the unit palette under Neutral, Campaign) for every player and place them next to the tavern.
You must create a region (in the region palette) on the map where you want your heroes to spawn. I've named this region to "HeroSpawn".
tut-4.jpg


The Trigger Data:

Following Variables will be used in this tutorial:
The Variables:
NameTypeInitial ValueArray
Tavern1HeroesUnit-typeEmpty100
HeroChosenByPlayerBooleanFalse12
TempPointPointnono
You can open the Variable Editor by going to the trigger editor and pressing "Cntrl + B" or alternativelly going to "Edit, Variables".

First we create a new folder. Call it "Tavern Heroes".
We create a new trigger in this folder, we call it "Tavern Initialization".

This is how my trigger looks like:
Tavern Initialization
Events
Map initialization
Conditions
Actions
Set Tavern1Heroes[1] = Paladin (Tavern)
Set Tavern1Heroes[2] = Archmage (Tavern)
Set Tavern1Heroes[3] = Mountain King (Tavern)
Set Tavern1Heroes[4] = Blood Mage (Tavern)
-------- If you wish to add more than 4 units to the Tavern, you must add them here. --------
This trigger will add my 4 hero-types to a variable. This will be used later. I have only made 4 heroes for this tutorial, in case you have more heroes, just repeat the actions for all heroes.

Now we need to create the trigger where you buy a hero and move it to the "HeroSpawn" region.

Events
Unit - A unit Sells a unit
Conditions
And - All (Conditions) are true
Conditions
((Sold unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Selling unit) Equal to Tavern 0000 <gen>
First we add the events. This trigger will run whenever a unit (such as a tavern) sells another unit (such as a hero).
In the conditions we check if the SOLD unit is a hero, and if the SELLING unit is the tavern you placed on the map. If you have multiple taverns, you add those to the "OR - CONDITIONS".
For example: if I have multiple taverns, my trigger will be looking like this:
Events
Unit - A unit Sells a unit
Conditions
And - All (Conditions) are true
Conditions
((Sold unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Selling unit) Equal to Moon Tavern 0000 <gen>
(Selling unit) Equal to Sun Tavern 0001 <gen>
(Selling unit) Equal to Earth Tavern 0002 <gen>

Next, we will add actions. Right now, our trigger will run when a tavern sells a hero. So what should happen then?
We need to check if you already bought a hero. When you already bought a hero, you're not allowed to buy a second hero! We will instantly remove the second hero in the "Then - Actions".
If this is your first hero, you should buy the hero and instantly move it to "HeroSpawn", where you can start the game.

Tavern Hero Chosen
Events
Unit - A unit Sells a unit
Conditions
And - All (Conditions) are true
Conditions
((Sold unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Selling unit) Equal to Tavern 0000 <gen>
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] Equal to True
Then - Actions
Unit - Remove (Sold unit) from the game
Game - Display to (All players) the text: You already chose a...
Else - Actions
Set Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] = True
Unit - Move (Sold unit) instantly to (Center of HeroSpawn <gen>)
Camera - Pan camera for (Owner of (Sold unit)) to (Center of HeroSpawn <gen>) over 1.00 seconds
Selection - Clear selection for (Owner of (Sold unit))
Selection - Add (Sold unit) to selection for (Owner of (Sold unit))

Wait a second. Right now everyone can buy the same hero. So every player will be able to play with for example a Paladin. Now, we probably do not want to see 12 Paladins fighting on the battlefield, do we? If we do, your trigger is finished. Else, go on with the tutorial.
So let's add the following action:
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)
Thanks to this action, whenever someone buys a hero, this hero will no longer be available for all players.

Your final trigger should look like this:
Tavern Hero Chosen
Events
Unit - A unit Sells a unit
Conditions
And - All (Conditions) are true
Conditions
((Sold unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Selling unit) Equal to Tavern 0000 <gen>
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] Equal to True
Then - Actions
Unit - Remove (Sold unit) from the game
Game - Display to (All players) the text: You already chose a...
Else - Actions
Set Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] = True
Unit - Move (Sold unit) instantly to (Center of HeroSpawn <gen>)
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)
Camera - Pan camera for (Owner of (Sold unit)) to (Center of HeroSpawn <gen>) over 1.00 seconds
Selection - Clear selection for (Owner of (Sold unit))
Selection - Add (Sold unit) to selection for (Owner of (Sold unit))

Voila, I have explained how to create a Tavern. In the rest of this tutorial, I'll explain to you how to repick your hero and how to randomise it.

Part 2: Randomising
When randomising, you make the computer pick for you. In other words: you don't know what hero you'll be playing. Everything in the previous tutorial should be working already, as we will build on it.

The Object Data:

Go to the unit editor and select the Night Elf Wisp. We will edit this unit (or, in case you'll use a wisp in the game, create a new one based on it).
Following Values will be changed:
  • Abilities - Normal - none
  • Stats - Food Cost: 0
  • Stats - Gold Cost: 0
  • Stats - Lumber Cost: 0
  • Stats - Stock Maximum: 0
  • Stats - Stock Replenish Interval
  • Text - Name: Hero Chooser
  • Text - Tooltip - Basic : Hero Chooser
  • Text - Tooltip - Extended: Randomise your hero!
Make sure the "Stats - Stock start delay" is 0

Finally, add your "wisp" (a.k.a Hero Chooser) to your Tavern. Note that the tavern can only have 11 heroes now. If you use more heroes, add them to another tavern.


The Trigger Data:

We will make a trigger that runs whenever you "buy" a "Hero Chooser" unit.
Events
Unit - A unit Sells a unit
Conditions
(Unit-type of (Sold unit)) Equal to Hero Chooser
In the actions, we will be REMOVING the "Hero Chooser" unit because ofcourse we do not wish to play with a wisp.
Next, we will create a random hero.
Ofcourse we NEED to check first if you already bought a hero before, so we will create an IF/THEN/ELSE action.
If you have not chosen a hero yet, you will do the "Then - Actions". In those actions we create a "Tavern1Heroes" (those you set up at the "Tavern Initialization" trigger at the start of the tutorial). In the array I'll put a RANDOM number between 1 and 4, because I have 4 heroes (the paladin, mountain king, archmage and bloodmage). If I have for example 6 heroes, I will but a RANDOM number between 1 and 6.
This is how the trigger looks like:
Actions
Unit - Remove (Sold unit) from the game
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] Equal to False
Then - Actions
Unit - Create 1 Tavern1Heroes[(Random integer number between 1 and 4)] for (Owner of (Sold unit)) at (Center of HeroSpawn <gen>) facing Default building facing degrees
Set Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] = True
Else - Actions
Do nothing

Voila, that's it. Next in the tutorial? Repicking your hero.

Part 3: Repicking your hero.
In many games (such as DotA, I often refer to this not because I like it, but because everyone knows this map, at least by name) you can repick your hero after choosing it. Usually it randomises your hero. I will, for once, not randomise your hero and allow you to independantly choose a new hero.

The Map Data
We'll need another region centered on the Tavern. I'll call it "Tavern"


The Trigger Data:


We will need some more variables.

The Variables:
NameTypeInitial ValueArray
PlayerRepickedBooleanFalse12
TempUnitGroupUnit Groupemptynone

Ok, so we want to be able to REPICK your hero. I'll make a trigger that repicks your hero when any player writes "-repick". Ofcourse, I will add conditions so ou cannot "repick" when you have not chosen a hero yet or when you ALREADY repicked.
Events
Player - Player 1 (Red) types a chat message containing -repick as An exact match
Player - Player 2 (Blue) types a chat message containing -repick as An exact match
Player - Player 3 (Teal) types a chat message containing -repick as An exact match
Player - Player 4 (Purple) types a chat message containing -repick as An exact match
Player - Player 5 (Yellow) types a chat message containing -repick as An exact match
Player - Player 6 (Orange) types a chat message containing -repick as An exact match
Player - Player 7 (Green) types a chat message containing -repick as An exact match
Player - Player 8 (Pink) types a chat message containing -repick as An exact match
Player - Player 9 (Gray) types a chat message containing -repick as An exact match
Player - Player 10 (Light Blue) types a chat message containing -repick as An exact match
Player - Player 11 (Dark Green) types a chat message containing -repick as An exact match
Player - Player 12 (Brown) types a chat message containing -repick as An exact match
Conditions
And - All (Conditions) are true
Conditions
Herochosenbyplayer[(Player number of (Triggering player))] Equal to True
PlayerRepicked[(Player number of (Triggering player))] Equal to False

I will use the following action
Actions
Set TempUnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Loop - Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Player - Make (Unit-type of (Picked unit)) Available for training/construction by (Picked player)
Unit - Remove (Picked unit) from the game
Custom script: call DestroyGroup(udg_TempUnitGroup)
so every player will be allowed to pick the hero you just removed.
The custom script is required for removing a memory leak.
Next, your hero should be removed from the game and you should be able to pick a new one.
Actions
Game - Display to (All players) the text: ((Name of (Triggering player)) + has repicked a hero!)
Set Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] = False
Selection - Clear selection for (Triggering player)
Selection - Add Tavern 0000 <gen> to selection for (Triggering player)
Camera - Pan camera for (Triggering player) to (Center of Tavern <gen>) over 1.00 seconds
-------- If you only allow 1 repick per player, keep the action below --------
Set PlayerRepicked[(Player number of (Triggering player))] = True
-------- If you allow unlimited repicks per player, remove the action above --------

In total, you should have the following trigger:

Tavern Hero Repick
Events
Player - Player 1 (Red) types a chat message containing -repick as An exact match
Player - Player 2 (Blue) types a chat message containing -repick as An exact match
Player - Player 3 (Teal) types a chat message containing -repick as An exact match
Player - Player 4 (Purple) types a chat message containing -repick as An exact match
Player - Player 5 (Yellow) types a chat message containing -repick as An exact match
Player - Player 6 (Orange) types a chat message containing -repick as An exact match
Player - Player 7 (Green) types a chat message containing -repick as An exact match
Player - Player 8 (Pink) types a chat message containing -repick as An exact match
Player - Player 9 (Gray) types a chat message containing -repick as An exact match
Player - Player 10 (Light Blue) types a chat message containing -repick as An exact match
Player - Player 11 (Dark Green) types a chat message containing -repick as An exact match
Player - Player 12 (Brown) types a chat message containing -repick as An exact match
Conditions
And - All (Conditions) are true
Conditions
Herochosenbyplayer[(Player number of (Triggering player))] Equal to True
PlayerRepicked[(Player number of (Triggering player))] Equal to False
Actions
Set TempUnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Loop - Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Player - Make (Unit-type of (Picked unit)) Available for training/construction by (Picked player)
Unit - Remove (Picked unit) from the game
Custom script: call DestroyGroup(udg_TempUnitGroup)
Game - Display to (All players) the text: ((Name of (Triggering player)) + has repicked a hero!)
Set Herochosenbyplayer[(Player number of (Owner of (Sold unit)))] = False
Selection - Clear selection for (Triggering player)
Selection - Add Tavern 0000 <gen> to selection for (Triggering player)
Camera - Pan camera for (Triggering player) to (Center of Tavern <gen>) over 1.00 seconds
-------- If you only allow 1 repick per player, keep the action below --------
Set PlayerRepicked[(Player number of (Triggering player))] = True
-------- If you allow unlimited repicks per player, remove the action above --------


Now, there is nothing as annoying as someone who repicks his hero in the middle of the game. So if we want to prohibit players from repicking your hero after e.g. 45 seconds, we add the following trigger:
Tavern Hero Repick disable
Events
Time - Elapsed game time is 45.00 seconds
Conditions
Actions
Trigger - Turn off Tavern Hero Repick <gen>
Trigger - Turn off (This trigger)

That's it, I have said everything about hero repicking in Taverns.
If you have any questions or you'd like to add something to this tutorial, feel free to post.


Circle of Power Heroes
In many RPG's you enter an area with many heroes standing on Circles of Power. Whenever a unit (usually a wisp) enters this Circle of Power, you gain your hero.
In my example I'll use the 4 Orc heroes.
tut6.jpg

The Map Data:
4 Circles of Power with 4 Orc heroes. 1 wisp in the middle of them.
1 region (HeroSpawn) where our heroes will spawn.

The Object Data:
I'll edit the wisp so it's no longer a wisp but just a unit used for selecting the hero.
The following values were changed:
  • Abilities - Normal - none
  • Techtree - structures build - nothing
  • Text - Name : Hero Chooser
tut-5.jpg

The Trigger Data:
Note: the following trigger needs to be made for EVERY selectable hero. In other words: I'll end up with 4 triggers, 1 for each hero. As they're very similar to each others, I'll only do this for 1 hero in the tutorial:

Events
Unit - A unit comes within 100.00 of Blademaster 0012 <gen>
Conditions
(Unit-type of (Triggering unit)) Equal to Hero Chooser
This trigger will run whenever the "Hero Chooser" (our edited wisp) comes close to the Blademaster.
So what do we want this trigger to do? We want to create a Blademaster for the owner of the Hero Chooser.

Actions
Unit - Create 1 Blademaster for (Owner of (Triggering unit)) at (Center of HeroSpawn <gen>) facing Default building facing degrees
This creates the Blademaster.
Unit - Remove (Triggering unit) from the game
This removes the Hero Chooser from the game. We don't want him to select another hero again.
Camera - Pan camera for (Owner of (Triggering unit)) to (Center of HeroSpawn <gen>) over 1.00 seconds
This pans the camera on your new Blademaster.
Trigger - Turn off (This trigger)
We turn off the trigger so the Blademaster cannot be chosen by another player.

So this is how my final trigger looks like:
CoP Blademaster
Events
Unit - A unit comes within 100.00 of Blademaster 0012 <gen>
Conditions
(Unit-type of (Triggering unit)) Equal to Hero Chooser
Actions
Unit - Create 1 Blademaster for (Owner of (Triggering unit)) at (Center of HeroSpawn <gen>) facing Default building facing degrees
Unit - Remove (Triggering unit) from the game
Camera - Pan camera for (Owner of (Triggering unit)) to (Center of HeroSpawn <gen>) over 1.00 seconds
Trigger - Turn off (This trigger)

This needs to be repeated for every hero in the game.

That's it.



Dialog Menu
In some RPG's, a dialog pops up at startup. In this dialog you have various options to choose your hero.
A Dialog can have unlimitted buttons, but you'll only see about max. 8 a the same time on 1 screen. Therefor, it's not recommended to use this system with many heroes. However, we can make a dialog with MULTIPLE pages. If you have many heroes, I suggest you read this tutorial and read continue on the "Extended Dialog" tutorial. However, if you're only using about 6 heroes in your map, this tutorial is what you're looking for.
Please note that you can test this dialog system in the attached map by typing "-dialog". As this is a testing map, it would've been annoying if it showed up at startup.

Recommended:
Basic Triggering Knowledge. If you know anything of dialogs, this tutorial might even be unnecessary for you.

The Map Data:
I need a region named "HeroSpawn". My hero will spawn here after selecting it.

The Trigger Data:

Following Variables are used:
The Variables:
NameTypeInitial ValueArray
DialogDialognonenone
DialogDeathKnightDialog Buttonnonenone
DialogDreadlordDialog Buttonnonenone
DialogLichDialog Buttonnonenone
DialogCryptLordDialog Buttonnonenone

In this example I use 4 heroes again. For every hero, you'll need to create a variable such as the "DialogDeathKnight" variable.
You can open the Variable Editor by going to the trigger editor and pressing "Cntrl + B" or alternativelly going to "Edit, Variables".


We will need to create a new folder in the trigger editor. I name mine "Dialog Heroes".

The first trigger will be called "Dialog Initialization"
The event is obvious:
Events
Game - Elapsed game time is equal to 0.5 seconds
The actions:
Dialog - Change the title of Dialog to Select your hero
This will change the title of your dialog into "Select your hero".
Dialog - Create a dialog button for Dialog labelled Death Knight
Set DialogDeathKnight = (Last created dialog Button)
Through this action, you add a new dialog button to your dialog, and you give it a name. I named mine "Death Knight".
In order to recognise this button, I need to add the second action (Set DialogDeathKnight = (Last created dialog Button)).
For every hero I have I must repeat those 2 actions.

Finally, I must show this dialog to every player, this will be done in the one but last action.

As I have 4 Heroes, this is how my trigger looks like:
Dialog Initialization
Events
Player - Player 1 (Red) types a chat message containing -dialog as An exact match
Conditions
Actions
Dialog - Change the title of Dialog to Select your hero
Dialog - Create a dialog button for Dialog labelled Death Knight
Set DialogDeathKnight = (Last created dialog Button)
Dialog - Create a dialog button for Dialog labelled Dreadlord
Set DialogDreadLord = (Last created dialog Button)
Dialog - Create a dialog button for Dialog labelled Lich
Set DialogLich = (Last created dialog Button)
Dialog - Create a dialog button for Dialog labelled Crypt Lord
Set DialogCryptLord = (Last created dialog Button)
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Dialog - Show Dialog for (Picked player)
Trigger - Turn off (This trigger)

Right now I have made a dialog that works. However, nothing will happen when I press one of the buttons.
In order to make a button work, I need to create the following trigger:

Dialog Death Knight
Events
Dialog - A dialog button is clicked for Dialog
Conditions
(Clicked dialog button) Equal to DialogDeathKnight
Actions
Unit - Create 1 Death Knight for (Triggering player) at (Center of HeroSpawn <gen>) facing Default building facing degrees
Camera - Pan camera for (Triggering player) to (Center of HeroSpawn <gen>) over 1.00 seconds
The previous trigger will create a Death Knight when you press the "Death Knight" button on the dialog. I must copy this trigger for every hero I have added to the dialog.

In fact, this is all I have to do.
Check the attached map for the triggers in detail. As said at the start of this tutorial, you can test this dialog by typing "-dialog".

Extended Dialog Menu
This is a dialog that takes place over multiple pages, allowing you to see many options on 1 screen.
In my example, I'll allow you to choose between one of the 4 undeath heroes or 1 of the 4 NE heroes.
It's recommended that you read the previous tutorial too.

The Map Data:
I'll need a region called "HeroSpawn". In here, my chosen hero will spawn.

The Trigger Data:

Following Variables were used:
The Variables:
NameTypeInitial ValueArray
EDialog1Dialognonenone
EDialog2Dialognonenone
DialogDeathKnightDialog Buttonnonenone
DialogDreadlordDialog Buttonnonenone
DialogLichDialog Buttonnonenone
DialogCryptLordDialog Buttonnonenone
DialogPriestessDialog Buttonnonenone
DialogDruidDialog Buttonnonenone
DialogWardenDialog Buttonnonenone
DialogDemonHunterDialog Buttonnonenone
DialogPageNEDialog Buttonnonenone
DialogPageUDDialog Buttonnonenone

Extended Dialog Initialization
Events
Player - Player 1 (Red) types a chat message containing -extendeddialog as An exact match
Conditions
Actions
-------- Initializing Undeath Page --------
Dialog - Change the title of EDialog1 to Select Undeath Hero...
Dialog - Create a dialog button for EDialog1 labelled Death Knight
Set DialogDeathKnight = (Last created dialog Button)
Dialog - Create a dialog button for EDialog1 labelled Dreadlord
Set DialogDreadLord = (Last created dialog Button)
Dialog - Create a dialog button for EDialog1 labelled Lich
Set DialogLich = (Last created dialog Button)
Dialog - Create a dialog button for EDialog1 labelled Crypt Lord
Set DialogCryptLord = (Last created dialog Button)
Dialog - Create a dialog button for EDialog1 labelled Next Page
Set DialogPageNE = (Last created dialog Button)
-------- Initializing Night Elf Page --------