﻿######################################################################
# Government
######################################################################

building_requirement_tribal = {
	scope:holder ?= {
		OR = {
			government_has_flag = government_is_tribal
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_wanua
		}
	}
}

building_requirement_wanua = {
	scope:holder ?= {
		government_has_flag = government_is_wanua
	}
}

building_requirement_tribal_holding_in_county = {
	NOT = {
		county = {
			any_county_province = {
				has_holding_type = tribal_holding
			}
		}
	}
}

building_requirement_nomad = {
	scope:holder ?= {
		government_has_flag = government_is_nomadic
	}
}

building_requirement_nomad_holding_in_county = {
	NOT = {
		county = {
			any_county_province = {
				has_holding_type = nomad_holding
			}
		}
	}
}

building_requirement_herder = {
	scope:holder ?= {
		government_has_flag = government_is_true_herder
	}
}

building_requirement_herder_holding_in_county = {
	NOT = {
		county = {
			any_county_province = {
				has_holding_type = herder_holding
			}
		}
	}
}

######################################################################
# Holding Level
######################################################################

building_requirement_castle_city_church = {
	trigger_if = {
		limit = { has_holding_type = castle_holding }
		has_building_or_higher = castle_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = city_holding }
		has_building_or_higher = city_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = church_holding }
		has_building_or_higher = temple_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = temple_citadel_holding }
		has_building_or_higher = temple_citadel_$LEVEL$
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_castle_city_church_failed"
			always = no
		}
	}
}

building_requirement_castle_city_church_temple_citadel_tribe = {
	trigger_if = {
		limit = { has_holding_type = castle_holding }
		has_building_or_higher = castle_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = city_holding }
		has_building_or_higher = city_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = church_holding }
		has_building_or_higher = temple_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = temple_citadel_holding }
		has_building_or_higher = temple_citadel_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = tribal_holding }
		trigger_if = {
			limit = {
				$LEVEL$ > 1
			}
			has_building_or_higher = tribe_02
		}
		trigger_else = { has_building_or_higher = tribe_01 }
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_castle_city_church_tribe_failed"
			always = no
		}
	}
}

######################################################################
# Special
######################################################################

building_hall_of_heroes_requirement = {
	custom_description = {
		text = building_requirement_hall_of_heroes_failed
		has_variable = hall_of_heroes
		scope:holder = {
			OR = {
				has_religion = religion:baltic_religion
				has_religion = religion:slavic_religion
				has_religion = religion:finno_ugric_religion
				has_religion = religion:siberian_religion
			}
		}
	}
}

building_university_requirement = {
	#has_variable = university
}

######################################################################
# Terrain
######################################################################

building_common_tradeport_requirement_terrain = {
	OR = {
		is_coastal = yes
		is_riverside_province = yes
	}
}

building_pastures_requirement_terrain = {
	OR = {
		terrain = farmlands
		terrain = plains
		terrain = steppe
		terrain = desert
		terrain = drylands
		terrain = oasis
		terrain = mountains
		terrain = desert_mountains
		terrain = hills
		terrain = tells
		terrain = floodplains
		AND = {
			terrain = jungle
			NOT = { geographical_region = world_innovation_elephants }
		}
	}
}

building_hunting_grounds_requirement_terrain = {
	OR = {
		terrain = plains
		terrain = drylands
		terrain = steppe
		terrain = hills
		terrain = tells
		terrain = taiga
		terrain = forest
		terrain = jungle
		terrain = wetlands
	}
}

building_orchards_requirement_terrain = {
	OR = {
		terrain = floodplains
		terrain = oasis
		has_building_or_higher = qanats_05
		culture = {
			has_cultural_parameter = vegetarian_fruit_orchard_allowed
		}
	}
}

building_farm_estates_requirement_terrain = {
	terrain = farmlands
}

building_tell_mines_requirement_terrain = {
	terrain = tells
}
building_military_camps_requirement_terrain = {
	#OR = { # All Terrains
	#	terrain = farmlands
	#	terrain = plains
	#	terrain = drylands
	#	terrain = desert
	#	terrain = oasis
	#	terrain = floodplains
	#	terrain = steppe
	#	terrain = mountains
	#	terrain = desert_mountains
	#	terrain = wetlands
	#	terrain = forest
	#	terrain = taiga
	#	terrain = jungle
	#	terrain = hills
	#}
}

building_regimental_grounds_requirement_terrain = {
	OR = {
		terrain = floodplains
		terrain = farmlands
	}
}

building_ramparts_requirement_terrain = {
	OR = {
		terrain = taiga
		terrain = forest
		terrain = jungle
	}
}

building_curtain_walls_requirement_terrain = {
	OR = {
		terrain = farmlands
		terrain = plains
		terrain = wetlands
		terrain = floodplains
	}
}

building_watchtowers_requirement_terrain = {
	OR = {
		terrain = desert
		terrain = drylands
		terrain = oasis
		terrain = steppe
	}
}

building_paddy_fields_requirement_terrain = {
	custom_tooltip = {
		text = building_paddy_fields_requirement_terrain_tt
		OR = {
			terrain = terraced_hills
			terrain = floodplains
			terrain = wetlands
			AND = {
				OR = {
					terrain = hills
					terrain = jungle
				}
				county.culture = { has_cultural_parameter = rice_cultivators_can_construct_paddy_fields_in_hills_and_jungle }
			}
		}
	}
}

building_potato_fields_requirement_terrain = {
	custom_tooltip = {
		text = building_potato_fields_requirement_terrain_tt
		OR = {
			terrain = farmlands
			terrain = hills
			terrain = tells
			terrain = plains
			terrain = steppe
			terrain = mountains
		}
	}
}

building_cereal_fields_requirement_terrain = {
	OR = {
		terrain = farmlands
		terrain = plains
		terrain = drylands
		AND = {
			terrain = floodplains
			NOR = {
				geographical_region = graphical_east_asia
				geographical_region = custom_viet_lands
			}
		}
		county = {
			OR = {
				has_county_modifier = fertile_desert_mountains_modifier
				has_county_modifier = dodekapolis_modifier
			}
		}

		has_building_or_higher = qanats_05
	}
}

building_outposts_requirement_terrain = {
	OR = {
		terrain = wetlands
		terrain = taiga
		terrain = forest
		terrain = jungle
	}
}

building_barracks_requirement_terrain = {
	#OR = {
	#	terrain = farmlands
	#	terrain = plains
	#	terrain = drylands
	#	terrain = floodplains # new
	#	terrain = hills
	#	terrain = mountains
	#	terrain = forest
	#	terrain = taiga
	#	terrain = jungle
	#	terrain = wetlands
	#	terrain = steppe
	#}
}

building_camel_farms_requirement_terrain = {
	geographical_region = world_innovation_camels # new
	OR = {
		terrain = desert
		terrain = desert_mountains
		terrain = oasis
		terrain = floodplains
		terrain = drylands # new
	}
}

building_stables_requirement_terrain = {
	# All terrains
}

building_smiths_requirement_terrain = {
	# All terrains
}

building_workshops_requirement_terrain = {
	# All terrains
}

building_logging_camps_requirement_terrain = {
	OR = {
		terrain = taiga
		terrain = forest
		terrain = jungle
	}
}

building_peat_quarries_requirement_terrain = {
	terrain = wetlands
}

building_hill_farms_requirement_terrain = {
	OR = {
		terrain = hills
		terrain = tells
		terrain = terraced_hills
	}
}

building_elephant_pens_requirement_terrain = {
	terrain = jungle
	OR = {
		geographical_region = world_innovation_elephants
		culture = { has_cultural_parameter = elephant_pens_building_bonuses }
	}
}

building_horse_pastures_requirement_terrain = {
	OR = {
		terrain = steppe
		geographical_region = world_steppe_east
		culture = { has_cultural_parameter = unlock_horse_pastures_building }
	}
}

building_plantations_requirement_terrain = {
	OR = {
		terrain = drylands
		terrain = desert
		terrain = oasis
	}
}

building_quarries_requirement_terrain = {
	OR = {
		terrain = mountains
		terrain = desert_mountains
		culture = { has_cultural_parameter = can_build_quarries_everywhere }
	}
}

building_warrior_lodges_requirement_terrain = {
	OR = {
		AND = {
			OR = {
				terrain = mountains
				terrain = desert_mountains
				terrain = hills
				terrain = tells
			}
			NOT = { geographical_region = world_horse_buildings_in_hills_and_mountains }
		}
		culture = { has_cultural_parameter = warrior_lodges_lift_restrictions }
	}
}

building_hillside_grazing_requirement_terrain = {
	OR = {
		terrain = mountains
		terrain = desert_mountains
		terrain = hills
		terrain = tells
	}
	geographical_region = world_horse_buildings_in_hills_and_mountains
}

building_wind_furnace_requirement_terrain = {
	geographical_region = world_india
	OR = {
		is_coastal = yes
		AND = {
			scope:holder.top_liege = {
				any_realm_county = {
					any_county_province = {
						has_building_or_higher = konasamudram_mines_01
					}
				}
			}
			duchy = {
				any_de_jure_county = {
					any_county_province = {
						has_building_or_higher = konasamudram_mines_01
					}
				}
			}
		}
		
	}
	
	scope:holder.culture = { has_innovation = innovation_wootz_steel }
}

building_hill_forts_requirement_terrain = {
	OR = {
		terrain = mountains
		terrain = desert_mountains
		terrain = hills
		terrain = tells
		terrain = terraced_hills
	}
}

building_windmills_requirement_terrain = {
	county ?= {
		any_county_province = {
			OR = {
				terrain = farmlands
				terrain = plains
				terrain = hills
				terrain = tells
				is_coastal = yes
			}
		}
	}
}

building_watermills_requirement_terrain = {
	county ?= {
		any_county_province = {
			OR = {
				terrain = mountains
				terrain = wetlands
				terrain = forest
				terrain = taiga
				terrain = jungle
				terrain = terraced_hills
				is_riverside_province = yes
			}
		}
	}
}

building_caravanserai_requirement_terrain = {
	county ?= {
		any_county_province = {
			OR = {
				terrain = drylands
				terrain = desert
				terrain = oasis
				terrain = floodplains
				terrain = steppe
				terrain = desert_mountains
				AND = {
					geographical_region = world_europe_west_iberia
					has_global_variable = fp2_struggle_conciliation_ending
				}
			}
		}
	}
}

building_qanats_requirement_terrain = {
 	county ?= {
		culture = { has_cultural_parameter = unlocks_qanat_building }
		county_has_province_with_terrain = {
			terrain = hills
			terrain = tells
			terrain = mountains
			terrain = desert_mountains
			terrain = desert
			terrain = drylands
		}
	}
}

building_hospices_requirement_terrain = {
	
}

has_any_special_mine_trigger = {
	has_building_with_flag = special_mine
	#OR = {
	#	has_building_or_higher = rammelsberg_mines_01
	#	has_building_or_higher = kutna_hora_mines_01
	#	has_building_or_higher = kremnica_mines_01
	#	has_building_or_higher = falun_mines_01
	#	has_building_or_higher = schwaz_mines_01
	#	has_building_or_higher = argentiera_mines_01
	#	has_building_or_higher = kollur_mines_01
	#	has_building_or_higher = siderokausia_mines_01
	#	has_building_or_higher = mali_mines_01
	#	has_building_or_higher = konasamudram_mines_01
	#	has_building_or_higher = dean_mines_01
	#	has_building_or_higher = phnom_dek_mines_01
	#	has_building_or_higher = zawar_mines_01
	#	has_building_or_higher = takkeda_mines_01
	#	has_building_or_higher = khetri_mines_01
	#	has_building_or_higher = taghaza_mines_01
	#	has_building_or_higher = ijil_mines_01
	#	has_building_or_higher = turda_mines_01
	#	has_building_or_higher = phocaea_mines_01
	#	has_building_or_higher = pansjhir_mines_01
	#	has_building_or_higher = trepca_mines_01
	#	has_building_or_higher = rudnik_mines_01
	#	has_building_or_higher = cevennes_mines_01
	#	has_building_or_higher = allaq_mines_01
	#	has_building_or_higher = verespatak_mines_01
	#	has_building_or_higher = nishapur_mines_01
	#	has_building_or_higher = srebrenica_mines_01
	#	has_building_or_higher = ratnapura_mines_01	
	#	has_building_or_higher = mogok_mines_01
	#}
}

######################################################################
# Baronies that cannot have a holding (intended for Sahara)
######################################################################

barony_cannot_construct_holding = {
	barony.title_province = {
		OR = {
			terrain = desert
			terrain = desert_mountains
		}
		geographical_region = world_africa_sahara
	}
}

######################################################################
# Triggers for add_random_building_effect script effect
######################################################################

# is any existing building of the checked tier? (e.g. 02)
has_any_building_of_level_trigger = {
	OR = {
		has_building = outposts_$BUILDING_LEVEL$
		has_building = logging_camps_$BUILDING_LEVEL$
		has_building = peat_quarries_$BUILDING_LEVEL$
		has_building = hill_forts_$BUILDING_LEVEL$
		has_building = plantations_$BUILDING_LEVEL$
		has_building = quarries_$BUILDING_LEVEL$
		has_building = hunting_grounds_$BUILDING_LEVEL$
		has_building = military_camps_$BUILDING_LEVEL$
		has_building = pastures_$BUILDING_LEVEL$
		has_building = ramparts_$BUILDING_LEVEL$
		has_building = curtain_walls_$BUILDING_LEVEL$
		has_building = watchtowers_$BUILDING_LEVEL$
		has_building = cereal_fields_$BUILDING_LEVEL$
		has_building = barracks_$BUILDING_LEVEL$
		has_building = camel_farms_$BUILDING_LEVEL$
		has_building = hill_farms_$BUILDING_LEVEL$
		has_building = elephant_pens_$BUILDING_LEVEL$
		has_building = common_tradeport_$BUILDING_LEVEL$
		has_building = orchards_$BUILDING_LEVEL$
		has_building = farm_estates_$BUILDING_LEVEL$
		has_building = regimental_grounds_$BUILDING_LEVEL$
		has_building = monastic_schools_$BUILDING_LEVEL$
	}
}

# is any existing building a lower tier than compare building?
has_lesser_building_trigger = {
	trigger_if = {
		limit = { has_building_or_higher = $COMPARE$_02 }
		has_any_building_of_level_trigger = { BUILDING_LEVEL = 01 }
	}
	trigger_else_if = {
		limit = { has_building_or_higher = $COMPARE$_03 }
		OR = {
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 01 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 02 }
		}
	}
	trigger_else_if = {
		limit = { has_building_or_higher = $COMPARE$_04 }
		OR = {
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 01 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 02 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 03 }
		}
	}
	trigger_else_if = {
		limit = { has_building_or_higher = $COMPARE$_05 }
		OR = {
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 01 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 02 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 03 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 04 }
		}
	}
	trigger_else_if = {
		limit = { has_building_or_higher = $COMPARE$_06 }
		OR = {
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 01 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 02 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 03 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 04 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 05 }
		}
	}
	trigger_else_if = {
		limit = { has_building_or_higher = $COMPARE$_07 }
		OR = {
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 01 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 02 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 03 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 04 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 05 }
			has_any_building_of_level_trigger = { BUILDING_LEVEL = 06 }
		}
	}
	trigger_else = { always = no } # Must already be highest tier possible
}

# can this building be added?
add_random_building_trigger = { 
	building_$BUILDING$_requirement_terrain = yes # terrain fits building type
	trigger_if = { # if all slots are full, this building type exists already
		limit = { free_building_slots = 0 }
		has_building_or_higher = $BUILDING$_01
		NOT = {
			has_lesser_building_trigger = { COMPARE = $BUILDING$ }
		}
	}
	trigger_else = {
		NOT = { has_building_or_higher = $BUILDING$_01 }
	}
}

# Innovation and holding level triggers for most economic buildings
generic_economic_building_innovation_trigger = {
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_01 }
		scope:build_owner.culture = { has_innovation = innovation_crop_rotation }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_02 }
		building_requirement_castle_city_church = { LEVEL = 02 }
		scope:build_owner.culture = { has_innovation = innovation_manorialism }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_04 }
		building_requirement_castle_city_church = { LEVEL = 03 }
		scope:build_owner.culture = { has_innovation = innovation_guilds }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_06 }
		building_requirement_castle_city_church = { LEVEL = 04 }
		scope:build_owner.culture = { has_innovation = innovation_cranes }
	}
}

# Innovation and holding level triggers for most fortification buildings
generic_fortification_building_innovations_trigger = {
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_01 }
		scope:build_owner.culture = { has_innovation = innovation_motte }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_02 }
		building_requirement_castle_city_church = { LEVEL = 02 }
		scope:build_owner.culture = { has_innovation = innovation_battlements }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_04 }
		building_requirement_castle_city_church = { LEVEL = 03 }
		scope:build_owner.culture = { has_innovation = innovation_hoardings }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_06 }
		building_requirement_castle_city_church = { LEVEL = 04 }
		scope:build_owner.culture = { has_innovation = innovation_machicolations }
	}
}

# Innovation and holding level triggers for most recruitment buildings
generic_recruitment_building_innovations_trigger = {
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_01 }
		scope:build_owner.culture = { has_innovation = innovation_barracks }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_02 }
		building_requirement_castle_city_church = { LEVEL = 02 }
		scope:build_owner.culture = { has_innovation = innovation_burhs }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_04 }
		building_requirement_castle_city_church = { LEVEL = 03 }
		scope:build_owner.culture = { has_innovation = innovation_castle_baileys }
	}
	trigger_if = {
		limit = { has_building_or_higher = $BUILDING$_06 }
		building_requirement_castle_city_church = { LEVEL = 04 }
		scope:build_owner.culture = { has_innovation = innovation_royal_armory }
	}
}

islamic_special_building_trigger = {
	OR = {
		has_building = holy_site_great_mosque_of_djenne_01
		has_building = holy_site_great_mosque_of_samarra_01
		has_building = holy_site_prophetic_mosque_01
		has_building = hagia_sophia_02
		has_building = the_friday_mosque_01 # shared zoroastrian
		has_building = holy_site_great_mosque_of_cordoba_01 # shared christian
		has_building_or_higher = damascus_mosque_01
		has_building_or_higher = yazd_mosque_01
	}
}

christian_special_building_trigger = {
	OR = {
		has_building = holy_site_cologne_cathedral_01
		has_building = holy_site_canterbury_cathedral_01
		has_building = holy_site_canterbury_cathedral_02
		has_building = holy_site_canterbury_cathedral_03
		has_building = temple_of_uppsala_01
		has_building = temple_of_uppsala_02
		has_building = lund_cathedral_01
		has_building = holy_site_great_mosque_of_cordoba_01 # shared muslim
		has_building_or_higher = cluny_abbey_01
		has_building_or_higher = beta_giyorgis_01
		has_building_or_higher = holy_wisdom_01
		has_building_or_higher = duomo_florence_01
		has_building_or_higher = wawel_cathedral_01
		has_building_or_higher = holy_site_st_peters_basilica_01
		has_building_or_higher = mont_st_michel_01
	}
}

eastern_special_building_trigger = {
	OR = {
		has_building = buddhas_of_bamian_01
		has_building = brihadeeswarar_temple_01
		has_building = shwedagon_pagoda_01
		has_building = ananda_temple_01
		has_building = khajuraho_01
		has_building_or_higher = jokhang_01
		has_building_or_higher = konark_temple_01
		has_building_or_higher = vatapi_caves_01
		has_building_or_higher = sanchi_stupa_01
		has_building_or_higher = boudhanath_01
	}
}

# Religious special building triggers
religious_special_building_exclusion_trigger = { # checks if any special buildings present do not fit your religion
	OR = {
		AND = { # Generic
			NOT = {
				barony = { is_holy_site_of = holder.faith }
			}
			OR = {
				has_building = holy_site_cathedral_01
				has_building = holy_site_mosque_01
				has_building = holy_site_pagan_grand_temple_01
				has_building = holy_site_indian_grand_temple_01
				has_building = holy_site_other_grand_temple_01
				has_building = hagia_sophia_01
				has_building = holy_site_mahabodhi_temple_01
				has_building = holy_site_imam_ali_mosque_01
				has_building = holy_site_great_mosque_of_mecca_01
				islamic_special_building_trigger = yes
				christian_special_building_trigger = yes
				has_building = holy_site_buddhist_grand_temple_01
				has_building = holy_site_japanese_temple_01
				has_building = holy_site_chinese_temple_01
				has_building = holy_site_se_asia_pagan_temple_01
			}
		}
		AND = { # Islamic
			NOT = { barony.holder.religion = religion:islam_religion }
			islamic_special_building_trigger = yes
		}
		AND = { # Christian
			NOT = { barony.holder.religion = religion:christianity_religion }
			christian_special_building_trigger = yes
		}
		AND = { # Islamic/Zoroastrian
			NOT = { barony.holder.religion = religion:zoroastrianism_religion }
			has_building = the_friday_mosque_01 # shared muslim
		}
		AND = { # Eastern family
			NOR = {
				barony.holder.religion = religion:hinduism_religion
				barony.holder.religion = religion:buddhism_religion
				barony.holder.religion = religion:jainism_religion
				barony.holder.religion = religion:taoism_religion
				barony.holder.religion = religion:zoroastrianism_religion
			}
			eastern_special_building_trigger = yes
		}
		# Judaism
		AND = {
			barony.holder.religion = religion:judaism_religion
			has_building = dome_of_the_rock_01
		}
		AND = {
			NOT = { barony.holder.religion = religion:judaism_religion }
			has_building = temple_in_jerusalem_01
		}
	}
}

building_murex_farm_requirement_terrain = {
	is_county_capital = yes
	is_coastal = yes
	geographical_region = mediteranean_coast
	NOR = {
		this.barony = title:b_salmydessus
		this.barony = title:b_chelai
	}
}

building_waterworks_requirement_terrain = {
	is_county_capital = yes
	NOR = {
		terrain = mountains
		terrain = desert_mountains
	}
	scope:holder.culture = { has_cultural_parameter = unlocks_waterworks_buildings }
}

building_spice_plantation_requirement_terrain = {
	is_county_capital = yes

	# cloves, nutmeg: present on Muluku Islands
	# cinnamomum verum: India, Sri Lanka, Bangladesh and Myanmar
	# cinnamomum malabathrum: Eastern Himalayas & Western Ghats
	OR = {
		geographical_region = world_asia_southeast_mainland
		geographical_region = world_asia_borneo
		geographical_region = world_asia_sulawesi_maluku
		geographical_region = world_asia_indonesia 
		geographical_region = world_india
	}
	OR = {
		terrain = jungle
		terrain = farmlands
		terrain = terraced_hills
		terrain = plains
	}
}

building_examination_hall_requirement_terrain = {
	is_county_capital = yes

	scope:holder = {
		government_has_flag = government_has_merit
	}
}

building_breweries_requirement = {
	OR = {
		AND = {
			has_building_or_higher = temple_$NUMBER$
			OR = {
				faith = faith:catholic
				faith = { has_doctrine_parameter = allows_brewery }
			}
		}
		AND = {
			has_building_or_higher = city_$NUMBER$
			culture = { has_cultural_parameter = allows_brewery }
		}
	}
}

#building_powder_magazine_requirement = {
#	scope:build_owner.culture = { 
#		OR = {
#			has_innovation = innovation_gunpowder 
#			has_innovation = innovation_fire_medicine
#		}
#	}
#}

building_leclerc_dyeworks_requirement_terrain = {
	is_county_capital = yes
	OR = {
		this.barony = title:b_paris
		this.barony = title:b_toulouse
		this.barony = title:b_bordeaux
		this.barony = title:b_saumur
		this.barony = title:b_marseille
		this.barony = title:b_lyon
		this.barony = title:b_roanne
	}
}

building_doggerland_ivory_deposits_requirement_terrain = {
	OR = {
		this.barony = title:b_favrsted
		this.barony = title:b_fljot
		this.barony = title:b_akranes
		this.barony = title:b_melar
		this.barony = title:b_hestr
		this.barony = title:b_storo
		this.barony = title:b_flekkevinger
		this.barony = title:b_ydreoer
		this.barony = title:b_lileo
	}
}

building_vineyards_requirement = {
	AND = {
		root.culture = { has_cultural_parameter = allows_vineyards }
		OR = {
			terrain = farmlands
			terrain = plains
			terrain = hills
		}
	}
}