﻿namespace = prelude_events

#####################################
# By Veronica Pazos
# prelude_events.0001 - Host: Regent likes you and tells everyone how great you are
# prelude_events.0010 - Host: Regent dislikes you and tells everyone how bad you are
# prelude_events.0020 - Host: There's a faction against you, try to get them to stop
# prelude_events.0030 - Guest: Your friend/lover is here!
# prelude_events.0040 - Guest: Your rival is here!
# prelude_events.0050 - Guest: Your family member is here!
# prelude_events.0060 - Guest: The Beautiful Capital
# prelude_events.0070 - Guest: Host offers you a seat in the council
# prelude_events.0080 - Host/Guest: Nice guest offers you skillful courtier
# prelude_events.0090 - Nomadic Host: Your nomadic guest arrives with some herd
# prelude_events.0100 - Host: Vassals ask you to build more in their realms
# prelude_events.0110 - Host: Different culture vassal asks you to say some words to them specifically
# prelude_events.0120 - Host: Cool guest gives you an artifact
# prelude_events.0130 - Host: officiator blesses your artifact
# prelude_events.0140 - Guest: Say some words to the host
# prelude_events.0150 - Guest: Host introduces you to a cool guest
# prelude_events.0160 - Guest: Guest of your dynasty is here!
# prelude_events.0170 - Guest: You talk to a guest of a different faith
# prelude_events.0180 - Host/Guest: You pray at the coronation chapel
# prelude_events.0190 - Host: Councillor that likes you encourages you
#####################################

# Regent likes you and tells everyone how great you are
scripted_trigger prelude_events_0001_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	NOR = {
		this = root
		involved_activity.var:officiator ?= this
		has_trait = greedy
		is_in_guest_subset = { name = supporter }
		is_in_guest_subset = { name = detractor }
	}
}
	
prelude_events.0001 = {
	type = activity_event
	title = prelude_events.0001.t
	desc = prelude_events.0001.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:guest
		animation = admiration
	}
	lower_left_portrait = scope:regent
	
	cooldown = { years = 10 }
	
	trigger = {
		has_active_diarchy = yes
		diarchy_swing <= 50
		# Not a thing for Co-Rulerships
		has_diarchy_active_parameter = diarchy_is_regency
		diarch ?= {
			opinion = {
				target = root
				value >= 45
			}
		}
		involved_activity = {
			NOT = { # Regent is not in the activity
				any_attending_character = {
					this = root.diarch
				}
			}
			any_attending_character = { 
				prelude_events_0001_appropriate_guest = yes
			}
		}
	}

	immediate = {
		diarch = { save_scope_as = regent }
		involved_activity = {
			random_attending_character = {
				limit = {
					prelude_events_0001_appropriate_guest = yes
				}
				weight = { # More likely to grab someone you actually want as a supporter
					base = 1
					modifier = {
						add = 1
						has_trait = generous
					}
					modifier = {
						add = 1
						has_trait = profligate
					}
					modifier = {
						add = 5
						highest_held_title_tier >= tier_kingdom
					}
					modifier = {
						add = 10
						is_powerful_vassal_of = root
					}
				}
				save_scope_as = guest
			}
		}
		hidden_effect = {
			scope:guest = {
				add_short_term_gold = medium_gold_value
				assign_quirk_effect = yes
			}
		}
	}
	
	option = { # I don't even have to speak myself!
		name = prelude_events.0001.a
		trigger = {
			has_trait = shy
		}
		add_character_modifier = {
			modifier = silent_coronation_modifier
			years = 1
		}
		stress_impact = {
			shy = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = shy
				factor = 2
			}
		}
	}
	
	option = { # Damn right
		name = prelude_events.0001.b
		custom_tooltip = prelude_events.0001.b.tt.supporter
		scope:guest = {
			pay_short_term_gold = {
				target = root
				gold = {
					value = medium_gold_value # Roughly the gift value
					multiply = 0.5
				}
			}
		}
		involved_activity = {
			add_to_guest_subset = {
				name = supporter
				target = scope:guest
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
				}
				factor = 0
			}
		}
	}
	
	option = { # Give me prestige pls
		name = prelude_events.0001.c
		custom_tooltip = {
			text = prelude_events.0001.c.tt.every_supporter
			add_prestige = {
				value = 20
				multiply = number_of_supporters
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_loss
			shy = major_stress_impact_gain
			greedy = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = shy
					has_trait = greedy
				}
				factor = 0
			}
		}
	}
}

# Regent dislikes you and tells everyone how bad you are
scripted_trigger prelude_events_0010_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_landed = yes
	is_healthy = yes
	NOR = {
		this = root
		involved_activity.var:officiator ?= this
	}
	is_in_guest_subset = { name = detractor }
}

scripted_trigger prelude_events_0010_can_create_faction_vassal_trigger = {
	is_landed = yes
	can_create_faction = {
		type = independence_faction
		target = prev
	}
	NOR = {
		is_allied_to = prev
		is_close_family_of = prev
		is_spouse_of = prev
	}
}

scripted_effect prelude_events_0010_screw_over_guest_effect = {
	if = {
		limit = {
			any_targeting_faction = {
				exists = yes
				NOT = { exists = faction_war }
			}
		}
		random_targeting_faction = {
			limit = {
				exists = yes
				NOT = { exists = faction_war }
			}
			faction_leader ?= { save_scope_as = leader }
			add_faction_discontent = 50
		}
	}
	else_if = {
		limit = {
			any_vassal = {
				prelude_events_0010_can_create_faction_vassal_trigger = yes
			}
		}
		random_vassal = {
			limit = { prelude_events_0010_can_create_faction_vassal_trigger = yes }
			create_faction = {
				type = independence_faction
				target = scope:guest
			}
			save_scope_as = leader
		}
	}
	else = {
		scope:leader = {
			create_faction = {
				type = peasant_faction
				target = scope:guest
			}
		}
	}
}
	
prelude_events.0010 = {
	type = activity_event
	title = prelude_events.0010.t
	desc = prelude_events.0010.desc
	theme = coronation_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = craven
			}
			animation = fear
		}
		animation = anger
	}
	center_portrait = {
		character = scope:guest_2
		animation = laugh
		camera = camera_event_center_close_to_right
	}
	right_portrait = {
		character = scope:guest
		animation = schadenfreude
		camera = camera_event_right_pointing_right
	}
	lower_left_portrait = scope:regent
	lower_right_portrait = {
		trigger = {
			exists = scope:leader
		}
		character = scope:leader
	}
	
	cooldown = { years = 10 }
	
	trigger = {
		has_active_diarchy = yes
		# Not a thing for Co-Rulerships
		has_diarchy_active_parameter = diarchy_is_regency
		diarch ?= {
			opinion = {
				target = root
				value < 25
			}
		}
		involved_activity = {
			NOT = { # Regent is not in the activity
				any_attending_character = {
					this = root.diarch
				}
			}
			any_attending_character = { 
				prelude_events_0010_appropriate_guest = yes
				count >= 2
			}
		}
	}

	immediate = {
		diarch = { save_scope_as = regent }
		involved_activity = {
			random_attending_character = {
				limit = {
					prelude_events_0010_appropriate_guest = yes
				}
				weight = { # More likely to grab someone that's relevant
					base = 1
					modifier = {
						add = 5
						any_targeting_faction = {
							exists = yes
							NOT = { exists = faction_war }
						}
					}
					modifier = {
						add = 5
						highest_held_title_tier >= tier_kingdom
					}
					modifier = {
						add = 10
						is_powerful_vassal_of = root
					}
				}
				save_scope_as = guest
			}
			random_attending_character = {
				limit = {
					prelude_events_0010_appropriate_guest = yes
					NOT = { this = scope:guest }
				}
				save_scope_as = guest_2
			}
		}
		hidden_effect = {
			scope:guest = {
				assign_quirk_effect = yes
			}
		}
		hidden_effect_new_object = {
			create_character = {
				location = scope:guest.capital_province
				template = peasant_faction_leader_template
				gender_female_chance = root_faith_dominant_gender_adjusted_female_chance
				faith = scope:guest.capital_county.faith
				culture = scope:guest.capital_county.culture
				save_scope_as = leader
			}
		}
	}
	
	option = { # They're plotting, PLOTTING!!!
		name = prelude_events.0010.a
		trigger = {
			has_trait = paranoid
		}
		update_diarchy_swing_with_perspective_effect = {
			SWING = major_sop_swing_liege_gain
			LIEGE = root
		}
		stress_impact = {
			paranoid = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = paranoid
				factor = 2
			}
		}
	}
	
	option = { # This is my moment
		name = prelude_events.0010.b
		trigger = {
			has_activity_intent = coronation_weaken_detractors
		}
		custom_tooltip = available_because_intent_tt
		add_internal_flag = special
		scope:guest = {
			prelude_events_0010_screw_over_guest_effect = yes
		}
		coronation_weaken_detractors_opinion_effect = yes
		stress_impact = {
			deceitful = major_stress_impact_loss
			vengeful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			just = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = deceitful
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = just
					has_trait = craven
				}
				factor = 0
			}
		}
	}
	
	option = { # Infiltrate their court
		name = prelude_events.0010.c
		trigger = {
			NOT = { has_activity_intent = coronation_weaken_detractors } # It's just a worse version
		}
		duel = {
			skill = intrigue
			value = high_skill_rating
			50 = { # They are convinced
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = prelude_events.0010.c.tt.success
				send_interface_toast = {
					title = prelude_events.0010.c.tt.success
					left_icon = scope:leader
					right_icon = scope:guest
					scope:guest = {
						prelude_events_0010_screw_over_guest_effect = yes
					}
				}
			}
			50 = { # They are indifferent
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = prelude_events.0010.c.tt.failure
				send_interface_toast = {
					title = prelude_events.0010.c.tt.failure
					left_icon = root
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			deceitful = major_stress_impact_loss
			vengeful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			just = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = deceitful
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = just
					has_trait = craven
				}
				factor = 0
			}
		}
	}
	
	option = { # Bribe the guy
		name = prelude_events.0010.d
		pay_short_term_gold = {
			target = scope:guest
			gold = minor_gold_value
		}
		custom_tooltip = {
			text = prelude_events.0010.d.supporter.tt
			involved_activity = {
				remove_from_guest_subset = {
					name = detractor
					target = scope:guest
				}
				add_to_guest_subset = {
					name = supporter
					target = scope:guest
				}
			}
		}
		stress_impact = {
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					gold <= medium_gold_value
				}
				factor = 0
			}
		}
	}
	
	option = { # I don't care enough
		name = prelude_events.0010.e
		trigger = {
			NOT = {
				has_trait = paranoid
			}
		}
		update_diarchy_swing_with_perspective_effect = {
			SWING = medium_sop_swing_diarch_gain
			LIEGE = root
		}
		stress_impact = {
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 0
			}
		}
	}
}

# There's a faction against you, try to get them to stop
scripted_trigger prelude_events_0020_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	this != root
	is_in_guest_subset = { name = detractor }
}

scripted_effect prelude_events_0020_weaken_faction_effect = {
	if = { # If one of them is the faction leader we make the faction less strong
		limit = {
			scope:faction = {
				faction_leader ?= {
					OR = {
						scope:faction_member = this
						scope:faction_member_2 = this
					}
				}
			}
		}
		if = {
			limit = {
				scope:faction = { faction_discontent >= 15 }
			}
			scope:faction = { add_faction_discontent = { -15 -20 } }
		}
		else_if = { # Add a strong hook on the Faction Leader
			limit = {
				scope:faction = {
					faction_leader ?= { scope:faction_member = this }
				}
				can_add_hook = {
					target = scope:faction_member
					type = life_threat_hook
				}
			}
			add_dread = medium_dread_gain
			add_hook = {
				target = scope:faction_member
				type = life_threat_hook
			}
		}
		else_if = {
			limit = {
				scope:faction = {
					faction_leader ?= { scope:faction_member_2 = this }
				}
				can_add_hook = {
					target = scope:faction_member_2
					type = life_threat_hook
				}
			}
			add_dread = medium_dread_gain
			add_hook = {
				target = scope:faction_member_2
				type = life_threat_hook
			}
		}
		else = {
			add_dread = medium_dread_gain
			if = {
				limit = {
					government_allows = administrative
					top_liege = scope:activity.activity_host
				}
				change_influence = minor_influence_gain
			}
			else = {
				add_prestige = minor_prestige_gain
			}
		}
	}
	else = { # Otherwise we straight up remove them
		scope:faction_member = {
			leave_faction_with_cooldown_effect = {
				FACTION = scope:faction
				YEARS = 20
			}
		}
	}
}

prelude_events.0020 = {
	type = activity_event
	title = prelude_events.0020.t
	desc = {
		desc = prelude_events.0020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:faction = { faction_leader ?= { scope:faction_member = this } }
				}
				desc = prelude_events.0020.desc.faction_member
			}
			triggered_desc = {
				trigger = {
					scope:faction = { faction_leader ?= { scope:faction_member_2 = this } }
				}
				desc = prelude_events.0020.desc.faction_member_2
			}
			desc = prelude_events.0020.desc.no_leader
		}
		desc = prelude_events.0020.desc.outro
	}
	theme = coronation_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = compassionate
					has_trait = gregarious
					has_trait = trusting
				}
			}
			animation = shock
		}
		animation = disapproval
	}
	center_portrait = {
		trigger = { exists = scope:faction_member_2 }
		character = scope:faction_member_2
		animation = schadenfreude
		camera = camera_event_center_close_to_right
	}
	right_portrait = {
		character = scope:faction_member
		animation = scheme
		camera = camera_event_right_pointing_right_scheme
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		has_activity_intent = coronation_weaken_detractors
		any_targeting_faction = {
			exists = yes
			NOT = { exists = faction_war }
			any_faction_member = {
				is_participant_in_activity = root.involved_activity
				save_temporary_scope_as = faction_member_temp
			}
		}
		involved_activity = {
			any_attending_character = {
				prelude_events_0020_appropriate_guest = yes
				this != scope:faction_member_temp
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			target_of_powerful_faction_trigger = yes
			factor = 2
		}
	}

	immediate = {
		ordered_targeting_faction = { # We grab the most pressing faction
			limit = {
				exists = yes
				NOT = { exists = faction_war }
				any_faction_member = {
					is_participant_in_activity = root.involved_activity
				}
			}
			order_by = faction_power
			save_scope_as = faction
			random_faction_member = {
				limit = { is_participant_in_activity = root.involved_activity }
				save_scope_as = faction_member
			}
		}
		if = {
			limit = {
				scope:faction = {
					any_faction_member = {
						is_participant_in_activity = root.involved_activity
						NOT = { this = scope:faction_member }
					}
				}
			}
			scope:faction = {
				random_faction_member = {
					limit = {
						is_participant_in_activity = root.involved_activity
						NOT = { this = scope:faction_member }
					}
					save_scope_as = faction_member_2
				}
			}
		}
		else = {
			involved_activity = {
				random_attending_character = {
					limit = {
						prelude_events_0020_appropriate_guest = yes
						this != scope:faction_member
					}
					save_scope_as = faction_member_2
				}
			}
		}
	}
	
	option = { # Tell them to drop it
		name = prelude_events.0020.a
		trigger = {
			OR = {
				has_focus = education_diplomacy
				has_focus_or_focus_trait_trigger = { FOCUS = diplomacy_foreign_affairs_focus }
			}
		}
		reason = lifestyle_focus
		add_internal_flag = special
		prelude_events_0020_weaken_faction_effect = yes
		coronation_weaken_detractors_opinion_effect = yes
		stress_impact = {
			arrogant = major_stress_impact_loss
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_focus = education_diplomacy
					has_focus_or_focus_trait_trigger = { FOCUS = diplomacy_foreign_affairs_focus }
				}
				factor = 2
			}
			modifier = {
				has_trait = craven
				factor = 0
			}
		}
	}
	
	option = { # _Try_ to tell them to drop it
		name = prelude_events.0020.b
		trigger = {
			NOR = {
				has_focus = education_diplomacy
				has_focus_or_focus_trait_trigger = { FOCUS = diplomacy_foreign_affairs_focus }
			}
		}
		duel = {
			skill = diplomacy
			target = scope:faction_member
			50 = { # They are convinced
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = prelude_events.0020.b.tt.success
				send_interface_toast = {
					title = prelude_events.0020.b.tt.success
					right_icon = scope:faction_leader
					prelude_events_0020_weaken_faction_effect = yes
					coronation_weaken_detractors_opinion_effect = yes
				}
			}
			50 = { # They are indifferent
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = prelude_events.0020.b.tt.failure
				send_interface_toast = {
					title = prelude_events.0020.b.tt.failure
					left_icon = root
					if = {
						limit = {
							government_allows = administrative
							top_liege = scope:activity.activity_host
						}
						change_influence = minor_influence_loss
					}
					else = {
						add_prestige = minor_prestige_loss
					}
				}
			}
		}
		stress_impact = {
			deceitful = major_stress_impact_loss
			vengeful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			just = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = deceitful
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = just
					has_trait = craven
				}
				factor = 0
			}
		}
	}
	
	option = { # Bribe the guy
		name = prelude_events.0020.c
		trigger = {
			scope:faction = {
				faction_leader ?= {
					OR = {
						scope:faction_member = this
						scope:faction_member_2 ?= this
					}
				}
			}
		}
		if = {
			limit = {
				scope:faction = {
					faction_leader ?= {
						NOT = {
							scope:faction_member = this
						}
					}
				}
			}
			pay_short_term_gold = {
				target = scope:faction_member
				gold = medium_gold_value
			}
			scope:faction_member = {
				leave_faction_with_cooldown_effect = {
					FACTION = scope:faction
					YEARS = 20
				}
			}
		}
		else_if = {
			limit = {
				scope:faction = {
					faction_leader ?= {
						NOT = {
							scope:faction_member_2 = this
						}
					}
					any_faction_member = { this = scope:faction_member_2 }
				}
			}
			pay_short_term_gold = {
				target = scope:faction_member_2
				gold = medium_gold_value
			}
			scope:faction_member_2 = {
				leave_faction_with_cooldown_effect = {
					FACTION = scope:faction
					YEARS = 20
				}
			}
		}
		else = {
			add_dread = medium_dread_gain
		}
		
		stress_impact = {
			deceitful = major_stress_impact_loss
			vengeful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			just = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = deceitful
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = just
					has_trait = craven
				}
				factor = 0
			}
		}
	}
	
	option = { # Whatever, man
		name = prelude_events.0020.d
		scope:faction = { add_faction_discontent = 5 }
		stress_impact = {
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					gold <= medium_gold_value
				}
				factor = 0
			}
		}
	}
}

# Guest: Your friend/lover is here!
scripted_trigger prelude_events_0030_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	this != root
	this != scope:host
	OR = {
		has_relation_soulmate = root
		has_relation_lover = root
		has_relation_best_friend = root
		has_relation_friend = root
		has_relation_blood_brother = root
		has_relation_crush = root
	}
}
	
prelude_events.0030 = {
	type = activity_event
	title = prelude_events.0030.t
	desc = {
		desc = prelude_events.0030.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:guest = { has_relation_lover = root }
				}
				desc = prelude_events.0030.desc.lover
			}
			desc = prelude_events.0030.desc.friend
		}
	}
	theme = coronation_activity
	center_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:guest
		triggered_animation = {
			trigger = { has_relation_lover = root }
			animation = flirtation
		}
		animation = admiration
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		this != involved_activity.activity_host
		involved_activity = {
			any_attending_character = { 
				prelude_events_0030_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			involved_activity = {
				any_attending_character = {
					OR = {
						has_relation_soulmate = root
						has_relation_blood_brother = root
						has_relation_best_friend = root
					}
				}
			}
			add = 1
		}
	}	

	immediate = {
		involved_activity = {
			save_scope_as = activity
			activity_host ?= { save_scope_as = host }
			random_attending_character = { 
				limit = {
					prelude_events_0030_appropriate_guest = yes
				}
				weight = {
					base = 1
					modifier = {
						OR = {
							has_relation_soulmate = root
							has_relation_blood_brother = root
							has_relation_best_friend = root
						}
						add = 5
					}
				}
				save_scope_as = guest
			}
		}
	}
	
	option = { # Sneak out
		name = prelude_events.0030.a
		trigger = {
			has_relation_lover = scope:guest
		}
		had_sex_with_effect = {
			CHARACTER = scope:guest
			PREGNANCY_CHANCE = pregnancy_chance
		}
		progress_towards_lover_effect = {
			REASON = lover_coronation_prelude_sneak_out
			CHARACTER = scope:guest
			OPINION = 15
		}
		stress_impact = {
			lustful = major_stress_impact_loss
			rakish = major_stress_impact_loss
			shy = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				OR = {
					has_trait = lustful
					has_trait = rakish
				}
				add = 200
			}
			modifier = {
				has_trait = shy
				factor = 0
			}
		}
	}
	
	option = { # Ask for a favor
		name = prelude_events.0030.b
		reason = hook
		add_internal_flag = special
		trigger = {
			has_hook = scope:guest
		}
		remove_hook = { target = scope:guest }
		scope:guest = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
				}
				factor = 0
			}
		}
	}
	
	option = { # Ask for a favor -- give them a hook on you
		name = prelude_events.0030.c
		trigger = {
			NOR = {
				has_hook = scope:guest
			}
			scope:guest = {
				can_add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		scope:guest = {
			add_hook = {
				target = root
				type = favor_hook
			}
		}
		scope:guest = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
				}
				factor = 0
			}
		}
	}
	
	option = { # Let's pregame
		name = prelude_events.0030.d
		trigger = {
			NOT = { has_relation_lover = scope:guest }
		}
		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 10
			}
		}
		else = {
			random = {
				chance = 15
				add_trait = lifestyle_reveler
			}
		}
		scope:guest = {
			add_opinion = {
				target = root
				modifier = amused_opinion
				opinion = 15
			}
		}
		if = {
			limit = {
				involved_activity = {
					any_attending_character = {
						this != root
						this != scope:guest
						OR = {
							has_trait = lifestyle_reveler
							has_trait = gregarious
							has_trait = drunkard
						}
					}
				}
			}
			involved_activity = {
				every_attending_character = {
					limit = {
						this != root
						this != scope:guest
						OR = {
							has_trait = lifestyle_reveler
							has_trait = gregarious
							has_trait = drunkard
						}
					}
					custom = every_party_character
					add_opinion = {
						target = root
						modifier = amused_opinion
						opinion = 10
					}
				}
			}
		}
		stress_impact = {
			lifestyle_reveler = medium_stress_loss
			gregarious = medium_stress_loss
			drunkard = medium_stress_loss
			temperate = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = lifestyle_reveler
					has_trait = gregarious
					has_trait = drunkard
				}
				factor = 2
			}
			modifier = {
				has_trait = temperate
				factor = 0
			}
		}
	}
	
	option = { # Nice to see you!
		name = prelude_events.0030.e
		stress_impact = {
			base = medium_stress_impact_loss
			paranoid = medium_stress_impact_loss
			shy = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = paranoid
					has_trait = shy
				}
				factor = 2
			}
		}
	}
}

# Guest: Your rival is here!
scripted_trigger prelude_events_0040_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	this != root
	this != scope:host
	mother ?= { this != root.mother }
	OR = {
		has_relation_nemesis = root
		has_relation_rival = root
		has_relation_potential_rival = root
		has_relation_bully = root
	}
	NOT = {
		has_dread_level_towards = {
			target = root
			level >= 2
		}
	}
}
	
prelude_events.0040 = {
	type = activity_event
	title = prelude_events.0040.t
	desc = prelude_events.0040.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = craven }
			animation = fear
		}
		animation = anger
	}
	right_portrait = {
		character = scope:guest
		animation = schadenfreude
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		this != involved_activity.activity_host
		involved_activity = {
			any_attending_character = { 
				prelude_events_0040_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			involved_activity = {
				any_attending_character = {
					has_relation_nemesis = root
				}
			}
			add = 1
		}
	}	

	immediate = {
		involved_activity = {
			activity_host ?= { save_scope_as = host }
			random_attending_character = { 
				limit = { prelude_events_0040_appropriate_guest = yes }
				weight = {
					base = 1
					modifier = {
						has_relation_nemesis = root
						add = 5
					}
				}
				save_scope_as = guest
			}
		}
	}
	
	option = { # If you have a scheme against them, massive success chance
		name = prelude_events.0040.a
		trigger = {
			any_scheme = {
				is_hostile = yes
				scheme_target_character = scope:guest
			}
		}
		reason = hostile_scheme
		random_scheme = {
			limit = {
				is_hostile = yes
				scheme_target_character = scope:guest
			}
			add_scheme_modifier = {
				type = massive_extra_success_chance_modifier
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			lazy = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = lazy
					has_trait = compassionate
					has_trait = forgiving
				}
				factor = 0
			}
		}
	}
	
	option = { # Insult them lol
		name = prelude_events.0040.b
		if = {
			limit = {
				involved_activity = {
					any_attending_character = {
						this != scope:guest
						NOR = {
							has_relation_friend = scope:guest
							is_close_family_or_spouse_trigger = {
								CHARACTER = scope:guest
							}
						}
						OR = {
							has_trait = callous
							has_trait = vengeful
							has_trait = wrathful
						}
					}
				}
			}
			involved_activity = {
				every_attending_character = {
					limit = {
						this != scope:guest
						this != root
						NOR = {
							has_relation_friend = scope:guest
							is_close_family_or_spouse_trigger = {
								CHARACTER = scope:guest
							}
						}
						OR = {
							has_trait = callous
							has_trait = vengeful
							has_trait = wrathful
						}
					}
					custom = every_callous_vengeful_wrathful_guest
					add_opinion = {
						target = root
						modifier = amused_opinion
						opinion = 20
					}
				}
			}
		}
		scope:guest = {
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -25
			}
		}
		stress_impact = {
			vengeful = medium_stress_impact_loss
			wrathful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			calm = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			forgiving = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = vengeful 
					has_trait = wrathful 
					has_trait = callous 
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = calm
					has_trait = compassionate
					has_trait = forgiving
				}
				factor = 0
			}
		}
	}
	
	option = { # Eavesdrop
		name = prelude_events.0040.c
		trigger = {
			NOT = {
				any_scheme = {
					is_hostile = yes
					scheme_target_character = scope:guest
				}
			}
		}
		if = {
			limit = {
				can_start_scheme = {
					type = murder
					target_character = scope:guest
				}
			}
			start_scheme = {
				type = murder
				target_character = scope:guest
			}
			custom_tooltip = prelude_events.0040.c.tt
			hidden_effect = {
				random_scheme = {
					limit = {
						scheme_type = murder
						scheme_target_character = scope:guest
					}
					add_scheme_modifier = {
						type = extra_success_chance_modifier
					}
				}
			}
		}
		else = {
			add_intrigue_lifestyle_xp = medium_lifestyle_xp
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
				}
				factor = 0
			}
		}
	}
	
	option = { # Let's not argue tonight
		name = prelude_events.0040.d
		if = {
			limit = {
				government_allows = administrative
				top_liege = scope:activity.activity_host
			}
			change_influence = minor_influence_gain
		}
		else = {
			add_prestige = minor_prestige_gain
		}
		every_vassal = {
			limit = { has_vassal_stance = courtly }
			custom = every_courtly_vassal
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 5
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
				}
				factor = 0
			}
		}
	}
}

# Guest: Your family member is here!
scripted_trigger prelude_events_0050_family_member = {
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	this != root
	is_close_or_extended_family_of = root
	NOT = { is_courtier_of = root }
	opinion = {
		target = root
		value >= 25
	}
}
	
prelude_events.0050 = {
	type = activity_event
	title = prelude_events.0050.t
	desc = {
		desc = prelude_events.0050.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_trait = callous }
				desc = prelude_events.0050.desc.callous
			}
			desc = prelude_events.0050.desc.normal
		}
		desc = prelude_events.0050.desc.outro
	}
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = dismissal
		}
		animation = happiness
	}
	right_portrait = {
		character = scope:guest
		animation = admiration
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		this != involved_activity.activity_host
		involved_activity = {
			any_attending_character = { 
				prelude_events_0050_family_member = yes
			}
		}
	}

	immediate = {
		save_scope_as = root_scope
		involved_activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					prelude_events_0050_family_member = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 5
						highest_held_title_tier >= tier_kingdom
					}
				}
				save_scope_as = guest
			}
		}
	}
	
	option = { # Go away
		name = prelude_events.0050.a
		trigger = {
			has_trait = callous
		}
		add_dread = medium_dread_gain
		scope:guest = {
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -15
			}
		}
		stress_impact = {
			base = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				factor = 2
			}
		}
	}
	
	option = { # Let's talk about family
		name = prelude_events.0050.b
		add_diplomacy_lifestyle_xp = major_lifestyle_experience
		stress_impact = {
			gregarious = medium_stress_impact_loss
			arrogant = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = arrogant
				}
				factor = 2
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	option = { # Discuss the new ruler
		name = prelude_events.0050.c
		trigger = {
			scope:host = {
				NOR = {
					is_close_family_of = root
					has_relation_rival = root
					has_relation_rival = scope:guest
				}
			}
		}
		scope:host = {
			add_opinion = {
				target = root
				modifier = flattered_opinion
				opinion = 20
			}
		}
		involved_activity = {
			every_attending_character = {
				limit = {
					NOR = {
						this = root
						this = scope:guest
						this = scope:host
					}
				}
				custom = custom.every_attending_character
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 10
				}
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
				}
				factor = 0
			}
		}
	}
	
	option = { # Discuss the new ruler - it's your family's spouse!
		name = prelude_events.0050.d
		trigger = {
			scope:guest = {
				is_spouse_of = scope:host
			}
		}
		dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		if = {
			limit = { has_activity_intent = coronation_offer_support }
			scope:guest = { add_random_skill_point_effect = yes }
			scope:host = { add_random_skill_point_effect = yes }
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			ambitious = major_stress_impact_loss
			arrogant = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = ambitious
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = humble
					has_trait = shy
				}
				factor = 0
			}
		}
	}
}

# Guest: The Beautiful Capital
prelude_events.0060 = {
	type = activity_event
	title = prelude_events.0060.t
	desc = prelude_events.0060.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = ambitious }
			animation = scheme
		}
		animation = personality_compassionate
	}
	right_portrait = {
		character = scope:host
		animation = thinking
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		has_activity_intent = coronation_advocate_domain
		capital_county = {
			OR = {
				NOT = { has_county_modifier = bp4_advocate_domain_construction_county_modifier }
				development_level < 99
			}
		}
		scope:host = { is_ai = yes }
	}

	immediate = {
		involved_activity = {
			activity_host = {
				save_scope_as = host
				assign_quirk_effect = yes
			}
		}
		capital_province = { save_scope_as = province }
	}
	
	option = { # This is the time to lick some boots
		name = prelude_events.0060.a
		trigger = {
			has_trait = ambitious
		}
		if = {
			limit = {
				can_set_relation_friend_trigger = { CHARACTER = scope:host }
				OR = {
					scope:host = { is_ai = yes }
					AND = {
						is_ai = no
						scope:host = { is_ai = no }
					}
				}
				reverse_opinion = {
					target =  scope:host
					value > 40
				}
			}
			set_relation_friend = {
				target = scope:host
				reason = friend_coronation_ambitious
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:host
				modifier = flattered_opinion
				opinion = 20
			}
		}
		if = {
			limit = {
				government_allows = administrative
				top_liege = scope:activity.activity_host
			}
			change_influence = medium_influence_gain
		}
		else = {
			add_prestige = medium_prestige_gain
		}
		stress_impact = {
			ambitious = major_stress_impact_loss
			content = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = ambitious
				factor = 2
			}
			modifier = {
				has_trait = content
				factor = 0
			}
		}
	}
	
	option = { # Ask for help
		name = prelude_events.0060.b
		if = { # You get a cool thing
			limit = {
				capital_county = {
					NOT = { has_county_modifier = bp4_advocate_domain_construction_county_modifier }
				}
			}
			capital_county = {
				add_county_modifier = {
					modifier = bp4_advocate_domain_construction_county_modifier
					years = 25
				}
			}
		}
		else = {
			capital_county = {
				change_development_level = 1
			}
		}
		# But you have to pay something
		if = {
			limit = {
				scope:host = {
					can_add_hook = {
						target = root
						type = strong_favor_hook
					}
				}
			}
			scope:host = {
				add_hook = {
					target = root
					type = strong_favor_hook
				}
			}
		}
		else = {
			if = {
				limit = {
					government_allows = administrative
					top_liege = scope:activity.activity_host
				}
				change_influence = major_influence_loss
			}
			else = {
				add_prestige = major_prestige_loss
			}
		}
		stress_impact = {
			diligent = medium_stress_impact_loss
			greedy = major_stress_impact_gain
			paranoid = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = diligent
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = paranoid
				}
				factor = 0
			}
		}
	}
	
	option = { # Ask for funding
		name = prelude_events.0060.c
		duel = {
			skill = stewardship
			target = scope:host
			50 = { # They are convinced
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					scope:host = { has_trait = generous }
					add = 10
				}
				modifier = {
					scope:host.gold >= monumental_gold_value
					add = 5
				}
				min = 5
				desc = prelude_events.0060.c.tt.success
				send_interface_toast = {
					title = prelude_events.0060.c.tt.success
					left_icon = root
					right_icon = scope:host
					scope:host = {
						pay_short_term_gold = {
							target = root
							gold = medium_gold_value
						}
					}
				}
			}
			50 = { # They are indifferent
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = prelude_events.0060.c.tt.failure
				send_interface_toast = {
					title = prelude_events.0060.c.tt.failure
					left_icon = root
					right_icon = scope:host
					if = {
						limit = {
							government_allows = administrative
							top_liege = scope:activity.activity_host
						}
						change_influence = medium_influence_loss
					}
					else = {
						add_prestige = medium_prestige_loss
					}
				}
			}
		}
		if = {
			limit = {
				scope:host = {
					can_add_hook = {
						target = root
						type = favor_hook
					}
				}
			}
			scope:host = {
				add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = shy
					scope:host.gold <= major_gold_value
					scope:host = { has_trait = greedy }
				}
				factor = 0
			}
		}
	}
	
	option = { # Let's just focus on you
		name = prelude_events.0060.d
		trigger = {
			NOT = { has_trait = ambitious }
		}
		if = {
			limit = {
				OR = {
					scope:host = { is_ai = yes }
					AND = {
						is_ai = no
						scope:host = { is_ai = no }
					}
				}
				reverse_opinion = {
					target =  scope:host
					value > 30
				}
			}
			progress_towards_friend_effect = {
				REASON = friend_coronation_support
				CHARACTER = scope:host
				OPINION = default_friend_opinion
			}
		}
		else = {
			reverse_add_opinion = {
				modifier = honesty_opinion
				target = scope:host
				opinion = 20
			}
		}
		
		add_prestige = minor_prestige_gain
		stress_impact = {
			loyal = major_stress_impact_loss
			content = medium_stress_impact_loss
			deceitful = major_stress_impact_gain
			ambitious = major_stress_impact_gain
			arrogant = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = loyal
					has_trait = content
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = deceitful
					has_trait = ambitious
					has_trait = arrogant
				}
				factor = 0
			}
		}
	}
}

# Guest: Host offers you a seat on the council
prelude_events.0070 = {
	type = activity_event
	title = prelude_events.0070.t
	desc = {	
		desc = prelude_events.0070.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:host = {
							opinion = {
								target = root
								value >= 75
							}
							has_relation_friend = root
						}
					}
				}
				desc = prelude_events.0070.desc.friend
			}
			triggered_desc = {
				trigger = {
					highest_skill = diplomacy
				}
				desc = prelude_events.0070.desc.diplomacy
			}
			triggered_desc = {
				trigger = {
					highest_skill = stewardship
				}
				desc = prelude_events.0070.desc.stewardship
			}
			triggered_desc = {
				trigger = {
					highest_skill = intrigue
				}
				desc = prelude_events.0070.desc.intrigue
			}
			triggered_desc = {
				trigger = {
					highest_skill = learning
				}
				desc = prelude_events.0070.desc.learning
			}
			triggered_desc = {
				trigger = {
					highest_skill = martial
				}
				desc = prelude_events.0070.desc.martial
			}
		}
		desc = prelude_events.0070.desc.outro
	}
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = lazy }
			animation = shock # no bueno
		}
		animation = ecstasy
	}
	right_portrait = {
		character = scope:host
		animation = personality_bold
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		involved_activity.activity_host = {
			this != root
			this = root.liege
			NOT = { government_has_flag = government_is_nomadic } # Do not mess with the Kurultai
			OR = { # They like you a lot or you're pretty good at something
				opinion = {
					target = root
					value >= 75
				}
				AND = {
					opinion = {
						target = root
						value >= 25
					}
					root = { has_any_high_skill_rating = yes }
				}
			}
			NOT = { has_relation_rival = root }
		}
		is_councillor = no
		is_ai = no # To avoid AI changing councillors too often/weirdly
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			involved_activity.activity_host = { has_relation_friend = root }
			add = 1
		}
	}

	immediate = {
		involved_activity.activity_host = { save_scope_as = host }
	}
	
	option = { # Try to avoid this
		name = prelude_events.0070.a
		flavor = prelude_events.0070.a.flavor
		trigger = {
			has_trait = lazy
			NOT = { has_character_modifier = bp4_lazy_realm_focus_modifier }
		}
		add_character_modifier = {
			modifier = bp4_lazy_realm_focus_modifier
			years = 10
		}
		stress_impact = {
			lazy = medium_stress_impact_loss
			ambitious = major_stress_impact_gain
		}
		ai_chance = { # This event can only happen to players
			base = 100
		}
	}
	
	option = { # Sure thing
		name = prelude_events.0070.b
		scope:host = {
			assign_appropriate_councillor_position_effect = { CHARACTER = root }
			set_variable = {
				name = block_fire_councillor
				value = root
				years = council_position_locked_value
			}
		}
		stress_impact = {
			ambitious = medium_stress_impact_loss
			diligent = major_stress_impact_loss
			lazy = major_stress_impact_gain
		}
		ai_chance = { # This event can only happen to players
			base = 100
		}
	}
	
	option = { # No thank you
		name = prelude_events.0070.c
		trigger = {
			NOT = { has_trait = lazy }
		}
		scope:host = {
			add_opinion = {
				target = root
				modifier = rejected_opinion
				opinion = -15
			}
		}
		stress_impact = {
			diligent = major_stress_impact_gain
			ambitious = major_stress_impact_gain
		}
		ai_chance = { # This event can only happen to players
			base = 100
		}
	}
}

# Nice guest offers you a skillful courtier
scripted_trigger prelude_events_0080_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_landed = yes
	is_healthy = yes
	this != root
	OR = {
		is_vassal_of = root
		opinion = {
			target = root
			value >= 25
		}
	}
	any_courtier = {
		prelude_events_0080_appropriate_courtier = yes
	}
}

scripted_trigger prelude_events_0080_appropriate_courtier = {
	is_ai = yes
	is_adult = yes
	is_healthy = yes
	this != root
	NOR = { # Just to be sure
		is_spouse_of = prev
		is_close_family_of = prev
		is_close_or_extended_family_of = root
	}
	has_any_high_skill_rating = yes
	NOT = { has_court_position = court_physician_court_position }
}
	
prelude_events.0080 = {
	type = activity_event
	title = prelude_events.0080.t
	desc = {	
		desc = prelude_events.0080.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_friend = scope:guest }
				desc = prelude_events.0080.desc.friend
			}
			triggered_desc = {
				trigger = { scope:guest.house = root.house }
				desc = prelude_events.0080.desc.same_house
			}
			desc = prelude_events.0080.desc.fallback
		}
	}
	theme = coronation_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = paranoid }
			animation = fear
		}
		animation = interested
	}
	center_portrait = {
		character = scope:courtier
		animation = obsequious_bow
		camera = camera_event_right_pointing_right
	}
	right_portrait = {
		character = scope:guest
		animation = personality_honorable
	}
	
	cooldown = { years = 5 }
	
	trigger = {
		is_ruler = yes
		involved_activity = {
			any_attending_character = { 
				prelude_events_0080_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			has_activity_intent = coronation_embrace_supporters
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			random_attending_character = {
				limit = {
					prelude_events_0080_appropriate_guest = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 5
						has_relation_friend = root
					}
					modifier = {
						add = 1
						opinion = {
							target = root
							value >= 50
						}
					}
					modifier = {
						add = 1
						is_vassal_of = root
					}
					modifier = {
						add = 1
						has_trait = generous
					}
				}
				save_scope_as = guest
				random_courtier = {
					limit = { prelude_events_0080_appropriate_courtier = yes }
					weight = {
						base = 1
						modifier = {
							add = 5
							has_any_court_position = yes
						}
						modifier = {
							add = -5
							is_councillor = yes
						}
					}
					save_scope_as = courtier
				}
			}
		}
		assign_appropriate_court_position_effect = { CANDIDATE = scope:courtier }
	}
	
	option = { # A spy!!!!
		name = prelude_events.0080.aa
		trigger = { has_trait = paranoid }
		add_character_modifier = {
			modifier = bp4_paranoid_measures_modifier
			years = 10
		}
		if = {
			limit = {
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
				}
			}
			progress_towards_rival_effect = {
				CHARACTER = scope:guest
				OPINION = -40
				REASON = rival_rejected_courtier_paranoid
			}
		}
		stress_impact = {
			paranoid = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100 # Paranoid AI can only choose this
		}
	}
	
	option = { # Appoint them
		name = prelude_events.0080.a
		trigger = {
			scope:courtier = { has_any_court_position_flag_trigger = yes }
		}
		add_courtier = scope:courtier
		distribute_determined_court_position_effect = {
			CANDIDATE = scope:courtier
			EMPLOYER = root
		}
		stress_impact = {
			paranoid = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = paranoid
				factor = 0
			}
		}
	}
	
	option = { # Sure, they can stay
		name = prelude_events.0080.b
		add_courtier = scope:courtier
		stress_impact = {
			paranoid = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = paranoid
				factor = 0
			}
		}
	}
	
	option = { # You're such a good guy
		name = prelude_events.0080.c
		if = {
			limit = {
				NOT = { has_relation_friend = scope:guest }
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
				}
				reverse_opinion = {
					target = scope:guest
					value > 30
				}
			}
			progress_towards_friend_effect = {
				REASON = friend_coronation_offered_courtier
				CHARACTER = scope:guest
				OPINION = default_friend_opinion
			}
		}
		else = { add_prestige = minor_prestige_gain }
		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
		stress_impact = {
			gregarious = medium_stress_impact_loss
			paranoid = major_stress_impact_gain
		}
		ai_chance = {
			base = 250
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = paranoid
				factor = 0
			}
		}
	}
}

# Nomadic Host: Your nomadic guest arrives with some herd
scripted_trigger prelude_events_0090_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_landed = yes
	is_healthy = yes
	government_has_flag = government_is_nomadic
	domicile.herd >= domicile.major_herd_value # They have something to give
	this != root
	OR = {
		is_vassal_of = root
		opinion = {
			target = root
			value >= 25
		}
	}
}
	
prelude_events.0090 = {
	type = activity_event
	title = prelude_events.0090.t
	desc = {	
		desc = prelude_events.0090.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_blood_brother = scope:guest }
				desc = prelude_events.0090.desc.blood_brother
			}
			triggered_desc = {
				trigger = {	
					opinion = {
						target = scope:guest
						value < 0
					}
				}
				desc = prelude_events.0090.desc.bad_opinion
			}
			desc = prelude_events.0090.desc.fallback
		}
		desc = prelude_events.0090.desc.outro
	}
	theme = coronation_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					opinion = {
						target = scope:guest
						value < 0
					}
				}
			}
			animation = dismissal
		}
		animation = admiration
	}
	right_portrait = {
		character = scope:guest
		animation = standing_horse
		camera = camera_event_standing_with_horse_right
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		government_has_flag = government_is_nomadic
		involved_activity = {
			any_attending_character = { 
				prelude_events_0090_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			involved_activity = {
				any_attending_character = {
					has_relation_blood_brother = root
				}
			}
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			random_attending_character = {
				limit = {
					prelude_events_0090_appropriate_guest = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						has_relation_blood_brother = root
					}
					modifier = {
						add = 2
						has_relation_friend = root
					}
					modifier = {
						add = 1
						opinion = {
							target = root
							value >= 50
						}
					}
					modifier = {
						add = 1
						is_vassal_of = root
					}
					modifier = {
						add = 1
						has_trait = generous
					}
				}
				save_scope_as = guest
				assign_quirk_effect = yes
			}
		}
	}
	
	option = { # BESTIEEEEEEEEE
		name = prelude_events.0090.aa
		reason = blood_brother
		trigger = { has_relation_blood_brother = scope:guest }
		custom_tooltip = {
			text = coronation_tt_positive_major
			scope:activity = { activity_special_type_progression_major = yes }
		}
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_major
            CHAR = root
        }
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 250
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	option = { # Tell them to f off
		name = prelude_events.0090.a
		reason = opinion_negative
		trigger = {
			NOT = { has_relation_blood_brother = scope:guest }
			OR = {
				has_trait = callous
				opinion = {
					target = scope:guest
					value < 0
				}
			}
		}
		add_dread = medium_dread_gain
		scope:guest = {
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -25
			}
		}
		if = {
			limit = { has_relation_rival = scope:guest }
			add_stress = major_stress_impact_loss
		}
		stress_impact = {
			callous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_relation_rival = scope:guest
				}
				factor = 2
			}
		}
	}
	
	option = { # Accept their Herd
		name = prelude_events.0090.b
		scope:guest = {
			pay_herd = {
				target = root
				value = domicile.medium_herd_value
			}
			add_prestige = medium_prestige_gain
		}
		stress_impact = {
			greedy = major_stress_impact_loss
			generous = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # I'm just happy to have you here
		name = prelude_events.0090.c
		if = {
			limit = { has_relation_rival = scope:guest }
			remove_relation_rival = scope:guest
		}
		else_if = {
			limit = {
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
					reverse_opinion = {
						target = scope:guest
						value > 20
					}
				}
			}
			progress_towards_friend_effect = {
				CHARACTER = scope:guest
				REASON = friend_nomadic_guest_coronation_herd
				OPINION = default_friend_opinion
			}
		}
		else = {
			reverse_add_opinion = {
				modifier = respect_opinion
				target = scope:guest
				opinion = 20
			}
		}
		coronation_move_towards_supporter_effect = { CHARACTER = scope:guest }
		stress_impact = {
			gregarious = medium_stress_impact_loss
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 250
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
}

# Host: Vassal asks you to build more in their realms
scripted_trigger prelude_events_0100_appropriate_vassal = {
	is_ai = yes
	is_adult = yes
	is_landed = yes
	is_healthy = yes
	is_vassal_of = root
	any_directly_owned_province = {
		free_building_slots >= 1
	}
	NOR = {
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
		is_in_guest_subset = { name = detractor }
		has_activity_intent = coronation_disrupt_loyalists
		government_has_flag = government_is_nomadic
		government_has_flag = government_is_herder
	}
}
	
prelude_events.0100 = {
	type = activity_event
	title = prelude_events.0100.t
	desc = prelude_events.0100.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = callous
			}
			animation = dismissal
		}
		animation = interested
	}
	right_portrait = {
		character = scope:vassal
		animation = beg
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		has_activity_intent = coronation_embrace_supporters
		NOT = { has_character_modifier = coronation_vassal_building_modifier }
		involved_activity = {
			any_attending_character = { 
				prelude_events_0100_appropriate_vassal = yes
			}
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			random_attending_character = {
				limit = {
					prelude_events_0100_appropriate_vassal = yes
					has_activity_intent = coronation_advocate_domain
					scope:activity = {
						is_target_in_variable_list = {
							name = major_supporter
							target = prev
						}	
					}
				}
				alternative_limit = {
					prelude_events_0100_appropriate_vassal = yes
					OR = {
						has_any_good_relationship_with_character_trigger = { CHARACTER = root }
						has_trait = loyal
						is_in_guest_subset = { name = supporter }
						has_activity_intent = coronation_advocate_domain
					}
				}
				alternative_limit = {
					prelude_events_0100_appropriate_vassal = yes
				}
				weight = {
					base = 1
					modifier = {
						has_trait = diligent
						add = 1
					}
					modifier = {
						has_activity_intent = coronation_advocate_domain
						add = 1
					}
					modifier = {
						is_powerful_vassal_of = root
						add = 2
					}
					modifier = {
						has_vassal_stance = parochial
						add = 2
					}
				}
				save_scope_as = vassal
				assign_quirk_effect = yes
				random_directly_owned_province = {
					limit = { free_building_slots >= 1 }
					save_scope_as = province
				}
			}
		}
		custom_tooltip = happened_because_intent_tt
	}
	
	option = { # Sure buddy
		name = prelude_events.0100.a
		add_character_modifier = coronation_vassal_building_modifier # Forever
		if = {
			limit = {
				any_vassal = {
					has_vassal_stance = parochial
				}
			}
			every_vassal = {
				custom = every_parochial_vassal
				add_opinion = {
					modifier = pleased_opinion
					opinion = 10
					target = root
				}
			}
		}
		
		custom_tooltip = {
			text = coronation_tt_positive_medium
			scope:activity = { activity_special_type_progression_medium = yes }
		}
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_medium
            CHAR = root
        }
		stress_impact = {
			callous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
				}
				factor = 2
			}
		}
	}
	
	option = { # You can build it yourself
		name = prelude_events.0100.b
		pay_short_term_gold = {
			target = scope:vassal
			gold = medium_gold_value
		}
		custom_tooltip = {
			text = coronation_tt_positive_major
			scope:activity = { activity_special_type_progression_major = yes }
		}
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_major
            CHAR = root
        }
        if = {
        	limit = {
        		OR = {
        			scope:vassal = { is_ai = yes }
        			AND = {
        				is_ai = no
        				scope:vassal = { is_ai = no }
        			}
        		}
        		reverse_opinion = {
        			target = scope:vassal
        			value > 20
        		}
        	}
        	progress_towards_friend_effect = {
				REASON = friend_coronation_paid_for_building
				CHARACTER = scope:vassal
				OPINION = default_friend_opinion
			}
        }
        else = {
        	reverse_add_opinion = {
        		target = scope:vassal
        		modifier = grateful_opinion
        		opinion = 20
        	}
        }
		coronation_move_towards_supporter_effect = { CHARACTER = scope:vassal }

		stress_impact = {
			greedy = major_stress_impact_loss
			generous = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # I'd rather focus on _me_
		name = prelude_events.0100.c
		add_stewardship_lifestyle_xp = major_lifestyle_xp
		if = {
			limit = {
				is_ai = no
				NOT = { has_trait = architect }
			}
			random = {
				chance = 25
				add_trait = architect
			}
		}
		stress_impact = {
			gregarious = medium_stress_impact_loss
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 250
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
}

# Host: Different culture vassal asks you to say some words to them specifically
scripted_trigger prelude_events_0110_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_landed = yes
	is_healthy = yes
	this != root
	culture != root.culture
}
	
prelude_events.0110 = {
	type = activity_event
	title = prelude_events.0110.t
	desc = prelude_events.0110.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = callous
			}
			animation = dismissal
		}
		triggered_animation = {
			trigger = {
				has_trait = lazy
			}
			animation = boredom
		}
		animation = interested
	}
	right_portrait = {
		character = scope:guest
		animation = debating
		camera = camera_event_right_pointing_right
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		has_activity_intent = coronation_impress_attendees
		involved_activity = {
			any_attending_character = { 
				prelude_events_0110_appropriate_guest = yes
			}
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			random_attending_character = {
				limit = {
					prelude_events_0110_appropriate_guest = yes
				}
				weight = {
					base = 1
					modifier = {
						is_powerful_vassal_of = root
						add = 2
					}
					modifier = {
						is_vassal_of = root
						has_vassal_stance = minority
						add = 2
					}
					modifier = {
						has_activity_intent = coronation_bear_witness
						add = 2
					}
					modifier = {
						root = {
							NOT = { knows_language_of_culture = prev.culture }
						}
						add = 10
					}
				}
				save_scope_as = guest
				assign_quirk_effect = yes
				culture = { save_scope_as = guest_culture }
			}
		}
	}
	
	option = { # If they have a different language, learn it
		name = prelude_events.0110.a
		add_internal_flag = special
		trigger = {
			NOT = { knows_language_of_culture = scope:guest_culture }
		}
		start_scheme = {
			type = learn_language
			target_character = scope:guest
		}
		custom_tooltip = diplomacy_family.2250.b.tt
		hidden_effect = {
			random_scheme = {
				limit = {
					scheme_type = learn_language
					scheme_target_character = scope:guest
				}
				add_scheme_modifier = {
					type = extra_success_chance_modifier
				}
			}
		}
		culture = {
			change_cultural_acceptance = {
				target = scope:guest_culture
				value = medium_cultural_acceptance_gain
				desc = cultural_acceptance_gain_coronation_impress_attendees
			}
		}
		if = {
			limit = {
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
				}
				reverse_opinion = {
					target = scope:guest
					value > 10
				}
			}
			progress_towards_friend_effect = {
				REASON = friend_coronation_learn_language
				CHARACTER = scope:guest
				OPINION = default_friend_opinion
			}
		}
		else = {
			reverse_add_opinion = {
				modifier = kindness_opinion
				target = scope:guest
				opinion = 20
			}
			
		}
		stress_impact = {
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	option = { # Sure, man
		name = prelude_events.0110.b
		culture = {
			change_cultural_acceptance = {
				target = scope:guest_culture
				value = major_cultural_acceptance_gain
				desc = cultural_acceptance_gain_coronation_impress_attendees
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_loss
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = compassionate
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = callous
					has_trait = arrogant 
				}
				factor = 0
			}
		}
	}
	
	option = { # I care more about myself
		name = prelude_events.0110.c
		custom_tooltip = {
			text = coronation_tt_positive_medium
			scope:activity = { activity_special_type_progression_medium = yes }
		}
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_medium
            CHAR = root
        }
		stress_impact = {
			callous = medium_stress_impact_loss
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 150
			modifier = {
				has_trait = callous
				factor = 2
			}
			modifier = {
				has_trait = compassionate
				factor = 0
			}
		}
	}
}

# Host: Cool guest gives you an artifact
scripted_trigger prelude_events_0120_appropriate_guest = {
	is_ai = yes
	is_adult = yes
	is_landed = yes
	is_healthy = yes
	this != root
	is_in_guest_subset = { name = supporter }
	any_character_artifact = {
		prelude_events_0120_appropriate_artifact = yes
	}
}

scripted_trigger prelude_events_0120_appropriate_artifact = {
	is_equipped = no
	NOR = {
		artifact_slot_type = helmet
		artifact_slot_type = regalia
		artifact_type = throne
		artifact_type = regalia
		has_variable = banner_house
        has_variable = banner_dynasty
		rarity = common
	}
}
	
prelude_events.0120 = {
	type = activity_event
	title = prelude_events.0120.t
	desc = prelude_events.0120.desc
	theme = coronation_activity
	left_portrait = {
		character = root
		animation = happiness
	}
	center_portrait = {
		character = scope:servant 
		animation = obsequious_bow
		camera = camera_event_right_pointing_right
	}
	right_portrait = {
		character = scope:guest
		animation = personality_honorable
		camera = camera_event_right_pointing_right
	}
	artifact = {
		position = lower_left_portrait
		target = scope:guest_artifact
	}
	artifact = {
		position = lower_center_portrait
		target = scope:my_artifact
		trigger = { exists = scope:my_artifact }
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		has_activity_intent = coronation_exalt_crown
		involved_activity = {
			any_attending_character = { 
				prelude_events_0120_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {	
		base = 1
		modifier = {
			NOT = {
				any_character_artifact = {
					count >= 1
				}
			}
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			random_attending_character = {
				limit = {
					prelude_events_0120_appropriate_guest = yes
				}
				weight = {
					base = 1
					modifier = {
						is_powerful_vassal_of = root
						add = 2
					}
					modifier = {
						has_activity_intent = coronation_offer_support
						add = 2
					}
				}
				save_scope_as = guest
				assign_quirk_effect = yes
				random_character_artifact = {
					limit = {
						prelude_events_0120_appropriate_artifact = yes
					}
					weight = {
						base = 1
						modifier = {
							ep1_artifact_is_court_artifact_trigger = no
							add = 2
						}
					}
					save_scope_as = guest_artifact
				}
			}
		}
		create_character = {
			location = root.location
			template = antiquarian_court_position_template
			gender_female_chance = 50
			faith = scope:guest.faith
			culture = scope:guest.culture
			save_scope_as = servant
		}
		hidden_effect = {
			scope:guest = { add_courtier = scope:servant }
		}
		if = {
			limit = {
				any_character_artifact = {
					prelude_events_0120_appropriate_artifact = yes
				}
			}
			random_character_artifact = {
				limit = { prelude_events_0120_appropriate_artifact = yes }
				save_scope_as = my_artifact
			}
		}
	}
	
	option = { # Let's exchange gifts
		name = prelude_events.0120.aa
		trigger = {
			exists = scope:my_artifact
		}
		add_internal_flag = special
		reason = artifact
		scope:guest_artifact = {
			set_owner = root
			set_artifact_description = coronation_gift_artifact_desc
		}
		scope:my_artifact = {
			set_owner = scope:guest
			set_artifact_description = coronation_gift_artifact_host_desc
		}
		if = {
			limit = {
				can_set_relation_friend_trigger = { CHARACTER = scope:guest }
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
				}
			}
			set_relation_friend = {
				target = scope:guest
				reason = friend_coronation_gift_exchange
			}
		}
		every_vassal = {
			limit = { has_vassal_stance = courtly }
			custom = every_courtly_vassal
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 15
			}
		}
		stress_impact = {
			generous = medium_stress_impact_loss
			gregarious = medium_stress_impact_loss
			callous = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = generous
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = callous
					has_trait = greedy
				}
				factor = 0
			}
		}
	}
	
	option = { # Is this how much you value my love?
		name = prelude_events.0120.a
		trigger = {
			OR = {
				has_trait = greedy
				has_trait = avaricious
			}
		}
		scope:guest = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
			add_opinion = {
				target = root
				opinion = -20
				modifier = annoyed_opinion
			}
		}
		scope:guest_artifact = {
			set_owner = root
			set_artifact_description = coronation_gift_artifact_desc
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			content = medium_stress_impact_gain
			generous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = callous
					has_trait = greedy
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = content
				}
				factor = 0
			}
		}
	}
	
	option = { # Thank you bestie
		name = prelude_events.0120.b
		scope:guest_artifact = {
			set_owner = root
			set_artifact_description = coronation_gift_artifact_desc
		}
		scope:guest = {
			if = {
				limit = {
					government_allows = administrative
					top_liege = scope:activity.activity_host
				}
				change_influence = medium_influence_gain
			}
			else = {
				add_prestige = medium_prestige_gain
			}
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 10
			}
		}
		stress_impact = {
			generous = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # Let's show it off to our guests!
		name = prelude_events.0120.c
		custom_tooltip = {
			text = coronation_tt_positive_tiny
			scope:activity = { activity_special_type_progression_tiny = yes }
		}
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_tiny
            CHAR = root
        }
		stress_impact = {
			gregarious = medium_stress_impact_loss
			callous = major_stress_impact_gain
		}
		ai_chance = {
			base = 250
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	after = {
		hidden_effect = {
			if = {
				limit = { is_ai = yes }
				scope:servant = { silent_disappearance_effect = yes }
			}
		}
	}
}

# Host: Get the officiator to bless an artifact
scripted_trigger prelude_events_0130_appropriate_artifact = {
	ep1_artifact_is_court_artifact_trigger = no
	NOR = {
		has_variable = ai_to_ai_destroy_in_sieges
		has_variable = unwanted_artifact
		has_variable = cursed_artifact
		rarity = common
	}
}
	
prelude_events.0130 = {
	type = activity_event
	title = prelude_events.0130.t
	desc = prelude_events.0130.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = zealous }
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = { has_trait = cynical }
			animation = dismissal
		}
		animation = interested
		camera = camera_event_left_pointing_right
	}
	right_portrait = {
		character = scope:coronator
		animation = wedding_priest
		camera = camera_event_right_pointing_right
	}
	artifact = {
		position = lower_left_portrait
		target = scope:my_artifact
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		has_activity_intent = coronation_exalt_crown
		coronation_living_officiator_trigger = yes
		involved_activity.var:officiator ?= { # And he likes you
			opinion = {
				target = root
				value >= 0
			}
		}
		involved_activity.var:officiator.location ?= root.location # The coronator is here
		any_character_artifact = {
			prelude_events_0130_appropriate_artifact = yes
		}
	}

	immediate = {
		save_scope_as = artifact_owner
		involved_activity = {
			save_scope_as = activity
			var:officiator = {
				save_scope_as = coronator
				assign_quirk_effect = yes
			}
		}
		ordered_character_artifact = {
			order_by = artifact_rarity
			limit = { prelude_events_0130_appropriate_artifact = yes }
			save_scope_as = my_artifact
		}
	}
	
	option = { # Please improve my artifact
		name = prelude_events.0130.a
		scope:my_artifact = {
			custom_tooltip = {
				text = prelude_events.0130.a.tt
				add_artifact_modifier = artifact_monthly_piety_gain_mult_5_modifier
				add_artifact_modifier = artifact_clergy_opinion_9_modifier
			}
			set_artifact_description = coronation_blessed_artifact_desc
		}
		stress_impact = {
			cynical = major_stress_impact_gain
			zealous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}
	
	option = { # Let me show it to the world
		name = prelude_events.0130.b
		scope:my_artifact = {
			custom_tooltip = {
				text = prelude_events.0130.b.tt
				add_artifact_modifier = artifact_monthly_prestige_2_modifier
			}
			set_artifact_description = coronation_blessed_artifact_desc
		}
		stress_impact = {
			cynical = medium_stress_impact_gain
			arrogant = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}
	
	option = { # Just bless this coronation
		name = prelude_events.0130.c
		every_vassal_or_below = {
			limit = { has_vassal_stance = courtly }
			custom = every_courtly_vassal
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
		if = {
			limit = { has_trait = cynical }
			custom_tooltip = {
				text = prelude_events_0130_cynical_tt
				scope:activity = { activity_special_type_progression_major = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_major
        	    CHAR = root
        	}
		}
		else = {
			custom_tooltip = {
				text = coronation_tt_positive_medium
				scope:activity = { activity_special_type_progression_medium = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_medium
        	    CHAR = root
        	}
		}
		stress_impact = {
			gregarious = medium_stress_impact_loss
			zealous = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = cynical
				}
				factor = 2
			}
			modifier = {
				has_trait = zealous
				factor = 0
			}
		}
	}
}

# Guest: Say some words to the host
scripted_trigger prelude_events_0140_appropriate_guest = {
	this != root
	this != involved_activity.activity_host
	is_physically_able_ai_adult = yes
	is_in_guest_subset = { name = supporter }
}

prelude_events.0140 = {
	type = activity_event
	title = prelude_events.0140.t
	desc = prelude_events.0140.desc
	theme = coronation_activity
	left_portrait = {
		character = scope:guest
		animation = admiration
		camera = camera_event_left_pointing_right
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_activity_intent = coronation_disrupt_loyalists
			}
			animation = scheme
		}
		animation = thinking
		camera = camera_event_left_pointing_right
	}
	right_portrait = {
		character = scope:host
		animation = survey
		camera = camera_event_right_pointing_left
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		involved_activity = {
			any_attending_character = {
				prelude_events_0140_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				has_activity_intent = coronation_offer_support
				has_activity_intent = coronation_disrupt_loyalists
			}
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			activity_host = {
				save_scope_as = host
				assign_quirk_effect = yes
			}
			random_attending_character = {
				limit = { prelude_events_0140_appropriate_guest = yes }
				weight = {
					base = 1
					modifier = {
						primary_title.tier >= tier_county
						add = 1
					}
					modifier = {
						is_powerful_vassal_of = scope:host
						add = 1
					}
				}
				save_scope_as = guest
			}
		}
	}
	
	option = { # That idiot
		name = prelude_events.0140.a
		trigger = { has_activity_intent = coronation_disrupt_loyalists }
		add_internal_flag = special
		custom_tooltip = available_because_intent_tt
		if = {
			limit = {
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_detractor
							target = root
						}
					}	
				}
			}
			custom_tooltip = {
				text = coronation_tt_negative
				scope:activity = { activity_special_type_progression_negative = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:negative
        	    CHAR = root
        	}
		}
		
		stress_impact = {
			base = medium_stress_impact_loss # You love this
			callous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				has_activity_intent = coronation_disrupt_loyalists
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = compassionate
					NOT = {
						is_in_guest_subset = { name = detractor }
					}
				}
				factor = 0
			}
		}
	}
	
	option = { # Shower them in compliments
		name = prelude_events.0140.b
		if = {
			limit = {
				has_activity_intent = coronation_offer_support
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_supporter
							target = root
						}
					}
				}
			}
			custom_tooltip = {
				text = prelude_events.0140.b.offer_support_tt
				scope:activity = { activity_special_type_progression_medium = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_medium
        	    CHAR = root
        	}
		}
		else_if = {
			limit = {
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_supporter
							target = root
						}
					}	
				}
			}
			custom_tooltip = {
				text = coronation_tt_positive_tiny
				scope:activity = { activity_special_type_progression_tiny = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_tiny
        	    CHAR = root
        	}
		}
		scope:host = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		involved_activity = {
			every_attending_character = {
				limit = {
					this != scope:host
					this != root
				}
				custom = custom.every_attending_character
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 5
				}
			}
		}
		stress_impact = {
			shy = medium_stress_impact_gain
			callous = major_stress_impact_gain
			deceitful = medium_stress_impact_loss
			gregarious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = deceitful
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = shy
					has_trait = callous
					NOT = {
						is_in_guest_subset = { name = supporter }
					}
				}
				factor = 0
			}
		}
	}
	
	option = { # I love diplomacy
		name = prelude_events.0140.c
		if = {
			limit = { has_lifestyle = diplomacy_lifestyle }
			add_diplomacy_lifestyle_xp = major_lifestyle_xp
		}
		else = {
			if = {
				limit = {
					government_allows = administrative
					top_liege = scope:activity.activity_host
				}
				change_influence = medium_influence_gain
			}
			else = {
				add_prestige = medium_prestige_gain
			}
		}
		stress_impact = {
			diplomat = major_stress_impact_loss
			arrogant = medium_stress_impact_loss
			callous = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = diplomacy_lifestyle
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = callous
				}
				factor = 0
			}
		}
	}
}

# Guest: Host introduces you to a cool guest
scripted_trigger prelude_events_0150_appropriate_guest = {
	is_physically_able_ai_adult = yes
	is_healthy = yes
	this != root
	this != involved_activity.activity_host
	NOT = { is_spouse_of = root }
	NOT = { is_close_or_extended_family_of = root }
	house ?= {
		NOT = { this = root.house }
	}
	NOR = {
		has_relation_friend = root
		has_relation_lover = root
		has_relation_rival = root
	}
	can_set_relation_friend_trigger = { CHARACTER = root }
	involved_activity.activity_host = { # Someone that the host actually likes
		opinion = {
			target = prev
			value >= 0
		}
	}
}

prelude_events.0150 = {
	type = activity_event
	title = prelude_events.0150.t
	desc = prelude_events.0150.desc
	theme = coronation_activity
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				scope:guest = {
					is_attracted_to_gender_of = root
					OR = {
						is_married = no
						might_cheat_on_every_partner_trigger = yes
					}
				}
				is_attracted_to_gender_of = scope:guest
			}
			animation = flirtation
		}
		animation = interested
	}
	center_portrait = {
		character = scope:guest
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = arrogant
					has_trait = deceitful
				}
			}
			animation = throne_room_conversation_3
		}
		animation = throne_room_conversation_4
		camera = camera_event_right_pointing_right
	}
	right_portrait = {
		character = scope:host
		animation = debating
		camera = camera_event_right_pointing_right
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		involved_activity.activity_host = { # Host likes you
			opinion = {
				target = root
				value >= 10
			}
		}
		involved_activity = {
			any_attending_character = {
				prelude_events_0150_appropriate_guest = yes
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			has_activity_intent = coronation_offer_support
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			activity_host = {
				save_scope_as = host
				assign_quirk_effect = yes
			}
			random_attending_character = {
				limit = { prelude_events_0150_appropriate_guest = yes }
				weight = {
					base = 1
					modifier = {
						primary_title.tier >= tier_county
						add = 1
					}
					modifier = {
						is_powerful_vassal_of = scope:host
						add = 1
					}
					modifier = {
						trait_compatibility = {
							target = root
							value >= medium_positive_trait_compatibility
						}
						add = 1
					}
				}
				assign_quirk_effect = yes
				save_scope_as = guest
			}
		}
	}
	
	option = { # I want to know them in the biblical sense
		name = prelude_events.0150.aa
		add_internal_flag = special
		trigger = {
			scope:guest = {
				is_attracted_to_gender_of = root
				OR = {
					is_married = no
					might_cheat_on_every_partner_trigger = yes
				}
			}
			is_attracted_to_gender_of = scope:guest
		}
		had_sex_with_effect = {
			CHARACTER = scope:guest
			PREGNANCY_CHANCE = seduce_pregnancy_chance
		}
		progress_towards_lover_effect = {
			REASON = lover_coronation_introduction
			CHARACTER = scope:guest
			OPINION = 30
		}
		if = {
			limit = {
				might_cheat_on_every_partner_trigger = no
			}
			add_stress = major_stress_gain
		}
		if = {
			limit = {
				has_focus_or_focus_trait_trigger = { FOCUS = intrigue_temptation_focus }
			}
			add_intrigue_lifestyle_xp = major_lifestyle_xp
			if = {
				limit = {
					is_ai = no
					NOT = { has_perk = unshackled_lust_perk }
				}
				random = {
					chance = 25
					add_perk = unshackled_lust_perk
				}
			}
		}
		stress_impact = {
			rakish = major_stress_impact_loss
			lustful = major_stress_impact_loss
			seducer = major_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = lustful
					has_trait = rakish
					has_trait = seducer
				}
				add = 100
			}
		}
	}
	
	option = { # They seem cool
		name = prelude_events.0150.a
		if = {
			limit = {
				reverse_opinion = {
					target = scope:guest
					value > 40
				}
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
				}
			}
			set_relation_friend = {
				target = scope:guest
				reason = friend_coronation_introduction
			}
		}
		else = {
			reverse_add_opinion = {
				modifier = friendliness_opinion
				target = scope:guest
				opinion = 20
			}
		}
		
		scope:host = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
		stress_impact = {
			gregarious = major_stress_impact_loss
			shy = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				has_trait = gregarious
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = shy
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # I want to talk with _you_
		name = prelude_events.0150.b
		if = {
			limit = {
				reverse_opinion = {
					target = scope:host
					value > 10
				}
				OR = {
					scope:host = { is_ai = yes }
					AND = {
						scope:host = { is_ai = no }
						is_ai = no
					}
				}
			}
			progress_towards_friend_effect = {
				REASON = friend_coronation_support
				CHARACTER = scope:host
				OPINION = default_friend_opinion
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:host
				modifier = friendliness_opinion
				opinion = 20
			}
		}
		
		stress_impact = {
			arrogant = medium_stress_impact_loss
			gregarious = medium_stress_impact_loss
			shy = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = shy
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # Whatever
		name = prelude_events.0150.c
		if = {
			limit = { has_lifestyle = diplomacy_lifestyle }
			add_diplomacy_lifestyle_xp = major_lifestyle_xp
		}
		else = {
			if = {
				limit = {
					government_allows = administrative
					top_liege = scope:activity.activity_host
				}
				change_influence = medium_influence_gain
			}
			else = {
				add_prestige = medium_prestige_gain
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				has_lifestyle = diplomacy_lifestyle
				factor = 2
			}
			modifier = {
				has_trait = gregarious
				factor = 0
			}
		}
	}
}

# Guest: Guest of your dynasty is here!
scripted_trigger prelude_events_0160_appropriate_guest = {
	is_physically_able_ai_adult = yes
	this != root
	dynasty ?= root.dynasty
	NOT = { is_close_family_or_spouse_trigger = { CHARACTER = root } }
}

prelude_events.0160 = {
	type = activity_event
	title = prelude_events.0160.t
	desc = prelude_events.0160.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = arrogant
					has_relation_rival = scope:guest
					scope:guest.prestige_level <= 1
				}
			}
			animation = dismissal
		}
		animation = happiness
	}
	right_portrait = {
		character = scope:guest
		triggered_animation = {
			trigger = {
				has_relation_rival = root
			}
			animation = eyeroll
		}
		animation = ecstasy
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		involved_activity = {
			any_attending_character = {
				prelude_events_0160_appropriate_guest = yes
			}
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			activity_host = {
				save_scope_as = host
				assign_quirk_effect = yes
			}
			random_attending_character = {
				limit = { prelude_events_0160_appropriate_guest = yes }
				assign_quirk_effect = yes
				weight = {
					base = 1
					modifier = {
						primary_title.tier >= tier_county
						add = 1
					}
					modifier = {
						primary_title.tier >= tier_duchy
						add = 1
					}
					modifier = {
						NOT = { house ?= root.house }
						add = 5
					}
				}
				save_scope_as = guest
				if = {
					limit = {
						any_held_title = {
							root = {
								NOT = { has_claim_on = prev }
							}
						}
					}
					ordered_held_title = {
						limit = {
							root = {
								NOT = { has_claim_on = prev }
							}
						}
						order_by = tier
						save_scope_as = my_claim
					}
				}
			}
		}
	}
	
	option = { # We are the BEST dynasty in the world
		name = prelude_events.0160.aa
		trigger = { prestige_level >= 4 }
		reason = prestige_level
		dynasty = {
			add_dynasty_prestige = minor_dynasty_prestige_gain
			if = {
				limit = {
					NOT = { has_dynasty_modifier = coronation_famed_dynasty_modifier }
				}
				add_dynasty_modifier = {
					modifier = coronation_famed_dynasty_modifier
					years = 80
				}
			}
		}
		stress_impact = {
			arrogant = major_stress_impact_loss
			gregarious = major_stress_impact_loss
			callous = major_stress_impact_gain
			humble = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = humble
					has_trait = callous
				}
				factor = 0
			}
		}
	}
	
	option = { # You are a disgrace to our dynasty
		name = prelude_events.0160.a
		trigger = {
			OR = {
				has_trait = callous
				has_trait = arrogant
				has_trait = ambitious
				has_relation_rival = scope:guest
				scope:guest.prestige_level <= 1
			}
			exists = scope:my_claim
		}
		add_internal_flag = special
		add_pressed_claim = scope:my_claim

		if = {
			limit = {
				OR = {
					scope:guest = { is_ai = yes }
					AND = {
						scope:guest = { is_ai = no }
						is_ai = no
					}
				}
			}
			set_relation_rival = {
				target = scope:guest
				reason = rival_coronation_dynasty_insult
			}
		}
		dynasty = {
			every_dynasty_member = {
				limit = {
					NOT = {
						this = root
					}
				}
				custom = custom.every_dynasty_member
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -5
				}
			}
		}
		stress_impact = {
			callous = major_stress_impact_loss
			arrogant = medium_stress_impact_loss
			ambitious = medium_stress_impact_loss
			gregarious = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = callous
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = compassionate
				}
				factor = 0
			}
		}
	}
	
	option = { # We are so cool cousin
		name = prelude_events.0160.b
		trigger = {
			has_legitimacy = yes 
		}
		if = {
			limit = {
				scope:guest = { has_legitimacy = yes }
			}
			scope:guest = { add_legitimacy = medium_legitimacy_gain }
		}
		add_legitimacy = medium_legitimacy_gain
		stress_impact = {
			gregarious = medium_stress_impact_loss
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	option = { # Let's focus on the coronation
		name = prelude_events.0160.c
		scope:host = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
		involved_activity = {
			every_attending_character = {
				limit = {
					this != scope:host
					this != root
				}
				custom = custom.every_attending_character
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 10
				}
			}
		}
		stress_impact = {
			shy = medium_stress_impact_loss
			humble = medium_stress_impact_loss
			arrogant = major_stress_impact_gain
			callous = major_stress_impact_gain
			ambitious = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = shy
					has_trait = humble
				}
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = callous
					has_trait = ambitious
				}
				factor = 0
			}
		}
	}
}

# Guest: You talk to a guest of different faith
scripted_trigger prelude_events_0170_appropriate_guest = {
	is_physically_able_ai_adult = yes
	this != root
	this != involved_activity.activity_host
	faith != root.faith
	NOT = { has_trait = cynical }
}
scripted_trigger prelude_events_0170_appropriate_supporter = {
	this != root
	this != involved_activity.activity_host
	learning < medium_skill_rating
	NOR = {
		has_trait = patient
		has_trait = zealous
	}
	is_ai = yes
	NOT = {
		has_character_flag = prelude_events_0170_supporter
	}
}

prelude_events.0170 = {
	type = activity_event
	title = prelude_events.0170.t
	desc = prelude_events.0170.desc
	theme = coronation_activity
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = zealous
			}
			animation = anger
		}
		animation = interested
	}
	right_portrait = {
		character = scope:guest
		animation = debating
	}
	lower_right_portrait = scope:supporter
	
	cooldown = { years = 1 }
	
	trigger = {
		involved_activity = {
			any_attending_character = {
				prelude_events_0170_appropriate_guest = yes
				save_temporary_scope_as = guest_temp
			}
		}
		trigger_if = {
			limit = {
				has_activity_intent = coronation_disrupt_loyalists
			}
			involved_activity = {
				any_guest_subset = {
					name = supporter
					NOT = {
						this = scope:guest_temp
					}
					prelude_events_0170_appropriate_supporter = yes
				}
			}
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = { prelude_events_0170_appropriate_guest = yes }
				assign_quirk_effect = yes
				weight = {
					base = 1
					modifier = {
						has_trait = theologian
						add = 1
					}
					modifier = {
						has_trait = zealous
						add = 1
					}
					modifier = {
						primary_title.tier >= tier_county
						add = 1
					}
					modifier = {
						primary_title.tier >= tier_duchy
						add = 1
					}
					modifier = {
						NOT = { faith.religion ?= root.faith.religion }
						add = 5
					}
				}
				save_scope_as = guest
			}
			ordered_guest_subset = {
				name = supporter
				order_by = {
					value = learning
					multiply = -1
				}
				limit = {
					NOT = {
						this = scope:guest
					}
					prelude_events_0170_appropriate_supporter = yes
					scope:activity = {
						is_target_in_variable_list = {
							name = major_supporter
							target = prev
						}
					}
				}
				alternative_limit = {
					NOT = {
						this = scope:guest
					}
					prelude_events_0170_appropriate_supporter = yes
				}
				save_scope_as = supporter
				add_character_flag = {
					flag = prelude_events_0170_supporter
					days = 20
				}
			}
			
		}
	}
	
	option = { # Try to convert them
		name = prelude_events.0170.aa
		trigger = {
			OR = {
				has_trait = zealous
				has_trait = theologian
			}
		}
		add_piety = major_piety_gain # You tried anyways
		duel = {
			target = scope:guest
			skill = learning
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = prelude_events.0170.aa.success
				send_interface_toast = {
					title = prelude_events.0170.aa.success
					left_icon = scope:guest
					scope:guest = { set_character_faith = root.faith }
				}
			}
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = prelude_events.0170.aa.failure
				send_interface_toast = {
					title = prelude_events.0170.aa.failure
					left_icon = scope:guest
					reverse_add_opinion = {
						target = scope:guest
						modifier = disrespect_opinion
						opinion = -15
					}
				}
			}
		}
		stress_impact = {
			theologian = major_stress_impact_loss
			zealous = major_stress_impact_loss
			arrogant = medium_stress_impact_loss
			cynical = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = theologian
					has_trait = zealous
					has_trait = arrogant
				}
				factor = 2
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}
	
	option = { # Have a rad theological debate
		name = prelude_events.0170.a
		duel = {
			target = scope:guest
			skill = learning
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = prelude_events.0170.a.crit_success
				send_interface_toast = {
					title = prelude_events.0170.a.crit_success
					left_icon = scope:host
					add_learning_lifestyle_xp = medium_lifestyle_xp
					scope:host = {
						add_opinion = {
							target = root
							modifier = impressed_opinion
							opinion = 20
						}
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = prelude_events.0170.a.success
				send_interface_toast = {
					title = prelude_events.0170.a.success
					left_icon = root
					add_piety = minor_piety_gain
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = prelude_events.0170.a.failure
				send_interface_toast = {
					title = prelude_events.0170.a.failure
					left_icon = root
					if = {
						limit = {
							government_allows = administrative
							top_liege = scope:activity.activity_host
						}
						change_influence = minor_influence_loss
					}
					else = {
						add_prestige = minor_prestige_loss
					}
				}
			}
		}
		
		stress_impact = {
			theologian = major_stress_impact_loss
			zealous = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			cynical = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = theologian
					has_trait = zealous
					has_trait = arrogant
				}
				factor = 1.5
			}
			modifier = {
				has_trait = cynical
				factor = 0
			}
		}
	}
	
	option = { # Tell me more of this god
		name = prelude_events.0170.b
		custom_tooltip = cheaper_to_convert_to_guest_faith_tt
		set_variable = {
			name = discounted_faith_to_convert_to_var
			value = scope:guest.faith
		}
		involved_activity = {
			every_attending_character = {
				limit = {
					is_vassal_of = scope:host
					has_vassal_stance = zealot
					NOT = { this = root }
				}
				custom = every_zealot_vassal_guest_tt
				add_opinion = {
					target = root
					modifier = impious_opinion
					opinion = -25
				}
			}
		}
		stress_impact = {
			gregarious = medium_stress_impact_loss
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = gregarious
				}
				factor = 2
			}
			modifier = {
				has_trait = callous
				factor = 0
			}
		}
	}
	
	option = { # Let's just focus on something else
		name = {
			trigger = {
				NOT = { has_activity_intent = coronation_disrupt_loyalists }
			}
			text = prelude_events.0170.c
		}
		name = {
			trigger = {
				has_activity_intent = coronation_disrupt_loyalists
			}
			text = prelude_events.0170.c.bad
		}
		flavor = {
			triggered_desc = {
				trigger = {
					has_activity_intent = coronation_disrupt_loyalists
				}
				desc = prelude_events.0170.c.bad_flavor
			}
		}
		if = {
			limit = {
				has_activity_intent = coronation_offer_support
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_supporter
							target = root
						}
					}
				}
			}
			custom_tooltip = {
				text = prelude_events.0140.b.offer_support_tt
				scope:activity = { activity_special_type_progression_medium = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_medium
        	    CHAR = root
        	}
		}
		else_if = {
			limit = {
				has_activity_intent = coronation_disrupt_loyalists
				exists = scope:supporter
			}
			scope:supporter = {
				add_stress = {
					value = medium_stress_impact_gain
					if = {
						limit = {
							root = {
								is_ai = no
							}
						}
						multiply = 1.5
					}
					else = {
						multiply = 0.5
					}
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					has_activity_intent = coronation_disrupt_loyalists
				}
			}
			if = {
				limit = {
					OR = {
						is_ai = no
						scope:activity = {
							is_target_in_variable_list = {
								name = major_supporter
								target = root
							}
						}
					}
				}
				custom_tooltip = {
					text = coronation_tt_positive_miniscule
					scope:activity = { activity_special_type_progression_miniscule = yes }
				}
				coronation_add_magnificence_log_effect = {
        	  	  VALUE = flag:positive_miniscule
        		    CHAR = root
        		}
			}
			add_prestige = minor_prestige_gain
		}
		else = {
			add_prestige = minor_prestige_gain
		}
		stress_impact = {
			base = minor_stress_impact_loss
			zealous = major_stress_impact_gain
			theologian = major_stress_impact_gain
			cynical = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = cynical
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = zealous
					has_trait = theologian
				}
				factor = 0
			}
		}
	}
}

# Host/Guest: You pray at the coronation chapel
prelude_events.0180 = {
	type = activity_event
	title = prelude_events.0180.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { this = involved_activity.activity_host }
				desc = prelude_events.0180.desc.host
			}
			desc = prelude_events.0180.desc.guest
		}
		desc = prelude_events.0180.desc.outro
	}
	theme = coronation_activity
	override_background = { reference = temple }
	center_portrait = {
		character = root
		animation = prayer
	}
	
	cooldown = { years = 1 }
	
	trigger = {
		NOT = { has_trait = cynical }
		faith = root.location.faith # There's a chapel of your faith here
		OR = {
			faith.religion != religion:christianity_religion
			faith.religion != religion:hinduism_religion
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			has_trait = zealous
			factor = 5
		}
	}

	immediate = {
		involved_activity = {
			activity_host = {
				save_scope_as = host
			}
			save_scope_as = activity
		}
	}
	
	option = { # Pray for a successful reign
		name = prelude_events.0180.a
		if = {
			limit = {
				has_activity_intent = coronation_impress_attendees
			}
			custom_tooltip = {
				text = prelude_events.0180.a.impress_attendees_tt
				scope:activity = { activity_special_type_progression_major = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_major
        	    CHAR = root
        	}
		}
		else_if = {
			limit = {
				has_activity_intent = coronation_offer_support
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_supporter
							target = root
						}
					}	
				}
			}
			add_piety = medium_piety_gain
			custom_tooltip = {
				text = prelude_events.0140.b.offer_support_tt
				scope:activity = { activity_special_type_progression_medium = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_medium
        	    CHAR = root
        	}
		}
		else_if = {
			limit = { this = involved_activity.activity_host }
			custom_tooltip = {
				text = coronation_tt_positive_medium
				scope:activity = { activity_special_type_progression_medium = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:positive_medium
        	    CHAR = root
        	}
		}
		else = {
			add_piety = medium_piety_gain
			if = {
				limit = {
					OR = {
						is_ai = no
						scope:activity = {
							is_target_in_variable_list = {
								name = major_supporter
								target = root
							}
						}
						has_activity_intent = coronation_offer_support
					}
				}
				custom_tooltip = {
					text = coronation_tt_positive_tiny
					scope:activity = { activity_special_type_progression_tiny = yes }
				}
				coronation_add_magnificence_log_effect = {
        		    VALUE = flag:positive_tiny
        		    CHAR = root
        		}
			}
			
		}
		stress_impact = {
			arrogant = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					AND = {
						this = scope:host
						has_trait = arrogant
					}
					has_activity_intent = coronation_impress_attendees
					has_activity_intent = coronation_offer_support
				}
				factor = 3
			}
			modifier = {
				factor = 0
				#Should only be picked by host and major supporters
				NOR = {
					this = scope:host
					AND = {
						scope:activity = {
							is_target_in_variable_list = {
								name = major_supporter
								target = prev
							}
						}
						#Should be someone who matters
						OR = {
							any_claim = {
								this = scope:host.primary_title
							}
							is_councillor_of = scope:host
							is_powerful_vassal_of = scope:host
							max_military_strength >= scope:host.half_current_military_strength
							intrigue >= very_high_skill_rating
						}
					}
					
				}
				
			}
		}
	}

	option = {	 #Pray for the downfall of host
		trigger = {
			NOT = {
				this = scope:host
			}
		}
		name = prelude_events.0180.b
		if = {
			limit = {
				has_activity_intent = coronation_disrupt_loyalists
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_detractor
							target = root
						}
					}
				}
			}
			custom_tooltip = {
				text = coronation_tt_negative
				scope:activity = { activity_special_type_progression_negative = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:negative
        	    CHAR = root
        	}
        	custom_tooltip = improved_because_intent_tt
		}
		else_if = {
			limit = {
				OR = {
					is_ai = no
					scope:activity = {
						is_target_in_variable_list = {
							name = major_detractor
							target = root
						}
					}
					has_activity_intent = coronation_disrupt_loyalists
				}
			}
			custom_tooltip = {
				text = coronation_tt_negative_tiny
				scope:activity = { activity_special_type_progression_negative_tiny = yes }
			}
			coronation_add_magnificence_log_effect = {
        	    VALUE = flag:negative_tiny
        	    CHAR = root
        	}
		}
		stress_impact = {
			vengeful = medium_stress_impact_loss
			sadistic = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = vengeful
					has_trait = sadistic
					has_activity_intent = coronation_disrupt_loyalists
				}
				factor = 3
			}
			modifier = {
				factor = 0
				#Should only be picked by major detractors
				NAND = {
					scope:activity = {
						is_target_in_variable_list = {
							name = major_detractor
							target = prev
						}
					}
					#Should be someone who matters
					OR = {
						any_claim = {
							this = scope:host.primary_title
						}
						is_councillor_of = scope:host
						is_powerful_vassal_of = scope:host
						max_military_strength >= scope:host.half_current_military_strength
						intrigue >= very_high_skill_rating
					}
				}
			}
		}
	}
	
	option = { # Pray for good health
		name = prelude_events.0180.c
		add_character_modifier = {
			modifier = coronation_good_health_modifier
			years = 15
		}
		stress_impact = {
			paranoid = medium_stress_impact_loss
			content = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = paranoid
					has_trait = content
				}
				factor = 2
			}
		}
	}
	
	option = { # Pray for Wealth
		name = prelude_events.0180.d
		add_character_modifier = {
			modifier = coronation_wealth_modifier
			years = 15
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
			avaricious = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = avaricious
				}
				factor = 2
			}
		}
	}
}

# Host: Councillor that likes you encourages you
scripted_trigger prelude_events_0190_appropriate_councillor = {
	location = root.location # They're here
	is_ai = yes
	is_healthy = yes
	opinion = {
		target = root
		value >= 10
	}
}

scripted_effect create_coronation_artifact_effect = {
	random_list = {
		10 = {
			create_artifact_weapon_effect = {
				OWNER = scope:councillor
				CREATOR = scope:antiquarian
				SET_WEAPON_TYPE = flag:no
			}
		}
		10 = {
			create_artifact_armor_effect = {
				OWNER = scope:councillor
				CREATOR = scope:antiquarian
				SET_ARMOR_TYPE = flag:no
			}
		}
		10 = {
			create_artifact_brooch_effect = {
				OWNER = scope:councillor
				SMITH = scope:antiquarian
			}
		}
		10 = {
			create_artifact_book_effect = {
				OWNER = scope:councillor 
				CREATOR = scope:antiquarian
				SET_SUBJECT = flag:no
				SET_TOPIC = flag:no
			}
		}
	}
	scope:newly_created_artifact = {
		set_artifact_description = artifact_coronation_gift_desc
		set_artifact_rarity = illustrious
		set_owner = scope:councillor
	}
}

prelude_events.0190 = {
	type = activity_event
	title = prelude_events.0190.t
	desc = {
		desc = prelude_events.0190.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:councillor = { is_spouse_of = root } }
				desc = prelude_events.0190.desc.spouse
			}
			desc = prelude_events.0190.desc.other
		}
		desc = prelude_events.0190.desc.outro
	}
		
	theme = coronation_activity
	override_background = { reference = relaxing_room }
	center_portrait = {
		character = root
		animation = wedding_happy_cry
	}
	right_portrait = {
		character = scope:councillor
		triggered_animation = {
			trigger = { root.cp:councillor_marshal ?= scope:councillor }
			animation = marshal
		}
		animation = admiration
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_left_portrait
	}
	cooldown = { years = 1 }
	
	trigger = {
		any_councillor = { prelude_events_0190_appropriate_councillor = yes }
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			any_councillor = {
				OR = {
					has_relation_friend = root
					has_relation_lover = root
				}
			}
			add = 5
		}
	}

	immediate = {
		save_scope_as = root_scope
		involved_activity = {
			save_scope_as = activity
			activity_host = { save_scope_as = host }
		}
		ordered_councillor = {
			limit = { prelude_events_0190_appropriate_councillor = yes }
			order_by = "opinion(root)"
			save_scope_as = councillor
		}
		save_scope_value_as = {
			name = encouraging_words_quality_boost
			value = yes
		}
		hidden_effect = {
			create_character = {
				location = scope:councillor.location
				template = great_antiquarian_court_position_template
				faith = scope:councillor.faith
				culture = scope:councillor.culture
				save_scope_as = antiquarian
			}
		}
		scope:antiquarian = {
			hidden_effect_new_object = {
				create_coronation_artifact_effect = yes
			}
		}
	}
	
	option = { # Thank you man
		name = prelude_events.0190.a
		scope:newly_created_artifact = {
			set_owner = root
		}
		stress_impact = {
			greedy = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	
	option = { # Cry together
		name = prelude_events.0190.b
		if = {
			limit = {
				scope:councillor = {
					is_spouse_of = root
				}
				can_set_relation_soulmate_trigger = { CHARACTER = scope:councillor }
			}
			set_relation_soulmate = {
				target = scope:councillor
				reason = lover_bestie_coronation_vespers
			}
			if = {
				limit = { scope:councillor = { has_any_fertility_relationship_with_root_trigger = no } }
				set_relation_wedding_good_fertility = scope:councillor
			}
		}
		else_if = {
			limit = {
				can_set_relation_best_friend_trigger = { CHARACTER = scope:councillor }
			}
			set_relation_best_friend = {
				target = scope:councillor
				reason = lover_bestie_coronation_vespers
			}
		}
		stress_impact = {
			gregarious = major_stress_impact_loss
			content = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = gregarious
					has_trait = content
				}
				factor = 2
			}
		}
	}
	
	option = { # I feel calmer now
		name = prelude_events.0190.c
		custom_tooltip = {
			text = coronation_tt_positive_tiny
			scope:activity = { activity_special_type_progression_tiny = yes }
		}
		coronation_add_magnificence_log_effect = {
            VALUE = flag:positive_tiny
            CHAR = root
        }
		stress_impact = {
			base = major_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}
}
