Hero Taverns

By SD_Ryoko
Demo map This tutorial also has a free demo map.
Download Here

Introduction

This tutorial will explain how to make a tavern where you can purchase your starting heroes. These taverns are common on the newer DOTA maps and some of the hero siege maps. When you have a lot of heroes, a tavern is nice because it takes much less room on your map than a hero arena does. We will cover creating the tavern, the heroes, and the triggers to make it all come together.

Were going to use the techtree and custom gameplay constants to restrict heroes to 1. This way, you don't have to use food, gold or lumber anymore! This allows you to use resources for other things, making a better map.

See also: Hero Arenas

Hero Taverns

A hero tavern uses icons to sell heroes.

Preparing your heros

The first step is prepare you heroes for the tavern. We also need to change the costs, techtree requirements, and button position of each hero for the tavern icon. The tavern will sort the heroes automatically, but when a hero is sold they will all shift to a new location. That's quite annoying, and we can prevent that by setting the units icon position. Taverns can hold up to twelve heros.

Hero Taverns

Button positions determine the icon locations of a hero.

Now you need to change your heroes to be compatable at the tavern. Remember that players start with zero resources, so unless your giving the players resources, the hero should cost nothing. To prevent players from owning more than one hero, we will modify the techtree requirements. Below is a list of fields you need to change, and a brief explenation of each.

* You'll notice some of these are default settings. But that is not true on all hero units.

  • Art - Button Position (X)   X position of the hero icon.
  • Art - Button Position (Y)   Y position of the hero icon.
  • Stats - Gold Cost   How much gold your hero will cost.
  • Stats - Lumber Cost   How much lumber your hero will cost.
  • Stats - Food Cost   Hero food cost. Probobly 0 for your map.
  • Stats - Stock Maximum   Change to 1.
  • Stats - Stock Start Delay   Were going to use 15 seconds.
  • Techtree - Requirements   Any Alter.
  • Techtree - Requirements - Tier 2   Any Tier 2 hall, Any Alter.
  • Techtree - Requirements - Tier 3   Any Tier 3 hall, Any Alter.

Creating the Tavern

Now we'll need a tavern to sell our heroes. I am going to start with the Tavern unit, which already sells heroes and it's a good template. The tavern is found in the object editor, under neutral passive buildings. Right click it and create a new custom unit.

First, lets change the abilities of the tavern. I am going to remove 'Revive Hero Instantly' because I do not want my tavern to revive heroes. The taverns abilities should read:

Abilities - Normal:   Select Unit, Invulnerable (Neutral)

Next we add all of the heroes we want the tavern to sell. The field inside the tavern we want to change is Techtree - Units Sold. Double click it to change it, and add in all of your heroes. Again, the tavern can sell a maximum of twelve heroes.

Placing the Tavern on the Map

Your tavern is ready, so now we can place it on the map. The tavern should be in a remote area, farther away from gameplay than your other units. You will also need a region to place the heroes inside when a player picks them.

You will need a player unit somewhere near the tavern, so that a player can purchase units from it. Most commonly used unit is the circle of power. Place a custom circle of power for each player that can buy heroes from the tavern. I like to make my circles of power very small, so they are not obviously seen. You can change the Art - Scaling Value to .10 and hide them behind the back of the building.

Hero Taverns

Place the player units near the tavern. I prefere to hide mine.

Alter Gameplay Constants

Next we need to alter the gameplay constants to restrict heroes to 1 per player.

  • Click Advanced, Gameplay Constants.
  • Check the box at the top that says 'Use Custom Gameplay Constants'.
  • Find 'Techtree - Dependancy Equivalents - Alter'. Here, add your custom circle of power we are using next to the taverns. You now have a legitamate alter on the map, using the circle of power. This will allow you to purchase a hero.
  • Find 'Techtree - Dependancy Equivalents - Hero'. This controls which units count when restricting heroes. Clear all heroes already on the list. Now one by one, add your custom heroes here. This prevents your players from purchasing more than one hero!
  • Click 'OK' when finished.

Creating the Triggers

The first trigger you will need is a trigger to give every player some starting resources. Most importantly, this trigger ADDS ALL HEROES to an array variable. This is used to generate random hero picks. Our trigger will run when the map starts.

  • Total_Heroes is how many heroes you have. I have 8 heroes.
  • Random_Count is how many randoms are left. Should be EQUAL to your Total_Heroes.
  • Hero_Array contains ALL your custom heroes.
  • Random_Data is used for choosing a random, uniqe hero. This should ALSO be equal to your number of heroes.
Map Initialization
    Events
        Map initialization
    Conditions
    Actions
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Player - Set (Picked player) Current gold to 750
                Player - Set (Picked player) Current lumber to 100
                Camera - Pan camera for (Picked player) to (Position of Tavern 0000 <gen>) over 0.00 seconds
                Player - Set (Picked player) Food cap to 6
        Set Total_Heroes = 8
        Set Random_Count = 8
        Set Hero_Array[1] = Alchemist
        Set Hero_Array[2] = Naga Sea Witch
        Set Hero_Array[3] = Tinker
        Set Hero_Array[4] = Beastmaster
        Set Hero_Array[5] = Dark Ranger
        Set Hero_Array[6] = Firelord
        Set Hero_Array[7] = Pandaren Brewmaster
        Set Hero_Array[8] = Pit Lord
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Set Random_Data[(Integer A)] = (Integer A)

Now we'll need a series of triggers. My demo map is more advanced, so I'll list which triggers I needed. You do not have to have all these features in your map, but it is popular now a days to have a random command and repick command.

The times and methods I used are preferences based on popular maps. You can change the times and how things work to your liking. But for this demo, we are going to use these triggers.

  • A trigger for when a unit is manually purchased from the tavern.
  • A trigger for the -random command.
  • A trigger for the -repick command.
  • A trigger to do 'all random'.
  • A trigger that turns on repick and random after 15 seconds, and turns off all random.
  • A trigger that turns off repick and random after 45 seconds.

When a hero is chosen in any way, it is taken out of the array using a mathematical sequence. Therefore, we never need to worry about whether or not a unique hero was chosen, because it no longer exists in the array!

Manual Hero Pick

Initially ON.
Events
    Unit - A unit Sells a unit
Conditions
    ((Sold unit) is A Hero) Equal to True
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)
    Game - Display to (All players) the text: (A player has chosen  + (Name of (Sold unit)))
    Selection - Select (Sold unit) for (Owner of (Sold unit))

Random Command

Initially OFF.
Events
    Player - Player 1 (Red) types a chat message containing -random as An exact match
    Player - Player 2 (Blue) types a chat message containing -random as An exact match
    Player - Player 3 (Teal) types a chat message containing -random as An exact match
    Player - Player 4 (Purple) types a chat message containing -random as An exact match
    Player - Player 5 (Yellow) types a chat message containing -random as An exact match
    Player - Player 6 (Orange) types a chat message containing -random as An exact match
Conditions
    (Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
Actions
    Set Random_Hero = (Random integer number between 1 and Random_Count)
    Unit - Create 1 Hero_Array[Random_Data[Random_Hero]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
    Game - Display to (All players) the text: (A player has randomed  + (Name of (Last created unit)))
    Selection - Select (Last created unit) for (Owner of (Last created unit))
    Player - Add -425 to (Triggering player) Current gold
    Player Group - Pick every player in (All players) and do (Actions)
        Loop - Actions
            Player - Make (Unit-type of (Last created unit)) Unavailable for training/construction by (Picked player)
    Set Random_Data[Random_Hero] = Random_Count
    Set Random_Count = (Random_Count - 1)

Repick Command

Initially OFF.
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
Conditions
    (Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 1
Actions
    Game - Display to (All players) the text: A player has repick...
    Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) 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)
            Unit - Remove (Picked unit) from the game
    Set Random_Hero = (Random integer number between 1 and Random_Count)
    Unit - Create 1 Hero_Array[Random_Data[Random_Hero]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
    Selection - Select (Last created unit) for (Owner of (Last created unit))
    Game - Display to (All players) the text: (A player has randomed  + (Name of (Last created unit)))
    Player Group - Pick every player in (All players) and do (Actions)
        Loop - Actions
            Player - Make (Unit-type of (Last created unit)) Unavailable for training/construction by (Picked player)
    Set Random_Data[Random_Hero] = Random_Count
    Set Random_Count = (Random_Count - 1)

All Random Command

Initially ON.
Events
    Player - Player 1 (Red) types a chat message containing -ar as An exact match
Conditions
Actions
    Trigger - Turn off Random Command <gen>
    For each (Integer A) from 1 to 6, do (Actions)
        Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    ((Player((Integer A))) slot status) Equal to Is playing
                Then - Actions
                    Set Random_Hero = (Random integer number between 1 and Random_Count)
                    Unit - Create 1 Hero_Array[Random_Data[Random_Hero]] for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
                    Selection - Select (Last created unit) for (Owner of (Last created unit))
                    Game - Display to (All players) the text: (A player has randomed  + (Name of (Last created unit)))
                    Player - Add -425 to (Player((Integer A))) Current gold
                    Set Random_Data[Random_Hero] = Random_Count
                    Set Random_Count = (Random_Count - 1)
                Else - Actions
                    Do nothing

Time is 15 seconds

Initially ON.
Events
    Time - Elapsed game time is 15.00 seconds
Conditions
Actions
    Trigger - Turn on Random Command <gen>
    Trigger - Turn on Repick Command <gen>
    Trigger - Turn off All Random Command <gen>

Time is 45 seconds

Initially ON.
Events
    Time - Elapsed game time is 45.00 seconds
Conditions
Actions
    Trigger - Turn off Repick Command <gen>
    Trigger - Turn off Random Command <gen>
 
 
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.