# -*- ck2.buildings -*-

 # Triggers are in Province scope. The From Scope contains the settlement holder (character)
 # start trigger is in title scope.

 #<tag> = {
 #	desc = description used in the tooltip of the building
 #	trigger = used for tech requirement of the building, set to 0 if no requirement so it can be build automatically on new games
 #	gold_cost = cost to build the building
 #	build_time = time to build, in days
 #
 #	ai_creation_factor = weight that the AI uses to determine what building to build
 #	extra_tech_building_start = when starting a new game this building will be pre-built if the province has higher tech than the requirement + this + random 0-1
 #}

 # Castle
castle = {
	# Wall quality, gives fortlevel
	ca_wall_q_1 = {
		desc = ca_wall_q_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 0
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_1 }
		gold_cost = 50
		build_time = 182
		fort_level = 0.5
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 60
		
		convert_to_tribal = tb_defensive_fortifications_1

		extra_tech_building_start = 1.0
	}
	ca_wall_q_2 = {
		desc = ca_wall_q_2_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 1
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_q_1
		prerequisites = { ca_wall_2 }
		gold_cost = 50
		build_time = 182
		fort_level = 0.5
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 59

		extra_tech_building_start = 1.4
	}
	ca_wall_q_3 = {
		desc = ca_wall_q_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 3
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_q_2
		gold_cost = 50
		build_time = 182
		fort_level = 0.5
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 58
		
		convert_to_tribal = tb_defensive_fortifications_2

		extra_tech_building_start = 1.2
	}
	ca_wall_q_4 = {
		desc = ca_wall_q_4_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 5
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_q_3
		gold_cost = 100
		build_time = 365
		fort_level = 1.0
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 57

		extra_tech_building_start = 0.8
	}
	ca_wall_q_5 = {
		desc = ca_wall_q_5_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 7
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_q_4
		gold_cost = 100
		build_time = 365
		fort_level = 1.0
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 56
		
		convert_to_tribal = tb_defensive_fortifications_3

		extra_tech_building_start = 0.4
	}

	#Walls, gives fortlevel, levysize and income
	ca_wall_1 = {
		desc = ca_wall_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 0
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 50
		build_time = 365
		fort_level = 0.5
		levy_size = 0.005
		tax_income = 0.2
		retinuesize = 20
		ai_creation_factor = 110
		
		convert_to_tribal = tb_hillfort_1

		extra_tech_building_start = 1.0
	}
	ca_wall_2 = {
		desc = ca_wall_2_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_1
		gold_cost = 50
		build_time = 547 #1.5y
		fort_level = 0.5
		levy_size = 0.005
		tax_income = 0.2
		retinuesize = 20
		ai_creation_factor = 110

		extra_tech_building_start = 1.4
	}
	ca_wall_3 = {
		desc = ca_wall_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 4
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_2
		gold_cost = 100
		build_time = 730 #2y
		fort_level = 1.0
		levy_size = 0.01
		tax_income = 0.2
		retinuesize = 20
		ai_creation_factor = 110
		
		convert_to_tribal = tb_hillfort_2

		extra_tech_building_start = 1.2
	}
	ca_wall_4 = {
		desc = ca_wall_4_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 6
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_3
		gold_cost = 150
		build_time = 1095 #3y
		fort_level = 1.0
		levy_size = 0.01
		tax_income = 0.2
		retinuesize = 20
		ai_creation_factor = 110

		extra_tech_building_start = 0.8
	}
	ca_wall_5 = {
		desc = ca_wall_5_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			OR = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 8
				county = { title = c_byzantion }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_wall_4
		gold_cost = 150
		build_time = 1460 #4y
		fort_level = 1.5
		levy_size = 0.02
		tax_income = 0.2
		retinuesize = 20
		ai_creation_factor = 110
		
		convert_to_tribal = tb_hillfort_3

		extra_tech_building_start = 0.4
	}
	ca_con_wall_6 = { # Theodosian Walls
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			has_building = ca_con_wall_6
			FROMFROM = { title = b_constantinople }
		}
		trigger = {
			county = { title = c_byzantion }
			emf_is_building_construction_allowed = yes
		}
		desc = ca_con_wall_6_desc
		upgrades_from = ca_wall_5
		gold_cost = 150
		build_time = 1460 #4y
		fort_level = 6.0
		garrison_size = 1.0
		retinuesize = 20
		ai_creation_factor = 110

		extra_tech_building_start = 0.0
	}

	#Keeps, gives levy and garrison size
	ca_keep_1 = {
		desc = ca_keep_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = { 
				NOT = { emf_province_is_gompa_monastery_culture = yes }
				has_building = ca_keep_1
			}
		}
		is_active_trigger = {
			NOT = { emf_province_is_gompa_monastery_culture = yes }
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 0
			NOT = { emf_province_is_gompa_monastery_culture = yes }
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 150
		build_time = 547 #1.5y
		levy_size = 0.05
		garrison_size = 0.05
		tech_growth_modifier_military = 0.02
		retinuesize = 20
		tax_income = -0.1
		liege_prestige = 0.05
		ai_creation_factor = 96
		
		convert_to_tribal = tb_training_grounds_1

		extra_tech_building_start = 1.0
	}
	ca_keep_2 = {
		desc = ca_keep_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = { 
				NOT = { emf_province_is_gompa_monastery_culture = yes }
				has_building = ca_keep_1
				has_building = ca_keep_2
			}
		}
		is_active_trigger = {
			NOT = { emf_province_is_gompa_monastery_culture = yes }
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 1
			NOT = { emf_province_is_gompa_monastery_culture = yes }
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_1 }
		upgrades_from = ca_keep_1
		gold_cost = 200
		build_time = 730 #2y
		levy_size = 0.1
		garrison_size = 0.1
		tech_growth_modifier_military = 0.02
		retinuesize = 20
		tax_income = -0.1
		liege_prestige = 0.05
		ai_creation_factor = 95

		extra_tech_building_start = 2.2
	}
	ca_keep_3 = {
		desc = ca_keep_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = { 
				NOT = { emf_province_is_gompa_monastery_culture = yes }
				has_building = ca_keep_1
				has_building = ca_keep_2
				has_building = ca_keep_3
			}
		}
		is_active_trigger = {
			NOT = { emf_province_is_gompa_monastery_culture = yes }
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
			NOT = { emf_province_is_gompa_monastery_culture = yes }
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_2 }
		upgrades_from = ca_keep_2
		gold_cost = 300
		build_time = 1095 #3y
		levy_size = 0.15
		garrison_size = 0.15
		tech_growth_modifier_military = 0.02
		retinuesize = 20
		tax_income = -0.1
		liege_prestige = 0.05
		ai_creation_factor = 94
		
		convert_to_tribal = tb_training_grounds_2

		extra_tech_building_start = 1.6
	}
	ca_keep_4 = {
		desc = ca_keep_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = { 
				NOT = { emf_province_is_gompa_monastery_culture = yes }
				has_building = ca_keep_1
				has_building = ca_keep_2
				has_building = ca_keep_3
				has_building = ca_keep_4
			}
		}
		is_active_trigger = {
			NOT = { emf_province_is_gompa_monastery_culture = yes }
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 4
			NOT = { emf_province_is_gompa_monastery_culture = yes }
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_keep_3
		gold_cost = 400
		build_time = 1460 #4y
		levy_size = 0.2
		garrison_size = 0.2
		tech_growth_modifier_military = 0.02
		retinuesize = 20
		tax_income = -0.1
		liege_prestige = 0.05
		ai_creation_factor = 93

		extra_tech_building_start = 1.0
	}
	ca_keep_5 = {
		desc = ca_keep_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = { 
				NOT = { emf_province_is_gompa_monastery_culture = yes }
				has_building = ca_keep_1
				has_building = ca_keep_2
				has_building = ca_keep_3
				has_building = ca_keep_4
				has_building = ca_keep_5
			}
		}
		is_active_trigger = {
			NOT = { emf_province_is_gompa_monastery_culture = yes }
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 6
			NOT = { emf_province_is_gompa_monastery_culture = yes }
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_keep_4
		gold_cost = 500
		build_time = 2190 #6y
		levy_size = 0.25
		garrison_size = 0.2
		tech_growth_modifier_military = 0.02
		retinuesize = 20
		tax_income = -0.1
		liege_prestige = 0.05
		ai_creation_factor = 92
		
		convert_to_tribal = tb_training_grounds_3

		extra_tech_building_start = 1.0
	}
	ca_keep_6 = {
		desc = ca_keep_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = { 
				NOT = { emf_province_is_gompa_monastery_culture = yes }
				has_building = ca_keep_1
				has_building = ca_keep_2
				has_building = ca_keep_3
				has_building = ca_keep_4
				has_building = ca_keep_5
				has_building = ca_keep_6
			}
		}
		is_active_trigger = {
			NOT = { emf_province_is_gompa_monastery_culture = yes }
		}
		trigger = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 8
			NOT = { emf_province_is_gompa_monastery_culture = yes }
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_keep_5
		gold_cost = 500
		build_time = 2160 #6y
		levy_size = 0.3
		garrison_size = 0.2
		tech_growth_modifier_military = 0.02
		retinuesize = 20
		tax_income = -0.1
		liege_prestige = 0.05
		ai_creation_factor = 91

		extra_tech_building_start = 0.2
	}

	# Militia barracks, gives light infantry and archers.
	ca_militia_barracks_1 = {
		desc = ca_militia_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 0
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 100
		build_time = 365
		light_infantry = 80
		archers = 10
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 80
		
		convert_to_tribal = tb_practice_range_1

		extra_tech_building_start = 1.0
	}
	ca_militia_barracks_2 = {
		desc = ca_militia_barracks_2_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 2
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_1 }
		upgrades_from = ca_militia_barracks_1
		gold_cost = 120
		build_time = 547
		light_infantry = 50
		archers = 50
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 79

		extra_tech_building_start = 2.2
	}
	ca_militia_barracks_3 = {
		desc = ca_militia_barracks_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 5
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_militia_barracks_2
		gold_cost = 200
		build_time = 1095
		light_infantry = 20
		archers = 90
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 78
		
		convert_to_tribal = tb_practice_range_2

		extra_tech_building_start = 1.2
	}
	ca_militia_barracks_4 = {
		desc = ca_militia_barracks_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 7
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_militia_barracks_3
		gold_cost = 300
		build_time = 1095
		light_infantry = 30
		archers = 120
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 77

		extra_tech_building_start = 0.5
	}

	#Training grounds, gives morale and reinforce rate
	ca_training_grounds_1 = {
		desc = ca_training_grounds_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 0
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_2 }
		gold_cost = 200
		build_time = 730
		land_morale = 0.1
		levy_reinforce_rate = 0.1
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 90
		
		convert_to_tribal = tb_arsenal_1

		extra_tech_building_start = 1.2
	}
	ca_training_grounds_2 = {
		desc = ca_training_grounds_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 3
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_training_grounds_1
		gold_cost = 250
		build_time = 1095
		land_morale = 0.15
		levy_reinforce_rate = 0.15
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 89

		extra_tech_building_start = 1.0
	}
	ca_training_grounds_3 = {
		desc = ca_training_grounds_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 6
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_training_grounds_2
		gold_cost = 300
		build_time = 2190
		land_morale = 0.2
		levy_reinforce_rate = 0.2
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 88
		
		convert_to_tribal = tb_arsenal_2

		extra_tech_building_start = 1.0
	}

	# Barracks, gives heavy infantry and pikemen
	ca_barracks_1 = {
		desc = ca_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NAND = {
					terrain = steppe
					emf_province_is_steppe_culture = yes
				}
				has_building = ca_barracks_1
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 0
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 100
		build_time = 365
		heavy_infantry = 30
		pikemen = 15
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 86
		
		convert_to_tribal = tb_war_camp_1

		extra_tech_building_start = 1.0
	}
	ca_barracks_2 = {
		desc = ca_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NAND = {
					terrain = steppe
					emf_province_is_steppe_culture = yes
				}
				has_building = ca_barracks_1
				has_building = ca_barracks_2
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 1
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_1 }
		upgrades_from = ca_barracks_1
		gold_cost = 120
		build_time = 547
		heavy_infantry = 40
		pikemen = 15
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 85

		extra_tech_building_start = 2.2
	}
	ca_barracks_3 = {
		desc = ca_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NAND = {
					terrain = steppe
					emf_province_is_steppe_culture = yes
				}
				has_building = ca_barracks_1
				has_building = ca_barracks_2
				has_building = ca_barracks_3
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 2
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_2 }
		upgrades_from = ca_barracks_2
		gold_cost = 200
		build_time = 730
		heavy_infantry = 45
		pikemen = 20
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 84
		
		convert_to_tribal = tb_war_camp_2

		extra_tech_building_start = 3.0
	}
	ca_barracks_4 = {
		desc = ca_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NAND = {
					terrain = steppe
					emf_province_is_steppe_culture = yes
				}
				has_building = ca_barracks_1
				has_building = ca_barracks_2
				has_building = ca_barracks_3
				has_building = ca_barracks_4
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 4
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_barracks_3
		gold_cost = 300
		build_time = 1095
		heavy_infantry = 50
		pikemen = 25
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 83

		extra_tech_building_start = 3.0
	}
	ca_barracks_5 = {
		desc = ca_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NAND = {
					terrain = steppe
					emf_province_is_steppe_culture = yes
				}
				has_building = ca_barracks_1
				has_building = ca_barracks_2
				has_building = ca_barracks_3
				has_building = ca_barracks_4
				has_building = ca_barracks_5
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 6
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_barracks_4
		gold_cost = 400
		build_time = 2190
		heavy_infantry = 60
		pikemen = 25
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 82
		
		convert_to_tribal = tb_war_camp_3

		extra_tech_building_start = 2.0
	}
	ca_barracks_6 = {
		desc = ca_barracks_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NAND = {
					terrain = steppe
					emf_province_is_steppe_culture = yes
				}
				has_building = ca_barracks_1
				has_building = ca_barracks_2
				has_building = ca_barracks_3
				has_building = ca_barracks_4
				has_building = ca_barracks_5
				has_building = ca_barracks_6
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 8
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_barracks_5
		gold_cost = 500
		build_time = 2190
		heavy_infantry = 65
		pikemen = 30
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 81

		extra_tech_building_start = 0.2
	}

	#Stable, gives light cavalry and some heavy cavalry
	ca_stable_1 = {
		desc = ca_stable_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NOR = {
					AND = {
						terrain = steppe
						emf_province_is_steppe_culture = yes
					}
					AND = {
						terrain = desert
						emf_province_is_desert_culture = yes
					}
				}
				has_building = ca_stable_1
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 0
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 100
		build_time = 365
		light_cavalry = 45
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 86

		extra_tech_building_start = 0.8
	}
	ca_stable_2 = {
		desc = ca_stable_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NOR = {
					AND = {
						terrain = steppe
						emf_province_is_steppe_culture = yes
					}
					AND = {
						terrain = desert
						emf_province_is_desert_culture = yes
					}
				}
				has_building = ca_stable_1
				has_building = ca_stable_2
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 1
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_1 }
		upgrades_from = ca_stable_1
		gold_cost = 120
		build_time = 547
		light_cavalry = 55
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 85

		extra_tech_building_start = 2.2
	}
	ca_stable_3 = {
		desc = ca_stable_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NOR = {
					AND = {
						terrain = steppe
						emf_province_is_steppe_culture = yes
					}
					AND = {
						terrain = desert
						emf_province_is_desert_culture = yes
					}
				}
				has_building = ca_stable_1
				has_building = ca_stable_2
				has_building = ca_stable_3
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 3
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_2 }
		upgrades_from = ca_stable_2
		gold_cost = 200
		build_time = 730
		light_cavalry = 55
		knights = 5
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 84

		extra_tech_building_start = 1.6
	}
	ca_stable_4 = {
		desc = ca_stable_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NOR = {
					AND = {
						terrain = steppe
						emf_province_is_steppe_culture = yes
					}
					AND = {
						terrain = desert
						emf_province_is_desert_culture = yes
					}
				}
				has_building = ca_stable_1
				has_building = ca_stable_2
				has_building = ca_stable_3
				has_building = ca_stable_4
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 5
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_stable_3
		gold_cost = 300
		build_time = 1095
		light_cavalry = 55
		knights = 10
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 83

		extra_tech_building_start = 1.2
	}
	ca_stable_5 = {
		desc = ca_stable_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NOR = {
					AND = {
						terrain = steppe
						emf_province_is_steppe_culture = yes
					}
					AND = {
						terrain = desert
						emf_province_is_desert_culture = yes
					}
				}
				has_building = ca_stable_1
				has_building = ca_stable_2
				has_building = ca_stable_3
				has_building = ca_stable_4
				has_building = ca_stable_5
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 7
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_stable_4
		gold_cost = 400
		build_time = 2190
		light_cavalry = 55
		knights = 20
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 82

		extra_tech_building_start = 0.8
	}
	ca_stable_6 = {
		desc = ca_stable_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				NOR = {
					AND = {
						terrain = steppe
						emf_province_is_steppe_culture = yes
					}
					AND = {
						terrain = desert
						emf_province_is_desert_culture = yes
					}
				}
				has_building = ca_stable_1
				has_building = ca_stable_2
				has_building = ca_stable_3
				has_building = ca_stable_4
				has_building = ca_stable_5
				has_building = ca_stable_6
			}
		}
		is_active_trigger = {
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 8
			trigger_if = {
				limit = { terrain = steppe }
				NOT = { emf_province_is_steppe_culture = yes }
			}
			trigger_else_if = {
				limit = { terrain = desert }
				NOT = { emf_province_is_desert_culture = yes }
			}
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_stable_5
		gold_cost = 500
		build_time = 2190
		light_cavalry = 55
		knights = 40
		retinuesize = 20
		tax_income = -0.05
		ai_creation_factor = 81

		extra_tech_building_start = 0.2
	}

	#Castle town, gives income
	ca_town_1 = {
		desc = ca_town_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 0
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 100
		build_time = 365
		tax_income = 2.5
		ai_creation_factor = 119
		
		convert_to_tribal = tb_market_town_1

		court_size_modifier = 1
		extra_tech_building_start = 0.5
	}
	ca_town_2 = {
		desc = ca_town_2_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 1
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_1 }
		upgrades_from = ca_town_1
		gold_cost = 120
		build_time = 547
		tax_income = 2.5
		ai_creation_factor = 119

		court_size_modifier = 1
		extra_tech_building_start = 1.0
	}
	ca_town_3 = {
		desc = ca_town_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 3
			emf_is_building_construction_allowed = yes
		}
		prerequisites = { ca_wall_2 }
		upgrades_from = ca_town_2
		gold_cost = 200
		build_time = 730
		tax_income = 2.5
		ai_creation_factor = 119
		
		convert_to_tribal = tb_market_town_2
		
		court_size_modifier = 1
		extra_tech_building_start = 1.2
	}
	ca_town_4 = {
		desc = ca_town_4_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 5
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_town_3
		gold_cost = 300
		build_time = 1095
		tax_income = 2.5
		ai_creation_factor = 119

		court_size_modifier = 1
		extra_tech_building_start = 1.2
	}
	ca_town_5 = {
		desc = ca_town_4_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = {
			TECH_CASTLE_CONSTRUCTION = 7
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_town_4
		gold_cost = 400
		build_time = 2190
		tax_income = 2.5
		ai_creation_factor = 119
		
		convert_to_tribal = tb_market_town_3

		court_size_modifier = 1
		extra_tech_building_start = 1.0
	}

	ca_shipyard_1 = {
		desc = shipyard_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		port = yes
		trigger = {
			TECH_NAVAL = 1
			emf_is_building_construction_allowed = yes
		}
		gold_cost = 100
		build_time = 365
		galleys = 7
		tax_income = -0.05
		ai_creation_factor = 70
		
		convert_to_tribal = tb_shipyard_1

		extra_tech_building_start = 0.3
	}

	ca_shipyard_2 = {
		desc = shipyard_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		port = yes
		trigger = {
			TECH_NAVAL = 2
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_shipyard_1
		gold_cost = 100
		build_time = 730
		galleys = 8
		tax_income = -0.05
		ai_creation_factor = 69

		extra_tech_building_start = 0.3
	}

	ca_shipyard_3 = {
		desc = shipyard_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		port = yes
		trigger = {
			TECH_NAVAL = 3
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_shipyard_2
		gold_cost = 100
		build_time = 1095
		galleys = 9
		tax_income = -0.05
		ai_creation_factor = 68
		
		convert_to_tribal = tb_shipyard_2
		
		extra_tech_building_start = 0.3
	}
	
	ca_shipyard_4 = {
		desc = shipyard_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		port = yes
		trigger = {
			TECH_NAVAL = 4
			emf_is_building_construction_allowed = yes
		}
		upgrades_from = ca_shipyard_3
		gold_cost = 100
		build_time = 1460
		galleys = 10
		tax_income = -0.05
		ai_creation_factor = 67
		
		extra_tech_building_start = 0.3
	}
	
	#Castellan Bloodline buildings.
	ca_special_fortifications_1 = { #Insulated Sections
		desc = ca_special_fortifications_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				FROMFROM = { has_building = ca_special_fortifications_1 } #Show the building only if it has been already built or if the owner has the proper bloodline to build it.
				FROM = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_castellan
						bloodline_is_active_for = PREV
					}
				}
				FROM = {
					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
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_castellan
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}

		gold_cost = 125
		build_time = 365
		fort_level = 0.5
		land_morale = 0.05
		
		add_number_to_name = no

		ai_creation_factor = 71

		extra_tech_building_start = 1.2
	}
	ca_special_fortifications_2 = { #Killing Fields
		desc = ca_special_fortifications_2_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = { 
			TECH_FORTIFICATIONS_CONSTRUCTION = 3
			custom_tooltip = {
				text = tooltip_has_castellan_bloodline
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_castellan
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		upgrades_from = ca_special_fortifications_1
		gold_cost = 250
		build_time = 560
		fort_level = 1
		land_morale = 0.05
		garrison_size = 0.05

		add_number_to_name = no
		
		ai_creation_factor = 72

		extra_tech_building_start = 1.2
	}
	ca_special_fortifications_3 = { #Extended Machicolations
		desc = ca_special_fortifications_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = { 
			TECH_FORTIFICATIONS_CONSTRUCTION = 5
			custom_tooltip = {
				text = tooltip_has_castellan_bloodline
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_castellan
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		upgrades_from = ca_special_fortifications_2
		gold_cost = 450
		build_time = 760
		fort_level = 1.5
		garrison_size = 0.15
		archers = 50

		add_number_to_name = no
		
		ai_creation_factor = 77

		extra_tech_building_start = 1.2
	}
	ca_special_fortifications_4 = { #Reinforced Barbican
		desc = ca_special_fortifications_4_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = { 
			TECH_FORTIFICATIONS_CONSTRUCTION = 7
			custom_tooltip = {
				text = tooltip_has_castellan_bloodline
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_castellan
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_castellan
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		upgrades_from = ca_special_fortifications_3
		gold_cost = 750
		build_time = 1250
		fort_level = 2
		levy_size = 0.2
		garrison_size = 0.3
		light_infantry = 100

		add_number_to_name = no
		
		ai_creation_factor = 78

		extra_tech_building_start = 1.2
	}

	#Murder Builder Bloodline buildings.
	ca_oppressive_fortifications_1 = { #Gloomy Monument
		desc = ca_oppressive_fortifications_1_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
			OR = {
				FROMFROM = { has_building = ca_oppressive_fortifications_1 } #Show the building only if it has been already built or if the owner has the proper bloodline to build it.
				FROM = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_blood_building
						bloodline_is_active_for = PREV
					}
				}
				FROM = {
					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
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_blood_building
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}

		gold_cost = 125
		build_time = 365
		local_revolt_risk = -0.05
		liege_prestige = 0.05
		
		add_number_to_name = no

		ai_creation_factor = 76

		extra_tech_building_start = 1.2
	}
	ca_oppressive_fortifications_2 = { #Connected Watchtowers
		desc = ca_oppressive_fortifications_2_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = { 
			TECH_CASTLE_CONSTRUCTION = 4
			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_blood_building
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		upgrades_from = ca_oppressive_fortifications_1
		gold_cost = 250
		build_time = 560
		fort_level = 1
		local_revolt_risk = -0.05
		garrison_size = 0.05

		add_number_to_name = no
		
		ai_creation_factor = 75

		extra_tech_building_start = 1.2
	}
	ca_oppressive_fortifications_3 = { #Lonely Spire
		desc = ca_oppressive_fortifications_3_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = { 
			TECH_CASTLE_CONSTRUCTION = 6
			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_blood_building
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		upgrades_from = ca_oppressive_fortifications_2
		gold_cost = 300
		build_time = 560
		fort_level = 1
		local_revolt_risk = -0.05
		garrison_size = 0.05

		add_number_to_name = no
		
		ai_creation_factor = 74

		extra_tech_building_start = 1.2
	}
	ca_oppressive_fortifications_4 = { #Palace of Justice
		desc = ca_oppressive_fortifications_4_desc
		potential = {
			has_game_rule = {
				name = dacse_buildings
				value = HIP
			}
		}
		trigger = { 
			TECH_CASTLE_CONSTRUCTION = 8
			custom_tooltip = {
				text = tooltip_has_murder_builder_bloodline
				hidden_tooltip = {
					OR = {
						FROM = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_blood_building
								bloodline_is_active_for = PREV
							}
						}
						FROM = {
							any_liege = {
								any_owned_bloodline = {
									has_bloodline_flag = bloodline_blood_building
									bloodline_is_active_for = PREV
								}
							}
						}
					}
				}
			}
			emf_is_building_construction_allowed = yes
		}
		is_active_trigger = {
			FROM = {
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		upgrades_from = ca_oppressive_fortifications_3
		gold_cost = 450
		build_time = 760
		fort_level = 1
		local_revolt_risk = -0.05
		garrison_size = 0.05

		add_number_to_name = no
		
		ai_creation_factor = 73

		extra_tech_building_start = 1.2
	}
}

