﻿is_location_valid_for_travel_event_on_land = {
	location = {
		exists = county #This will exclude sea provinces, impassable provinces, river provinces, etc
	}
}

is_guard_type_character_trigger = {
	OR = {
		has_court_position = bodyguard_court_position
		has_court_position = akolouthos_court_position
		is_knight_of = root
		has_council_position = councillor_marshal
		save_temporary_scope_as = guard_check
		AND = {
			root.current_travel_plan = { 
				scope:guard_check = { is_travel_entourage_character = yes }
			}
			is_available_travelling_adult = yes
			is_healthy = yes
			prowess > low_skill_rating
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
		}
	}	
}

is_character_not_specialized_in_terrain = { #Used in character scope
	save_temporary_scope_as = character_in_terrain
	is_location_valid_for_travel_event_on_land = yes
	location = { #Is it reasonable for us to get lost, etc in this type of terrain?
		switch = {
			trigger = terrain
			jungle = {
				scope:character_in_terrain = {
					NOT = { has_trait = jungle_stalker }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = jungle_stalker }
					}
				}
			}
			desert = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			drylands = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			desert_mountains = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			oasis = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			mountains = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			wetlands = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			hills = {
				scope:character_in_terrain = {
					NOT = { has_trait = desert_warrior }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = desert_warrior }
					}
				}
			}
			farmlands = {
				scope:character_in_terrain = {
					NOT = { has_trait = open_terrain_expert }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = open_terrain_expert }
					}
				}
			}
			plains = {
				scope:character_in_terrain = {
					NOT = { has_trait = open_terrain_expert }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = open_terrain_expert }
					}
				}
			}
			steppe = {
				scope:character_in_terrain = {
					NOT = { has_trait = open_terrain_expert }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = open_terrain_expert }
					}
				}
			}
			forest = {
				scope:character_in_terrain = {
					NOT = { has_trait = forest_fighter }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = forest_fighter }
					}
				}
			}
			taiga = {
				scope:character_in_terrain = {
					NOT = { has_trait = forest_fighter }
					current_travel_plan.travel_leader ?= {
						NOT = { has_trait = forest_fighter }
					}
				}
			}
		}
	}
}

has_sea_danger_type = {
	is_sea_province = yes
	OR = {
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = sea
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = coastal_sea
		}
	}
}

has_terrain_danger_type = {
	OR = {
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = hills
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = forest
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = mountains
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = desert_mountains
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = wetlands
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = floodplains
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = drylands
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = desert
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = jungle
		}
		travel_danger_type = {
			travel_plan = $TRAVEL$
			terrain = steppe
		}
	}
}

is_nomadic_location_trigger = {
	geographical_region = world_steppe
	culture = {
		OR = {
			has_cultural_pillar = heritage_mongolic
			has_cultural_pillar = heritage_turkic
			has_cultural_pillar = heritage_ugro_permian
		}
	}
}

is_snowy_rural_scandinavia_location_trigger = {
	location = {
		OR = {
			has_holding = no
			has_holding_type = tribal_holding
		}	
		geographical_region = world_europe_north
	}
	location_has_winter_trigger = yes
}

### EP2 BACKGROUND TRIGGERS

# Checks that a character is traveling to or from an activity and is not currently participating in an activity 
is_travelling_not_at_activity = {
	is_travelling = yes 
	trigger_if = {
		limit = { exists = involved_activity }
		has_activity_state = travel
	}
}

# Checks that a character is traveling, but currently at an activity and not actually moving around the map
is_travelling_at_activity = {
	is_travelling = yes 
	trigger_if = {
		limit = { exists = involved_activity }
		NOT = { has_activity_state = travel }
	}
}

#update this if a new travel point of interest is added to the game, although currently it's only used in 1 laamp task contract
has_any_travel_poi_trigger = {
	OR = {
		has_travel_point_of_interest = poi_capitals
		has_travel_point_of_interest = poi_special_buildings_martial
		has_travel_point_of_interest = poi_special_buildings_learning
		has_travel_point_of_interest = poi_special_buildings_religious
		has_travel_point_of_interest = poi_special_buildings_diplomatic
		has_travel_point_of_interest = poi_grand_city
		has_travel_point_of_interest = poi_special_buildings_wonder
		has_travel_point_of_interest = poi_special_buildings_economic
		has_travel_point_of_interest = poi_mausoleum_at_halicarnassus
		has_travel_point_of_interest = poi_lighthouse_of_alexandria
		has_travel_point_of_interest = poi_natural_feature
	}
}