﻿# Events for managing general event happenings; liege arriving at a stop, etc.

namespace = tour_general

############################
## Tour Arriving at a Stop
############################
## Vassal Events
## 0001-0499
## by James Beaumont
############################
# tour_general.0001 - Vassal: Liege arrival event
# 
# 
############################
## Liege Events
## 0500-0999
## by James Beaumont
############################
# tour_general.0501 - Liege: Rejected at the gates
# 
# 
# 

############################
## Tour Remaining at a Stop
############################
## Bilateral Vassal Events
## 1000-1999
## by Filippa Gannholm Kirsten
############################
# tour_general.1001 - Vassal: Liege requests or has tried to steal the courtier
# tour_general.1002 - Vassal/Liege: "Share" the courtier - A Gruesomely Glorious Meal
# 
# 
############################
## Vassal Events
## 2000-2999
## by Filippa Gannholm Kirsten
############################
# 
# 
# 
# 
# 
# 
# 
############################
## Bilateral Liege Events
## 3000-3999
## by Filippa Gannholm Kirsten
############################
# tour_general.3001 - Liege: You find a courtier you'd like to bring with you
# tour_general.3002 - Liege: Vassal has either decided to give you the courtier, attached terms or declined
# 
# 
# 
# 
# 
############################
## Liege Events
## 4000-4999
## by Filippa Gannholm Kirsten
############################
# 
# 
# 
# 
# 
# 
# 

#####################################################################################

############################
## Vassal Events
## 0001-0499
## by James Beaumont
############################

# Vassal: Liege arrival event
tour_general.0001 = {
	type = activity_event
	title = tour_general.0001.title
	desc = {
		desc = tour_general.0001.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = { category = special_type option = tour_type_majesty }
					}
				}
				desc = tour_general.0001.desc.type.majesty
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = { category = special_type option = tour_type_taxation }
					}
				}
				desc = tour_general.0001.desc.type.taxation
			}
			desc = tour_general.0001.desc.type.intimidation
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_relation_rival = scope:visiting_liege
						opinion = {
							target = scope:visiting_liege
							value <= -25
						}
					}
				}
				desc = tour_general.0001.desc.mid.hates_liege
			}
			triggered_desc = {
				trigger = { has_relation_lover = scope:visiting_liege }
				desc = tour_general.0001.desc.mid.lover
			}
			triggered_desc = {
				trigger = { has_relation_friend = scope:visiting_liege }
				desc = tour_general.0001.desc.mid.friend
			}
			triggered_desc = {
				trigger = {
					OR = {
						is_close_family_of = scope:visiting_liege
						is_consort_of = scope:visiting_liege
					}
				}
				desc = tour_general.0001.desc.mid.close_family
			}
			triggered_desc = {
				trigger = {
					exists = house
					scope:visiting_liege.house ?= root.house
				}
				desc = tour_general.0001.desc.mid.house
			}
			triggered_desc = {
				trigger = { is_powerful_vassal_of = scope:visiting_liege }
				desc = tour_general.0001.desc.mid.powerful_vassal
			}
			desc = tour_general.0001.desc.mid.default
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity = { has_current_phase = tour_phase_tour_grounds }
				}
				desc = tour_general.0001.desc.phase.tour_grounds
			}
			triggered_desc = {
				trigger = {
					scope:activity = { has_current_phase = tour_phase_dinner }
				}
				desc = tour_general.0001.desc.phase.dinner
			}
			desc = tour_general.0001.desc.phase.cultural_festival
		}
		desc = tour_general.0001.desc.outro
	}

	theme = tour_stop
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:visiting_liege
		animation = personality_honorable
	}
	trigger = { exists = scope:activity }
	option = { # Begin the activity!
		name = tour_general.0001.a
		name = {
			#Duuuude...
			trigger = { 
				scope:visiting_liege = { has_trait = hashishiyah }
			}
			text = tour_general.2001.a_hashish
			
		}

		if = { #Tour the Grounds
			limit = {
				scope:activity = {
					has_current_phase = tour_phase_tour_grounds
				}
			}
			custom_tooltip = {
				text = tour_begin_tour_grounds_tt
				scope:visiting_liege = {
					trigger_event = tour_grounds_events.3001
				}
			}
		}
		else_if = { #Cultural Festival
			limit = {
				scope:activity = {
					has_current_phase = tour_phase_cultural_festival
				}
			}
			custom_tooltip = {
				text = cultural_festival_begins_tt
				root.location.county = {
					save_scope_as = cultural_festival_scope
				}
				scope:visiting_liege = {
					trigger_event = cultural_festival.2000
				}
			}
		}
		else_if = { #Dinner
			limit = {
				scope:activity = {
					has_current_phase = tour_phase_dinner
				}
			}
			custom_tooltip = {
				text = tour_begin_dinner_tt
				scope:visiting_liege = {
					trigger_event = host_dinner_events.3000
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_rationality = 1
			}
		}
	}

	option = { # Turn them away
		name = tour_general.0001.b
		custom_tooltip = {
			text = reject_at_gates_tt
			scope:visiting_liege = {
				trigger_event = tour_general.0501
			}
		}
		reverse_add_opinion = {
			target = scope:visiting_liege
			modifier = insult_opinion
		 	opinion = -25
		}
		remove_from_activity = involved_activity
		if = {
			limit = {
        		has_character_flag = being_visited_on_tour
        	}
        	remove_character_flag = being_visited_on_tour
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 10
				OR = {
					has_relation_rival = scope:visiting_liege
					opinion = {
						target = scope:visiting_liege
						value <= -20
					}
				}
			}
			modifier = {
				add = 5
				has_trait = shy
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = tour_type_majesty
					}
				}
			}
			modifier = {
				add = 10
				OR = {
					has_trait = craven
				}
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = tour_type_intimidation
					}
				}
			}
			modifier = {
				add = 25
				has_trait = greedy
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = tour_type_taxation
					}
				}
			}
			modifier = {
				add = 5
				has_trait = paranoid
			}
			modifier = {
				factor = 2
				has_relation_nemesis = scope:visiting_liege
			}
		}
	}
}

############################
## Liege Events
## 0500-0999
## by James Beaumont
############################

# Liege: the phase has invalidated
tour_general.0500 = {
	type = activity_event
	title = tour_general.0500.title
	desc = {
		desc = tour_general.0500.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:tour_location.province_owner = scope:host
				}
				desc = tour_general.0500.desc.self
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						any_activity_phase_location_past = {
							NOT = { this = scope:tour_location }
							province_owner = scope:stop_host_scope
						}
					}
				}
				desc = tour_general.0500.desc.already_visited
			}
			triggered_desc = {
				trigger = {
					NOT = { scope:stop_host_scope.liege = root }
				}
				desc = tour_general.0500.desc.no_longer_liege
			}
			triggered_desc = {
				trigger = {
					NOT = {
						scope:stop_host_scope = {
							highest_held_title_tier >= tier_county
						}
					}
				}
				desc = tour_general.0500.desc.lowly_baron
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						is_in_army = yes
					}
				}
				desc = tour_general.0500.desc.leading_army
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						is_travelling = yes
					}
				}
				desc = tour_general.0500.desc.gone_travelling
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						is_imprisoned_by = root
					}
				}
				desc = tour_general.0500.desc.imprisoned_by_me
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						is_imprisoned = yes
					}
				}
				desc = tour_general.0500.desc.imprisoned
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						has_contagious_deadly_disease_trigger = yes
					}
				}
				desc = tour_general.0500.desc.deadly_illness
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						has_trait = incapable
					}
				}
				desc = tour_general.0500.desc.incapable
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						has_variable = gone_adventuring
					}
				}
				desc = tour_general.0500.desc.gone_adventuring
			}
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = {
						is_at_war = yes
					}
				}
				desc = tour_general.0500.desc.at_war
			}
		}
		desc = tour_general.0500.desc.outro
	}

	theme = travel_tour
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = {
			NOT = { root = scope:stop_host_scope }
		}
		character = scope:stop_host_scope
		animation = sadness
	}

	immediate = {
		custom_tooltip = current_phase_skipped_tt
	}

	option = { # Aww, I was looking forward to it! (┬┬﹏┬┬)
		name = tour_general.0500.a
	}
}

# Liege: Rejected at the gates
tour_general.0501 = {
	type = activity_event
	title = tour_general.0501.title
	desc = tour_general.0501.desc

	theme = tour_arrival_turned_away
	window = tour_arrival_event
	
	left_portrait = {
		character = root
		animation = shock
	}

	immediate = {
		scope:activity = {
			skip_activity_phase = yes
		}
		play_arrival_music_effect = {
			WELCOME_LEVEL = suspicious
		}
	}

	option = { # Move on with no recourse
		name = tour_general.0501.a
		scope:activity = {
			add_activity_log_entry = {
				key = turned_away_at_gates_log
				tags = { bad }
				character = scope:visiting_liege
				target = scope:stop_host_scope
				scope:stop_host_scope = {
					send_interface_toast = {
						title = tour_general.0501.liege_merciful
						left_icon = scope:stop_host_scope
						right_icon = scope:visiting_liege
						add_opinion = {
							target = scope:visiting_liege
							modifier = merciful_opinion
						}
					}
				}
			}
		}
		stress_impact = {
			calm = minor_stress_impact_loss
			content = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
			shy = medium_stress_impact_loss
			base = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain # What are they scheming?
			trusting = minor_stress_impact_gain # They betrayed my trust
			stubborn = medium_stress_impact_gain
			arrogant = major_stress_impact_gain
			vengeful = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				NOR = {
					has_trait = calm
					has_trait = content
					has_trait = humble
					has_trait = forgiving
				}
			}
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_compassion = 0.5
			}
		}
	}

	option = { # I will never forget this grievous insult
		name = tour_general.0501.b
		scope:activity = {
			add_activity_log_entry = {
				key = turned_away_at_gates_log
				tags = { bad }
				character = scope:visiting_liege
				target = scope:stop_host_scope
				scope:stop_host_scope = {
					send_interface_toast = {
						title = tour_general.0501.liege_angry
						left_icon = scope:stop_host_scope
						right_icon = scope:visiting_liege
						scope:visiting_liege = {
							progress_towards_rival_effect = {
								CHARACTER = scope:stop_host_scope
								OPINION = default_rival_opinion
								REASON = rival_turned_away_tour
							}
							add_opinion = {
								target = scope:stop_host_scope
								modifier = turned_away_tour_opinion
							}
						}
					}
				}
			}
		}
		stress_impact = {
			shy = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			content = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.1
			}
		}
	}

	option = { # Break down the gates!
		name = tour_general.0501.c
		if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = tour_type_intimidation
					}
				}
			}
			increase_tour_success_effect = { POINTS = 1 }
		}
		add_tyranny = major_tyranny_value
		add_dread = medium_dread_gain
		add_gold = scope:stop_host_scope.capital_province.raid_gold_value
		scope:activity = {
			add_activity_log_entry = {
				key = raided_me_log
				tags = { bad }
				character = scope:visiting_liege
				target = scope:stop_host_scope
				scope:stop_host_scope = {
					send_interface_toast = {
						title = tour_general.0501.raid
						left_icon = scope:stop_host_scope
						right_icon = scope:visiting_liege
						progress_towards_rival_effect = {
							CHARACTER = scope:visiting_liege
							OPINION = default_rival_opinion
							REASON = rival_raided_me
						}
						scope:stop_host_scope.capital_province = {
							add_province_modifier = {
								modifier = recently_looted_modifier
								years = 5
							}
							county = {
								if = {
									limit = {
										holder = {
											NOT = { has_perk = enduring_hardships_perk }
										}
									}
									change_county_control = raid_county_control_loss_value
									change_development_progress_with_overflow = -5
								}
							}
						}
					}
				}
			}
		}
		if = { # Arbitrary people don't care about tyranny
			limit = {
				NOT = {
					has_trait = arbitrary
				}
			}
			stress_impact = {
				wrathful = major_stress_impact_loss
				arrogant = major_stress_impact_loss
				sadistic = major_stress_impact_loss
				content = minor_stress_impact_gain
				humble = minor_stress_impact_gain
				forgiving = medium_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				wrathful = major_stress_impact_loss
				arrogant = major_stress_impact_loss
				sadistic = major_stress_impact_loss
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.1
			}
		}
	}
}

# Liege: Leaving a stop event
scripted_effect tour_demand_accepted_effect = {
	involved_activity ?= {
		add_activity_log_entry = {
			key = demand_accepted_log
			tags = { good major }
			character = scope:visiting_liege
			target = scope:stop_host_scope
			if = {
				limit = {
					has_activity_option = {
						category = special_type
						option = tour_type_majesty
					}
				}
				scope:stop_host_scope = {
					add_prestige = minor_prestige_loss
				}
				scope:visiting_liege = {
					add_prestige = minor_prestige_gain
					dynasty = { add_dynasty_prestige = miniscule_dynasty_prestige_gain }
				}
			}
			else_if = {
				limit = {
					has_activity_option = {
						category = special_type
						option = tour_type_taxation
					}
				}
				scope:stop_host_scope = {
					pay_short_term_gold = {
						target = scope:visiting_liege
						gold = medium_gold_value
					}
					if = {
						limit = {
							NOT = { has_trait = generous }
						}
						add_opinion = {
							modifier = taxation_tour_opinion
							target = scope:visiting_liege
						}
					}
				}
			}
			else_if = {
				limit = {
					has_activity_option = {
						category = special_type
						option = tour_type_intimidation
					}
				}
				scope:stop_host_scope = {
					add_dread = 10
					if = {
						limit = {
							is_a_faction_member = yes
							#AGOT Added
							NOT = { joined_faction = { faction_is_type = agot_loyalist_faction } }
						}
						leave_faction = joined_faction
						add_faction_cooldown_effect = { YEARS = 10 }
					}
					else = {
						add_faction_cooldown_effect = { YEARS = 20 }
					}
				}
				scope:stop_host_scope = {
					add_opinion = {
						modifier = dread_tour_opinion
						target = scope:visiting_liege
						opinion = -15
					}
				}
			}
			increase_tour_success_effect = { POINTS = 1 }
		}
	}
}

scripted_effect tour_demand_rejected_effect = {
	scope:visiting_liege = {
		add_opinion = {
			target = scope:stop_host_scope
			modifier = refused_tour_demand_opinion
		}
	}
}

tour_general.0510 = {
	type = activity_event
	title = tour_general.0510.title
	desc = tour_general.0510.desc

	theme = travel_tour
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:stop_host_scope
		animation = admiration
	}

	trigger = { # Prevent this from firing a bunch of times
		NOT = {
			exists = var:having_end_event
		}
	}

	immediate = {
		set_variable = {
			name = having_end_event
			value = yes
		}
	}

	option = { # Make your demand!
		name = tour_general.0510.a
		show_as_tooltip = {
			random_list = {
				50 = {
					show_chance = no
					desc = if_vassal_accepts_tt
					tour_demand_accepted_effect = yes
				}
				50 = {
					show_chance = no
					desc = if_vassal_rejects_tt
					tour_demand_rejected_effect = yes
				}
			}
		}
		scope:stop_host_scope = {
			trigger_event = tour_general.0511
		}
		stress_impact = {
			wrathful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.1
			}
		}
	}

	option = { # Move on without making a demand
		name = tour_general.0510.b
		show_as_tooltip = {
			reverse_add_opinion = {
				target = scope:stop_host_scope
				modifier = merciful_opinion
			}
		}
		scope:stop_host_scope = {
			trigger_event = tour_general.0513
		}
		stress_impact = {
			calm = minor_stress_impact_loss
			content = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
			shy = medium_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				NOR = {
					has_trait = calm
					has_trait = content
					has_trait = humble
					has_trait = forgiving
				}
			}
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_compassion = 0.5
			}
		}
	}
}

#Vassal, accept the demand?
tour_general.0511 = {
	type = activity_event
	title = tour_general.0511.title
	desc = {
		desc = tour_general.0511.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = tour_type_majesty
						}
					}
				}
				desc = tour_general.0511.desc.kneel
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = tour_type_taxation
						}
					}
				}
				desc = tour_general.0511.desc.money
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = tour_type_intimidation
						}
					}
				}
				desc = tour_general.0511.desc.factions
			}
		}
	}

	theme = travel_tour
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:visiting_liege
		animation = dismissal
	}

	option = { # Accept the demand
		name = tour_general.0511.a
		scope:visiting_liege = {
			send_interface_toast = {
				title = tour_general.0511.gave_demand
				left_icon = scope:stop_host_scope
				right_icon = scope:visiting_liege
				tour_demand_accepted_effect = yes
			}
		}
		stress_impact = {
			calm = minor_stress_impact_loss
			content = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
			stubborn = medium_stress_impact_gain
			arrogant = major_stress_impact_gain
			vengeful = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				dread > scope:visiting_liege.dread
			}
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_compassion = 0.5
				ai_honor = 1
				ai_greed = -1
			}
			modifier = {
				add = 25
				has_dread_level_towards = {
					target = scope:visiting_liege
					level >= 1
				}
			}
			modifier = {
				add = 500
				has_dread_level_towards = {
					target = scope:visiting_liege
					level >= 2
				}
			}
			modifier = {
				add = 500
				has_trait = loyal
			}
		}
	}

	option = { # Reject the demand
		name = tour_general.0511.b
		show_as_tooltip = {
			tour_demand_rejected_effect = yes
		}
		scope:visiting_liege = {
			trigger_event = tour_general.0512
		}
		stress_impact = {
			wrathful = minor_stress_impact_loss
			content = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				NOR = {
					has_trait = calm
					has_trait = content
					has_trait = humble
					has_trait = forgiving
				}
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.5
			}
			modifier = {
				factor = 0.5
				has_dread_level_towards = {
					target = scope:visiting_liege
					level >= 1
				}
			}
			modifier = {
				factor = 0
				opinion = {
					target = scope:visiting_liege
					value >= 75
				}
			}
			modifier = {
				factor = 0
				OR = {
					ai_honor >= 75
					ai_greed <= -75
				}
			}
			modifier = { # Yes, the placement is correct!
				add = 50
				has_trait = disloyal
			}
			modifier = {
				factor = 0
				OR = {
					has_relation_friend = scope:visiting_liege
					has_relation_lover = scope:visiting_liege
				}
			}
			modifier = {
				factor = 0
				has_trait = loyal
			}
			modifier = {
				factor = 0
				has_dread_level_towards = {
					target = scope:visiting_liege
					level >= 2
				}
			}
		}
	}

	after = {
		hidden_effect = {
			scope:activity ?= {
				progress_activity_phase_after = { days = 1 }
				if = {
					limit = {
						exists = var:stop_host
					}
					var:stop_host = {
						remove_from_activity = scope:activity
					}
					remove_variable = stop_host
				}
				if = {
					limit = {
						scope:activity = { exists = var:months_of_stop }
					}
					remove_variable = months_of_stop
				}
			}
		}
	}
}

#Liege, informed vassal rejected the demand
tour_general.0512 = {
	type = activity_event
	title = tour_general.0513.title
	desc = tour_general.0513.desc

	theme = travel_tour
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:stop_host_scope
		animation = disapproval
	}

	option = { # How dare!
		name = tour_general.0513.a
		tour_demand_rejected_effect = yes
		ai_chance = {
			base = 50
		}
	}
}

#Vassal, informed liege made no demand
tour_general.0513 = {
	type = activity_event
	title = tour_general.0512.title
	desc = tour_general.0512.desc

	theme = travel_tour
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:visiting_liege
		animation = thinking
	}

	option = { # Coolio
		name = tour_general.0512.a
		add_opinion = {
			target = scope:visiting_liege
			modifier = merciful_opinion
		}
		ai_chance = {
			base = 50
		}
	}

	after = {
		hidden_effect = {
			scope:activity ?= {
				progress_activity_phase_after = { days = 1 }
				if = {
					limit = {
						exists = var:stop_host
					}
					var:stop_host = {
						remove_from_activity = scope:activity
					}
					remove_variable = stop_host
				}
				if = {
					limit = {
						scope:activity = { exists = var:months_of_stop }
					}
					remove_variable = months_of_stop
				}
			}
		}
	}
}


############################
## Tour Remaining at a Stop
############################

############################
## Vassal Events
## 1000-2999
## by Filippa Gannholm Kirsten & James Beaumont
############################

scripted_trigger tour_general_1001_has_suitable_bodyguard = {
	NOT = { this = scope:stop_host_scope }
	is_available_healthy_ai_adult = yes
	location = scope:visiting_liege.location
}

scripted_trigger tour_general_1001_host_has_unusual_trait = {
	OR = {
		is_cannibal_trigger = yes
		has_trait = lunatic
		has_trait = possessed
	}
}

scripted_trigger tour_general_1001_has_cannibalist_pandering = {
	scope:tour_general_3001_target_courtier = { has_trait = gluttonous }
	is_cannibal_trigger = yes
}

scripted_effect tour_general_1001_stress_effect = {
	#Annoyed, but not *too* fussed about losing this strange courtier	
	if = {
		limit = {
			scope:tour_general_3001_target_courtier = { 
				OR = { 
					has_character_flag = tour_general_3001_is_delectable
					has_character_flag = tour_general_3001_has_insanity_trait
				} 
			}
			scope:visiting_liege = {
				has_character_flag = tour_general_3001_failed_courtier_theft
			}
		}
		stress_impact = {
			generous = minor_stress_impact_loss
			forgiving = medium_stress_impact_loss
			just = miniscule_stress_impact_gain
		}
	}
	#Annoyed to be losing a good courtier
	else_if = {
		limit = {
			scope:visiting_liege = {
				has_character_flag = tour_general_3001_failed_courtier_theft
			}
		}
		stress_impact = {
			greedy = major_stress_impact_gain
			vengeful = major_stress_impact_gain
			just = minor_stress_impact_gain
		}
	}
	#Annoyed, but not *too* fussed about losing this courtier	
	else_if = {
		limit = {
			scope:tour_general_3001_target_courtier = { 
				OR = { 
					has_character_flag = tour_general_3001_is_delectable
					has_character_flag = tour_general_3001_has_insanity_trait
				} 
			}
		}
		stress_impact = { generous = minor_stress_impact_loss }
	}
	#Annoyed to be losing a good courtier
	else = {
		stress_impact = { greedy = major_stress_impact_gain }
	}
}

scripted_effect tour_general_1001_cannibal_stress_effect = {
	#If you're a craven cannibal, this should even itself out; otherwise you lost out on a good meal!
	if = {
		limit = {
			has_trait = cannibal
			NOT = { has_trait = craven }
		}
		stress_impact = { cannibal = miniscule_stress_impact_gain }
	}
}

#Vassal: Liege requests or has tried to steal the courtier
tour_general.1001 = {
	type = activity_event
	title = {
		first_valid = {
			#They tried to steal your courtier
			triggered_desc = {
				trigger = {
					scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
				}
				desc = tour_general.1001.title_theft
			}
			#They requested the courtier amicably
			triggered_desc = {
				desc = tour_general.1001.title
			}
		}
	}
	desc = {
		desc = tour_general.1001.intro
		first_valid = {
			#Liege tried to steal the courtier
			triggered_desc = {
				trigger = {
					scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
				}
				desc = tour_general.1001.desc_theft_liege
			}
			#Liege requested the courtier
			triggered_desc = {
				desc = tour_general.1001.desc
			}
		}
		first_valid = {
			#Outro: Courtier is unusual, Liege tried to steal the courtier
			triggered_desc = {
				trigger = {
					scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
					scope:tour_general_3001_target_courtier = { 
						OR = { 
							has_character_flag = tour_general_3001_is_delectable
							has_character_flag = tour_general_3001_has_insanity_trait
						} 
					}
				}
				desc = tour_general.1001.outro_theft_liege_unusual_courtier
			}
			#Outro: Liege tried to steal the courtier
			triggered_desc = {
				trigger = {
					scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
				}
				desc = tour_general.1001.outro_theft_liege
			}
			#Outro: Host is unusual, Courtier is unusual
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { 
						OR = { 
							has_character_flag = tour_general_3001_is_delectable
							has_character_flag = tour_general_3001_has_insanity_trait
						} 
					}
					tour_general_1001_host_has_unusual_trait = yes
				}
				desc = tour_general.1001.outro_unusual_host_unusual_courtier
			}
			#Outro: Courtier is unusual
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { 
						OR = { 
							has_character_flag = tour_general_3001_is_delectable
							has_character_flag = tour_general_3001_has_insanity_trait
						} 
					}
				}
				desc = tour_general.1001.outro_unusual_courtier
			}
			#Outro: Default
			triggered_desc = {
				desc = tour_general.1001.outro
			}
		}
	}
	theme = tour_stop
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
			}
			animation = rage
		}
		animation = personality_rational
	}
	right_portrait = {
		character = scope:visiting_liege
		animation = personality_content
	}
	lower_left_portrait = {
		character = scope:tour_general_3001_target_courtier
	}
	lower_right_portrait = {
		trigger = {
			exists = scope:tour_general_1001_bodyguard
			scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
			scope:stop_host_scope = {
				OR = {
					has_trait = lunatic
					has_trait = possessed
				}
			}
		}
		character = scope:tour_general_1001_bodyguard
	}
	immediate = {
		#Find a bodyguard, if possible
		scope:visiting_liege = {
			if = {
				limit = {
					any_court_position_holder = {
						type = bodyguard_court_position
						tour_general_1001_has_suitable_bodyguard = yes
					}
				}
				random_court_position_holder = {
					type = bodyguard_court_position
					limit = { tour_general_1001_has_suitable_bodyguard = yes }
					save_scope_as = tour_general_1001_bodyguard
				}
			}
		}
		#TODO_CD_EP2 Also check if said bodyguard is with the Liege on the Tour when Travel is in
	}
	#A1: Alright, have the courtier
	option = {
		name = tour_general.1001.a
		trigger = { 
			NOT = {
				scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
			}
		}
		custom_tooltip = tour_general.3001.b_liege_decides.tt
		add_character_flag = {
			flag = tour_general_1001_gave_away_courtier
			days = 10
		}
		reverse_add_opinion = {
			target = scope:visiting_liege
			modifier = ep2_humored_liege_opinion
		 	opinion = 25
		}
		tour_general_1001_stress_effect = yes
		tour_general_1001_cannibal_stress_effect = yes
		stress_impact = {
			paranoid = major_stress_impact_loss #The less people the better, right?
		}
		ai_chance = {
			base = 10
			modifier = {
				OR = {
					has_relation_best_friend = scope:visiting_liege
					has_relation_friend = scope:visiting_liege
					opinion = {
						target = scope:visiting_liege
						value >= medium_positive_opinion
					}
				}	
				add = 50
			}
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_greed = -1	
			}
			modifier = {
				ai_greed >= medium_positive_ai_value
				add = -25
			}
		}
	}
	#A2: Post-theft - Begrudgingly have the courtier
	option = {
		name = tour_general.1001.a_theft_liege
		trigger = { 
			scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
		}
		custom_tooltip = tour_general.3001.b_liege_decides.tt
		add_character_flag = {
			flag = tour_general_1001_gave_away_courtier
			days = 10
		}
		reverse_add_opinion = {
			target = scope:visiting_liege
			modifier = ep2_humored_liege_opinion
		 	opinion = 25
		}
		tour_general_1001_stress_effect = yes
		tour_general_1001_cannibal_stress_effect = yes
		stress_impact = {
			paranoid = major_stress_impact_loss #The less people the better, right?
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_relation_best_friend = scope:visiting_liege
					has_relation_friend = scope:visiting_liege
					opinion = {
						target = scope:visiting_liege
						value >= medium_positive_opinion
					}
				}	
				add = 25
			}
			ai_value_modifier = {
				ai_compassion = 1
				ai_honor = 1
				ai_greed = -1
				ai_vengefulness = -1.5
			}
			modifier = {
				ai_greed >= medium_positive_ai_value
				add = -50
			}
		}
	}
	#I want a hook in return
	option = {
		name = tour_general.1001.b
		trigger = {
			can_add_hook = {
				type = favor_hook
				target = scope:visiting_liege
			}
		}
		custom_tooltip = tour_general.1001.b.tt
		custom_tooltip = tour_general.3001.b_liege_decides.tt
		add_character_flag = {
			flag = tour_general_1001_requested_hook
			days = 10
		}
		tour_general_1001_cannibal_stress_effect = yes
		stress_impact = {
			honest = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_rationality = 1.5
				ai_vengefulness = 0.5
				ai_boldness = 0.75
				ai_compassion = -0.1
				ai_honor = -0.1
			}
			modifier = {
				ai_boldness >= medium_positive_ai_value
				ai_energy >= low_positive_ai_value
				add = 25
			}
		}
	}
	#I want gold in return
	option = {
		name = tour_general.1001.c
		trigger = { 
			has_trait = greedy
			tour_general_1001_has_cannibalist_pandering = no
		} 
		custom_tooltip = tour_general.1001.c.tt
		custom_tooltip = tour_general.3001.b_liege_decides.tt
		add_character_flag = {
			flag = tour_general_1001_requested_gold
			days = 10
		}
		tour_general_1001_cannibal_stress_effect = yes
		stress_impact = {
			greedy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = 2
				ai_boldness = 0.75
				ai_vengefulness = 0.5
				ai_compassion = -0.1
				ai_zeal = -1
			}
			modifier = {
				ai_boldness >= medium_positive_ai_value
				ai_energy >= low_positive_ai_value
				add = 25
			}
		}
	}
	#Cannibal option: Let's "share" the courtier
	option = {
		name = tour_general.1001.d
		flavor = tour_general.1001.d.flavor
		trigger = { tour_general_1001_has_cannibalist_pandering = yes }
		custom_tooltip = tour_general.1001.d.tt
		custom_tooltip = tour_general.1001.d.tt_extra
		add_character_flag = {
			flag = tour_general_1001_offered_a_meal
			days = 10
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = {
				OR = {
					scope:visiting_liege = { has_trait = cannibal }
					any_known_secret = {
						secret_owner = scope:visiting_liege
						secret_type = secret_cannibal
						any_secret_knower = { this = root }
					}
				}
				add = 100
			}
			modifier = {
				OR = {
					has_relation_best_friend = scope:visiting_liege
					has_relation_friend = scope:visiting_liege
					has_relation_lover = scope:visiting_liege
				}	
				add = 25
			}
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = -1
				ai_compassion = -1
				ai_greed = -0.5
				ai_zeal = -0.5
			}
			modifier = {
				OR = {
					ai_boldness >= high_positive_ai_value
					ai_energy >= high_positive_ai_value
				}
				add = 25
			}
		}
	}
	#Insanity option: Liege must die
	option = {
		name = tour_general.1001.e
		flavor = tour_general.1001.e.flavor
		trigger = {
			scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
			AND = { 
				OR = {
					has_trait = lunatic
					has_trait = possessed
				}
				OR = {
					has_trait = vengeful
					has_trait = wrathful
					has_trait = irritable
				}
			}
		}
		custom_tooltip = tour_general.1001.e.tt
		if = {
			limit = { exists = scope:tour_general_1001_bodyguard }
			duel = {
				skill = prowess
				target = scope:tour_general_1001_bodyguard
				#You successfully kill the liege
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 1
						min = 5
					}
					desc = tour_general.1001.e.success
					send_interface_toast = {
						type = event_toast_text_and_effect_good
						left_icon = scope:stop_host_scope
						right_icon = scope:visiting_liege
						title = tour_general.1001.e.success.tt
						desc = tour_general.1001.e.success.desc

						scope:visiting_liege = {
							death = {
								killer = scope:stop_host_scope
								death_reason = death_fight
							}
						}
						#TODO_CD_EP2 Should this be criminal?
					}
				}
				#Bodyguard steps in and kills you
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 2
						min = 5
					}
					desc = tour_general.1001.e.bodyguard
					scope:visiting_liege = {
						send_interface_toast = {
							type = event_toast_text_and_effect_good
							left_icon = scope:tour_general_1001_bodyguard
							right_icon = scope:stop_host_scope
							title = tour_general.1001.e.success.tt
							desc = tour_general.1001.e.bodyguard.desc

							scope:stop_host_scope = {
								death = {
									killer = scope:tour_general_1001_bodyguard
									death_reason = death_fight
								}
							}
						}
					}
				}
			}
		}
		else = {
			duel = {
				skill = prowess
				target = scope:visiting_liege
				#You successfully kill the liege
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 1
						min = 5
					}
					desc = tour_general.1001.e.success
					send_interface_toast = {
						type = event_toast_text_and_effect_good
						left_icon = scope:stop_host_scope
						right_icon = scope:visiting_liege
						title = tour_general.1001.e.success.tt
						desc = tour_general.1001.e.success.desc

						scope:visiting_liege = {
							death = {
								killer = scope:stop_host_scope
								death_reason = death_fight
							}
						}
					}
				}
				#You fail the attempt and die in the process
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 2
						min = 5
					}
					desc = tour_general.1001.e.failure
					scope:visiting_liege = {
						send_interface_toast = {
							type = event_toast_text_and_effect_good
							left_icon = scope:visiting_liege
							right_icon = scope:stop_host_scope
							title = tour_general.1001.e.success.tt
							desc = tour_general.1001.e.success.desc

							scope:stop_host_scope = {
								death = {
									killer = scope:visiting_liege
									death_reason = death_fight
								}
							}
						}
					}
				}
			}
		}
		tour_general_1001_cannibal_stress_effect = yes
		if = {
			limit = { is_alive = yes }
			stress_impact = {
				calm = major_stress_impact_gain
				craven = major_stress_impact_gain
				compassionate = major_stress_impact_gain
				wrathful = major_stress_impact_loss
				vengeful = major_stress_impact_loss
				generous = minor_stress_impact_loss
			}
		}	
		ai_chance = {
			base = 0
			modifier = {
				OR = {
					has_relation_nemesis = scope:visiting_liege
					has_relation_rival = scope:visiting_liege
					opinion = {
						target = scope:visiting_liege
						value >= high_negative_opinion
					}
				}	
				add = 25
			}
			modifier = {
				OR = {
					has_relation_best_friend = scope:visiting_liege
					has_relation_friend = scope:visiting_liege
					opinion = {
						target = scope:visiting_liege
						value >= medium_positive_opinion
					}
				}	
				add = -50
			}
			modifier = {
				AND = {
					NOT = { exists = scope:tour_general_1001_bodyguard }
					prowess <= liege.prowess
				}
				add = -200
			}
			modifier = {
				AND = {
					exists = scope:tour_general_1001_bodyguard
					prowess <= scope:tour_general_1001_bodyguard.prowess
				}
				add = -200
			}
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
				ai_greed = -1
				ai_compassion = -1
				ai_rationality = -2
			}
			modifier = {
				ai_boldness >= high_positive_ai_value
				ai_energy >= high_positive_ai_value
				ai_rationality >= high_negative_ai_value
				add = 25
			}
		}
	}
	#Polite "no"
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { 
							scope:visiting_liege = { has_character_flag = tour_general_3001_failed_courtier_theft }
						}
						desc = tour_general.1001.f_theft_liege
					}
					#Default
					triggered_desc = {
						desc = tour_general.1001.f
					}
				}
			}
		}
		custom_tooltip = tour_general.1001.f.tt
		custom_tooltip = tour_general.3001.b_liege_decides.tt
		add_character_flag = {
			flag = tour_general_1001_declined
			days = 5
		}
		tour_general_1001_cannibal_stress_effect = yes
		if = {
			limit = {
				NOT = {
					any_secret = { secret_type = secret_cannibal }
				}
			}
			stress_impact = {
				generous = minor_stress_impact_loss
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 3
				ai_rationality = 1
				ai_honor = 1
				ai_zeal = 1
				ai_compassion = -1
				ai_greed = -1
			}
			modifier = {
				ai_greed >= medium_positive_ai_value
				add = -25
			}
		}
	}
	after = {
		scope:visiting_liege = { remove_character_flag = tour_general_3001_failed_courtier_theft }
		if = {
			limit = { 
				OR = { 
					has_character_flag = tour_general_1001_gave_away_courtier
					has_character_flag = tour_general_1001_requested_hook
					has_character_flag = tour_general_1001_requested_gold
					has_character_flag = tour_general_1001_offered_a_meal
					has_character_flag = tour_general_1001_declined
				}
			}
			#Trigger liege-follow up
			scope:visiting_liege = { 
				trigger_event = { 
					id = tour_general.3002
					days = 1
				}
			}
		}
		scope:tour_general_3001_target_courtier = {
			remove_character_flag = tour_general_3001_is_delectable
			remove_character_flag = tour_general_3001_has_insanity_trait
			remove_character_flag = tour_general_3001_has_beauty_trait
			remove_character_flag = tour_general_3001_has_physique_trait
			remove_character_flag = tour_general_3001_has_intellect_trait
			remove_character_flag = tour_general_3001_has_good_martial
			remove_character_flag = tour_general_3001_has_good_diplomacy
			remove_character_flag = tour_general_3001_has_good_stewardship
			remove_character_flag = tour_general_3001_has_good_intrigue
			remove_character_flag = tour_general_3001_has_good_learning
			remove_character_flag = tour_general_3001_has_good_prowess
		}
	}
}

#Vassal/Liege: "Share" the courtier - A Gruesomely Glorious Meal
tour_general.1002 = {
	type = activity_event
	title = {
		first_valid = {
			#Host perspective
			triggered_desc = {
				trigger = {
					root = scope:stop_host_scope
				}
				desc = tour_general.1002.title_vassal
			}
			#Liege perspective
			triggered_desc = {
				desc = tour_general.1002.title
			}
		}
	}
	desc = {
		first_valid = {
			#Host perspective
			triggered_desc = {
				trigger = { root = scope:stop_host_scope }
				desc = tour_general.1002.desc_host
			}
			#Liege perspective
			triggered_desc = {
				desc = tour_general.1002.desc_liege
			}
		}
	}
	theme = travel_tour
	override_background = { reference = feast }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { 
				root = scope:visiting_liege
				has_trait = compassionate
			}
			animation = stress
		}
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:tour_general_1002_other_character
		animation = ecstasy
	}
	lower_center_portrait = {
		character = scope:tour_general_3001_target_courtier
	}
	immediate = {
	#Set up our other portrait
		if = {
			limit = { root = scope:stop_host_scope }
			scope:visiting_liege = {
				save_scope_as = tour_general_1002_other_character
			}
		}
		else = {
			scope:stop_host_scope = {
				save_scope_as = tour_general_1002_other_character
			}
		}
		scope:tour_general_3001_target_courtier = {
			death = {
				death_reason = death_vanished
			}
		}
	}
	#Liege: This is divine!
	option = {
		name = tour_general.1002.a
		trigger = { root = scope:visiting_liege }
		flavor = tour_general.1002.a.flavor
		stress_impact = {
			base = major_stress_impact_loss
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 1
			}
			modifier = {
				has_trait = gluttonous
				add = 25
			}
			modifier = {
				AND = {
					NOT = { has_trait = compassionate }
					stress_level > 1
				}
				add = 100
			}
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}
	#Liege: ... maybe just the tiniest bite
	option = {
		name = tour_general.1002.b
		trigger = { root = scope:visiting_liege }
		stress_impact = {
			base = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain	
		}
		ai_chance = {
			base = 0
			modifier = {
				has_trait = compassionate
				add = 30
			}
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}
	#Host: Dig in!
	option = {
		name = tour_general.1002.c
		trigger = { root = scope:stop_host_scope }
		flavor = tour_general.1002.a.flavor
		stress_impact = {
			base = major_stress_impact_loss
		}
		ai_chance = {
			base = 10
		}
	}
}



############################
## Liege Events
## 3000-5999
## by Filippa Gannholm Kirsten
############################

scripted_effect tour_general_3001_calculate_relationship_decline_effect = {
	if = {
		limit = {
			scope:stop_host_scope = {
				OR = {
					has_relation_best_friend = root
					has_relation_friend = root
					opinion = {
						target = root
						value >= medium_positive_opinion
					}
				}		
			}
		}
		reverse_add_opinion = {
			target = scope:stop_host_scope
			modifier = ep2_liege_relocated_my_courtier_opinion
		 	opinion = -20
		}
		add_dread = 10
		add_tyranny = 10
	}
	else = {
		reverse_add_opinion = {
			target = scope:stop_host_scope
			modifier = ep2_disliked_liege_relocated_my_courtier_opinion
		 	opinion = -50
		}
		add_dread = 30
		add_tyranny = 30
	}
}

scripted_trigger tour_general_3001_courtier_to_steal_exists = {
	NOT = { this = scope:stop_host_scope }
	OR = {
		martial >= 20
		stewardship >= 20
		intrigue >= 20
		diplomacy >= 20
		learning >= 20
		prowess >= 20
		has_trait = strong
		has_trait = shrewd
		has_trait_rank = {
			trait = beauty_good
			rank >= 1
		}
		has_trait_rank = {
			trait = intellect_good
			rank >= 1
		}
		has_trait_rank = {
			trait = physique_good
			rank >= 1
		}
		AND = {
			trigger_if = {
				limit = {
					scope:visiting_liege = {
						is_female = yes
					}
				}
				is_male = yes
			}
			trigger_else_if = {
				limit = {
					scope:visiting_liege = {
						is_male = yes
					}
				}
				is_female = yes
			}
			trigger_else = {
				always = no
			}
			is_attracted_to_gender_of = scope:visiting_liege
			has_trait = fecund
			age <= 20
		}
	}
	is_available_healthy_adult = yes
	age <= 40
}

scripted_trigger tour_general_3001_insane_courtier_to_steal_exists = {
	NOT = { this = scope:stop_host_scope }
	OR = {
		has_trait = lunatic
		has_trait = possessed
		has_trait = depressed
	}
	is_available_adult = yes
	NOT = {
		has_trait_rank = {
			trait = wounded
			rank >= 2
		}
	}
}

scripted_trigger tour_general_3001_delectable_courtier_to_steal_exists = {
	NOT = { this = scope:stop_host_scope }
	has_trait = gluttonous
	is_available_healthy_adult = yes
}

scripted_effect tour_general_3001_add_courtier_effect = {
	add_courtier = scope:tour_general_3001_target_courtier
	current_travel_plan = {
		add_companion = scope:tour_general_3001_target_courtier
	}
	#Check if we found a gluttonous target but we're not a cannibal
	if = {
		limit = {
			scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
			is_cannibal_trigger = no
		}
		add_character_modifier = {
			modifier = courtier_cook_modifier
			years = 20
		}
	}
}

#Liege: You find a courtier you'd like to bring with you
tour_general.3001 = {
	type = activity_event
	title = tour_general.3001.title
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
					is_cannibal_trigger = yes
				}
				desc = tour_general.3001.desc_gluttonous_cannibal
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
				}
				desc = tour_general.3001.desc_gluttonous
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait }
				}
				desc = tour_general.3001.desc_insanity_courtier
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_beauty_trait }
				}
				desc = tour_general.3001.desc_beauty
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_intellect_trait }
				}
				desc = tour_general.3001.desc_intellect
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_physique_trait }
				}
				desc = tour_general.3001.desc_physique
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_good_martial }
				}
				desc = tour_general.3001.desc_martial
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_good_diplomacy }
				}
				desc = tour_general.3001.desc_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_good_stewardship }
				}
				desc = tour_general.3001.desc_stewardship
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_good_intrigue }
				}
				desc = tour_general.3001.desc_intrigue
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_good_learning }
				}
				desc = tour_general.3001.desc_learning
			}
			triggered_desc = {
				trigger = {
					scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_good_prowess }
				}
				desc = tour_general.3001.desc_prowess
			}
		}
		desc = tour_general.3001.desc_outro
	}
	theme = tour_stop
	left_portrait = {
		character = root
		animation = scheme
	}
	#Showcase our target, animation adapted to type of courtier
	right_portrait = {
		character = scope:tour_general_3001_target_courtier
		triggered_animation = {
			trigger = { 
				scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait }
			}
			animation = personality_irrational
		}
		triggered_animation = {
			trigger = { 
				scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
			}
			animation = admiration
		}
		animation = worry
	}
	#Showcase the vassal liege
	lower_right_portrait = {
		character = scope:stop_host_scope
	}
	
	cooldown = { years = 10 }
	trigger = {
		is_available_travelling_adult = yes
		scope:stop_host_scope = { NOT = { this = root } }
		exists = scope:stop_host_scope
		scope:stop_host_scope = {
			any_courtier = {
				OR = {
					tour_general_3001_courtier_to_steal_exists = yes
					AND = {
						scope:visiting_liege = { 
							OR = {
								has_trait = lunatic
								has_trait = possessed
							}
						}
						tour_general_3001_insane_courtier_to_steal_exists = yes
					}
					AND = {
						scope:visiting_liege = { is_cannibal_trigger = yes }
						tour_general_3001_delectable_courtier_to_steal_exists = yes
					}
				}
			}
		}
		NOT = { has_trait = blind }
	}
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				has_trait = callous
				has_trait = sadistic
				has_trait = arbitrary
			}
			add = 5
		}
		modifier = {
			OR = {
				has_trait = paranoid
				has_trait = compassionate
			}
			add = -2
		}
		modifier = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_intimidation
				}
			}
			factor = 2
		}
	}
	#Set up our scopes
	immediate = {
		select_local_animal_effect = { TYPE = prowling } # Save scope to limit possible animals: any/big/small/dangerous/harmless/prowling
		scope:stop_host_scope = {
			random_list = {
				50 = {
					trigger = {
						any_courtier = { tour_general_3001_courtier_to_steal_exists = yes }
					}
					random_courtier = {
						limit = { tour_general_3001_courtier_to_steal_exists = yes }
						save_scope_as = tour_general_3001_target_courtier
					}
				}
				#If we have an insanity trait, let's see if we can bring more insane people
				50 = {
					trigger = {
						any_courtier = { tour_general_3001_insane_courtier_to_steal_exists = yes }
						scope:visiting_liege = { 
							OR = {
								has_trait = lunatic
								has_trait = possessed
							}
						}
					}
					random_courtier = {
						limit = { tour_general_3001_insane_courtier_to_steal_exists = yes }
						save_scope_as = tour_general_3001_target_courtier
					}
				}
				#If we have particular tastes, let's see if we can bring more.. delectable.. people
				50 = {
					trigger = {
						any_courtier = { tour_general_3001_delectable_courtier_to_steal_exists = yes }
						scope:visiting_liege = { is_cannibal_trigger = yes }
					}
					random_courtier = {
						limit = { tour_general_3001_delectable_courtier_to_steal_exists = yes }
						save_scope_as = tour_general_3001_target_courtier
					}
				}
			}
		}
		#Determine the event flavor - what's the interesting characteristic of the courtier?
		scope:tour_general_3001_target_courtier = {
			random_list = {
				#Cannibal liege
				50 = {
					trigger = { has_trait = gluttonous }
					modifier = {
						OR = {
							scope:visiting_liege = { is_cannibal_trigger = yes }
							scope:stop_host_scope = { is_cannibal_trigger = yes }
						}
						factor = 2
					}
					add_character_flag = {
						flag = tour_general_3001_is_delectable
						days = 15
					}
				}
				#Lunatic/possessed liege
				50 = {
					trigger = {
						scope:visiting_liege = {
							OR = {
								has_trait = lunatic
								has_trait = possessed
							}
						}
						OR = {
							has_trait = lunatic
							has_trait = possessed
							has_trait = depressed
						}
					}
					add_character_flag = {
						flag = tour_general_3001_has_insanity_trait
						days = 15
					}
				}
				50 = {
					trigger = {
						has_trait_rank = {
							trait = beauty_good
							rank >= 1
						}
					}
					add_character_flag = {
						flag = tour_general_3001_has_beauty_trait
						days = 15
					}
				}
				50 = {
					trigger = {
						OR = {
							has_trait_rank = {
								trait = intellect_good
								rank >= 1
							}
							has_trait = shrewd
						}
					}
					add_character_flag = {
						flag = tour_general_3001_has_intellect_trait
						days = 15
					}
				}
				50 = {
					trigger = {
						OR = {
							has_trait_rank = {
								trait = physique_good
								rank >= 1
							}
							has_trait = strong
						}
					}
					add_character_flag = {
						flag = tour_general_3001_has_physique_trait
						days = 15
					}
				}
				25 = {
					trigger = { martial >= 20 }
					add_character_flag = {
						flag = tour_general_3001_has_good_martial
						days = 15
					}
				}
				25 = {
					trigger = { diplomacy >= 20 }
					add_character_flag = {
						flag = tour_general_3001_has_good_diplomacy
						days = 15
					}
				}
				25 = {
					trigger = { stewardship >= 20 }
					add_character_flag = {
						flag = tour_general_3001_has_good_stewardship
						days = 15
					}
				}
				25 = {
					trigger = { intrigue >= 20 }
					add_character_flag = {
						flag = tour_general_3001_has_good_intrigue
						days = 15
					}
				}
				25 = {
					trigger = { learning >= 20 }
					add_character_flag = {
						flag = tour_general_3001_has_good_learning
						days = 15
					}
				}
				25 = {
					trigger = { prowess >= 20 }
					add_character_flag = {
						flag = tour_general_3001_has_good_prowess
						days = 15
					}
				}
			}
		}
	}
	#Relocate the courtier forcefully
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { 
							scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
							is_cannibal_trigger = yes
						}
						desc = tour_general.3001.a_cannibal
					}
					triggered_desc = {
						trigger = { 
							scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait  }
							OR = {
								has_trait = lunatic
								has_trait = possessed
							}
						}
						desc = tour_general.3001.a_insanity
					}
					#Default
					triggered_desc = {
						desc = tour_general.3001.a
					}
				}
			}
		}
		trigger = {
			involved_activity = {
				has_activity_option = {
					category = special_type
					option = tour_type_intimidation
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { 
						scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
						is_cannibal_trigger = yes
					}
					desc = tour_general.3001.a_cannibal.flavor
				}
				triggered_desc = {
					trigger = { 
						scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait }
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
					desc = tour_general.3001.a_insanity.flavor
				}
				#Default
				triggered_desc = {
					desc = tour_general.3001.a.flavor
				}
			}
		}
		scope:stop_host_scope = {
			send_interface_toast = {
				type = event_toast_effect_bad
				left_icon = scope:visiting_liege
				right_icon = scope:tour_general_3001_target_courtier
				title = tour_general.3001.a.tt

				scope:visiting_liege = { 
					tour_general_3001_add_courtier_effect = yes
					tour_general_3001_calculate_relationship_decline_effect = yes
				}
				# TODO_CD_EP2 add reason and uncomment
				#progress_towards_rival_effect = {
				#	CHARACTER = scope:stop_host_scope
				#	OPINION = no
				#} 
			}
		}
		stress_impact = {
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			paranoid = major_stress_impact_gain
			craven = minor_stress_impact_gain
			deceitful = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
				add = 25
			}
			modifier = {
				OR = {
					has_trait = craven
					has_trait = paranoid
				}
				add = -25
			}
			ai_value_modifier = {
				ai_boldness = 2
				ai_greed = 1
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				OR = {
					has_relation_rival = scope:stop_host_scope
					has_relation_nemesis = scope:stop_host_scope
					opinion = {
						target = scope:stop_host_scope
						value <= low_negative_opinion
					}
				}
				add = 50
			}
			modifier = {
				ai_boldness >= medium_positive_ai_value
				ai_energy >= medium_positive_ai_value
				add = 25
			}
		}
	}
	#Request the courtier
	option = {
		name = tour_general.3001.b
		scope:stop_host_scope = { 
			trigger_event = {
				id = tour_general.1001
				days = 1
			} 
		}
		custom_tooltip = tour_general.3001.b_host_decides.tt
		stress_impact = {
			arrogant = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 10
			#The AI respects the vassal
			modifier = {
				OR = {
					has_relation_best_friend = scope:stop_host_scope
					has_relation_friend = scope:stop_host_scope
					opinion = {
						target = scope:stop_host_scope
						value >= medium_positive_opinion
					}
				}
				factor = 2
			}
			modifier = {
				has_trait = arrogant
				add = -25
			}
			modifier = {
				has_trait = honest
				add = 25
			}
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 2
				ai_rationality = 1
			}
		}
	}
	#Attempt to steal the courtier
	option = {
		name = tour_general.3001.c
		duel = {
			skill = intrigue
			target = scope:stop_host_scope
			#You steal them successfully
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 10
					min = 5
				}
				desc = tour_general_3001_stolen_courtier
				send_interface_toast = {
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:tour_general_3001_target_courtier
					title = tour_general.3001.c.tt_success

					tour_general_3001_add_courtier_effect = yes
				}
			}
			#You get caught
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -10
					min = 5
				}
				desc = tour_general_3001_failed_steal
				custom_tooltip = tour_general.3001.b_host_decides.tt
				if = {
					limit = {
						scope:stop_host_scope = {
							OR = {
								has_trait = lunatic
								has_trait = possessed
							}
						}
					}
					custom_tooltip = tour_general.3001.b.harmful_sideeffects.tt
				}
				send_interface_toast = {
					type = event_toast_text_bad
					left_icon = root
					right_icon = scope:stop_host_scope
					title = tour_general.3001.c.tt_failure
					desc = tour_general.3001.c.tt_failure.desc
				}
				add_character_flag = tour_general_3001_failed_courtier_theft
				scope:stop_host_scope = { 
					trigger_event = { 
						id = tour_general.1001
						days = 1
					}
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			paranoid = major_stress_impact_gain
			honest = major_stress_impact_gain
			deceitful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			modifier = {
				intrigue > scope:stop_host_scope.intrigue
				factor = 2
			}
			modifier = {
				ai_boldness >= medium_positive_ai_value
				ai_energy >= medium_positive_ai_value
				add = 25
			}
			modifier = {
				has_trait = deceitful
				add = 25
			}
			ai_value_modifier = {
				ai_boldness = 2
				ai_rationality = 1
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				scope:stop_host_scope = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
					}
				}
				add = -25
			}
		}
	}
	#Nah, this isn't a good idea
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { 
							scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
							is_cannibal_trigger = yes
						}
						desc = tour_general.3001.d_cannibal
					}
					triggered_desc = {
						trigger = { 
							scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait }
							OR = {
								has_trait = lunatic
								has_trait = possessed
							}
						}
						desc = tour_general.3001.d_insanity
					}
					#Default
					triggered_desc = {
						desc = tour_general.3001.d
					}
				}
			}
		}
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { 
						scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
						is_cannibal_trigger = yes
					}
					desc = tour_general.3001.d_cannibal.flavor
				}
				triggered_desc = {
					trigger = { 
						scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait }
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
					desc = tour_general.3001.d_insanity.flavor
				}
			}
		}
		if = {
			limit = {
				scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
				has_trait = cannibal
			}
			stress_impact = {
				cannibal = major_stress_impact_gain
			}
		}
		else_if = {
			limit = {
				scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_is_delectable }
				is_cannibal_trigger = yes
			}
			stress_impact = {
				base = major_stress_impact_gain
			}
		}
		else_if = {
			limit = {
				scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_3001_has_insanity_trait }
				OR = {
					has_trait = lunatic
					has_trait = possessed
				}
			}
			stress_impact = {
				lunatic_1 = major_stress_impact_gain
				lunatic_genetic = major_stress_impact_gain
				possessed_1 = major_stress_impact_gain
				lunatic_genetic = major_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				arrogant = miniscule_stress_impact_gain
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				OR = {
					ai_compassion >= high_positive_ai_value
					has_trait = paranoid
				}		
				add = 30
			}
			modifier = {
				has_trait = content
				add = 25
			}
			modifier = {
				is_cannibal_trigger = yes
				add = -25
			}
			modifier = {
				has_trait = lazy
				add = 25
			}
			ai_value_modifier = {
				ai_compassion = 1
				ai_energy = -1
			}
		}
	}
}

#Liege: Vassal has either decided to give you the courtier, attached terms or declined
tour_general.3002 = {
	type = activity_event
	title = {
		first_valid = {
			#Denied request
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_declined }
				}
				desc = tour_general.3002.title_denied
			}
			#Approved request
			triggered_desc = {
				desc = tour_general.3002.title
			}
		}
	}
	desc = {
		desc = tour_general.3002.intro
		first_valid = {
			#Give away courtier
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_gave_away_courtier }
				}
				desc = tour_general.3002.desc_free
			}
			#Request a hook
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_requested_hook }
				}
				desc = tour_general.3002.desc_hook
			}
			#Request gold
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_requested_gold }
				}
				desc = tour_general.3002.desc_gold
			}
			#Cannibal suggestion
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_offered_a_meal }
				}
				desc = tour_general.3002.desc_cannibal
			}
			#Declined
			triggered_desc = {
				trigger = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_declined }
				}
				desc =  tour_general.3002.desc_declined
			}
		}
	}
	theme = tour_stop
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { 
				scope:stop_host_scope = { 
					has_character_flag = tour_general_1001_declined } 
				}
			animation = disapproval
		}
		animation = personality_rational
	}
	right_portrait = {
		character = scope:stop_host_scope
		triggered_animation = {
			trigger = { has_character_flag = tour_general_1001_declined }
			animation = disapproval
		}
		animation = personality_dishonorable
	}
	lower_right_portrait = {
		character = scope:tour_general_3001_target_courtier
	}
	immediate = {
		#Set up cannibal secrets
		scope:stop_host_scope = {
			if = {
				limit = {
					any_secret = {
						secret_type = secret_cannibal
						NOT = { 
							any_secret_knower = { this = root } 
						}
					}
				}
				random_secret = {
					limit = {
						secret_type = secret_cannibal
						NOT = { 
							any_secret_knower = { this = root } 
						}
					}
					save_scope_as = tour_general_3002_host_cannibal_secret
				}
			}
		}
		if = {
			limit = {
				any_secret = {
					secret_type = secret_cannibal
					NOT = { 
						any_secret_knower = { this = scope:stop_host_scope } 
					}
				}
			}
			random_secret = {
				limit = {
					secret_type = secret_cannibal
					NOT = { 
						any_secret_knower = { this = scope:stop_host_scope } 
					}
				}
				save_scope_as = tour_general_3002_liege_cannibal_secret
			}
		}
	}
	#Giving up the courtier; no strings
	option = {
		name = tour_general.3002.a
		trigger = {
			scope:stop_host_scope = { has_character_flag = tour_general_1001_gave_away_courtier }
		}
		scope:stop_host_scope = {
			send_interface_toast = {
				type = event_toast_effect_good
				left_icon = scope:stop_host_scope
				right_icon = scope:visiting_liege
				title = tour_general.3001.tt_positive

				scope:visiting_liege = { 
					tour_general_3001_add_courtier_effect = yes 
					add_opinion = {
						target = scope:stop_host_scope
						modifier = ep2_humored_liege_opinion
					 	opinion = 25
					}
				}
				# TODO_CD_EP2 add reason and uncomment
				#progress_towards_friend_effect = {
				#	CHARACTER = scope:stop_host_scope
				#	OPINION = no
				#}
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				has_trait = paranoid
				add = -30
			}
			modifier = {
				has_trait = craven
				add = -15
			}
			ai_value_modifier = {
				ai_greed = 2
			}
		}
	}
	#Relocate the courtier forcefully
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { 
							scope:tour_general_3001_target_courtier = { has_character_flag = tour_general_1001_declined }
						}
						desc = tour_general.3002.b_declined
					}
					#Default
					triggered_desc = {
						desc = tour_general.3002.b
					}
				}
			}
		}
		trigger = {
			scope:stop_host_scope = { 
				NOR = { 
					has_character_flag = tour_general_1001_gave_away_courtier
					has_character_flag = tour_general_1001_offered_a_meal
				}
			}
		}
		flavor = tour_general.3001.a.flavor
		scope:stop_host_scope = {
			send_interface_toast = {
				type = event_toast_effect_bad
				left_icon = scope:stop_host_scope
				right_icon = scope:visiting_liege
				title = tour_general.3001.a.tt
				
				scope:visiting_liege = { 
					tour_general_3001_add_courtier_effect = yes
					tour_general_3001_calculate_relationship_decline_effect = yes
				}
				# TODO_CD_EP2 add reason and uncomment
				#progress_towards_rival_effect = {
				#	CHARACTER = scope:stop_host_scope
				#	OPINION = no
				#}
			}
		}
		stress_impact = {
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			paranoid = major_stress_impact_gain
			craven = minor_stress_impact_gain
			deceitful = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
				add = 25
			}
			modifier = {
				OR = {
					has_trait = craven
					has_trait = paranoid
				}
				add = -25
			}
			ai_value_modifier = {
				ai_vengefulness = 2
				ai_boldness = 1
				ai_greed = 1
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				OR = {
					has_relation_rival = scope:stop_host_scope
					has_relation_nemesis = scope:stop_host_scope
					opinion = {
						target = scope:stop_host_scope
						value < low_positive_opinion
					}
				}
				ai_vengefulness >= low_positive_ai_value
				factor = 2
			}
			modifier = {
				ai_boldness >= medium_positive_ai_value
				ai_energy >= low_positive_ai_value
				add = 25
			}
		}
	}
	#Hook yes
	option = {
		name = tour_general.3002.c
		trigger = {
			scope:stop_host_scope = { has_character_flag = tour_general_1001_requested_hook }
		}
		scope:stop_host_scope = {
			send_interface_toast = {
				type = event_toast_effect_good 
				left_icon = scope:stop_host_scope
				right_icon = scope:tour_general_3001_target_courtier
				title = tour_general.3001.tt_positive

				scope:visiting_liege = { tour_general_3001_add_courtier_effect = yes }
				add_hook = {
					type = favor_hook
					target = scope:visiting_liege
				}
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				has_trait = paranoid
				add = -30
			}
			modifier = {
				has_trait = craven
				add = -15
			}
			ai_value_modifier = {
				ai_greed = -0.5
			}
		}
	}
	#Gold yes
	option = {
		name = tour_general.3002.d
		trigger = {
			scope:stop_host_scope = { has_character_flag = tour_general_1001_requested_gold }
		}
		scope:stop_host_scope = {
			send_interface_toast = {
				type = event_toast_effect_good 
				left_icon = scope:stop_host_scope
				right_icon = scope:tour_general_3001_target_courtier
				title = tour_general.3001.tt_positive

				scope:visiting_liege = { 
					tour_general_3001_add_courtier_effect = yes
					pay_short_term_gold = {
						target = scope:stop_host_scope
						gold = medium_gold_value
					}
				}
			}
		}
		ai_chance = {
			base = 0
			#Gold? I have plenty!
			modifier = {
				short_term_gold > root.major_gold_value
				add = 50
			}
			modifier = {
				short_term_gold > root.medium_gold_value
				add = 10
			}
			ai_value_modifier = {
				ai_rationality = 1
				ai_greed = -2
				ai_vengefulness = -0.5
			}
		}
	}
	#Nah, too rich for my taste
	option = {
		name = tour_general.3002.e
		trigger = {
			NOT = { 
				scope:stop_host_scope = { 
					OR = {
						has_character_flag = tour_general_1001_offered_a_meal 
						has_character_flag = tour_general_1001_declined
					}
				}
			}
		}
		scope:stop_host_scope = {
			send_interface_toast = {
				type = event_toast_text_bad 
				left_icon = scope:stop_host_scope
				right_icon = scope:tour_general_3001_target_courtier
				title = tour_general.3001.tt_negative
				desc = tour_general.3001.desc_negative
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				AND = {
					scope:stop_host_scope = { has_character_flag = tour_general_1001_requested_gold }
					has_trait = greedy
				}
				add = 50
			}
			ai_value_modifier = {
				ai_greed = 1
				ai_rationality = -1
			}
		}
	}
	#Host turns out to be a cannibal
	##Cannibal yes, let's dine
	option = {
		name = tour_general.3002.f
		trigger = {
			scope:stop_host_scope = { has_character_flag = tour_general_1001_offered_a_meal }
		}
		flavor = tour_general.1001.d.flavor
		if = {
			limit = {
				exists = scope:tour_general_3002_host_cannibal_secret
			}
			scope:tour_general_3002_host_cannibal_secret = {
				reveal_to = root
			}
		}
		if = {
			limit = {
				exists = scope:tour_general_3002_liege_cannibal_secret
			}
			scope:tour_general_3002_liege_cannibal_secret = {
				reveal_to = scope:stop_host_scope
			}
		}
		#If we're NOT a cannibal; do we want to become a cannibal...?
		if = {
			limit = { is_cannibal_trigger = no }
			add_secret = { type = secret_cannibal }
		}
		trigger_event = { 
			id = tour_general.1002
			days = 1
		}
		scope:stop_host_scope = {
			trigger_event = { 
				id = tour_general.1002
				days = 1
			}
			add_opinion = {
				target = root
				modifier = also_cannibal
			 	opinion = 20
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				OR = {
					any_secret = {
						secret_type = secret_cannibal
					}
					has_trait = cannibal
				}
				add = 100
			}
			modifier = {
				stress_level > 1
				add = 100
			}
			modifier = {
				has_trait = compassionate
				add = -100
			}
			modifier = {
				has_trait = paranoid
				add = -30
			}
			ai_value_modifier = {
				ai_boldness = 1
				ai_energy = 1
				ai_compassion = -2
				ai_zeal = -1
			}
		}
	}
	##Cannibal no, and expose their secret
	option = {
		name = tour_general.3002.g
		trigger = {
			scope:stop_host_scope = { has_character_flag = tour_general_1001_offered_a_meal }
		}
		if = {
			limit = {
				scope:stop_host_scope = {
					NOT = { has_trait = cannibal }
				}
				exists = scope:tour_general_3002_host_cannibal_secret
			}
			scope:tour_general_3002_host_cannibal_secret = {
				expose_secret = root
			}
			reverse_add_opinion = {
				target = scope:stop_host_scope
				modifier = exposed_my_secret_opinion
			 	opinion = -25
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:stop_host_scope
				modifier = ep2_declined_exotic_dinner_inviation_opinion
			 	opinion = -25
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				has_trait = paranoid	
				add = 30
			}
			modifier = {
				has_trait = craven	
				add = 15
			}
			modifier = {
				has_trait = honest
				add = 30
			}
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = 2
				ai_zeal = 1
			}
		}
	}
	#Host did not want to give up courtier
	##Oh well
	option = {
		name = tour_general.3002.h
		trigger = {
			scope:stop_host_scope = { has_character_flag = tour_general_1001_declined }
		}
		if = {
			limit = {
				is_ai = yes
				has_trait = forgiving
			}
			scope:stop_host_scope = {
				send_interface_toast = {
					type = event_toast_text_and_effect_bad 
					left_icon = scope:stop_host_scope
					right_icon = scope:visiting_liege
					title = tour_general.3002.h.tt
					desc = tour_general.3002.h.tt.desc

					scope:visiting_liege = {
						add_opinion = {
							target = scope:stop_host_scope
							modifier = insult_opinion
						 	opinion = -25
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				is_ai = no
				NOT = { has_trait = forgiving }
			}
			scope:stop_host_scope = {
				send_interface_toast = {
					type = event_toast_text_and_effect_bad 
					left_icon = scope:stop_host_scope
					right_icon = scope:visiting_liege
					title = tour_general.3002.h.tt
					desc = tour_general.3002.h.tt.desc

					scope:visiting_liege = {
						# TODO_CD_EP2 add reason and uncomment
						#progress_towards_rival_effect = {
						#	CHARACTER = scope:stop_host_scope
						#	OPINION = no
						#}
					}
				}
			}
		}
		else = {
			scope:stop_host_scope = {
				send_interface_toast = {
					type = event_toast_text_neutral
					left_icon = scope:stop_host_scope
					right_icon = scope:visiting_liege
					title = tour_general.3001.tt_positive
					desc = tour_general.3001.desc_negative
				}
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			generous = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			calm = minor_stress_impact_loss		
		}
		ai_chance = {
			base = 10
			#The AI respects the vassal
			modifier = {
				OR = {
					has_relation_best_friend = scope:stop_host_scope
					has_relation_friend = scope:stop_host_scope
					opinion = {
						target = scope:stop_host_scope
						value <= low_negative_opinion
					}
				}
				add = 50
			}
			modifier = {
				has_trait = arrogant
				add = -25
			}
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 2
				ai_rationality = 0.5
			}
		}
	}
	after = {
		scope:stop_host_scope = {
			remove_character_flag = tour_general_1001_gave_away_courtier
			remove_character_flag = tour_general_1001_requested_hook
			remove_character_flag = tour_general_1001_requested_gold
			remove_character_flag = tour_general_1001_offered_a_meal
			remove_character_flag = tour_general_1001_declined
		}	
	}
}

###################
##	tour_general.9999
##	Letter event to vassal notifying them of upcoming visit from their liege
##	by Chad Uhl 
###################

tour_general.9999 = {
	type = letter_event
	opening = tour_general.9999.opening
	desc = {
		desc = tour_general.9999.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_phase = { type = tour_phase_tour_grounds location = root.capital_province }
					}
				}
				desc = tour_general.9999.phase_tour_grounds
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_phase = { type = tour_phase_dinner location = root.capital_province }
					}
				}
				desc = tour_general.9999.phase_dinner
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_phase = { type = tour_phase_cultural_festival location = root.capital_province }
					}
				}
				desc = tour_general.9999.phase_cultural_festival
			}
			desc = tour_general.9999.phase_fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = { category = special_type option = tour_type_majesty }
					}
				}
				desc = tour_general.9999.type_taxation
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = { category = special_type option = tour_type_intimidation }
					}
				}
				desc = tour_general.9999.type_taxation
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = { category = special_type option = tour_type_taxation }
					}
				}
				desc = tour_general.9999.type_taxation
			}
		}
		desc = tour_general.9999.closing
	}
	sender = scope:host

	option = {
		name = tour_general.9999.a
	}
}

# Liege is no longer visiting by James Beaumont
tour_general.9998 = {
	type = letter_event
	opening = tour_general.9998.opening
	desc = tour_general.9998.desc
	sender = scope:steward

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_steward
			}
			cp:councillor_steward = { save_scope_as = steward }
		}
		else_if = {
			limit = {
				any_courtier = {
					is_adult = yes
				}
			}
			random_courtier = {
				limit = { is_adult = yes }
				save_scope_as = steward
			}
		}
		else = {
			random_pool_character = {
				province = root.capital_province
				limit = {
					is_adult = yes
				}
				save_scope_as = steward
			}
		}
	}

	option = {
		name = tour_general.9998.a
	}
}
