﻿namespace = destination_events

destination_events.10 = { # A good Caravan Master for hire
	type = character_event
	content_source = dlc_015
	title = destination_events.10.t
	desc = destination_events.10.desc
	theme = wanderer_destination_focus

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = boredom
	}

	right_portrait = {
		character = scope:provider_character
		animation = thinking
	}

	lower_right_portrait = scope:travel_leader_character

	trigger = {
		is_ai = no
		has_lifestyle = wanderer_lifestyle
		any_councillor = {
			OR = {
				has_council_position = councillor_chancellor
				has_council_position = councillor_steward
				AND = {
					is_kurultai_trigger = yes
					OR = {
						highest_skill = diplomacy
						highest_skill = stewardship
					}
					OR = {
						diplomacy >= high_skill_rating
						stewardship >= high_skill_rating
					}
				}
			}
		}
		OR = {
			NOT = { employs_court_position = travel_leader_court_position }
			trigger_if = {
				limit = {
					employs_court_position = travel_leader_court_position
				}
				court_position:travel_leader_court_position = {
					aptitude = {
						court_position = travel_leader_court_position
						value < 50
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = wanderer_destination_focus }
	}

	immediate = {
		#if = { #Unop: Disable this if since this scope is no longer needed
		#	limit = { employs_court_position = travel_leader_court_position }
		#	random_court_position_holder = {
		#		limit = { has_court_position = travel_leader_court_position }
		#		save_scope_as = current_travel_leader
		#	}
		#}
		if = {
			limit = {
				NOT = { exists = scope:provider_character }
			}
			random_councillor = {
				limit = {
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = councillor_steward
						AND = {
							is_kurultai_trigger = yes
							OR = {
								highest_skill = diplomacy
								highest_skill = stewardship
							}
							OR = {
								diplomacy >= high_skill_rating
								stewardship >= high_skill_rating
							}
						}
					}
				}
				save_scope_as = provider_character
			}
		}
		hidden_effect = {
			create_character = {
				template = travel_leader_court_position_template
				age = { 25 45 }
				gender = root
				#employer = root  #Unop: Don't make them courtier before they are hired
				location = root.capital_province #Unop: Make sure they are at the same location as our current char
				faith = root.faith
				culture = root.culture

				after_creation = {
					save_scope_as = travel_leader_character
				}
			}
		}
	}

	option = {
		name = destination_events.10.a
		remove_treasury_or_gold = tiny_treasury_or_gold_value
		custom_tooltip = destination_events.10.a.tt
		court_position_grant_effect = { #Unop Use court_position_grant_effect instead of appoint_court_position
			EMPLOYER = root
			POS = travel_leader
			CANDIDATE = scope:travel_leader_character
		}
		stress_impact = {
			paranoid = minor_stress_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = paranoid
			}
		}
	}

	option = {
		name = destination_events.10.b
		scope:travel_leader_character = {
			silent_disappear_ai_if_not_hired = yes
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 1
				has_trait = paranoid
			}
		}
	}
}

destination_events.20 = { # Preparing for an excursion
	type = character_event
	content_source = dlc_015
	title = destination_events.20.t
	desc = destination_events.20.desc
	theme = wanderer_destination_focus

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		animation = ecstasy
	}

	right_portrait = {
		character = scope:provider_character
		animation = thinking
	}

	override_background = { reference = bp1_wine_cellar }

	trigger = {
		has_lifestyle = wanderer_lifestyle
		any_councillor = {
			OR = {
				has_council_position = councillor_chancellor
				has_council_position = councillor_steward
				AND = {
					is_kurultai_trigger = yes
					OR = {
						highest_skill = diplomacy
						highest_skill = stewardship
					}
					OR = {
						diplomacy >= high_skill_rating
						stewardship >= high_skill_rating
					}
				}
			}
		}
		NOR = {
			has_character_modifier = destination_excursion_safety_modifier
			has_character_modifier = destination_excursion_speed_modifier
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = wanderer_destination_focus }
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:provider_character }
			}
			random_councillor = {
				limit = {
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = councillor_steward
						AND = {
							is_kurultai_trigger = yes
							OR = {
								highest_skill = diplomacy
								highest_skill = stewardship
							}
							OR = {
								diplomacy >= high_skill_rating
								stewardship >= high_skill_rating
							}
						}
					}
				}
				save_scope_as = provider_character
			}
		}
	}

	option = {
		name = destination_events.20.a
		add_character_modifier = destination_excursion_safety_modifier
		ai_chance = {
			base = 0
		}
	}

	option = {
		name = destination_events.20.b
		add_character_modifier = destination_excursion_speed_modifier
		ai_chance = {
			base = 0
		}
	}

	option = {
		name = destination_events.20.c
		add_gold = tiny_gold_value
		ai_chance = {
			base = 100
		}
	}
}

destination_events.30 = { # The Journey to <Special Building>
	type = character_event
	content_source = dlc_015
	title = destination_events.30.t
	desc = destination_events.30.desc
	theme = wanderer_destination_focus

	left_portrait = {
		character = root
		animation = page_flipping
	}

	override_background = {
		trigger = {
			scope:journey_province = {
				OR = {
					has_holding_type = city_holding
					has_holding_type = tribal_holding
					has_holding_type = castle_holding
				}
			}
		}
		reference = market
	}
	override_background = {
		trigger = {
			scope:journey_province = {
				has_holding_type = church_holding
				barony = { is_holy_site = yes }
			}
		}
		reference = holy_site_scope
	}
	override_background = {
		trigger = {
			scope:journey_province = {
				has_holding_type = church_holding
				barony = { is_holy_site = no }
			}
		}
		reference = temple
	}

	override_effect_2d = {
		reference = legend_glow
	}

	trigger = {
		is_ai = no
		has_lifestyle = wanderer_lifestyle
		OR = {
			NOT = { has_variable_list = extra_journey_target }
			variable_list_size = {
				name = extra_journey_target
				value <= 3
			}
		}
		any_special_building_province = {
			has_special_building = yes
			any_journey_point_of_interest_trigger = yes
			trigger_if = {
				limit = {
					root = { has_variable_list = visited_poi }
				}
				NOT = {
					root = {
						is_target_in_variable_list = {
							name = visited_poi
							target = prev
						}
					}
				}
			}
			trigger_if = {
				limit = {
					root = { has_variable_list = extra_journey_target }
				}
				NOT = {
					root = {
						is_target_in_variable_list = {
							name = extra_journey_target
							target = prev
						}
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = wanderer_destination_focus }
	}

	immediate = {
		random_special_building_province = {
			limit = {
				has_special_building = yes
				any_journey_point_of_interest_trigger = yes
				trigger_if = {
					limit = {
						root = { has_variable_list = visited_poi }
					}
					NOT = {
						root = {
							is_target_in_variable_list = {
								name = visited_poi
								target = prev
							}
						}
					}
				}
			}
			save_scope_as = journey_province
			save_scope_as = background_terrain_scope
		}
		add_to_variable_list = {
			name = extra_journey_target
			target = scope:journey_province
		}
	}

	option = {
		name = destination_events.30.a
		custom_tooltip = destination_events.30.a.tt
	}
}

destination_events.40 = { # Remember the language of <X>?
	type = character_event
	content_source = dlc_015
	title = destination_events.40.t
	desc = destination_events.40.desc
	theme = wanderer_destination_focus

	left_portrait = {
		character = root
		animation = thinking
	}

	right_portrait = {
		character = scope:teacher_character
		animation = happy_teacher
	}

	trigger = {
		is_ai = no
		has_lifestyle = wanderer_lifestyle
		has_variable_list = visited_poi
		num_of_known_languages < language_soft_cap
		NOT = {
			any_scheme = {
				type = learn_language
			}
		}
		any_in_list = {
			variable = visited_poi
			exists = culture.culture_head
			root = {
				NOT = { knows_language_of_culture = prev.culture }
				can_start_scheme = {
					type = learn_language
					target_character = prev.culture.culture_head
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = wanderer_destination_focus }
	}

	immediate = {
		random_in_list = {
			variable = visited_poi
			limit = {
				exists = culture.culture_head
				root = { NOT = { knows_language_of_culture = prev.culture } }
			}
			save_scope_as = poi_province
		}
		create_character = {
			template = scholar_character
			employer = root
			culture = scope:poi_province.culture
			save_scope_as = teacher_character
			after_creation = {
				learn_language_of_culture = root.culture
				add_opinion = {
					target = root
					modifier = friendliness_opinion
					opinion = 50
				}
			}
		}
	}

	option = {
		name = destination_events.40.a
		remove_short_term_gold = minor_gold_value
		start_scheme = {
			type = learn_language
			target_character = scope:teacher_character
		}
		add_character_modifier = {
			modifier = destination_inspired_by_language
			years = 10
		}
		stress_impact = {
			lazy = minor_stress_gain
			diligent = medium_stress_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = lazy
			}
		}
	}

	option = {
		name = destination_events.40.b
		scope:teacher_character = {
			move_to_pool = yes # This is for the tooltip
			silent_disappear_ai_if_not_hired = yes
		}
	}
}
