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
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.
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.
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".
The Trigger Data:
Following Variables will be used in this tutorial:
The Variables:
| Name | Type | Initial Value | Array |
| Tavern1Heroes | Unit-type | Empty | 100 |
| HeroChosenByPlayer | Boolean | False | 12 |
| TempPoint | Point | no | no |
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
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.
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:
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
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)
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
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
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:
| Name | Type | Initial Value | Array |
| PlayerRepicked | Boolean | False | 12 |
| TempUnitGroup | Unit Group | empty | none |
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

Conditions


And - All (Conditions) are true
I will use the following action

Actions
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
In total, you should have the following trigger:

Tavern Hero Repick
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
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.
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
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
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:
| Name | Type | Initial Value | Array |
| Dialog | Dialog | none | none |
| DialogDeathKnight | Dialog Button | none | none |
| DialogDreadlord | Dialog Button | none | none |
| DialogLich | Dialog Button | none | none |
| DialogCryptLord | Dialog Button | none | none |
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
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
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:
| Name | Type | Initial Value | Array |
| EDialog1 | Dialog | none | none |
| EDialog2 | Dialog | none | none |
| DialogDeathKnight | Dialog Button | none | none |
| DialogDreadlord | Dialog Button | none | none |
| DialogLich | Dialog Button | none | none |
| DialogCryptLord | Dialog Button | none | none |
| DialogPriestess | Dialog Button | none | none |
| DialogDruid | Dialog Button | none | none |
| DialogWarden | Dialog Button | none | none |
| DialogDemonHunter | Dialog Button | none | none |
| DialogPageNE | Dialog Button | none | none |
| DialogPageUD | Dialog Button | none | none |

Extended Dialog Initialization