decisions = {

	build_stuff = {
		is_high_prio = yes # Will show an alert once decision is enabled
		ai = no
		
		potential = {
		}
		allow = {
			ai = no
		}
		effect = {
			any_realm_province = {
				any_province_holding = {
#####################CASTLES#####################
					if = { #Keeps
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_keep_5
								NOT = { has_building = ca_keep_6 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 8 }
							}
							add_building = ca_keep_6
						}
						else_if = {
							limit = {
								has_building = ca_keep_4
								NOT = { has_building = ca_keep_5 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 6 }
							}
							add_building = ca_keep_5
						}
						else_if = {
							limit = {
								has_building = ca_keep_3
								NOT = { has_building = ca_keep_4 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 4 }
							}
							add_building = ca_keep_4
						}
						else_if = {
							limit = {
								has_building = ca_keep_2
								has_building = ca_wall_2
								NOT = { has_building = ca_keep_3 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 2 }
							}
							add_building = ca_keep_3
						}
						else_if = {
							limit = {
								has_building = ca_keep_1
								has_building = ca_wall_1
								NOT = { has_building = ca_keep_2 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
							}
							add_building = ca_keep_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_keep_1 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
							}
							add_building = ca_keep_1
						}
					}
					if = { #Walls
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_wall_4
								NOT = { has_building = ca_wall_5 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 8 }
							}
							add_building = ca_wall_5
						}
						else_if = {
							limit = {
								has_building = ca_wall_3
								NOT = { has_building = ca_wall_4 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 6 }
							}
							add_building = ca_wall_4
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_wall_3 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 4 }
							}
							add_building = ca_wall_3
						}
						else_if = {
							limit = {
								has_building = ca_wall_1
								NOT = { has_building = ca_wall_2 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 2 }
							}
							add_building = ca_wall_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_wall_1 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
							}
							add_building = ca_wall_1
						}
					}
					if = { #Fortifications
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_wall_q_4
								NOT = { has_building = ca_wall_q_5 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 7 }
							}
							add_building = ca_wall_q_5
						}
						else_if = {
							limit = {
								has_building = ca_wall_q_3
								NOT = { has_building = ca_wall_q_4 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
							}
							add_building = ca_wall_q_4
						}
						else_if = {
							limit = {
								has_building = ca_wall_q_2
								NOT = { has_building = ca_wall_q_3 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
							}
							add_building = ca_wall_q_3
						}
						else_if = {
							limit = {
								has_building = ca_wall_q_1
								NOT = { has_building = ca_wall_q_2 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
							}
							add_building = ca_wall_q_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_wall_q_1 }
								location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
							}
							add_building = ca_wall_q_1
						}
					}
					if = { #Militia Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_militia_barracks_3
								NOT = { has_building = ca_militia_barracks_4 }
								location = { TECH_CASTLE_CONSTRUCTION = 7 }
							}
							add_building = ca_militia_barracks_4
						}
						else_if = {
							limit = {
								has_building = ca_militia_barracks_2
								NOT = { has_building = ca_militia_barracks_3 }
								location = { TECH_CASTLE_CONSTRUCTION = 5 }
							}
							add_building = ca_militia_barracks_3
						}
						else_if = {
							limit = {
								has_building = ca_militia_barracks_1
								has_building = ca_wall_1
								NOT = { has_building = ca_militia_barracks_2 }
								location = { TECH_CASTLE_CONSTRUCTION = 1 }
							}
							add_building = ca_militia_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_militia_barracks_1 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_militia_barracks_1
						}
					}
					if = { #Training Grounds
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_training_grounds_2
								NOT = { has_building = ca_training_grounds_3 }
								location = { TECH_CASTLE_CONSTRUCTION = 6 }
							}
							add_building = ca_training_grounds_3
						}
						else_if = {
							limit = {
								has_building = ca_training_grounds_1
								NOT = { has_building = ca_training_grounds_2 }
								location = { TECH_CASTLE_CONSTRUCTION = 3 }
							}
							add_building = ca_training_grounds_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_training_grounds_1 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_training_grounds_1
						}
					}
					if = { #Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_barracks_5
								NOT = { has_building = ca_barracks_6 }
								location = { TECH_CASTLE_CONSTRUCTION = 7 }
							}
							add_building = ca_barracks_6
						}
						else_if = {
							limit = {
								has_building = ca_barracks_4
								NOT = { has_building = ca_barracks_5 }
								location = { TECH_CASTLE_CONSTRUCTION = 5 }
							}
							add_building = ca_barracks_5
						}
						else_if = {
							limit = {
								has_building = ca_barracks_3
								NOT = { has_building = ca_barracks_4 }
								location = { TECH_CASTLE_CONSTRUCTION = 3 }
							}
							add_building = ca_barracks_4
						}
						else_if = {
							limit = {
								has_building = ca_barracks_2
								has_building = ca_wall_2
								NOT = { has_building = ca_barracks_3 }
								location = { TECH_CASTLE_CONSTRUCTION = 1 }
							}
							add_building = ca_barracks_3
						}
						else_if = {
							limit = {
								has_building = ca_barracks_1
								has_building = ca_wall_1
								NOT = { has_building = ca_barracks_2 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_barracks_1 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_barracks_1
						}
					}
					if = { #Stables
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_stable_5
								NOT = { has_building = ca_stable_6 }
								location = { TECH_CASTLE_CONSTRUCTION = 8 }
							}
							add_building = ca_stable_6
						}
						else_if = {
							limit = {
								has_building = ca_stable_4
								NOT = { has_building = ca_stable_5 }
								location = { TECH_CASTLE_CONSTRUCTION = 6 }
							}
							add_building = ca_stable_5
						}
						else_if = {
							limit = {
								has_building = ca_stable_3
								NOT = { has_building = ca_stable_4 }
								location = { TECH_CASTLE_CONSTRUCTION = 4 }
							}
							add_building = ca_stable_4
						}
						else_if = {
							limit = {
								has_building = ca_stable_2
								has_building = ca_wall_2
								NOT = { has_building = ca_stable_3 }
								location = { TECH_CASTLE_CONSTRUCTION = 2 }
							}
							add_building = ca_stable_3
						}
						else_if = {
							limit = {
								has_building = ca_stable_1
								has_building = ca_wall_1
								NOT = { has_building = ca_stable_2 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_stable_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_stable_1 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_stable_1
						}
					}
					if = { #Castle Towns
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_town_5
								NOT = { has_building = ca_town_6 }
								location = { TECH_CASTLE_CONSTRUCTION = 8 }
							}
							add_building = ca_town_6
						}
						else_if = {
							limit = {
								has_building = ca_town_4
								NOT = { has_building = ca_town_5 }
								location = { TECH_CASTLE_CONSTRUCTION = 6 }
							}
							add_building = ca_town_5
						}
						else_if = {
							limit = {
								has_building = ca_town_3
								NOT = { has_building = ca_town_4 }
								location = { TECH_CASTLE_CONSTRUCTION = 4 }
							}
							add_building = ca_town_4
						}
						else_if = {
							limit = {
								has_building = ca_town_2
								has_building = ca_wall_2
								NOT = { has_building = ca_town_3 }
								location = { TECH_CASTLE_CONSTRUCTION = 2 }
							}
							add_building = ca_town_3
						}
						else_if = {
							limit = {
								has_building = ca_town_1
								has_building = ca_wall_1
								NOT = { has_building = ca_town_2 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_town_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_town_1 }
								location = { TECH_CASTLE_CONSTRUCTION = 0 }
							}
							add_building = ca_town_1
						}
					}
					if = { #Shipyards
						limit = { holding_type = castle}
						if = {
							limit = {
								has_building = ca_shipyard_3
								NOT = { has_building = ca_shipyard_4 }
								location = { 
									TECH_NAVAL = 4 
									port = yes
								}
							}
							add_building = ca_shipyard_4
						}
						else_if = {
							limit = {
								has_building = ca_shipyard_2
								NOT = { has_building = ca_shipyard_3 }
								location = {
									TECH_NAVAL = 3
									port = yes
								}
							}
							add_building = ca_shipyard_3
						}
						else_if = {
							limit = {
								has_building = ca_shipyard_1
								NOT = { has_building = ca_shipyard_2 }
								location = {
									TECH_NAVAL = 2
									port = yes
								}
							}
							add_building = ca_shipyard_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_shipyard_1 }
								location = { 
									TECH_NAVAL = 1
									port = yes
								}
							}
							add_building = ca_shipyard_1
						}
					}
					if = { #Castellan Bloodline buildings
						limit = { holding_type = castle}
						if = {
							limit = {
								has_building = ca_special_fortifications_3
								NOT = { has_building = ca_special_fortifications_4 }
								location = { 
									TECH_FORTIFICATIONS_CONSTRUCTION = 7
									custom_tooltip = {
										text = tooltip_has_castellan_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_castellan 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_castellan 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ca_special_fortifications_4
						}
						else_if = {
							limit = {
								has_building = ca_special_fortifications_2
								NOT = { has_building = ca_special_fortifications_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 5
									custom_tooltip = {
										text = tooltip_has_castellan_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_castellan 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_castellan 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ca_special_fortifications_3
						}
						else_if = {
							limit = {
								has_building = ca_special_fortifications_1
								NOT = { has_building = ca_special_fortifications_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 3
									custom_tooltip = {
										text = tooltip_has_castellan_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_castellan 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_castellan 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ca_special_fortifications_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_special_fortifications_1 }
								location = { 
									TECH_FORTIFICATIONS_CONSTRUCTION = 1
									custom_tooltip = {
										text = tooltip_has_castellan_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_castellan 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_castellan 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ca_special_fortifications_1
						}
					}#CULTURAL BUILDINGS#
					if = { #Welsh and English Longbow Archery Range
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_saxon_english_3
								NOT = { has_building = ca_culture_saxon_english_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = ca_culture_saxon_english_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_saxon_english_2
								NOT = { has_building = ca_culture_saxon_english_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = ca_culture_saxon_english_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_saxon_english_1
								NOT = { has_building = ca_culture_saxon_english_2 }
								location = { 
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = ca_culture_saxon_english_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_saxon_english_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = ca_culture_saxon_english_1
						}
					}
					if = { #Scottish Schiltrone
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_scottish_3
								NOT = { has_building = ca_culture_scottish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = scottish
								}
							}
							add_building = ca_culture_scottish_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_scottish_2
								NOT = { has_building = ca_culture_scottish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = scottish
								}
							}
							add_building = ca_culture_scottish_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_scottish_1
								NOT = { has_building = ca_culture_scottish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = scottish
								}
							}
							add_building = ca_culture_scottish_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_scottish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = scottish
								}
							}
							add_building = ca_culture_scottish_1
						}
					}
					if = { #Baltic Tribes Heavy Infantry Camps
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_baltic_3
								NOT = { has_building = ca_culture_group_baltic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = ca_culture_group_baltic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_baltic_2
								NOT = { has_building = ca_culture_group_baltic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = ca_culture_group_baltic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_baltic_1
								NOT = { has_building = ca_culture_group_baltic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = ca_culture_group_baltic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_baltic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = ca_culture_group_baltic_1
						}
					}
					if = { #Altaic Horse Breeders (and Persian)
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_altaic_3
								NOT = { has_building = ca_culture_group_altaic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = ca_culture_group_altaic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_altaic_2
								NOT = { has_building = ca_culture_group_altaic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = ca_culture_group_altaic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_altaic_1
								NOT = { has_building = ca_culture_group_altaic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = ca_culture_group_altaic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_altaic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = ca_culture_group_altaic_1
						}
					}
					if = { #Frankish, Occitan, Norman and German Lists (and Breton)
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_frank_norman_german_3
								NOT = { has_building = ca_culture_frank_norman_german_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = ca_culture_frank_norman_german_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_frank_norman_german_2
								NOT = { has_building = ca_culture_frank_norman_german_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = ca_culture_frank_norman_german_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_frank_norman_german_1
								NOT = { has_building = ca_culture_frank_norman_german_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = ca_culture_frank_norman_german_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_frank_norman_german_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = ca_culture_frank_norman_german_1
						}
					}
					if = { #Iberian Fast horse breeders
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_iberian_3
								NOT = { has_building = ca_culture_group_iberian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture_group = iberian
								}
							}
							add_building = ca_culture_group_iberian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_iberian_2
								NOT = { has_building = ca_culture_group_iberian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture_group = iberian
								}
							}
							add_building = ca_culture_group_iberian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_iberian_1
								NOT = { has_building = ca_culture_group_iberian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = iberian
								}
							}
							add_building = ca_culture_group_iberian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_iberian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = iberian
								}
							}
							add_building = ca_culture_group_iberian_1
						}
					}
					if = { #Italian Pike formations
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_italian_3
								NOT = { has_building = ca_culture_italian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = ca_culture_italian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_italian_2
								NOT = { has_building = ca_culture_italian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = ca_culture_italian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_italian_1
								NOT = { has_building = ca_culture_italian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = ca_culture_italian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_italian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = ca_culture_italian_1
						}
					}
					if = { #Russian Armories
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_russian_3
								NOT = { has_building = ca_culture_russian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture_group = east_slavic
								}
							}
							add_building = ca_culture_russian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_russian_2
								NOT = { has_building = ca_culture_russian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture_group = east_slavic
								}
							}
							add_building = ca_culture_russian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_russian_1
								NOT = { has_building = ca_culture_russian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = east_slavic
								}
							}
							add_building = ca_culture_russian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_russian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = east_slavic
								}
							}
							add_building = ca_culture_russian_1
						}
					}
					if = { #Scandinavian Housecarls (and Saxon)
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_north_germanic_3
								NOT = { has_building = ca_culture_group_north_germanic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = ca_culture_group_north_germanic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_north_germanic_2
								NOT = { has_building = ca_culture_group_north_germanic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = ca_culture_group_north_germanic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_north_germanic_1
								NOT = { has_building = ca_culture_group_north_germanic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = ca_culture_group_north_germanic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_north_germanic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = ca_culture_group_north_germanic_1
						}
					}
					if = { #Hungarian Hussars (and West Slavic)
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_hungarian_3
								NOT = { has_building = ca_culture_hungarian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = ca_culture_hungarian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_hungarian_2
								NOT = { has_building = ca_culture_hungarian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = ca_culture_hungarian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_hungarian_1
								NOT = { has_building = ca_culture_hungarian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = ca_culture_hungarian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_hungarian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = ca_culture_hungarian_1
						}
					}
					if = { #Arabian Camel Cavalry
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_arabic_3
								NOT = { has_building = ca_culture_group_arabic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = ca_culture_group_arabic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_arabic_2
								NOT = { has_building = ca_culture_group_arabic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = ca_culture_group_arabic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_arabic_1
								NOT = { has_building = ca_culture_group_arabic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = ca_culture_group_arabic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_arabic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = ca_culture_group_arabic_1
						}
					}
					if = { #Byzantine Cataphracts
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_byzantine_3
								NOT = { has_building = ca_culture_group_byzantine_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = ca_culture_group_byzantine_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_byzantine_2
								NOT = { has_building = ca_culture_group_byzantine_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = ca_culture_group_byzantine_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_byzantine_1
								NOT = { has_building = ca_culture_group_byzantine_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = ca_culture_group_byzantine_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_byzantine_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = ca_culture_group_byzantine_1
						}
					}
					if = { #Irish Gallowglass
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_irish_3
								NOT = { has_building = ca_culture_irish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = irish
								}
							}
							add_building = ca_culture_irish_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_irish_2
								NOT = { has_building = ca_culture_irish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = irish
								}
							}
							add_building = ca_culture_irish_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_irish_1
								NOT = { has_building = ca_culture_irish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = irish
								}
							}
							add_building = ca_culture_irish_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_irish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = irish
								}
							}
							add_building = ca_culture_irish_1
						}
					}
					if = { #Ethiopian Light Infantry Drilling Ground
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_ethiopian_3
								NOT = { has_building = ca_culture_ethiopian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = ethiopian
								}
							}
							add_building = ca_culture_ethiopian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_ethiopian_2
								NOT = { has_building = ca_culture_ethiopian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = ethiopian
								} 
							}
							add_building = ca_culture_ethiopian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_ethiopian_1
								NOT = { has_building = ca_culture_ethiopian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = ethiopian
								}
							}
							add_building = ca_culture_ethiopian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_ethiopian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = ethiopian
								}
							}
							add_building = ca_culture_ethiopian_1
						}
					}
					if = { #Somali Light Infantry Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_somali_3
								NOT = { has_building = ca_culture_somali_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = somali
								}
							}
							add_building = ca_culture_somali_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_somali_2
								NOT = { has_building = ca_culture_somali_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = somali
								}
							}
							add_building = ca_culture_somali_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_somali_1
								NOT = { has_building = ca_culture_somali_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = somali
								}
							}
							add_building = ca_culture_somali_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_somali_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = somali
								}
							}
							add_building = ca_culture_somali_1
						}
					}
					if = { #West African Free Warrior Lodge
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_west_african_3
								NOT = { has_building = ca_culture_west_african_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = ca_culture_west_african_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_west_african_2
								NOT = { has_building = ca_culture_west_african_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = ca_culture_west_african_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_west_african_1
								NOT = { has_building = ca_culture_west_african_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = ca_culture_west_african_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_west_african_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = ca_culture_west_african_1
						}
					}
					if = { #South Slavic Cavalry
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_group_south_slavic_3
								NOT = { has_building = ca_culture_group_south_slavic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture_group = south_slavic
								}
							}
							add_building = ca_culture_group_south_slavic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_south_slavic_2
								NOT = { has_building = ca_culture_group_south_slavic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture_group = south_slavic
								}
							}
							add_building = ca_culture_group_south_slavic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_group_south_slavic_1
								NOT = { has_building = ca_culture_group_south_slavic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = south_slavic
								}
							}
							add_building = ca_culture_group_south_slavic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_group_south_slavic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = south_slavic
								}
							}
							add_building = ca_culture_group_south_slavic_1
						}
					}
					if = { #Dutch Urban Militia
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_dutch_3
								NOT = { has_building = ca_culture_dutch_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = dutch
								}
							}
							add_building = ca_culture_dutch_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_dutch_2
								NOT = { has_building = ca_culture_dutch_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = dutch
								}
							}
							add_building = ca_culture_dutch_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_dutch_1
								NOT = { has_building = ca_culture_dutch_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = dutch
								}
							}
							add_building = ca_culture_dutch_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_dutch_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = dutch
								}
							}
							add_building = ca_culture_dutch_1
						}
					}
					if = { #Aztec Jaguar Warriors
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_nahuatl_3
								NOT = { has_building = ca_culture_nahuatl_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = nahuatl
								}
							}
							add_building = ca_culture_nahuatl_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_nahuatl_2
								NOT = { has_building = ca_culture_nahuatl_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = nahuatl
								}
							}
							add_building = ca_culture_nahuatl_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_nahuatl_1
								NOT = { has_building = ca_culture_nahuatl_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = nahuatl
								}
							}
							add_building = ca_culture_nahuatl_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_nahuatl_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = nahuatl
								}
							}
							add_building = ca_culture_nahuatl_1
						}
					}
					if = { #Jewish Heavy Infantry
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_jewish_3
								NOT = { has_building = ca_culture_jewish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture_group = israelite
								}
							}
							add_building = ca_culture_jewish_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_jewish_2
								NOT = { has_building = ca_culture_jewish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture_group = israelite
								}
							}
							add_building = ca_culture_jewish_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_jewish_1
								NOT = { has_building = ca_culture_jewish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = israelite
								}
							}
							add_building = ca_culture_jewish_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_jewish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = israelite
								}
							}
							add_building = ca_culture_jewish_1
						}
					}
					if = { #Indian war elephant pens
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_indian_3
								NOT = { has_building = ca_culture_indian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = ca_culture_indian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_indian_2
								NOT = { has_building = ca_culture_indian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = ca_culture_indian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_indian_1
								NOT = { has_building = ca_culture_indian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = ca_culture_indian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_indian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = ca_culture_indian_1
						}
					}
					if = { #Nubian Warrior Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_nubian_3
								NOT = { has_building = ca_culture_nubian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = nubian
								}
							}
							add_building = ca_culture_nubian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_nubian_2
								NOT = { has_building = ca_culture_nubian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = nubian
								}
							}
							add_building = ca_culture_nubian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_nubian_1
								NOT = { has_building = ca_culture_nubian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = nubian
								}
							}
							add_building = ca_culture_nubian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_nubian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = nubian
								}
							}
							add_building = ca_culture_nubian_1
						}
					}
					if = { #Germanic Heavy Infantry Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_germanic_3
								NOT = { has_building = ca_culture_germanic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = ca_culture_germanic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_germanic_2
								NOT = { has_building = ca_culture_germanic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = ca_culture_germanic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_germanic_1
								NOT = { has_building = ca_culture_germanic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = ca_culture_germanic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_germanic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = ca_culture_germanic_1
						}
					}
					if = { #Pictish Hall of War
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_pictish_3
								NOT = { has_building = ca_culture_pictish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = pictish
								}
							}
							add_building = ca_culture_pictish_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_pictish_2
								NOT = { has_building = ca_culture_pictish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = pictish
								}
							}
							add_building = ca_culture_pictish_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_pictish_1
								NOT = { has_building = ca_culture_pictish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = pictish
								}
							}
							add_building = ca_culture_pictish_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_pictish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = pictish
								}
							}
							add_building = ca_culture_pictish_1
						}
					}
					if = { #Suebi Free Warriors
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_suebi_3
								NOT = { has_building = ca_culture_suebi_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = suebi
								}
							}
							add_building = ca_culture_suebi_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_suebi_2
								NOT = { has_building = ca_culture_suebi_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = suebi
								}
							}
							add_building = ca_culture_suebi_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_suebi_1
								NOT = { has_building = ca_culture_suebi_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = suebi
								}
							}
							add_building = ca_culture_suebi_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_suebi_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = suebi
								}
							}
							add_building = ca_culture_suebi_1
						}
					}
					if = { #Moorish Cavalry Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_moors_3
								NOT = { has_building = ca_culture_moors_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = ca_culture_moors_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_moors_2
								NOT = { has_building = ca_culture_moors_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = ca_culture_moors_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_moors_1
								NOT = { has_building = ca_culture_moors_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = ca_culture_moors_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_moors_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = ca_culture_moors_1
						}
					}
					if = { #Han Crossbow Range
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_chinese_han_3
								NOT = { has_building = ca_culture_chinese_han_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = han
								}
							}
							add_building = ca_culture_chinese_han_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_chinese_han_2
								NOT = { has_building = ca_culture_chinese_han_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = han
								}
							}
							add_building = ca_culture_chinese_han_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_chinese_han_1
								NOT = { has_building = ca_culture_chinese_han_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = han
								}
							}
							add_building = ca_culture_chinese_han_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_chinese_han_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = han
								}
							}
							add_building = ca_culture_chinese_han_1
						}
					}
					if = { #Jurchen Cavalry Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_altaic_jurchen_3
								NOT = { has_building = ca_culture_altaic_jurchen_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = jurchen
								}
							}
							add_building = ca_culture_altaic_jurchen_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_altaic_jurchen_2
								NOT = { has_building = ca_culture_altaic_jurchen_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = jurchen
								}
							}
							add_building = ca_culture_altaic_jurchen_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_altaic_jurchen_1
								NOT = { has_building = ca_culture_altaic_jurchen_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = jurchen
								}
							}
							add_building = ca_culture_altaic_jurchen_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_altaic_jurchen_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = jurchen
								}
							}
							add_building = ca_culture_altaic_jurchen_1
						}
					}
					if = { #Tibetan Culture Group
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_tibetan_3
								NOT = { has_building = ca_culture_tibetan_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture_group = tibetan_group
								}
							}
							add_building = ca_culture_tibetan_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_tibetan_2
								NOT = { has_building = ca_culture_tibetan_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture_group = tibetan_group
								}
							}
							add_building = ca_culture_tibetan_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_tibetan_1
								NOT = { has_building = ca_culture_tibetan_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = tibetan_group
								}
							}
							add_building = ca_culture_tibetan_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_culture_tibetan_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = tibetan_group
								}
							}
							add_building = ca_culture_tibetan_1
						}
					}
					if = { #Roman Heavy Infantry camps
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_roman_3
								NOT = { has_building = ca_culture_roman_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = roman
								}
							}
							add_building = ca_culture_roman_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_roman_2
								NOT = { has_building = ca_culture_roman_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = roman
								}
							}
							add_building = ca_culture_roman_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_roman_1
								NOT = { has_building = ca_culture_roman_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = roman
								}
							}
							add_building = ca_culture_roman_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_roman_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = roman
								}
							}
							add_building = ca_culture_roman_1
						}
					}
					if = { #Coptic Spearmen
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_coptic_3
								NOT = { has_building = ca_culture_coptic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = coptic
								}
							}
							add_building = ca_culture_coptic_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_coptic_2
								NOT = { has_building = ca_culture_coptic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = coptic
								}
							}
							add_building = ca_culture_coptic_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_coptic_1
								NOT = { has_building = ca_culture_coptic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = coptic
								}
							}
							add_building = ca_culture_coptic_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_coptic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = coptic
								}
							}
							add_building = ca_culture_coptic_1
						}
					}
					if = { #Arberian cavalry
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_arberian_3
								NOT = { has_building = ca_culture_arberian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = arberian
								}
							}
							add_building = ca_culture_arberian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_arberian_2
								NOT = { has_building = ca_culture_arberian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = arberian
								}
							}
							add_building = ca_culture_arberian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_arberian_1
								NOT = { has_building = ca_culture_arberian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = arberian
								}
							}
							add_building = ca_culture_arberian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_arberian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = arberian
								}
							}
							add_building = ca_culture_arberian_1
						}
					}
					if = { #Sardinian Birrudo
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_culture_sardinian_3
								NOT = { has_building = ca_culture_sardinian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									culture = sardinian
								}
							}
							add_building = ca_culture_sardinian_4
						}
						else_if = {
							limit = {
								has_building = ca_culture_sardinian_2
								NOT = { has_building = ca_culture_sardinian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									culture = sardinian
								}
							}
							add_building = ca_culture_sardinian_3
						}
						else_if = {
							limit = {
								has_building = ca_culture_sardinian_1
								NOT = { has_building = ca_culture_sardinian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = sardinian
								}
							}
							add_building = ca_culture_sardinian_2
						}
						else_if = {
							limit = {
								has_building = ca_wall_2
								NOT = { has_building = ca_culture_sardinian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = sardinian
								}
							}
							add_building = ca_culture_sardinian_1
						}
					}
					if = { #Tibet Monastery Stuff
						limit = { holding_type = castle }
						if = {
							limit = {
								owner = { government = theocratic_feudal_government }
								has_building = ca_government_monastery_3
								NOT = { has_building = ca_government_monastery_4 }
								location = { TECH_CITY_CONSTRUCTION = 4 }
							}
							add_building = ca_government_monastery_4
						}
						else_if = {
							limit = {
								owner = { government = theocratic_feudal_government }
								has_building = ca_government_monastery_2
								NOT = { has_building = ca_government_monastery_3 }
								location = { TECH_CITY_CONSTRUCTION = 2 }
							}
							add_building = ca_government_monastery_3
						}
						else_if = {
							limit = {
								owner = { government = theocratic_feudal_government }
								has_building = ca_wall_1
								has_building = ca_government_monastery_1
								NOT = { has_building = ca_government_monastery_2 }
								location = { TECH_CITY_CONSTRUCTION = 1 }
							}
							add_building = ca_government_monastery_2
						}
						else_if = {
							limit = {
								owner = { government = theocratic_feudal_government }
								NOT = { has_building = ca_government_monastery_1 }
								location = { TECH_CITY_CONSTRUCTION = 0 }
							}
							add_building = ca_government_monastery_1
						}
					}
					if = { #Steppe Barracks
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_steppe_barracks_5
								NOT = { has_building = ca_steppe_barracks_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_barracks_6
						}
						else_if = {
							limit = {
								has_building = ca_steppe_barracks_4
								NOT = { has_building = ca_steppe_barracks_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_barracks_5
						}
						else_if = {
							limit = {
								has_building = ca_steppe_barracks_3
								NOT = { has_building = ca_steppe_barracks_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_barracks_4
						}
						else_if = {
							limit = {
								has_building = ca_steppe_barracks_2
								has_building = ca_wall_2
								NOT = { has_building = ca_steppe_barracks_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_barracks_3
						}
						else_if = {
							limit = {
								has_building = ca_steppe_barracks_1
								has_building = ca_wall_1
								NOT = { has_building = ca_steppe_barracks_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_steppe_barracks_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_barracks_1
						}
					}
					if = { #Steppe Stable
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_steppe_stable_5
								NOT = { has_building = ca_steppe_stable_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 8
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_stable_6
						}
						else_if = {
							limit = {
								has_building = ca_steppe_stable_4
								NOT = { has_building = ca_steppe_stable_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_stable_5
						}
						else_if = {
							limit = {
								has_building = ca_steppe_stable_3
								NOT = { has_building = ca_steppe_stable_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_stable_4
						}
						else_if = {
							limit = {
								has_building = ca_steppe_stable_2
								has_building = ca_wall_2
								NOT = { has_building = ca_steppe_stable_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_stable_3
						}
						else_if = {
							limit = {
								has_building = ca_steppe_stable_1
								has_building = ca_wall_1
								NOT = { has_building = ca_steppe_stable_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_stable_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_steppe_stable_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
										culture_group = iranian
									}
								}
							}
							add_building = ca_steppe_stable_1
						}
					}
					if = { #Desert Stable,
						limit = { holding_type = castle }
						if = {
							limit = {
								has_building = ca_desert_stable_5
								NOT = { has_building = ca_desert_stable_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 8
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
									}
								}
							}
							add_building = ca_desert_stable_6
						}
						else_if = {
							limit = {
								has_building = ca_desert_stable_4
								NOT = { has_building = ca_desert_stable_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
									}
								}
							}
							add_building = ca_desert_stable_5
						}
						else_if = {
							limit = {
								has_building = ca_desert_stable_3
								NOT = { has_building = ca_desert_stable_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
									}
								}
							}
							add_building = ca_desert_stable_4
						}
						else_if = {
							limit = {
								has_building = ca_desert_stable_2
								has_building = ca_wall_2
								NOT = { has_building = ca_desert_stable_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
									}
								}
							}
							add_building = ca_desert_stable_3
						}
						else_if = {
							limit = {
								has_building = ca_desert_stable_1
								has_building = ca_wall_1
								NOT = { has_building = ca_desert_stable_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
									}
								}
							}
							add_building = ca_desert_stable_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ca_desert_stable_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
									}
								}
							}
							add_building = ca_desert_stable_1
						}
					}
#####################TRIBAL#####################
					if = { #Hillforts
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_hillfort_3
								NOT = { has_building = tb_hillfort_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = tb_hillfort_4
						}
						else_if = {
							limit = {
								has_building = tb_hillfort_2
								NOT = { has_building = tb_hillfort_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = tb_hillfort_3
						}
						else_if = {
							limit = {
								has_building = tb_hillfort_1
								NOT = { has_building = tb_hillfort_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = tb_hillfort_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_hillfort_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = tb_hillfort_1
						}
					}
					if = { #Market Town
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_market_town_3
								NOT = { has_building = tb_market_town_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = tb_market_town_4
						}
						else_if = {
							limit = {
								has_building = tb_market_town_2
								NOT = { has_building = tb_market_town_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = tb_market_town_3
						}
						else_if = {
							limit = {
								has_building = tb_market_town_1
								NOT = { has_building = tb_market_town_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = tb_market_town_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_market_town_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = tb_market_town_1
						}
					}
					if = { #Defensive Fortifications
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_defensive_fortifications_3
								NOT = { has_building = tb_defensive_fortifications_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = tb_defensive_fortifications_4
						}
						else_if = {
							limit = {
								has_building = tb_defensive_fortifications_2
								NOT = { has_building = tb_defensive_fortifications_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = tb_defensive_fortifications_3
						}
						else_if = {
							limit = {
								has_building = tb_defensive_fortifications_1
								NOT = { has_building = tb_defensive_fortifications_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = tb_defensive_fortifications_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_defensive_fortifications_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = tb_defensive_fortifications_1
						}
					}
					if = { #Shipyards
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_shipyard_3
								NOT = { has_building = tb_shipyard_4 }
								location = {
									TECH_NAVAL = 4
									port = yes
								}
							}
							add_building = tb_shipyard_4
						}
						else_if = {
							limit = {
								has_building = tb_shipyard_2
								NOT = { has_building = tb_shipyard_3 }
								location = {
									TECH_NAVAL = 3
									port = yes
								}
							}
							add_building = tb_shipyard_3
						}
						else_if = {
							limit = {
								has_building = tb_shipyard_1
								NOT = { has_building = tb_shipyard_2 }
								location = {
									TECH_NAVAL = 2
									port = yes
								}
							}
							add_building = tb_shipyard_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_shipyard_1 }
								location = {
									TECH_NAVAL = 1
									port = yes
								}
							}
							add_building = tb_shipyard_1
						}
					}
					if = { #Training Grounds
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_training_grounds_3
								NOT = { has_building = tb_training_grounds_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tb_training_grounds_4
						}
						else_if = {
							limit = {
								has_building = tb_training_grounds_2
								NOT = { has_building = tb_training_grounds_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tb_training_grounds_3
						}
						else_if = {
							limit = {
								has_building = tb_training_grounds_1
								NOT = { has_building = tb_training_grounds_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tb_training_grounds_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_training_grounds_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tb_training_grounds_1
						}
					}
					if = { #War Camp
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_war_camp_3
								NOT = { has_building = tb_war_camp_4 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_war_camp_4
						}
						else_if = {
							limit = {
								has_building = tb_war_camp_2
								NOT = { has_building = tb_war_camp_3 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_war_camp_3
						}
						else_if = {
							limit = {
								has_building = tb_war_camp_1
								NOT = { has_building = tb_war_camp_2 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_war_camp_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_war_camp_1 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_war_camp_1
						}
					}
					if = { #Practice Range
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_practice_range_3
								NOT = { has_building = tb_practice_range_4 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_practice_range_4
						}
						else_if = {
							limit = {
								has_building = tb_practice_range_2
								NOT = { has_building = tb_practice_range_3 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_practice_range_3
						}
						else_if = {
							limit = {
								has_building = tb_practice_range_1
								NOT = { has_building = tb_practice_range_2 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_practice_range_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_practice_range_1 }
								location = {
									TECH_INFANTRY = 0
								}
							}
							add_building = tb_practice_range_1
						}
					}
					if = { #Steppe Barracks
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_steppe_barracks_3
								NOT = { has_building = tb_steppe_barracks_4 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
									}
								}
							}
							add_building = tb_steppe_barracks_4
						}
						else_if = {
							limit = {
								has_building = tb_steppe_barracks_2
								NOT = { has_building = tb_steppe_barracks_3 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
									}
								}
							}
							add_building = tb_steppe_barracks_3
						}
						else_if = {
							limit = {
								has_building = tb_steppe_barracks_1
								NOT = { has_building = tb_steppe_barracks_2 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
									}
								}
							}
							add_building = tb_steppe_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_steppe_barracks_1 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										culture_group = altaic
										culture_group = magyar
									}
								}
							}
							add_building = tb_steppe_barracks_1
						}
					}
					if = { #Steppe Stable
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_steppe_stable_3
								NOT = { has_building = tb_steppe_stable_4 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										terrain = steppe
										terrain = plains
									}
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
									}
								}
							}
							add_building = tb_steppe_stable_4
						}
						else_if = {
							limit = {
								has_building = tb_steppe_stable_2
								NOT = { has_building = tb_steppe_stable_3 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										terrain = steppe
										terrain = plains
									}
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
									}
								}
							}
							add_building = tb_steppe_stable_3
						}
						else_if = {
							limit = {
								has_building = tb_steppe_stable_1
								NOT = { has_building = tb_steppe_stable_2 }
								location = {
									TECH_CAVALRY = 0
									terrain = steppe
									OR = {
										terrain = steppe
										terrain = plains
									}
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
									}
								}
							}
							add_building = tb_steppe_stable_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_steppe_stable_1 }
								location = {
									TECH_CAVALRY = 0
									OR = {
										terrain = steppe
										terrain = plains
									}
									OR = {
										culture_group = altaic
										culture_group = magyar
										culture = alan
									}
								}
							}
							add_building = tb_steppe_stable_1
						}
					}
					if = { #Weaponsmith
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_arsenal_3
								NOT = { has_building = tb_arsenal_4 }
								location = {
									TECH_RECRUITMENT = 0
								}
							}
							add_building = tb_arsenal_4
						}
						else_if = {
							limit = {
								has_building = tb_arsenal_2
								NOT = { has_building = tb_arsenal_3 }
								location = {
									TECH_RECRUITMENT = 0
								}
							}
							add_building = tb_arsenal_3
						}
						else_if = {
							limit = {
								has_building = tb_arsenal_1
								NOT = { has_building = tb_arsenal_2 }
								location = {
									TECH_RECRUITMENT = 0
								}
							}
							add_building = tb_arsenal_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_arsenal_1 }
								location = {
									TECH_RECRUITMENT = 0
								}
							}
							add_building = tb_arsenal_1
						}
					}
					if = { #Desert Stable
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_desert_stable_3
								NOT = { has_building = tb_desert_stable_4 }
								location = {
									TECH_CAVALRY = 0
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
										culture_group = iranian
									}
								}
							}
							add_building = tb_desert_stable_4
						}
						else_if = {
							limit = {
								has_building = tb_desert_stable_2
								NOT = { has_building = tb_desert_stable_3 }
								location = {
									TECH_CAVALRY = 0
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
										culture_group = iranian
									}
								}
							}
							add_building = tb_desert_stable_3
						}
						else_if = {
							limit = {
								has_building = tb_desert_stable_1
								NOT = { has_building = tb_desert_stable_2 }
								location = {
									TECH_CAVALRY = 0
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
										culture_group = iranian
									}
								}
							}
							add_building = tb_desert_stable_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_desert_stable_1 }
								location = {
									TECH_CAVALRY = 0
									terrain = desert
									OR = {
										culture_group = east_african
										culture_group = west_african
										culture_group = arabic
										culture_group = iranian
									}
								}
							}
							add_building = tb_desert_stable_1
						}
					}
					if = { #Welsh and English Longbow Archery Range
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_saxon_english_3
								NOT = { has_building = tb_culture_saxon_english_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = tb_culture_saxon_english_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_saxon_english_2
								NOT = { has_building = tb_culture_saxon_english_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = tb_culture_saxon_english_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_saxon_english_1
								NOT = { has_building = tb_culture_saxon_english_2 }
								location = { 
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = tb_culture_saxon_english_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_saxon_english_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = english
										culture = welsh
									}
								}
							}
							add_building = tb_culture_saxon_english_1
						}
					}
					if = { #Scottish Schiltrone
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_scottish_3
								NOT = { has_building = tb_culture_scottish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = scottish
								}
							}
							add_building = tb_culture_scottish_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_scottish_2
								NOT = { has_building = tb_culture_scottish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = scottish
								}
							}
							add_building = tb_culture_scottish_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_scottish_1
								NOT = { has_building = tb_culture_scottish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = scottish
								}
							}
							add_building = tb_culture_scottish_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_scottish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = scottish
								}
							}
							add_building = tb_culture_scottish_1
						}
					}
					if = { #Baltic Tribes Heavy Infantry Camps
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_baltic_3
								NOT = { has_building = tb_culture_group_baltic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = tb_culture_group_baltic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_baltic_2
								NOT = { has_building = tb_culture_group_baltic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = tb_culture_group_baltic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_baltic_1
								NOT = { has_building = tb_culture_group_baltic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = tb_culture_group_baltic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_baltic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = baltic
										culture_group = finno_ugric
									}
								}
							}
							add_building = tb_culture_group_baltic_1
						}
					}
					if = { #Altaic Horse Breeders (and Persian)
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_altaic_3
								NOT = { has_building = tb_culture_group_altaic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = tb_culture_group_altaic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_altaic_2
								NOT = { has_building = tb_culture_group_altaic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = tb_culture_group_altaic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_altaic_1
								NOT = { has_building = tb_culture_group_altaic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = tb_culture_group_altaic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_altaic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = turkish
										culture = pecheneg
										culture = cuman
										culture = khazar
										culture = bolghar
										culture = avar
										culture = karluk
										culture = kirghiz
										culture = uyghur
										culture = mongol
										culture = khitan
										culture_group = iranian
									}
								}
							}
							add_building = tb_culture_group_altaic_1
						}
					}
					if = { #Frankish, Occitan, Norman and German Lists (and Breton)
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_frank_norman_german_3
								NOT = { has_building = tb_culture_frank_norman_german_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = tb_culture_frank_norman_german_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_frank_norman_german_2
								NOT = { has_building = tb_culture_frank_norman_german_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = tb_culture_frank_norman_german_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_frank_norman_german_1
								NOT = { has_building = tb_culture_frank_norman_german_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = tb_culture_frank_norman_german_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_frank_norman_german_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = frankish
										culture = occitan
										culture = norman
										culture = german
										culture = breton
										culture = outremer
									}
								}
							}
							add_building = tb_culture_frank_norman_german_1
						}
					}
					if = { #Iberian Fast horse breeders
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_iberian_3
								NOT = { has_building = tb_culture_group_iberian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = iberian
								}
							}
							add_building = tb_culture_group_iberian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_iberian_2
								NOT = { has_building = tb_culture_group_iberian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = iberian
								}
							}
							add_building = tb_culture_group_iberian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_iberian_1
								NOT = { has_building = tb_culture_group_iberian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = iberian
								}
							}
							add_building = tb_culture_group_iberian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_iberian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = iberian
								}
							}
							add_building = tb_culture_group_iberian_1
						}
					}
					if = { #Italian Pike formations
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_italian_3
								NOT = { has_building = tb_culture_italian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = tb_culture_italian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_italian_2
								NOT = { has_building = tb_culture_italian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = tb_culture_italian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_italian_1
								NOT = { has_building = tb_culture_italian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = tb_culture_italian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_italian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = italian 
										culture = dalmatian
									}
								}
							}
							add_building = tb_culture_italian_1
						}
					}
					if = { #Russian Armories
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_russian_3
								NOT = { has_building = tb_culture_russian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = east_slavic
								}
							}
							add_building = tb_culture_russian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_russian_2
								NOT = { has_building = tb_culture_russian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = east_slavic
								}
							}
							add_building = tb_culture_russian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_russian_1
								NOT = { has_building = tb_culture_russian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = east_slavic
								}
							}
							add_building = tb_culture_russian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_russian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = east_slavic
								}
							}
							add_building = tb_culture_russian_1
						}
					}
					if = { #Scandinavian Housecarls (and Saxon)
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_north_germanic_3
								NOT = { has_building = tb_culture_group_north_germanic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = tb_culture_group_north_germanic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_north_germanic_2
								NOT = { has_building = tb_culture_group_north_germanic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = tb_culture_group_north_germanic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_north_germanic_1
								NOT = { has_building = tb_culture_group_north_germanic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = tb_culture_group_north_germanic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_north_germanic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = north_germanic
										culture = saxon
										culture = old_saxon
										culture = frisian
									}
								}
							}
							add_building = tb_culture_group_north_germanic_1
						}
					}
					if = { #Hungarian Hussars (and West Slavic)
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_hungarian_3
								NOT = { has_building = tb_culture_hungarian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = tb_culture_hungarian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_hungarian_2
								NOT = { has_building = tb_culture_hungarian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = tb_culture_hungarian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_hungarian_1
								NOT = { has_building = tb_culture_hungarian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = tb_culture_hungarian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_hungarian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = hungarian
										culture_group = west_slavic
									}
								}
							}
							add_building = tb_culture_hungarian_1
						}
					}
					if = { #Arabian Camel Cavalry
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_arabic_3
								NOT = { has_building = tb_culture_group_arabic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = tb_culture_group_arabic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_arabic_2
								NOT = { has_building = tb_culture_group_arabic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = tb_culture_group_arabic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_arabic_1
								NOT = { has_building = tb_culture_group_arabic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = tb_culture_group_arabic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_arabic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = bedouin_arabic
										culture = levantine_arabic
										culture = egyptian_arabic
									}
								}
							}
							add_building = tb_culture_group_arabic_1
						}
					}
					if = { #Byzantine Cataphracts
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_byzantine_3
								NOT = { has_building = tb_culture_group_byzantine_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = tb_culture_group_byzantine_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_byzantine_2
								NOT = { has_building = tb_culture_group_byzantine_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = tb_culture_group_byzantine_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_byzantine_1
								NOT = { has_building = tb_culture_group_byzantine_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = tb_culture_group_byzantine_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_byzantine_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = armenian
										culture = greek
										culture = alan
										culture = georgian
										culture = assyrian
										culture = crimean_gothic
									}
								}
							}
							add_building = tb_culture_group_byzantine_1
						}
					}
					if = { #Irish Gallowglass
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_irish_3
								NOT = { has_building = tb_culture_irish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = irish
								}
							}
							add_building = tb_culture_irish_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_irish_2
								NOT = { has_building = tb_culture_irish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = irish
								}
							}
							add_building = tb_culture_irish_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_irish_1
								NOT = { has_building = tb_culture_irish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = irish
								}
							}
							add_building = tb_culture_irish_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_irish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = irish
								}
							}
							add_building = tb_culture_irish_1
						}
					}
					if = { #Ethiopian Light Infantry Drilling Ground
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_ethiopian_3
								NOT = { has_building = tb_culture_ethiopian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = ethiopian
								}
							}
							add_building = tb_culture_ethiopian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_ethiopian_2
								NOT = { has_building = tb_culture_ethiopian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = ethiopian
								} 
							}
							add_building = tb_culture_ethiopian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_ethiopian_1
								NOT = { has_building = tb_culture_ethiopian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = ethiopian
								}
							}
							add_building = tb_culture_ethiopian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_ethiopian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = ethiopian
								}
							}
							add_building = tb_culture_ethiopian_1
						}
					}
					if = { #Somali Light Infantry Barracks
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_somali_3
								NOT = { has_building = tb_culture_somali_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = somali
								}
							}
							add_building = tb_culture_somali_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_somali_2
								NOT = { has_building = tb_culture_somali_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = somali
								}
							}
							add_building = tb_culture_somali_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_somali_1
								NOT = { has_building = tb_culture_somali_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = somali
								}
							}
							add_building = tb_culture_somali_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_somali_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = somali
								}
							}
							add_building = tb_culture_somali_1
						}
					}
					if = { #West African Free Warrior Lodge
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_west_african_3
								NOT = { has_building = tb_culture_west_african_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = tb_culture_west_african_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_west_african_2
								NOT = { has_building = tb_culture_west_african_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = tb_culture_west_african_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_west_african_1
								NOT = { has_building = tb_culture_west_african_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = tb_culture_west_african_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_west_african_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = west_african 
										culture_group = central_african
										culture = daju
									}
								}
							}
							add_building = tb_culture_west_african_1
						}
					}
					if = { #South Slavic Cavalry
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_group_south_slavic_3
								NOT = { has_building = tb_culture_group_south_slavic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = south_slavic
								}
							}
							add_building = tb_culture_group_south_slavic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_south_slavic_2
								NOT = { has_building = tb_culture_group_south_slavic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = south_slavic
								}
							}
							add_building = tb_culture_group_south_slavic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_group_south_slavic_1
								NOT = { has_building = tb_culture_group_south_slavic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = south_slavic
								}
							}
							add_building = tb_culture_group_south_slavic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_group_south_slavic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = south_slavic
								}
							}
							add_building = tb_culture_group_south_slavic_1
						}
					}
					if = { #Dutch Urban Militia
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_dutch_3
								NOT = { has_building = tb_culture_dutch_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = dutch
								}
							}
							add_building = tb_culture_dutch_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_dutch_2
								NOT = { has_building = tb_culture_dutch_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = dutch
								}
							}
							add_building = tb_culture_dutch_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_dutch_1
								NOT = { has_building = tb_culture_dutch_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = dutch
								}
							}
							add_building = tb_culture_dutch_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_dutch_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = dutch
								}
							}
							add_building = tb_culture_dutch_1
						}
					}
					if = { #Aztec Jaguar Warriors
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_nahuatl_3
								NOT = { has_building = tb_culture_nahuatl_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = nahuatl
								}
							}
							add_building = tb_culture_nahuatl_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_nahuatl_2
								NOT = { has_building = tb_culture_nahuatl_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = nahuatl
								}
							}
							add_building = tb_culture_nahuatl_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_nahuatl_1
								NOT = { has_building = tb_culture_nahuatl_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = nahuatl
								}
							}
							add_building = tb_culture_nahuatl_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_nahuatl_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = nahuatl
								}
							}
							add_building = tb_culture_nahuatl_1
						}
					}
					if = { #Jewish Heavy Infantry
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_jewish_3
								NOT = { has_building = tb_culture_jewish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = israelite
								}
							}
							add_building = tb_culture_jewish_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_jewish_2
								NOT = { has_building = tb_culture_jewish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = israelite
								}
							}
							add_building = tb_culture_jewish_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_jewish_1
								NOT = { has_building = tb_culture_jewish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = israelite
								}
							}
							add_building = tb_culture_jewish_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_jewish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = israelite
								}
							}
							add_building = tb_culture_jewish_1
						}
					}
					if = { #Indian war elephant pens
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_indian_3
								NOT = { has_building = tb_culture_indian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = tb_culture_indian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_indian_2
								NOT = { has_building = tb_culture_indian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = tb_culture_indian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_indian_1
								NOT = { has_building = tb_culture_indian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = tb_culture_indian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_indian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture_group = indo_aryan_group
										culture_group = dravidian_group
									}
								}
							}
							add_building = tb_culture_indian_1
						}
					}
					if = { #Nubian Warrior Barracks
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_nubian_3
								NOT = { has_building = tb_culture_nubian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = nubian
								}
							}
							add_building = tb_culture_nubian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_nubian_2
								NOT = { has_building = tb_culture_nubian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = nubian
								}
							}
							add_building = tb_culture_nubian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_nubian_1
								NOT = { has_building = tb_culture_nubian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = nubian
								}
							}
							add_building = tb_culture_nubian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_nubian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = nubian
								}
							}
							add_building = tb_culture_nubian_1
						}
					}
					if = { #Germanic Heavy Infantry Barracks
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_germanic_3
								NOT = { has_building = tb_culture_germanic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = tb_culture_germanic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_germanic_2
								NOT = { has_building = tb_culture_germanic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = tb_culture_germanic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_germanic_1
								NOT = { has_building = tb_culture_germanic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = tb_culture_germanic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_germanic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = lombard
										culture = old_frankish
									}
								}
							}
							add_building = tb_culture_germanic_1
						}
					}
					if = { #Pictish Hall of War
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_pictish_3
								NOT = { has_building = tb_culture_pictish_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = pictish
								}
							}
							add_building = tb_culture_pictish_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_pictish_2
								NOT = { has_building = tb_culture_pictish_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = pictish
								}
							}
							add_building = tb_culture_pictish_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_pictish_1
								NOT = { has_building = tb_culture_pictish_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = pictish
								}
							}
							add_building = tb_culture_pictish_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_pictish_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = pictish
								}
							}
							add_building = tb_culture_pictish_1
						}
					}
					if = { #Suebi Free Warriors
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_suebi_3
								NOT = { has_building = tb_culture_suebi_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = suebi
								}
							}
							add_building = tb_culture_suebi_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_suebi_2
								NOT = { has_building = tb_culture_suebi_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = suebi
								}
							}
							add_building = tb_culture_suebi_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_suebi_1
								NOT = { has_building = tb_culture_suebi_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = suebi
								}
							}
							add_building = tb_culture_suebi_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_suebi_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = suebi
								}
							}
							add_building = tb_culture_suebi_1
						}
					}
					if = { #Moorish Cavalry Barracks
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_moors_3
								NOT = { has_building = tb_culture_moors_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = tb_culture_moors_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_moors_2
								NOT = { has_building = tb_culture_moors_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = tb_culture_moors_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_moors_1
								NOT = { has_building = tb_culture_moors_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = tb_culture_moors_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_moors_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									OR = {
										culture = andalusian_arabic
										culture = maghreb_arabic
									}
								}
							}
							add_building = tb_culture_moors_1
						}
					}
					if = { #Han Crossbow Range
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_chinese_han_3
								NOT = { has_building = tb_culture_chinese_han_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = han
								}
							}
							add_building = tb_culture_chinese_han_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_chinese_han_2
								NOT = { has_building = tb_culture_chinese_han_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = han
								}
							}
							add_building = tb_culture_chinese_han_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_chinese_han_1
								NOT = { has_building = tb_culture_chinese_han_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = han
								}
							}
							add_building = tb_culture_chinese_han_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_chinese_han_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = han
								}
							}
							add_building = tb_culture_chinese_han_1
						}
					}
					if = { #Jurchen Cavalry Barracks
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_altaic_jurchen_3
								NOT = { has_building = tb_culture_altaic_jurchen_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = jurchen
								}
							}
							add_building = tb_culture_altaic_jurchen_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_altaic_jurchen_2
								NOT = { has_building = tb_culture_altaic_jurchen_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = jurchen
								}
							}
							add_building = tb_culture_altaic_jurchen_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_altaic_jurchen_1
								NOT = { has_building = tb_culture_altaic_jurchen_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = jurchen
								}
							}
							add_building = tb_culture_altaic_jurchen_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_altaic_jurchen_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = jurchen
								}
							}
							add_building = tb_culture_altaic_jurchen_1
						}
					}
					if = { #Tibetan Culture Group
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_tibetan_3
								NOT = { has_building = tb_culture_tibetan_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = tibetan_group
								}
							}
							add_building = tb_culture_tibetan_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_tibetan_2
								NOT = { has_building = tb_culture_tibetan_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture_group = tibetan_group
								}
							}
							add_building = tb_culture_tibetan_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_tibetan_1
								NOT = { has_building = tb_culture_tibetan_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = tibetan_group
								}
							}
							add_building = tb_culture_tibetan_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tb_culture_tibetan_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture_group = tibetan_group
								}
							}
							add_building = tb_culture_tibetan_1
						}
					}
					if = { #Roman Heavy Infantry camps
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_roman_3
								NOT = { has_building = tb_culture_roman_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = roman
								}
							}
							add_building = tb_culture_roman_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_roman_2
								NOT = { has_building = tb_culture_roman_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = roman
								}
							}
							add_building = tb_culture_roman_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_roman_1
								NOT = { has_building = tb_culture_roman_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = roman
								}
							}
							add_building = tb_culture_roman_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_roman_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = roman
								}
							}
							add_building = tb_culture_roman_1
						}
					}
					if = { #Coptic Spearmen
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_coptic_3
								NOT = { has_building = tb_culture_coptic_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = coptic
								}
							}
							add_building = tb_culture_coptic_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_coptic_2
								NOT = { has_building = tb_culture_coptic_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = coptic
								}
							}
							add_building = tb_culture_coptic_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_coptic_1
								NOT = { has_building = tb_culture_coptic_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = coptic
								}
							}
							add_building = tb_culture_coptic_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_coptic_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = coptic
								}
							}
							add_building = tb_culture_coptic_1
						}
					}
					if = { #Arberian cavalry
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_arberian_3
								NOT = { has_building = tb_culture_arberian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = arberian
								}
							}
							add_building = tb_culture_arberian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_arberian_2
								NOT = { has_building = tb_culture_arberian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = arberian
								}
							}
							add_building = tb_culture_arberian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_arberian_1
								NOT = { has_building = tb_culture_arberian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = arberian
								}
							}
							add_building = tb_culture_arberian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_arberian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = arberian
								}
							}
							add_building = tb_culture_arberian_1
						}
					}
					if = { #Sardinian Birrudo
						limit = { holding_type = tribal }
						if = {
							limit = {
								has_building = tb_culture_sardinian_3
								NOT = { has_building = tb_culture_sardinian_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = sardinian
								}
							}
							add_building = tb_culture_sardinian_4
						}
						else_if = {
							limit = {
								has_building = tb_culture_sardinian_2
								NOT = { has_building = tb_culture_sardinian_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									culture = sardinian
								}
							}
							add_building = tb_culture_sardinian_3
						}
						else_if = {
							limit = {
								has_building = tb_culture_sardinian_1
								NOT = { has_building = tb_culture_sardinian_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = sardinian
								}
							}
							add_building = tb_culture_sardinian_2
						}
						else_if = {
							limit = {
								
								NOT = { has_building = tb_culture_sardinian_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									culture = sardinian
								}
							}
							add_building = tb_culture_sardinian_1
						}
					}
#####################NOMAD#####################
					if = { #Horse Breeders
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_horse_breeder_7
								NOT = { has_building = no_horse_breeder_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_horse_breeder_8
						}
						else_if = {
							limit = {
								has_building = no_horse_breeder_6
								NOT = { has_building = no_horse_breeder_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_horse_breeder_7
						}
						else_if = {
							limit = {
								has_building = no_horse_breeder_5
								NOT = { has_building = no_horse_breeder_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_horse_breeder_6
						}
						else_if = {
							limit = {
								has_building = no_horse_breeder_4
								NOT = { has_building = no_horse_breeder_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_horse_breeder_5
						}
						else_if = {
							limit = {
								has_building = no_horse_breeder_3
								NOT = { has_building = no_horse_breeder_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_horse_breeder_4
						}
						else_if = {
							limit = {
								has_building = no_horse_breeder_2
								NOT = { has_building = no_horse_breeder_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_horse_breeder_3
						}
						else_if = {
							limit = {
								has_building = no_horse_breeder_1
								NOT = { has_building = no_horse_breeder_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_horse_breeder_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_horse_breeder_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_horse_breeder_1
						}
					}
					if = { #Riding Contests
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_riding_contests_7
								NOT = { has_building = no_riding_contests_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
								}
							}
							add_building = no_riding_contests_8
						}
						else_if = {
							limit = {
								has_building = no_riding_contests_6
								NOT = { has_building = no_riding_contests_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
								}
							}
							add_building = no_riding_contests_7
						}
						else_if = {
							limit = {
								has_building = no_riding_contests_5
								NOT = { has_building = no_riding_contests_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_riding_contests_6
						}
						else_if = {
							limit = {
								has_building = no_riding_contests_4
								NOT = { has_building = no_riding_contests_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_riding_contests_5
						}
						else_if = {
							limit = {
								has_building = no_riding_contests_3
								NOT = { has_building = no_riding_contests_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_riding_contests_4
						}
						else_if = {
							limit = {
								has_building = no_riding_contests_2
								NOT = { has_building = no_riding_contests_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_riding_contests_3
						}
						else_if = {
							limit = {
								has_building = no_riding_contests_1
								NOT = { has_building = no_riding_contests_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_riding_contests_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_riding_contests_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_riding_contests_1
						}
					}
					if = { #Airag Producer
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_airag_producer_7
								NOT = { has_building = no_airag_producer_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 6
								}
							}
							add_building = no_airag_producer_8
						}
						else_if = {
							limit = {
								has_building = no_airag_producer_6
								NOT = { has_building = no_airag_producer_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = no_airag_producer_7
						}
						else_if = {
							limit = {
								has_building = no_airag_producer_5
								NOT = { has_building = no_airag_producer_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_airag_producer_6
						}
						else_if = {
							limit = {
								has_building = no_airag_producer_4
								NOT = { has_building = no_airag_producer_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_airag_producer_5
						}
						else_if = {
							limit = {
								has_building = no_airag_producer_3
								NOT = { has_building = no_airag_producer_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_airag_producer_4
						}
						else_if = {
							limit = {
								has_building = no_airag_producer_2
								NOT = { has_building = no_airag_producer_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_airag_producer_3
						}
						else_if = {
							limit = {
								has_building = no_airag_producer_1
								NOT = { has_building = no_airag_producer_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_airag_producer_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_airag_producer_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_airag_producer_1
						}
					}
					if = { #Cattle Pens
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_cattle_pens_7
								NOT = { has_building = no_cattle_pens_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_cattle_pens_8
						}
						else_if = {
							limit = {
								has_building = no_cattle_pens_6
								NOT = { has_building = no_cattle_pens_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_cattle_pens_7
						}
						else_if = {
							limit = {
								has_building = no_cattle_pens_5
								NOT = { has_building = no_cattle_pens_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_cattle_pens_6
						}
						else_if = {
							limit = {
								has_building = no_cattle_pens_4
								NOT = { has_building = no_cattle_pens_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_cattle_pens_5
						}
						else_if = {
							limit = {
								has_building = no_cattle_pens_3
								NOT = { has_building = no_cattle_pens_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_cattle_pens_4
						}
						else_if = {
							limit = {
								has_building = no_cattle_pens_2
								NOT = { has_building = no_cattle_pens_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_cattle_pens_3
						}
						else_if = {
							limit = {
								has_building = no_cattle_pens_1
								NOT = { has_building = no_cattle_pens_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_cattle_pens_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_cattle_pens_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_cattle_pens_1
						}
					}
					if = { #Ox and Wagon
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_ox_wagon_7
								NOT = { has_building = no_ox_wagon_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_ox_wagon_8
						}
						else_if = {
							limit = {
								has_building = no_ox_wagon_6
								NOT = { has_building = no_ox_wagon_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_ox_wagon_7
						}
						else_if = {
							limit = {
								has_building = no_ox_wagon_5
								NOT = { has_building = no_ox_wagon_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_ox_wagon_6
						}
						else_if = {
							limit = {
								has_building = no_ox_wagon_4
								NOT = { has_building = no_ox_wagon_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_ox_wagon_5
						}
						else_if = {
							limit = {
								has_building = no_ox_wagon_3
								NOT = { has_building = no_ox_wagon_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_ox_wagon_4
						}
						else_if = {
							limit = {
								has_building = no_ox_wagon_2
								NOT = { has_building = no_ox_wagon_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_ox_wagon_3
						}
						else_if = {
							limit = {
								has_building = no_ox_wagon_1
								NOT = { has_building = no_ox_wagon_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_ox_wagon_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_ox_wagon_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_ox_wagon_1
						}
					}
					if = { #Meat Preserver
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_meat_preserver_7
								NOT = { has_building = no_meat_preserver_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = no_meat_preserver_8
						}
						else_if = {
							limit = {
								has_building = no_meat_preserver_6
								NOT = { has_building = no_meat_preserver_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_meat_preserver_7
						}
						else_if = {
							limit = {
								has_building = no_meat_preserver_5
								NOT = { has_building = no_meat_preserver_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_meat_preserver_6
						}
						else_if = {
							limit = {
								has_building = no_meat_preserver_4
								NOT = { has_building = no_meat_preserver_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_meat_preserver_5
						}
						else_if = {
							limit = {
								has_building = no_meat_preserver_3
								NOT = { has_building = no_meat_preserver_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_meat_preserver_4
						}
						else_if = {
							limit = {
								has_building = no_meat_preserver_2
								NOT = { has_building = no_meat_preserver_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_meat_preserver_3
						}
						else_if = {
							limit = {
								has_building = no_meat_preserver_1
								NOT = { has_building = no_meat_preserver_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_meat_preserver_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_meat_preserver_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_meat_preserver_1
						}
					}
					if = { #Sheep
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_sheep_7
								NOT = { has_building = no_sheep_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_sheep_8
						}
						else_if = {
							limit = {
								has_building = no_sheep_6
								NOT = { has_building = no_sheep_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_sheep_7
						}
						else_if = {
							limit = {
								has_building = no_sheep_5
								NOT = { has_building = no_sheep_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_sheep_6
						}
						else_if = {
							limit = {
								has_building = no_sheep_4
								NOT = { has_building = no_sheep_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_sheep_5
						}
						else_if = {
							limit = {
								has_building = no_sheep_3
								NOT = { has_building = no_sheep_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_sheep_4
						}
						else_if = {
							limit = {
								has_building = no_sheep_2
								NOT = { has_building = no_sheep_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_sheep_3
						}
						else_if = {
							limit = {
								has_building = no_sheep_1
								NOT = { has_building = no_sheep_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_sheep_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_sheep_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_sheep_1
						}
					}
					if = { #Felt Crafter
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_felt_crafter_7
								NOT = { has_building = no_felt_crafter_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 6
								}
							}
							add_building = no_felt_crafter_8
						}
						else_if = {
							limit = {
								has_building = no_felt_crafter_6
								NOT = { has_building = no_felt_crafter_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = no_felt_crafter_7
						}
						else_if = {
							limit = {
								has_building = no_felt_crafter_5
								NOT = { has_building = no_felt_crafter_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_felt_crafter_6
						}
						else_if = {
							limit = {
								has_building = no_felt_crafter_4
								NOT = { has_building = no_felt_crafter_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_felt_crafter_5
						}
						else_if = {
							limit = {
								has_building = no_felt_crafter_3
								NOT = { has_building = no_felt_crafter_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_felt_crafter_4
						}
						else_if = {
							limit = {
								has_building = no_felt_crafter_2
								NOT = { has_building = no_felt_crafter_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_felt_crafter_3
						}
						else_if = {
							limit = {
								has_building = no_felt_crafter_1
								NOT = { has_building = no_felt_crafter_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_felt_crafter_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_felt_crafter_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_felt_crafter_1
						}
					}
					if = { #Ger Crafter
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_ger_crafter_7
								NOT = { has_building = no_ger_crafter_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 6
								}
							}
							add_building = no_ger_crafter_8
						}
						else_if = {
							limit = {
								has_building = no_ger_crafter_6
								NOT = { has_building = no_ger_crafter_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = no_ger_crafter_7
						}
						else_if = {
							limit = {
								has_building = no_ger_crafter_5
								NOT = { has_building = no_ger_crafter_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_ger_crafter_6
						}
						else_if = {
							limit = {
								has_building = no_ger_crafter_4
								NOT = { has_building = no_ger_crafter_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_ger_crafter_5
						}
						else_if = {
							limit = {
								has_building = no_ger_crafter_3
								NOT = { has_building = no_ger_crafter_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_ger_crafter_4
						}
						else_if = {
							limit = {
								has_building = no_ger_crafter_2
								NOT = { has_building = no_ger_crafter_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_ger_crafter_3
						}
						else_if = {
							limit = {
								has_building = no_ger_crafter_1
								NOT = { has_building = no_ger_crafter_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_ger_crafter_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_ger_crafter_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_ger_crafter_1
						}
					}
					if = { #Wrestling
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_wrestling_7
								NOT = { has_building = no_wrestling_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
								}
							}
							add_building = no_wrestling_8
						}
						else_if = {
							limit = {
								has_building = no_wrestling_6
								NOT = { has_building = no_wrestling_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
								}
							}
							add_building = no_wrestling_7
						}
						else_if = {
							limit = {
								has_building = no_wrestling_5
								NOT = { has_building = no_wrestling_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
								}
							}
							add_building = no_wrestling_6
						}
						else_if = {
							limit = {
								has_building = no_wrestling_4
								NOT = { has_building = no_wrestling_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_wrestling_5
						}
						else_if = {
							limit = {
								has_building = no_wrestling_3
								NOT = { has_building = no_wrestling_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_wrestling_4
						}
						else_if = {
							limit = {
								has_building = no_wrestling_2
								NOT = { has_building = no_wrestling_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_wrestling_3
						}
						else_if = {
							limit = {
								has_building = no_wrestling_1
								NOT = { has_building = no_wrestling_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_wrestling_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_wrestling_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_wrestling_1
						}
					}
					if = { #Shrine
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_shrine_7
								NOT = { has_building = no_shrine_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = no_shrine_8
						}
						else_if = {
							limit = {
								has_building = no_shrine_6
								NOT = { has_building = no_shrine_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_shrine_7
						}
						else_if = {
							limit = {
								has_building = no_shrine_5
								NOT = { has_building = no_shrine_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_shrine_6
						}
						else_if = {
							limit = {
								has_building = no_shrine_4
								NOT = { has_building = no_shrine_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_shrine_5
						}
						else_if = {
							limit = {
								has_building = no_shrine_3
								NOT = { has_building = no_shrine_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_shrine_4
						}
						else_if = {
							limit = {
								has_building = no_shrine_2
								NOT = { has_building = no_shrine_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_shrine_3
						}
						else_if = {
							limit = {
								has_building = no_shrine_1
								NOT = { has_building = no_shrine_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_shrine_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_shrine_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_shrine_1
						}
					}
					if = { #Hunting Parties
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_hunting_parties_7
								NOT = { has_building = no_hunting_parties_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_hunting_parties_8
						}
						else_if = {
							limit = {
								has_building = no_hunting_parties_6
								NOT = { has_building = no_hunting_parties_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_hunting_parties_7
						}
						else_if = {
							limit = {
								has_building = no_hunting_parties_5
								NOT = { has_building = no_hunting_parties_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_hunting_parties_6
						}
						else_if = {
							limit = {
								has_building = no_hunting_parties_4
								NOT = { has_building = no_hunting_parties_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_hunting_parties_5
						}
						else_if = {
							limit = {
								has_building = no_hunting_parties_3
								NOT = { has_building = no_hunting_parties_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_hunting_parties_4
						}
						else_if = {
							limit = {
								has_building = no_hunting_parties_2
								NOT = { has_building = no_hunting_parties_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_hunting_parties_3
						}
						else_if = {
							limit = {
								has_building = no_hunting_parties_1
								NOT = { has_building = no_hunting_parties_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_hunting_parties_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_hunting_parties_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_hunting_parties_1
						}
					}
					if = { #Yam
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_yam_7
								NOT = { has_building = no_yam_8 }
								location = {
									TECH_TRADE_PRACTICES = 4
								}
							}
							add_building = no_yam_8
						}
						else_if = {
							limit = {
								has_building = no_yam_6
								NOT = { has_building = no_yam_7 }
								location = {
									TECH_TRADE_PRACTICES = 3
								}
							}
							add_building = no_yam_7
						}
						else_if = {
							limit = {
								has_building = no_yam_5
								NOT = { has_building = no_yam_6 }
								location = {
									TECH_TRADE_PRACTICES = 2
								}
							}
							add_building = no_yam_6
						}
						else_if = {
							limit = {
								has_building = no_yam_4
								NOT = { has_building = no_yam_5 }
								location = {
									TECH_TRADE_PRACTICES = 2
								}
							}
							add_building = no_yam_5
						}
						else_if = {
							limit = {
								has_building = no_yam_3
								NOT = { has_building = no_yam_4 }
								location = {
									TECH_TRADE_PRACTICES = 1
								}
							}
							add_building = no_yam_4
						}
						else_if = {
							limit = {
								has_building = no_yam_2
								NOT = { has_building = no_yam_3 }
								location = {
									TECH_TRADE_PRACTICES = 1
								}
							}
							add_building = no_yam_3
						}
						else_if = {
							limit = {
								has_building = no_yam_1
								NOT = { has_building = no_yam_2 }
								location = {
									TECH_TRADE_PRACTICES = 0
								}
							}
							add_building = no_yam_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_yam_1 }
								location = {
									TECH_TRADE_PRACTICES = 0
								}
							}
							add_building = no_yam_1
						}
					}
					if = { #Baghatur Council
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_baghatur_council_7
								NOT = { has_building = no_baghatur_council_8 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 6
								}
							}
							add_building = no_baghatur_council_8
						}
						else_if = {
							limit = {
								has_building = no_baghatur_council_6
								NOT = { has_building = no_baghatur_council_7 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 5
								}
							}
							add_building = no_baghatur_council_7
						}
						else_if = {
							limit = {
								has_building = no_baghatur_council_5
								NOT = { has_building = no_baghatur_council_6 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 4
								}
							}
							add_building = no_baghatur_council_6
						}
						else_if = {
							limit = {
								has_building = no_baghatur_council_4
								NOT = { has_building = no_baghatur_council_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 3
								}
							}
							add_building = no_baghatur_council_5
						}
						else_if = {
							limit = {
								has_building = no_baghatur_council_3
								NOT = { has_building = no_baghatur_council_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 3
								}
							}
							add_building = no_baghatur_council_4
						}
						else_if = {
							limit = {
								has_building = no_baghatur_council_2
								NOT = { has_building = no_baghatur_council_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = no_baghatur_council_3
						}
						else_if = {
							limit = {
								has_building = no_baghatur_council_1
								NOT = { has_building = no_baghatur_council_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = no_baghatur_council_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_baghatur_council_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 1
								}
							}
							add_building = no_baghatur_council_1
						}
					}
					if = { #Harbor
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_harbor_7
								NOT = { has_building = no_harbor_8 }
								location = {
									TECH_NAVAL = 7
									port = yes
								}
							}
							add_building = no_harbor_8
						}
						else_if = {
							limit = {
								has_building = no_harbor_6
								NOT = { has_building = no_harbor_7 }
								location = {
									TECH_NAVAL = 6
									port = yes
								}
							}
							add_building = no_harbor_7
						}
						else_if = {
							limit = {
								has_building = no_harbor_5
								NOT = { has_building = no_harbor_6 }
								location = {
									TECH_NAVAL = 5
									port = yes
								}
							}
							add_building = no_harbor_6
						}
						else_if = {
							limit = {
								has_building = no_harbor_4
								NOT = { has_building = no_harbor_5 }
								location = {
									TECH_NAVAL = 4
									port = yes
								}
							}
							add_building = no_harbor_5
						}
						else_if = {
							limit = {
								has_building = no_harbor_3
								NOT = { has_building = no_harbor_4 }
								location = {
									TECH_NAVAL = 3
									port = yes
								}
							}
							add_building = no_harbor_4
						}
						else_if = {
							limit = {
								has_building = no_harbor_2
								NOT = { has_building = no_harbor_3 }
								location = {
									TECH_NAVAL = 2
									port = yes
								}
							}
							add_building = no_harbor_3
						}
						else_if = {
							limit = {
								has_building = no_harbor_1
								NOT = { has_building = no_harbor_2 }
								location = {
									TECH_NAVAL = 1
									port = yes
								}
							}
							add_building = no_harbor_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_harbor_1 }
								location = {
									TECH_NAVAL = 0
									port = yes
								}
							}
							add_building = no_harbor_1
						}
					}
					if = { #Fishing Village
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_fishing_village_7
								NOT = { has_building = no_fishing_village_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_8
						}
						else_if = {
							limit = {
								has_building = no_fishing_village_6
								NOT = { has_building = no_fishing_village_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_7
						}
						else_if = {
							limit = {
								has_building = no_fishing_village_5
								NOT = { has_building = no_fishing_village_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_6
						}
						else_if = {
							limit = {
								has_building = no_fishing_village_4
								NOT = { has_building = no_fishing_village_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_5
						}
						else_if = {
							limit = {
								has_building = no_fishing_village_3
								NOT = { has_building = no_fishing_village_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_4
						}
						else_if = {
							limit = {
								has_building = no_fishing_village_2
								NOT = { has_building = no_fishing_village_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_3
						}
						else_if = {
							limit = {
								has_building = no_fishing_village_1
								NOT = { has_building = no_fishing_village_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_fishing_village_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
									OR = {
										port = yes
										borders_major_river = yes
										borders_lake = yes
									}
								}
							}
							add_building = no_fishing_village_1
						}
					}
					if = { #Composite Bow Crafter
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_composite_bow_crafter_7
								NOT = { has_building = no_composite_bow_crafter_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 7
								}
							}
							add_building = no_composite_bow_crafter_8
						}
						else_if = {
							limit = {
								has_building = no_composite_bow_crafter_6
								NOT = { has_building = no_composite_bow_crafter_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
								}
							}
							add_building = no_composite_bow_crafter_7
						}
						else_if = {
							limit = {
								has_building = no_composite_bow_crafter_5
								NOT = { has_building = no_composite_bow_crafter_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
								}
							}
							add_building = no_composite_bow_crafter_6
						}
						else_if = {
							limit = {
								has_building = no_composite_bow_crafter_4
								NOT = { has_building = no_composite_bow_crafter_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
								}
							}
							add_building = no_composite_bow_crafter_5
						}
						else_if = {
							limit = {
								has_building = no_composite_bow_crafter_3
								NOT = { has_building = no_composite_bow_crafter_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
								}
							}
							add_building = no_composite_bow_crafter_4
						}
						else_if = {
							limit = {
								has_building = no_composite_bow_crafter_2
								NOT = { has_building = no_composite_bow_crafter_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_composite_bow_crafter_3
						}
						else_if = {
							limit = {
								has_building = no_composite_bow_crafter_1
								NOT = { has_building = no_composite_bow_crafter_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_composite_bow_crafter_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_composite_bow_crafter_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_composite_bow_crafter_1
						}
					}
					if = { #Lamellar Armor Crafter
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_lamellar_armor_crafter_7
								NOT = { has_building = no_lamellar_armor_crafter_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
								}
							}
							add_building = no_lamellar_armor_crafter_8
						}
						else_if = {
							limit = {
								has_building = no_lamellar_armor_crafter_6
								NOT = { has_building = no_lamellar_armor_crafter_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
								}
							}
							add_building = no_lamellar_armor_crafter_7
						}
						else_if = {
							limit = {
								has_building = no_lamellar_armor_crafter_5
								NOT = { has_building = no_lamellar_armor_crafter_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
								}
							}
							add_building = no_lamellar_armor_crafter_6
						}
						else_if = {
							limit = {
								has_building = no_lamellar_armor_crafter_4
								NOT = { has_building = no_lamellar_armor_crafter_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
								}
							}
							add_building = no_lamellar_armor_crafter_5
						}
						else_if = {
							limit = {
								has_building = no_lamellar_armor_crafter_3
								NOT = { has_building = no_lamellar_armor_crafter_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
								}
							}
							add_building = no_lamellar_armor_crafter_4
						}
						else_if = {
							limit = {
								has_building = no_lamellar_armor_crafter_2
								NOT = { has_building = no_lamellar_armor_crafter_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_lamellar_armor_crafter_3
						}
						else_if = {
							limit = {
								has_building = no_lamellar_armor_crafter_1
								NOT = { has_building = no_lamellar_armor_crafter_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
								}
							}
							add_building = no_lamellar_armor_crafter_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_lamellar_armor_crafter_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = no_lamellar_armor_crafter_1
						}
					}
					if = { #Minority Shrine
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_minority_shrine_7
								NOT = { has_building = no_minority_shrine_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = no_minority_shrine_8
						}
						else_if = {
							limit = {
								has_building = no_minority_shrine_6
								NOT = { has_building = no_minority_shrine_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_minority_shrine_7
						}
						else_if = {
							limit = {
								has_building = no_minority_shrine_5
								NOT = { has_building = no_minority_shrine_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_minority_shrine_6
						}
						else_if = {
							limit = {
								has_building = no_minority_shrine_4
								NOT = { has_building = no_minority_shrine_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_minority_shrine_5
						}
						else_if = {
							limit = {
								has_building = no_minority_shrine_3
								NOT = { has_building = no_minority_shrine_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_minority_shrine_4
						}
						else_if = {
							limit = {
								has_building = no_minority_shrine_2
								NOT = { has_building = no_minority_shrine_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_minority_shrine_3
						}
						else_if = {
							limit = {
								has_building = no_minority_shrine_1
								NOT = { has_building = no_minority_shrine_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_minority_shrine_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_minority_shrine_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_minority_shrine_1
						}
					}
					if = { #Clan Gathering Hall
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_gathering_hall_7
								NOT = { has_building = no_gathering_hall_8 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = no_gathering_hall_8
						}
						else_if = {
							limit = {
								has_building = no_gathering_hall_6
								NOT = { has_building = no_gathering_hall_7 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = no_gathering_hall_7
						}
						else_if = {
							limit = {
								has_building = no_gathering_hall_5
								NOT = { has_building = no_gathering_hall_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_gathering_hall_6
						}
						else_if = {
							limit = {
								has_building = no_gathering_hall_4
								NOT = { has_building = no_gathering_hall_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = no_gathering_hall_5
						}
						else_if = {
							limit = {
								has_building = no_gathering_hall_3
								NOT = { has_building = no_gathering_hall_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_gathering_hall_4
						}
						else_if = {
							limit = {
								has_building = no_gathering_hall_2
								NOT = { has_building = no_gathering_hall_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = no_gathering_hall_3
						}
						else_if = {
							limit = {
								has_building = no_gathering_hall_1
								NOT = { has_building = no_gathering_hall_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_gathering_hall_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_gathering_hall_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = no_gathering_hall_1
						}
					}
					if = { #Minter
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_minter_7
								NOT = { has_building = no_minter_8 }
								location = {
									TECH_TRADE_PRACTICES = 6
									has_trade_post = yes
								}
							}
							add_building = no_minter_8
						}
						else_if = {
							limit = {
								has_building = no_minter_6
								NOT = { has_building = no_minter_7 }
								location = {
									TECH_TRADE_PRACTICES = 5
									has_trade_post = yes
								}
							}
							add_building = no_minter_7
						}
						else_if = {
							limit = {
								has_building = no_minter_5
								NOT = { has_building = no_minter_6 }
								location = {
									TECH_TRADE_PRACTICES = 4
									has_trade_post = yes
								}
							}
							add_building = no_minter_6
						}
						else_if = {
							limit = {
								has_building = no_minter_4
								NOT = { has_building = no_minter_5 }
								location = {
									TECH_TRADE_PRACTICES = 3
									has_trade_post = yes
								}
							}
							add_building = no_minter_5
						}
						else_if = {
							limit = {
								has_building = no_minter_3
								NOT = { has_building = no_minter_4 }
								location = {
									TECH_TRADE_PRACTICES = 2
									has_trade_post = yes
								}
							}
							add_building = no_minter_4
						}
						else_if = {
							limit = {
								has_building = no_minter_2
								NOT = { has_building = no_minter_3 }
								location = {
									TECH_TRADE_PRACTICES = 2
									has_trade_post = yes
								}
							}
							add_building = no_minter_3
						}
						else_if = {
							limit = {
								has_building = no_minter_1
								NOT = { has_building = no_minter_2 }
								location = {
									TECH_TRADE_PRACTICES = 1
									has_trade_post = yes
								}
							}
							add_building = no_minter_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_minter_1 }
								location = {
									TECH_TRADE_PRACTICES = 1
									has_trade_post = yes
								}
							}
							add_building = no_minter_1
						}
					}
					if = { #Camp Fortifications
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_camp_fortifications_7
								NOT = { has_building = no_camp_fortifications_8 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 5
								}
							}
							add_building = no_camp_fortifications_8
						}
						else_if = {
							limit = {
								has_building = no_camp_fortifications_6
								NOT = { has_building = no_camp_fortifications_7 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 4
								}
							}
							add_building = no_camp_fortifications_7
						}
						else_if = {
							limit = {
								has_building = no_camp_fortifications_5
								NOT = { has_building = no_camp_fortifications_6 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 3
								}
							}
							add_building = no_camp_fortifications_6
						}
						else_if = {
							limit = {
								has_building = no_camp_fortifications_4
								NOT = { has_building = no_camp_fortifications_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = no_camp_fortifications_5
						}
						else_if = {
							limit = {
								has_building = no_camp_fortifications_3
								NOT = { has_building = no_camp_fortifications_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 1
								}
							}
							add_building = no_camp_fortifications_4
						}
						else_if = {
							limit = {
								has_building = no_camp_fortifications_2
								NOT = { has_building = no_camp_fortifications_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 1
								}
							}
							add_building = no_camp_fortifications_3
						}
						else_if = {
							limit = {
								has_building = no_camp_fortifications_1
								NOT = { has_building = no_camp_fortifications_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = no_camp_fortifications_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_camp_fortifications_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = no_camp_fortifications_1
						}
					}
					if = { #Camel Breeder
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_camel_breeder_7
								NOT = { has_building = no_camel_breeder_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
									terrain = desert
								}
							}
							add_building = no_camel_breeder_8
						}
						else_if = {
							limit = {
								has_building = no_camel_breeder_6
								NOT = { has_building = no_camel_breeder_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
									terrain = desert
								}
							}
							add_building = no_camel_breeder_7
						}
						else_if = {
							limit = {
								has_building = no_camel_breeder_5
								NOT = { has_building = no_camel_breeder_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									terrain = desert
								}
							}
							add_building = no_camel_breeder_6
						}
						else_if = {
							limit = {
								has_building = no_camel_breeder_4
								NOT = { has_building = no_camel_breeder_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
									terrain = desert
								}
							}
							add_building = no_camel_breeder_5
						}
						else_if = {
							limit = {
								has_building = no_camel_breeder_3
								NOT = { has_building = no_camel_breeder_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									terrain = desert
								}
							}
							add_building = no_camel_breeder_4
						}
						else_if = {
							limit = {
								has_building = no_camel_breeder_2
								NOT = { has_building = no_camel_breeder_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									terrain = desert
								}
							}
							add_building = no_camel_breeder_3
						}
						else_if = {
							limit = {
								has_building = no_camel_breeder_1
								NOT = { has_building = no_camel_breeder_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									terrain = desert
								}
							}
							add_building = no_camel_breeder_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_camel_breeder_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = desert
								}
							}
							add_building = no_camel_breeder_1
						}
					}
					if = { #Elephant Camp
						limit = { holding_type = nomad }
						if = {
							limit = {
								has_building = no_elephant_camp_7
								NOT = { has_building = no_elephant_camp_8 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 6
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_8
						}
						else_if = {
							limit = {
								has_building = no_elephant_camp_6
								NOT = { has_building = no_elephant_camp_7 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 5
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_7
						}
						else_if = {
							limit = {
								has_building = no_elephant_camp_5
								NOT = { has_building = no_elephant_camp_6 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 4
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_6
						}
						else_if = {
							limit = {
								has_building = no_elephant_camp_4
								NOT = { has_building = no_elephant_camp_5 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 3
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_5
						}
						else_if = {
							limit = {
								has_building = no_elephant_camp_3
								NOT = { has_building = no_elephant_camp_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 2
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_4
						}
						else_if = {
							limit = {
								has_building = no_elephant_camp_2
								NOT = { has_building = no_elephant_camp_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_3
						}
						else_if = {
							limit = {
								has_building = no_elephant_camp_1
								NOT = { has_building = no_elephant_camp_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 1
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_2
						}
						else_if = {
							limit = {
								NOT = { has_building = no_elephant_camp_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
									terrain = jungle
								}
							}
							add_building = no_elephant_camp_1
						}
					}
#####################CITY#####################
					if = { #Some sort of wall, I guess?
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_wall_q_4
								NOT = { has_building = ct_wall_q_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 7
								}
							}
							add_building = ct_wall_q_5
						}
						else_if = {
							limit = {
								has_building = ct_wall_q_3
								NOT = { has_building = ct_wall_q_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 5
								}
							}
							add_building = ct_wall_q_4
						}
						else_if = {
							limit = {
								has_building = ct_wall_q_2
								NOT = { has_building = ct_wall_q_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 3
								}
							}
							add_building = ct_wall_q_3
						}
						else_if = {
							limit = {
								has_building = ct_wall_q_1
								has_building = ct_wall_2
								NOT = { has_building = ct_wall_q_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 1
								}
							}
							add_building = ct_wall_q_2
						}
						else_if = {
							limit = {
								has_building = ct_wall_1
								NOT = { has_building = ct_wall_q_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = ct_wall_q_1
						}
					}
					if = { #Some sort of wall, I guess? Some More Walls then.
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_wall_4
								NOT = { has_building = ct_wall_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 8
								}
							}
							add_building = ct_wall_5
						}
						else_if = {
							limit = {
								has_building = ct_wall_3
								NOT = { has_building = ct_wall_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 6
								}
							}
							add_building = ct_wall_4
						}
						else_if = {
							limit = {
								has_building = ct_wall_2
								NOT = { has_building = ct_wall_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 4
								}
							}
							add_building = ct_wall_3
						}
						else_if = {
							limit = {
								has_building = ct_wall_1
								NOT = { has_building = ct_wall_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = ct_wall_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_wall_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = ct_wall_1
						}
					}
					if = { #Merchant Republic Arsenal
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_rep_arsenal_2
								NOT = { has_building = ct_rep_arsenal_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
								}
							}
							add_building = ct_rep_arsenal_3
						}
						else_if = {
							limit = {
								has_building = ct_rep_arsenal_1
								NOT = { has_building = ct_rep_arsenal_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = ct_rep_arsenal_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_rep_arsenal_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_rep_arsenal_1
						}
					}
					if = { #Militia Training Grounds
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_training_grounds_5
								NOT = { has_building = ct_training_grounds_6 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 8
								}
							}
							add_building = ct_training_grounds_6
						}
						else_if = {
							limit = {
								has_building = ct_training_grounds_4
								NOT = { has_building = ct_training_grounds_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 6
								}
							}
							add_building = ct_training_grounds_5
						}
						else_if = {
							limit = {
								has_building = ct_training_grounds_3
								NOT = { has_building = ct_training_grounds_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 4
								}
							}
							add_building = ct_training_grounds_4
						}
						else_if = {
							limit = {
								has_building = ct_training_grounds_2
								NOT = { has_building = ct_training_grounds_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = ct_training_grounds_3
						}
						else_if = {
							limit = {
								has_building = ct_training_grounds_1
								NOT = { has_building = ct_training_grounds_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = ct_training_grounds_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_training_grounds_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = ct_training_grounds_1
						}
					}
					if = { #Barracks
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_barracks_5
								NOT = { has_building = ct_barracks_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
								}
							}
							add_building = ct_barracks_6
						}
						else_if = {
							limit = {
								has_building = ct_barracks_4
								NOT = { has_building = ct_barracks_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = ct_barracks_5
						}
						else_if = {
							limit = {
								has_building = ct_barracks_3
								NOT = { has_building = ct_barracks_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = ct_barracks_4
						}
						else_if = {
							limit = {
								has_building = ct_barracks_2
								has_building = ct_wall_2
								NOT = { has_building = ct_barracks_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = ct_barracks_3
						}
						else_if = {
							limit = {
								has_building = ct_barracks_1
								has_building = ct_wall_1
								NOT = { has_building = ct_barracks_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_barracks_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_barracks_1
						}
					}
					if = { #Guard
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_guard_4
								NOT = { has_building = ct_guard_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
								}
							}
							add_building = ct_guard_5
						}
						else_if = {
							limit = {
								has_building = ct_guard_3
								NOT = { has_building = ct_guard_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = ct_guard_4
						}
						else_if = {
							limit = {
								has_building = ct_guard_2
								has_building = ct_wall_2
								NOT = { has_building = ct_guard_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = ct_guard_3
						}
						else_if = {
							limit = {
								has_building = ct_guard_1
								has_building = ct_wall_1
								NOT = { has_building = ct_guard_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_guard_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_guard_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_guard_1
						}
					}
					if = { #Marketplace
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_marketplace_5
								NOT = { has_building = ct_marketplace_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
								}
							}
							add_building = ct_marketplace_6
						}
						else_if = {
							limit = {
								has_building = ct_marketplace_4
								NOT = { has_building = ct_marketplace_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = ct_marketplace_5
						}
						else_if = {
							limit = {
								has_building = ct_marketplace_3
								NOT = { has_building = ct_marketplace_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = ct_marketplace_4
						}
						else_if = {
							limit = {
								has_building = ct_marketplace_2
								has_building = ct_wall_2
								NOT = { has_building = ct_marketplace_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = ct_marketplace_3
						}
						else_if = {
							limit = {
								has_building = ct_marketplace_1
								has_building = ct_wall_1
								NOT = { has_building = ct_marketplace_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_marketplace_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_marketplace_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = ct_marketplace_1
						}
					}
					if = { #Port
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_port_4
								NOT = { has_building = ct_port_5 }
								location = {
									TECH_TRADE_PRACTICES = 6
									port = yes
								}
							}
							add_building = ct_port_5
						}
						else_if = {
							limit = {
								has_building = ct_port_3
								NOT = { has_building = ct_port_4 }
								location = {
									TECH_TRADE_PRACTICES = 4
									port = yes
								}
							}
							add_building = ct_port_4
						}
						else_if = {
							limit = {
								has_building = ct_port_2
								has_building = ct_wall_2
								NOT = { has_building = ct_port_3 }
								location = {
									TECH_TRADE_PRACTICES = 3
									port = yes
								}
							}
							add_building = ct_port_3
						}
						else_if = {
							limit = {
								has_building = ct_port_1
								has_building = ct_wall_1
								NOT = { has_building = ct_port_2 }
								location = {
									TECH_TRADE_PRACTICES = 1
									port = yes
								}
							}
							add_building = ct_port_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_port_1 }
								location = {
									TECH_TRADE_PRACTICES = 0
									port = yes
								}
							}
							add_building = ct_port_1
						}
					}
					if = { #Shipyards
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_shipyard_3
								NOT = { has_building = ct_shipyard_4 }
								location = {
									TECH_NAVAL = 4
									port = yes
								}
							}
							add_building = ct_shipyard_4
						}
						else_if = {
							limit = {
								has_building = ct_shipyard_2
								NOT = { has_building = ct_shipyard_3 }
								location = {
									TECH_NAVAL = 3
									port = yes
								}
							}
							add_building = ct_shipyard_3
						}
						else_if = {
							limit = {
								has_building = ct_shipyard_1
								NOT = { has_building = ct_shipyard_2 }
								location = {
									TECH_NAVAL = 2
									port = yes
								}
							}
							add_building = ct_shipyard_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_shipyard_1 }
								location = {
									TECH_NAVAL = 1
									port = yes
								}
							}
							add_building = ct_shipyard_1
						}
					}
					if = { #University
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_university_2
								NOT = { has_building = ct_university_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 8
								}
							}
							add_building = ct_university_3
						}
						else_if = {
							limit = {
								has_building = ct_university_1
								NOT = { has_building = ct_university_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = ct_university_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_university_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = ct_university_1
						}
					}
					if = { #Architect Bloodline buildings
						limit = { holding_type = city }
						if = {
							limit = {
								has_building = ct_planned_infrastructure_3
								NOT = { has_building = ct_planned_infrastructure_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
									custom_tooltip = {
										text = tooltip_has_architect_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
													has_bloodline_flag = bloodline_architect 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_architect 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ct_planned_infrastructure_4
						}
						else_if = {
							limit = {
								has_building = ct_planned_infrastructure_2
								NOT = { has_building = ct_planned_infrastructure_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
									custom_tooltip = {
										text = tooltip_has_architect_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
													has_bloodline_flag = bloodline_architect 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_architect 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ct_planned_infrastructure_3
						}
						else_if = {
							limit = {
								has_building = ct_planned_infrastructure_1
								NOT = { has_building = ct_planned_infrastructure_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
									custom_tooltip = {
										text = tooltip_has_architect_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
													has_bloodline_flag = bloodline_architect 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_architect 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ct_planned_infrastructure_2
						}
						else_if = {
							limit = {
								NOT = { has_building = ct_planned_infrastructure_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
									custom_tooltip = {
										text = tooltip_has_architect_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
													has_bloodline_flag = bloodline_architect 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_architect 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = ct_planned_infrastructure_1
						}
					}
#####################TEMPLES#####################
					if = { #Some cool walls
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_wall_q_4
								NOT = { has_building = tp_wall_q_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 7
								}
							}
							add_building = tp_wall_q_5
						}
						else_if = {
							limit = {
								has_building = tp_wall_q_3
								NOT = { has_building = tp_wall_q_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 5
								}
							}
							add_building = tp_wall_q_4
						}
						else_if = {
							limit = {
								has_building = tp_wall_q_2
								NOT = { has_building = tp_wall_q_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 3
								}
							}
							add_building = tp_wall_q_3
						}
						else_if = {
							limit = {
								has_building = tp_wall_q_1
								has_building = tp_wall_2
								NOT = { has_building = tp_wall_q_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 1
								}
							}
							add_building = tp_wall_q_2
						}
						else_if = {
							limit = {
								has_building = tp_wall_1
								NOT = { has_building = tp_wall_q_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tp_wall_q_1
						}
					}
					if = { #Some cool walls, except it's more walls
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_wall_4
								NOT = { has_building = tp_wall_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 8
								}
							}
							add_building = tp_wall_5
						}
						else_if = {
							limit = {
								has_building = tp_wall_3
								NOT = { has_building = tp_wall_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 6
								}
							}
							add_building = tp_wall_4
						}
						else_if = {
							limit = {
								has_building = tp_wall_2
								NOT = { has_building = tp_wall_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 4
								}
							}
							add_building = tp_wall_3
						}
						else_if = {
							limit = {
								has_building = tp_wall_1
								NOT = { has_building = tp_wall_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = tp_wall_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_wall_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tp_wall_1
						}
					}
					if = { #Monastery
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_monastery_5
								NOT = { has_building = tp_monastery_6 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 8
								}
							}
							add_building = tp_monastery_6
						}
						else_if = {
							limit = {
								has_building = tp_monastery_4
								NOT = { has_building = tp_monastery_5 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 6
								}
							}
							add_building = tp_monastery_5
						}
						else_if = {
							limit = {
								has_building = tp_monastery_3
								NOT = { has_building = tp_monastery_4 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 4
								}
							}
							add_building = tp_monastery_4
						}
						else_if = {
							limit = {
								has_building = tp_monastery_2
								NOT = { has_building = tp_monastery_3 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 2
								}
							}
							add_building = tp_monastery_3
						}
						else_if = {
							limit = {
								has_building = tp_monastery_1
								has_building = tp_wall_1
								NOT = { has_building = tp_monastery_2 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tp_monastery_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_monastery_1 }
								location = {
									TECH_FORTIFICATIONS_CONSTRUCTION = 0
								}
							}
							add_building = tp_monastery_1
						}
					}
					if = { #Barracks
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_barracks_5
								NOT = { has_building = tp_barracks_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
								}
							}
							add_building = tp_barracks_6
						}
						else_if = {
							limit = {
								has_building = tp_barracks_4
								NOT = { has_building = tp_barracks_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = tp_barracks_5
						}
						else_if = {
							limit = {
								has_building = tp_barracks_3
								NOT = { has_building = tp_barracks_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = tp_barracks_4
						}
						else_if = {
							limit = {
								has_building = tp_barracks_2
								has_building = tp_wall_2
								NOT = { has_building = tp_barracks_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = tp_barracks_3
						}
						else_if = {
							limit = {
								has_building = tp_barracks_1
								has_building = tp_wall_1
								NOT = { has_building = tp_barracks_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = tp_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_barracks_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = tp_barracks_1
						}
					}
					if = { #Elite Barracks
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_elite_barracks_5
								NOT = { has_building = tp_elite_barracks_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 8
								}
							}
							add_building = tp_elite_barracks_6
						}
						else_if = {
							limit = {
								has_building = tp_elite_barracks_4
								NOT = { has_building = tp_elite_barracks_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 6
								}
							}
							add_building = tp_elite_barracks_5
						}
						else_if = {
							limit = {
								has_building = tp_elite_barracks_3
								NOT = { has_building = tp_elite_barracks_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 4
								}
							}
							add_building = tp_elite_barracks_4
						}
						else_if = {
							limit = {
								has_building = tp_elite_barracks_2
								has_building = tp_wall_2
								NOT = { has_building = tp_elite_barracks_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 2
								}
							}
							add_building = tp_elite_barracks_3
						}
						else_if = {
							limit = {
								has_building = tp_elite_barracks_1
								has_building = tp_wall_1
								NOT = { has_building = tp_elite_barracks_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = tp_elite_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_elite_barracks_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = tp_elite_barracks_1
						}
					}
					if = { #Town
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_town_5
								NOT = { has_building = tp_town_6 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
								}
							}
							add_building = tp_town_6
						}
						else_if = {
							limit = {
								has_building = tp_town_4
								NOT = { has_building = tp_town_5 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
								}
							}
							add_building = tp_town_5
						}
						else_if = {
							limit = {
								has_building = tp_town_3
								NOT = { has_building = tp_town_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = tp_town_4
						}
						else_if = {
							limit = {
								has_building = tp_town_2
								has_building = tp_wall_2
								NOT = { has_building = tp_town_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
								}
							}
							add_building = tp_town_3
						}
						else_if = {
							limit = {
								has_building = tp_town_1
								has_building = tp_wall_1
								NOT = { has_building = tp_town_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = tp_town_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_town_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 0
								}
							}
							add_building = tp_town_1
						}
					}
					if = { #Shipyards
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_shipyard_3
								NOT = { has_building = tp_shipyard_4 }
								location = {
									TECH_NAVAL = 4
									port = yes
								}
							}
							add_building = tp_shipyard_4
						}
						else_if = {
							limit = {
								has_building = tp_shipyard_2
								NOT = { has_building = tp_shipyard_3 }
								location = {
									TECH_NAVAL = 3
									port = yes
								}
							}
							add_building = tp_shipyard_3
						}
						else_if = {
							limit = {
								has_building = tp_shipyard_1
								NOT = { has_building = tp_shipyard_2 }
								location = {
									TECH_NAVAL = 2
									port = yes
								}
							}
							add_building = tp_shipyard_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_shipyard_1 }
								location = {
									TECH_NAVAL = 1
									port = yes
								}
							}
							add_building = tp_shipyard_1
						}
					}
					if = { #School
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_school_1
								has_building = tp_wall_2
								NOT = { has_building = tp_school_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 6
								}
							}
							add_building = tp_school_2
						}
						else_if = {
							limit = {
								has_building = tp_wall_1
								NOT = { has_building = tp_school_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
								}
							}
							add_building = tp_school_1
						}
					}
					if = { #Monumental Bloodline buildings
						limit = { holding_type = temple }
						if = {
							limit = {
								has_building = tp_monumental_shrines_3
								NOT = { has_building = tp_monumental_shrines_4 }
								location = {
									TECH_CITY_CONSTRUCTION = 7
									custom_tooltip = {
										text = tooltip_has_monumental_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_monumental 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_monumental 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = tp_monumental_shrines_4
						}
						else_if = {
							limit = {
								has_building = tp_monumental_shrines_2
								NOT = { has_building = tp_monumental_shrines_3 }
								location = {
									TECH_CITY_CONSTRUCTION = 5
									custom_tooltip = {
										text = tooltip_has_monumental_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_monumental 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_monumental 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = tp_monumental_shrines_3
						}
						else_if = {
							limit = {
								has_building = tp_monumental_shrines_1
								NOT = { has_building = tp_monumental_shrines_2 }
								location = {
									TECH_CITY_CONSTRUCTION = 3
									custom_tooltip = {
										text = tooltip_has_monumental_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_monumental 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_monumental 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = tp_monumental_shrines_2
						}
						else_if = {
							limit = {
								NOT = { has_building = tp_monumental_shrines_1 }
								location = {
									TECH_CITY_CONSTRUCTION = 1
									custom_tooltip = {
										text = tooltip_has_monumental_bloodline
										hidden_tooltip = {
											OR = {
												FROM = {
													any_owned_bloodline = {
														has_bloodline_flag = bloodline_monumental 
													}
												}
												FROM = {
													any_liege = {
														any_owned_bloodline = {
															has_bloodline_flag = bloodline_monumental 
														}	
													}
												}
											}
										}
									}
								}
							}
							add_building = tp_monumental_shrines_1
						}
					}
#####################FAMILY PALACE#####################
					if = { #Mansion
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_mansion_3
								NOT = { has_building = fp_mansion_4 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_mansion_4
						}
						else_if = {
							limit = {
								has_building = fp_mansion_2
								NOT = { has_building = fp_mansion_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_mansion_3
						}
						else_if = {
							limit = {
								has_building = fp_mansion_1
								NOT = { has_building = fp_mansion_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_mansion_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_mansion_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_mansion_1
						}
					}
					if = { #Barracks
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_barracks_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_barracks_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_barracks_3
						}
						else_if = {
							limit = {
								has_building = fp_barracks_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_barracks_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_barracks_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_barracks_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_barracks_1
						}
					}
					if = { #Stables
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_stable_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_stable_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_stable_3
						}
						else_if = {
							limit = {
								has_building = fp_stable_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_stable_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_stable_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_stable_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_stable_1
						}
					}
					if = { #Stables
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_bowyer_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_bowyer_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_bowyer_3
						}
						else_if = {
							limit = {
								has_building = fp_bowyer_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_bowyer_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_bowyer_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_bowyer_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_bowyer_1
						}
					}
					if = { #Shipyards
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_shipyard_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_shipyard_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_shipyard_3
						}
						else_if = {
							limit = {
								has_building = fp_shipyard_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_shipyard_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_shipyard_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_shipyard_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_shipyard_1
						}
					}
					if = { #Warehouse
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_warehouse_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_warehouse_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_warehouse_3
						}
						else_if = {
							limit = {
								has_building = fp_warehouse_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_warehouse_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_warehouse_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_warehouse_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_warehouse_1
						}
					}
					if = { #Garden
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_garden_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_garden_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_garden_3
						}
						else_if = {
							limit = {
								has_building = fp_garden_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_garden_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_garden_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_garden_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_garden_1
						}
					}
					if = { #Wine Cellar
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_cellar_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_cellar_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_cellar_3
						}
						else_if = {
							limit = {
								has_building = fp_cellar_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_cellar_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_cellar_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_cellar_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_cellar_1
						}
					}
					if = { #Shrine
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_shrine_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_shrine_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_shrine_3
						}
						else_if = {
							limit = {
								has_building = fp_shrine_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_shrine_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_shrine_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_shrine_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_shrine_1
						}
					}
					if = { #Vault
						limit = { holding_type = family_palace }
						if = {
							limit = {
								has_building = fp_vault_2
								has_building = fp_mansion_3
								NOT = { has_building = fp_vault_3 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_vault_3
						}
						else_if = {
							limit = {
								has_building = fp_vault_1
								has_building = fp_mansion_2
								NOT = { has_building = fp_vault_2 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_vault_2
						}
						else_if = {
							limit = {
								NOT = { has_building = fp_vault_1 }
								location = {
									TECH_CASTLE_CONSTRUCTION = 0
								}
							}
							add_building = fp_vault_1
						}
					}
				}
			}
		}
	}
}