- Joined
- Feb 4, 2007
- Messages
- 389
Various Hero Selection Systems and How They Work
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:
-
View Previous
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to Previous
- Actions
-
Events
-
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 - Conditions
-
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 - Conditions
-
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
-
If - Conditions
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to Previous [/CODE]
- Runs this trigger when an ability is cast, but only if it is the "Previous" Ability.
- [TRIGGER]Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)
-
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
The rest of the trigger is repetitive, and does not need to be explained.
-
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 - Conditions
-
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
-
If - Conditions
-
Events
-
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
-
Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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 - Conditions
-
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
-
If - Conditions
- Camera - Apply Camera 002 <gen> for (Owner of (Triggering unit)) over 0.00 seconds
- Unit - Remove (Triggering unit) from the game
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
-
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
-
Conditions
-
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)
-
If - Conditions
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.
-
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>
-
Events
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:
-
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))))
-
Events
- 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)
Now you need this trigger to register when a button is clicked, and what button it was:
-
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 - Conditions
-
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
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
-
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