Now we are going to add buildings, guilds, traits, ancillaries, and triggers to our little mod.
Buildings are separated into "trees". A tree is simply a collection of buildings all related to each other that progress from lowest to highest in a strait line. You have to have A before you can build B before you can build C and so on. There can bea maximum of 128 trees with 9 buildings each, which gives you a maximum of 1152 buildings. Most mods will not even come close to that as many trees do not reach the maximum of 9 buildings.
We will be working with the following files. Copy the vanilla files into your mod folder:
export_descr_buildings.txt
export_descr_buildings_enums.txt
descr_building_battle.txt
descr_building_battle_enums.txt
In the text folder, convert them first:
building_battle.txt
export_buildings.txt
export_descr_guilds.txt
Before we create a new building it is best to decide how many levels there are going to be. I am going to create a Goldsmith with levels, Apprentice and Master. The easiest thing to do is find a tree with the same number of levels as you want to create and copy it, then change what you need to change. I am using bank as my template, simply because it has fewer units to remove than some of the others with 2 levels. Here is the original code:
This line simply names the tree. I used roads for this example because of the hinterland tag. Each tree name must be unique, and to keep things clean you should never have a level name the same as the tree name. The hinterland_ tag on the front end prevents the building from being destroyed by the player and is optional:
Code:
building hinterland_roads
This tells the game which tree to reference when the settlement is converted from city to castle. To use this feature you will have to build two trees, one for the city level and one for the castle level.
Code:
convert_to hinterland_castle_roads
This line defines the levels, from lowest level to highest.
Code:
levels roads paved_roads
This is pretty self explanatory. The building can only be built in a city, and only by the listed factions and cultures.
Code:
roads city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, }
This tells the game which entry in the tree named above to convert the building to. Note that it says 0, which is the first entry. Another case of starting counting at 0 instead of 1. Remember that as it will save you hours of headache later.
This defines what bonuses/penalties the building gives you. These are all listed in the Building Traits section of the M2TW Ultimate Docudemons, with examples of how they are used. Anything that says bonus can also be a negative bonus.
Code:
capability
{
road_level 0
}
This section defines the specifics of the building. I believe the material relates to how easily the building is damaged in the battle map, the rest is obvious.
Code:
material wooden
construction 1
cost 400
settlement_min town
Here is where you define the next building in the tree. As far as I know you cannot mix the tree up, you have to list the next level.
After that is the next level entry. At the end of all the levels there is a section called plugins. We will be leaving these empty for this course, but you can specify other buildings here. Basically what this does is apply a bonus from another building tree to this tree. There is some information on that here.
Decide what you are going to name your buildings, and start replacing text. Just change the name at first, and I always set the requries factions to all like this:
Code:
apprentice_gsmith requires factions { all, }
Once you get your new building to show up in the game you can tweak it. Here is my code. Note that I removed the convert_to lines and also that it doesnt speficy city or castle. You can do this if you want the building available in both types of settlement:
Now you need to add the text that shows up in game, in export_buildings.txt. If you notice you can create an entry for each culture, so that all cultures have a different description. This is useful because if you have two very different buildings but they have the same capabilities you can just name them differently and save on your building slots. For instance You can create generic_building_1 and give it an income_bonus of 2. Then in the descriptions file you could call it journalist for the northern_european culture and scribe for the middle_eastern culture with two very different descriptions by just appending the culture_name after the building_name. If all you put in the file is the building_name then all cultures will have the same description. The roads and farms and some of the guilds are done this way. For the purposes of the class all that is required is a single description.
Code:
{apprentice_gsmith}Apprentice Goldsmith
{apprentice_gsmith_desc}A jeweler for the masses that creates simple rings, necklaces, and other small items made from gold. One say he aspires to become a Master Goldsmith.
{apprentice_gsmith_short}A basic goldsmith capable of simple jewelry. Provides an income bonus.
{master_gsmith}Master Goldsmith
{master_gsmith_desc}A Master Goldsmith capable of doing any gold work you require.
{master_gsmith_desc_short}A Master Goldsmith. Provides an income bonus.
This will get the building in game, but it will show up as a barracks from RTW. This is because we havent given the building an image yet.
To give the building an image we need to create some folders. In the data folder create a folder named ui
Inside the ui folder create a folder for each culture you want to have the building, northern_european, southern_european, etc
Inside each culture folder create a folder named buildings
Inside the buildings folder create a folder named construction
Then you need 2 images for each building inside the building folder, with the culture name on the front.
#northern_apprentice_gsmith.tga
#northern_apprentice_gsmith_constructed.tga
#northern_master_gsmith.tga
#northern_master_gsmith_constructed.tga
Inside the construction folder you need 1 image for each building.
#northern_apprentice_gsmith.tga
#northern_european_master_gsmith.tga
Then your buildings will show up properly in game.
If you want them to show up in the battle map, we have to add a few more files. First open building_battle.txt and add description lines for your new buildings.
Code:
{apprentice_gsmith}Apprentice Goldsmith
{master_gsmith}Master Goldsmith
Then open descr_building_battle.txt. At the top of the file there is a section named stat_cats (statistics categories) that defines how strong a building is. Pick one that you think should apply to your new building and create an entry at the bottom.
Code:
apprentice_gsmith
{
stat_cat medium_stone
localised_name apprentice_gsmith
}
master_gsmith
{
stat_cat medium_stone
localised_name master_gsmith
}
This will allow your building to show on the battle map, and also allow it to be damaged by riots and auto calc battles.