The Age of Empires II Technology Trees In Your Web Browser

Age of Empires II currently offers 31 unique civilization to play as. Compared to, for example, the three races that players can choose from in StarCraft 2, that might seem overwhelming at first. However, all Age of Empires II civilizations share a common pool of units, buildings and technologies, with only a few unique elements to each civilization. This lowers the bar for newer players significantly.

A civilization’s technology tree shows which units, buildings and technologies are available to that civilization in which age. This follows some general rules, like that mesoamerican civilizations do not have access to cavalry, and further civilization-specific rules that disable certain units and technologies for a civilization. Due to the common pool, all technology trees look similar, albeit not identical.

The Age of Empires II Technology Trees In Your Web Browser

The leftmost part of the Japanese technology tree

Sometimes, players wish to access the technology tree for one or more civilizations without having the game open, to see which units, buildings or technologies are available to a civilization.

Let’s build an online technology tree!

We start by analyzing the layout of the in-game technology tree:

  • There are eight rows, two per age.
  • Squares are connected  by exclusively horizontal and vertical lines.
  • Elements of one upgrade line are all within the same column.
  • Buildings are centered on their immediate unit and technology children.

Sounds doable!

Our next step is to collect all available building, unit and technology names. We devise a clever algorithm to recreate the desired layout that contains the data we collected before.

Next we notice that some civilizations have unique units, which move parts of the tree around when they are inserted.

Crestfallen, we exclaim „Oh no!“ and scrap the idea of an accurate representation of the in-game tech tree, because while we are rather motivated, we are first and foremost lazy programmers.

Instead, we create a „master“ technology tree which contains the elements of all technology trees in the game. Unfortunately, this means that it gets even wider than the original version(s). Also, some squares will be disabled for 30 out of 31 civilizations, but whatever. At this point, we don’t care.

Speaking of disabling: We add a the functionality to display big red crosses when an item is disabled. Hereafter, we spend two hours scrolling through the tech tree of every civilization and adding the information which buildings, units and technologies are disabled to our application.

As a finishing touch, we add all the icons, and we are basically done!

The Age of Empires II Technology Trees In Your Web Browser

Add dank memes to your blog posts to boost your reach among adolescent audiences.

We present: A bland online version of the Age of Empires II technology tree. In your browser, even kind of mobile-friendly, MIT-Licensed (except the icons).

Unfortunately this version is currently without the civilization bonuses that are usually displayed below the civilization selection box, as we could also not be bothered to manually type them all.

Everything is Regicide – now with Treason

In Everything is Regicide with UserPatch 1.5 I described how to turn any random map script into a custom regicide map, with the help of UserPatch 1.5 and the guard_state command.

However, regicide is only half the fun without the Treason1 technology. For the mere cost of 400 gold, it briefly reveals the positions of all enemy kings. Treason can also be researched repeatedly, making it easier for you to hunt those kings down and eventually kill them, defeating the player instantly.

Treason is only available in regicide games, where it replaces the Spies technology2. Treason could hence not be used on the custom regicide maps above. The latest update of UserPatch 1.5 however allows us to manually enable the technology in our random map script, without the use of any mod!

Adding Treason to Custom Regicide Maps

First we need to define three constants at the top of the script (if they are not defined already):

#const GAIA_SET_PLAYER_DATA -10
#const DATA_MODE_FLAGS 1
#const ATTR_SET 0

Now we can mess with the availability of Treason and Spies in the <PLAYER_SETUP> section by adding an effect_amount command:

<PLAYER_SETUP>
  […]
  effect_amount GAIA_SET_PLAYER_DATA DATA_MODE_FLAGS ATTR_SET 1

The value 1 at the end enables the Treason technology, the value 2 disables the Spies technology, and the value 3 does both (so Treason is available while Spies is not).

I have of course updated all the custom King of the Hill Regicide maps over at Github to include both Treason and Spies: click me

Have fun!

Does it have to be a king?

The guard_state option not only works with kings, but with arbitrary units.

Supposedly, Treason also works with other units that a guard_state is set for. If there is a king, it is revealed, else one guard_state unit is revealed. This behaviour is not necessarily ideal, but without doubt better than before.

  1. (the medieval kind)
  2. For the mere price of 200 Gold per enemy villager (min. 200, max 30.000), Spies reveals the line of sight of all enemy players‘ units.

Everything is Regicide with UserPatch 1.5

Regicide is a fun game mode in Age of Empires II where each player controls one1 king, and as soon as a player controls zero kings, the player drops out of the game.

King of the Hill is a fun game mode in Age of Empires II where there is an indestructible monument in the center of the map. When a player has at least one unit around the monument and all other players don’t, the player gets control of the monument. The first time this happens in a game, a countdown of 550 in-game years starts. A player who controls the monument when the countdown hits zero wins the game. When control of the monument switches and the countdown is below 100 in-game years, it is reset to 100 in-game years.

In regular gameplay, these gamemodes are mutually exclusive: You can either play Regicide and hunt kings (cruel, I know!), or you can play King of the Hill and desperately throw your armies into the middle. But you could not do both at the same time.

Now, with the endless possibilities that UserPatch 1.5 has brought upon us, you actually can. But how? Let us find out.

Random maps in Age of Empires II are generated using random map scripts. A random map script is a text file with the extension .rms that contains instructions on how to generate the terrain and distribute players, units and resources on a map. In addition to the maps that come with the original game, many interesting and fun random map scripts have been developed by the community.

Let’s look at what a map would have to do in order to provide Regicide or King of the Hill capabilities, respectively.

We can easily see that the mechanics of Regicide are rather easy to implement:

begin loop
    for each player
        if player does not control king
            player loses
        endif
    endfor
end loop

We need to put a king on the map (easy), and when a player has no king, the player must drop out (???).

The mechanics of King of the Hill are rather complicated in comparison:

begin loop
    if there are units around the monument
        if no countdown is running
            countdown = 550
            start countdown
            give control of the monument to a player who has units around the monument
        else
            if player who controls monument has no units around the monument
                give control of the monument to a player who has units around the monument
                if countdown < 100
                    countdown = 100
                endif
            endif
        endif
    endif
    if countdown == 0
        player who controls monument wins
    endif
end loop

We need to put a monument in the dead center of the map (not sure if we can hit the center, but approximately it’s definitely possible) and handle a countdown (???) as well as ownership changes (???).

From what we gathered so far, it looks way more practical to create a random map script which simulates a Regicide game, and to then use it with the King of the Hill game mode, where game itself handles all the monument placement and especially the gameplay logic for us.

UserPatch 1.5 introduces a new statement into Random Map Scripting: guard_state. It is a very powerful statement which can serve two functions at once: Generate a resource trickle and define a victory/defeat condition. This makes it a bit tricky to use.

Everything is Regicide with UserPatch 1.5

The reference text for guard_state from the UserPatch 1.5 beta documentation.

Our plan for creating a King of the Hill Regicide map is as follows:

  1. Take practically any old random map script
  2. Place a king unit, even if the game mode is not Regicide
  3. Use guard_state to make a player lose if the player does not control any king unit
  4. Maybe adjust the starting resources
  5. Play the map with the King of the Hill game mode
  6. Profit!

Let’s go through these step by step.

1. Take practically any old random map script

I take the WSVG Single Maps v2 by HJ1, because they contain many standard maps, but frankly, it does not really matter.

2. Place a king unit, even if the game mode is not Regicide

While in theory only the king is necessary, we usually want to recreate the Regicide look and feel, which includes additional villagers (no problem), a castle from the start (no problem) and different resources (welp… you can’t have everything.)

The random map script will probably contain a part like this in the <OBJECTS_GENERATION> section2:

/* SPECIAL STUFF FOR REGICIDE */

if REGICIDE
create_object VILLAGER
{
 number_of_objects 7
 set_place_for_every_player
 min_distance_to_players 6
 max_distance_to_players 6
}

create_object KING
{
 set_place_for_every_player
 min_distance_to_players 6
 max_distance_to_players 6
}

create_object CASTLE
{
 set_place_for_every_player
 min_distance_to_players 10
 max_distance_to_players 10
}

endif

This places additional villagers, a king, and a castle. We simply copy this part, but replace „if REGICIDE“ with „if KING_OT_HILL“:

/* SPECIAL STUFF FOR REGICIDE */

if REGICIDE
(…)
endif

if KING_OT_HILL
create_object VILLAGER
{
 number_of_objects 7
 set_place_for_every_player
 min_distance_to_players 6
 max_distance_to_players 6
}

create_object KING
{
 set_place_for_every_player
 min_distance_to_players 6
 max_distance_to_players 6
}

create_object CASTLE
{
 set_place_for_every_player
 min_distance_to_players 10
 max_distance_to_players 10
}

endif

Note: This way, the map will only work with King of the Hill or Regicide game modes. If we want this map to be usable for any other game mode as well, we can instead simply remove the „if REGICIDE“ and „endif“ parts.

If you can’t find a regicide section in your random map script file, just copy it from this article and paste it into the <OBJECTS_GENERATION> section. If there is no such section, that’s very strange, but you can add that as well in that case.

Now that we get kings in King of the Hill, we can move on to the interesting part. Simply losing your king won’t kill you… yet.

3. Use guard_state to make a player lose if the player does not control any king unit

We need to tell guard_state to watch out for kings. Also, we need to set guard-flag-victory. We do not want to use the resource trickle functionality, but have to fill all parameters. Hence, we add the resource identifiers at the top of the file, before any section. In the <PLAYER SETUP> section, we add our guard_state rule with an arbitrary resource and a ResourceDelta of zero.

The top of our random map script file now looks like this3:

#const AMOUNT_FOOD 0
#const AMOUNT_WOOD 1
#const AMOUNT_STONE 2
#const AMOUNT_GOLD 3

<PLAYER_SETUP>
 random_placement
 guard_state KING AMOUNT_WOOD 0 1

Turns out that we are done. The King of the Hill Regicide game is ready to be played. But wait, there’s more!

(If there is no <PLAYER_SETUP> section in your random map script file, just add it. It might also not be at the top.)

4. Maybe adjust the starting resources

In regular games, each player starts with 200 wood, 200 food, 100 gold and 200 stone when using standard resources4. In Regicide games however, players start with 500 wood, 500 food, 0 gold and 150 stone. We can adjust for that by introducing further declarations at the top of our random map script as well as four effect_amount statements in the <PLAYER_SETUP> section, which adjust the starting resource values. The top of our file now looks like this:

#const AMOUNT_FOOD 0
#const AMOUNT_WOOD 1
#const AMOUNT_STONE 2
#const AMOUNT_GOLD 3
#const STARTING_FOOD 91
#const STARTING_WOOD 92
#const STARTING_STONE 93
#const STARTING_GOLD 94
#const MOD_RESOURCE 1
#const ATTR_SET 0


  random_placement
  guard_state KING AMOUNT_WOOD 0 1
  effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET 300
  effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET 300
  effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -100
  effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -50

Don’t be fooled: It might say „ATTR_SET“, but the values are actually added to the initial values, they do not replace them.

5. Play the map with the King of the Hill game mode

We move the .rms file into the game folder for random map scripts, most likely C:/Program Files (x86)/Steam/steamapps/common/Age2HD/Random or C:/Program Files/Microsoft Games/Age of Empires II/Random.

We start up the game.

We create a new game with a custom map and select our random map script.

We start the game.

We see the monument in the middle.

We see our king.

We delete our king.

We lose.

We are happy that it works.

6. Profit!

Check out these maps that I already modified and threw on GitHub for your playing pleasure.

Everything is Regicide with UserPatch 1.5

This is a fake screenshot that I took with the HD edition because I wanted an image in this article, but did not want to reboot my computer in order to start up Voobly.

Drawbacks and fun ideas

King of the Hill Regicide games lack two main things one thing: The starting resources of a Regicide game, which are different from a standard random map game, and the Treason technology, which reveals the positions of all enemy kings on the map for a few seconds.

The „king“ unit does not necessarily need to be a king. Basically any unit that the players can’t produce themselves will do5. Why not use Joan of Arc? Or even a building? You can do anything. Anything at all. The only limit is yourself.

TL;DR

Add this to your random map script in order to turn it into a King of the Hill Regicide map:

At the top:

#const AMOUNT_FOOD 0 
#const AMOUNT_WOOD 1 
#const AMOUNT_STONE 2 
#const AMOUNT_GOLD 3
#const STARTING_FOOD 91
#const STARTING_WOOD 92
#const STARTING_STONE 93
#const STARTING_GOLD 94
#const MOD_RESOURCE 1
#const ATTR_SET 0

In the <PLAYER_SETUP> section:

guard_state KING AMOUNT_WOOD 0 1
effect_amount MOD_RESOURCE STARTING_WOOD ATTR_SET 300
effect_amount MOD_RESOURCE STARTING_FOOD ATTR_SET 300
effect_amount MOD_RESOURCE STARTING_GOLD ATTR_SET -100
effect_amount MOD_RESOURCE STARTING_STONE ATTR_SET -50

In the <OBJECTS_GENERATION> section:

if KING_OT_HILL
create_object VILLAGER
{
 number_of_objects 7
 set_place_for_every_player
 min_distance_to_players 6
 max_distance_to_players 6
}

create_object KING
{
 set_place_for_every_player
 min_distance_to_players 6
 max_distance_to_players 6
}

create_object CASTLE
{
 set_place_for_every_player
 min_distance_to_players 10
 max_distance_to_players 10
}

endif

[Update 2017-09-22]: Added the adjustment of starting resources, big thanks to TriRem!

  1. In rare settings, that may also be two or more kings.
  2. Random map scripts are organized in sections.
  3. We actually don’t even need all resources declared. But maybe we want to extend the map later. Adding them doesn’t hurt.
  4. We ignore civilization „bonuses“ here as they do not interfere with what we are doing.
  5. We can also use units that the players can produce, like villagers or scouts. But that would kind of foil the base idea of Regicide.