General - Advanced Hero Selection

Fulla

Evil Overlord
Reaction score
31
Heya,

In this tutorial I hope to show you how to make an advanced hero selection system in a step by step guide.
This one works via players clicking on heroes they wish to use as opposed to taverns or region methods.

I've tried to include as many pictures & samples as possible.
If you have any suggestions, recommendations or critiques, by all means tell me.

I'd Strongly Recommend first of, to download the sample map attached, to see how it works & looks ingame.
If you are already fairly experienced with the World Editor you could simply copy/paste across the system into your map & skip this tutorial.
It might however be a good idea, to read it anyways.

Contents
  • Globals
  • Dummy Units/Abilities
  • Terrain/Units/Rects
  • Player Teams
  • Cameras
  • Heroes Setup
  • Select Hero
  • Confirm Hero
  • Final Touches


Globals

Firstoff the dreaded global variables:
Globals.jpg

  • Boolean Array - This is so when a player has selected a Hero we can mark him as already having a hero, preventing him from slecting any more.
  • Unit Groups - A/B - These are there to groupup the heroes for selection purposes. We can detect if a player clicks on them, with necessary conditions
  • Unit Group - Used - This is used to store current Heroes that are selected by players and being considered for use. Stops a player snatching someone else players before he can confirm.
  • Player Groups - These are to group the players into their appropiate teams. Simplifies alot of things later on, which you'll see.
  • Unit Array - This is to store a players current hero he has selected. We use this to change the ownership/color of previous selected heroes back to normal when selecting a new hero

Dummy Units/Abilities

For the selection system, well need 1 dummy unit & 1 dummy ability.
I recommend basing these on the milita unit + the tornado slow aura ability.

Dummy Unit
- Will be used as fake unit sold on Heroes, to confirm/select that Hero.
- Will be used as a dummy to lock/rotate the camera around.
  • Add/replace invulnerable/locust abilities
  • Remove his shadow
  • Disable attacks
  • Remove his sound speed
  • Reduce Gold/Lumber/Food cost to 0
  • Alter his tooltips, something like:
    - Tooltip Basic - 'Select this Hero'
    - Tooltip Extended - 'Selects this Hero to fight for your cause.'
  • Give him an appropoate icon, I recommend MC's tick box icon
Unit.jpg

Selection Arrow Ability
This is very easy, only need to add 2 minor things:
  • Art target - Stop Sharing
  • Art target attachment point - Overhead
Ability-1.jpg

Terrain/Units/Rects

Now we need to setup the terrain & the units, creating both a hero selection area & a base for each team.

Hero Selection Areas:
- All heroes should be computer ally player of team A/B, in this case player's 6/12.
- Place a milita unit in the center (more on that later).
HA.jpg

HB.jpg

Team Bases:
- Place a rect, where the heroes can teleport to after picking a hero.
BA.jpg

BB.jpg

Player Teams

Next we need to setup the teams, in this testmap/tutorial Iill be using 2 teams:
- Players 1-6 - (Player 6 being the computer ally)
- Players 7-12 - (Player 12 being the computer ally)

Here is a sample code on how I'd recommend going about this:
Code:
Init 2
    Events
        Map initialization
    Conditions
    Actions
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                For each (Integer B) from 1 to 12, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Less than 7
                                (Integer B) Less than 7
                            Then - Actions
                                Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Ally with shared vision
                                Player - Make (Player((Integer B))) treat (Player((Integer A))) as an Ally with shared vision
                                Player Group - Add (Player((Integer A))) to ForceA
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Less than 7
                                (Integer B) Greater than 6
                            Then - Actions
                                Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Enemy
                                Player - Make (Player((Integer B))) treat (Player((Integer A))) as an Enemy
                            Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Integer A) Greater than 6
                                (Integer B) Greater than 6
                            Then - Actions
                                Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Ally with shared vision
                                Player - Make (Player((Integer B))) treat (Player((Integer A))) as an Ally with shared vision
                                Player Group - Add (Player((Integer A))) to ForceB
                            Else - Actions

Cameras

Would also be nice to setup a nice camera for each player:

Cameras:
  • Create a cinematic fade in for all players.
  • Move the camera for each team to their hero selection areas.
  • Lock the camera for each team onto that milita in their hero selection areas.
  • Rotate the camera for each team around that milita in their hero selection areas.
  • Disable user control.

Code:
Initz
    Events
        Map initialization
    Conditions
    Actions
        Cinematic - Fade in over 8.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                Camera - Pan camera for (Player((Integer A))) to (Position of Selection Unit 0016 <gen>) over 0.00 seconds
                Camera - Lock camera target for (Player((Integer A))) to Selection Unit 0016 <gen>, offset by (0.00, 0.00) using Default rotation
                Camera - Rotate camera 720.00 degrees around (Position of Selection Unit 0016 <gen>) for Player 1 (Red) over 120.00 seconds
        For each (Integer A) from 7 to 12, do (Actions)
            Loop - Actions
                Camera - Pan camera for (Player((Integer A))) to (Position of Selection Unit 0028 <gen>) over 0.00 seconds
                Camera - Lock camera target for (Player((Integer A))) to Selection Unit 0028 <gen>, offset by (0.00, 0.00) using Default rotation
                Camera - Rotate camera 720.00 degrees around (Position of Selection Unit 0028 <gen>) for Player 1 (Red) over 120.00 seconds
Cinematic - Disable user control for (All players)

Heroes Setup

Prepare the Heroes:
  • Place heroes in their groups
  • Change color ro Black (Neutral color)
  • Disable attack/movement on all heroes
  • Reduce Skill Ponits to 0
  • Add Sell Units ability
  • Add Milita (Dummy Unit Selection) to stock
  • Make invulnerable
Code:
Unit Group - Add Paladin 0000 <gen> to GroupA
Unit Group - Add Blood Mage 0003 <gen> to GroupA
Unit Group - Add Keeper of the Grove 0004 <gen> to GroupA
Unit Group - Add Warden 0007 <gen> to GroupA
Unit Group - Add Demon Hunter 0006 <gen> to GroupA
Unit Group - Add Priestess of the Moon 0005 <gen> to GroupA
Unit Group - Add Archmage 0001 <gen> to GroupA
Unit Group - Add Mountain King 0002 <gen> to GroupA
--------   --------
Unit Group - Add Death Knight 0012 <gen> to GroupB
Unit Group - Add Shadow Hunter 0011 <gen> to GroupB
Unit Group - Add Far Seer 0009 <gen> to GroupB
Unit Group - Add Tauren Chieftain 0010 <gen> to GroupB
Unit Group - Add Blademaster 0008 <gen> to GroupB
Unit Group - Add Dreadlord 0014 <gen> to GroupB
Unit Group - Add Lich 0013 <gen> to GroupB
Unit Group - Add Crypt Lord 0015 <gen> to GroupB
--------   --------
Unit Group - Pick every unit in GroupA and do (Actions)
    Loop - Actions
        Unit - Change color of (Picked unit) to Black
        Hero - Modify unspent skill points of (Picked unit): Set to 0 points
        Custom script:   call UnitRemoveAbility(GetEnumUnit(),'Amov')
        Custom script:   call UnitRemoveAbility(GetEnumUnit(),'Aatk')
        Unit - Remove Shadow Meld from (Picked unit)
        Unit - Add Sell Units to (Picked unit)
        Neutral Building - Add Selection Unit to (Picked unit) with 1 in stock and a max stock of 1
        Unit - Make (Picked unit) Invulnerable
Unit Group - Pick every unit in GroupB and do (Actions)
    Loop - Actions
        Unit - Change color of (Picked unit) to Black
        Hero - Modify unspent skill points of (Picked unit): Set to 0 points
        Custom script:   call UnitRemoveAbility(GetEnumUnit(),'Amov')
        Custom script:   call UnitRemoveAbility(GetEnumUnit(),'Aatk')
        Unit - Add Sell Units to (Picked unit)
        Neutral Building - Add Selection Unit to (Picked unit) with 1 in stock and a max stock of 1
        Unit - Make (Picked unit) Invulnerable

Select Hero

Finally we are reaching the good stuff.
This code will handle players clicking on a hero.
For this we need:
  • Detect player unit selection.
  • Check the player hasnt already got a hero.
  • Check the hero isnt already being selected by another player.
  • Check the player is selecting from the right group of heroes.
  • Remove the selection arrow from the previously selected hero.
  • Change the previously selected hero back to computer ally.
  • Change the previously selected heroes color back to black.
  • Add the selection arrow to the new hero selected.
  • Change ownership of the newly selected hero, also changing color.
  • Set the newly selected hero as the players Selection
  • Add the hero to the used group, marking it as being used.
Code:
Select Hero
    Events
        Player - Player 1 (Red) Selects a unit
        Player - Player 2 (Blue) Selects a unit
        Player - Player 3 (Teal) Selects a unit
        Player - Player 4 (Purple) Selects a unit
        Player - Player 5 (Yellow) Selects a unit
        Player - Player 6 (Orange) Selects a unit
        Player - Player 7 (Green) Selects a unit
        Player - Player 8 (Pink) Selects a unit
        Player - Player 9 (Gray) Selects a unit
        Player - Player 10 (Light Blue) Selects a unit
        Player - Player 11 (Dark Green) Selects a unit
        Player - Player 12 (Brown) Selects a unit
    Conditions
        Finished[(Player number of (codeing player))] Equal to False
        ((codeing unit) is in Used) Equal to False
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((codeing player) is in ForceA) Equal to True
                ((codeing unit) is in GroupA) Equal to True
            Then - Actions
                Unit - Remove Selection Arrow  from Selected[(Player number of (codeing player))]
                Unit - Change ownership of Selected[(Player number of (codeing player))] to Player 6 (Orange) and Retain color
                Unit - Change color of Selected[(Player number of (codeing player))] to Black
                --------   --------
                Unit - Add Selection Arrow  to (codeing unit)
                Unit - Change ownership of (codeing unit) to (codeing player) and Change color
                Set Selected[(Player number of (codeing player))] = (codeing unit)
                Unit Group - Add (codeing unit) to Used
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((codeing player) is in ForceB) Equal to True
                ((codeing unit) is in GroupB) Equal to True
            Then - Actions
                Unit - Remove Selection Arrow  from Selected[(Player number of (codeing player))]
                Unit - Change ownership of Selected[(Player number of (codeing player))] to Player 12 (Brown) and Retain color
                Unit - Change color of Selected[(Player number of (codeing player))] to Black
                --------   --------
                Unit - Add Selection Arrow  to (codeing unit)
                Unit - Change ownership of (codeing unit) to (codeing player) and Change color
                Set Selected[(Player number of (codeing player))] = (codeing unit)
            Else - Actions

Confirm Hero

Nearly there. This code will handle players confirming their hero.
It will detect them 'buying' the fake selection unit, returning the selected hero back to normal & then lastly creating a fresh new hero at their teams base for them to use.

For this we need:
  • Detect unit being sold.
  • Check the unit being sold is the dummy selection unit.
  • Set the players boolean, marking him as having a hero (prevents him from picking any others).
  • As in the unit selection, remove the selection arrow from previous unit, change it back to computer ally & change its color to black.
  • Reset the players camera & move it to his team's base.
  • Create the hero he selected at his team's base for him.
  • Add a special effect onto the freshly created hero, I recommend tomb of retraining.
  • Select the newly created hero for him.

Code:
Confirm Hero
    Events
        Unit - A unit Sells a unit
    Conditions
        (Unit-type of (Sold unit)) Equal to Selection Unit
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Selling unit) is in GroupA) Equal to True
            Then - Actions
                Set Finished[(Player number of (codeing player))] = True
                Unit - Remove Selection Arrow  from (codeing unit)
                Unit - Change ownership of (codeing unit) to Player 6 (Orange) and Retain color
                Unit - Change color of (codeing unit) to Black
                Camera - Reset camera for (codeing player) to standard game-view over 0.00 seconds
                Camera - Pan camera for (codeing player) to (Center of BaseA <gen>) over 0.00 seconds
                Unit - Create 1 (Unit-type of (codeing unit)) for (codeing player) at (Center of BaseA <gen>) facing 0.00 degrees
                Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                Selection - Select (Last created unit) for (codeing player)
                Game - Display to (All players) the text: ((Name of (codeing player)) + ( has chosen  + ((Proper name of (Last created unit)) + (, the  + (Name of (Last created unit))))))
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Selling unit) is in GroupB) Equal to True
            Then - Actions
                Set Finished[(Player number of (codeing player))] = True
                Unit - Remove Selection Arrow  from (codeing unit)
                Unit - Change ownership of (codeing unit) to Player 12 (Brown) and Retain color
                Unit - Change color of (codeing unit) to Black
                Camera - Reset camera for (codeing player) to standard game-view over 0.00 seconds
                Camera - Pan camera for (codeing player) to (Center of BaseA <gen>) over 0.00 seconds
                Unit - Create 1 (Unit-type of (codeing unit)) for (codeing player) at (Center of BaseB <gen>) facing 0.00 degrees
                Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                Selection - Select (Last created unit) for (codeing player)
                Game - Display to (All players) the text: ((Name of (codeing player)) + ( has chosen  + ((Proper name of (codeing unit)) + (,  + (Name of (codeing unit))))))
            Else - Actions

Final Touches

As a small add-on I'd recommend adding a finishing touch to the Dummy Unit. in his Model File, change it to 'blank' / a 'space'.
This will make him invisible, in the editor hell show up as a green box, but ignore that.
new2.jpg

new.jpg

Thats all folks, thx for reading this tutorial.
I hope you enjoyed it and learnt something from it.

EDIT:
Query 1) Do these forums use [Goto] [Point] tags for setting up 'jumps' in the contents for easier navigation, could get it working if so.
Query 2) I tried [trigger] tags, thought that would work for GUI, the code tags dont bring them out either. What the tags for GUI please.
thx
 

Attachments

  • HeroSelection.w3x
    57.4 KB · Views: 620

lh2705

Just another Helper
Reaction score
111
I don't see why anyone is not replying this thread.

Anyways, I'll be the first then. :D
I think this is very well written and would help other map makers to use this type of system into their maps instead of the plain tavern system.
Also, there is an upside and a downside for using this system.

The Upside, there will be no map lags when you choose your hero.
The Downside, the map would take a longer time to load since the heroes are preloaded onto the map.

But, its no different from using the tavern type system. The tavern system just takes a shorter time to load, but the map will lag upon hero creation.
Just a reminder when choosing which type of selection system you would like. ;)

In short, awesome tutorial and great work.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Impressive work.

I love how it is polished :)

Although the cinematic part is useless at best, everything is well explained and the example map explains the system good.

Many screenshots, the code is well detailed.

Thumbs up and approved ;)

> Do these forums use [Goto] [Point] tags for setting up 'jumps' in the contents for easier navigation, could get it working if so.

Unfortunately, no.

> I tried [trigger] tags, thought that would work for GUI, the code tags dont bring them out either. What the tags for GUI please.
thx

CODE tags are our trigger tags :p
 

Fulla

Evil Overlord
Reaction score
31
aha thx alot.
My next task will be a highly detailed, yet simplistic tutorial on making an efficient multiboard.

- Basics of a Multiboard (Beginner)
- Creating a Dota like Multibaord (Intermediate)
- Creating an endgame Multiboard displaying statistics (Advanced)
 

wilze

Active Member
Reaction score
3
u can also set the model to
.mdl to make it invisable XD unnessesary.

great tut
 
G

Gerhard

Guest
Great tutorial, learnt alot :D

Found two things to complain about :)

1st you wrote player 1 red instead of player integerA at two places in the camera trigger.

2nd you have forgot to remove sold unit from game in Confirm Hero
 

San-D

New Member
Reaction score
15
Exelent tutorial! But not good if u have 30-40 heroes

I found a flaw! (No Offence, I just wanna help improve this!)
If u press F10 (menu) while the cammera is spinning, it stops after u return

PS
Also, if u strat clicking the sasme hero over and and over, it does wierd things!
 

The Helper

Necromancy Power over 9000
Staff member
Reaction score
1,697
5 Star Bump

5 Star Bump! - This tutorial has only been rated twice. Please consider rating this tutorial so we have more opinions. Thanks!
 
D

darkzz

Guest
Terrain/Units/Rects

Now we need to setup the terrain & the units, creating both a hero selection area & a base for each team.

Hero Selection Areas:
- All heroes should be computer ally player of team A/B, in this case player's 6/12.

how do i setup it ? thx
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top