﻿namespace = coronation_events

#####################################
# Coronation - Systemic Events		#
# coronation_events - 0000-9999		#
#####################################

scripted_effect sworn_oath_effect = {
	scope:activity = {
		custom_tooltip = coronation_tt_positive_medium
		change_variable = {
			name = activity_special_type_progression
			add = 10
		}
	}
}

scripted_effect warlike_oath_effect = {
	scope:activity = {
		every_attending_character = {
			custom = warlike_character_opinion
			limit = {
				is_vassal_of = scope:host
				OR = {
					has_vassal_stance = glory_hound
					has_vassal_stance = belligerent
				}
			}
			add_opinion = {
				modifier = respect_opinion
				target = scope:host
				opinion = 15
			}
		}
	}
}

# Phase Controller
coronation_events.0050 = {
	type = activity_event
	hidden = yes

	trigger = {
		involved_activity ?= {
			NOT = { has_current_phase = coronation_phase_feast }
			OR = {
				is_current_phase_active = no
				has_variable = ceremony_complete
			}
		}
	}

	immediate = {
		if = {
			limit = {
				involved_activity ?= {
					NOT = {
						any_in_list = {
							variable = coronation_list_busy
							OR = {
								is_alive = yes
								involved_activity ?= root.involved_activity
							}
						}
					}
				}
			}
			involved_activity ?= {
				progress_activity_phase_after = { days = 1 }
			}
		}
		else = {
			trigger_event = {
				id = coronation_events.0050
				weeks = 1
			}
		}
	}
}

# Oath Event
coronation_events.0100 = {
	type = activity_event
	title = coronation_events.0100.t
	desc = {
		desc = coronation_events.0100.desc.opening
		triggered_desc = {
			trigger = {
				scope:previous_ruler ?= {
					is_close_family_of = root
				}
			}
			desc = coronation_events.0100.desc.previous_ruler_close_family
		}
		triggered_desc = {
			trigger = {
				scope:previous_ruler ?= {
					NOT = { is_close_family_of = root }
					is_lowborn = yes
				}
			}
			desc = coronation_events.0100.desc.previous_ruler_not_family_no_house
		}
		triggered_desc = {
			trigger = {
				scope:previous_ruler ?= {
					NOT = { is_close_family_of = root }
				}
			}
			desc = coronation_events.0100.desc.previous_ruler_not_family
		}
		triggered_desc = {
			trigger = {
				NOT = { exists = scope:previous_ruler }
			}
			desc = coronation_events.0100.desc.first_ruler
		}
		desc = coronation_events.0100.desc.outro
	}
	center_portrait = {
		character = root
		animation = storyteller
	}
	theme = coronation_activity
	override_background = {
		trigger = {
			scope:host = {
				coronation_proper_artifact_crown_trigger = yes
				coronation_living_officiator_trigger = yes
			}
		}
		reference = temple
	}
	override_background = {
		trigger = {
			NOT = {
				scope:host = {
					coronation_proper_artifact_crown_trigger = yes
					coronation_living_officiator_trigger = yes
				}
			}
			
		}
		reference = throne_room
	}

	immediate = {
		# For MP
		coronation_busy_effect = yes

		save_scope_as = root_scope
		coronation_set_oath_alternatives_effect = yes
		primary_title.previous_holder ?= {
			save_scope_as = previous_ruler
		}
		### Special Checks
		if = {
			limit = {
				any_in_list = {
					list = chosen_oaths
					this = flag:learning_oath_1
				}
			}
			if = { # University exists
				limit = {
					any_realm_county = {
						title_province = { has_university_building_trigger = yes }
					}
				}
				set_variable = {
					name = learning_oath_1_university_exists
					value = 1
				}
			}
			save_scope_value_as = {
				name = learning_oath_temp_cost
				value = oath_university_gold_value
			}
			save_scope_value_as = {
				name = learning_oath_temp_development
				value = oath_university_development_value
			}
		}

		if = {
			limit = {
				any_character_struggle = { is_struggle_type = iberian_struggle }
			}
			struggle:iberian_struggle = { save_scope_as = involved_struggle }
		}
		else_if = {
			limit = {
				any_character_struggle = { is_struggle_type = persian_struggle }
			}
			struggle:persian_struggle = { save_scope_as = involved_struggle }
		}
	}

	## Diplomacy
	# Alliances
	option = {
		name = coronation_events.0100.alliances
		flavor = coronation_events.0100.alliances_flavor
		reason = alliance_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:diplomacy_oath_1
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = diplomacy_oath_1
				TIME = 7300
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# Children
	option = {
		name = coronation_events.0100.children
		flavor = coronation_events.0100.children_flavor
		reason = children_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:diplomacy_oath_2
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = diplomacy_oath_2
				TIME = 10950
			}
		}

		ai_chance = {
			base = 10
		}
	}

	## Martial
	# Reconquest
	option = {
		name = coronation_events.0100.reconquest
		flavor = coronation_events.0100.reconquest_flavor
		reason = reconquest_oath
		
		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:martial_oath_1
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = martial_oath_1
				TIME = 7300
			}
			set_variable = {
				name = oath_reconquest_title
				value = primary_title
			}
			create_character_memory = {
				type = reconquest_oath_memory
			}
		}
		# Vassals who approve
		warlike_oath_effect = yes
		# Threatened rulers who disapprove
		scope:activity = {
			every_attending_character = {
				custom = coronation_events.0100.reconquest_opinion
				limit = {
					any_directly_owned_province = {
						barony = {
							target_is_de_jure_liege_or_above = scope:host.primary_title
						}
					}
					NOR = {
						target_is_liege_or_above = scope:host
						this = scope:host
					}
				}
				add_opinion = {
					modifier = threatened_opinion
					target = root
					opinion = -20
				}
			}
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 100
				OR = {
					ai_has_warlike_personality = yes
					ai_has_conqueror_personality = yes
				}
			}
		}
	}

	# Conquest
	option = {
		name = coronation_events.0100.conquest
		flavor = coronation_events.0100.conquest_flavor
		reason = conquest_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:martial_oath_2
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			if = {
				limit = {
					is_ai = yes
				}
				add_character_modifier = {
					modifier = oath_warlike_ai_modifier
					years = 20
				}
			}
			coronation_chosen_oath_setup_effect = {
				VAR = martial_oath_2
				TIME = 7300
			}
			set_variable = {
				name = oath_conquest_size
				value = oath_conquest_value_1
			}
			create_character_memory = {
				type = conquest_oath_memory
			}
		}
		# Vassals who approve
		warlike_oath_effect = yes
		# Threatened rulers who disapprove
		scope:activity = {
			every_attending_character = {
				custom = coronation_events.0100.conquest_opinion
				limit = {
					any_held_title = {
						is_neighbor_to_realm = root
					}
					NOR = {
						target_is_liege_or_above = scope:host
						this = scope:host
					}
				}
				add_opinion = {
					modifier = threatened_opinion
					target = root
					opinion = -20
				}
			}
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 100
				OR = {
					ai_has_warlike_personality = yes
					ai_has_conqueror_personality = yes
				}
			}
		}
	}

	## Stewardship
	# Peace
	option = {
		name = coronation_events.0100.peace
		flavor = coronation_events.0100.peace_flavor
		reason = peace_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:stewardship_oath_1
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			if = {
				limit = {
					is_ai = yes
				}
				add_character_modifier = {
					modifier = oath_peaceful_ai_modifier
					years = 20
				}
			}
			coronation_chosen_oath_setup_effect = {
				VAR = stewardship_oath_1
				TIME = 18250
			}

		}

		ai_chance = {
			base = 10
		}
	}

	# Buildings
	option = {
		name = coronation_events.0100.buildings
		flavor = coronation_events.0100.buildings_flavor
		reason = build_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:stewardship_oath_2
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = stewardship_oath_2
				TIME = 7300
			}
			set_variable = {
				name = stewardship_oath_2_buildings
				value = 0
			}
		}

		ai_chance = {
			base = 10
			modifier = {
				add = 20
				ai_has_economical_boom_personality = yes
			}
			modifier = {
				factor = 0
				OR = {
					ai_has_warlike_personality = yes
					ai_has_conqueror_personality = yes
				}
			}
		}
	}

	## Intrigue

	## Learning
	# University
	option = {
		name = coronation_events.0100.university
		flavor = coronation_events.0100.university_flavor
		reason = university_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:learning_oath_1
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = learning_oath_1
				TIME = 18250
			}
			set_variable = {
				name = learning_oath_cost
				value = scope:learning_oath_temp_cost
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# De jure rights

	option = {
		name = coronation_events.0100.purge_pretenders
		flavor = coronation_events.0100.purge_pretenders_flavor
		reason = purge_pretenders_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:purge_pretenders_oath
			}
		}

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = purge_pretenders_oath
				TIME = 7300
			}
			set_variable = {
				name = purge_pretenders_target_title
				value = primary_title
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# End the Struggle
	option = {
		name = coronation_events.0100.end_the_struggle
		flavor = coronation_events.0100.end_the_struggle_flavor
		reason = end_the_struggle_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:end_the_struggle_oath
			}
		}

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = end_the_struggle_oath
				TIME = 18250
			}
			if = {
				limit = {
					any_character_struggle = { is_struggle_type = iberian_struggle }
				}
				set_variable = {
					name = end_the_struggle_oath_type_var
					value = flag:iberian_struggle
				}
			}
			else_if = {
				limit = {
					any_character_struggle = { is_struggle_type = persian_struggle }
				}
				set_variable = {
					name = end_the_struggle_oath_type_var
					value = flag:persian_struggle
				}
				
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# Greatest Hunter
	option = {
		name = coronation_events.0100.greatest_hunter
		flavor = coronation_events.0100.greatest_hunter_flavor
		reason = greatest_hunter_oath
		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:greatest_hunter_oath
			}
		}
		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = greatest_hunter_oath
				TIME = 14600
			}
			set_variable = {
				name = greatest_hunter_oath_r_counter
				value = 0
			}
			set_variable = {
				name = greatest_hunter_oath_l_counter
				value = 0
			}
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 10
				has_trait = lifestyle_hunter 
			}
			modifier = {
				add = 10
				ai_energy > 0
			}
		}
	}

	# Heir Preparation
	option = {
		name = coronation_events.0100.heir_preparation
		flavor = coronation_events.0100.heir_preparation_flavor
		reason = heir_preparation_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:heir_preparation_oath
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = heir_preparation_oath
				TIME = 14600
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# Install Claimants
	option = {
		name = coronation_events.0100.install_claimants
		flavor = coronation_events.0100.install_claimants_flavor
		reason = install_claimants_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:install_claimants_oath
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = install_claimants_oath
				TIME = 7300
			}
			set_variable = {
				name = install_claimants_oath_counter
				value = 0
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# Mend the Fracture
	option = {
		name = coronation_events.0100.mend_the_fracture
		flavor = coronation_events.0100.mend_the_fracture_flavor
		reason = mend_the_fracture_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:mend_the_fracture_oath
			}
		}
		sworn_oath_effect = yes

		random_sub_realm_county = {
			limit = {
				culture != root.culture
				culture = {
					cultural_acceptance = {
						target = root.culture
						value <= 20
					}
					any_culture_county = {
						count >= 6
						holder = {
							target_is_liege_or_above = root
						}
					}
					any_culture_county = {
						percent >= 0.6
						holder = {
							target_is_liege_or_above = root
						}
					}
				}
			}
			culture = {
				save_scope_as = target_culture
			}	
		}

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = mend_the_fracture_oath
				TIME = 7300
			}
			set_variable = {
				name = mend_the_fracture_oath_target_culture
				value = scope:target_culture
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# Provide for the Warriors
	option = {
		name = coronation_events.0100.provide_for_the_warriors
		flavor = coronation_events.0100.provide_for_the_warriors_flavor
		reason = provide_for_the_warriors_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:provide_for_the_warriors_oath
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = provide_for_the_warriors_oath
				TIME = 7300
			}
		}

		ai_chance = {
			base = 10
			modifier = {
				add = 20
				ai_has_economical_boom_personality = yes
			}
			modifier = {
				factor = 0
				OR = {
					ai_has_warlike_personality = yes
					ai_has_conqueror_personality = yes
				}
			}
		}
	}

	# Provide for the Faithful
	option = {
		name = coronation_events.0100.provide_for_the_faithful
		flavor = coronation_events.0100.provide_for_the_faithful_flavor
		reason = provide_for_the_faithful_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:provide_for_the_faithful_oath
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = provide_for_the_faithful_oath
				TIME = 7300
			}
		}

		ai_chance = {
			base = 10
			modifier = {
				add = 20
				ai_has_economical_boom_personality = yes
			}
			modifier = {
				factor = 0
				OR = {
					ai_has_warlike_personality = yes
					ai_has_conqueror_personality = yes
				}
			}
		}
	}

	# Provide for the Poor

	option = {
		name = coronation_events.0100.provide_for_the_poor
		flavor = coronation_events.0100.provide_for_the_poor_flavor
		reason = provide_for_the_poor_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:provide_for_the_poor_oath
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = provide_for_the_poor_oath
				TIME = 7300
			}
		}

		ai_chance = {
			base = 10
			modifier = {
				add = 20
				ai_has_economical_boom_personality = yes
			}
			modifier = {
				factor = 0
				OR = {
					ai_has_warlike_personality = yes
					ai_has_conqueror_personality = yes
				}
			}
		}
	}

	# Repent

	option = {
		name = coronation_events.0100.repent
		flavor = coronation_events.0100.repent_flavor
		reason = repent_oath

		trigger = {
			any_in_list = {
				list = chosen_oaths
				this = flag:repent_oath
			}
		}
		sworn_oath_effect = yes

		scope:host = { 
			coronation_chosen_oath_setup_effect = {
				VAR = repent_oath
				TIME = 7300
			}
			set_variable = {
				name = repent_oath_pilgrimage_counter
				value = 0
			}
		}

		ai_chance = {
			base = 0
		}
	}

	# Opt-out, where you don't take an oath
	option = {
		name = coronation_events.0100.opt_out
		scope:host = {
			add_character_flag = {
				flag = coronation_no_oath
				days = 40
			}
		}
		ai_chance = {
			base = 1
		}
	}

	after = {
		# For MP
		coronation_ready_effect = yes

		scope:activity = {
			every_attending_character = {
				limit = {
					NOT = { this = root }
				}
				trigger_event = coronation_events.0110
			}
		}
		# Cleanup of variable checks
		remove_variable = learning_oath_1_university_exists

		if = {
			limit = {
				has_multiple_players = yes
				scope:activity = {
					any_attending_character = {
						NOT = { this = scope:host }
						is_ai = no
					}
				}
			}
			scope:activity = { 
				progress_activity_phase_after = { weeks = 8 } 
				set_variable = ceremony_complete
			}
			trigger_event = {
				id = coronation_events.0050
				weeks = 1
			}
		}
		else = {
			scope:activity = { progress_activity_phase_after = { days = 1 } }
		}
	}
}

# Oath - Attendee Followup Event
coronation_events.0110 = {
	type = activity_event
	title = coronation_events.0110.t
	desc = {
		desc = coronation_events.0110.desc.intro
		first_valid = {
			# Diplomacy
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = diplomacy_oath_1
					}
				}
				desc = coronation_events.0110.desc.diplomacy_oath_1
			}
			# Martial
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = martial_oath_1
					}
				}
				desc = coronation_events.0110.desc.martial_oath_1
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = martial_oath_2
					}
				}
				desc = coronation_events.0110.desc.martial_oath_2
			}
			# Stewardship
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = stewardship_oath_1
					}
				}
				desc = coronation_events.0110.desc.stewardship_oath_1
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = stewardship_oath_2
					}
				}
				desc = coronation_events.0110.desc.stewardship_oath_2
			}
			# Intrigue
			# Learning
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = learning_oath_1
					}
				}
				desc = coronation_events.0110.desc.learning_oath_1
			}
			# De Jure Rights
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = purge_pretenders_oath
					}
				}
				desc = coronation_events.0110.desc.purge_pretenders_oath
			}
			# End the Struggle
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = end_the_struggle_oath
					}
				}
				desc = coronation_events.0110.desc.end_the_struggle_oath
			}
			# Greatest Hunter
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = greatest_hunter_oath
					}
				}
				desc = coronation_events.0110.desc.greatest_hunter_oath
			}
			# Heir Preparation
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = heir_preparation_oath
					}
				}
				desc = coronation_events.0110.desc.heir_preparation_oath
			}
			# Install Claimants
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = install_claimants_oath
					}
				}
				desc = coronation_events.0110.desc.install_claimants_oath
			}
			# Mend the Fracture
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = mend_the_fracture_oath
					}
				}
				desc = coronation_events.0110.desc.mend_the_fracture_oath
			}
			# Provide for the Warriors
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = provide_for_the_warriors_oath
					}
				}
				desc = coronation_events.0110.desc.provide_for_the_warriors_oath
			}
			# Provide for the Faithful
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = provide_for_the_faithful_oath
					}
				}
				desc = coronation_events.0110.desc.provide_for_the_faithful_oath
			}
			# Provide for the Poor
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = provide_for_the_poor_oath
					}
				}
				desc = coronation_events.0110.desc.provide_for_the_poor_oath
			}
			# Repent
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_variable = repent_oath
					}
				}
				desc = coronation_events.0110.desc.repent_oath
			}

			# Other
			desc = coronation_events.0110.desc.fallback
		}
		desc = coronation_events.0110.desc.outro
	}
	center_portrait = {
		character = scope:activity.activity_host
		animation = storyteller
	}
	theme = coronation_activity
	override_background = {
		trigger = {
			scope:host = {
				coronation_proper_artifact_crown_trigger = yes
				coronation_living_officiator_trigger = yes
			}
		}
		reference = temple
	}
	override_background = {
		trigger = {
			NOT = {
				scope:host = {
					coronation_proper_artifact_crown_trigger = yes
					coronation_living_officiator_trigger = yes
				}
			}
			
		}
		reference = throne_room
	}

	immediate = {
		# For MP
		coronation_busy_effect = yes
	}

	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:host = {
								has_character_flag = coronation_no_oath
							}
						}
						desc = coronation_events.0110.no_oath
					}
					desc = coronation_events.0110.regular
				}
			}
		}
	}

	after = {
		# For MP
		coronation_ready_effect = yes
	}
}

# Oath Failure Event
coronation_events.0150 = {
	type = character_event
	title = coronation_events.0150.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = honest
				}
				desc = coronation_events.0150.desc_honest
			}
			triggered_desc = {
				trigger = {
					has_trait = deceitful
				}
				desc = coronation_events.0150.desc_deceitful
			}
			desc = coronation_events.0150.desc
		}
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = honest
			}
			animation = grief
		}
		triggered_animation = {
			trigger = {
				has_trait = deceitful
			}
			animation = dismissal
		}
		animation = disapproval
	}
	theme = coronation

	trigger = {
		highest_held_title_tier >= tier_kingdom
		calc_true_if = {
			amount > 0
			AND = {
				has_variable = diplomacy_oath_1
				NOT = { has_variable = diplomacy_oath_1_timer }
			}
			AND = {
				has_variable = diplomacy_oath_2
				NOT = { has_variable = diplomacy_oath_2_timer }
			}
			AND = {
				has_variable = martial_oath_1
				NOT = { has_variable = martial_oath_1_timer }
			}
			AND = {
				has_variable = martial_oath_2
				NOT = { has_variable = martial_oath_2_timer }
			}
			AND = {
				has_variable = stewardship_oath_1
				NOT = { has_variable = stewardship_oath_1_timer }
			}
			AND = {
				has_variable = stewardship_oath_2
				NOT = { has_variable = stewardship_oath_2_timer }
			}
			AND = {
				has_variable = learning_oath_1
				NOT = { has_variable = learning_oath_1_timer }
			}
			AND = {
				has_variable = purge_pretenders_oath
				NOT = { has_variable = purge_pretenders_oath_timer }
			}
			AND = {
				has_variable = end_the_struggle_oath
				NOT = { has_variable = end_the_struggle_oath_timer }
			}
			AND = {
				has_variable = greatest_hunter_oath
				NOT = { has_variable = greatest_hunter_oath_timer }
			}
			AND = {
				has_variable = heir_preparation_oath
				NOT = { has_variable = heir_preparation_oath_timer }
			}
			AND = {
				has_variable = install_claimants_oath
				NOT = { has_variable = install_claimants_oath_timer }
			}
			AND = {
				has_variable = mend_the_fracture_oath
				NOT = { has_variable = mend_the_fracture_oath_timer }
			}
			AND = {
				has_variable = provide_for_the_warriors_oath
				NOT = { has_variable = provide_for_the_warriors_oath_timer }
			}
			AND = {
				has_variable = provide_for_the_faithful_oath
				NOT = { has_variable = provide_for_the_faithful_oath_timer }
			}
			AND = {
				has_variable = provide_for_the_poor_oath
				NOT = { has_variable = provide_for_the_poor_oath_timer }
			}
			AND = {
				has_variable = repent_oath
				NOT = { has_variable = repent_oath_timer }
			}
		}
	}

	immediate = {
		# Diplomacy
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = diplomacy_oath_1
		}
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = diplomacy_oath_2
		}
		# Martial
		coronation_oath_remove_variable_on_failure_effect = { 
			VAR = martial_oath_1 
		}
		coronation_oath_remove_variable_on_failure_effect = { 
			VAR = martial_oath_2 
		}
		# Stewardship
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = stewardship_oath_1
		}
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = stewardship_oath_2
		}
		# Intrigue
		# Learning
		coronation_oath_remove_variable_on_failure_effect = { 
			VAR = learning_oath_1 
		}

		# Purge Pretenders
		coronation_oath_remove_variable_on_failure_effect = { 
			VAR = purge_pretenders_oath 
		}

		#End the Struggle
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = end_the_struggle_oath
		}

		# Greatest Hunter
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = greatest_hunter_oath
		}
		# Heir Preparation
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = heir_preparation_oath
		}
		# Install Claimants
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = install_claimants_oath
		}
		# Mend the Fracture
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = mend_the_fracture_oath
		}
		# Provide for the Warriors
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = provide_for_the_warriors_oath
		}
		# Provide for the Faithful
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = provide_for_the_faithful_oath
		}
		# Provide for the Poor
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = provide_for_the_poor_oath
		}
		# Repent
		coronation_oath_remove_variable_on_failure_effect = {
			VAR = repent_oath
		}

		coronation_broken_oath_punishment_effect = yes
	}

	option = {
		name = {
			trigger = { 
				always = yes
			}
			text = coronation_events.0150.a
		}
		name = {
			trigger = { 
				has_trait = deceitful
			}
			text = coronation_events.0150.a_deceitful
		}
		name = {
			trigger = { 
				has_trait = honest
			}
			text = coronation_events.0150.a_honest
		}

		add_prestige = {
			value = {
				value = -20
				multiply = scope:scale_of_oath_failure_scope
				min = -10000
				max = -100
			}
		}
	
		add_legitimacy = {
			value = {
				value = -10
				multiply = scope:scale_of_oath_failure_scope
				min = -2000
				max = -50
			}
		}

		if = {
			limit = {
				is_ai = no
			}
			set_nickname_effect = { NICKNAME = nick_the_oathbreaker }
		}
		else = {
			random = {
				chance = 5
				set_nickname_effect = { NICKNAME = nick_the_oathbreaker }
			}
		}
		

		stress_impact = {
			deceitful = minor_stress_impact_loss
			honest = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}		
	}
}

# Oath Success Event
coronation_events.0175 = {
	type = character_event
	title = coronation_events.0175.t
	desc = coronation_events.0175.desc
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				drinks_alcohol_trigger = yes
			}
			animation = toast_goblet
		}
		triggered_animation = {
			trigger = {
				drinks_alcohol_trigger = no
			}
			animation = happiness
		}
	}
	theme = coronation

	override_effect_2d = {
		reference = legend_glow
	}

	immediate = {
		switch = {
			trigger = scope:find_oath
			flag:diplomacy_oath_1 = {
				coronation_oath_reward_effect = { VARIABLE = diplomacy_oath_1 }
			}
			flag:diplomacy_oath_2 = {
				coronation_oath_reward_effect = { VARIABLE = diplomacy_oath_2 }
			}
			flag:martial_oath_1 = {
				coronation_oath_reward_effect = { VARIABLE = martial_oath_1 }
			}
			flag:martial_oath_2 = {
				coronation_oath_reward_effect = { VARIABLE = martial_oath_2 }
			}
			flag:stewardship_oath_1 = {
				coronation_oath_reward_effect = { VARIABLE = stewardship_oath_1 }
			}
			flag:stewardship_oath_2 = {
				coronation_oath_reward_effect = { VARIABLE = stewardship_oath_2 }
			}
			flag:learning_oath_1 = {
				coronation_oath_reward_effect = { VARIABLE = learning_oath_1 }
			}
			flag:purge_pretenders_oath = {
				coronation_oath_reward_effect = { VARIABLE = purge_pretenders_oath }
			}
			flag:end_the_struggle_oath = {
				coronation_oath_reward_effect = { VARIABLE = end_the_struggle_oath }
			}
			flag:greatest_hunter_oath = {
				coronation_oath_reward_effect = { VARIABLE = greatest_hunter_oath }
			}
			flag:heir_preparation_oath = {
				coronation_oath_reward_effect = { VARIABLE = heir_preparation_oath }
			}
			flag:install_claimants_oath = {
				coronation_oath_reward_effect = { VARIABLE = install_claimants_oath }
			}
			flag:mend_the_fracture_oath = {
				coronation_oath_reward_effect = { VARIABLE = mend_the_fracture_oath }
			}
			flag:provide_for_the_warriors_oath = {
				coronation_oath_reward_effect = { VARIABLE = provide_for_the_warriors_oath }
			}
			flag:provide_for_the_faithful_oath = {
				coronation_oath_reward_effect = { VARIABLE = provide_for_the_faithful_oath }
			}
			flag:provide_for_the_poor_oath = {
				coronation_oath_reward_effect = { VARIABLE = provide_for_the_poor_oath }
			}
			flag:repent_oath = {
				coronation_oath_reward_effect = { VARIABLE = repent_oath }
			}
		}
	}

	option = {
		name = coronation_events.0175.a
		stress_impact = { base = medium_stress_loss }

		if = {
			limit = {
				has_variable = oath_reconquest_title
			}
			remove_variable = oath_reconquest_title
		}
	}
}

scripted_trigger coronation_events_0200_available_chaplain_trigger = {
	basic_is_available_ai = yes
	is_travelling = no
	NOR = {
		exists = involved_activity
		has_character_flag = planning_an_activity
	}
}

# Start of Prelude Phase
coronation_events.0200 = {
	type = activity_event
	title = coronation_events.0200.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity.activity_host = root
				}
				desc = coronation_events.0200.desc.host
			}
			triggered_desc = {
				trigger = {
					scope:activity.activity_host != root
				}
				desc = coronation_events.0200.desc.guest
			}
		}
	}
	left_portrait = {
		character = scope:attendee
		animation = standing_horse
		camera = camera_event_standing_with_horse_left_angled_in
	}
	center_portrait = {
		character = scope:activity.activity_host
		triggered_animation = {
			trigger = {
				OR = {
					government_has_flag = government_is_celestial
					government_has_flag = government_is_meritocratic
					government_has_flag = government_is_japan_administrative
				}
			}
			animation = emperor
		}
		animation = storyteller
		camera = camera_event_center_moved_left
	}
	right_portrait = {
		character = scope:other_guest
		triggered_animation = {
			trigger = {
				scope:host = {
					coronation_host_east_asian_admin_or_mandala_trigger = yes
				}
				is_merit_based_official = yes
			}
			animation = gongshou_with_hu
		}
		triggered_animation = {
			trigger = {
				scope:host = {
					coronation_host_east_asian_admin_or_mandala_trigger = yes
				}
			}
			animation = throne_room_bow_2
		}
		animation = throne_room_applaud_1
		camera = camera_event_right_to_the_right
	}
	override_background = {
		trigger = {
			involved_activity.activity_location.culture ?= { has_building_gfx = southeast_asian_building_gfx }
		}
		reference = ep2_holy_site_indian
	}
	override_background = {
		trigger = {
			OR = {
				involved_activity.activity_location.culture ?= { has_graphical_western_culture_group_trigger = yes }
				involved_activity.activity_location = { steppe_building_gfx_use_western_trigger = yes }
				#Do not want generic courtyard calling up Constantinople for this one
				location.county = title:c_byzantion
			}
			NOT = {
				scope:activity.activity_location.county.title_province ?= {
					has_holding_type = tribal_holding
				}
			}
		}
		reference = bp2_courtyard
	}
	override_background = {
		reference = courtyard
	}
	theme = coronation

	immediate = {
		# For MP
		coronation_busy_effect = yes
		scope:activity = {
			activity_host = { save_scope_as = host }

			if = {
				limit = {
					NOT = {
						root = scope:host
					}
				}
				root = { save_scope_as = attendee }
			}
			else = {
				random_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							is_courtier_of = scope:host
						}
					}
					alternative_limit = {
						NOT = {
							this = scope:host
						}
					}
					save_scope_as = attendee
				}
			}
			random_attending_character = {
				limit = {
					NOR = {
						this = scope:host
						this = scope:attendee
						is_in_guest_subset = {
							name = detractor
						}
						is_spouse_of = scope:host
					}
					OR = {
						AND = {
							is_courtier_of = scope:host
							NOT = {
								has_relation_rival = scope:host
							}
						}
						
						is_in_guest_subset = {
							name = supporter
						}
					}
				}
				alternative_limit = {
					NOR = {
						this = scope:host
						this = scope:attendee
					}
				}
				save_scope_as = other_guest
			}
		}
		if = {
			limit = {
				this = scope:host
			}
			scope:activity = {
				coronation_update_supporters_detractors_effect = yes
			}
		}
	}

	option = {
		name = coronation_events.0200.a
		trigger = {
			scope:activity.activity_host = root
		}
		if = {
			limit = {
				NOT = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = coronation_type_anointment
						}
						any_attending_character = {
							this = scope:host.faith.religious_head
							is_alive = yes
							is_imprisoned = no
							
						}
					}
				}
				coronation_proper_artifact_crown_trigger = yes
				OR = {
					cp:councillor_court_chaplain.involved_activity ?= root.involved_activity
					involved_activity = {
						any_attending_character = {
							government_has_flag = government_is_theocracy
						}
					}
					#Can be forcibly added
					cp:councillor_court_chaplain ?= {
						coronation_events_0200_available_chaplain_trigger = yes
					}
				}
			}
			trigger_event = coronation_events.0300
		}
		else_if = {
			limit = {
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = coronation_type_anointment
					}
					any_attending_character = {
						this = scope:host.faith.religious_head
						is_alive = yes
						is_imprisoned = no
					}
				}
			}
			involved_activity = {
				set_variable = {
					name = officiator
					value = scope:host.faith.religious_head
				}
				scope:host.faith.religious_head = {
					add_character_flag = {
						flag = coronation_officiator
						years = 2
					} 
				}
			}
		}
	}

	option = {
		name = coronation_events.0200.b
		trigger = {
			scope:activity.activity_host != root
		}
	}

	after = {
		# For MP
		coronation_ready_effect = yes
	}
}

scripted_trigger coronation_events_0205_audience = {
	NOR = {
		this = scope:host
		this = root
		trigger_if = {
			limit = {
				exists = scope:activity.special_guest:priest
			}
			this = scope:activity.special_guest:priest
		}
		is_spouse_of = scope:host
		is_close_family_of = scope:host
		is_diarch_of_target = scope:host
	}	
}

# Start of Ceremony Phase
coronation_events.0205 = {
	type = activity_event
	title = coronation_events.0205.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					involved_activity.var:activity_special_type_progression < 25
				}
				desc = coronation_events.0205.meager
			}
			desc = coronation_events.0205.great
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					location.barony = title:b_constantinople
					OR = {
						scope:host.faith.religion = religion:eastern_orthodox_religion 
						scope:host.faith.religion = religion:catholic_religion 
						scope:host.faith.religion = religion:protestant_religion 
					}
				}
				desc = coronation_events.0205.hagia_sophia
			}
			triggered_desc = {
				trigger = {
					location.barony = title:b_paris
					OR = {
						scope:host.faith.religion = religion:eastern_orthodox_religion 
						scope:host.faith.religion = religion:catholic_religion 
						scope:host.faith.religion = religion:protestant_religion 
					}
					OR = {
						primary_title = title:k_france
						primary_title = title:e_france
						culture = {
							OR = {
								this = culture:french
								any_parent_culture_or_above = {
									this = culture:french
								}
							}
						}
						location.culture = {
							OR = {
								this = culture:french
								any_parent_culture_or_above = {
									this = culture:french
								}
							}
						}
					}
				}
				desc = coronation_events.0205.saint_denis
			}
			triggered_desc = {
				trigger = {
					current_year > 1000
					location.barony = title:b_krakow
					OR = {
						scope:host.faith.religion = religion:eastern_orthodox_religion 
						scope:host.faith.religion = religion:catholic_religion 
						scope:host.faith.religion = religion:protestant_religion 
					}
				}
				desc = coronation_events.0205.wawel
			}
			triggered_desc = {
				trigger = {
					location.barony = title:b_vaticano
					faith = faith:catholic
					scope:host.faith = faith:catholic
				}
				desc = coronation_events.0205.st_peters
			}
			triggered_desc = {
				trigger = {
					current_year >= 950
					location.barony = title:b_london
					OR = {
						scope:host.faith.religion = religion:eastern_orthodox_religion 
						scope:host.faith.religion = religion:catholic_religion 
						scope:host.faith.religion = religion:protestant_religion 
					}
				}
				desc = coronation_events.0205.westminster
			}
			triggered_desc = {
				trigger = {
					location.barony = title:b_reims
					OR = {
						scope:host.faith.religion = religion:eastern_orthodox_religion 
						scope:host.faith.religion = religion:catholic_religion 
						scope:host.faith.religion = religion:protestant_religion 
					}
				}
				desc = coronation_events.0205.reims
			}
			triggered_desc = {
				trigger = {
					location.barony = title:b_aachen
					OR = {
						scope:host.faith.religion = religion:eastern_orthodox_religion 
						scope:host.faith.religion = religion:catholic_religion 
						scope:host.faith.religion = religion:protestant_religion 
					}
					NOT = {
						government_has_flag = government_is_nomadic
					}
				}
				desc = coronation_events.0205.aachen
			}
			triggered_desc = {
				trigger = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
				desc = coronation_events.0205.east_admin_location
			}
			desc = coronation_events.0205.temple
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
				desc = coronation_events.0205.east_admin_description
			}
			triggered_desc = {
				trigger = {
					scope:activity.var:activity_special_type_progression < 25
				}
				desc = coronation_events.0205.silence
			}
			desc = coronation_events.0205.cheers
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity.activity_host = root
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
				desc = coronation_events.0205.desc.host_east_asian
			}
			triggered_desc = {
				trigger = {
					scope:activity.activity_host = root
				}
				desc = coronation_events.0205.desc.host
				
			}
			triggered_desc = {
				trigger = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
				desc = coronation_events.0205.desc.guest_east_asian
			}
			triggered_desc = {
				trigger = {
					involved_activity.activity_host != root
				}
				desc = coronation_events.0205.desc.guest
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
					scope:activity.var:activity_special_type_progression < 25
				}
				desc = coronation_events.0205.desc.low_magnificence_east_asian
			}
			triggered_desc = {
				trigger = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
					scope:activity.var:activity_special_type_progression < 75
				}
				desc = coronation_events.0205.desc.medium_magnificence_east_asian
			}
			triggered_desc = {
				trigger = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
					scope:activity.var:activity_special_type_progression < 75
				}
				desc = coronation_events.0205.desc.high_magnificence_east_asian
			}
			triggered_desc = {
				trigger = {
					scope:activity.var:activity_special_type_progression < 25
				}
				desc = coronation_events.0205.desc.low_magnificence
			}
			triggered_desc = {
				trigger = {
					scope:activity.var:activity_special_type_progression < 75
				}
				desc = coronation_events.0205.desc.medium_magnificence
			}
			desc = coronation_events.0205.desc.high_magnificence
		}
	}
	left_portrait = {
		triggered_animation = {
			trigger = {
				scope:host = {
					OR = {
						coronation_host_east_asian_trigger = yes
						government_has_flag = government_is_steppe_admin
					}
				}
			}
			animation = throne_room_bow_2
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression < 25
			}
			animation = rage
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression >= 75
			}
			animation = throne_room_cheer_1
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression >= 25
			}
			animation = personality_content
		}
		character = scope:audience_1
		camera = camera_event_left_away_3_4
		hide_info = yes
	}
	center_portrait = {
		character = involved_activity.activity_host
		triggered_animation = {
			trigger = {
				OR = {
					scope:activity.var:activity_special_type_progression < 25
					scope:host = {
						coronation_host_east_asian_admin_or_mandala_trigger = yes
					}
					scope:host = {
						government_has_flag = government_is_steppe_admin
					}
				}
			}
			animation = jockey_walk
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression >= 25
			}
			animation = jockey_wave
		}
		camera = camera_event_horse_left_centered
	}
	right_portrait = {
		triggered_animation = {
			trigger = {
				scope:host = {
					OR = {
						coronation_host_east_asian_trigger = yes
						government_has_flag = government_is_steppe_admin
					}
				}
			}
			animation = throne_room_bow_2
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression < 25
			}
			animation = war_defender
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression >= 75
			}
			animation = throne_room_cheer_2
		}
		triggered_animation = {
			trigger = {
				scope:activity.var:activity_special_type_progression >= 25
			}
			animation = throne_room_cheer_1
		}
		character = scope:audience_2
		camera = camera_event_far_right_very_right
		hide_info = yes
	}
	theme = coronation

	#East Asian exterior holy sites
	override_background = {
		trigger = {
			scope:host = {
				OR = {
					coronation_host_east_asian_trigger = yes
					government_has_flag = government_is_steppe_admin
				}
			}
			scope:activity.activity_location ?= {
				OR = {
					culture ?= { has_graphical_east_asia_culture_group_trigger = yes }
					steppe_building_gfx_use_east_asian_trigger = yes
					culture ?= { has_graphical_india_culture_group_trigger = yes }
					steppe_building_gfx_use_indian_trigger = yes
				}
			}
		}
		reference = holy_site_generic
	}
	#Cool gates
	override_background = {
		trigger = {
			location = {
				NOR = {
					has_holding_type = tribal_holding
					has_holding_type = herder_holding
					has_holding_type = nomad_holding
					culture = { has_building_gfx = southeast_asian_building_gfx }
				}
				OR = {
					geographical_region = mediteranean_coast
					geographical_region = world_asia_minor
					culture = { has_graphical_mediterranean_culture_group_trigger = yes }
					steppe_building_gfx_use_mediterranean_trigger = yes
					geographical_region = graphical_mena
					geographical_region = graphical_india
					culture ?= { has_building_gfx = iranian_building_gfx }
					culture ?= { has_building_gfx = indian_building_gfx }
					AND = {
				 		geographical_region = world_europe_west_iberia
				 		faith ?= { religion = religion:islam_religion }
				 	}
				 	steppe_building_gfx_use_indian_trigger = yes
				 	AND = {
							steppe_building_gfx_use_mena_trigger = yes
						NOT = {
							root = { government_has_flag = government_is_tribal }
							geographical_region = world_steppe
						}
					}
				}
			}
		}
		reference = ep3_city_gate
	}
	#Nomadic market doesn't look great - and east asian admins should use courtyard
	override_background = {
		trigger = {
			OR = {
				location.county.holder = {
					OR = {
						government_has_flag = government_is_nomadic
						government_has_flag = government_is_herder
					}
				}
				scope:host = {
					OR = {
						coronation_host_east_asian_trigger = yes
						government_has_flag = government_is_steppe_admin
					}
				}
			}
		}
		reference = courtyard
	}
	#Put some SEA in there
	override_background = {
		trigger = {
			location.culture = { has_building_gfx = southeast_asian_building_gfx }
		}
		reference = tgp_village_sea
	}
	override_background = {
		reference = market
	}
	override_effect_2d = {
		trigger = {
			scope:activity.var:activity_special_type_progression < 25
			exists = scope:rain_day
		}
		reference = rain
	}

	immediate = {
		# For MP
		coronation_busy_effect = yes
		random_rain_snow_chance_effect = yes
		involved_activity = {
			activity_host = {
				save_scope_as = host
				save_scope_as = value_target
			}
			activity_location = { save_scope_as = location }
			#Guards for orderly east asian ceremonies in the palace
			if = {
				limit = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
				create_character = {
					template = mercenary
					location = scope:location
					culture = scope:host.culture
					faith = scope:host.faith
					gender_female_chance = scope_value_target_soldier_female_chance
					save_scope_as = audience_1
				}
				create_character = {
					template = mercenary
					location = scope:location
					culture = scope:host.culture
					faith = scope:host.faith
					gender_female_chance = scope_value_target_soldier_female_chance
					save_scope_as = audience_2
				}
			}
			else = {
				create_character = {
					template = generic_peasant_character_no_rags
					location = scope:location
					culture = scope:location.culture
					faith = scope:location.faith
					save_scope_as = audience_1
				}
				create_character = {
					template = generic_peasant_character_no_rags
					location = scope:location
					culture = scope:location.culture
					faith = scope:location.faith
					save_scope_as = audience_2
				}
			}
			
		}
		play_coronation_ceremony_music_effect = yes
		scope:host = {
			if = {
				limit = {
					root = { is_ai = no }
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:host }
					OR = {
						has_trait = conqueror
						has_trait = greatest_of_khans
						has_lifestyle = martial_lifestyle
					}
				}
				add_character_flag = {
					flag = need_military_outfit
					days = 30
				}
			}
		}
		if = {
			limit = {
				this = scope:host
			}
			coronation_ceremony_magnificence_effect = yes
		}
		if = {
			limit = {
				this = scope:host
			}
			scope:activity = {
				coronation_update_supporters_detractors_effect = yes
			}
		}
	}
	#normal host entrance
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:host = {
								OR = {
									coronation_host_east_asian_trigger = yes
									government_has_flag = government_is_steppe_admin
								}
							}
							scope:activity.var:activity_special_type_progression < 25
						}
						desc = coronation_events.0205.a_low_magnificence_east_admin
					}
					triggered_desc = {
						trigger = {
							OR = {
								scope:activity.var:activity_special_type_progression < 25
								AND = {
									scope:activity.var:activity_special_type_progression < 	75
									OR = {
										has_trait = shy
										has_trait = paranoid
										has_trait = craven
									}
								}
							}
						}
						desc = coronation_events.0205.a_low_magnificence
					}
					triggered_desc = {
						trigger = {
							OR = {
								scope:activity.var:activity_special_type_progression >= 75
								has_trait = arrogant
								has_trait = trusting
								has_trait = ambitious
								has_trait = gregarious
								has_trait = trusting
							}
							NOR = {
								has_trait = humble
								has_trait = content
								has_trait = depressed
							}
						}
						desc = coronation_events.0205.a_high_magnificence
					}
					desc = coronation_events.0205.a
				}
			}
		}
		trigger = {
			this = scope:host
			NOR = {
				has_disfiguring_physical_attribute_trigger = yes
				has_trait = infirm
				health <= dying_health
				has_regal_presence_trait_trigger = yes
			}
		}
		coronation_ceremony_county_effect = yes
		if = {
			limit = {
				scope:activity.var:activity_special_type_progression < 25
			}
			stress_impact = {
				craven = minor_stress_impact_gain
				paranoid = minor_stress_impact_gain
				shy = miniscule_stress_impact_gain
			}
		}
	}
	
	#You are physically not great to look at and that kind of ruins the ceremony...
	option = {
		trigger = {
			this = scope:host
			OR = {
				has_disfiguring_physical_attribute_trigger = yes
				has_trait = infirm
				health <= dying_health
			}
		}
		name = coronation_events.0205.b
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							scope:activity = {
								OR = {
									has_activity_option = {
										category = ceremony_size
										option = coronation_large_ceremony
									}
									has_activity_option = {
										category = ceremony_feast_type
										option = ceremony_feast_type_lavish
									}
								}
							}
							has_activity_intent = coronation_impress_attendees
						}
					}
					desc = coronation_events.0205.b_improved
				}
				triggered_desc = {
					trigger = {
						OR = {
							has_trait = infirm
							health <= dying_health
						}
					}
					desc = coronation_events.0205.b_flavor_infirm
				}
			}
		}
		coronation_ceremony_county_effect = yes

		
		if = {
			limit = {
				scope:activity.var:activity_special_type_progression < 25
			}
			stress_impact = {
				base = miniscule_stress_impact_gain
				craven = minor_stress_impact_gain
				paranoid = minor_stress_impact_gain
				shy = miniscule_stress_impact_gain
			}
		}
		else_if = {
			limit = {
				scope:activity.var:activity_special_type_progression < 75
			}
			stress_impact = {
				base = miniscule_stress_impact_gain
			}
		}
	}

	#You are a glorious sight
	option = {
		name = {
			trigger = {
				scope:activity.var:activity_special_type_progression < 25
				scope:host = {
					OR = {
						coronation_host_east_asian_trigger = yes
						government_has_flag = government_is_steppe_admin
					}
				}
			}
			text = coronation_events.0205.c_low_magnificence_east_admin
		}
		name = {
			trigger = {
				scope:activity.var:activity_special_type_progression < 25
				NOT = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
			}
			text = coronation_events.0205.c_low_magnificence
		}
		name = {
			trigger = {
				scope:activity.var:activity_special_type_progression >= 25
			}
			text = coronation_events.0205.c
		}
		trigger = {
			this = scope:host
			has_regal_presence_trait_trigger = yes
			NOR = {
				has_disfiguring_physical_attribute_trigger = yes
				has_trait = infirm
				health <= dying_health
			}
		}
		add_prestige = minor_prestige_gain
		coronation_ceremony_county_effect = yes
		if = {
			limit = {
				scope:activity.var:activity_special_type_progression >= 25
			}
			stress_impact = {
				arrogant = minor_stress_impact_loss
			}
		}
	}

	option = {
		name = coronation_events.0205.d
		trigger = {
			this != scope:host
		}
	}
	
	option = { # Magnificence is disastrous, pay gold to fix it
		name = {
			trigger = {
				scope:host = {
					OR = {
						coronation_host_east_asian_trigger = yes
						government_has_flag = government_is_steppe_admin
					}
				}
			}
			text = coronation_events.0205.e_east_admin
		}
		name = {
			trigger = {
				NOT = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
			}
			text = coronation_events.0205.e
		}
		trigger = {
			this = scope:host
			scope:activity.var:activity_special_type_progression < 25
		}
		flavor = coronation_events.0205.e.tt
		#AI often have worse coronations because they don't save up beforehand
		if = {
			limit = {
				is_ai = no
			}
			remove_short_term_gold = massive_gold_value
		}
		else = {
			remove_short_term_gold = major_gold_value
		}
		
		custom_tooltip = coronation_tt_positive_massive
		scope:activity = { activity_special_type_progression_massive = yes }
		coronation_add_magnificence_log_effect = {
			VALUE = flag:positive_massive
			CHAR = root
		}
		hidden_effect = {
			involved_activity = {
				every_attending_character = {
					limit = { this != root }
					send_interface_toast = {
						title = coronation_events.0205.e.toast
						left_icon = scope:host
						custom_tooltip = coronation_tt_positive_massive # No effect, just the tooltip
					}
				}
			}
		}
		ai_chance = {
			base = 1
			modifier = {
				short_term_gold <= massive_gold_value
				factor = 0
			}
		}
	}
	
	option = { # Magnificence is disastrous, get stressed to try and fix it
		name = {
			trigger = {
				scope:host = {
					OR = {
						coronation_host_east_asian_trigger = yes
						government_has_flag = government_is_steppe_admin
					}
				}
			}
			text = coronation_events.0205.f_east_admin
		}
		name = {
			trigger = {
				NOT = {
					scope:host = {
						OR = {
							coronation_host_east_asian_trigger = yes
							government_has_flag = government_is_steppe_admin
						}
					}
				}
			}
			text = coronation_events.0205.f
		}
		trigger = {
			this = scope:host
			scope:activity.var:activity_special_type_progression < 25
		}
		flavor = coronation_events.0205.f.tt
		duel = {
			skills = { diplomacy learning }
			value = decent_skill_rating
			65 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = coronation_events.0205.f.success
				send_interface_toast = {
					title = coronation_events.0205.f.success
					left_icon = root
					custom_tooltip = coronation_tt_positive_massive
					scope:activity = { activity_special_type_progression_massive = yes }
					coronation_add_magnificence_log_effect = {
						VALUE = flag:positive_massive
						CHAR = root
					}
				}
				hidden_effect = {
					involved_activity = {
						every_attending_character = {
							limit = { this != root }
							send_interface_toast = {
								title = coronation_events.0205.f.toast
								left_icon = scope:host
								custom_tooltip = coronation_tt_positive_massive # No effect, just the tooltip
							}
						}
					}
				}
			}
			35 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = coronation_events.0205.f.failure
				send_interface_toast = {
					title = coronation_events.0205.f.failure
					left_icon = root
					add_prestige = minor_prestige_loss
				}
			}
		}
		if = {
			limit = { is_ai = no }
			stress_impact = {
				base = massive_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				base = major_stress_impact_gain
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				OR = {
					diplomacy >= high_skill_rating
					learning >= high_skill_rating
				}
				add = 1
			}
			modifier = {
				OR = {
					ai_energy >= high_positive_ai_value
					ai_sociability >= high_positive_ai_value
					AND = {
						ai_energy >= low_positive_ai_value
						ai_sociability >= low_positive_ai_value
					}
				}
				add = 0.1
			}
			modifier = {
				has_a_bad_stress_coping_trait_trigger = no
				stress_level = 0
				NOR = {
					diplomacy < low_skill_rating
					learning < low_skill_rating
				}
				add = 0.25
			}
			modifier = {
				stress <= 15
				has_a_bad_stress_coping_trait_trigger = no
				stress_level = 0
				NOR = {
					diplomacy <= low_skill_rating
					learning <= low_skill_rating
				}
				add = 0.25
			}
		}
	}
	
	after = {
		# For MP
		coronation_ready_effect = yes

		scope:audience_1 = {
			silent_disappearance_effect = yes
		}
		scope:audience_2 = {
			silent_disappearance_effect = yes
		}
		#Ask for clergy/nobility approval event
		if = {
			limit = {
				root = scope:host
				#God-Kings and the Mandate of Heaven-adjacent skip the assents
				scope:host = {
					NOR = {
						government_has_flag = government_is_celestial
						government_has_flag = government_is_meritocratic
						government_has_flag = government_is_mandala
						government_is_japanese_trigger = yes
					}
				}
			}
			trigger_event = {
				id = coronation_events.6120
				days = 3
			}
		}
		#God-Kings and the Mandate of Heaven-adjacent skip the assents - Host
		else_if = {
			limit = {
				root = scope:host
				scope:host = {
					coronation_host_east_asian_admin_or_mandala_trigger = yes
				}
			}
			#artifact blessing
			trigger_event = {
				id = coronation_events.6110
				days = 12
			}
		}
		#God-Kings and the Mandate of Heaven-adjacent skip the assents - Guest
		else_if = {
			limit = {
				scope:host = {
					OR = {
						government_has_flag = government_is_celestial
						government_has_flag = government_is_meritocratic
						government_has_flag = government_is_mandala
						government_is_japanese_trigger = yes
					}
				}
			}
			#Anointment event
			trigger_event = {
				id = coronation_events.6130
				days = 9
			}
		}
		#Guest
		else = {
			trigger_event = {
				id = coronation_events.6123
				days = 6
			}
		}
	}
}

# Start of Feast Phase
coronation_events.0210 = {
	type = activity_event
	title = coronation_events.0210.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity.activity_host = root
				}
				desc = coronation_events.0210.desc.host
			}
			triggered_desc = {
				trigger = {
					scope:activity.activity_host != root
				}
				desc = coronation_events.0210.desc.guest
			}
		}
	}
	left_portrait = {
		character = scope:attendee
		triggered_animation = {
			trigger = {
				drinks_alcohol_trigger = yes
			}
			animation = drink_goblet
		}
		triggered_animation = {
			trigger = {
				NOR = {
					AND = {
						is_ai = no
						is_in_guest_subset = { name = detractor }
					}
					involved_activity = {
						is_target_in_variable_list = {
							name = major_detractor
							target = scope:attendee
						}
					}
					has_activity_intent = coronation_disrupt_loyalists
				}
			}
			animation = personality_content
		}
		animation = eyeroll
		camera = camera_event_left_to_the_left
	}
	center_portrait = {
		character = scope:activity.activity_host
		animation = toast_goblet
		camera = camera_event_center_pointing_slighty_left
	}
	right_portrait = {
		character = scope:musician
		animation = instrument_active
		camera = camera_event_far_right_very_right
		hide_info = yes
	}
	theme = coronation
	override_background = {
		reference = feast
	}

	immediate = {
		# For MP
		coronation_busy_effect = yes
		involved_activity = {
			activity_host = { save_scope_as = host }
			if = {
				limit = {
					NOT = { root = scope:host }
				}
				root = { save_scope_as = attendee }
			}
			else = {
				random_attending_character = {
					limit = {
						NOR = {
							this = scope:host
							is_courtier_of = scope:host
						}
					}
					save_scope_as = attendee
				}
			}
		}
		create_character = {
			template = bard_template
			dynasty = none
			location = root.location
			gender_female_chance = root_faith_dominant_gender_female_chance
			save_scope_as = musician
		}
		if = {
			limit = {
				this = scope:host
			}
			scope:activity = {
				coronation_update_supporters_detractors_effect = yes
			}
		}
	}

	option = {
		name = coronation_events.0210.a
		trigger = {
			scope:activity.activity_host = root
		}
		stress_impact = {
			base = miniscule_stress_impact_loss
			gluttonous = minor_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
		}
	}

	option = {
		name = coronation_events.0210.b
		trigger = {
			scope:activity.activity_host != root
		}
		stress_impact = {
			gluttonous = minor_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
		}
	}

	after = {
		# For MP
		coronation_ready_effect = yes
		scope:musician = {
			silent_disappearance_effect = yes
		}
	}
}

scripted_effect coronation_events_0300_theocratic_candidate_effect = {
	
}

# Choosing an officiator
coronation_events.0300 = {
	type = activity_event
	title = coronation_events.0300.t
	desc = coronation_events.0300.desc
	left_portrait = {
		character = scope:animation_1
		animation = personality_zealous
	}
	center_portrait = {
		character = scope:animation_3
		animation = wedding_priest
	}
	right_portrait = {
		character = scope:animation_2
		animation = chaplain
	}
	theme = coronation_activity

	trigger = {
		NOT = {
			involved_activity = {
				has_variable = officiator
				var:officiator ?= {
					is_alive = yes
					involved_activity ?= root.involved_activity
				}
			}
		}
		OR = {
			cp:councillor_court_chaplain.involved_activity ?= involved_activity
			involved_activity = {
				any_attending_character = {
					government_has_flag = government_is_theocracy
				}
			}
			#Can be forcibly added to activity
			cp:councillor_court_chaplain = {
				coronation_events_0200_available_chaplain_trigger = yes
			}
		}
	}

	immediate = {
		# For MP
		coronation_busy_effect = yes

		if = {
			limit = {
				OR = {
					cp:councillor_court_chaplain.involved_activity ?= involved_activity
					cp:councillor_court_chaplain = {
						coronation_events_0200_available_chaplain_trigger = yes
					}
				}
			}
			cp:councillor_court_chaplain = {
				save_scope_as = chaplain
				save_scope_as = animation_1
			}
			#Forcibly add to activity if they ain't there
			if = {
				limit = {
					NOT = {
						exists = cp:councillor_court_chaplain.involved_activity
						cp:councillor_court_chaplain.involved_activity = involved_activity	
					}
				}
				hidden_effect = {
					cp:councillor_court_chaplain = {
						set_location = root.location
						add_to_activity_without_travel = root.involved_activity
					}
				}
			}
		}
		
		involved_activity = {
			ordered_attending_character = {
				limit = {
					faith = root.faith
					NOT = { scope:chaplain ?= this }
					government_has_flag = government_is_theocracy
				}
				save_scope_as = alternative_1
				if = {
					limit = {
						NOT = { exists = scope:animation_1 }
					}
					save_scope_as = animation_1
				}
				else = {
					save_scope_as = animation_2
				}
			}
			ordered_attending_character = {
				limit = {
					faith = root.faith
					NOR = { scope:alternative_1 ?= this scope:chaplain ?= this}
					government_has_flag = government_is_theocracy
				}
				save_scope_as = alternative_2
				if = {
					limit = {
						NOT = { exists = scope:animation_1 }
					}
					save_scope_as = animation_1
				}
				else = {
					save_scope_as = animation_3
				}
			}
		}
	}

	# Court Chaplain
	option = {
		name = coronation_events.0300.a
		trigger = {
			exists = scope:chaplain
		}
		involved_activity = {
			set_variable = {
				name = officiator
				value = scope:chaplain
			}
		}
		scope:chaplain = {
			if = {
				limit = {
					this = faith.religious_head
				}
				root = { add_piety = medium_piety_gain }
			}
			add_opinion = {
				target = root
				opinion = 20
				modifier = pleased_opinion
			}
			if = {
				limit = {
					root = { highest_held_title_tier >= tier_empire }
				}
				add_piety = major_piety_gain
				add_prestige = major_prestige_gain
			}
			else = {
				add_piety = medium_piety_gain
				add_prestige = medium_prestige_gain
			}
		}
		
		custom_tooltip = coronation_events_0300_a_tooltip

		ai_chance = {
			base = 100
			modifier = {
				add = 100
				scope:chaplain = {
					is_vassal_of = root
				}
			}
		}
	}

	# Relevant character - 1
	option = {
		name = coronation_events.0300.b
		trigger = {
			exists = scope:alternative_1
		}
		involved_activity = {
			set_variable = {
				name = officiator
				value = scope:alternative_1
			}
		}
		scope:alternative_1 = {
			if = {
				limit = {
					this = faith.religious_head
				}
				root = { add_piety = medium_piety_gain }
			}
			add_opinion = {
				target = root
				opinion = 20
				modifier = pleased_opinion
			}
			if = {
				limit = {
					root = { highest_held_title_tier >= tier_empire }
				}
				add_piety = major_piety_gain
				add_prestige = major_prestige_gain
			}
			else = {
				add_piety = medium_piety_gain
				add_prestige = medium_prestige_gain
			}
		}

		custom_tooltip = coronation_events_0300_b_tooltip

		ai_chance = {
			base = 10
			modifier = {
				add = 20
				scope:alternative_1 = {
					is_vassal_of = root
				}
			}
		}
	}

	# Relevant character - 2
	option = {
		name = coronation_events.0300.c
		trigger = {
			exists = scope:alternative_2
		}
		involved_activity = {
			set_variable = {
				name = officiator
				value = scope:alternative_2
			}
		}
		scope:alternative_2 = {
			if = {
				limit = {
					this = faith.religious_head
				}
				root = { add_piety = medium_piety_gain }
			}
			add_opinion = {
				target = root
				opinion = 20
				modifier = pleased_opinion
			}
			if = {
				limit = {
					root = { highest_held_title_tier >= tier_empire }
				}
				add_piety = major_piety_gain
				add_prestige = major_prestige_gain
			}
			else = {
				add_piety = medium_piety_gain
				add_prestige = medium_prestige_gain
			}
		}

		custom_tooltip = coronation_events_0300_c_tooltip

		ai_chance = {
			base = 10
			modifier = {
				add = 20
				scope:alternative_2 = {
					is_vassal_of = root
				}
			}
		}
	}

	# Myself
	option = {
		name = coronation_events.0300.d

		custom_tooltip = coronation_events_0300_d_tooltip
		#No effect if you are head of faith
		if = {
			limit = {
				NAND = {
					exists = faith.religious_head
					this = faith.religious_head
				}
			}
			if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = coronation_type_anointment
						}
					}
				}
				custom_tooltip = coronation_events_0300_d_tooltip_effect_hof
			}
			else = {
				custom_tooltip = coronation_events_0300_d_tooltip_effect
			}
		}
		

		ai_chance = {
			base = 0
			modifier = {
				has_trait = cynical
				add = 20
			}
			modifier = {
				has_trait = ambitious
				add = 20
			}
			modifier = {
				has_trait = paranoid
				add = 20
			}
			modifier = {
				has_trait = arrogant
				add = 20
			}
			modifier = {
				culture = { has_cultural_pillar = heritage_iberian }
				scope:chaplain ?= {
					opinion = {
						target = root
						value >= 0
					}
				}
				add = 200
			}
		}
	}

	after = {
		# For MP
		coronation_ready_effect = yes

		involved_activity = {
			var:officiator ?=  {
				add_character_flag = {
					flag = coronation_officiator
					years = 2
				} 
			}
		}
	}
}

#Death of the Officiator
coronation_events.0301 = {
	type = activity_event
    title = coronation_events.0301.t

	desc = coronation_events.0301.desc

	theme = coronation_activity

	left_portrait = {
		character = root
		animation = personality_zealous
	}

	center_portrait = {
		character = scope:first_candidate
		animation = wedding_priest
	}
	right_portrait = {
		trigger = {
			exists = scope:second_candidate
		}
		character = scope:second_candidate
		animation = prayer
	}

	lower_left_portrait = {
		character = scope:dead_officiator
	}

	immediate = {
		# For MP
		coronation_busy_effect = yes

		scope:activity = {
			var:officiator ?= {
				save_scope_as = dead_officiator
			}
		}

		if = {
			limit = {
				cp:councillor_court_chaplain ?= {
					NOT = { this = scope:dead_officiator }
				}
			}
			cp:councillor_court_chaplain = {
				save_scope_as = first_candidate
			}
		}
		else = {
			create_character = {
				template = virtuous_priest_character_template
				location = scope:activity.activity_location
				culture = scope:activity.activity_location.culture
				faith = root.faith
				save_scope_as = first_candidate
			}
		}

		scope:first_candidate = {
			if = {
				limit = {
					NOT = { location = scope:activity.activity_location }
				}
				set_location = scope:activity.activity_location
			}
			if = {
				limit = {
					NOT = { involved_activity = root.involved_activity }
				}
				add_to_activity = root.involved_activity
			}
		}
		if = {
			limit = {
				faith.religious_head = { #when in Rome
					location.county = root.location.county
					NOT = {
						this = scope:first_candidate
					}		
				}
				
			}
			faith.religious_head = {
				save_scope_as = second_candidate
			}
		}
		else = {
			involved_activity = {
				ordered_attending_character = {
					order_by = piety_level
					limit = {
						faith = root.faith
						government_has_flag = government_is_theocracy
						NOT = { this = scope:dead_officiator this = scope:first_candidate }
					}
					save_scope_as = second_candidate
				}
			}
		}
		save_scope_as = new_officiator #error suppresion
	}

	option = {
		name = coronation_events.0301.a

		custom_tooltip = coronation_events.0301.a.tooltip

		trigger = {
			trigger_if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = coronation_type_anointment
						}
					}
					is_ai = no
				}
				piety_level >= 4
			}
			NAND = {
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = coronation_type_anointment
					}
				}
				scope:second_candidate ?= root.faith.religious_head
			}
		}

		show_as_unavailable = {
			NAND = {
				scope:activity = {
					has_activity_option = {
						category = special_type
						option = coronation_type_anointment
					}
				}
				scope:second_candidate ?= root.faith.religious_head
			}
		}

		scope:first_candidate = {
			add_character_flag = {
				flag = coronation_officiator
				years = 2
			} 
		}
		involved_activity = {
			set_variable = {
				name = officiator
				value = scope:first_candidate
			}
		}
		
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = coronation_events.0301.b

		trigger = {
			exists = scope:second_candidate
			trigger_if = {
				limit = {
					scope:activity = {
						has_activity_option = {
							category = special_type
							option = coronation_type_anointment
						}
					}
					NOT = {
						scope:second_candidate = root.faith.religious_head #Whomst to prevent a new pope from blessing you
					}
					
				}
				scope:second_candidate.piety_level >= 4	
			}	
		}

		show_as_unavailable = {
			exists = scope:second_candidate
		}

		custom_tooltip = coronation_events.0301.b.tooltip

		scope:second_candidate = {
			add_character_flag = {
				flag = coronation_officiator
				years = 2
			} 
		}
		involved_activity = {
			set_variable = {
				name = officiator
				value = scope:second_candidate
			}
		}
	}

	option = {
		name = coronation_events.0301.c

		trigger = {
			has_ce1_dlc_trigger = yes		
		}
		custom_tooltip = coronation_events.0301.c.tooltip
		custom_tooltip = coronation_events.0301.c.tooltip_second
		custom_tooltip = coronation_events.0301.c.tooltip_third
		
		set_variable = {
			name = dead_officiator_funeral
			value = scope:dead_officiator
		}


		ai_chance = {
			base = 0
		}

		add_character_flag = {
			flag = cancelled_coronation
			years = 1
		}
	}

	option = {
		name = coronation_events.0301.d

		custom_tooltip = coronation_events.0301.d.tooltip

		trigger = {
			scope:activity = {
				has_activity_option = {
					category = special_type
					option = coronation_type_anointment
				}
			}
			piety_level <= 3
			is_ai = no
			NOT = {
				scope:second_candidate ?= root.faith.religious_head
			}
		}

		add_piety_level = -1
		custom_tooltip = coronation_tt_negative_major
		scope:activity = { activity_special_type_progression_negative_major = yes }
		scope:first_candidate = {
			add_character_flag = {
				flag = coronation_officiator
				years = 2
			} 
		}
		involved_activity = {
			set_variable = {
				name = officiator
				value = scope:first_candidate
			}
		}
	}

	option = {
		name = coronation_events.0301.e

		custom_tooltip = coronation_events.0301.e.tooltip
		custom_tooltip = coronation_events.0301.e.tooltip_second

		trigger = {
			scope:activity = {
				has_activity_option = {
					category = special_type
					option = coronation_type_anointment
				}
			}
			is_ai = no
			has_ce1_dlc_trigger = no
			piety_level <= 3
		}

		add_character_flag = {
			flag = cancelled_coronation
			years = 1
		}
	}


	after = {
		# For MP
		coronation_ready_effect = yes

		scope:first_candidate = {
			if = {
				limit = {
					NOR = {
						has_character_flag = coronation_officiator
						root.cp:councillor_court_chaplain = this
					}
				}
				silent_disappearance_effect = yes
			}
		}
	}

}

coronation_events.0302 = {
	scope = none
	hidden = yes

	immediate = {
		if = {
			limit = {
				has_ach_dlc_trigger = yes
			}
			every_kingdom = {
				holder ?= {
					if = {
						limit = {
							is_independent_ruler = yes
							is_alive = yes 
							coronation_trigger = yes
							NOT = {
								coronation_has_proper_artifact_trigger = yes
							}
						}
						coronation_create_artifact_game_start_effect = yes
					}	
				}
			}
			every_empire = {
				holder ?= {
					if = {
						limit = {
							is_independent_ruler = yes
							is_alive = yes 
							coronation_trigger = yes
							NOT = {
								coronation_has_proper_artifact_trigger = yes
							}
						}
						coronation_create_artifact_game_start_effect = yes
					}	
				}
			}
			every_hegemony = {
				holder ?= {
					if = {
						limit = {
							is_independent_ruler = yes
							is_alive = yes 
							coronation_trigger = yes
							NOT = {
								coronation_has_proper_artifact_trigger = yes
							}
						}
						coronation_create_artifact_game_start_effect = yes
					}	
				}
			}
		}
	}
}


coronation_events.0310 = {
	type = activity_event
    title = coronation_events.0310.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:high_magnificence
				}
				desc = coronation_events.0310.desc.high_magnificence
			}
			triggered_desc = {
				trigger = {
					exists = scope:mid_magnificence
				}
				desc = coronation_events.0310.desc.mid_magnificence
			}
			triggered_desc = {
				trigger = {
					exists = scope:low_magnificence
				}
				desc = coronation_events.0310.desc.low_magnificence
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:impress_attendees
				}
				desc = coronation_events.0310.desc.impress_attendees
			}
			triggered_desc = {
				trigger = {
					exists = scope:weaken_detractors
				}
				desc = coronation_events.0310.desc.weaken_detractors
			}
			triggered_desc = {
				trigger = {
					exists = scope:embrace_supporters
				}
				desc = coronation_events.0310.desc.embrace_supporters
			}
			triggered_desc = {
				trigger = {
					exists = scope:exalt_crown
				}
				desc = coronation_events.0310.desc.exalt_crown
			}
		}
	}

	theme = coronation_activity

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
			}
			animation = worry
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
			}
			animation = ecstasy
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
			}
			animation = personality_cynical
		}
		camera = camera_event_very_left
	}

	override_effect_2d = {
		trigger = {
			exists = scope:high_magnificence
		}
		reference = legend_glow
	}

	override_effect_2d = {
		trigger = {
			exists = scope:low_magnificence
		}
		reference = flies
	}

	center_portrait = {
		character = scope:first_char
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:impress_attendees
			}
			animation = dismissal
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:impress_attendees
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:impress_attendees
			}
			animation = drink
		}
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:weaken_detractors
			}
			animation = eyeroll
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:weaken_detractors
			}
			animation = fear
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:weaken_detractors
			}
			animation = shock
		}
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:embrace_supporters
			}
			animation = eyeroll
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:embrace_supporters
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:embrace_supporters
			}
			animation = personality_content
		}
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:exalt_crown
			}
			animation = eyeroll
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:exalt_crown
			}
			animation = hero_flex
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:exalt_crown
			}
			animation = personality_rational
		}
		camera = camera_event_center_pointing_left
	}
	right_portrait = {
		character = scope:second_char
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:impress_attendees
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:impress_attendees
			}
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:impress_attendees
			}
			animation = reception_bride_right
		}
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:weaken_detractors
			}
			animation = map_disgust
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:weaken_detractors
			}
			animation = personality_coward
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:weaken_detractors
			}
			animation = sadness
		}
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:embrace_supporters
			}
			animation = schadenfreude
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:embrace_supporters
			}
			animation = obsequious_bow
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:embrace_supporters
			}
			animation = interested
		}
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
				exists = scope:exalt_crown
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
				exists = scope:exalt_crown
			}
			animation = personality_greedy
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
				exists = scope:exalt_crown
			}
			animation = spymaster
		}
	}

	trigger = {
		trigger_if = {
			limit = {
				has_activity_intent = coronation_impress_attendees
			}
			var:host_intent_start ?= flag:coronation_impress_attendees
		}
		trigger_else_if = {
			limit = {
				has_activity_intent = coronation_weaken_detractors
			}
			var:host_intent_start ?= flag:coronation_weaken_detractors
		}
		trigger_else_if = {
			limit = {
				has_activity_intent = coronation_embrace_supporters
			}
			var:host_intent_start ?= flag:coronation_embrace_supporters
		}
		trigger_else_if = {
			limit = {
				has_activity_intent = coronation_exalt_crown
			}
			var:host_intent_start ?= flag:coronation_exalt_crown
		}
		trigger_else = {
			always = no
		}
	}

	on_trigger_fail = {
		trigger_event = coronation_events.0311
	}

	immediate = {
		add_character_flag = no_coronation_events
		# For MP
		coronation_busy_effect = yes

		save_scope_as = host
		custom_tooltip = happened_because_intent_tt
		if = {
			limit = {
				scope:activity.var:activity_special_type_progression < 25
			}
			save_scope_as = low_magnificence
			set_variable = {
				name = reward_tier
				value = 1
			}
		}
		else_if = {
			limit = {
				scope:activity.var:activity_special_type_progression >= 75
			}
			save_scope_as = high_magnificence
			set_variable = {
				name = reward_tier
				value = 3
			}
		}
		else = {
			save_scope_as = mid_magnificence
			set_variable = {
				name = reward_tier
				value = 2
			}
		}
		set_variable = {
			name = reward_tier_plus_one
			value = {
				add = var:reward_tier
				add = 1
			}
		}
		set_variable = {
			name = reward_tier_plus_two
			value = {
				add = var:reward_tier
				add = 2
			}
		}
		switch = {
			trigger = has_activity_intent
			coronation_impress_attendees = {
				save_scope_as = impress_attendees
				scope:activity = {
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_supporter
									target = prev
								}
							}
						}
						save_scope_as = first_char
					}
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_detractor
									target = prev
								}
							}
						}
						save_scope_as = second_char
					}
				}
			}
			coronation_weaken_detractors = {
				save_scope_as = weaken_detractors
				scope:activity = {
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_detractor
									target = prev
								}
							}
						}
						save_scope_as = first_char
					}
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_detractor
									target = prev
								}
							}
							NOT = {
								this = scope:first_char
							}
						}
						save_scope_as = second_char
					}
				}
			}
			coronation_embrace_supporters = {
				save_scope_as = embrace_supporters
				scope:activity = {
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_supporter
									target = prev
								}
							}
						}
						save_scope_as = first_char
					}
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_supporter
									target = prev
								}
							}
							NOT = {
								this = scope:first_char
							}
						}
						save_scope_as = second_char
					}
				}			
			}
			coronation_exalt_crown = {
				save_scope_as = exalt_crown
				scope:activity = {
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_detractor
									target = prev
								}
							}
						}
						save_scope_as = first_char
					}
					random_attending_character = {
						limit = {
							scope:activity = {
								is_target_in_variable_list = {
									name = major_supporter
									target = prev
								}
							}
							NOT = {
								this = scope:first_char
							}
						}
						save_scope_as = second_char
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:first_char }
			}
			scope:activity = {
				random_attending_character = {
					limit = {
						exists = scope:second_char
						NOR = {
							this = scope:second_char
							this = root
						}
					}
					save_scope_as = first_char
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:second_char }
			}
			scope:activity = {
				random_attending_character = {
					limit = {
						exists = scope:first_char
						NOR = {
							this = scope:first_char
							this = root
						}
					}
					save_scope_as = second_char
				}
			}
		}
	}

	option = { #impress_attendees cultural acceptance
		name = coronation_events.0310.a
		trigger = {
			exists = scope:impress_attendees
			scope:activity = {
				any_attending_character = { count >= 3 culture != scope:activity.activity_host.culture }
			}
		}	
		custom_tooltip = coronation_events.0310.a.reward.tooltip
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.a.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.a.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.a.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:cultural_acceptance
		}
	}

	option = { #impress_attendees opinion gain
		name = coronation_events.0310.b
		trigger = {
			exists = scope:impress_attendees
		}
		custom_tooltip = coronation_events.0310.b.reward.tooltip
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.b.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.b.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.b.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:opinion_gain
		}
	}

	option = { #impress_attendees legitimacy and prestige gain
		name = coronation_events.0310.c
		custom_tooltip = coronation_events.0310.c.reward.tooltip
		trigger = {
			exists = scope:impress_attendees
		}	
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = intrigue
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.c.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.c.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.c.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:legitimacy_and_prestige_gain
		}
	}

	option = { #weaken_detractors prevents detractors from joining new factions for x years
		name = coronation_events.0310.d
		trigger = {
			exists = scope:weaken_detractors
		}	
		custom_tooltip = coronation_events.0310.d.reward.tooltip
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = diplomacy
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.d.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.d.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.d.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:prevent_faction_joining
		}
	}

	option = { #weaken_detractors detractors more easily imprisoned
		name = coronation_events.0310.e
		custom_tooltip = coronation_events.0310.e.reward.tooltip
		trigger = {
			exists = scope:weaken_detractors
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = intrigue
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.e.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.e.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.e.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:easier_imprisonment
		}

	}

	option = { #weaken_detractors stress 'em
		name = coronation_events.0310.f
		custom_tooltip = coronation_events.0310.f.reward.tooltip
		trigger = {
			exists = scope:weaken_detractors
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = learning
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.f.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.f.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.f.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:stress
		}
	}

	option = { #embrace_supporters supporter vassals get modifier that makes them better at being councillors
		name = coronation_events.0310.g
		custom_tooltip = coronation_events.0310.g.reward.tooltip
		trigger = {
			exists = scope:embrace_supporters
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = learning
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.g.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.g.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.g.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:better_councillors
		}
	}

	option = { #embrace_supporters supporter vassals get development boost to their realms
		name = coronation_events.0310.h
		custom_tooltip = coronation_events.0310.h.reward.tooltip
		trigger = {
			exists = scope:embrace_supporters
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.h.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.h.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.h.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:vassal_development_boost
		}
	}

	option = { #embrace_supporters supporter vassals get defensive bonuses to their realms
		name = coronation_events.0310.i
		custom_tooltip = coronation_events.0310.i.reward.tooltip
		trigger = {
			exists = scope:embrace_supporters
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = martial
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.i.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.i.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.i.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:vassal_defensive_boost
		}
	}

	option = { #exalt_crown artifact boost
		name = coronation_events.0310.j
		custom_tooltip = coronation_events.0310.j.reward.tooltip
		trigger = {
			exists = scope:exalt_crown
			any_character_artifact = {
				count >= 3
				exists = this
			}
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = learning
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.j.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.j.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.j.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:artifact_boost
		}
	}

	option = { #exalt_crown domain boost development
		name = coronation_events.0310.k
		custom_tooltip = coronation_events.0310.k.reward.tooltip
		trigger = {
			exists = scope:exalt_crown
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = stewardship
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.k.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.k.success
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.k.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:host_development_boost
		}
	}

	option = { #exalt_crown domain boost defense
		name = coronation_events.0310.l
		custom_tooltip = coronation_host_defense_boost_reward_tt
		trigger = {
			exists = scope:exalt_crown
		}
		switch = {
			trigger = exists
			scope:low_magnificence = { custom_tooltip = coronation_events.0310.low_magnificence }
			scope:mid_magnificence = { custom_tooltip = coronation_events.0310.mid_magnificence }
			scope:high_magnificence = { custom_tooltip = coronation_events.0310.high_magnificence }
		}
		duel = {
			skill = martial
			value = high_skill_rating
			10 = { #two tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
					min = -49
				}
				change_variable = {
					name = reward_tier
					add = 2
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.l.crit_success
				}
			}
			60 = { #one tier improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.l.success
				}
				change_variable = {
					name = reward_tier
					add = 1
				}
			}
			30 = { #no improvement
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = coronation_events.0310.intent_toast
					left_icon = root
					custom_tooltip = coronation_events.0310.l.no_improvement
				}
			}
		}
		set_variable = {
			name = host_had_intent_reward
			value = flag:host_defense_boost
		}
	}

	after = {
		# For MP
		coronation_ready_effect = yes

		trigger_event = coronation_events.0311
	}
}

coronation_events.0311 = { #Host ending event
	type = activity_event
    title = coronation_events.0311.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					trigger_if = {
						limit = {
							OR = {
								exists = scope:high_magnificence
								exists = scope:low_magnificence
								exists = scope:mid_magnificence
							}
						}
						exists = scope:high_magnificence
					}
					trigger_else = {
						scope:activity.var:activity_special_type_progression >= 75
					}
				}
				desc = coronation_events.0311.desc.high_magnificence
			}
			triggered_desc = {
				trigger = {
					trigger_if = {
						limit = {
							OR = {
								exists = scope:high_magnificence
								exists = scope:low_magnificence
								exists = scope:mid_magnificence
							}
						}
						exists = scope:mid_magnificence
					}
					trigger_else = {
						scope:activity.var:activity_special_type_progression >= 25
					}
				}
				desc = coronation_events.0311.desc.mid_magnificence
			}
			desc = coronation_events.0311.desc.low_magnificence
		}
	}

	theme = coronation_activity

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
			}
			animation = shame
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
			}
			animation = personality_honorable
		}
	}

	override_effect_2d = {
		trigger = {
			exists = scope:high_magnificence
		}
		reference = legend_glow
	}

	override_effect_2d = {
		trigger = {
			exists = scope:low_magnificence
		}
		reference = flies
	}

	immediate = {
		coronation_completed_log_entry_effect = yes
		if = {
			limit = {
				has_variable = host_intent_start
			}
			scope:activity = { ach_host_intent_rewards_effect = yes }
		}
	}

	option = {
		name = coronation_events.0311.a	
	}
	after = {
		#We trigger the guest goodbye event here to make sure the guest player is notified about the host intent reward
		scope:activity = {
			every_attending_character = {
				limit = {
					is_ai = no
					NOT = { this = scope:activity.activity_host }
				}
				trigger_event = coronation_events.0312
			}
		}
		#reward variable cleanup
		remove_variable = reward_tier
		remove_variable = reward_tier_plus_one
		remove_variable = reward_tier_plus_two
		remove_variable = host_had_intent_reward
	}
}

coronation_events.0312 = { #Guest ending event
	type = activity_event
    title = coronation_events.0312.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:high_magnificence
				}
				desc = coronation_events.0310.desc.high_magnificence
			}
			triggered_desc = {
				trigger = {
					exists = scope:mid_magnificence
				}
				desc = coronation_events.0310.desc.mid_magnificence
			}
			triggered_desc = {
				trigger = {
					exists = scope:low_magnificence
				}
				desc = coronation_events.0310.desc.low_magnificence
			}
		}
	}

	theme = coronation_activity

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
			}
			animation = eyeroll
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
			}
			animation = personality_forgiving
		}
	}

	right_portrait = {
		character = scope:activity.activity_host
		triggered_animation = {
			trigger = {
				exists = scope:low_magnificence
			}
			animation = shame
		}
		triggered_animation = {
			trigger = {
				exists = scope:high_magnificence
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				exists = scope:mid_magnificence
			}
			animation = frontend_right_idle
		}
	}

	override_effect_2d = {
		trigger = {
			scope:province = {
				exists = scope:high_magnificence
			}
		}
		reference = legend_glow
	}

	override_effect_2d = {
		trigger = {
			scope:province = {
				exists = scope:low_magnificence
			}
		}
		reference = flies
	}

	immediate = {
		create_character_memory = {
			type = witnessed_a_coronation_memory
			participants = {
				host = scope:activity.activity_host
			}
		}
		if = {
			limit = {
				OR = {
					scope:first_reward_target ?= this
					scope:second_reward_target ?= this
					scope:third_reward_target ?= this
					scope:fourth_reward_target ?= this
					scope:fifth_reward_target ?= this
					scope:first_reward_target ?= culture
					scope:second_reward_target ?= culture
					scope:third_reward_target ?= culture
					scope:fourth_reward_target ?= culture
					scope:fifth_reward_target ?= culture
				}
			}
			switch = {
				trigger = scope:activity.activity_host.var:host_had_intent_reward
				flag:cultural_acceptance = {
					custom_tooltip = coronation_events.0312.cultural_acceptance
				}
				flag:better_councillors = {
					custom_tooltip = coronation_events.0312.better_councillors
				}
				flag:vassal_development_boost = {
					custom_tooltip = coronation_events.0312.vassal_development_boost
				}
				flag:vassal_defensive_boost = {
					custom_tooltip = coronation_events.0312.vassal_defensive_boost
				}
			}
		}
		show_as_tooltip = {
			coronation_completed_log_entry_effect = yes
			ach_host_intent_rewards_tooltip_effect = yes
		}
	}

	option = {
		name = coronation_events.0312.a
	}
}

coronation_events.0400 = { # HoF supports anointment
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = coronation_events.0400.desc
	sender = scope:recipient

	option = {
		name = coronation_events.0400.a
		if = {
			limit = {
				is_ai = yes
			}
			#AI should attempt to hold their coronation RIGHT NOW
			ai_attempt_to_host_activity = activity_coronation
			debug_log = "AI attempted to host a coronation"
			debug_log_scopes = yes
		}
	}
}
