Disable builds and upgrade

Level 4
Jan 18, 2016
Currently working on a campaign and was wondering: how do you disable the worker from not being able to build certain buildings?
From example, in the original RoC campaign, peasants in the 2nd mission can only build 1st tier buildings like barracks, farms etc but unable to build Arcane sanctum.
Also the Town Hall is unable to upgrade to Keep in that mission. So how do I disable them in my map?
Level 17
Sep 26, 2009
Well, I can see three ways to do this:

1) Simply remove those buildings from the build/upgrade menu.
If those buildings aren't even going to be used in said map, there's no need to go out of your way to disable them, when you can simply remove them. That means you need to edit the object editor data.
For workers, find "Techtree - Structures Built" field and remove all unwanted structures.
For building upgrades, search and edit the "Techtree - Upgrades To" field.

The disadvantage of this method is that it is global - in other words, if you edit "Human" race this way, all players with Human race will be affected.

2) Edit Player's Techtree Properties.
In the menu in the top bar of your world editor go to "Scenario" -> "Techtree Properties...". In the newly opened window check the "Use Custom Techtree" checkbox. Then you simply select player and choose buildings/units/upgrades and by unchecking specific boxes you disable that thing in game.
It's basically an easier version of the method #1, with the advantage that you set this for each player alone (in comparison to methdod #1 where it was globally for that race)

3) Set building availability via triggers.
You can make buildings/units (un)available for construction/training by using the following action:
  • Player - Make Lumber Mill Available for training/construction by Player 1 (Red)
The actions is "Player - Set Training/Construction Availability Of Unit".

The advantage of this approach is that you can change the availability dynamically during game, while method #2 is set on map initialization only.

You want to have this situation: At the start of the map, you can only build Town Hall. Once you build Town Hall you want the player to be able to build any other building.

The way to do this is by disabling all buildings except for Town Hall (via method #2).
However you will need method #3 to catch when Town Hall has been built and via trigger actions in method #3 enable other buildings.