Various Hero Selection Systems and How They Work - WIP
In this tutorial I'm going explain many of the methods for hero selection.
Index-
1 · Next / Previous Hero Viewing2 · Dialog Menu Selection
3 · Using a Unit and Circles of Power
4 · Hero Taverns
5 · Clicking and Doubleclicking
6 · Random Hero
1 - Next / Previous Hero Viewing
Difficulty: Moderate
Note: This is not a good idea if you have more than 8-12 heroes.
This is not a very common method of hero selection. In fact, I've only ever seen it used in the Blizzard map Azeroth Grand Prix. I used it myself in one of my maps.
Essentially what this system entails is having a unit that has several abilities; Next, Previous, and an ability with the icon of the Hero. When you click Next, it locks your camera to the next hero in line, and when you click Previous it locks your camera to the previous hero. Then when you click the ability with the Hero's icon, it selects that hero.
Variables:
- "HeroSelector" - Unit Array Variable - Size 12
- "HeroSelectAbil" - Ability Array Variable - Size 12 (Initial Value set to your first hero)
- "L" - Point Variable
Abilities:
- You will need an ability for every hero. The ability should be named after the hero and should have the same icon as the hero.
- Next - Should be based off an ability easily modified to do nothing.
- Previous - Should be based off an ability easily modified to do nothing, but should not be based off the same ability as "Next."
Units:
- You will need one of each of your heroes (preferably in a line) owned by Neutral Passive.
- You will need one Hero Selector unit for each player. Should have the Abilities Next, Previous, and the ability corresponding to the first hero.
Triggers:
Code:
View Previous
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Previous
Actions
Actions
Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Dwarves
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Panda
Camera - Lock camera target for (Owner of (Triggering unit)) to Panda 0040 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Clubz
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Dwarves
Camera - Lock camera target for (Owner of (Triggering unit)) to Dwarves 0037 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Muskles
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Clubz
Camera - Lock camera target for (Owner of (Triggering unit)) to Ice T 0036 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
Code:
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Previous
Runs this trigger when an ability is cast, but only if it is the "Previous" Ability.
Code:
Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)
Removes the ability that is assigned to HeroSelectAbil for that player.
Code:
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Dwarves
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Panda
Camera - Lock camera target for (Owner of (Triggering unit)) to Panda 0040 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
This checks if the HeroSelectAbil variable is set to the Dwarves ability. If it is, it sets it to the Panda ability, Locks the camera to the Panda unit, and adds the Panda ability to the unit.
Code:
Skip remaining actions
This is in there to make sure that it doesn't continue the function.
The rest of the trigger is repetitive, and does not need to be explained.
Code:
View Next
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Next
Actions
Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Panda
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Dwarves
Camera - Lock camera target for (Owner of (Triggering unit)) to Dwarves 0037 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Dwarves
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Clubz
Camera - Lock camera target for (Owner of (Triggering unit)) to Ice T 0036 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
As you can tell, the Next trigger is just the same as the Previous trigger, in reverse.
Code:
Pick Cart
Events
Unit - A unit Starts the effect of an ability
Conditions
(Unit-type of (Triggering unit)) Equal to Hero Selection
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Panda
(Ability being cast) Equal to Bonez
(Ability being cast) Equal to Clubz
(Ability being cast) Equal to Dwarves
(Ability being cast) Equal to Fatty
(Ability being cast) Equal to Muskles
(Ability being cast) Equal to Priest
(Ability being cast) Equal to Revenant
(Ability being cast) Equal to Spirit
(Ability being cast) Equal to Tinker
(Ability being cast) Equal to Troll
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Bonez
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Bonez for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Clubz
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Ice T for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Dwarves
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Dwarves for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Fatty
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Fatty for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Muskles
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Muskles for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Panda
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Panda for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Priest
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Priest for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Revenant
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Revenant for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Spirit
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Toad for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Tinker
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Tinker for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Troll
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Troll for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
Camera - Apply Camera 002 <gen> for (Owner of (Triggering unit)) over 0.00 seconds
Unit - Remove (Triggering unit) from the game
This trigger creates the unit corresponding to the clicked ability.
Code:
Conditions
(Unit-type of (Triggering unit)) Equal to Hero Selection
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Panda
(Ability being cast) Equal to Bonez
(Ability being cast) Equal to Clubz
(Ability being cast) Equal to Dwarves
(Ability being cast) Equal to Fatty
(Ability being cast) Equal to Muskles
(Ability being cast) Equal to Priest
(Ability being cast) Equal to Revenant
(Ability being cast) Equal to Spirit
(Ability being cast) Equal to Tinker
(Ability being cast) Equal to Troll
Checks if the triggering unit is the Hero Selection unit and if the cast Ability is any of the abilities corresponding to the heroes.
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Bonez
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Bonez for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Checks if the ability being cast is the ability corresponding to the Bonez hero. If it is, it creates 1 Bonez at a random point in the Team1Spawn region.
Note: "Set L = ..." and "call RemoveLocation(udg_L)" are used to avoid a memory leak in this trigger.
Last but not least you'll want to have a trigger that sets the Hero Selectors.
Code:
HeroSelectors
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Set HeroSelector[1] = Hero Selection 0012 <gen>
Set HeroSelector[2] = Hero Selection 0013 <gen>
Set HeroSelector[3] = Hero Selection 0014 <gen>
Set HeroSelector[4] = Hero Selection 0015 <gen>
Set HeroSelector[5] = Hero Selection 0011 <gen>
Set HeroSelector[6] = Hero Selection 0017 <gen>
Set HeroSelector[7] = Hero Selection 0016 <gen>
Set HeroSelector[8] = Hero Selection 0020 <gen>
Set HeroSelector[9] = Hero Selection 0019 <gen>
Set HeroSelector[10] = Hero Selection 0018 <gen>
Set HeroSelector[11] = Hero Selection 0021 <gen>
Set HeroSelector[12] = Hero Selection 0022 <gen>
This sets the HeroSelector variables according to their arrays. "HeroSelector[1]" is set to Red's Hero Selector unit, "HeroSelector[2]" is set to Blue's, etc..
2 - Dialog Button Selection
Difficulty: Easy
This is a fairly easy to create and very easy to comprehend method. It only requires two triggers, and only a few variables.
Variables:
- "Dialog_Var" - Dialog Variable
- "Hero1_Var" - Dialog Button Variable
- "Hero2_Var" - Dialog Button Variable
- You must create a Dialog Button Variable for each of the Dialog Buttons.
Triggers:
Code:
Dialog
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Dialog - Change the title of Dialog_Var to Pick your Hero
Dialog - Create a dialog button for Dialog_Var labelled Hero 1
Set Hero1_Var = (Last created dialog Button)
Dialog - Create a dialog button for Dialog_Var labelled Hero 2
Set Hero2_Var = (Last created dialog Button)
For each (Integer A) from 1 to 12, do (Dialog - Show Dialog_Var for (Player((Integer A))))
Code:
Dialog - Change the title of Dialog_Var to Pick your Hero
Changes the title of the Dialog_Var variable to "Pick your Hero." This is what will be displayed at the top of the menu.
Code:
Dialog - Create a dialog button for Dialog_Var labelled Hero 1
Set Hero1_Var = (Last created dialog Button)
Puts a dialog button on the menu labeled "Hero 1" This is what will be displayed on the button itself. Then it sets the Hero1_Var variable to the button that was just created. You need to set the variable so that you can reference it later.
Now you need this trigger to register when a button is clicked, and what button it was:
Code:
ClickedButton
Events
Dialog - A dialog button is clicked for Dialog_Var
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to Hero1_Var
Then - Actions
Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to Hero2_Var
Then - Actions
Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Else - Actions
Code:
If - Conditions
(Clicked dialog button) Equal to Hero1_Var
Then - Actions
Unit - Create 1 Mountain King for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Creates a Mountain King if the clicked button was the Hero1_Var button.
3 - Using a Unit and Circles of Power
Difficulty: Easy
This is one of the more common methods used in maps like Hero Wars, DotA, and Arena-types.
Basically what this system does, is you have a bunch of heroes in a line, and Circles of Power in front of each one. When a unit (usually a wisp) goes on the Circle of Power that corresponds to the unit it wants, it creates that hero and kills the wisp.
Variables:
- "L" - Point Variable
Regions:
- "Spawn" - This is where the heroes will be spawned when they are selected.
- You will need a region on top of each of the circles of power in front of your heroes.
Triggers:
Code:
Paladin
Events
Unit - A unit enters Paladin <gen>
Conditions
(Unit-type of (Triggering unit)) Equal to Wisp
Actions
Unit - Remove (Triggering unit) from the game
Set L = (Center of Spawn <gen>)
Unit - Create 1 Paladin for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
-------- Stop here if you want the heroes to be able to be selected more than once. --------
Unit - Remove Paladin 0000 <gen> from the game
Trigger - Turn off (This trigger)
Code:
Unit - A unit enters Paladin <gen>
Paladin is a region on top of the Circle of Power in front of the Paladin Hero.
Code:
(Unit-type of (Triggering unit)) Equal to Wisp
Checks to see if the triggering unit is a Wisp, which is what I used for selection.
Code:
Unit - Remove (Triggering unit) from the game
Removes the wisp from the game.
Code:
Set L = (Center of Spawn <gen>)
Sets the Point Variable "L" to the center of the Spawn region.
Code:
Unit - Create 1 Paladin for (Owner of (Triggering unit)) at L facing Default building facing degrees
Creates a Paladin for the player controlling the Wisp at the Spawn location.
Code:
Custom script: call RemoveLocation(udg_L)
Removes the Point Variable memory leak.
Code:
[COLOR="Red"]Unit - Remove Paladin 0000 <gen> from the game[/COLOR]
Removes the Paladin hero that is on display from the game.
Note: The above code is only necessary if you do not want different players to be able to select the same hero.
Code:
[COLOR="Red"]Trigger - Turn off (This trigger)[/COLOR]
Turns off this trigger so that this hero cannot be selected again.
Note: The above code is only necessary if you do not want different players to be able to select the same hero.
Repeat this trigger for each of the heroes available in your map. You're done.
I will work on the other Selection Systems later. This is by no means complete.