- Joined
- Aug 21, 2005
- Messages
- 3,699
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:
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:
Now we need to create the trigger where you buy a hero and move it to the "HeroSpawn" region.
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:
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.
So let's add the following action:
Your final trigger should look like this:
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:
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.
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:
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.
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.
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.
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:
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:
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:
So what do we want this trigger to do? We want to create a Blademaster for the owner of the Hero Chooser.
So this is how my final trigger looks like:
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:
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:
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:
In order to make a button work, I need to create the following trigger:
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:
However, there are some differences: In this trigger I create TWO dialogs instead of one, each with 4 buttons. At the end of the trigger, I show the FIRST dialog of the 2 I've made.
Note that for every page you want your dialog to have, you actually need to create a new dialog variable and new actions in this trigger.
There is another change too:
For Each hero in both dialogs, you need to make a new trigger (just like the ones made in the previous tutorial). In my example I use the Death Knight.
Now, let's go back to the "Next Page" and "Previous Page" button. Right now it doesn't work yet.
What we'll need to do is make a trigger that runs whenever you click the "previous page" or "next page" button. The event & Condition is similar to the above trigger.
That's it. I've explained how to browse through multiple pages of a dialog system.
Dialogs are quite powerful. While I have explained how to make a hero selection system, you can also use the Dialog system for other things, such as selecting your race, selecting what weapon you wish to equip, etc. etc.
Clicking/Doubleclicking.
Although this is not a very popular method, it's quite easy to implement and use.
Basically, this is how the system works: In front of you are a few heroes. By clicking on them a description pops up, and by double clicking you select the hero.
In my example I'll use the 8 neutral heroes.
The Map Data:
I'll need to create 8 neutral heroes (close to each others) somewhere on the map. Next, I must make sure that you can select them. Therefor, I must make sure you can actually SEE the 8 heroes. To do this, one of my units needs to be near those heroes. In my example, I'll simply create a sentry ward near them.
Next, I'll need a region where my hero will spawn. I call it "HeroSpawn".
The Trigger Data:
These are the variables used:
We'll only need ONE trigger.
Basically, we need to check if a unit is selected. However, this trigger can only run when you have NOT chosen a hero yet and when the selected unit is one of the 8 neutral heroes I've placed on the map.
In our actions we'll have to check if the player has already clicked the unit. If that's true, a hero should be created (as you double-clicked the hero). Else, a description will pop up
In the "Then - actions" we will create a unit of the SELECTED unit type. We also set "SelectionHeroselected" equal to true so you won't be able to select a 2nd hero.
In the "Else - actions" we will set the LAST selected unit (SelectedUnit[(Player number of (Triggering player))]) to the unit you just selected. This way, the next time you select a unit, the computer will remember what unit you selected the last time.
In the Else actions we'll also put the description of the selected unit. For example:
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
- Circle of Power Heroes
- Dialog menu
- Extended Dialog (further explanation)
- Clicking/Doubleclicking
- Next/Previous Hero Viewing(completelly made by Tonks, thanks to him)
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:
Name | Type | Initial Value | Array |
Tavern1Heroes | Unit-type | Empty | 100 |
HeroChosenByPlayer | Boolean | False | 12 |
TempPoint | Point | no | no |
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. --------
-
Events
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>
-
Conditions
-
Conditions
-
And - All (Conditions) are true
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>
-
Conditions
-
Conditions
-
And - All (Conditions) are true
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>
-
Conditions
-
Conditions
-
And - All (Conditions) are true
-
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))
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
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)
-
Loop - Actions
-
Player Group - Pick every player in (All players) and do (Actions)
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>
-
Conditions
-
Conditions
-
And - All (Conditions) are true
-
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)
-
Loop - Actions
- 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))
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
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!
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
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
-
If - Conditions
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.
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
- 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
-
Conditions
-
And - All (Conditions) are true
-
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)
-
Loop - Actions
- Unit - Remove (Picked unit) from the game
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
- Custom script: call DestroyGroup(udg_TempUnitGroup)
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 --------
-
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
-
Conditions
-
And - All (Conditions) are true
-
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)
-
Loop - Actions
- Unit - Remove (Picked unit) from the game
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
- 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 --------
-
Events
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)
-
Events
If you have any questions or you'd like to add something to this tutorial, feel free to post.
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
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
- 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)
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)
-
Events
That's it.
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:
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
- 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)
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)
-
Loop - Actions
- Trigger - Turn off (This trigger)
-
Events
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
-
Events
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".
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:
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
-
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 --------
- Dialog - Change the title of EDialog2 to Select Night Elf He...
- Dialog - Create a dialog button for EDialog2 labelled Priestess of the Moon
- Set DialogPriestess = (Last created dialog Button)
- Dialog - Create a dialog button for EDialog2 labelled Druid of the Grove
- Set DialogDruid = (Last created dialog Button)
- Dialog - Create a dialog button for EDialog2 labelled Demon Hunter
- Set DialogDemonHunter = (Last created dialog Button)
- Dialog - Create a dialog button for EDialog2 labelled Warden
- Set DialogWarden = (Last created dialog Button)
- Dialog - Create a dialog button for EDialog2 labelled Previous Page
- Set DialogPageUD = (Last created dialog Button)
- -------- Showing the Dialog --------
-
Player Group - Pick every player in (All players) and do (Actions)
-
Loop - Actions
- Dialog - Show EDialog1 for (Picked player)
-
Loop - Actions
- Trigger - Turn off (This trigger)
-
Events
However, there are some differences: In this trigger I create TWO dialogs instead of one, each with 4 buttons. At the end of the trigger, I show the FIRST dialog of the 2 I've made.
Note that for every page you want your dialog to have, you actually need to create a new dialog variable and new actions in this trigger.
There is another change too:
-
Actions
- Dialog - Create a dialog button for EDialog1 labelled Next Page
- Set DialogPageNE = (Last created dialog Button)
-
Actions
- Dialog - Create a dialog button for EDialog2 labelled Previous Page
- Set DialogPageUD = (Last created dialog Button)
For Each hero in both dialogs, you need to make a new trigger (just like the ones made in the previous tutorial). In my example I use the Death Knight.
-
Extended Dialog Death Knight
-
Events
- Dialog - A dialog button is clicked for EDialog1
-
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
-
Events
Now, let's go back to the "Next Page" and "Previous Page" button. Right now it doesn't work yet.
What we'll need to do is make a trigger that runs whenever you click the "previous page" or "next page" button. The event & Condition is similar to the above trigger.
-
Extended Dialog UD
-
Events
- Dialog - A dialog button is clicked for EDialog2
-
Conditions
- (Clicked dialog button) Equal to DialogPageUD
-
Actions
- Dialog - Show EDialog1 for (Triggering player)
-
Events
-
Extended Dialog NE
-
Events
- Dialog - A dialog button is clicked for EDialog1
-
Conditions
- (Clicked dialog button) Equal to DialogPageNE
-
Actions
- Dialog - Show EDialog2 for (Triggering player)
-
Events
That's it. I've explained how to browse through multiple pages of a dialog system.
Dialogs are quite powerful. While I have explained how to make a hero selection system, you can also use the Dialog system for other things, such as selecting your race, selecting what weapon you wish to equip, etc. etc.
Although this is not a very popular method, it's quite easy to implement and use.
Basically, this is how the system works: In front of you are a few heroes. By clicking on them a description pops up, and by double clicking you select the hero.
In my example I'll use the 8 neutral heroes.
The Map Data:
I'll need to create 8 neutral heroes (close to each others) somewhere on the map. Next, I must make sure that you can select them. Therefor, I must make sure you can actually SEE the 8 heroes. To do this, one of my units needs to be near those heroes. In my example, I'll simply create a sentry ward near them.
Next, I'll need a region where my hero will spawn. I call it "HeroSpawn".
The Trigger Data:
These are the variables used:
Name | Type | Initial Value | Array |
Selectedunit | unit-type | no unit | 12 |
SelectionHeroSelected | Boolean | False | 12 |
We'll only need ONE trigger.
Basically, we need to check if a unit is selected. However, this trigger can only run when you have NOT chosen a hero yet and when the selected unit is one of the 8 neutral heroes I've placed on the map.
-
Events
- Player - Player 1 (Red) Selects a unit
- Player - Player 2 (Blue) Selects a unit
-
Conditions
-
And - All (Conditions) are true
-
Conditions
- SelectionHeroselected[(Player number of (Triggering player))] Equal to False
-
Or - Any (Conditions) are true
-
Conditions
- (Triggering unit) Equal to Alchemist 0019 <gen>
- (Triggering unit) Equal to Tinker 0020 <gen>
- (Triggering unit) Equal to Naga Sea Witch 0021 <gen>
- (Triggering unit) Equal to Beastmaster 0022 <gen>
- (Triggering unit) Equal to Dark Ranger 0026 <gen>
- (Triggering unit) Equal to Firelord 0027 <gen>
- (Triggering unit) Equal to Pandaren Brewmaster 0028 <gen>
- (Triggering unit) Equal to Pit Lord 0029 <gen>
-
Conditions
-
Conditions
-
And - All (Conditions) are true
In our actions we'll have to check if the player has already clicked the unit. If that's true, a hero should be created (as you double-clicked the hero). Else, a description will pop up
-
Actions
- Selection - Clear selection for (Triggering player)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to SelectedUnit[(Player number of (Triggering player))]
-
Then - Actions
- Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at (Center of HeroSpawn <gen>) facing Default building facing degrees
- Set SelectionHeroselected[(Player number of (Triggering player))] = True
-
Else - Actions
- Set SelectedUnit[(Player number of (Triggering player))] = (Triggering unit)
- Wait 1.50 seconds
- Set SelectedUnit[(Player number of (Triggering player))] = No unit
-
If - Conditions
In the "Then - actions" we will create a unit of the SELECTED unit type. We also set "SelectionHeroselected" equal to true so you won't be able to select a 2nd hero.
In the "Else - actions" we will set the LAST selected unit (SelectedUnit[(Player number of (Triggering player))]) to the unit you just selected. This way, the next time you select a unit, the computer will remember what unit you selected the last time.
In the Else actions we'll also put the description of the selected unit. For example:
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Pandaren Brewmaster 0028 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Pandaren Brewmaster...
-
Else - Actions
- Do nothing
-
If - Conditions
-
Selection Heroes
-
Events
- Player - Player 1 (Red) Selects a unit
- Player - Player 2 (Blue) Selects a unit
-
Conditions
-
And - All (Conditions) are true
-
Conditions
- SelectionHeroselected[(Player number of (Triggering player))] Equal to False
-
Or - Any (Conditions) are true
-
Conditions
- (Triggering unit) Equal to Alchemist 0019 <gen>
- (Triggering unit) Equal to Tinker 0020 <gen>
- (Triggering unit) Equal to Naga Sea Witch 0021 <gen>
- (Triggering unit) Equal to Beastmaster 0022 <gen>
- (Triggering unit) Equal to Dark Ranger 0026 <gen>
- (Triggering unit) Equal to Firelord 0027 <gen>
- (Triggering unit) Equal to Pandaren Brewmaster 0028 <gen>
- (Triggering unit) Equal to Pit Lord 0029 <gen>
-
Conditions
-
Conditions
-
And - All (Conditions) are true
-
Actions
- Selection - Clear selection for (Triggering player)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to SelectedUnit[(Player number of (Triggering player))]
-
Then - Actions
- Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at (Center of HeroSpawn <gen>) facing Default building facing degrees
- Set SelectionHeroselected[(Player number of (Triggering player))] = True
-
Else - Actions
- Set SelectedUnit[(Player number of (Triggering player))] = (Triggering unit)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Alchemist 0019 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Alchemist: War...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Tinker 0020 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Tinker: Cunnin...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Naga Sea Witch 0021 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Sea Witch: Mys...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Beastmaster 0022 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Beastmaster: W...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Dark Ranger 0026 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Dark Ranger: C...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Firelord 0027 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Firelord: Myst...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Triggering unit) Equal to Pandaren Brewmaster 0028 <gen>
-
Then - Actions
- Game - Display to (Player group((Triggering player))) the text: The Pandaren Brewma...
-
Else - Actions
- Game - Display to (Player group((Triggering player))) the text: The Pit Lord: Warr...
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Wait 1.50 seconds
- Set SelectedUnit[(Player number of (Triggering player))] = No unit
-
If - Conditions
-
Events
Attachments
Last edited: