castle = {
	# Keep
	ca_keep_1 = {
		gold_cost = 128
		build_time = 547 #1.5y
		ai_creation_factor = 102
		extra_tech_building_start = -1

		fort_level = 0.5
		levy_size = 0.06
		garrison_size = 0.06
		tax_income = 0.10

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 0
			ai_can_build_trigger = yes
		}
	}

	ca_keep_2 = {
		upgrades_from = ca_keep_1
		gold_cost = 128
		build_time = 730 #2y

		fort_level = 0.5
		levy_size = 0.06
		garrison_size = 0.06
		tax_income = 0.10

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 2
			ai_can_build_trigger = yes
		}
	}

	ca_keep_3 = {
		upgrades_from = ca_keep_2
		gold_cost = 257
		build_time = 1095 #3y

		fort_level = 0.5
		levy_size = 0.06
		garrison_size = 0.06
		tax_income = 0.10

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 4
			ai_can_build_trigger = yes
		}
	}

	ca_keep_4 = {
		upgrades_from = ca_keep_3
		gold_cost = 513
		build_time = 1460 #4y

		fort_level = 1
		levy_size = 0.06
		garrison_size = 0.06
		tax_income = 0.10

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 6
			ai_can_build_trigger = yes
		}
	}

	ca_keep_5 = {
		upgrades_from = ca_keep_4
		gold_cost = 1025
		build_time = 2190 #6y
		extra_tech_building_start = 1.4

		fort_level = 1
		levy_size = 0.06
		garrison_size = 0.06
		tax_income = 0.10

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 8
			ai_can_build_trigger = yes
		}
	}

	# Barracks
	ca_barracks_1 = {
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 105
		extra_tech_building_start = 1.2

		levy_size = 0.2
		heavy_infantry = 43
		pikemen = 21

		potential = {
			OR = {
				FROMFROM = { has_building = ca_barracks_1 }

				AND = {
					FROMFROM = { has_building = ca_keep_1 }
					TECH_HEAVY_INFANTRY >= 1
				}
			}
		}

		trigger = {
			TECH_HEAVY_INFANTRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_barracks_2 = {
		upgrades_from = ca_barracks_1
		gold_cost = 120
		build_time = 547
		ai_creation_factor = 104
		extra_tech_building_start = 2.2

		heavy_infantry = 52
		pikemen = 21

		trigger = {
			TECH_HEAVY_INFANTRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_barracks_3 = {
		upgrades_from = ca_barracks_2
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 103
		extra_tech_building_start = 3.6

		heavy_infantry = 57
		pikemen = 26

		trigger = {
			TECH_HEAVY_INFANTRY >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_barracks_4 = {
		upgrades_from = ca_barracks_3
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 102
		extra_tech_building_start = 3.8

		heavy_infantry = 62
		pikemen = 31

		trigger = {
			TECH_HEAVY_INFANTRY >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_barracks_5 = {
		upgrades_from = ca_barracks_4
		gold_cost = 400
		build_time = 2190
		ai_creation_factor = 101
		extra_tech_building_start = 3.0

		heavy_infantry = 72
		pikemen = 31

		trigger = {
			TECH_HEAVY_INFANTRY >= 7
			ai_can_build_trigger = yes
		}
	}

	# Training Grounds
	ca_training_grounds_1 = {
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 89
		extra_tech_building_start = 1.4

		land_morale = 0.1
		levy_reinforce_rate = 0.1
		retinuesize = 20

		potential = {
			FROMFROM = {
				OR = {
					has_building = ca_keep_1
					has_building = ca_training_grounds_1
				}
			}
		}

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 0
			ai_can_build_trigger = yes
		}
	}

	ca_training_grounds_2 = {
		upgrades_from = ca_training_grounds_1
		gold_cost = 250
		build_time = 1095
		ai_creation_factor = 88
		extra_tech_building_start = 0.9

		land_morale = 0.15
		levy_reinforce_rate = 0.15
		retinuesize = 20

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_training_grounds_3 = {
		upgrades_from = ca_training_grounds_2
		gold_cost = 300
		build_time = 2190
		ai_creation_factor = 88
		extra_tech_building_start = 0.8

		land_morale = 0.2
		levy_reinforce_rate = 0.2
		retinuesize = 20

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 6
			ai_can_build_trigger = yes
		}
	}

	# Shrine
	ca_shrine_1 = {
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 50
		extra_tech_building_start = 1

		monthly_character_piety = 0.05

		potential = {
			OR = {
				FROMFROM = { has_building = ca_shrine_1 }

				AND = {
					FROMFROM = { has_building = ca_keep_1 }
					TECH_RELIGIOUS_CUSTOMS >= 1
				}
			}
		}

		trigger = {
			TECH_RELIGIOUS_CUSTOMS >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_shrine_2 = {
		upgrades_from = ca_shrine_1
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 50
		extra_tech_building_start = 1

		monthly_character_piety = 0.05

		trigger = {
			TECH_RELIGIOUS_CUSTOMS >= 3
			ai_can_build_trigger = yes
		}
	}

	# Town Market
	ca_town_market_1 = {
		prestige_cost = 0
		build_time = 0
		ai_creation_factor = 120
		extra_tech_building_start = -1

		tax_income = 0.5

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 0
		}
	}

	ca_town_market_2 = {
		upgrades_from = ca_town_market_1
		gold_cost = 100
		build_time = 547
		ai_creation_factor = 120
		extra_tech_building_start = 1.2

		tax_income = 0.5

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_town_market_3 = {
		upgrades_from = ca_town_market_2
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 120
		extra_tech_building_start = 0.8

		tax_income = 1

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_town_market_4 = {
		upgrades_from = ca_town_market_3
		gold_cost = 250
		build_time = 1095
		ai_creation_factor = 120
		extra_tech_building_start = 1.0

		tax_income = 3

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_town_market_5 = {
		upgrades_from = ca_town_market_4
		gold_cost = 300
		build_time = 2190
		ai_creation_factor = 120
		extra_tech_building_start = 1.2

		tax_income = 4

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 7
			ai_can_build_trigger = yes
		}
	}

	# Housing
	ca_housing_1 = {
		prestige_cost = 0
		build_time = 0
		ai_creation_factor = 120
		extra_tech_building_start = -1

		land_morale = 0.05
		levy_size = 0.025
		levy_reinforce_rate = 0.05
		light_infantry = 16
		archers = 12

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 0
		}
	}

	ca_housing_2 = {
		prerequisites = { ca_town_market_1 }
		upgrades_from = ca_housing_1
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 89
		extra_tech_building_start = 1.4

		land_morale = 0.05
		levy_size = 0.025
		levy_reinforce_rate = 0.05
		light_infantry = 16
		archers = 12

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_housing_3 = {
		upgrades_from = ca_housing_2
		gold_cost = 250
		build_time = 1095
		ai_creation_factor = 88
		extra_tech_building_start = 0.9

		land_morale = 0.05
		levy_size = 0.025
		levy_reinforce_rate = 0.05
		light_infantry = 16
		archers = 12

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_housing_4 = {
		upgrades_from = ca_housing_3
		gold_cost = 400
		build_time = 1095
		ai_creation_factor = 88
		extra_tech_building_start = 0.9

		land_morale = 0.05
		levy_size = 0.025
		levy_reinforce_rate = 0.05
		light_infantry = 16
		archers = 12

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_housing_5 = {
		upgrades_from = ca_housing_4
		gold_cost = 500
		build_time = 1095
		ai_creation_factor = 88
		extra_tech_building_start = 0.9

		land_morale = 0.15
		levy_size = 0.025
		levy_reinforce_rate = 0.25
		light_infantry = 16
		archers = 12

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 7
			ai_can_build_trigger = yes
		}
	}

	# Stable
	ca_stable_1 = {
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 89
		extra_tech_building_start = 0.6

		light_cavalry = 46

		potential = {
			OR = {
				FROMFROM = { has_building = ca_stable_1 }

				AND = {
					TECH_CAVALRY >= 1

					FROMFROM = {
						OR = {
							has_building = ca_keep_1

							AND = {
								has_building = ca_town_market_1
								has_building = ca_housing_1
							}
						}
					}
				}
			}
		}

		trigger = {
			TECH_CAVALRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_stable_2 = {
		upgrades_from = ca_stable_1
		gold_cost = 120
		build_time = 547
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		light_cavalry = 56

		trigger = {
			TECH_CAVALRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_stable_3 = {
		upgrades_from = ca_stable_2
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 87
		extra_tech_building_start = 0.8

		light_cavalry = 66

		trigger = {
			TECH_CAVALRY >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_stable_4 = {
		upgrades_from = ca_stable_3
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 86
		extra_tech_building_start = 1.0

		light_cavalry = 66
		knights = 15

		trigger = {
			TECH_CAVALRY >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_stable_5 = {
		upgrades_from = ca_stable_4
		gold_cost = 400
		build_time = 2190
		ai_creation_factor = 85
		extra_tech_building_start = 1.2

		light_cavalry = 66
		knights = 20

		trigger = {
			TECH_CAVALRY >= 7
			ai_can_build_trigger = yes
		}
	}

	# Desert Stable
	ca_desert_stable_1 = {
		replaces = ca_stable_1
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 89
		extra_tech_building_start = 0.6

		camel_cavalry = 46

		potential = {
			terrain = desert

			OR = {
				FROMFROM = { has_building = ca_desert_stable_1 }

				AND = {
					TECH_CAVALRY >= 1

					FROMFROM = {
						OR = {
							has_building = ca_keep_1

							AND = {
								has_building = ca_town_market_1
								has_building = ca_housing_1
							}
						}
					}
				}
			}
		}

		trigger = {
			TECH_CAVALRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_desert_stable_2 = {
		replaces = ca_stable_2
		upgrades_from = ca_desert_stable_1
		gold_cost = 120
		build_time = 547
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		camel_cavalry = 56

		potential = {
			terrain = desert
		}

		trigger = {
			TECH_CAVALRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_desert_stable_3 = {
		replaces = ca_stable_3
		upgrades_from = ca_desert_stable_2
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 87
		extra_tech_building_start = 0.8

		camel_cavalry = 66

		potential = {
			terrain = desert
		}

		trigger = {
			TECH_CAVALRY >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_desert_stable_4 = {
		replaces = ca_stable_4
		upgrades_from = ca_desert_stable_3
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 86
		extra_tech_building_start = 1.0

		camel_cavalry = 66
		knights = 15

		potential = {
			terrain = desert
		}

		trigger = {
			TECH_CAVALRY >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_desert_stable_5 = {
		replaces = ca_stable_5
		upgrades_from = ca_desert_stable_4
		gold_cost = 400
		build_time = 2190
		ai_creation_factor = 85
		extra_tech_building_start = 1.2

		camel_cavalry = 66
		knights = 20

		potential = {
			terrain = desert
		}

		trigger = {
			TECH_CAVALRY >= 7
			ai_can_build_trigger = yes
		}
	}

	# Steppe Stable
	ca_steppe_stable_1 = {
		replaces = ca_stable_1
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 89
		extra_tech_building_start = 0.6

		light_cavalry = 32
		horse_archers = 14

		potential = {
			terrain = steppe

			OR = {
				FROMFROM = { has_building = ca_steppe_stable_1 }

				AND = {
					TECH_CAVALRY >= 1

					FROMFROM = {
						OR = {
							has_building = ca_keep_1

							AND = {
								has_building = ca_town_market_1
								has_building = ca_housing_1
							}
						}
					}
				}
			}
		}

		trigger = {
			TECH_CAVALRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_steppe_stable_2 = {
		replaces = ca_stable_2
		upgrades_from = ca_steppe_stable_1
		gold_cost = 120
		build_time = 547
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		light_cavalry = 42
		horse_archers = 24

		potential = {
			terrain = steppe
		}

		trigger = {
			TECH_CAVALRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_steppe_stable_3 = {
		replaces = ca_stable_3
		upgrades_from = ca_steppe_stable_2
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 87
		extra_tech_building_start = 0.8

		light_cavalry = 42
		horse_archers = 24

		potential = {
			terrain = steppe
		}

		trigger = {
			TECH_CAVALRY >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_steppe_stable_4 = {
		replaces = ca_stable_4
		upgrades_from = ca_steppe_stable_3
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 86
		extra_tech_building_start = 1.0

		light_cavalry = 42
		horse_archers = 24
		knights = 15

		potential = {
			terrain = steppe
		}

		trigger = {
			TECH_CAVALRY >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_steppe_stable_5 = {
		replaces = ca_stable_5
		upgrades_from = ca_steppe_stable_4
		gold_cost = 400
		build_time = 2190
		ai_creation_factor = 85
		extra_tech_building_start = 1.2

		light_cavalry = 42
		horse_archers = 24
		knights = 20

		potential = {
			terrain = steppe
		}

		trigger = {
			TECH_CAVALRY >= 7
			ai_can_build_trigger = yes
		}
	}

	# City Wall
	ca_wall_1 = {
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 90
		extra_tech_building_start = 1.2

		fort_level = 1

		potential = {
			OR = {
				FROMFROM = { has_building = ca_wall_1 }

				AND = {
					TECH_FORTIFICATIONS_CONSTRUCTION >= 1

					FROMFROM = {
						has_building = ca_town_market_1
						has_building = ca_housing_1
					}
				}
			}
		}

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_wall_2 = {
		upgrades_from = ca_wall_1
		gold_cost = 100
		build_time = 547 #1.5y
		ai_creation_factor = 89
		extra_tech_building_start = 0.6

		fort_level = 0.75

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 2
			ai_can_build_trigger = yes
		}
	}

	ca_wall_3 = {
		upgrades_from = ca_wall_2
		gold_cost = 200
		build_time = 730 #2y
		ai_creation_factor = 88
		extra_tech_building_start = 0.8

		fort_level = 1.5

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 4
			ai_can_build_trigger = yes
		}
	}

	ca_wall_4 = {
		upgrades_from = ca_wall_3
		gold_cost = 200
		build_time = 1095 #3y
		ai_creation_factor = 87
		extra_tech_building_start = 1.0

		fort_level = 1.5

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 6
			ai_can_build_trigger = yes
		}
	}

	ca_wall_5 = {
		upgrades_from = ca_wall_4
		gold_cost = 300
		build_time = 1460 #4y
		ai_creation_factor = 86
		extra_tech_building_start = 1.2

		fort_level = 2.0

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 8
			ai_can_build_trigger = yes
		}
	}

	# Militia
	ca_militia_1 = {
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 100
		extra_tech_building_start = 1.2

		light_infantry = 50
		archers = 100

		potential = {
			FROMFROM = {
				OR = {
					has_building = ca_militia_1

					AND = {
						has_building = ca_town_market_1
						has_building = ca_housing_1
					}
				}
			}
		}

		trigger = {
			TECH_LIGHT_INFANTRY >= 0
			ai_can_build_trigger = yes
		}
	}

	ca_militia_2 = {
		upgrades_from = ca_militia_1
		gold_cost = 120
		build_time = 547
		ai_creation_factor = 98
		extra_tech_building_start = 1.2

		light_infantry = 50
		archers = 100

		trigger = {
			TECH_LIGHT_INFANTRY >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_militia_3 = {
		upgrades_from = ca_militia_2
		gold_cost = 200
		build_time = 1095
		ai_creation_factor = 98
		extra_tech_building_start = 1.2

		light_infantry = 50
		archers = 100

		trigger = {
			TECH_LIGHT_INFANTRY >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_militia_4 = {
		upgrades_from = ca_militia_2
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 98
		extra_tech_building_start = 1.2

		light_infantry = 50
		archers = 100

		trigger = {
			TECH_LIGHT_INFANTRY >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_militia_5 = {
		upgrades_from = ca_militia_2
		gold_cost = 400
		build_time = 1095
		ai_creation_factor = 98
		extra_tech_building_start = 1.2

		light_infantry = 50
		archers = 100

		trigger = {
			TECH_LIGHT_INFANTRY >= 7
			ai_can_build_trigger = yes
		}
	}

	# Navy
	ca_shipyard_1 = {
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 85
		extra_tech_building_start = 0.5

		galleys = 10

		port = yes

		potential = {
			OR = {
				FROMFROM = { has_building = ca_shipyard_1 }

				AND = {
					TECH_NAVAL >= 1

					FROMFROM = {
						has_building = ca_town_market_1
						has_building = ca_housing_1
					}
				}
			}
		}

		trigger = {
			TECH_NAVAL >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_shipyard_2 = {
		upgrades_from = ca_shipyard_1
		gold_cost = 100
		build_time = 730
		ai_creation_factor = 85
		extra_tech_building_start = 0.7

		galleys = 5

		port = yes

		trigger = {
			TECH_NAVAL >= 2
			ai_can_build_trigger = yes
		}
	}

	ca_shipyard_3 = {
		upgrades_from = ca_shipyard_2
		gold_cost = 100
		build_time = 1095
		ai_creation_factor = 85
		extra_tech_building_start = 0.9

		galleys = 7

		port = yes

		trigger = {
			TECH_NAVAL >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_shipyard_4 = {
		upgrades_from = ca_shipyard_3
		gold_cost = 100
		build_time = 1460
		ai_creation_factor = 85
		extra_tech_building_start = 1.1

		galleys = 8

		port = yes

		trigger = {
			TECH_NAVAL >= 4
			ai_can_build_trigger = yes
		}
	}

	ca_shipyard_5 = {
		upgrades_from = ca_shipyard_4
		gold_cost = 100
		build_time = 1460
		ai_creation_factor = 85
		extra_tech_building_start = 1

		galleys = 10

		port = yes

		trigger = {
			TECH_NAVAL >= 5
			ai_can_build_trigger = yes
		}
	}

	# Trade
	ca_port_1 = {
		gold_cost = 100
		build_time = 365
		ai_creation_factor = 130
		extra_tech_building_start = 0

		tax_income = 0.5

		port = yes

		potential = {
			OR = {
				FROMFROM = { has_building = ca_port_1 }

				AND = {
					TECH_NAVAL >= 1
					TECH_TRADE_PRACTICES >= 1

					FROMFROM = {
						has_building = ca_town_market_1
						has_building = ca_housing_1
					}
				}
			}
		}

		trigger = {
			TECH_NAVAL >= 1
			TECH_TRADE_PRACTICES >= 1
			ai_can_build_trigger = yes
		}
	}

	ca_port_2 = {
		upgrades_from = ca_port_1
		gold_cost = 150
		build_time = 547
		ai_creation_factor = 130
		extra_tech_building_start = 0.6

		tax_income = 0.5

		port = yes

		trigger = {
			TECH_TRADE_PRACTICES >= 3
			ai_can_build_trigger = yes
		}
	}

	ca_port_3 = {
		upgrades_from = ca_port_2
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 130
		extra_tech_building_start = 0.8

		tax_income = 0.5

		port = yes

		trigger = {
			TECH_TRADE_PRACTICES >= 5
			ai_can_build_trigger = yes
		}
	}

	ca_port_4 = {
		upgrades_from = ca_port_3
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 130
		extra_tech_building_start = 1.0

		tax_income = 0.5

		port = yes

		trigger = {
			TECH_TRADE_PRACTICES >= 6
			ai_can_build_trigger = yes
		}
	}

	ca_port_5 = {
		upgrades_from = ca_port_4
		gold_cost = 400
		build_time = 2190
		ai_creation_factor = 130
		extra_tech_building_start = 1.2

		tax_income = 1

		port = yes

		trigger = {
			TECH_TRADE_PRACTICES >= 7
			ai_can_build_trigger = yes
		}
	}

	###SPECIAL###
	# Government Monastery
	ca_government_monastery_1 = {
		gold_cost = 150
		build_time = 547
		levy_size = 0.05
		ai_creation_factor = 96
		extra_tech_building_start = 0.2

		garrison_size = 0.05
		tech_growth_modifier = 0.025
		liege_piety = 0.05
		culture_techpoints = 0.01

		add_number_to_name = no

		potential = {
			OR = {
				FROM = { government = theocratic_feudal_government }
				FROMFROM = { has_building = ca_government_monastery_1 }
			}
		}

		trigger = {
			TECH_TEMPLE_CONSTRUCTION >= 0
		}
	}

	ca_government_monastery_2 = {
		desc = ca_government_monastery_1_desc
		prerequisites = { ca_wall_1 }
		upgrades_from = ca_government_monastery_1
		gold_cost = 200
		build_time = 730
		ai_creation_factor = 95
		extra_tech_building_start = 0.2

		levy_size = 0.05
		garrison_size = 0.05
		tech_growth_modifier = 0.05
		liege_piety = 0.05
		culture_techpoints = 0.02

		add_number_to_name = no

		potential = {
			OR = {
				FROM = { government = theocratic_feudal_government }
				FROMFROM = { has_building = ca_government_monastery_2 }
			}
		}

		trigger = {
			TECH_TEMPLE_CONSTRUCTION >= 0
		}
	}

	ca_government_monastery_3 = {
		desc = ca_government_monastery_1_desc
		upgrades_from = ca_government_monastery_2
		gold_cost = 300
		build_time = 1095
		ai_creation_factor = 94
		extra_tech_building_start = 0.2

		levy_size = 0.05
		garrison_size = 0.05
		tech_growth_modifier = 0.075
		liege_piety = 0.05
		culture_techpoints = 0.03

		add_number_to_name = no

		potential = {
			OR = {
				FROM = { government = theocratic_feudal_government }
				FROMFROM = { has_building = ca_government_monastery_3 }
			}
		}

		trigger = {
			TECH_TEMPLE_CONSTRUCTION >= 2
		}
	}

	ca_government_monastery_4 = {
		desc = ca_government_monastery_1_desc
		upgrades_from = ca_government_monastery_3
		gold_cost = 400
		build_time = 1460
		ai_creation_factor = 93
		extra_tech_building_start = 0.2

		levy_size = 0.05
		garrison_size = 0.05
		tech_growth_modifier = 0.1
		liege_piety = 0.05
		culture_techpoints = 0.04

		add_number_to_name = no

		potential = {
			OR = {
				FROM = { government = theocratic_feudal_government }
				FROMFROM = { has_building = ca_government_monastery_4 }
			}
		}

		trigger = {
			TECH_TEMPLE_CONSTRUCTION >= 4
		}
	}

	# Castellan Bloodline buildings
	ca_special_fortifications_1 = { # Insulated Sections
		desc = ca_special_fortifications_1_desc
		gold_cost = 125
		build_time = 365
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 0.5
		land_morale = 0.05

		add_number_to_name = no

		potential = {
			# Show the building only if it has been already built or if the owner has the proper bloodline to build it.
			OR = {
				FROMFROM = { has_building = ca_special_fortifications_1 }

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_castellan
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 1

			custom_tooltip = {
				text = tooltip_has_castellan_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_castellan
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	ca_special_fortifications_2 = { # Killing Fields
		desc = ca_special_fortifications_2_desc
		upgrades_from = ca_special_fortifications_1
		gold_cost = 250
		build_time = 560
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 1
		land_morale = 0.05
		garrison_size = 0.05

		add_number_to_name = no

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 3

			custom_tooltip = {
				text = tooltip_has_castellan_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_castellan
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	ca_special_fortifications_3 = { # Extended Machicolations
		desc = ca_special_fortifications_3_desc
		upgrades_from = ca_special_fortifications_2
		gold_cost = 450
		build_time = 760
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 1.5
		garrison_size = 0.15
		archers = 50

		add_number_to_name = no

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 5

			custom_tooltip = {
				text = tooltip_has_castellan_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_castellan
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	ca_special_fortifications_4 = { # Reinforced Barbican
		desc = ca_special_fortifications_4_desc
		upgrades_from = ca_special_fortifications_3
		gold_cost = 750
		build_time = 1250
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 2
		levy_size = 0.2
		garrison_size = 0.3
		light_infantry = 100

		add_number_to_name = no

		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION >= 7

			custom_tooltip = {
				text = tooltip_has_castellan_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_castellan
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	# Murder Builder Bloodline buildings.
	ca_oppressive_fortifications_1 = { # Gloomy Monument
		desc = ca_oppressive_fortifications_1_desc
		gold_cost = 125
		build_time = 365
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		local_revolt_risk = -0.05
		liege_prestige = 0.05

		add_number_to_name = no

		potential = {
			# Show the building only if it has been already built or if the owner has the proper bloodline to build it.
			OR = {
				FROMFROM = { has_building = ca_oppressive_fortifications_1 }

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_blood_building
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 2

			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_blood_building
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	ca_oppressive_fortifications_2 = { # Connected Watchtowers
		desc = ca_oppressive_fortifications_2_desc
		upgrades_from = ca_oppressive_fortifications_1
		gold_cost = 250
		build_time = 560
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 1
		local_revolt_risk = -0.05
		garrison_size = 0.05

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 4

			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_blood_building
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	ca_oppressive_fortifications_3 = { # Lonely Spire
		desc = ca_oppressive_fortifications_3_desc
		upgrades_from = ca_oppressive_fortifications_2
		gold_cost = 300
		build_time = 560
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 1
		local_revolt_risk = -0.05
		garrison_size = 0.05

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 6

			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_blood_building
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	ca_oppressive_fortifications_4 = { # Palace of Justice
		desc = ca_oppressive_fortifications_4_desc
		upgrades_from = ca_oppressive_fortifications_3
		gold_cost = 450
		build_time = 760
		ai_creation_factor = 88
		extra_tech_building_start = 1.2

		fort_level = 1
		local_revolt_risk = -0.05
		garrison_size = 0.05

		add_number_to_name = no

		trigger = {
			TECH_CASTLE_CONSTRUCTION >= 8

			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline

				FROM = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_blood_building
							bloodline_is_active_for = PREV
						}

						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
					}
				}
			}
		}

		is_active_trigger = {
			FROM = {
				show_only_failed_conditions = yes

				is_tribal = no
				is_nomadic = no
			}
		}
	}

	### SPECIAL
    # Theodosian Walls
    ca_con_wall_6 = {
        desc = ca_con_wall_6_desc
        gold_cost = 300
        build_time = 1460
        ai_creation_factor = 100

        fort_level = 6

        potential = {
            FROMFROM = { title = b_constantinople }
        }
	}
}