﻿wayfarer_the_real_threat_trigger = {
	is_councillor_of = root
	is_ai = yes
	opinion = {
		target = root
		value < 10
	}
}

# Used to keep track of mines found after our time period, so they have a higher chance to spawn for the Inspection event, particularly in Norway
later_historical_gold_mine_trigger = {
	OR = {
		this = province:1705 # Kildonan Gold Rush, 1869
		this = province:1665 # Dolgellau Gold Rush, Mid-19th century
	}
}

later_historical_silver_mine_trigger = {
	OR = {
		this = province:248 # Kongsberg, 1623
		this = province:346 # Sala, 15th century
	}
}

later_historical_copper_mine_trigger = {
	this = province:241 # Røros, 1645

}

reminiscing_event_trigger = {
	is_ai = no
	has_variable = reminiscing_location
	var:reminiscing_location = root.location
}

local_guild_trigger = {
	OR = {
		has_building_or_higher = watermills_01
		has_building_or_higher = windmills_01
		has_building_or_higher = common_tradeport_01
		has_building_or_higher = pastures_01
		has_building_or_higher = hunting_grounds_01
		has_building_or_higher = orchards_01
		has_building_or_higher = logging_camps_01
		has_building_or_higher = quarries_01
		has_building_or_higher = smiths_01
		has_building_or_higher = stables_01
		has_building_or_higher = guild_halls_01
		has_building_or_higher = hospices_01
		has_building_or_higher = workshops_01
	}
}

local_guild_compare_trigger = {
	switch = {
		trigger = scope:local_guild_scope
		1 = {
			NOT = { has_building_or_higher = watermills_01 }
			building_watermills_requirement_terrain = yes
		}
		2 = {
			NOT = { has_building_or_higher = windmills_01 }
			building_windmills_requirement_terrain = yes
		}
		3 = {
			NOT = { has_building_or_higher = common_tradeport_01 }
			building_common_tradeport_requirement_terrain = yes
		}
		4 = {
			NOT = { has_building_or_higher = pastures_01 }
			building_pastures_requirement_terrain = yes
		}
		5 = {
			NOT = { has_building_or_higher = pastures_01 }
			building_pastures_requirement_terrain = yes
		}
		6 = {
			NOT = { has_building_or_higher = pastures_01 }
			building_pastures_requirement_terrain = yes
		}
		7 = {
			NOT = { has_building_or_higher = pastures_01 }
			building_pastures_requirement_terrain = yes
		}
		8 = {
			NOT = { has_building_or_higher = hunting_grounds_01 }
			building_hunting_grounds_requirement_terrain = yes
		}
		9 = {
			NOT = { has_building_or_higher = hunting_grounds_01 }
			building_hunting_grounds_requirement_terrain = yes
		}
		10 = {
			NOT = { has_building_or_higher = hunting_grounds_01 }
			building_hunting_grounds_requirement_terrain = yes
		}
		11 = {
			NOT = { has_building_or_higher = orchards_01 }
			building_orchards_requirement_terrain = yes
		}
		12 = {
			NOT = { has_building_or_higher = logging_camps_01 }
			building_logging_camps_requirement_terrain = yes
		}
		13 = {
			NOT = { has_building_or_higher = quarries_01 }
			building_quarries_requirement_terrain = yes
		}
		14 = {
			NOT = { has_building_or_higher = quarries_01 }
			building_quarries_requirement_terrain = yes
		}
		15 = {
			NOT = { has_building_or_higher = smiths_01 }
			building_smiths_requirement_terrain = yes
		}
		16 = {
			NOT = { has_building_or_higher = stables_01 }
			building_stables_requirement_terrain = yes
		}
		17 = {
			NOT = { has_building_or_higher = guild_halls_01 }
			has_building_or_higher = city_01
		}
		18 = {
			NOT = { has_building_or_higher = hospices_01 }
		}
		19 = {
			NOT = { has_building_or_higher = hospices_01 }
		}
		20 = {
			NOT = { has_building_or_higher = workshops_01 }
			building_workshops_requirement_terrain = yes
		}
	}
}

landless_inspector_terrain_knowing_the_land_trigger = {
	trigger_if = {
		limit = {
			OR = {
				terrain = forest
				terrain = jungle
				terrain = taiga
				terrain = wetlands
			}
		}
		landless_inspector_terrain_master_trigger = { TERRAIN = woodlands }
	}
	trigger_if = {
		limit = {
			OR = {
				terrain = mountains
				terrain = hills
				terrain = desert_mountains
			}
		}
		landless_inspector_terrain_master_trigger = { TERRAIN = highlands }
	}
	trigger_if = {
		limit = {
			OR = {
				terrain = plains
				terrain = steppe
				terrain = farmlands
				terrain = floodplains
			}
		}
		landless_inspector_terrain_master_trigger = { TERRAIN = lowlands }
	}
	trigger_if = {
		limit = {
			OR = {
				terrain = desert
				terrain = oasis
				terrain = drylands
			}
		}
		landless_inspector_terrain_master_trigger = { TERRAIN = drylands }
	}
}

landless_inspector_terrain_master_trigger = {
	root = {
		OR = {
			has_character_modifier = landless_inspector_$TERRAIN$_tier_1_modifier
			has_character_modifier = landless_inspector_$TERRAIN$_tier_2_modifier
			has_character_modifier = nomadic_inspector_$TERRAIN$_tier_2_modifier
			has_character_modifier = landless_inspector_$TERRAIN$_tier_3_modifier
			has_character_modifier = nomadic_inspector_$TERRAIN$_tier_3_modifier
		}
	}
}

landless_inspector_king_of_the_wilds = {
	switch = {
		trigger = has_character_modifier
		# Woodlands
		master_terrain_forest_modifier = { root.location ?= { terrain = forest } }
		master_terrain_jungle_modifier = { root.location ?= { terrain = jungle } }
		master_terrain_taiga_modifier = { root.location ?= { terrain = taiga } }
		master_terrain_wetlands_modifier = { root.location ?= { terrain = wetlands } }
		# Highlands
		master_terrain_mountains_modifier = { root.location ?= { terrain = mountains } }
		master_terrain_hills_modifier = { root.location ?= { terrain = hills } }
		master_terrain_desert_mountains_modifier = { root.location ?= { terrain = desert_mountains } }
		# Lowlands
		master_terrain_plains_modifier = { root.location ?= { terrain = plains } }
		master_terrain_steppe_modifier = { root.location ?= { terrain = steppe } }
		master_terrain_farmlands_modifier = { root.location ?= { terrain = farmlands } }
		master_terrain_floodplains_modifier = { root.location ?= { terrain = floodplains } }
		# Drylands
		master_terrain_drylands_modifier = { root.location ?= { terrain = drylands } }
		master_terrain_desert_modifier = { root.location ?= { terrain = desert } }
		master_terrain_oasis_modifier = { root.location ?= { terrain = oasis } }
	}
}
