﻿mbrxxx_can_construct_poi_trigger = {
	scope:county = {
		custom_description = {
			any_county_province = {
				count = all

				nor = {
					has_construction_with_flag = mbrxxx_militia
					has_construction_with_flag = mbrxxx_horse
					has_building_with_flag = mbrxxx_militia
					has_building_with_flag = mbrxxx_horse
				}
			}
			text = "mbrxxx_can_only_have_one_coach_house_or_warden_station"
		}
	}
}

mbrxxx_consulate_can_construct_or_enabled_trigger = {
	scope:holder = {
		custom_description = {
			text = mbrxxx_must_be_at_least_duke
			subject = scope:holder
			not = { highest_held_title_tier < tier_duchy }
		}
	}

	scope:holder = {
		custom_description = {
			text = mbrxxx_already_have_a_consulate_or_embassy
			subject = scope:holder
			not = {
				any_directly_owned_province = {
					has_building_or_higher = embassy_01
				}
			}
		}
	}

	trigger_if = {
		limit = {
			exists = scope:holder.capital_province
			this = scope:holder.capital_province
		}
	}
	trigger_else = {
		custom_description = {
			text = "mbrxxx_must_be_your_capital_failed"
			always = no
		}
	}

	trigger_if = {
		limit = {
			scope:holder = {
				exists = dynasty
				dynasty = {
					or = {
						has_dynasty_perk = law_legacy_1
						has_dynasty_perk = erudition_legacy_1
					}
				}
			}
		}
	}
	trigger_else = {
		custom_description = {
			text = "mbrxxx_need_law_1_or_erudite_1_failed"
			always = no
		}
	}
}

mbrxxx_embassy_can_construct_or_enabled_trigger = {
	scope:holder = {
		custom_description = {
			text = mbrxxx_must_be_at_least_duke
			subject = scope:holder
			not = { highest_held_title_tier < tier_duchy }
		}
	}

	scope:holder = {
		custom_description = {
			text = mbrxxx_already_have_a_embassy
			subject = scope:holder
			not = {
				any_directly_owned_province = {
					has_building_or_higher = embassy_02
				}
			}
		}
	}

	trigger_if = {
		limit = {
			exists = scope:holder.capital_province
			scope:holder.capital_province = {
				has_building_or_higher = embassy_01
			}
			this = scope:holder.capital_province
		}
	}
	trigger_else_if = {
		limit = {
			exists = scope:holder.capital_province
			not = { this = scope:holder.capital_province }
		}
	}
	trigger_else = {
		custom_description = {
			text = "mbrxxx_must_be_your_capital_failed"
			always = no
		}
	}

	trigger_if = {
		limit = {
			scope:holder = {
				exists = dynasty
				dynasty = {
					or = {
						has_dynasty_perk = law_legacy_3
						has_dynasty_perk = erudition_legacy_3
					}
				}
			}
		}
	}
	trigger_else = {
		custom_description = {
			text = "mbrxxx_need_law_3_or_erudite_3_failed"
			always = no
		}
	}
}

mbrxxx_building_requirement_castle_city_church_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 = tribal_holding }
		has_building_or_higher = tribe_$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_tribe_failed"
			always = no
		}
	}
}

mbrxxx_building_requirement_castle_tribe = {
	trigger_if = {
		limit = { has_holding_type = castle_holding }
		has_building_or_higher = castle_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = tribal_holding }
		has_building_or_higher = tribe_$LEVEL$
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_castle_tribe_failed"
			always = no
		}
	}
}

building_vineyard_requirement_terrain = {
	or = {
		agot_is_drylands_terrain = yes
		agot_is_hills_terrain = yes
		agot_is_farmlands_terrain = yes
		agot_is_plains_terrain = yes
		agot_is_floodplains_terrain = yes
		terrain = drylands
		terrain = hills
		terrain = terraced_hills
		terrain = farmlands
		terrain = plains
		terrain = floodplains
	}
}

building_slaughterhouse_requirement_terrain = {
	or = {
		agot_is_farmlands_terrain = yes
		agot_is_plains_terrain = yes
		agot_is_steppe_terrain = yes
		agot_is_desert_terrain = yes
		agot_is_drylands_terrain = yes
		agot_is_oasis_terrain = yes
		agot_is_mountains_terrain = yes
		agot_is_desert_mountains_terrain = yes
		agot_is_hills_terrain = yes
		agot_is_floodplains_terrain = yes
		terrain = farmlands
		terrain = plains
		terrain = steppe
		terrain = desert
		terrain = drylands
		terrain = oasis
		terrain = mountains
		terrain = desert_mountains
		terrain = hills
		terrain = terraced_hills
		terrain = floodplains
		AND = {
			agot_is_jungle_terrain = yes
			NOT = { geographical_region = world_innovation_elephants }
		}
	}
}

building_tunnel_requirement_terrain = {
	or = {
		agot_is_mountains_terrain = yes
		agot_is_desert_mountains_terrain = yes
		agot_is_hills_terrain = yes
		terrain = terraced_hills
	}
}

building_town_requirement_terrain = {
	or = {
		agot_is_hills_terrain = yes
		agot_is_farmlands_terrain = yes
		agot_is_plains_terrain = yes
		agot_is_forest_terrain = yes
		agot_is_drylands_terrain = yes
		agot_is_floodplains_terrain = yes
		agot_is_steppe_terrain = yes
		terrain = hills
		terrain = terraced_hills
		terrain = farmlands
		terrain = plains
		terrain = forest
		terrain = drylands
		terrain = floodplains
		terrain = steppe
	}
}

building_farming_requirement_terrain = {
	or = {
		agot_is_farmlands_terrain = yes
		agot_is_floodplains_terrain = yes
		terrain = terraced_hills
	}
}

building_militia_requirement_terrain = {
	or = {
		agot_is_desert_terrain = yes
		agot_is_desert_mountains_terrain = yes
		agot_is_drylands_terrain = yes
		agot_is_farmlands_terrain = yes
		agot_is_floodplains_terrain = yes
		agot_is_forest_terrain = yes
		agot_is_hills_terrain = yes
		agot_is_jungle_terrain = yes
		agot_is_mountains_terrain = yes
		agot_is_oasis_terrain = yes
		agot_is_plains_terrain = yes
		agot_is_steppe_terrain = yes
		agot_is_taiga_terrain = yes
		agot_is_wetlands_terrain = yes
		terrain = desert
		terrain = desert_mountains
		terrain = drylands
		terrain = farmlands
		terrain = floodplains
		terrain = forest
		terrain = hills
		terrain = terraced_hills
		terrain = jungle
		terrain = mountains
		terrain = oasis
		terrain = plains
		terrain = steppe
		terrain = taiga
		terrain = wetlands
	}
}

mbrxxx_civil_engineering_can_construct_or_enabled_trigger = {
	custom_tooltip = {
		text = mbrxxx_county_development_requirement
		county.development_level >= 5
	}
	culture = {
		has_innovation = innovation_development_01
	}
}

mbrxxx_coach_house_has_spy_trigger = {
	or = {
		has_building_or_higher = horse_04
		has_building_or_higher = mbrxxx_camel_04
		has_building_or_higher = mbrxxx_horse_archer_04
	}
}

mbrxxx_coach_house_has_gamekeeper_trigger = {
	or = {
		has_building_or_higher = horse_06
		has_building_or_higher = mbrxxx_camel_06
		has_building_or_higher = mbrxxx_horse_archer_06
	}
}

mbrxxx_coach_house_has_casino_trigger = {
	or = {
		has_building_or_higher = horse_08
		has_building_or_higher = mbrxxx_camel_08
		has_building_or_higher = mbrxxx_horse_archer_08
	}
}

mbrxxx_warden_station_has_blademaster_trigger = {
	has_building_or_higher = militia_04
}

mbrxxx_light_cavalry_requirement_terrain_trigger = {
	building_horse_pastures_requirement_terrain = no
	building_camel_farms_requirement_terrain = no
}

# AGOT triggers
MBRXXX_building_requirement_castle_city_church_monastery = {
	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 = monastery_holding }
		has_building_or_higher = monastery_$LEVEL$
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_castle_city_church_monastery_failed"
			always = no
		}
	}
}

MBRXXX_building_requirement_castle_city_church_tribe_pirate = {
	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 = tribal_holding }
		has_building_or_higher = tribe_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = pirate_den_holding }
		has_building_or_higher = pirate_den_$LEVEL$
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_castle_city_church_tribe_pirate_failed"
			always = no
		}
	}
}

MBRXXX_building_requirement_tribe_pirate = {
	trigger_if = {
		limit = { has_holding_type = tribal_holding }
		has_building_or_higher = tribe_$LEVEL$
	}
	trigger_else_if = {
		limit = { has_holding_type = pirate_den_holding }
		has_building_or_higher = pirate_den_$LEVEL$
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_tribe_pirate_failed"
			always = no
		}
	}
}

MBRXXX_building_requirement_pirate = {
	trigger_if = {
		limit = { has_holding_type = pirate_den_holding }
		has_building_or_higher = pirate_den_$LEVEL$
	}
	trigger_else = {
		custom_description = {
			text = "building_requirement_pirate_failed"
			always = no
		}
	}
}
