#scmr_build_castle_tech	按科技建造城堡建筑
#scmr_build_temple_tech	按科技建造寺庙建筑
#scmr_build_city_tech	按科技建造城市建筑
#scmr_build_tb_tech		按科技建造部落建筑
#scmr_build_nd_tech		按科技建造游牧建筑
#scmr_build_hp_tech		按科技建造医院建筑
#scmr_build_tr_tech		按科技建造贸易站建筑


scmr_build_castle_tech = {
	if = {
		limit = {
			not = {
				has_building = ca_wall_q_1
			}
		}
		add_building = ca_wall_q_1
	}
	if = {
		limit = {
			not = {
				has_building = ca_wall_q_2
			}
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 1
			}
		}
		add_building = ca_wall_q_2
	}
	if = {
		limit = {
			not = {
				has_building = ca_wall_q_3
			}
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 3
			}
		}
		add_building = ca_wall_q_3
	}
	if = {
		limit = {
			not = {
				has_building = ca_wall_q_4
			}
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 5
			}
		}
		add_building = ca_wall_q_4
	}
	if = {
		limit = {
			not = {
				has_building = ca_wall_q_5
			}
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 7
			}
		}
		add_building = ca_wall_q_5
	}
	if = {
		limit = {
			not = {
				has_building = ca_wall_1
			}
		}
		add_building = ca_wall_1
	}
	if = {
		limit = {
			not = {
				has_building = ca_wall_2
			}
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
		add_building = ca_wall_2
	}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_wall_3
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 4
		}
	}
	add_building = ca_wall_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_wall_4
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 6
		}
	}
	add_building = ca_wall_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_wall_5
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 8
		}
	}
	add_building = ca_wall_5
					}
					if =
					{
	limit = 
	{
		title = b_constantinople
		not = {
			has_building = ca_con_wall_6
		}
	}
	add_building = ca_con_wall_6
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_keep_1
		}
	}
	add_building = ca_keep_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_keep_2
		}
	}
	add_building = ca_keep_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_keep_3
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
	}
	add_building = ca_keep_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_keep_4
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 4
		}
	}
	add_building = ca_keep_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_keep_5
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 6
		}
	}
	add_building = ca_keep_5
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_keep_6
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 8
		}
	}
	add_building = ca_keep_6
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_militia_barracks_1
		}
	}
	add_building = ca_militia_barracks_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_militia_barracks_2
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 1
		}
	}
	add_building = ca_militia_barracks_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_militia_barracks_3
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 5
		}
	}
	add_building = ca_militia_barracks_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_militia_barracks_4
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 7
		}
	}
	add_building = ca_militia_barracks_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_training_grounds_1
		}
		or = {
			has_building = ca_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ca_training_grounds_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_training_grounds_2
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 3
		}
		or = {
			has_building = ca_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ca_training_grounds_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_training_grounds_3
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 6
		}
		or = {
			has_building = ca_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ca_training_grounds_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_town_1
		}
	}
	add_building = ca_town_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_town_2
		}
	}
	add_building = ca_town_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_town_3
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 2
		}
		or = {
			has_building = ca_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ca_town_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_town_4
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 4
		}
		or = {
			has_building = ca_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ca_town_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ca_town_5
		}
		location = {
			TECH_CASTLE_CONSTRUCTION = 6
		}
		or = {
			has_building = ca_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ca_town_5
					}
					if =
					{
	limit =
	{
		location = {
			terrain = steppe
		}
		holder_scope = {
			or = {
				culture_group = altaic
				culture_group = magyar
				culture = alan
				culture_group = iranian
			}
		}
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_1
			}
		}
		add_building = ca_steppe_barracks_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_2
			}
		}
		add_building = ca_steppe_barracks_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_3
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_barracks_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_4
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 1
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_barracks_4
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_5
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 3
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_barracks_5
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_6
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 5
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_barracks_6
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_1
			}
		}
		add_building = ca_steppe_stable_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_2
			}
		}
		add_building = ca_steppe_stable_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_3
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 2
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_stable_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_4
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 4
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_stable_4
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_5
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 6
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_stable_5
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_6
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 8
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_steppe_stable_6
	}
	}
	if = {
		limit = {
			location = {
				terrain = desert
			}
			holder_scope = {
				OR = {
					culture_group = east_african
					culture_group = west_african
					culture_group = arabic
				}
			}
		}
		if =
	{
		limit = {
			not = {
				has_building = ca_desert_stable_1
			}
		}
		add_building = ca_desert_stable_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_desert_stable_2
			}
		}
		add_building = ca_desert_stable_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_desert_stable_3
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 2
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_desert_stable_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_desert_stable_4
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 4
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_desert_stable_4
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_desert_stable_5
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 6
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_desert_stable_5
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_desert_stable_6
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 8
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_desert_stable_6
	}
		
	}
					if =
					{
	limit =
	{
		or = {
			not = {
				location = {
					terrain = steppe
				}
			}
			and = {
				not =  {
					holder_scope =
					{
						culture_group = altaic
					}
				}
				not = {
					holder_scope =
					{
						culture_group = magyar
					}
				}
			}
		}
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_1
				has_building = ca_barracks_1
			}
		}
		add_building = ca_barracks_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_2
				has_building = ca_barracks_2
			}
		}
		add_building = ca_barracks_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_3
				has_building = ca_barracks_3
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 1
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_barracks_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_4
				has_building = ca_barracks_4
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 3
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_barracks_4
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_5
				has_building = ca_barracks_5
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 5
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_barracks_5
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_barracks_6
				has_building = ca_barracks_6
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 7
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_barracks_6
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_1
				has_building = ca_desert_stable_1
				has_building = ca_stable_1
			}
		}
		add_building = ca_stable_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_2
				has_building = ca_desert_stable_2
				has_building = ca_stable_2
			}
		}
		add_building = ca_stable_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_3
				has_building = ca_desert_stable_3
				has_building = ca_stable_3
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 2
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_stable_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_4
				has_building = ca_desert_stable_4
				has_building = ca_stable_4
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 4
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_stable_4
	}
	if =
	{
		limit = {
			not = {
				has_building = ca_steppe_stable_5
				has_building = ca_desert_stable_5
				has_building = ca_stable_5
			}
			location = {
				TECH_CASTLE_CONSTRUCTION = 6
			}
			or = {
				has_building = ca_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ca_stable_5
	}
					}
					if =
					{
	limit =
	{
		location = {
			port = yes
		}
	}
	if = 
	{
		limit = {
			not =  {
				has_building = ca_shipyard_1
			}
			location = {
				TECH_NAVAL = 1
			}
		}
		add_building = ca_shipyard_1
	}
	if = 
	{
		limit = {
			not =  {
				has_building = ca_shipyard_2
			}
			location = {
				TECH_NAVAL = 2
			}
		}
		add_building = ca_shipyard_2
	}
	if = 
	{
		limit = {
			not =  {
				has_building = ca_shipyard_3
			}
			location = {
				TECH_NAVAL = 3
			}
		}
		add_building = ca_shipyard_3
	}
	if = 
	{
		limit = {
			not =  {
				has_building = ca_shipyard_4
			}
			location = {
				TECH_NAVAL = 4
			}
		}
		add_building = ca_shipyard_4
	}
	
	}
	
	if = {
		limit = {
			location = {
				OR = {
					culture = english
					culture = welsh
					culture = cumbric
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_saxon_english_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_saxon_english_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_saxon_english_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_saxon_english_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_saxon_english_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_saxon_english_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_saxon_english_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_saxon_english_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_saxon_english_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_saxon_english_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_saxon_english_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_saxon_english_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture = scottish
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_scottish_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_scottish_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_scottish_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_scottish_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_scottish_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_scottish_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_scottish_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_scottish_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_scottish_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_scottish_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_scottish_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_scottish_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = baltic
					culture_group = finno_ugric
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_baltic_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_baltic_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_baltic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_baltic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_baltic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_baltic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_baltic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_baltic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_baltic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_baltic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_baltic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_baltic_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = altaic
						NOT = { culture = jurchen }
					}
					culture_group = iranian
					culture_group = magyar
					culture = romanian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_altaic_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_altaic_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_altaic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_altaic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_altaic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_altaic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_altaic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_altaic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_altaic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_altaic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_altaic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_altaic_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = central_germanic
						NOR = {
							culture = dutch # SWMH only
							culture = lombard
							culture = visigothic # SWMH only
							culture = old_frankish
							culture = suebi
							culture = low_frankish
						}
					}
					AND = {
						culture_group = latin
						NOR = {
							culture = roman # Vanilla only
							culture = italian # Vanilla only
							culture = dalmatian # Vanilla only
							culture = sicilian # Vanilla only
							culture = neapolitan # Vanilla only
						}
					}
					culture = occitan
					culture = breton
					culture = cornish
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_frank_norman_german_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_frank_norman_german_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_frank_norman_german_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_frank_norman_german_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_frank_norman_german_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_frank_norman_german_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_frank_norman_german_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_frank_norman_german_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_frank_norman_german_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_frank_norman_german_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_frank_norman_german_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_frank_norman_german_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture = portuguese
					culture = galician
					culture = andalusian_arabic
					culture_group = horse_group
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_portuguese_galician_andalusian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_portuguese_galician_andalusian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_portuguese_galician_andalusian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_portuguese_galician_andalusian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_portuguese_galician_andalusian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_portuguese_galician_andalusian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_portuguese_galician_andalusian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_portuguese_galician_andalusian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_portuguese_galician_andalusian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_portuguese_galician_andalusian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_portuguese_galician_andalusian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_portuguese_galician_andalusian_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = iberian
						NOR = {
							culture = basque
							culture = andalusian_arabic # SWMH only
							culture = visigothic # Vanilla only
							culture = occitan # SWMH only
							culture = catalan
							culture = galician
							culture = portuguese
						}
					}
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_iberian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_iberian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_iberian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_iberian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_iberian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_iberian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_iberian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_iberian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_iberian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_iberian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_iberian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_iberian_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = italian_group # SWMH only
						NOR = {
							culture = ligurian
							culture = venetian
							culture = roman
						}
					}
					culture = italian
					culture = dalmatian
					culture = sicilian
					culture = neapolitan
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_italian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_italian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_italian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_italian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_italian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_italian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_italian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_italian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_italian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_italian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_italian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_italian_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = east_slavic
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_russian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_russian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_russian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_russian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_russian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_russian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_russian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_russian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_russian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_russian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_russian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_russian_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = north_germanic
						NOT = { culture = frisian } # SWMH only
					}
					AND = {
						culture_group = west_germanic
						NOR = {
							culture = english
							culture = frisian # Vanilla only
							culture = dutch # Vanilla only
						}
					}
					culture = pommeranian
					culture = norsegaelic
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_germanic_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_north_germanic_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_germanic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_north_germanic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_germanic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_north_germanic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_germanic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_north_germanic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_germanic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_north_germanic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_germanic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_north_germanic_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = west_slavic
				NOT = {
					culture = pommeranian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_hungarian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_hungarian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_hungarian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_hungarian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_hungarian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_hungarian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_hungarian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_hungarian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_hungarian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_hungarian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_hungarian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_hungarian_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = arabic
				NOT = { culture = andalusian_arabic } # Vanilla only
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_arabic_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_arabic_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_arabic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_arabic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_arabic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_arabic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_arabic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_arabic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_arabic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_arabic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_arabic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_arabic_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = north_african
				NOT = { culture = canarian }
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_african_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_north_african_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_african_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_north_african_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_african_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_north_african_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_african_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_north_african_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_african_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_north_african_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_north_african_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_north_african_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = byzantine
				NOR = {
					culture = romanian # SWMH only
					culture = arberian
					culture = assyrian # Vanilla only
					culture = coptic # Vanilla only
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_byzantine_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_byzantine_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_byzantine_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_byzantine_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_byzantine_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_byzantine_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_byzantine_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_byzantine_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_byzantine_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_byzantine_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_byzantine_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_byzantine_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture = irish
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_irish_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_irish_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_irish_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_irish_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_irish_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_irish_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_irish_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_irish_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_irish_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_irish_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_irish_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_irish_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = east_african
				NOR = {
					culture = coptic # SWMH only
					culture = daju
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_ethiopian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_ethiopian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_ethiopian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_ethiopian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_ethiopian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_ethiopian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_ethiopian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_ethiopian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_ethiopian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_ethiopian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_ethiopian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_ethiopian_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = west_african
					culture_group = central_african
					culture = daju
					culture = canarian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_west_african_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_west_african_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_west_african_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_west_african_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_west_african_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_west_african_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_west_african_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_west_african_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_west_african_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_west_african_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_west_african_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_west_african_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = south_slavic
						NOR = {
							culture = croatian
							culture = romanian # Vanilla only
						}
					}
					culture = arberian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_south_slavic_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_group_south_slavic_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_south_slavic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_group_south_slavic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_south_slavic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_group_south_slavic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_south_slavic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_group_south_slavic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_south_slavic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_group_south_slavic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_group_south_slavic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_group_south_slavic_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture = dutch
					culture = frisian
					culture = low_frankish
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_dutch_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_dutch_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_dutch_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_dutch_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_dutch_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_dutch_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_dutch_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_dutch_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_dutch_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_dutch_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_dutch_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_dutch_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = mesoamerican
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_nahuatl_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_nahuatl_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_nahuatl_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_nahuatl_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_nahuatl_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_nahuatl_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_nahuatl_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_nahuatl_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_nahuatl_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_nahuatl_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_nahuatl_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_nahuatl_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = israelite
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_jewish_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_jewish_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_jewish_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_jewish_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_jewish_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_jewish_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_jewish_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_jewish_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_jewish_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_jewish_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_jewish_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_jewish_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = indo_aryan_group
					culture_group = dravidian_group
					culture_group = elephant_group
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_indian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_indian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_indian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_indian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_indian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_indian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_indian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_indian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_indian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_indian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_indian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_indian_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture = lombard
					culture = old_frankish
					culture = visigothic
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_germanic_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_germanic_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_germanic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_germanic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_germanic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_germanic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_germanic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_germanic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_germanic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_germanic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_germanic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_germanic_5
		}
					
	}


	if = {
		limit = {
			location = {
				culture = suebi
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_suebi_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_suebi_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_suebi_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_suebi_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_suebi_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_suebi_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_suebi_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_suebi_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_suebi_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_suebi_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_suebi_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_suebi_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture = basque
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_basque_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_basque_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_basque_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_basque_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_basque_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_basque_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_basque_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_basque_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_basque_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_basque_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_basque_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_basque_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture = croatian
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_croatia_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_croatia_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_croatia_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_croatia_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_croatia_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_croatia_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_croatia_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_croatia_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_croatia_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_croatia_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_croatia_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_croatia_5
		}
					
	}

	if = {
		limit = {
			location = {
				culture = catalan
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_catalan_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_catalan_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_catalan_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_catalan_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_catalan_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_catalan_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_catalan_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_catalan_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_catalan_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_catalan_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_catalan_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_catalan_5
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = aramaic
					culture = assyrian # Vanilla only
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_culture_assyrian_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_assyrian_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_assyrian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_assyrian_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_assyrian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_assyrian_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_assyrian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_assyrian_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_assyrian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_assyrian_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_assyrian_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_assyrian_5
		}
					
	}
					
					
	if = {
		limit = {
			location = {
				culture_group = chinese_group
			}
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_chinese_han_0
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_chinese_han_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_chinese_han_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_chinese_han_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_chinese_han_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_chinese_han_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_chinese_han_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_chinese_han_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_chinese_han_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_chinese_han_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_chinese_han_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_chinese_han_5
		}
					
	}
					
	if = {
		limit = {
			location = {
				culture = jurchen
			}
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_altaic_jurchen_0
				}
			}
			add_building = ca_culture_altaic_jurchen_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_altaic_jurchen_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_altaic_jurchen_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_altaic_jurchen_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_altaic_jurchen_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_altaic_jurchen_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = ca_culture_altaic_jurchen_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_altaic_jurchen_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_altaic_jurchen_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_altaic_jurchen_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}	
			}
			add_building = ca_culture_altaic_jurchen_5
		}
					
	}
					
	if = {
		limit = {
			location = {
				culture_group = tibetan_group
			}
		}
	
		if = {
			limit = {
				not = {
					has_building = ca_culture_tibetan_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = ca_culture_tibetan_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_tibetan_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = ca_culture_tibetan_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_tibetan_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = ca_culture_tibetan_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_tibetan_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = ca_culture_tibetan_4
		}
					
	}
					
	#Holy Fury
	
	if = {
		limit = {
			location = {
				culture = coptic
			}
			holder_scope = {
				culture = coptic
			}
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_coptic_1
				}
				has_building = ca_wall_2
			}
			add_building = ca_culture_coptic_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_coptic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}
			}
			add_building = ca_culture_coptic_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_coptic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}
			}
			add_building = ca_culture_coptic_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_coptic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}
			}
			add_building = ca_culture_coptic_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_coptic_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}
			}
			add_building = ca_culture_coptic_5
		}
	}
	
	if = {
		limit = {
			location = {
				OR = { 
					culture_group = horse_group 
					culture_group = cat_group 
					culture_group = bear_group 
					culture_group = hedgehog_group 
					culture_group = duck_group 
					culture_group = dog_group 
					culture_group = elephant_group 
					culture_group = dragon_group 
				}
			}
			holder_scope = {
				OR = { 
					culture_group = horse_group 
					culture_group = cat_group 
					culture_group = bear_group 
					culture_group = hedgehog_group 
					culture_group = duck_group 
					culture_group = dog_group 
					culture_group = elephant_group 
					culture_group = dragon_group 
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_animal_0
				}
			}
			add_building = ca_culture_animal_0
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_animal_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}
			}
			add_building = ca_culture_animal_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_animal_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}
			}
			add_building = ca_culture_animal_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_animal_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}
			}
			add_building = ca_culture_animal_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_animal_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}
			}
			add_building = ca_culture_animal_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_culture_animal_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}
			}
			add_building = ca_culture_animal_5
		}
	}				
	if = {
		limit = {
			location = {
				terrain = steppe
				emf_province_is_steppe_culture = yes
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = ca_steppe_barracks_1
				}
			}
			add_building = ca_steppe_barracks_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_barracks_2
				}
				has_building = ca_wall_1
			}
			add_building = ca_steppe_barracks_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_barracks_3
				}
				has_building = ca_wall_2
			}
			add_building = ca_steppe_barracks_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_barracks_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}
			}
			add_building = ca_steppe_barracks_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_barracks_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}
			}
			add_building = ca_steppe_barracks_5
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_barracks_6
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 5
				}
			}
			add_building = ca_steppe_barracks_6
		}
	}
					
	if = {
		limit = {
			location = {
				terrain = steppe
				emf_province_is_steppe_culture = yes
			}
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_stable_1
				}
			}
			add_building = ca_steppe_stable_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_stable_2
				}
				has_building = ca_wall_1
				
			}
			add_building = ca_steppe_stable_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_stable_3
				}
				has_building = ca_wall_2
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}
			}
			add_building = ca_steppe_stable_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_stable_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}
			}
			add_building = ca_steppe_stable_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_stable_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}
			}
			add_building = ca_steppe_stable_5
		}
		if = {
			limit = {
				not = {
					has_building = ca_steppe_stable_6
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 8
				}
			}
			add_building = ca_steppe_stable_6
		}
	}
					
	if = {
		limit = {
			location = {
				emf_province_is_desert_culture = yes
				terrain = desert
			}
		}
		if = {
			limit = {
				not = {
					has_building = ca_desert_stable_1
				}
			}
			add_building = ca_desert_stable_1
		}
		if = {
			limit = {
				not = {
					has_building = ca_desert_stable_2
				}
				has_building = ca_wall_1
			}
			add_building = ca_desert_stable_2
		}
		if = {
			limit = {
				not = {
					has_building = ca_desert_stable_3
				}
				has_building = ca_wall_2
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}
			}
			add_building = ca_desert_stable_3
		}
		if = {
			limit = {
				not = {
					has_building = ca_desert_stable_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}
			}
			add_building = ca_desert_stable_4
		}
		if = {
			limit = {
				not = {
					has_building = ca_desert_stable_5
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 6
				}
			}
			add_building = ca_desert_stable_5
		}
		if = {
			limit = {
				not = {
					has_building = ca_desert_stable_6
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 8
				}
			}
			add_building = ca_desert_stable_6
		}
	}
	#Holy Fury
	if = {
		limit = {
			holder_scope = {
				OR = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_blood_building
						bloodline_is_active_for = PREV
					}
					any_liege = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_blood_building 
							bloodline_is_active_for = PREV
						}	
					}
				}
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		if = {
			limit = {
				location = { TECH_CASTLE_CONSTRUCTION = 2 }
			}
			add_building = ca_oppressive_fortifications_1
		}
		if = {
			limit = {
				location = { TECH_CASTLE_CONSTRUCTION = 4 }
			}
			add_building = ca_oppressive_fortifications_2
		}
		if = {
			limit = {
				location = { TECH_CASTLE_CONSTRUCTION = 6 }
			}
			add_building = ca_oppressive_fortifications_3
		}
		if = {
			limit = {
				location = { TECH_CASTLE_CONSTRUCTION = 8 }
			}
			add_building = ca_oppressive_fortifications_4
		}
	}
	if = {
		limit = {
			holder_scope = {
				OR = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_castellan 
					}
					any_liege = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_castellan 
						}	
					}
				}
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		if = {
			limit = {
				location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
			}
			add_building = ca_special_fortifications_1
		}
		if = {
			limit = {
				location = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
			}
			add_building = ca_special_fortifications_2
		}
		if = {
			limit = {
				location = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
			}
			add_building = ca_special_fortifications_3
		}
		if = {
			limit = {
				location = { TECH_FORTIFICATIONS_CONSTRUCTION = 7 }
			}
			add_building = ca_special_fortifications_4
		}
	}	
	refill_holding_levy = yes
}

scmr_build_temple_tech = {
	if = {
			limit =  {
				not = {
		has_building = tp_wall_q_1
				}
			}
			add_building = tp_wall_q_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_q_2
				}
				or = {
		and = {
			has_building = tp_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 1
			}
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_wall_q_2
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_q_3
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 3
				}
			}
			add_building = tp_wall_q_3
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_q_4
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 5
				}
			}
			add_building = tp_wall_q_4
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_q_5
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 7
				}
			}
			add_building = tp_wall_q_5
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_1
				}
			}
			add_building = tp_wall_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_2
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
			add_building = tp_wall_2
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_3
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 4
				}
			}
			add_building = tp_wall_3
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_4
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 6
				}
			}
			add_building = tp_wall_4
		}
		if = {
			limit =  {
				not = {
		has_building = tp_wall_5
				}
				location = {
		TECH_FORTIFICATIONS_CONSTRUCTION = 8
				}
			}
			add_building = tp_wall_5
		}
		if = {
			limit =  {
				not = {
		has_building = tp_monastery_1
				}
			}
			add_building = tp_monastery_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_monastery_2
				}
			}
			add_building = tp_monastery_2
		}
		if = {
			limit =  {
				not = {
		has_building = tp_monastery_3
				}
				location = {
		TECH_CITY_CONSTRUCTION = 2
				}
			}
			add_building = tp_monastery_3
		}
		if = {
			limit =  {
				not = {
		has_building = tp_monastery_4
				}
				location = {
		TECH_CITY_CONSTRUCTION = 4
				}
			}
			add_building = tp_monastery_4
		}
		if = {
			limit =  {
				not = {
		has_building = tp_monastery_5
				}
				location = {
		TECH_CITY_CONSTRUCTION = 6
				}
			}
			add_building = tp_monastery_5
		}
		if = {
			limit =  {
				not = {
		has_building = tp_monastery_6
				}
				location = {
		TECH_CITY_CONSTRUCTION = 8
				}
			}
			add_building = tp_monastery_6
		}
		if = {
			limit =  {
				not = {
		has_building = tp_barracks_1
				}
			}
			add_building = tp_barracks_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_barracks_2
				}
			}
			add_building = tp_barracks_2
		}
		if = {
			limit =  {
				not = {
		has_building = tp_barracks_3
				}
				location = {
		TECH_CITY_CONSTRUCTION = 1
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_barracks_3
		}
		if = {
			limit =  {
				not = {
		has_building = tp_barracks_4
				}
				location = {
		TECH_CITY_CONSTRUCTION = 3
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_barracks_4
		}
		if = {
			limit =  {
				not = {
		has_building = tp_barracks_5
				}
				location = {
		TECH_CITY_CONSTRUCTION = 5
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_barracks_5
		}
		if = {
			limit =  {
				not = {
		has_building = tp_barracks_6
				}
				location = {
		TECH_CITY_CONSTRUCTION = 7
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_barracks_6
		}
		if = {
			limit =  {
				not = {
		has_building = tp_elite_barracks_1
				}
			}
			add_building = tp_elite_barracks_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_elite_barracks_2
				}
			}
			add_building = tp_elite_barracks_2
		}
		if = {
			limit =  {
				not = {
		has_building = tp_elite_barracks_3
				}
				location = {
		TECH_CITY_CONSTRUCTION = 2
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_elite_barracks_3
		}
		if = {
			limit =  {
				not = {
		has_building = tp_elite_barracks_4
				}
				location = {
		TECH_CITY_CONSTRUCTION = 4
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_elite_barracks_4
		}
		if = {
			limit =  {
				not = {
		has_building = tp_elite_barracks_5
				}
				location = {
		TECH_CITY_CONSTRUCTION = 6
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_elite_barracks_5
		}
		if = {
			limit =  {
				not = {
		has_building = tp_elite_barracks_6
				}
				location = {
		TECH_CITY_CONSTRUCTION = 8
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_elite_barracks_6
		}
		if = {
			limit =  {
				not = {
		has_building = tp_town_1
				}
			}
			add_building = tp_town_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_town_2
				}
			}
			add_building = tp_town_2
		}
		if = {
			limit =  {
				not = {
					has_building = tp_town_3
				}
				location = {
		TECH_CITY_CONSTRUCTION = 1
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_town_3
		}
		if = {
			limit =  {
				not = {
		has_building = tp_town_4
				}
				location = {
		TECH_CITY_CONSTRUCTION = 3
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_town_4
		}
		if = {
			limit =  {
				not = {
		has_building = tp_town_5
				}
				location = {
		TECH_CITY_CONSTRUCTION = 5
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_town_5
		}
		if = {
			limit =  {
				not = {
		has_building = tp_town_6
				}
				location = {
		TECH_CITY_CONSTRUCTION = 7
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_town_6
		}
		if = {
			limit = {
				location = {
		port = yes
				}
			}
			if = {
				limit =  {
		not = {
			has_building = tp_shipyard_1
		}
		location = {
			TECH_NAVAL = 1
		}
				}
				add_building = tp_shipyard_1
			}
			if = {
				limit =  {
		not = {
			has_building = tp_shipyard_2
		}
		location = {
			TECH_NAVAL = 2
		}
				}
				add_building = tp_shipyard_2
			}
			if = {
				limit =  {
		not = {
			has_building = tp_shipyard_3
		}
		location = {
			TECH_NAVAL = 3
		}
				}
				add_building = tp_shipyard_3
			}
			if = {
				limit =  {
		not = {
			has_building = tp_shipyard_4
		}
		location = {
			TECH_NAVAL = 4
		}
				}
				add_building = tp_shipyard_4
			}
			
		}
		if = {
			limit =  {
				not = {
		has_building = tp_school_1
				}
				location = {
		TECH_CITY_CONSTRUCTION = 3
				}
			}
			add_building = tp_school_1
		}
		if = {
			limit =  {
				not = {
		has_building = tp_school_2
				}
				location = {
		TECH_CITY_CONSTRUCTION = 6
				}
				or = {
		has_building = tp_wall_2
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
				}
			}
			add_building = tp_school_2
		}
		
		#new addon
		if = {
			limit = {
				holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
					religion = norse_pagan
					liege = { 
						religion = norse_pagan
					} 
				}
			}
			add_building = tp_great_pillar_norse
		}
		#Holy Fury
		if = {
			limit = {
				holder_scope = {
					OR = {  
						religion = hellenic_pagan
						religion = hellenic_pagan_reformed
					}
				}	
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_zeus
				}
				add_building = tp_shrine_zeus
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_poseidon
				}
				add_building = tp_shrine_poseidon
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_hades
				}
				add_building = tp_shrine_hades
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_hermes
				}
				add_building = tp_shrine_hermes
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_demeter
				}
				add_building = tp_shrine_demeter
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_athena
				}
				add_building = tp_shrine_athena
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_apollo
				}
				add_building = tp_shrine_apollo
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_arthemis
				}
				add_building = tp_shrine_arthemis
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_ares
				}
				add_building = tp_shrine_ares
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_aphrodite
				}
				add_building = tp_shrine_aphrodite
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_ephaestus
				}
				add_building = tp_shrine_ephaestus
			}
			if = {
				limit = {
					has_title_flag = flag_dedicated_to_hestia
				}
				add_building = tp_shrine_hestia
			}
		}
		if = {
			limit = {
				location = {
					OR = {
						has_province_modifier = tomb_of_a_saint
						has_province_modifier = pillaged_tomb_of_a_saint
					}
				}
			}
			add_building = tp_saint_shrine
		}
		if = {
			limit = {
				holder_scope = {
					OR = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_monumental 
							bloodline_is_active_for = PREV
						}
						any_liege = {
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_monumental
								bloodline_is_active_for = PREV								
							}	
						}
					}
					NOR = {
						is_tribal = yes
						is_nomadic = yes
					}
				}
			}
			if = {
				limit = {
					location = {
						TECH_CITY_CONSTRUCTION = 1
					}
				}	
				add_building = tp_monumental_shrines_1
			}
			if = {
				limit = {
					location = {
						TECH_CITY_CONSTRUCTION = 3
					}
				}	
				add_building = tp_monumental_shrines_2
			}
			if = {
				limit = {
					location = {
						TECH_CITY_CONSTRUCTION = 5
					}
				}	
				add_building = tp_monumental_shrines_3
			}
			if = {
				limit = {
					location = {
						TECH_CITY_CONSTRUCTION = 7
					}
				}	
				add_building = tp_monumental_shrines_4
			}
		}	
		refill_holding_levy = yes
}

scmr_build_city_tech = {
	if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_q_1
		}
	}
	add_building = ct_wall_q_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_q_2
		}
		or = {
			and = {
				has_building = ct_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 1
				}
			}
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_wall_q_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_q_3
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 3
		}
	}
	add_building = ct_wall_q_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_q_4
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 5
		}
	}
	add_building = ct_wall_q_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_q_5
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 7
		}
	}
	add_building = ct_wall_q_5
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_1
		}
	}
	add_building = ct_wall_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_2
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
	}
	add_building = ct_wall_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_3
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 4
		}
	}
	add_building = ct_wall_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_4
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 6
		}
	}
	add_building = ct_wall_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_wall_5
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 8
		}
	}
	add_building = ct_wall_5
					}
	if = {
		limit = {
			holder_scope = {
				is_merchant_republic = yes
			}
		}
		if = {
			limit = {
				NOT = {
					has_building = ct_rep_arsenal_1
				}
			}
			add_building = ct_rep_arsenal_1
		}
		if = {
			limit = {
				NOT = {
					has_building = ct_rep_arsenal_2
				}
				location = {
					TECH_CITY_CONSTRUCTION = 4
				}
			}
			add_building = ct_rep_arsenal_2
		}
		if = {
			limit = {
				NOT = {
					has_building = ct_rep_arsenal_3
				}
				location = {
					TECH_CITY_CONSTRUCTION = 7
				}
			}
			add_building = ct_rep_arsenal_3
		}
	}				
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_training_grounds_1
		}
	}
	add_building = ct_training_grounds_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_training_grounds_2
		}
	}
	add_building = ct_training_grounds_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_training_grounds_3
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 2
		}
	}
	add_building = ct_training_grounds_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_training_grounds_4
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 4
		}
	}
	add_building = ct_training_grounds_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_training_grounds_5
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 6
		}
	}
	add_building = ct_training_grounds_5
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_training_grounds_6
		}
		location = {
			TECH_FORTIFICATIONS_CONSTRUCTION = 8
		}
	}
	add_building = ct_training_grounds_6
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_barracks_1
		}
	}
	add_building = ct_barracks_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_barracks_2
		}
	}
	add_building = ct_barracks_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_barracks_3
		}
		location = {
			TECH_CITY_CONSTRUCTION = 1
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_barracks_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_barracks_4
		}
		location = {
			TECH_CITY_CONSTRUCTION = 3
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_barracks_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_barracks_5
		}
		location = {
			TECH_CITY_CONSTRUCTION = 5
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_barracks_5
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_barracks_6
		}
		location = {
			TECH_CITY_CONSTRUCTION = 7
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_barracks_6
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_guard_1
		}
	}
	add_building = ct_guard_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_guard_2
		}
		location = {
			TECH_CITY_CONSTRUCTION = 2
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_guard_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_guard_3
		}
		location = {
			TECH_CITY_CONSTRUCTION = 4
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_guard_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_guard_4
		}
		location = {
			TECH_CITY_CONSTRUCTION = 6
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_guard_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_guard_5
		}
		location = {
			TECH_CITY_CONSTRUCTION = 8
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_guard_5
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_marketplace_1
		}
	}
	add_building = ct_marketplace_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_marketplace_2
		}
	}
	add_building = ct_marketplace_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_marketplace_3
		}
		location = {
			TECH_CITY_CONSTRUCTION = 1
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_marketplace_3
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_marketplace_4
		}
		location = {
			TECH_CITY_CONSTRUCTION = 3
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_marketplace_4
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_marketplace_5
		}
		location = {
			TECH_CITY_CONSTRUCTION = 5
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_marketplace_5
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_marketplace_6
		}
		location = {
			TECH_CITY_CONSTRUCTION = 7
		}
		or = {
			has_building = ct_wall_2
			location = {
				TECH_FORTIFICATIONS_CONSTRUCTION = 2
			}
		}
	}
	add_building = ct_marketplace_6
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_university_1
		}
		location = {
			TECH_CITY_CONSTRUCTION = 2
		}
	}
	add_building = ct_university_1
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_university_2
		}
		location = {
			TECH_CITY_CONSTRUCTION = 4
		}
	}
	add_building = ct_university_2
					}
					if =
					{
	limit = 
	{
		not = {
			has_building = ct_university_3
		}
		location = {
			TECH_CITY_CONSTRUCTION = 8
		}
	}
	add_building = ct_university_3
					}
					if =
					{
	limit =
	{
		location = {
			port = yes
		}
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_port_1
			}
		}
		add_building = ct_port_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_port_2
			}
			location = {
				TECH_TRADE_PRACTICES = 1
			}
		}
		add_building = ct_port_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_port_3
			}
			location = {
				TECH_TRADE_PRACTICES = 3
			}
			or = {
				has_building = ct_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ct_port_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_port_4
			}
			location = {
				TECH_TRADE_PRACTICES = 4
			}
			or = {
				has_building = ct_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ct_port_4
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_port_5
			}
			location = {
				TECH_TRADE_PRACTICES = 6
			}
			or = {
				has_building = ct_wall_2
				location = {
					TECH_FORTIFICATIONS_CONSTRUCTION = 2
				}
			}
		}
		add_building = ct_port_5
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_shipyard_1
			}
			location = {
				TECH_NAVAL = 1
			}
		}
		add_building = ct_shipyard_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_shipyard_2
			}
			location = {
				TECH_NAVAL = 2
			}
		}
		add_building = ct_shipyard_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_shipyard_3
			}
			location = {
				TECH_NAVAL = 3
			}
		}
		add_building = ct_shipyard_3
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_shipyard_4
			}
			location = {
				TECH_NAVAL = 4
			}
		}
		add_building = ct_shipyard_4
	}
					}
					if =
					{
	limit =
	{
		holder_scope = {
			is_patrician = yes
		}
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_rep_arsenal_1
			}
		}
		add_building = ct_rep_arsenal_1
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_rep_arsenal_2
			}
			location = {
				TECH_CITY_CONSTRUCTION = 4
			}
		}
		add_building = ct_rep_arsenal_2
	}
	if =
	{
		limit = {
			not = {
				has_building = ct_rep_arsenal_3
			}
			location = {
				TECH_CITY_CONSTRUCTION = 7
			}
		}
		add_building = ct_rep_arsenal_3
	}
					}
		#Holy Fury				
	if = {
		limit = {
			holder_scope = {
				OR = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_architect
						bloodline_is_active_for = PREV
					}
					any_liege = {
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_architect 
							bloodline_is_active_for = PREV
						}	
					}
				}
				NOR = {
					is_tribal = yes
					is_nomadic = yes
				}
			}
		}
		if = { 
			limit = {
				location = { TECH_CITY_CONSTRUCTION = 1 }
			}
			add_building = ct_planned_infrastructure_1
		}
		if = { 
			limit = {
				location = { TECH_CITY_CONSTRUCTION = 3 }
			}
			add_building = ct_planned_infrastructure_2
		}
		if = { 
			limit = {
				location = { TECH_CITY_CONSTRUCTION = 5 }
			}
			add_building = ct_planned_infrastructure_3
		}
		if = { 
			limit = {
				location = { TECH_CITY_CONSTRUCTION = 7 }
			}
			add_building = ct_planned_infrastructure_4
		}
	}					
					refill_holding_levy = yes
}

scmr_build_tb_tech = {
	add_building = tb_hillfort_1
    add_building = tb_hillfort_2
    add_building = tb_market_town_1
    add_building = tb_market_town_2
    add_building = tb_training_grounds_1
    add_building = tb_training_grounds_2
    add_building = tb_training_grounds_3
    add_building = tb_training_grounds_4
    add_building = tb_war_camp_1
    add_building = tb_war_camp_2
    add_building = tb_war_camp_3
    add_building = tb_war_camp_4
    add_building = tb_practice_range_1
    add_building = tb_practice_range_2
    add_building = tb_practice_range_3
    add_building = tb_practice_range_4
    add_building = tb_arsenal_1
    add_building = tb_arsenal_2
    add_building = tb_arsenal_3
    add_building = tb_arsenal_4
	if = {
		limit = {
			location = {
				TECH_CASTLE_CONSTRUCTION = 1
			}
			NOT = {
				has_building = tb_hillfort_4
			}
		}
		add_building = tb_hillfort_3
		add_building = tb_hillfort_4
	}
	if = {
		limit = {
			location = {
				TECH_CITY_CONSTRUCTION = 1
			}
			NOT = {
				has_building = tb_market_town_4
			}
		}
		add_building = tb_market_town_3
		add_building = tb_market_town_4
	}
	if = {
		limit = {
			location = {
				terrain = steppe
				emf_province_is_steppe_culture = yes
			}
			NOT = {
				has_building = tb_steppe_barracks_4
			}
		}
		add_building = tb_steppe_barracks_1
		add_building = tb_steppe_barracks_2
		add_building = tb_steppe_barracks_3
		add_building = tb_steppe_barracks_4
	}
	if = {
		limit = {
			location = {
				OR = {
					terrain = plains
					terrain = steppe
				}
				emf_province_is_steppe_culture = yes
			}
			NOT = {
				has_building = tb_steppe_stable_4
			}
		}
		add_building = tb_steppe_stable_1
		add_building = tb_steppe_stable_2
		add_building = tb_steppe_stable_3
		add_building = tb_steppe_stable_4
	}
	if = {
		limit = {
			location = {
				terrain = desert
				emf_province_is_desert_culture = yes
			}
			NOT = {
				has_building = tb_desert_stable_4
			}
		}
		add_building = tb_desert_stable_1
		add_building = tb_desert_stable_2
		add_building = tb_desert_stable_3
		add_building = tb_desert_stable_4
	}
	if = {
		limit = {
			NOT = {
				has_building = tb_emf_magyar_1
			}
			holder_scope = {
				culture = hungarian
				religion = tengri_pagan
				NOT = { has_global_flag = emf_magyar_migration_completed }
				NOT = { year = 920 }
			}
		}
		add_building = tb_emf_magyar_1
	}
	if = {
		limit = {
			location = {
				port = yes
			}
		}
		if = {
			limit = {
				NOT = {
					has_building = tb_shipyard_1
				}
				location = {
					TECH_NAVAL = 1
				}
			}
			add_building = tb_shipyard_1
		}
		if = {
			limit = {
				NOT = {
					has_building = tb_shipyard_2
				}
				location = {
					TECH_NAVAL = 2
				}
			}
			add_building = tb_shipyard_2
		}
		if = {
			limit = {
				NOT = {
					has_building = tb_shipyard_3
				}
				location = {
					TECH_NAVAL = 3
				}
			}
			add_building = tb_shipyard_3
		}
		if = {
			limit = {
				NOT = {
					has_building = tb_shipyard_4
				}
				location = {
					TECH_NAVAL = 4
				}
			}
			add_building = tb_shipyard_4
		}
	}
	
	#new addon
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = norse_pagan
				liege = { 
					is_tribal = yes 
					religion = norse_pagan
				} 
			}
		}
		add_building = tb_great_pillar_norse
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = tengri_pagan
				liege = { 
					is_tribal = yes 
					religion = tengri_pagan
				} 
			}
		}
		add_building = tb_great_pillar_tengri
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = slavic_pagan
				liege = { 
					is_tribal = yes 
					religion = slavic_pagan
				} 
			}
		}
		add_building = tb_great_pillar_slavic
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = baltic_pagan
				liege = { 
					is_tribal = yes 
					religion = baltic_pagan
				} 
			}
		}
		add_building = tb_great_pillar_baltic
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = finnish_pagan
				liege = { 
					is_tribal = yes 
					religion = finnish_pagan
				} 
			}
		}
		add_building = tb_great_pillar_finnish
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = west_african_pagan
				liege = { 
					is_tribal = yes 
					religion = west_african_pagan
				} 
			}
		}
		add_building = tb_great_pillar_west_african
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = aztec
				liege = { 
					is_tribal = yes 
					religion = aztec
				} 
			}
		}
		add_building = tb_great_pillar_aztec
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = bon
				liege = { 
					is_tribal = yes 
					religion = bon
				} 
			}
		}
		add_building = tb_great_pillar_bon
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = zun_pagan
				liege = { 
					is_tribal = yes 
					religion = zun_pagan
				} 
			}
		}
		add_building = tb_great_pillar_zun
	}
	if = {
		limit = {
			holder_scope = { #Owner and his liege must be of the founding religion, otherwise the building becomes inactive.
				is_tribal = yes 
				religion = hellenic_pagan
				liege = { 
					is_tribal = yes 
					religion = hellenic_pagan
				} 
			}
		}
		add_building = tb_great_pillar_hellenic
	}
	if = {
		limit = {
			location = {
				OR = {
					culture = english
					culture = welsh
					culture = cumbric
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_saxon_english_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_saxon_english_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_saxon_english_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_saxon_english_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_saxon_english_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_saxon_english_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_saxon_english_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_saxon_english_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture = scottish
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_scottish_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_scottish_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_scottish_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_scottish_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_scottish_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_scottish_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_scottish_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_scottish_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = baltic
					culture_group = finno_ugric
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_baltic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_baltic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_baltic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_baltic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_baltic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_baltic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_baltic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_baltic_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = altaic
						NOT = { culture = jurchen }
					}
					culture_group = iranian
					culture_group = magyar
					culture = romanian
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_altaic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_altaic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_altaic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_altaic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_altaic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_altaic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_altaic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_altaic_4
		}		
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = central_germanic
						NOR = {
							culture = dutch # SWMH only
							culture = lombard
							culture = visigothic # SWMH only
							culture = old_frankish
							culture = suebi
							culture = low_frankish
						}
					}
					AND = {
						culture_group = latin
						NOR = {
							culture = roman # Vanilla only
							culture = italian # Vanilla only
							culture = dalmatian # Vanilla only
							culture = sicilian # Vanilla only
							culture = neapolitan # Vanilla only
						}
					}
					culture = occitan
					culture = breton
					culture = cornish
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_frank_norman_german_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_frank_norman_german_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_frank_norman_german_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_frank_norman_german_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_frank_norman_german_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_frank_norman_german_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_frank_norman_german_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_frank_norman_german_4
		}	
	}

	if = {
		limit = {
			location = {
				OR = {
					culture = portuguese
					culture = galician
					culture = andalusian_arabic
					culture_group = horse_group
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_portuguese_galician_andalusian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_portuguese_galician_andalusian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_portuguese_galician_andalusian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_portuguese_galician_andalusian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_portuguese_galician_andalusian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_portuguese_galician_andalusian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_portuguese_galician_andalusian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_portuguese_galician_andalusian_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = iberian
						NOR = {
							culture = basque
							culture = andalusian_arabic # SWMH only
							culture = visigothic # Vanilla only
							culture = occitan # SWMH only
							culture = catalan
							culture = galician
							culture = portuguese
						}
					}
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_iberian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_iberian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_iberian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_iberian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_iberian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_iberian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_iberian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_iberian_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = italian_group # SWMH only
						NOR = {
							culture = ligurian
							culture = venetian
							culture = roman
						}
					}
					culture = italian
					culture = dalmatian
					culture = sicilian
					culture = neapolitan
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_italian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_italian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_italian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_italian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_italian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_italian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_italian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_italian_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = east_slavic
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_russian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_russian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_russian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_russian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_russian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_russian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_russian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_russian_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = north_germanic
						NOT = { culture = frisian } # SWMH only
					}
					AND = {
						culture_group = west_germanic
						NOR = {
							culture = english
							culture = frisian # Vanilla only
							culture = dutch # Vanilla only
						}
					}
					culture = pommeranian
					culture = norsegaelic
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_germanic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_north_germanic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_germanic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_north_germanic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_germanic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_north_germanic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_germanic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_north_germanic_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = west_slavic
				NOT = {
					culture = pommeranian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_hungarian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_hungarian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_hungarian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_hungarian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_hungarian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_hungarian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_hungarian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_hungarian_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = arabic
				NOT = { culture = andalusian_arabic } # Vanilla only
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_arabic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_arabic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_arabic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_arabic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_arabic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_arabic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_arabic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_arabic_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = north_african
				NOT = { culture = canarian }
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_african_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_north_african_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_african_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_north_african_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_african_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_north_african_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_north_african_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_north_african_4
		}
	
					
	}

	if = {
		limit = {
			location = {
				culture_group = byzantine
				NOR = {
					culture = romanian # SWMH only
					culture = arberian
					culture = assyrian # Vanilla only
					culture = coptic # Vanilla only
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_byzantine_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_byzantine_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_byzantine_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_byzantine_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_byzantine_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_byzantine_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_byzantine_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_byzantine_4
		}		
	}

	if = {
		limit = {
			location = {
				culture = irish
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_irish_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_irish_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_irish_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_irish_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_irish_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_irish_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_irish_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_irish_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture_group = east_african
				NOR = {
					culture = coptic # SWMH only
					culture = daju
				}
			}
		}
		
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_ethiopian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_ethiopian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_ethiopian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_ethiopian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_ethiopian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_ethiopian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_ethiopian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_ethiopian_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = west_african
					culture_group = central_african
					culture = daju
					culture = canarian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_west_african_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_west_african_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_west_african_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_west_african_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_west_african_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_west_african_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_west_african_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_west_african_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					AND = {
						culture_group = south_slavic
						NOR = {
							culture = croatian
							culture = romanian # Vanilla only
						}
					}
					culture = arberian
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_south_slavic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_group_south_slavic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_south_slavic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_group_south_slavic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_south_slavic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_group_south_slavic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_group_south_slavic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_group_south_slavic_4
		}
			
	}

	if = {
		limit = {
			location = {
				OR = {
					culture = dutch
					culture = frisian
					culture = low_frankish
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_dutch_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_dutch_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_dutch_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_dutch_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_dutch_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_dutch_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_dutch_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_dutch_4
		}
	}

	if = {
		limit = {
			location = {
				culture_group = mesoamerican
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_nahuatl_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_nahuatl_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_nahuatl_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_nahuatl_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_nahuatl_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_nahuatl_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_nahuatl_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_nahuatl_4
		}
			
	}

	if = {
		limit = {
			location = {
				culture_group = israelite
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_jewish_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_jewish_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_jewish_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_jewish_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_jewish_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_jewish_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_jewish_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_jewish_4
		}
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = indo_aryan_group
					culture_group = dravidian_group
					culture_group = elephant_group
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_indian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_indian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_indian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_indian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_indian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_indian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_indian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_indian_4
		}		
	}

	if = {
		limit = {
			location = {
				OR = {
					culture = lombard
					culture = old_frankish
					culture = visigothic
				}
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_germanic_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_germanic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_germanic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_germanic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_germanic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_germanic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_germanic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_germanic_4
		}
					
	}

	

	if = {
		limit = {
			location = {
				culture = suebi
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_suebi_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_suebi_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_suebi_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_suebi_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_suebi_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_suebi_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_suebi_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_suebi_4
		}
					
	}

	if = {
		limit = {
			location = {
				culture = basque
			}
		}
		
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_basque_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_basque_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_basque_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_basque_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_basque_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_basque_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_basque_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_basque_4
		}
	
					
	}

	if = {
		limit = {
			location = {
				culture = croatian
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_croatia_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_croatia_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_croatia_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_croatia_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_croatia_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_croatia_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_croatia_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_croatia_4
		}
			
	}

	if = {
		limit = {
			location = {
				culture = catalan
			}
		}
		
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_catalan_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_catalan_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_catalan_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_catalan_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_catalan_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_catalan_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_catalan_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_catalan_4
		}
		
					
	}

	if = {
		limit = {
			location = {
				OR = {
					culture_group = aramaic
					culture = assyrian # Vanilla only
				}
			}
		}
		
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_assyrian_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_assyrian_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_assyrian_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_assyrian_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_assyrian_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 3
				}	
			}
			add_building = tb_culture_assyrian_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_assyrian_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_assyrian_4
		}
			
	}
					
					
	if = {
		limit = {
			location = {
				culture_group = chinese_group
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_chinese_han_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = tb_culture_chinese_han_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_chinese_han_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_chinese_han_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_chinese_han_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_chinese_han_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_chinese_han_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_chinese_han_4
		}
					
	}
					
	if = {
		limit = {
			location = {
				culture = jurchen
			}
		}
		
		if = {
			limit = {
				not = {
					has_building = tb_culture_altaic_jurchen_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = tb_culture_altaic_jurchen_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_altaic_jurchen_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_altaic_jurchen_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_altaic_jurchen_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_altaic_jurchen_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_altaic_jurchen_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_altaic_jurchen_4
		}
					
	}
					
	if = {
		limit = {
			location = {
				culture_group = tibetan_group
			}
		}
	
		if = {
			limit = {
				not = {
					has_building = tb_culture_tibetan_1
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 0
				}	
			}
			add_building = tb_culture_tibetan_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_tibetan_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}	
			}
			add_building = tb_culture_tibetan_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_tibetan_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}	
			}
			add_building = tb_culture_tibetan_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_tibetan_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}	
			}
			add_building = tb_culture_tibetan_4
		}
					
	}
					
	#Holy Fury
	
	if = {
		limit = {
			location = {
				culture = coptic
			}
			holder_scope = {
				culture = coptic
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_coptic_1
				}
				has_building = ca_wall_2
			}
			add_building = tb_culture_coptic_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_coptic_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}
			}
			add_building = tb_culture_coptic_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_coptic_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}
			}
			add_building = tb_culture_coptic_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_coptic_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}
			}
			add_building = tb_culture_coptic_4
		}
	}
	
	if = {
		limit = {
			location = {
				OR = { 
					culture_group = horse_group 
					culture_group = cat_group 
					culture_group = bear_group 
					culture_group = hedgehog_group 
					culture_group = duck_group 
					culture_group = dog_group 
					culture_group = elephant_group 
					culture_group = dragon_group 
				}
			}
			holder_scope = {
				OR = { 
					culture_group = horse_group 
					culture_group = cat_group 
					culture_group = bear_group 
					culture_group = hedgehog_group 
					culture_group = duck_group 
					culture_group = dog_group 
					culture_group = elephant_group 
					culture_group = dragon_group 
				}
			}
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_animal_1
				}
				has_building = ca_wall_2
			}
			add_building = tb_culture_animal_1
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_animal_2
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 1
				}
			}
			add_building = tb_culture_animal_2
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_animal_3
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 2
				}
			}
			add_building = tb_culture_animal_3
		}
		if = {
			limit = {
				not = {
					has_building = tb_culture_animal_4
				}
				location = {
					TECH_CASTLE_CONSTRUCTION = 4
				}
			}
			add_building = tb_culture_animal_4
		}
	}	
	
	
	refill_holding_levy = yes
}
	

scmr_build_nd_tech = {
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_1 }
		}
		add_building = no_horse_breeder_1
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_2 }
		}
		add_building = no_horse_breeder_2
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_3 }
			location = { TECH_CASTLE_CONSTRUCTION = 1 }
		}
		add_building = no_horse_breeder_3
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_4 }
			location = { TECH_CASTLE_CONSTRUCTION = 1 }
		}
		add_building = no_horse_breeder_4
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_5 }
			location = { TECH_CASTLE_CONSTRUCTION = 2 }
		}
		add_building = no_horse_breeder_5
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_6 }
			location = { TECH_CASTLE_CONSTRUCTION = 2 }
		}
		add_building = no_horse_breeder_6
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_7 }
			location = { TECH_CASTLE_CONSTRUCTION = 3 }
		}
		add_building = no_horse_breeder_7
	}
	if = {
		limit = {
			NOT = { has_building = no_horse_breeder_8 }
			location = { TECH_CASTLE_CONSTRUCTION = 3 }
		}
		add_building = no_horse_breeder_8
	}
	
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_1 }
		}
		add_building = no_riding_contests_1
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_2 }
			location = { TECH_CASTLE_CONSTRUCTION = 1 }
		}
		add_building = no_riding_contests_2
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_3 }
			location = { TECH_CASTLE_CONSTRUCTION = 1 }
		}
		add_building = no_riding_contests_3
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_4 }
			location = { TECH_CASTLE_CONSTRUCTION = 2 }
		}
		add_building = no_riding_contests_4
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_5 }
			location = { TECH_CASTLE_CONSTRUCTION = 2 }
		}
		add_building = no_riding_contests_5
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_6 }
			location = { TECH_CASTLE_CONSTRUCTION = 3 }
		}
		add_building = no_riding_contests_6
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_7 }
			location = { TECH_CASTLE_CONSTRUCTION = 4 }
		}
		add_building = no_riding_contests_7
	}
	if = {
		limit = {
			NOT = { has_building = no_riding_contests_8 }
			location = { TECH_CASTLE_CONSTRUCTION = 5 }
		}
		add_building = no_riding_contests_8
	}
	
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_1 }
			location = { TECH_CITY_CONSTRUCTION = 0 }
		}
		add_building = no_wagon_train_1
	}
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_2 }
			location = { TECH_CITY_CONSTRUCTION = 0 }
		}
		add_building = no_wagon_train_2
	}
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_3 }
			location = { TECH_CITY_CONSTRUCTION = 1 }
		}
		add_building = no_wagon_train_3
	}
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_4 }
			location = { TECH_CITY_CONSTRUCTION = 1 }
		}
		add_building = no_wagon_train_4
	}
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_5 }
			location = { TECH_CITY_CONSTRUCTION = 2 }
		}
		add_building = no_wagon_train_5
	}
	if = { 
		limit = {
			NOT = { has_building = no_wagon_train_6 }
			location = { TECH_CITY_CONSTRUCTION = 2 }
		}
		add_building = no_wagon_train_6
	}
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_7 }
			location = { TECH_CITY_CONSTRUCTION = 3 }
		}
		add_building = no_wagon_train_7
	}
	if = {
		limit = {
			NOT = { has_building = no_wagon_train_8 }
			location = { TECH_CITY_CONSTRUCTION = 3 }
		}
		add_building = no_wagon_train_8
	}
	
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_1 }
		}
		add_building = no_craftsmens_quarter_1
	}
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_2 }
		}
		add_building = no_craftsmens_quarter_2
	}
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_3 }
			location = { TECH_CITY_CONSTRUCTION = 1 }
		}
		add_building = no_craftsmens_quarter_3
	}
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_4 }
			location = { TECH_CITY_CONSTRUCTION = 1 }
		}
		add_building = no_craftsmens_quarter_4
	}
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_5 }
			location = { TECH_CITY_CONSTRUCTION = 2 }
		}
		add_building = no_craftsmens_quarter_5
	}
	if = { 
		limit = {
			NOT = { has_building = no_craftsmens_quarter_6 }
			location = { TECH_CITY_CONSTRUCTION = 2 }
		}
		add_building = no_craftsmens_quarter_6
	}
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_7 }
			location = { TECH_CITY_CONSTRUCTION = 3 }
		}
		add_building = no_craftsmens_quarter_7
	}
	if = {
		limit = {
			NOT = { has_building = no_craftsmens_quarter_8 }
			location = { TECH_CITY_CONSTRUCTION = 3 }
		}
		add_building = no_craftsmens_quarter_8
	}
	
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_1 }
		}
		add_building = no_training_grounds_1
	}
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_2 }
		}
		add_building = no_training_grounds_2
	}
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_3 }
		}
		add_building = no_training_grounds_3
	}
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_4 }
		}
		add_building = no_training_grounds_4
	}
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_5 }
		}
		add_building = no_training_grounds_5
	}
	if = { 
		limit = {
			NOT = { has_building = no_training_grounds_6 }
		}
		add_building = no_training_grounds_6
	}
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_7 }
		}
		add_building = no_training_grounds_7
	}
	if = {
		limit = {
			NOT = { has_building = no_training_grounds_8 }
		}
		add_building = no_training_grounds_8
	}
	
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_1 }
			location = { TECH_TRADE_PRACTICES = 1 }
		}
		add_building = no_messenger_system_1
	}
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_2 }
			location = { TECH_TRADE_PRACTICES = 1 }
		}
		add_building = no_messenger_system_2
	}
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_3 }
			location = { TECH_TRADE_PRACTICES = 2 }
		}
		add_building = no_messenger_system_3
	}
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_4 }
			location = { TECH_TRADE_PRACTICES = 2 }
		}
		add_building = no_messenger_system_4
	}
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_5 }
			location = { TECH_TRADE_PRACTICES = 3 }
		}
		add_building = no_messenger_system_5
	}
	if = { 
		limit = {
			NOT = { has_building = no_messenger_system_6 }
			location = { TECH_TRADE_PRACTICES = 3 }
		}
		add_building = no_messenger_system_6
	}
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_7 }
			location = { TECH_TRADE_PRACTICES = 4 }
		}
		add_building = no_messenger_system_7
	}
	if = {
		limit = {
			NOT = { has_building = no_messenger_system_8 }
			location = { TECH_TRADE_PRACTICES = 5 }
		}
		add_building = no_messenger_system_8
	}
	
	
	if = {
		limit = {
			location = { port = yes }
			}
		if = {
			limit = {
			NOT = { has_building = no_harbor_1 }
		}
		add_building = no_harbor_1
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_2 }
		location = { TECH_NAVAL = 1 }
			}
			add_building = no_harbor_2
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_3 }
		location = { TECH_NAVAL = 2 }
			}
			add_building = no_harbor_3
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_4 }
		location = { TECH_NAVAL = 3 }
			}
			add_building = no_harbor_4
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_5 }
		location = { TECH_NAVAL = 4 }
			}
			add_building = no_harbor_5
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_6 }
		location = { TECH_NAVAL = 5 }
			}
			add_building = no_harbor_6
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_7 }
		location = { TECH_NAVAL = 6 }
			}
			add_building = no_harbor_7
		}
		if = {
			limit = {
		NOT = { has_building = no_harbor_8 }
		location = { TECH_NAVAL = 7 }
			}
			add_building = no_harbor_8
		}
	}	
	
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_1 }
		}
		add_building = no_gathering_hall_1
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_2 }
		}
		add_building = no_gathering_hall_2
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_3 }
			location = { TECH_CITY_CONSTRUCTION = 1 }
		}
		add_building = no_gathering_hall_3
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_4 }
			location = { TECH_CITY_CONSTRUCTION = 1 }
		}
		add_building = no_gathering_hall_4
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_5 }
			location = { TECH_CITY_CONSTRUCTION = 2 }
		}
		add_building = no_gathering_hall_5
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_6 }
			location = { TECH_CITY_CONSTRUCTION = 2 }
		}
		add_building = no_gathering_hall_6
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_7 }
			location = { TECH_CITY_CONSTRUCTION = 3 }
		}
		add_building = no_gathering_hall_7
	}
	if = {
		limit = {
			NOT = { has_building = no_gathering_hall_8 }
			location = { TECH_CITY_CONSTRUCTION = 4 }
		}
		add_building = no_gathering_hall_8
	}
	
	
	
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_1 }
		}
		add_building = no_camp_fortifications_1
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_2 }
		}
		add_building = no_camp_fortifications_2
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_3 }
			location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
		}
		add_building = no_camp_fortifications_3
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_4 }
			location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
		}
		add_building = no_camp_fortifications_4
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_5 }
			location = { TECH_FORTIFICATIONS_CONSTRUCTION = 2 }
		}
		add_building = no_camp_fortifications_5
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_6 }
			location = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
		}
		add_building = no_camp_fortifications_6
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_7 }
			location = { TECH_FORTIFICATIONS_CONSTRUCTION = 4 }
		}
		add_building = no_camp_fortifications_7
	}
	if = {
		limit = {
			NOT = { has_building = no_camp_fortifications_8 }
			location = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
		}
		add_building = no_camp_fortifications_8
	}
	
	if = {
		limit = {
			OR = {
				holder_scope = { 
					trait = lucky_ruler 
				}
				holder_scope = {
					has_landed_title = e_mongol_empire
					ai = yes
					NOT = { year = 1300 }
				}
			}
			NOT = {
				has_building = no_lucky_1
			}
		}
		add_building = no_lucky_1
	}
	refill_holding_levy = yes
}


scmr_build_hp_tech = {
	if = {
		limit = {  
			location = { TECH_CONSTRUCTION = 2 }
		} 
		add_to_extra_holding = { type = hospital building = hospital_building_1 }
		add_to_extra_holding = { type = hospital building = leper_colony_1 }
		add_to_extra_holding = { type = hospital building = soup_kitchen_1 }
	}
	if = {
		limit = {  
			location = { TECH_CONSTRUCTION = 3 }
		} 
		add_to_extra_holding = { type = hospital building = hospital_building_2 }
		add_to_extra_holding = { type = hospital building = chapel_1 }
		add_to_extra_holding = { type = hospital building = translation_house_1 }
		add_to_extra_holding = { type = hospital building = pilgrims_inn_1 }
		add_to_extra_holding = { type = hospital building = library_1 }
	}
	if = {
		limit = {  
			location = { TECH_CONSTRUCTION = 4 }
		}
		add_to_extra_holding = { type = hospital building = hospital_building_3 }
		add_to_extra_holding = { type = hospital building = pharmacology_laboratory_1 }
		add_to_extra_holding = { type = hospital building = medical_academy_1 }
		add_to_extra_holding = { type = hospital building = observatory_1 }
	}
	if = {
		limit = {  
			location = { TECH_CONSTRUCTION = 5 }
		}
		add_to_extra_holding = { type = hospital building = hospital_building_4 }
	}
	if = {
		limit = {  
			location = { TECH_CONSTRUCTION = 6 }
		}
		add_to_extra_holding = { type = hospital building = hospital_building_5 }
	}
}


scmr_build_tr_tech = {
	if = {
		limit = {
			trade_post_owner = { is_patrician = yes }
			location = { port = yes }
		}
		add_to_extra_holding = { type = trade_post building = tr_port_1 }
		add_to_extra_holding = { type = trade_post building = tr_port_2 }
		add_to_extra_holding = { type = trade_post building = tr_port_3 }
		add_to_extra_holding = { type = trade_post building = tr_enclave_1 }
		add_to_extra_holding = { type = trade_post building = tr_enclave_2 }
		add_to_extra_holding = { type = trade_post building = tr_enclave_3 }
		add_to_extra_holding = { type = trade_post building = tr_garrison_1 }
		add_to_extra_holding = { type = trade_post building = tr_garrison_2 }
		add_to_extra_holding = { type = trade_post building = tr_garrison_3 }
	}
	if = {
		limit = {
			location = {
				trade_route = silk_road
				silk_road_trade_post_trigger = yes
			}
		}
		if = {
			limit = {
				location = { TECH_TRADE_PRACTICES = 1 }
			}
			add_to_extra_holding = { type = trade_post building = tr_silk_road_1 }
			add_to_extra_holding = { type = trade_post building = trade_offices_1 }
			add_to_extra_holding = { type = trade_post building = mercenary_garrison_1 }
			
		}
		if = {
			limit = {
				location = { TECH_TRADE_PRACTICES = 2 }
			}
			add_to_extra_holding = { type = trade_post building = tr_silk_road_2 }
			add_to_extra_holding = { type = trade_post building = trade_offices_2 }
			add_to_extra_holding = { type = trade_post building = mercenary_garrison_2 }
		}
		if = {
			limit = {
				location = { TECH_TRADE_PRACTICES = 4 }
			}
			add_to_extra_holding = { type = trade_post building = tr_silk_road_3 }
			add_to_extra_holding = { type = trade_post building = trade_offices_3 }
			add_to_extra_holding = { type = trade_post building = mercenary_garrison_3 }
		}
	}
	
	if = {
		limit = {
			location = {
				trade_route = silk_road
				silk_road_trade_post_trigger = yes
			}
			trade_post_owner = {
				OR = {
					culture_group = israelite
					religion_group = jewish_group
					culture = khazar
				}
				NOR = {
					has_character_modifier = expelled_jewish
					any_liege = {
						has_character_modifier = expelled_jewish
					}
				}
			}
		}
		if = {
			limit = {
				location = { TECH_TRADE_PRACTICES = 1 }
			}
			add_to_extra_holding = { type = trade_post building = radhanite_quarter_1 }
		}
		if = {
			limit = {
				location = { TECH_TRADE_PRACTICES = 3 }
			}
			add_to_extra_holding = { type = trade_post building = radhanite_quarter_2 }
		}
		if = {
			limit = {
				location = { TECH_TRADE_PRACTICES = 4 }
			}
			add_to_extra_holding = { type = trade_post building = radhanite_quarter_3 }
		}
	}
}