Building modding

From Crusader Kings II Wiki
Jump to: navigation, search
Buildings are fairly simple to mod.

Building definitions are located in common\buildings\ folder.


Name Type Description Example
potential conditions (province scope) Decides if the building shows up on the buildings list of a holding. FROM is the settlement holder (a character), FROMFROM is the holding (a barony title).
potential = { religion = catholic }
desc Key Localization key for building description, used in the tooltip of the building. Follows <building_name>_desc convention.
desc = shipyard_desc
add_number_to_name bool Makes the game use 1st level building name, and add number after it to name higher level buildings.
add_number_to_name = no
replaces building The replaced building will not be constructible, even if its potential would match.
ca_steppe_barracks_1 = {
	replaces = ca_barracks_1
trigger conditions (province scope) Requirements to be able to build the building.
is_active_trigger conditions (province scope) The building will not apply its modifiers to the holding, unless the trigger conditions are satisfied.
is_active_trigger = {
 location = {
  OR = {
   port = yes
   borders_major_river = yes
   borders_lake = yes
port bool Can only be built on coastal province.
port = yes
prerequisites List<building> Other buildings requirements
ca_steppe_barracks_2 = {
	prerequisites = { ca_wall_1 }
not_if_x_exists List<building> Cannot build this building if another is (or others are) built.
not_if_x_exists = { ca_walls_1 ca_walls_2 }
upgrades_from building
upgrades_from = tb_training_grounds_1
gold_cost int Cost to build the building
gold_cost = 150
prestige_cost int Cost to build the building
prestige_cost = 300
build_time int Time to build, in days
build_time = 365
ai_creation_factor int Chances for the AI to chose constructing this building.
ai_creation_factor = 95
ai_feudal_modifier int Modifies the ai creation weight if the ai is feudal, or is tribal but strive to become feudal.
ai_feudal_modifier = -10
ai_republic_modifier int Modifies the ai creation weight if the ai is a republic, or is tribal but strive to become a republic.
ai_republic_modifier = 5
extra_tech_building_start double When starting a new game, a building will be pre-built if the province has higher technology than the trigger requirement(s) + the value of extra_building_start + a random number 0-1
extra_tech_building_start = 0.4
scouting bool Determines if the building gives vision of the province where it was built, like a Merchant Republic trade post.
scouting = yes
convert_to_city building If the holding is converted to another type, the building gets converted to the equivalent building
convert_to_city = ct_wall_1
convert_to_castle = ca_keep_2
convert_to_temple = tp_town_1
convert_to_tribal = tb_shipyard_1
<modifier_name> Building modifiers Modifiers provided by the building, in case is_active_trigger is valid.

Note that a negative tax_income might be used to simulate an upkeep for the building.

fort_level = 0.5


Here is an example from common\buildings\00_Castle.txt:

ca_keep_6 = {
	desc = ca_keep_1_desc
	upgrades_from = ca_keep_5
	gold_cost = 500
	build_time = 2190 #6y
	levy_size = 0.3
	garrison_size = 0.2
	ai_creation_factor = 97
	extra_tech_building_start = 0.2

Adding a new building[edit]

So lets assume you want to add a new building to the game. This guide will give basic instruction on how to create a basic working building. There are more polished and professional ways to attack this task, but they will all build upon the basic file structure and placement included below.

There are several decisions that you have to make in order to create a building that will work correctly. In what type of settlement will the building be located, castle, city, or temple? What type of restrictions will be placed on where the building can be created? What will be the bonuses or traits that this building grants?

First locate the "buildings" folder inside the CK2 file structure. Usually it is something like: C:\Program Files\Steam\SteamApps\common\buildings. Once you have located the "buildings" folder you will need to add an entry to the one of these files that corresponds with the type of building you wish to add. For this example I am going to add a simple statue to my castle that will provide some nice bonuses, so I will choose the 00_castle.txt file.

It is highly recommended that you use Notepad++ to edit the file and make a backup of this file before you make any changes.

Under the "castle = {" heading I am just going to copy the formatting of the first entry making minor changes to create my own building. My favorite starting location is Moray in Scotland, so I will restrict the building to only working in that province. I want the building to always be available for me to build, with modest costs, and some nice bonuses for my troops and income. It will look something like this:

castle = {
	ca_statue = {
		desc = ca_statue_desc
		potential = {
			OR = {
				province_id = 40 #Moray
		trigger = { always = yes }
		build_cost = 150
		build_time = 91
		knights = 50
		levy_size = 0.5
		tax_income = 5

There are tons of different triggers and traits that can be added to buildings to make them unique and powerful! It may be worthwhile just looking at the other entries to learn how to personalize your building. This building will give my lord 50 heavy infantry, a 50% larger levy, and 5 as income!

Once these lines have been added to the 00_castle.txt file, the description tags need to be created in the localisation directory, it should be in the same folder where you found the "common" folder.

Using Notepad++ copy one of the .csv files and rename it for your own building. Open the file and delete all lines except for the top line (which only serves as a template and is not actually necessary). Follow the format that it explicitly outlines in the template on the top line, making sure not to miss any punctuation marks! If desired you can add these translations, just type the French description you wish to appear in place of the "FRENCH" on the appropriate line. I don't play the game in other languages, so I didn't add any translations. Mine looks something like this:

ca_statue;Heroic Statue;FRENCH;GERMAN;;SPANISH;;;;;;;;;x
ca_statue_desc;This heroic statue stands as a testament for the deeds of the great men who came before and that all men can achieve greatness.;FRENCH;GERMAN;;SPANISH;;;;;;;;;x

After completing these steps you should have a Statue you can build in Moray.

DefinesGame rulesReligionCultureTraitsTechnologyLawsBuildingsCasus BelliObjectivesGovernmentsDiseaseDeathMinor titles