# Written by Flavio

namespace = HF

# Explain coronation preparation, ask whom to ask to be crowned by
character_event = {
	id = HF.20200
	title = EVTTITLE20200
	desc = EVTDESCHF20200
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # prepare_coronation_ceremony, HF_coronation_decisions.txt

	option = { # Ask to be crowned by the Pope
		name = EVTOPTAHF20200

		trigger = {
			NOT = { trait = excommunicated }

			rightful_religious_head_scope = {
				controls_religion = yes # No antipopes!
				block_general_event_trigger = no
			}
		}

		religion_head = {
			show_scope_change = no

			letter_event = {
				id = HF.20201
				days = 30
				random = 5
				tooltip = EVTTOOLTIPHF20201
			}
		}

		ai_chance = {
			factor = 70

			mult_modifier = {
				factor = 0.7
				real_tier = EMPEROR
			}

			mult_modifier = {
				factor = 0.1

				religion_head = {
					opinion = {
						who = ROOT
						value < -80
					}
				}
			}

			mult_modifier = {
				factor = 0.25

				religion_head = {
					opinion = {
						who = ROOT
						value < -60
					}
				}
			}

			mult_modifier = {
				factor = 0.5

				religion_head = {
					opinion = {
						who = ROOT
						value < -40
					}
				}
			}

			mult_modifier = {
				factor = 0.7

				religion_head = {
					opinion = {
						who = ROOT
						value < -20
					}
				}
			}

			mult_modifier = {
				factor = 0.8

				religion_head = {
					opinion = {
						who = ROOT
						value < 0
					}
				}
			}

			mult_modifier = {
				factor = 1.25

				religion_head = {
					opinion = {
						who = ROOT
						value >= 20
					}
				}
			}

			mult_modifier = {
				factor = 1.25

				religion_head = {
					opinion = {
						who = ROOT
						value >= 40
					}
				}
			}

			mult_modifier = {
				factor = 1.5

				religion_head = {
					opinion = {
						who = ROOT
						value >= 60
					}
				}
			}

			mult_modifier = {
				factor = 1.75

				religion_head = {
					opinion = {
						who = ROOT
						value >= 80
					}
				}
			}

			mult_modifier = {
				factor = 2

				religion_head = {
					opinion = {
						who = ROOT
						value >= 100
					}
				}
			}
		}
	}

	option = { # Invested by powerful Bishop
		name = EVTOPTBHF20200

		trigger = {
			NOT = { trait = excommunicated }

			OR = {
				lower_real_tier_than = EMPEROR
				has_law = investiture_law_1
			}

			any_realm_lord = {
				is_theocracy = yes
				religion = ROOT
				controls_religion = no
				block_general_event_trigger = no

				OR = {
					higher_real_tier_than = BARON
					is_cardinal = yes
					is_antipope = yes
				}
			}
		}

		custom_tooltip = { text = EVTTOOLTIPBHF20200 }

		if = { # If Pope is available but he's snubbed by an Emperor, he'll get mad
			limit = {
				real_tier = EMPEROR

				rightful_religious_head_scope = {
					controls_religion = yes
				}
			}

			custom_tooltip = {
				text = scorned_the_pope

				religion_head = {
					opinion = {
						name = opinion_offended
						who = ROOT
						years = 30
					}
				}
			}
		}

		random_realm_lord = {
			show_scope_change = no

			limit = {
				is_theocracy = yes
				religion = ROOT
				controls_religion = no
				block_general_event_trigger = no

				OR = {
					higher_real_tier_than = BARON
					is_cardinal = yes
					is_antipope = yes
				}
			}

			# First search for a possible antipopes.
			preferred_limit = { is_antipope = yes }
			preferred_limit = { is_cardinal = yes }

			letter_event = {
				id = HF.20201
				days = 30
				random = 5
			}
		}

		ai_chance = { factor = 30 }
	}

	option = { # Invested by random priest
		name = EVTOPTCHF20200

		trigger = {
			OR = {
				lower_real_tier_than = EMPEROR
				has_law = investiture_law_1
			}

			any_realm_lord = {
				is_theocracy = yes
				religion = ROOT
				lower_real_tier_than = COUNT
				controls_religion = no
				is_cardinal = no
				is_antipope = no
				block_general_event_trigger = no
			}
		}

		custom_tooltip = { text = EVTTOOLTIPCHF20200 }

		if = { # Emperors not crowned by Pope or Antipope receive an additional penalty
			limit = { real_tier = EMPEROR }

			prestige = -300
			piety = -75
		}

		if = { # If Pope is available but he's snubbed by an Emperor, he'll get mad.
			limit = {
				real_tier = EMPEROR

				rightful_religious_head_scope = {
					controls_religion = yes
				}
			}

			custom_tooltip = {
				text = scorned_the_pope

				religion_head = {
					opinion = {
						name = opinion_offended
						who = ROOT
						years = 30
					}
				}
			}
		}

		if = { # If powerful theocrats are available but player picks random priest, the other theocrats will be mad.
			limit = {
				OR = {
					lower_real_tier_than = EMPEROR
					has_law = investiture_law_1
				}

				NOT = { trait = excommunicated }

				any_realm_lord = {
					is_theocracy = yes
					religion = ROOT
					controls_religion = no
					block_general_event_trigger = no

					OR = {
						higher_real_tier_than = BARON
						is_cardinal = yes
						is_antipope = yes
					}
				}
			}

			custom_tooltip = {
				text = scorned_powerful_theocrats

				any_realm_lord = {
					limit = {
						is_theocracy = yes
						religion = ROOT
						controls_religion = no
						block_general_event_trigger = no

						OR = {
							higher_real_tier_than = BARON
							is_cardinal = yes
							is_antipope = yes
						}
					}

					opinion = {
						name = opinion_offended
						years = 10
						who = ROOT
					}
				}
			}
		}

		random_realm_lord = {
			show_scope_change = no

			limit = {
				is_theocracy = yes
				religion = ROOT
				lower_real_tier_than = COUNT
				controls_religion = no
				is_cardinal = no
				is_antipope = no
				block_general_event_trigger = no
			}

			preferred_limit = {
				opinion = {
					who = ROOT
					value >= 50
				}
			}

			preferred_limit = {
				opinion = {
					who = ROOT
					value >= 20
				}
			}

			letter_event = {
				id = HF.20201
				days = 30
				random = 5
			}
		}

		ai_chance = {
			factor = 10

			mult_modifier = {
				factor = 1.5
				trait = slothful
			}

			mult_modifier = {
				factor = 1.5
				trait = shy
			}

			mult_modifier = {
				factor = 1.25
				trait = content
			}

			mult_modifier = {
				factor = 0.7
				trait = proud
			}

			mult_modifier = {
				factor = 0.7
				trait = ambitious
			}

			mult_modifier = {
				factor = 0.7
				tier = EMPEROR
			}

			mult_modifier = {
				factor = 0.5
				has_landed_title = e_hre
			}
		}
	}

	option = { # Changed your mind, not yet
		name = EVTOPTDHF20200

		custom_tooltip = {
			text = coronation_canceled
			remove_character_modifier = coronation_request_cooldown
		}

		ai_chance = { factor = 0 }
	}
}

# Scary giant letter event determining what is the priest going to ask to the Ruler/Emperor in exchange for the Coronation
letter_event = {
	id = HF.20201
	desc = EVTDESCHFA20201
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		FROM = {
			religion = ROOT

			OR = {
				religion = catholic
				religion = fraticelli
			}
		}
	}

	option = { # For random priest
		name = EVTOPTAHF20201

		trigger = {
			lower_real_tier_than = COUNT
			controls_religion = no
			is_cardinal = no
			is_antipope = no
		}

		random_list = {
			50 = {
				trigger = {
					opinion = {
						who = FROM
						value > -100
					}
				}

				mult_modifier = {
					factor = 0.5

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 0.6

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 0.7

					opinion = {
						who = FROM
						value < -40

					}
				}

				mult_modifier = {
					factor = 0.8

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value >= 20
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value >= 40
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value >= 60
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value >= 80
					}
				}

				mult_modifier = {
					factor = 2

					opinion = {
						who = FROM
						value >= 100
					}
				}

				FROM = {
					letter_event = { id = HF.20202 } # Priest asks for nothing, proceed with coronation
				}
			}

			50 = {
				mult_modifier = {
					factor = 1.5
					trait = greedy
				}

				mult_modifier = {
					factor = 1.25
					trait = slothful
				}

				mult_modifier = {
					factor = 1.25
					trait = envious
				}

				mult_modifier = {
					factor = 1.5
					trait = bad_priest_christian
				}

				FROM = {
					letter_event = { id = HF.20203 } # Priest asks for small donation
				}
			}
		}
	}

	option = { # For powerful theocrat
		name = EVTOPTBHF20201

		trigger = {
			controls_religion = no

			OR = {
				higher_real_tier_than = BARON
				is_cardinal = yes
				is_antipope = yes
			}
		}

		random_list = {
			40 = {
				trigger = {
					opinion = {
						who = FROM
						value > -100
					}
				}

				mult_modifier = {
					factor = 1.5
					trait = greedy
				}

				mult_modifier = {
					factor = 1.25
					trait = slothful
				}

				mult_modifier = {
					factor = 1.25
					trait = envious
				}

				mult_modifier = {
					factor = 0.5

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 0.6

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 0.7

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 0.8

					opinion = {
						who = FROM
						value < -20
					}
				}

				FROM = {
					letter_event = { id = HF.20204 } # Donate money to me
				}
			}

			40 = {
				trigger = {
					NOT = { trait = cynical }

					opinion = {
						who = FROM
						value > -100
					}
				}

				mult_modifier = {
					factor = 1.5
					trait = charitable
				}

				mult_modifier = {
					factor = 1.5
					trait = zealous
				}

				mult_modifier = {
					factor = 0.5
					trait = bad_priest_christian
				}

				mult_modifier = { # Antipope more likely to ask for little
					factor = 1.5

					has_opinion_modifier = {
						name = opinion_controlled_antipope
						who = FROM
					}
				}

				mult_modifier = { # Supported Cardinal more likely to ask for little
					factor = 1.5

					has_opinion_modifier = {
						name = opinion_supported_cardinal
						who = FROM
					}
				}

				mult_modifier = {
					factor = 0.5

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 0.6

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 0.7

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 0.8

					opinion = {
						who = FROM
						value < -20
					}
				}

				FROM = {
					letter_event = { id = HF.20205 } # Donate money to the Pope (including antipopes)
				}
			}

			20 = {
				trigger = {
					FROM = {
						any_child = {
							is_adult = yes
							vassal_of = PREV
							is_married = no
							is_ruler = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 3

							is_adult = yes
							vassal_of = PREV
							is_married = no
							is_ruler = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 4

							is_adult = yes
							vassal_of = PREV
							is_married = no
							is_ruler = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 5

							is_adult = yes
							vassal_of = PREV
							is_married = no
							is_ruler = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 6

							is_adult = yes
							vassal_of = PREV
							is_married = no
							is_ruler = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 0.25
					trait = bad_priest_christian
				}

				mult_modifier = {
					factor = 0.25
					trait = cynical
				}

				FROM = {
					letter_event = { id = HF.20206 } # Send child to monastery/nunnery
				}
			}

			10 = {
				trigger = {
					# Check if holy orders exist
					OR = {
						is_title_active = d_knights_templar
						is_title_active = d_teutonic_order
						is_title_active = k_teutonic_state
						is_title_active = d_knights_hospitaller
						is_title_active = d_knights_santiago
						is_title_active = d_knights_calatrava
					}

					FROM = {
						any_child = {
							is_adult = yes
							vassal_of = PREV
							is_ruler = no
							is_female = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 3

							is_adult = yes
							vassal_of = PREV
							is_ruler = no
							is_female = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 4

							is_adult = yes
							vassal_of = PREV
							is_ruler = no
							is_female = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 5

							is_adult = yes
							vassal_of = PREV
							is_ruler = no
							is_female = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_child = {
							count >= 6

							is_adult = yes
							vassal_of = PREV
							is_ruler = no
							is_female = no
							prisoner = no
							is_incapable = no
							is_primary_heir = no

							NOR = {
								trait = monk
								trait = nun
							}
						}
					}
				}

				mult_modifier = {
					factor = 0.25
					trait = bad_priest_christian
				}

				mult_modifier = {
					factor = 0.25
					trait = cynical
				}

				FROM = {
					letter_event = { id = HF.20207 } # Send son to holy order
				}
			}

			10 = {
				trigger = {
					FROM = { war = no }

					OR = {
						trait = bad_priest_christian
						trait = hedonist
					}

					NOR = {
						trait = celibate
						trait = temperate
					}
				}

				mult_modifier = {
					factor = 1.5
					trait = gluttonous
				}

				mult_modifier = {
					factor = 1.5
					trait = drunkard
				}

				mult_modifier = {
					factor = 1.5
					trait = greedy
				}

				mult_modifier = {
					factor = 1.25
					trait = cynical
				}

				mult_modifier = {
					factor = 0.5
					trait = zealous
				}

				FROM = {
					letter_event = { id = HF.20208 } # Wishes to have orgy for himself
				}
			}

			10 = {
				trigger = {
					FROM = {
						any_demesne_title = {
							can_be_given_away = yes
							tier = COUNT
							is_feudal = yes
							location = { is_capital = no }
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					FROM = {
						any_demesne_title = {
							count >= 2

							can_be_given_away = yes
							tier = COUNT
							is_feudal = yes
							location = { is_capital = no }
						}
					}
				}

				mult_modifier = {
					factor = 2

					FROM = {
						any_demesne_title = {
							count >= 5

							can_be_given_away = yes
							tier = COUNT
							is_feudal = yes
							location = { is_capital = no }
						}
					}
				}

				FROM = {
					letter_event = { id = HF.20209 } # Wishes for another County
				}
			}

			10 = {
				trigger = {
					is_monastic_member_trigger = yes
					FROM = { is_monastic_member_trigger = no }
				}

				mult_modifier = {
					factor = 1.5
					trait = zealous
				}

				mult_modifier = {
					factor = 1.5
					trait = scholar
				}

				mult_modifier = {
					factor = 1.5
					trait = socializer
				}

				mult_modifier = {
					factor = 1.25
					trait = gregarious
				}

				FROM = {
					letter_event = { id = HF.20210 } # Join my Monastic Order
				}
			}

			10 = {
				trigger = {
					FROM = {
						any_artifact = {
							has_artifact_flag = christian

							NOR = {
								has_artifact_flag = rare
								has_artifact_flag = very_rare
								has_artifact_flag = unique # Won't give the holiest ones away
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5
					trait = zealous
				}

				mult_modifier = {
					factor = 1.5
					trait = scholar
				}

				mult_modifier = {
					factor = 1.5
					trait = theologian
				}

				mult_modifier = {
					factor = 1.5
					trait = mystic
				}

				FROM = {
					letter_event = { id = HF.20240 } # Give me a relic
				}
			}
		}
	}

	option = { # For the Pope
		name = EVTOPTCHF20201

		trigger = { controls_religion = yes }

		random_list = {
			80 = {
				trigger = { vassal_of = FROM }

				modifier = {
					factor = 2

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result.
					has_opinion_modifier = {
						name = opinion_requested_independence
						who = FROM
					}
				}

				mult_modifier = {
					factor = 1.5
					religion = catholic
				}

				mult_modifier = {
					factor = 2

					opinion = {
						who = FROM
						value <= -100
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 0.9

					opinion = {
						who = FROM
						value >= 20
					}
				}

				mult_modifier = {
					factor = 0.8

					opinion = {
						who = FROM
						value >= 40
					}
				}

				mult_modifier = {
					factor = 0.7

					opinion = {
						who = FROM
						value >= 60
					}
				}

				mult_modifier = {
					factor = 0.6

					opinion = {
						who = FROM
						value >= 80
					}
				}

				mult_modifier = {
					factor = 0.5

					opinion = {
						who = FROM
						value >= 100
					}
				}

				FROM = {
					letter_event = { id = HF.20211 } # I want to be independent
				}
			}

			20 = {
				trigger = {
					opinion = {
						who = FROM
						value > -100
					}
				}

				mult_modifier = {
					factor = 0.5
					vassal_of = FROM
				}

				mult_modifier = { # Supported Pope more likely to ask for little
					factor = 1.5

					has_opinion_modifier = {
						name = opinion_supported_pope
						who = FROM
					}
				}

				mult_modifier = {
					factor = 0.2

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 0.3

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 0.4

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 0.5

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 0.6

					opinion = {
						who = FROM
						value < 0
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value >= 20
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value >= 40
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value >= 60
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value >= 80
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value >= 100
					}
				}

				mult_modifier = {
					factor = 1.5
					trait = greedy
				}

				mult_modifier = {
					factor = 0.5
					trait = zealous
				}

				FROM = {
					letter_event = { id = HF.20212 } # I want gold
				}
			}

			30 = {
				trigger = {
					FROM = { has_law = investiture_law_1 }
				}

				mult_modifier = {
					factor = 2

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_papal_investiture
						who = FROM
					}
				}

				mult_modifier = {
					factor = 1.5
					FROM = { real_tier = EMPEROR }
				}

				mult_modifier = {
					factor = 1.75
					FROM = { has_landed_title = e_hre }
				}

				mult_modifier = {
					factor = 1.5
					real_tier = KING
				}

				mult_modifier = {
					factor = 1.5
					trait = envious
				}

				mult_modifier = {
					factor = 1.75
					independent = yes
				}

				FROM = {
					letter_event = { id = HF.20213 } # I want you to enact Papal Investiture
				}
			}

			30 = {
				trigger = {
					FROM = { war = no } # Wartime coronation

					# Check if any excommunicated rulers are available in the first place
					any_independent_ruler = {
						excommunicated_for = ROOT
						is_within_diplo_range = FROM
						in_revolt = no

						NOR = {
							is_liege_of = FROM
							is_allied_with = ROOT

							any_current_enemy = {
								NOT = { religion_group = ROOT }
							}
						}
					}
				}

				mult_modifier = {
					factor = 2.5

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_excommunication_war
						who = FROM
					}
				}

				mult_modifier = {
					factor = 0.35
					FROM = { lower_real_tier_than = EMPEROR }
				}

				mult_modifier = {
					factor = 0.25
					FROM = { realm_size < 40 }
				}

				mult_modifier = {
					factor = 0.5
					FROM = { realm_size < 80 }
				}

				mult_modifier = {
					factor = 0.75
					FROM = { realm_size < 150 }
				}

				FROM = {
					letter_event = { id = HF.20214 } # I want you to depose excommunicated ruler
				}
			}

			30 = {
				trigger = {
					FROM = { war = no } # Wartime coronation

					# Check if any antipopes are available in the first place
					any_independent_ruler = {
						OR = {
							religion = catholic
							religion = fraticelli
						}

						rightful_religious_head_scope = {
							controls_religion = no
							is_vassal_or_below_of = PREV
						}

						religion = FROM
						is_within_diplo_range = FROM
						NOT = { is_allied_with = ROOT }
					}
				}

				mult_modifier = {
					factor = 2.5

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_antipope_war
						who = FROM
					}
				}

				mult_modifier = {
					factor = 0.35
					FROM = { lower_tier_than = EMPEROR }
				}

				mult_modifier = {
					factor = 0.25
					FROM = { realm_size < 40 }
				}

				mult_modifier = {
					factor = 0.5
					FROM = { realm_size < 80 }
				}

				mult_modifier = {
					factor = 0.75
					FROM = { realm_size < 150 }
				}

				FROM = {
					letter_event = { id = HF.20215 } # I want you to depose an antipope
				}
			}

			20 = {
				trigger = {
					FROM = {
						real_tier = EMPEROR

						# Check if you or your vassals hold lands within Italy
						any_realm_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								de_jure_vassal_or_below = d_latium
								de_jure_vassal_or_below = d_spoleto
								de_jure_vassal_or_below = d_ancona
								de_jure_vassal_or_below = d_ferrara
								de_jure_vassal_or_below = d_benevento
							}

							trigger_if = {
								limit = { holder = PREV }
								can_be_given_away = yes
							}
						}
					}

					# If Papacy already controls historical provinces, it won't be interested in gaining even more land in Italy
					NAND = {
						completely_controls = d_latium
						completely_controls = d_spoleto
						completely_controls = d_ancona
						completely_controls = d_ferrara
						completely_controls = d_benevento
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value <= -100
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value < 0
					}
				}

				mult_modifier = {
					factor = 0.85

					opinion = {
						who = FROM
						value >= 20
					}
				}

				mult_modifier = {
					factor = 0.85

					opinion = {
						who = FROM
						value >= 40
					}
				}

				mult_modifier = {
					factor = 0.75

					opinion = {
						who = FROM
						value >= 60
					}
				}

				mult_modifier = {
					factor = 0.5

					opinion = {
						who = FROM
						value >= 80
					}
				}

				mult_modifier = {
					factor = 0.9
					FROM = { trait = zealous }
				}

				mult_modifier = {
					factor = 0.9
					FROM = { trait = baptized_by_pope }
				}

				mult_modifier = {
					factor = 0.9
					FROM = { piety >= 100 }
				}

				mult_modifier = {
					factor = 0.9
					FROM = { piety >= 150 }
				}

				mult_modifier = {
					factor = 0.8
					FROM = { piety >= 250 }
				}

				mult_modifier = {
					factor = 0.7
					FROM = { has_law = investiture_law_0 }
				}

				# Historical Pope will want historical Vatican lands
				mult_modifier = {
					factor = 1.5

					religion = catholic

					c_roma = {
						OR = {
							holder_scope = {
								character = FROM
								is_vassal_or_below_of = FROM
							}

							any_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = FROM
										is_vassal_or_below_of = FROM
									}
								}
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.5

					religion = catholic

					d_latium = {
						OR = {
							holder_scope = {
								character = FROM
								is_vassal_or_below_of = FROM
							}

							any_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = FROM
										is_vassal_or_below_of = FROM
									}
								}
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.45

					religion = catholic

					d_spoleto = {
						OR = {
							holder_scope = {
								character = FROM
								is_vassal_or_below_of = FROM
							}

							any_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = FROM
										is_vassal_or_below_of = FROM
									}
								}
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.35

					religion = catholic

					d_ancona = {
						OR = {
							holder_scope = {
								character = FROM
								is_vassal_or_below_of = FROM
							}

							any_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = FROM
										is_vassal_or_below_of = FROM
									}
								}
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.25

					religion = catholic

					d_ferrara = {
						OR = {
							holder_scope = {
								character = FROM
								is_vassal_or_below_of = FROM
							}

							any_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = FROM
										is_vassal_or_below_of = FROM
									}
								}
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.15

					religion = catholic

					d_benevento = {
						OR = {
							holder_scope = {
								character = FROM
								is_vassal_or_below_of = FROM
							}

							any_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = FROM
										is_vassal_or_below_of = FROM
									}
								}
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.25

					religion = catholic
					FROM = { has_landed_title = e_hre }
				}

				mult_modifier = {
					factor = 2.5

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_papal_land
						who = FROM
					}
				}

				if = {
					limit = {
						OR = {
							trait = lunatic
							trait = possessed
						}
					}

					FROM = {
						letter_event = { id = HF.20225 } # Calls for Donation of Constantine
					}
				}
				else = {
					FROM = {
						letter_event = { id = HF.20216 } # I want a piece of Italy
					}
				}
			}

			10 = {
				trigger = {
					FROM = { war = no } # Wartime coronation
					religion = catholic # Catholics only

					OR = {
						trait = bad_priest_christian
						trait = hedonist
					}

					NOR = {
						trait = celibate
						trait = temperate
					}
				}

				mult_modifier = {
					factor = 1.5
					trait = gluttonous
				}

				mult_modifier = {
					factor = 1.5
					trait = drunkard
				}

				mult_modifier = {
					factor = 1.5
					trait = greedy
				}

				mult_modifier = {
					factor = 1.25
					trait = cynical
				}

				mult_modifier = {
					factor = 0.5
					trait = zealous
				}

				FROM = {
					letter_event = { id = HF.20235 } # Wishes to have orgy
				}
			}

			5 = {
				trigger = {
					# Check if holy orders exist
					OR = {
						is_title_active = d_knights_templar
						is_title_active = d_teutonic_order
						is_title_active = k_teutonic_state
						is_title_active = d_knights_hospitaller
						is_title_active = d_knights_santiago
						is_title_active = d_knights_calatrava
					}

					FROM = {
						higher_real_tier_than = KING

						# Check if you have enough land to give
						any_demesne_title = {
							can_be_given_away = yes
							tier = DUKE
						}
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value <= -100
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 10

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_land_holyorder
						who = FROM
					}
				}

				FROM = {
					letter_event = { id = HF.20217 } # Give lands to the Holy Orders
				}
			}

			15 = {
				trigger = {
					FROM = {
						any_artifact = {
							has_artifact_flag = christian

							OR = {
								has_artifact_flag = rare
								has_artifact_flag = very_rare
							}
						}
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value <= -100
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 10

					# Opinion modifier keeps track of the Pope's previous decision,
					# should the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_artifact
						who = FROM
					}
				}

				FROM = {
					letter_event = { id = HF.20241 } # Give me a relic
				}
			}

			30 = {
				trigger = {
					FROM = {
						higher_real_tier_than = KING
						war = no
					}

					# If Papacy already controls historical provinces, it won't be interested in gaining even more land in Italy
					NAND = {
						completely_controls = d_latium
						completely_controls = d_spoleto
						completely_controls = d_ancona
						completely_controls = d_ferrara
						completely_controls = d_benevento
					}

					# Check if a potential target exists (either an infidel, a heretic, or a hated Christian ruler).
					any_independent_ruler = {
						is_within_diplo_range = FROM

						NOR = {
							is_allied_with = ROOT
							reverse_has_truce = FROM
						}

						OR = {
							excommunicated_for = ROOT
							NOT = { religion = ROOT }

							reverse_opinion = {
								who = ROOT
								value < -50
							}
						}

						any_realm_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								de_jure_vassal_or_below = d_latium
								de_jure_vassal_or_below = d_spoleto
								de_jure_vassal_or_below = d_ancona
								de_jure_vassal_or_below = d_ferrara
								de_jure_vassal_or_below = d_benevento
							}
						}
					}
				}

				mult_modifier = {
					factor = 0.25
					FROM = { realm_size < 40 }
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value <= -100
					}
				}

				mult_modifier = {
					factor = 1.75

					opinion = {
						who = FROM
						value < -80
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -60
					}
				}

				mult_modifier = {
					factor = 1.5

					opinion = {
						who = FROM
						value < -40
					}
				}

				mult_modifier = {
					factor = 1.25

					opinion = {
						who = FROM
						value < -20
					}
				}

				mult_modifier = {
					factor = 2
					religion = catholic
					FROM = { has_landed_title = e_hre }
				}

				mult_modifier = {
					factor = 2.5

					# Opinion modifier keeps track of the Pope's previous decision, should
					# the player deny his first request and then attempt to ask again immediately after for a different result
					has_opinion_modifier = {
						name = opinion_requested_pepin_war
						who = FROM
					}
				}

				# If Papacy doesn't control any of its historical provinces,
				# this request will be its highest priority (as long as potential enemies are available and it's an imperial coronation)
				mult_modifier = {
					factor = 10

					NAND = {
						completely_controls = d_latium
						completely_controls = d_spoleto
						completely_controls = d_ancona
						completely_controls = d_ferrara
						completely_controls = d_benevento
					}
				}

				FROM = {
					letter_event = { id = HF.20221 } # Holy war Italy for me
				}
			}
		}
	}
}

# Ruler: Random Priest doesn't ask for anything, proceed with the coronation immediately
letter_event = {
	id = HF.20202
	desc = EVTDESCHFA20202
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20202

		set_character_flag = flag_crowned_by_priest

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20202

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Random Priest asks for small donation
letter_event = {
	id = HF.20203
	desc = EVTDESCHFA20203
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20203

		set_character_flag = flag_crowned_by_priest

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		transfer_scaled_wealth = {
			to = FROM
			value = 1
			min = 50
			max = 50
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20203

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop asks for donation to himself
letter_event = {
	id = HF.20204
	desc = EVTDESCHFA20204
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20204

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		transfer_scaled_wealth = {
			to = FROM
			value = 1
			min = 150
			max = 150
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20204

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop asks for donation to the Pope
letter_event = {
	id = HF.20205
	desc = EVTDESCHFA20205
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20205

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		rightful_religious_head_scope = {
			show_scope_change = no

			transfer_scaled_wealth = {
				from = ROOT
				value = 1
				min = 100
				max = 100
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20205

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop asks for child to become monk/nun
letter_event = {
	id = HF.20206
	desc = EVTDESCHFA20206
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		random_child = {
			limit = {
				is_adult = yes
				vassal_of = ROOT
				is_married = no
				is_ruler = no
				prisoner = no
				is_incapable = no
				is_primary_heir = no

				NOR = {
					trait = monk
					trait = nun
				}
			}

			save_event_target_as = son_monk_candidate
		}
	}

	option = {
		name = EVTOPTAHF20206

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		character_event = { id = HF.20300 } # Go to budget event

		religion_head = {
			show_scope_change = no

			event_target:son_monk_candidate = {
				show_scope_change = no

				set_christian_ascetic_effect = yes
				move_character = PREV
			}
		}
	}

	option = { # End of the line
		name = EVTOPTBHF20206

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop asks for son to join holy order
letter_event = {
	id = HF.20207
	desc = EVTDESCHFA20207
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		random_child = {
			limit = {
				is_adult = yes
				vassal_of = ROOT
				is_married = no
				is_ruler = no
				is_female = no
				prisoner = no
				is_incapable = no
				is_primary_heir = no

				NOR = {
					trait = monk
					trait = nun
				}
			}

			save_event_target_as = son_holyorder_candidate
		}

		random_playable_ruler = {
			limit = {
				religion = ROOT

				OR = {
					has_landed_title = d_knights_templar
					has_landed_title = d_teutonic_order
					has_landed_title = k_teutonic_state
					has_landed_title = d_knights_hospitaller
					has_landed_title = d_knights_santiago
					has_landed_title = d_knights_calatrava
				}
			}

			save_event_target_as = son_holyorder_host
		}
	}


	option = {
		name = EVTOPTAHF20207

		set_character_flag = flag_crowned_by_bishop
		show_portrait = event_target:son_holyorder_host

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		event_target:son_holyorder_host = {
			show_scope_change = no

			event_target:son_holyorder_candidate = {
				show_scope_change = no

				add_trait = celibate
				move_character = PREV
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20207

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop wants an orgy
letter_event = {
	id = HF.20208
	desc = EVTDESCHFA20208
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	# Fund AND join the Orgy
	option = {
		name = EVTOPTZHF20208

		custom_tooltip = { text = join_bishop_orgy }

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 2
			}

			hidden_effect = {
				tiered_piety_negative_effect = yes
			}
		}

		transfer_scaled_wealth = {
			to = FROM
			value = 0.5
			min = 50
			max = 200
		}

		tiered_piety_negative_effect = yes

		character_event = { id = HF.20236 } # Small event chain
		# character_event = { id = HF.20300 } # Go to budget event

		ai_chance = { factor = 10 }
	}

	option = {
		name = EVTOPTAHF20208

		trigger = {
			NOT = { trait = hedonist }
		}

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 2
			}

			hidden_effect = {
				tiered_piety_negative_effect = yes
			}
		}

		transfer_scaled_wealth = {
			to = FROM
			value = 0.5
			min = 50
			max = 200
		}

		piety = -50

		character_event = { id = HF.20300 } # Go to budget event

		ai_chance = { factor = 100 }
	}

	option = { # End of the line
		name = EVTOPTBHF20208

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop wants a county
letter_event = {
	id = HF.20209
	desc = EVTDESCHFA20209
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20209

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		random_demesne_title = {
			show_scope_change = no

			limit = {
				tier = COUNT
				can_be_given_away = yes
				is_feudal = yes
				location = { is_capital = no }
			}

			grant_title = FROM
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20209

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Bishop wants you to join his monastic order
letter_event = {
	id = HF.20210
	desc = EVTDESCHFA20210
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20210

		set_character_flag = flag_crowned_by_bishop

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			ROOT = {
				show_scope_change = no

				join_prev_monastic_order_society = yes
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20210

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Pope wants to be independent
letter_event = {
	id = HF.20211
	desc = EVTDESCHFA20211
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20211

		custom_tooltip = {
			text = TT_EVTOPTAHF20211
			set_character_flag = flag_crowned_by_pope
		}

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			set_defacto_liege = THIS
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20211

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_independence
			who = FROM
			years = 10
		}

		ai_chance = { factor = 0 }
	}
}

# Ruler: Pope wants gold
letter_event = {
	id = HF.20212
	desc = EVTDESCHFA20212
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20212

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			hidden_effect = {
				opinion = {
					name = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = {
			limit = { real_tier = KING }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 }
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = {
			limit = { real_tier = EMPEROR }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 }
				}
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20212

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Pope wants Papal Investiture
letter_event = {
	id = HF.20213
	desc = EVTDESCHFA20213
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20213

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		primary_title = {
			set_title_flag = non_manual_law_change # No prestige loss
			revoke_law = investiture_law_1
			add_law_w_cooldown = investiture_law_0
			clr_title_flag = non_manual_law_change # No prestige loss
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20213

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player.
		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_requested_papal_investiture
				who = ROOT
				years = 10
			}
		}

		ai_chance = { factor = 0 }
	}
}

# Ruler: Pope wants an Excommunicated Ruler deposed
letter_event = {
	id = HF.20214
	desc = EVTDESCHFA20214
	border = GFX_event_letter_frame_religion

	desc = {
		text = EVTDESCHFA20214
		trigger = {
			event_target:excommunication_war_target = { always = yes }
		}
	}
	desc = { # If no target could be found for whatever reason, default to money donation
		text = EVTDESCHFA20212
		trigger = {
			NOT = { event_target:excommunication_war_target = { always = yes } }
		}
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	# Select potential target so that it appears in the tooltip
	immediate = {
		random_independent_ruler = {
			limit = {
				excommunicated_for = ROOT
				is_within_diplo_range = ROOT
				in_revolt = no

				NOR = {
					is_liege_of = FROM
					is_allied_with = FROM

					any_current_enemy = {
						NOT = { religion_group = ROOT }
					}
				}
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 50 }
				relative_power = { who = ROOT power < 2 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 100 }
				relative_power = { who = ROOT power < 2 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 150 }
				relative_power = { who = ROOT power < 2 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 50 }
				relative_power = { who = ROOT power < 3 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 100 }
				relative_power = { who = ROOT power < 3 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 150 }
				relative_power = { who = ROOT power < 3 }
			}

			preferred_limit = {
				relative_power = { who = ROOT power < 4 }
			}

			save_event_target_as = excommunication_war_target
		}
	}

	option = {
		name = EVTOPTAHF20214

		trigger = { event_target:excommunication_war_target = { always = yes } }

		custom_tooltip = {
			text = tooltip_coronation_depose_excommunicate
			set_character_flag = flag_excommunicated_for_coronation
		}

		event_target:excommunication_war_target = {
			character_event = { id = HF.20218 } # Ping to potential target
		}

		# character_event = { id = HF.20300 } # Go to budget event - # Not this time, it'll be fired on_success of the war
	}

	option = { # End of the line
		name = EVTOPTBHF20214

		trigger = { event_target:excommunication_war_target = { always = yes } }

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_excommunication_war
			who = FROM
			years = 10
		}

		ai_chance = { factor = 0 }
	}

	option = {
		name = EVTOPTAHF20212

		trigger = {
			NOT = { event_target:excommunication_war_target = { always = yes } } # If no target could be found for whatever reason
		}

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			hidden_effect = {
				opinion = {
					name = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = {
			limit = { real_tier = KING }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 }
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = {
			limit = { real_tier = EMPEROR }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 }
				}
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20212

		trigger = {
			NOT = { event_target:excommunication_war_target = { always = yes } } # If no target could be found for whatever reason
		}

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ruler: Pope wants an Antipope deposed
letter_event = {
	id = HF.20215
	border = GFX_event_letter_frame_religion

	desc = {
		text = EVTDESCHFA20215
		trigger = {
			event_target:antipapal_war_target = { always = yes }
		}
	}
	desc = { # If no target could be found for whatever reason, default to money donation
		text = EVTDESCHFA20212
		trigger = {
			NOT = { event_target:antipapal_war_target = { always = yes } }
		}
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		random_independent_ruler = {
			limit = {
				OR = {
					religion = catholic
					religion = fraticelli
				}

				rightful_religious_head_scope = {
					vassal_of = PREV
					is_antipope = yes
				}

				religion = FROM
				is_within_diplo_range = ROOT
				NOT = { is_allied_with = FROM }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 50 }
				relative_power = { who = ROOT power < 2 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 100 }
				relative_power = { who = ROOT power < 2 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 150 }
				relative_power = { who = ROOT power < 2 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 50 }
				relative_power = { who = ROOT power < 3 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 100 }
				relative_power = { who = ROOT power < 3 }
			}

			preferred_limit = {
				distance_from_realm = { who = ROOT value < 150 }
				relative_power = { who = ROOT power < 3 }
			}

			preferred_limit = {
				relative_power = { who = ROOT power < 4 }
			}

			save_event_target_as = antipapal_war_target
		}
	}

	option = {
		name = EVTOPTAHF20215

		trigger = { event_target:antipapal_war_target = { always = yes } }

		custom_tooltip = {
			text = tooltip_coronation_depose_antipope
			set_character_flag = flag_antipope_for_coronation
		}

		event_target:antipapal_war_target = {
			character_event = { id = HF.20218 } # Ping to potential target
		}

		# character_event = { id = HF.20300 } # Go to budget event - # Not this time, it'll be fired on_success of the war
	}

	option = { # End of the line
		name = EVTOPTBHF20215

		trigger = { event_target:antipapal_war_target = { always = yes } }

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_antipope_war
			who = FROM
			years = 10
		}

		ai_chance = { factor = 0 }
	}

	option = {
		name = EVTOPTAHF20212

		trigger = {
			NOT = { event_target:antipapal_war_target = { always = yes } } # In the event of no target being found
		}

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			hidden_effect = {
				opinion = {
					name = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = {
			limit = { real_tier = KING }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 }
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = {
			limit = { real_tier = EMPEROR }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 }
				}
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20212

		trigger = {
			NOT = { event_target:antipapal_war_target = { always = yes } } # In the event of no target being found
		}

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Emperor: Pope wants a piece of Italy.
letter_event = {
	id = HF.20216
	desc = EVTDESCHFA20216
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	option = {
		name = EVTOPTAHF20216

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		character_event = { id = HF.20300 } # Go to budget event

		# First of all, if the Emperor has Rome, it is asked automatically as an additional gift
		c_roma = {
			show_scope_change = no

			if = {
				limit = { holder = ROOT }

				grant_title = FROM

				# Pope vassalizes all vassal titles in the scope
				any_de_jure_vassal = {
					show_scope_change = no

					limit = {
						vassal_of = ROOT
						NOT = { character = ROOT }
					}

					set_defacto_liege = FROM
					character_event = { id = HF.20230 }
				}

				# Pope takes over any titles under the title he's taking over from you
				any_de_jure_vassal_title = {
					show_scope_change = no

					limit = { holder = ROOT }

					grant_title = FROM
				}
			}
		}

		# Secondly, check for all Duchies within the borders of the historical Donation of Pepin (Latium, Spoleto, Ancona, Ferrara, Benevento).
		# If the Emperor owns them directly, the Pope takes the title, if his vassals do, said vassals will become the Papacy's vassals.
		any_title_under = {
			show_scope_change = no

			limit = {
				OR = {
					title = d_latium
					title = d_spoleto
					title = d_ancona
					title = d_ferrara
					title = d_benevento
				}
			}

			if = {
				limit = {
					holder = ROOT
					can_be_given_away = yes
				}

				grant_title = FROM

				any_de_jure_vassal = {
					show_scope_change = no

					limit = {
						vassal_of = ROOT
						NOT = { character = ROOT }
					}

					set_defacto_liege = FROM
					character_event = { id = HF.20230 }
				}

				any_de_jure_vassal_title = {
					show_scope_change = no

					limit = { holder = ROOT }

					grant_title = FROM
				}
			}
			else = {
				holder_scope = {
					show_scope_change = no

					if = {
						limit = {
							vassal_of = ROOT
							lower_real_tier_than = FROM
						}

						set_defacto_liege = FROM
						character_event = { id = HF.20230 }
					}
				}
			}
		}
	}

	option = { # End of the line
		name = EVTOPTBHF20216

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_requested_papal_land
				years = 10
				who = ROOT
			}
		}

		ai_chance = { factor = 0 }
	}
}

# Emperor: Pope wants you to give a Duchy to a Holy Order
letter_event = {
	id = HF.20217
	border = GFX_event_letter_frame_religion

	desc = {
		text = EVTDESCHFA20217
		trigger = { has_landed_title = event_target:scoped_duchy }
	}
	desc = { # If target duchy couldn't be found for whatever reason, default to money donation
		text = EVTDESCHFA20212
		trigger = {
			NOT = { has_landed_title = event_target:scoped_duchy }
		}
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		# Check if there is an available bordering province, in order to limit bordergore
		random_demesne_title = {
			limit = {
				tier = DUKE
				can_be_given_away = yes

				any_direct_de_jure_vassal_title = {
					location = {
						any_neighbor_province = {
							has_owner = yes

							owner = {
								NOR = {
									character = ROOT
									is_vassal_or_below_of = ROOT
								}
							}
						}
					}
				}
			}

			# Try to give them counties as well
			preferred_limit = {
				any_de_jure_vassal_title = {
					holder = ROOT
				}
			}

			save_event_target_as = scoped_duchy
		}

		# Otherwise pick random demesne Duchy
		if = {
			limit = {
				NOT = { event_target:scoped_duchy = { always = yes } }
			}

			random_demesne_title = {
				limit = {
					tier = DUKE
					can_be_given_away = yes
				}

				# Try to give them counties as well
				preferred_limit = {
					any_de_jure_vassal_title = {
						holder = ROOT
					}
				}

				save_event_target_as = scoped_duchy
			}
		}

		random_playable_ruler = {
			limit = {
				religion = ROOT

				OR = {
					has_landed_title = d_knights_templar
					has_landed_title = d_teutonic_order
					has_landed_title = k_teutonic_state
					has_landed_title = d_knights_hospitaller
					has_landed_title = d_knights_santiago
					has_landed_title = d_knights_calatrava
				}
			}

			save_event_target_as = scoped_grandmaster
		}
	}

	option = {
		name = EVTOPTAHF20217

		trigger = { has_landed_title = event_target:scoped_duchy }

		set_character_flag = flag_crowned_by_pope
		show_portrait = event_target:scoped_grandmaster

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		character_event = { id = HF.20300 } # Go to budget event

		# Make sure both targets exist, otherwise randomize
		if = {
			limit = {
				has_landed_title = event_target:scoped_duchy
				event_target:scoped_grandmaster = { is_alive = yes }
			}

			event_target:scoped_duchy = {
				show_scope_change = no

				grant_title = event_target:scoped_grandmaster

				# Transfer vassals under the Duchy
				any_de_jure_vassal = {
					show_scope_change = no

					limit = {
						vassal_of = ROOT
						lower_real_tier_than = event_target:scoped_grandmaster
						NOT = { character = ROOT }
					}

					set_defacto_liege = event_target:scoped_grandmaster
				}

				# Take over dejure titles under the Duchy
				any_de_jure_vassal_title = {
					show_scope_change = no

					limit = { holder = ROOT }

					grant_title = event_target:scoped_grandmaster
				}
			}
		}
		else = {
			# If the player is being sneaky or the Grandmaster dies in the meantime, pick another duchy
			random_playable_ruler = {
				show_scope_change = no

				limit = {
					religion = ROOT

					OR = {
						has_landed_title = d_knights_templar
						has_landed_title = d_teutonic_order
						has_landed_title = k_teutonic_state
						has_landed_title = d_knights_hospitaller
						has_landed_title = d_knights_santiago
						has_landed_title = d_knights_calatrava
					}
				}

				ROOT = {
					show_scope_change = no

					random_demesne_title = {
						show_scope_change = no

						limit = {
							tier = DUKE
							can_be_given_away = yes
						}

						grant_title = PREVPREV

						any_de_jure_vassal = {
							show_scope_change = no

							limit = {
								vassal_of = ROOT
								lower_tier_than = PREVPREVPREV
								NOT = { character = ROOT }
							}

							set_defacto_liege = PREVPREVPREV
						}

						any_de_jure_vassal_title = {
							show_scope_change = no

							limit = { holder = ROOT }

							grant_title = PREVPREVPREV
						}
					}
				}
			}
		}
	}

	option = { # End of the line
		name = EVTOPTBHF20217

		trigger = { has_landed_title = event_target:scoped_duchy }

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_land_holyorder
			who = FROM
			years = 10
		}

		ai_chance = { factor = 0 }
	}

	option = {
		name = EVTOPTAHF20212

		trigger = {
			NOT = { has_landed_title = event_target:scoped_duchy } # If target duchy couldn't be found for whatever reason
		}

		hidden_effect = {
			reverse_opinion = {
				name = opinion_coronation_money_refund
				who = FROM
				years = 100
			}
		}

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = {
			limit = { real_tier = KING }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 }
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = {
			limit = { real_tier = EMPEROR }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 }
				}
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20212

		trigger = {
			NOT = { has_landed_title = event_target:scoped_duchy } # In the event of target being invalidated
		}

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ping to Excommunicated ruler/liege of antipope, prepare for war
character_event = {
	id = HF.20218
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20218
		trigger = {
			FROM = { has_character_flag = flag_excommunicated_for_coronation }
		}
	}
	desc = {
		text = EVTDESCHFB20218
		trigger = {
			FROM = { has_character_flag = flag_antipope_for_coronation }
		}
	}

	is_triggered_only = yes

	immediate = {
		FROM = { character_event = { id = HF.20219 } }
	}

	option = {
		name = EVTOPTAHF20218

		if = {
			limit = { FROM = { has_character_flag = flag_excommunicated_for_coronation } }

			opinion = {
				name = opinion_promised_to_depose_me
				who = FROM
				years = 10
			}

			reverse_opinion = {
				name = opinion_promised_to_depose_him
				who = FROM
				years = 10
			}
		}
		else = {
			opinion = {
				name = opinion_promised_to_depose_myantipope
				who = FROM
				years = 10
			}

			reverse_opinion = {
				name = opinion_promised_to_depose_hisantipope
				who = ROOT
				years = 10
			}
		}
	}
}

# Back to uncrowned Ruler, start the war
character_event = {
	id = HF.20219
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20219
		trigger = { has_character_flag = flag_excommunicated_for_coronation }
	}
	desc = {
		text = EVTDESCHFB20219
		trigger = { has_character_flag = flag_antipope_for_coronation }
	}

	is_triggered_only = yes

	immediate = {
		if = {
			limit = { has_character_flag = flag_excommunicated_for_coronation }

			war = {
				target = FROM
				casus_belli = excommunicated_ruler
			}
		}
		else = {
			war = {
				target = FROM
				casus_belli = depose_antipope
			}
		}
	}

	option = {
		name = EVTOPTAHF20219

		tooltip = {
			if = {
				limit = { has_character_flag = flag_excommunicated_for_coronation }

				reverse_opinion = {
					name = opinion_promised_to_depose_me
					who = FROM
					years = 10
				}

				opinion = {
					name = opinion_promised_to_depose_him
					who = FROM
					years = 10
				}
			}
			else = {
				reverse_opinion = {
					name = opinion_promised_to_depose_myantipope
					who = FROM
					years = 10
				}

				opinion = {
					name = opinion_promised_to_depose_hisantipope
					who = FROM
					years = 10
				}
			}
		}

	}
}

# on_success of Excommunication/Antipope CB: congratulate with ruler, resume the coronation event chain
character_event = {
	id = HF.20220
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20220
		trigger = { has_character_flag = flag_excommunicated_for_coronation }
	}
	desc = {
		text = EVTDESCHFB20220
		trigger = { has_character_flag = flag_antipope_for_coronation }
	}

	trigger = { higher_real_tier_than = DUKE } # In case the first ruler dies or loses his Coronation-worthy tier before the war is won

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20220

		set_character_flag = flag_preparing_coronation # Set it back to avoid the decision from being available again
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		set_character_flag = flag_crowned_by_pope

		religion_head = { # Otherwise the scope would have been lost
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			reverse_opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}
}

# Ruler: Pope wants you to wage Holy War on his behalf
letter_event = {
	id = HF.20221
	border = GFX_event_letter_frame_religion

	desc = {
		text = EVTDESCHFA20221
		trigger = {
			event_target:papal_war_target = { always = yes }
		}
	}
	desc = { # If target could not be found for whatever reason, default to money donation
		text = EVTDESCHFA20212
		trigger = {
			NOT = { event_target:papal_war_target = { always = yes } }
		}
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		if = {
			limit = {
				any_independent_ruler = {
					is_within_diplo_range = ROOT
					NOT = { is_allied_with = FROM }

					OR = {
						NOT = { religion_group = FROM }
						is_heresy_of = FROM

						reverse_opinion = {
							who = FROM
							value < -50
						}
					}

					any_realm_title = {
						OR = {
							title = d_latium
							title = d_spoleto
							title = d_ancona
							title = d_ferrara
							title = d_benevento
							de_jure_vassal_or_below = d_latium
							de_jure_vassal_or_below = d_spoleto
							de_jure_vassal_or_below = d_ancona
							de_jure_vassal_or_below = d_ferrara
							de_jure_vassal_or_below = d_benevento
						}
					}
				}
			}

			random_independent_ruler = {
				limit = {
					is_within_diplo_range = ROOT

					NOR = {
						is_allied_with = FROM
						religion_group = FROM
					}

					any_realm_title = {
						OR = {
							title = d_latium
							title = d_spoleto
							title = d_ancona
							title = d_ferrara
							title = d_benevento
							de_jure_vassal_or_below = d_latium
							de_jure_vassal_or_below = d_spoleto
							de_jure_vassal_or_below = d_ancona
							de_jure_vassal_or_below = d_ferrara
							de_jure_vassal_or_below = d_benevento
						}
					}
				}

				preferred_limit = {
					NOT = { religion_group = FROM }
				}

				preferred_limit = {
					is_heresy_of = FROM
				}

				save_event_target_as = papal_war_target
			}
		}
	}

	option = {
		name = EVTOPTAHF20221

		trigger = { event_target:papal_war_target = { always = yes } }

		custom_tooltip = {
			text = tooltip_coronation_pepin_war
			set_character_flag = flag_pepin_for_coronation
		}

		event_target:papal_war_target = {
			character_event = { id = HF.20222 } # Ping to potential target
		}

		# character_event = { id = HF.20300 } # Go to budget event - # Not this time, it'll be fired on_success of the war
	}

	option = { # End of the line
		name = EVTOPTBHF20221

		trigger = { event_target:papal_war_target = { always = yes } }

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_pepin_war
			who = FROM
			years = 10
		}

		ai_chance = { factor = 0 }
	}

	option = {
		name = EVTOPTAHF20212

		trigger = {
			NOT = { event_target:papal_war_target = { always = yes } } # If no target was found
		}

		opinion = {
			name = opinion_supposed_to_crown
			who = FROM
			months = 1
		}

		set_character_flag = flag_crowned_by_pope

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			hidden_effect = {
				opinion = {
					name = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = {
			limit = { real_tier = KING }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 }
				}
			}
		}

		# Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = {
			limit = { real_tier = EMPEROR }

			if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -75
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < -25
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 0
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 }
				}
			}

			else_if = {
				limit = {
					reverse_opinion = {
						who = FROM
						value < 50
					}
				}

				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 }
				}
			}

			else = {
				if = {
					limit = { piety < 350 }
					transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 }
				}
				else = {
					transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 }
				}
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20212

		trigger = {
			NOT = { event_target:papal_war_target = { always = yes } } # If no target was found
		}

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Ping to target owner of papal land, prepare for war
character_event = {
	id = HF.20222
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20222
		trigger = {
			NOT = { religion = FROMFROM }
		}
	}
	desc = {
		text = EVTDESCHFB20222
		trigger = { religion = FROMFROM }
	}

	is_triggered_only = yes

	immediate = {
		# Long check to determine which title will be the subject of the war
		# If the selected target has more than one title, the one most dear to the Pope will be prioritized
		########################################################################################

		# Check if the target or one of his vassals own one of the possible target Duchies or any land within their dejure
		random_landed_title = {
			limit = {
				OR = {
					title = d_latium
					title = d_spoleto
					title = d_ancona
					title = d_ferrara
					title = d_benevento
				}

				OR = {
					# Check whether you (or your vassals) own the title directly...
					holder_scope = {
						OR = {
							character = ROOT
							is_vassal_or_below_of = ROOT
						}
					}

					# ...or if you (or your vassals) only own land within the title's dejure
					any_de_jure_vassal_title = {
						holder_scope = {
							OR = {
								character = ROOT
								is_vassal_or_below_of = ROOT
							}
						}
					}
				}
			}

			preferred_limit = { title = d_latium }
			preferred_limit = { title = d_spoleto }
			preferred_limit = { title = d_ancona }
			preferred_limit = { title = d_ferrara }
			preferred_limit = { title = d_benevento }

			save_event_target_as = pepin_title_target
		}

		FROM = {
			character_event = { id = HF.20223 }
		}
	}

	option = {
		name = EVTOPTAHF20222
	}
}

# Back to uncrowned Emperor, start the war
character_event = {
	id = HF.20223
	desc = EVTDESCHFA20223
	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = {
		unsafe_war = {
			target = FROM
			casus_belli = pepin_religious
			thirdparty_title = event_target:pepin_title_target
		}
	}

	option = {
		name = EVTOPTAHF20223

		tooltip = {
			war = {
				target = FROM
				casus_belli = pepin_religious
				thirdparty_title = event_target:pepin_title_target
			}
		}
	}
}

# on_victory: Emperor praised for giving land to the Pope
character_event = {
	id = HF.20224
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20224
		trigger = {
			NAND = {
				has_character_flag = flag_pepin_for_coronation
				higher_real_tier_than = DUKE
			}
			NOT = { has_character_flag = flag_pope_gifts_artifact }
		}
	}
	desc = {
		text = EVTDESCHFB20224
		trigger = { # Special description if you waged the war for coronation
			has_character_flag = flag_pepin_for_coronation
			higher_real_tier_than = DUKE
			NOT = { has_character_flag = flag_pope_gifts_artifact }
		}
	}
	desc = {
		text = EVTDESCHFC20224
		trigger = {
			has_character_flag = flag_pope_gifts_artifact
			NAND = {
				has_character_flag = flag_pepin_for_coronation
				higher_real_tier_than = DUKE
			}
		}
	}
	desc = {
		text = EVTDESCHFD20224
		trigger = { # Special description if you waged the war for coronation
			has_character_flag = flag_pepin_for_coronation
			has_character_flag = flag_pope_gifts_artifact
			higher_real_tier_than = DUKE
		}
	}

	is_triggered_only = yes

	option = {
		name = EXCELLENT

		if = {
			limit = { has_character_flag = flag_pope_gifts_artifact }

			religion_head = {
				show_scope_change = no

				random_artifact = {
					show_scope_change = no

					limit = {
						has_artifact_flag = christian

						NOR = {
							has_artifact_flag = very_rare
							has_artifact_flag = unique # Won't give the holiest ones away
						}
					}

					transfer_artifact = {
						to = ROOT
						from = PREV
					}
				}
			}
		}

		clr_character_flag = flag_pope_gifts_artifact

		if = {
			limit = {
				has_character_flag = flag_pepin_for_coronation
				higher_real_tier_than = DUKE # In case the first ruler loses his Coronation-worthy tier before the war is won
			}

			clr_character_flag = flag_pepin_for_coronation
			set_character_flag = flag_preparing_coronation
			set_character_flag = flag_crowned_by_pope

			religion_head = { # Otherwise the scope would have been lost
				show_scope_change = no

				save_event_target_as = coronation_priest

				reverse_opinion = {
					name = opinion_supposed_to_crown
					who = ROOT
					months = 1
				}

				opinion = {
					name = opinion_supposed_to_crown
					who = ROOT
					months = 1
				}
			}

			character_event = { id = HF.20300 } # Go to budget event
		}
	}
}

# Emperor: Crazy Pope wants the Empire
letter_event = {
	id = HF.20225
	desc = EVTDESCHFA20225
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20225

		FROM = {
			show_scope_change = no

			make_tributary = {
				who = ROOT
				tributary_type = permanent
			}
		}

		character_event = { id = HF.20226 }

		ai_chance = {
			factor = 80

			mult_modifier = {
				factor = 0.1

				NOR = {
					trait = zealous
					trait = lunatic
					trait = possessed
				}
			}
		}
	}

	option = { # End of the line
		name = EVTOPTBHF20225

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_papal_land
			who = ROOT
			years = 10
		}

		ai_chance = { factor = 20 }
	}
}

# Follow-up event about Emperor bowing to the Pope
character_event = {
	id = HF.20226
	desc = EVTDESCHFA20226
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20226

		set_character_flag = flag_crowned_by_pope

		opinion = {
			name = opinion_supposed_to_crown
			who = FROMFROM
			months = 1
		}

		FROMFROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		character_event = { id = HF.20300 } # Go to budget event
	}
}

# on_death chain: if a ruler dies while during a war started as part of a deal for a coronation,
# the heir will inherit the flag, and be crowned at the end
character_event = {
	id = HF.20227

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = flag_antipope_for_coronation

	trigger = {
		any_war = {
			using_cb = depose_antipope
		}
	}

	immediate = {
		current_heir = {
			set_character_flag = flag_antipope_for_coronation

			character_event = {
				id = HF.20418 # Further safety check, in case the war invalidates for some reason
				days = 2
			}
		}
	}
}

character_event = {
	id = HF.20418

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = flag_antipope_for_coronation

	trigger = {
		NAND = {
			higher_real_tier_than = DUKE
			any_war = { using_cb = depose_antipope }
		}
	}

	immediate = {
		clr_character_flag = flag_antipope_for_coronation
	}
}

# on_death chain: if a ruler dies while during a war started as part of a deal for a coronation,
# the heir will inherit the flag, and be crowned at the end
character_event = {
	id = HF.20228

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = flag_excommunicated_for_coronation

	trigger = {
		any_war = {
			using_cb = excommunicated_ruler
		}
	}

	immediate = {
		current_heir = {
			set_character_flag = flag_excommunicated_for_coronation

			character_event = {
				id = HF.20419 # Further safety check, in case the war invalidates for some reason
				days = 2
			}
		}
	}
}

character_event = {
	id = HF.20419

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = flag_excommunicated_for_coronation

	trigger = {
		NAND = {
			higher_real_tier_than = DUKE
			any_war = { using_cb = excommunicated_ruler }
		}
	}

	immediate = {
		clr_character_flag = flag_excommunicated_for_coronation
	}
}

# on_death chain: if a ruler dies while during a war started as part of a deal for a coronation,
# the heir will inherit the flag, and be crowned at the end
character_event = {
	id = HF.20229

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = flag_pepin_for_coronation

	trigger = {
		any_war = {
			using_cb = pepin_religious
		}
	}

	immediate = {
		current_heir = {
			set_character_flag = flag_pepin_for_coronation

			character_event = {
				id = HF.20420 # Further safety check, in case the war invalidates for some reason
				days = 2
			}
		}
	}
}

character_event = {
	id = HF.20420

	is_triggered_only = yes
	hide_window = yes

	has_character_flag = flag_pepin_for_coronation

	trigger = {
		NAND = {
			higher_real_tier_than = DUKE
			any_war = { using_cb = pepin_religious }
		}
	}

	immediate = {
		clr_character_flag = flag_pepin_for_coronation
	}
}

# Notification: Vassal, you've just become a Papal vassal
character_event = {
	id = HF.20230
	desc = EVTDESCHFA20230
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20230
	}
}

# on_death of the coronation_priest. Set hidden opinion to ping back to the coronation_ruler.
character_event = {
	id = HF.20231

	is_triggered_only = yes
	hide_window = yes

	only_rulers = yes
	min_age = 16

	trigger = {
		has_any_opinion_modifier = opinion_supposed_to_crown
	}

	immediate = {
		any_playable_ruler = {
			limit = {
				has_opinion_modifier = {
					name = opinion_supposed_to_crown
					who = ROOT
				}
			}

			character_event = { id = HF.20232 }
		}
	}
}

# Ruler to be crowned: your coronation_priest has died. The ceremony is cancelled
character_event = {
	id = HF.20232
	desc = EVTDESCHFA20232
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate  = {
		remove_trait = travelling
		remove_character_modifier = out_traveling
		set_variable = { which = coronation_count value = 0 }

		clr_character_flag = flag_preparing_coronation # Still used when after waging wars
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		clr_character_flag = flag_pepin_for_coronation
		clr_character_flag = flag_extravagant_coronation
		clr_character_flag = flag_regular_coronation
		clr_character_flag = flag_secluded_coronation
		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope

		clr_character_flag = flag_coronation_foreign_friendship
		clr_character_flag = flag_coronation_vassal_friendship
		clr_character_flag = flag_coronation_diplomacy_boost
		clr_character_flag = flag_coronation_learning_boost
		clr_character_flag = flag_coronation_guest_opinions
		clr_character_flag = flag_coronation_gain_diligent
		clr_character_flag = flag_coronation_gain_ambitious
		clr_character_flag = flag_coronation_haughty_child
		clr_character_flag = flag_coronation_priest_approves
		clr_character_flag = flag_coronation_hre_talk
		clr_character_flag = flag_coronation_pope_talk
		clr_character_flag = flag_coronation_foreign_teacher
		clr_character_flag = flag_coronation_priest_disapproves
		clr_character_flag = flag_coronation_diplomatic_incident
		clr_character_flag = flag_coronation_cynic_taunts
		clr_character_flag = flag_coronation_wandering_knight
		clr_character_flag = flag_coronation_wandering_priest
		clr_character_flag = flag_coronation_random_rivalry
		clr_character_flag = flag_coronation_secluded_embarassed
		clr_character_flag = flag_coronation_secluded_vassals
		clr_character_flag = flag_coronation_secluded_priest
		clr_character_flag = flag_coronation_secluded_ambitious
		clr_character_flag = flag_coronation_secluded_proud
		clr_character_flag = flag_coronation_secluded_steward


		hidden_effect = {
			any_opinion_modifier_target = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = ROOT
					}
				}

				remove_opinion = {
					name = opinion_coronation_guest
					who = ROOT
				}

				remove_trait = travelling
				character_event = { id = HF.20233 }
			}
		}
	}

	option = {
		name = EVTOPTAHF20232
	}
}

# Guest: Ruler to be crowned lost coronation_priest. Coronation has been cancelled
character_event = {
	id = HF.20233
	desc = EVTDESCHFA20233
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20233
	}
}

# Ruler: Pope wants an orgy
letter_event = {
	id = HF.20235
	desc = EVTDESCHFA20235
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	# Fund AND join the Orgy
	option = {
		name = EVTOPTZHF20235

		custom_tooltip = { text = join_pope_orgy }

		set_character_flag = flag_crowned_by_pope

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 2
			}

			reverse_opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 2
			}
		}

		transfer_scaled_wealth = {
			to = FROM
			value = 0.75
			min = 150
			max = 400
		}

		tiered_piety_negative_effect = yes

		hidden_effect = {
			FROM = {
				tiered_piety_negative_effect = yes
			}
		}

		character_event = { id = HF.20236 } # Small event chain
		# character_event = { id = HF.20300 } # Go to budget event

		ai_chance = { factor = 10 }
	}

	option = {
		name = EVTOPTAHF20235

		trigger = {
			NOT = { trait = hedonist }
		}

		set_character_flag = flag_crowned_by_bishop

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 2
			}

			reverse_opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 2
			}
		}

		transfer_scaled_wealth = {
			to = FROM
			value = 0.75
			min = 150
			max = 400
		}

		piety = -50

		hidden_effect = {
			FROM = {
				tiered_piety_negative_effect = yes
			}
		}

		character_event = { id = HF.20300 } # Go to budget event

		ai_chance = { factor = 100 }
	}

	option = { # End of the line
		name = EVTOPTBHF20235

		custom_tooltip = { text = coronation_canceled }

		ai_chance = { factor = 0 }
	}
}

# Go to the priest's orgy, because why not
character_event = {
	id = HF.20236
	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	desc = { # Orgy with Prince-Bishop
		text = EVTDESCHFA20236
		trigger = { has_character_flag = orgy_bishop }
	}
	desc = { # Orgy with the Pope
		text = EVTDESCHFB20236
		trigger = { has_character_flag = orgy_pope }
	}

	is_triggered_only = yes
	show_from_from = yes

	immediate = {
		if = {
			limit = {
				FROMFROM = { controls_religion = yes }
			}

			set_character_flag = orgy_pope
		}
		else = {
			set_character_flag = orgy_bishop
		}
	}

	option = {
		name = EVTOPTAHF20236

		custom_tooltip = {
			text = papal_orgy_drunk
			set_character_flag = flag_papal_orgy_drunk
		}

		if = {
			limit = { trait = drunkard }
			tiered_piety_negative_effect = yes
		}
		else = {
			add_trait = drunkard
		}

		if = {
			limit = { religion = catholic }
			prestige = 50
		}
	}

	option = {
		name = EVTOPTBHF20236

		custom_tooltip = {
			text = papal_orgy_lustful
			set_character_flag = flag_papal_orgy_lustful
		}

		if = {
			limit = { trait = chaste }
			remove_trait = chaste
		}
		else_if = {
			limit = { trait = lustful }
			tiered_piety_negative_effect = yes
		}
		else = {
			add_trait = lustful
		}

		if = {
			limit = { religion = catholic }
			prestige = 50
		}
	}

	option = {
		name = EVTOPTCHF20236

		custom_tooltip = {
			text = papal_orgy_glutton
			set_character_flag = flag_papal_orgy_glutton
		}

		if = {
			limit = { trait = gluttonous }
			tiered_piety_negative_effect = yes
		}
		else_if = {
			limit = { trait = temperate }
			remove_trait = temperate
		}
		else_if = {
			limit = { NOT = { trait = gluttonous } }
			add_trait = gluttonous
		}

		if = {
			limit = { religion = catholic }
			gain_weight_large_effect = yes
			weight_trait_check_effect = yes
			prestige = 50
		}
		else = {
			gain_weight_medium_effect = yes
			weight_trait_check_effect = yes
		}
	}

	after = {
		hidden_effect = {
			random_list = {
				40 = { # Priest comes onto you
					trigger = {
						FROMFROM = { attracted_to_root_trigger = yes }
					}

					mult_modifier = {
						factor = 0.25

						is_female = yes
						practical_age >= 45
					}

					mult_modifier = {
						factor = 0.5
						has_ugly_trait_trigger = yes
					}

					mult_modifier = {
						factor = 0.5
						trait = disfigured
					}

					mult_modifier = {
						factor = 0.5
						trait = bubonic_plague
					}

					mult_modifier = {
						factor = 0.5
						trait = inbred
					}

					mult_modifier = {
						factor = 1.75
						has_fair_trait_trigger = yes
					}

					mult_modifier = {
						factor = 1.5
						practical_age < 30
					}

					mult_modifier = {
						factor = 2.5
						age < 18 # Obviously...
					}

					mult_modifier = {
						factor = 0.5
						trait = one_eyed
					}

					mult_modifier = {
						factor = 1.5
						trait = lustful
					}

					mult_modifier = {
						factor = 0.5
						FROMFROM = { NOT = { trait = lustful } }
					}

					character_event = { id = HF.20237 }
				}

				30 = { # Become Hedonist
					trigger = { lifestyle_traits < 1 }

					mult_modifier = {
						factor = 1.5
						trait = drunkard
					}

					mult_modifier = {
						factor = 1.5
						trait = gluttonous
					}

					mult_modifier = {
						factor = 1.5
						trait = slothful
					}

					mult_modifier = {
						factor = 1.5
						trait = lustful
					}

					character_event = { id = HF.20238 }
				}

				30 = { # Nothing happens, end the event
					character_event = { id = HF.20239 }
				}
			}
		}
	}
}

# Time for the communion
character_event = {
	id = HF.20237
	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	desc = { # with Prince-Bishop
		text = EVTDESCHFA20237
		trigger = { has_character_flag = orgy_bishop }
	}
	desc = { # with the Pope
		text = EVTDESCHFB20237
		trigger = { has_character_flag = orgy_pope }
	}

	is_triggered_only = yes
	show_from_from_from = yes

	option = {
		name = EVTOPTAHF20237

		custom_tooltip = {
			text = papal_orgy_communion

			if = {
				limit = {
					is_female = yes
					practical_age <= 40
					fertility >= 0.4

					FROMFROMFROM = {
						is_female = no
						NOT = { trait = eunuch }
					}
				}

				random = {
					chance = 10

					mult_modifier = {
						factor = 0.5
						fertility < 0.3 # 5%
					}

					mult_modifier = {
						factor = 1.5
						fertility >= 0.3 # 15%
					}

					mult_modifier = {
						factor = 1.4
						fertility >= 0.5 # 21%
					}

					mult_modifier = {
						factor = 1.3
						fertility >= 0.7 # 27.3%
					}

					mult_modifier = {
						factor = 1.2
						fertility >= 0.9 # 32.8%
					}

					mult_modifier = {
						factor = 1.2
						fertility >= 1.25 # 39.3%
					}

					mult_modifier = {
						factor = 1.3
						fertility >= 1.5 # 51.1%
					}

					mult_modifier = {
						factor = 1.3
						fertility >= 1.75 # 66.4%
					}

					mult_modifier = {
						factor = 1.51
						fertility >= 2 # 100%
					}

					impregnate = FROMFROMFROM

					if = {
						limit = { FROMFROMFROM = { controls_religion = yes } }
						set_character_flag = flag_vatican_prince # Cleared on birth
					}
				}
			}
		}

		tiered_prestige_reward_effect = yes
		tiered_piety_negative_effect = yes

		character_event = { id = HF.20239 } # Conclude the Orgy

		ai_chance = {
			factor = 90

			trigger = {
				FROMFROMFROM = { root_attraction_trigger = yes }
			}

			mult_modifier = {
				factor = 0.25
				trait = chaste
			}
		}
	}

	option = {
		name = EVTOPTBHF20237

		character_event = {
			id = HF.20239 # Conclude the Orgy
			tooltip = papal_orgy_flee
		}

		ai_chance = { factor = 10 }
	}
}

# Becoming Hedonist
character_event = {
	id = HF.20238
	desc = EVTDESCHFA20238
	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	show_from_from_from = yes
	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20238

		add_trait = hedonist
		character_event = { id = HF.20239 } # Proceed with the coronation
	}
}

# The orgy has concluded
character_event = {
	id = HF.20239
	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	desc = { # with Prince-Bishop
		text = EVTDESCHFA20239
		trigger = { has_character_flag = orgy_bishop }
	}
	desc = { # with the Pope
		text = EVTDESCHFB20239
		trigger = { has_character_flag = orgy_pope }
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20239

		clr_character_flag = flag_papal_orgy_drunk
		clr_character_flag = flag_papal_orgy_lustful
		clr_character_flag = flag_papal_orgy_glutton
		clr_character_flag = orgy_bishop
		clr_character_flag = orgy_pope
		character_event = { id = HF.20300 } # Proceed with the coronation
	}
}

# Ruler: Bishop asks for small religious artifact
letter_event = {
	id = HF.20240
	desc = EVTDESCHFA20240
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		random_artifact = {
			limit = {
				has_artifact_flag = christian

				NOR = {
					has_artifact_flag = rare
					has_artifact_flag = very_rare
					has_artifact_flag = flag_considering_donation
				}
			}

			save_event_target_as = scoped_artifact
			set_artifact_flag = flag_considering_donation
		}
	}

	option = {
		name = EVTOPTAHF20240

		set_character_flag = flag_crowned_by_bishop

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			reverse_opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		event_target:scoped_artifact = {
			show_scope_change = no

			transfer_artifact = {
				from = ROOT
				to = FROM
			}

			clr_artifact_flag = flag_considering_donation
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20240

		custom_tooltip = {
			text = coronation_canceled

			event_target:scoped_artifact = {
				clr_artifact_flag = flag_considering_donation
			}
		}

		ai_chance = { factor = 0 }
	}
}

# Ruler: Pope asks for rare religious artifact
letter_event = {
	id = HF.20241
	desc = EVTDESCHFA20241
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		random_artifact = {
			limit = {
				has_artifact_flag = christian
				NOT = { has_artifact_flag = flag_considering_donation }

				OR = {
					has_artifact_flag = very_rare
					has_artifact_flag = rare
				}
			}

			save_event_target_as = scoped_artifact
			set_artifact_flag = flag_considering_donation
		}
	}

	option = {
		name = EVTOPTAHF20241
		set_character_flag = flag_crowned_by_pope

		FROM = {
			show_scope_change = no

			save_event_target_as = coronation_priest

			opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}

			reverse_opinion = {
				name = opinion_supposed_to_crown
				who = ROOT
				months = 1
			}
		}

		event_target:scoped_artifact = {
			show_scope_change = no

			transfer_artifact = {
				from = ROOT
				to = FROM
			}

			clr_artifact_flag = flag_considering_donation
		}

		character_event = { id = HF.20300 } # Go to budget event
	}

	option = { # End of the line
		name = EVTOPTBHF20241

		custom_tooltip = { text = coronation_canceled }

		# The Pope remembers what he wants, cheaty spammy player
		reverse_opinion = {
			name = opinion_requested_artifact
			who = FROM
			years = 10
		}

		event_target:scoped_artifact = {
			clr_artifact_flag = flag_considering_donation
		}

		ai_chance = { factor = 0 }
	}
}

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

#### Coronation sponsor found, now decide how much money to invest in it. (REVISED WITH SCALED WEALTH)
character_event = {
	id = HF.20300
	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20300
		trigger = {
			war = no

			OR = {
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
		}
	}
	desc = {
		text = EVTDESCHFB20300
		trigger = {
			war = no
			has_character_flag = flag_crowned_by_priest
		}
	}
	desc = {
		text = EVTDESCHFC20300
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		save_event_target_as = coronation_ruler

		add_character_modifier = {
			name = out_traveling
			days = 66
			hidden = yes # Make the character inaccessible, the ruler himself is not actually out, he's still at court
		}
	}

	option = {
		name = EVTOPTAHF20300

		trigger = { war = no }

		custom_tooltip = { text = send_extracoronation_invitations }

		set_character_flag = flag_extravagant_coronation

		if = {
			limit = { ai = no } # Cheaty AI...

			scaled_wealth = {
				value = -1
				min = -250
				max = -1000
			}
		}

		character_event = {
			id = HF.20305 # Ceremony actually starts
			days = 11
		}

		any_vassal = {
			limit = {
				block_general_event_trigger = no
				NOT = { has_any_opinion_modifier = opinion_coronation_guest }
			}

			letter_event = { id = HF.20301 } # Send Invitations
		}

		any_independent_ruler = {
			limit = {
				higher_real_tier_than = DUKE
				religion = ROOT
				is_within_diplo_range = ROOT
				war = no
				is_theocracy = no
				block_general_event_trigger = no
				NOT = { has_any_opinion_modifier = opinion_coronation_guest }

				distance_from_realm = {
					who = ROOT
					value < 120
				}
			}

			letter_event = { id = HF.20302 } # Send Invitations to other Catholic neighbors
		}

		ai_chance = {
			factor = 30

			trigger = { wealth >= -100 }

			mult_modifier = {
				factor = 0.5
				NOT = { scaled_wealth = 1 }
			}

			mult_modifier = {
				factor = 0.5
				NOT = { scaled_wealth = 0.5 }
			}

			mult_modifier = {
				factor = 0.25
				wealth < 0
			}

			mult_modifier = {
				factor = 3
				real_tier = EMPEROR
			}

			mult_modifier = {
				factor = 0.75
				trait = greedy
			}
		}
	}

	option = {
		name = EVTOPTBHF20300

		trigger = { war = no }

		custom_tooltip = { text = send_coronation_invitations }

		set_character_flag = flag_regular_coronation

		character_event = {
			id = HF.20305 # Ceremony actually starts
			days = 11
		}

		any_vassal = {
			limit = {
				block_general_event_trigger = no
				NOT = { has_any_opinion_modifier = opinion_coronation_guest }
			}

			letter_event = { id = HF.20301 } # Send Invitations
		}

		if = {
			limit = { ai = no } # Cheaty AI...

			scaled_wealth = {
				value = -0.5
				min = -100
				max = -500
			}
		}

		ai_chance = {
			factor = 40

			trigger = { wealth >= -100 }

			mult_modifier = {
				factor = 0.5
				NOT = { scaled_wealth = 0.5 }
			}

			mult_modifier = {
				factor = 0.5
				NOT = { scaled_wealth = 0.25 }
			}

			mult_modifier = {
				factor = 0.25
				wealth < 0
			}

			mult_modifier = {
				factor = 0.5
				real_tier = EMPEROR
			}

			mult_modifier = {
				factor = 0.75
				trait = greedy
			}
		}
	}

	option = {
		name = {
			text = EVTOPTCHF20300
			trigger = { war = no}
		}
		name = {
			text = EVTOPTCHF20300_B
			trigger = { war = yes }
		}

		custom_tooltip = { text = send_seclcoronation_invitations }

		set_character_flag = flag_secluded_coronation

		character_event = {
			id = HF.20305 # Ceremony actually starts
			days = 11
		}

		any_voter = {
			limit = {
				block_general_event_trigger = no
				NOT = { has_any_opinion_modifier = opinion_coronation_guest }
			}

			letter_event = { id = HF.20301 } # Send Invitations
		}

		if = {
			limit = { ai = no } # Cheaty AI...

			scaled_wealth = {
				value = -0.05
				min = -10
				max = -150
			}
		}

		ai_chance = {
			factor = 30

			mult_modifier = {
				factor = 0.25
				wealth < 0
			}

			mult_modifier = {
				factor = 3
				wealth < -100
			}

			mult_modifier = {
				factor = 0.1
				real_tier = EMPEROR
			}

			mult_modifier = {
				factor = 1.5
				trait = greedy
			}
		}
	}
}

# Vassal: Ruler is inviting you to his coronation
letter_event = {
	id = HF.20301
	desc = EVTDESCHFA20301
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		FROM = {
			OR = {
				has_character_flag = flag_crowned_by_priest
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
		}
	}

	option = {
		name = EVTOPTAHF20301

		FROM = {
			letter_event = {
				id = HF.20303 # Notification
				days = 3
				random = 5
			}
		}

		opinion = {
			name = opinion_coronation_guest
			months = 4
			who = FROM
		}

		add_character_modifier = {
			name = out_traveling # Vassal travel is short, so no regent needed
			days = 45
		}

		ai_chance = { factor = 70 }
	}

	option = { # End of the line
		name = EVTOPTBHF20301

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_dislike
				who = ROOT
				years = 10
			}

			letter_event = {
				id = HF.20304 # Notification
				days = 3
				random = 5
			}
		}

		ai_chance = {
			factor = 30

			trigger = {
				# Of course he will be present
				NOT = { character = event_target:coronation_priest }
			}

			mult_modifier = {
				factor = 0.3
				opinion = { who = FROM value >= 100 }
			}

			mult_modifier = {
				factor = 0.4
				opinion = { who = FROM value >= 80 }
			}

			mult_modifier = {
				factor = 0.5
				opinion = { who = FROM value >= 60 }
			}

			mult_modifier = {
				factor = 0.65
				opinion = { who = FROM value >= 40 }
			}

			mult_modifier = {
				factor = 0.75
				opinion = { who = FROM value >= 20 }
			}

			mult_modifier = {
				factor = 0.85
				opinion = { who = FROM value >= 0 }
			}

			mult_modifier = {
				factor = 1.15
				opinion = { who = FROM value < 0 }
			}

			mult_modifier = {
				factor = 1.25
				opinion = { who = FROM value < -20 }
			}

			mult_modifier = {
				factor = 1.5
				opinion = { who = FROM value < -40 }
			}

			mult_modifier = {
				factor = 1.5
				opinion = { who = FROM value < -60 }
			}

			mult_modifier = {
				factor = 1.75
				opinion = { who = FROM value < -80 }
			}

			mult_modifier = {
				factor = 2
				opinion = { who = FROM value <= -100 }
			}
		}
	}
}

# Foreign Ruler: Ruler is inviting you to his coronation
letter_event = {
	id = HF.20302
	desc = EVTDESCHFA20302
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	trigger = {
		FROM = {
			OR = {
				has_character_flag = flag_crowned_by_priest
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
		}
	}

	option = {
		name = EVTOPTAHF20302

		FROM = {
			show_scope_change = no

			prestige = 75 # Prestigious guests bring prestige

			letter_event = {
				id = HF.20303 # Notification
				days = 5
				random = 5
			}
		}

		opinion = {
			name = opinion_coronation_guest
			who = FROM
			months = 4
		}

		add_trait = travelling # Foreign Ruler's travel is longer, it needs a regent, as if it were a pilgrimage

		# add_character_modifier = {
		#	name = out_traveling
		#	days = 45
		# }

		ai_chance = { factor = 70 }
	}

	option = { # End of the line
		name = EVTOPTBHF20302

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_dislike
				who = ROOT
				years = 10
			}

			letter_event = {
				id = HF.20304 # Notification
				days = 5
				random = 5
			}
		}

		ai_chance = {
			factor = 30

			trigger = {
				# Of course he will be present
				NOT = { character = event_target:coronation_priest }
			}

			mult_modifier = {
				factor = 0.3
				opinion = { who = FROM value >= 100 }
			}

			mult_modifier = {
				factor = 0.4
				opinion = { who = FROM value >= 80 }
			}

			mult_modifier = {
				factor = 0.5
				opinion = { who = FROM value >= 60 }
			}

			mult_modifier = {
				factor = 0.65
				opinion = { who = FROM value >= 40 }
			}

			mult_modifier = {
				factor = 0.75
				opinion = { who = FROM value >= 20 }
			}

			mult_modifier = {
				factor = 0.85
				opinion = { who = FROM value >= 0 }
			}

			mult_modifier = {
				factor = 1.15
				opinion = { who = FROM value < 0 }
			}

			mult_modifier = {
				factor = 1.25
				opinion = { who = FROM value < -20 }
			}

			mult_modifier = {
				factor = 1.5
				opinion = { who = FROM value < -40 }
			}

			mult_modifier = {
				factor = 1.5
				opinion = { who = FROM value < -60 }
			}

			mult_modifier = {
				factor = 1.75
				opinion = { who = FROM value < -80 }
			}

			mult_modifier = {
				factor = 2
				opinion = { who = FROM value <= -100 }
			}
		}
	}
}

# Ruler Notification: Vassal will come to the Coronation Ceremony
letter_event = {
	id = HF.20303
	desc = EVTDESCHF20303

	is_triggered_only = yes
	notification = yes

	ai = no

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}

		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}

	option = {
		name = EVTOPTAHF20303
	}
}

# Ruler Notification: Vassal will not come to the Coronation Ceremony
letter_event = {
	id = HF.20304
	desc = EVTDESCHF20304

	is_triggered_only = yes
	notification = yes

	ai = no

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}

		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}

	option = {
		name = EVTOPTAHF20304
	}
}

# Ruler: Day 11 from budget, ceremony starts
character_event = {
	id = HF.20305
	picture = GFX_evt_magnificent_castle
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20305
		trigger = {
			has_character_flag = flag_extravagant_coronation
			war = no
		}
	}
	desc = {
		text = EVTDESCHFB20305
		trigger = {
			has_character_flag = flag_regular_coronation
			war = no
		}
	}
	desc = {
		text = EVTDESCHFC20305
		trigger = {
			has_character_flag = flag_secluded_coronation
			war = no
		}
	}

	desc = {
		text = EVTDESCHFD20305
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}

		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}

		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	option = {
		name = EVTOPTAHF20305

		hidden_effect = {
			# random_coronation_events_effect, fired in HF.20365
			# Ruler befriends foreign ruler
			# Ruler befriends vassal
			# Ruler's new acquaintances improve his diplomacy/stewardship
			# Ruler's new acquaintances improve his intrigue/learning
			# Ruler's diplomacy helps him improve opinion of all guests
			# Ruler's new resolve makes him lose slothful/content
			# Proud ruler's trepidation makes him gain ambitious
			# Child ruler's flattered and can become haughty or conscientious
			# The coronation_priest approves of the ceremony
			# Temperate/Celibate coronation_priest disapproves of the extravagant ceremony
			# HRE/Francia Emperor gets a talk from the priest about being the heir of Charlemagne (chance for prestige, learning, diligent)
			# The Pope talks to the Ruler about his duties as protector of Christendom (chance to gain zealous, cynical, learning)
			# Child ruler is taught by foreign ruler about stewardship
			# Two foreign Kings (guests) become (or are) rivals, coronation_ruler with high diplomacy can help them lose rivalry and become his friends
			# Cynical vassal (or wicked priest) annoys the coronation_priest. High diplomacy ruler may help and gain gregarious
			# A knight comes to pledge his service to the new King/Emperor, if ruler is female/child, chance to become friend/lover or increase martial
			# A wise priest joins the court
			# Ruler becomes rival of one of his vassals

			# Ruler is embarassed of secluded coronation, chance to gain stressed or paranoid
			# Ruler's vassals are offended by secluded coronation (chance to avoid with high diplomacy)
			# Coronation_priest is disappointed by secluded ceremony
			# Ruler is disraught by secluded ceremony (chance to lose ambitious, gain content/slothful)
			# Ruler reflects upon secluded coronation (chance to lose proud, gain humble)
			# Ruler's Councillor becomes his rival due to secluded coronation

			set_variable = {
				which = coronation_count
				value = 0
			}

			character_event = {
				id = HF.20365 # First and second row of random list
				days = 3
				random = 3
			}

			# For safety reasons, just in case guests die in the middle of the feast and prevent the last event from firing
			character_event = {
				id = HF.20366 # THE CORONATION ITSELF #
				days = 32
			}
		}
	}
}

# Ruler has chance to befriend foreign ruler
character_event = {
	id = HF.20306
	desc = EVTDESCHFA20306
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes # random_coronation_events_effect
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_foreign_friendship

		random_independent_ruler = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}

				num_of_friends < 3

				NOR = {
					is_rival = ROOT
					is_friend = ROOT
					is_lover = ROOT
					is_married = ROOT
				}

				opinion = {
					who = FROM
					value >= -20
				}
			}

			save_event_target_as = potential_friend
		}
	}

	option = {
		name = EVTOPTAHF20306

		event_target:potential_friend = {
			show_scope_change = no

			character_event = {
				id = HF.20307
				tooltip = EVTTOOLTIPAHF20307
			}
		}

		ai_chance = {
			factor = 90

			mult_modifier = {
				factor = 0.5
				trait = shy
			}

			mult_modifier = {
				factor = 0.5
				trait = paranoid
			}
		}
	}

	option = {
		name = EVTOPTBHF20306

		ai_chance = { factor = 10 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Foreign ruler/Vassal: Ruler wants to become your friend
character_event = {
	id = HF.20307
	desc = EVTDESCHFA20307
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20307

		add_friend = FROM
		FROM = { character_event = { id = HF.20308 } }

		ai_chance = {
			factor = 90

			mult_modifier = {
				factor = 0.8
				FROM = { trait = shy }
			}

			mult_modifier = {
				factor = 0.75
				FROM = { trait = cruel }
				NOT = { trait = cruel }
			}

			mult_modifier = {
				factor = 0.5
				trait = envious
			}
		}
	}

	option = {
		name = EVTOPTBHF20307

		FROM = {
			show_scope_change = no

			character_event = {
				id = HF.20309
				tooltip = EVTTOOLTIPAHF20309
			}
		}

		ai_chance = { factor = 10 }
	}
}

# Ruler: you've acquired a new friend
character_event = {
	id = HF.20308
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	desc = {
		trigger = { NOT = { is_liege_of = FROM } }
		text = EVTDESCHFA20308
	}
	desc = {
		trigger = { is_liege_of = FROM }
		text = EVTDESCHFB20308
	}

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	option = {
		name = EXCELLENT

		tooltip = {
			add_friend = FROM
		}
	}
}

# Ruler: you have not acquired a new friend
character_event = {
	id = HF.20309
	desc = EVTDESCHFA20309
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	option = {
		name = EVTOPTAHF20309
	}
}

# Ruler has chance to befriend one of his vassals
character_event = {
	id = HF.20310
	desc = EVTDESCHFA20310
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_vassal_friendship

		random_vassal = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}

				num_of_friends < 3

				NOR = {
					is_rival = ROOT
					is_friend = ROOT
					is_lover = ROOT
					is_married = ROOT
				}

				opinion = {
					who = FROM
					value >= -20
				}
			}

			save_event_target_as = potential_friend
		}
	}

	option = {
		name = EVTOPTAHF20310

		event_target:potential_friend = {
			show_scope_change = no

			character_event = {
				id = HF.20307
				tooltip = EVTTOOLTIPAHF20307
			}
		}

		ai_chance = {
			factor = 90

			mult_modifier = {
				factor = 0.5
				trait = shy
			}

			mult_modifier = {
				factor = 0.5
				trait = paranoid
			}
		}
	}

	option = {
		name = EVTOPTBHF20310

		ai_chance = { factor = 10 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Ruler talks with guests, chance to gain diplomacy or stewardship
character_event = {
	id = HF.20311
	desc = EVTDESCHFA20311
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_diplomacy_boost
	}

	option = {
		name = EVTOPTAHF20311

		change_diplomacy = 1

		hidden_effect = {
			any_opinion_modifier_target = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = ROOT
					}

					OR = {
						AND = {
							vassal_of = ROOT
							is_ruler = yes
						}

						independent = yes
					}
				}

				character_event = { id = HF.20312 }
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				diplomacy < 10
			}
		}
	}

	option = {
		name = EVTOPTBHF20311

		change_stewardship = 1

		hidden_effect = {
			any_opinion_modifier_target = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = ROOT
					}

					OR = {
						AND = {
							vassal_of = ROOT
							is_ruler = yes
						}

						independent = yes
					}
				}

				character_event = { id = HF.20313 }
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				stewardship < 10
			}
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Coronation guest: ruler displays diplomacy
character_event = {
	id = HF.20312
	desc = EVTDESCHFA20312
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20312

		prestige = 40

		random = {
			chance = 5
			change_diplomacy = 1
		}
	}
}

# Coronation guest: ruler displays stewardship
character_event = {
	id = HF.20313
	desc = EVTDESCHFA20313
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20313

		prestige = 40

		random = {
			chance = 5
			change_stewardship = 1
		}
	}
}

# Ruler talks with guests, chance to gain intrigue or learning
character_event = {
	id = HF.20314
	desc = EVTDESCHFA20314
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_learning_boost
	}

	option = {
		name = EVTOPTAHF20314

		change_intrigue = 1

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				intrigue < 10
			}
		}
	}

	option = {
		name = EVTOPTBHF20314

		change_learning = 1

		any_opinion_modifier_target = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}

				OR = {
					AND = {
						vassal_of = ROOT
						is_ruler = yes
					}

					independent = yes
				}
			}

			character_event = { id = HF.20315 }
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				learning < 10
			}
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Coronation guest: ruler displays learning
character_event = {
	id = HF.20315
	desc = EVTDESCHFA20315
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20315

		piety = 50

		random = {
			chance = 5
			change_learning = 1
		}
	}
}

# Ruler shows off with guests, chance to improve opinion
character_event = {
	id = HF.20316
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20316
		trigger = { is_adult = yes }
	}
	desc = {
		text = EVTDESCHFB20316
		trigger = { is_adult = no }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_guest_opinions
	}

	option = {
		name = EVTOPTAHF20316

		custom_tooltip = {
			text = EVTTOOLTIPAHF20316

			random_list = {
				50 = {
					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.25
						diplomacy >= 6
					}

					mult_modifier = {
						factor = 1.25
						diplomacy >= 8
					}

					mult_modifier = {
						factor = 1.25
						diplomacy >= 10
					}

					mult_modifier = {
						factor = 1.5
						diplomacy >= 12
					}

					mult_modifier = {
						factor = 1.75
						diplomacy >= 15
					}

					mult_modifier = {
						factor = 1.25
						trait = gregarious
					}

					mult_modifier = {
						factor = 0.5
						trait = shy
					}

					mult_modifier = {
						factor = 1.25
						trait = underhanded_rogue
					}

					mult_modifier = {
						factor = 1.5
						trait = charismatic_negotiator
					}

					mult_modifier = {
						factor = 1.75
						trait = grey_eminence
					}

					mult_modifier = {
						factor = 1.75
						is_adult = no # Lower expectations
					}

					character_event = { id = HF.20317 } # Success
				}

				50 = {
					character_event = { id = HF.20318 } # Failure
				}
			}
		}

		ai_chance = {
			factor = 90

			mult_modifier = {
				factor = 0.75
				diplomacy < 10
			}

			mult_modifier = {
				factor = 0.5
				trait = shy
			}
		}
	}

	option = {
		name = EVTOPTBHF20316

		ai_chance = { factor = 10 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Success: Ruler has impressed his guests
character_event = {
	id = HF.20317
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20317
		trigger = { is_adult = yes }
	}
	desc = {
		text = EVTDESCHFB20317
		trigger = { is_adult = no }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	option = {
		name = EVTOPTAHF20317

		custom_tooltip = { text = EVTTOOLTIPAHF20317 }

		if = {
			limit = { is_adult = yes }
			prestige = 75
		}
		else = {
			prestige = 150
		}

		any_opinion_modifier_target = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}

				OR = {
					AND = {
						vassal_of = ROOT
						is_ruler = yes
					}

					independent = yes
				}

				NOT = { character = event_target:coronation_priest }
			}

			character_event = { id = HF.20319 }
		}

		event_target:coronation_priest = {
			character_event = { id = HF.20319 }
		}
	}
}

# Failure: Ruler has not impressed his guests
character_event = {
	id = HF.20318
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20318
		trigger = { is_adult = yes }
	}
	desc = {
		text = EVTDESCHFB20318
		trigger = { is_adult = no }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	option = {
		name = EVTOPTAHF20318

		custom_tooltip = { text = EVTTOOLTIPAHF20318 }

		if = {
			limit = { is_adult = yes }
			prestige = -90
		}
		else = {
			prestige = -40
		}

		any_player = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}

				NOT = { character = event_target:coronation_priest }
			}

			character_event = { id = HF.20320 }
		}

		event_target:coronation_priest = {
			character_event = { id = HF.20320 }
		}
	}
}

# Coronation guest: ruler speech increased opinion
character_event = {
	id = HF.20319
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20319
		trigger = { is_adult = yes }
	}
	desc = {
		text = EVTDESCHFB20319
		trigger = { is_adult = no }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20319

		prestige = 40

		opinion = {
			name = opinion_swayed_1
			who = FROM
			years = 10
		}
	}
}

# Coronation guest: ruler speech did not increase opinion
character_event = {
	id = HF.20320
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20320
		trigger = { is_adult = yes }
	}
	desc = {
		text = EVTDESCHFB20320
		trigger = { is_adult = no }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20320

		opinion = {
			name = opinion_tiresome
			who = FROM
			years = 3
		}
	}
}

# Ruler galvanized by upcoming coronation, chance to lose content or slothful
character_event = {
	id = HF.20321
	desc = EVTDESCHFA20321
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_gain_diligent
	}

	option = {
		name = EVTOPTAHF20321

		trigger = { trait = content }

		prestige = 75

		random = {
			chance = 50
			remove_trait_content_effect = yes
		}
	}

	option = {
		name = EVTOPTBHF20321

		trigger = { trait = slothful }

		piety = 20

		random = {
			chance = 50
			remove_trait_slothful_effect = yes
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Proud Ruler galvanized by upcoming coronation, chance to become ambitious or lose proud
character_event = {
	id = HF.20322
	desc = EVTDESCHFA20322
	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_gain_ambitious
	}

	option = {
		name = EVTOPTAHF20322

		prestige = 75

		random = {
			chance = 50

			if = {
				limit = { trait = ambitious }
				prestige = 75
			}
			else = {
				add_trait_fully_ambitious_effect = yes
			}
		}
	}

	option = {
		name = EVTOPTBHF20322

		piety = 50

		random = {
			chance = 50
			remove_trait_proud_effect = yes
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Child Ruler galvanized by upcoming coronation, chance to become haughty or conscientious
character_event = {
	id = HF.20323
	desc = EVTDESCHFA20323
	picture = GFX_evt_child_reading
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_haughty_child
	}

	option = {
		name = EVTOPTAHF20323

		prestige = 75

		if = {
			limit = {
				has_dlc = "Conclave"
				NOT = { trait = haughty }
			}

			random = {
				chance = 50
				add_trait = haughty
			}
		}
	}

	option = {
		name = EVTOPTBHF20323

		if = {
			limit = {
				has_dlc = "Conclave"
				NOT = { trait = conscientious }
			}

			piety = 50

			random = {
				chance = 50
				add_trait = conscientious
			}
		}
		else = {
			piety = 75
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Ruler: coronation_priest is pleased by the feast
character_event = {
	id = HF.20324
	desc = EVTDESCHFA20324
	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_priest_approves # To avoid the same event happening twice during the coronation
	}

	option = {
		name = EVTOPTAHF20324

		if = {
			limit = { is_adult = yes }
			piety = 40
		}
		else = {
			piety = 60
		}

		reverse_opinion = {
			name = opinion_impressed
			who = event_target:coronation_priest
			years = 10
		}

		any_opinion_modifier_target = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}

				OR = {
					AND = {
						vassal_of = ROOT
						is_ruler = yes
					}

					independent = yes
				}
			}

			character_event = { id = HF.20325 }
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Coronation guest: coronation_priest is impressed by the feast
character_event = {
	id = HF.20325
	desc = EVTDESCHFA20325
	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20325

		piety = 50
	}
}

# Emperor of Francia/HRE: coronation_priest speaks about responsibility of Charlemagne
character_event = {
	id = HF.20326
	desc = EVTDESCHFA20326
	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_hre_talk
	}

	option = {
		name = EVTOPTAHF20326

		prestige = 100

		ai_chance = { factor = 40 }
	}

	option = {
		name = EVTOPTBHF20326

		change_learning = 2

		ai_chance = { factor = 30 }
	}

	option = {
		name = EVTOPTCHF20326

		if = {
			limit = { trait = slothful }
			remove_trait = slothful
		}
		else_if = {
			limit = { trait = diligent }
			piety = 30
		}
		else = {
			add_trait = diligent
		}

		ai_chance = { factor = 30 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Ruler: Pope talks about responsibility of Catholic Kings
character_event = {
	id = HF.20327
	desc = EVTDESCHFA20327
	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_pope_talk
	}

	option = {
		name = EVTOPTAHF20327

		if = {
			limit = { trait = cynical }
			remove_trait = cynical
		}
		else_if = {
			limit = { trait = zealous }
			piety = 75
		}
		else = {
			add_trait = zealous
		}
	}

	option = {
		name = EVTOPTBHF20327

		change_learning = 2
	}

	option = {
		name = EVTOPTCHF20327

		add_trait_partially_silently_cynical_effect = yes

		ai_chance = { factor = 0 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Foreign coronation guest: chance to teach Child Ruler about stewardship
character_event = {
	id = HF.20328
	desc = EVTDESCHFA20328
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20328

		event_target:coronation_ruler = {
			show_scope_change = no

			character_event = {
				id = HF.20329
				tooltip = EVTTOOLTIPHF20329
			}
		}

		if = {
			limit = { trait = slothful }
			remove_trait = slothful
		}
		else_if = {
			limit = { trait = diligent }
			piety = 20
		}
		else = {
			add_trait = diligent
		}

		ai_chance = {
			factor = 99

			mult_modifier = {
				factor = 0.5
				trait = slothful
			}
		}
	}

	option = {
		name = EVTOPTBHF20328

		prestige = 75

		random = {
			chance = 50
			add_trait_partially_proud_effect = yes
		}

		ai_chance = { factor = 1 }
	}
}

# Child Ruler: foreign ruler wants to teach you about statemanship
character_event = {
	id = HF.20329
	desc = EVTDESCHFA20329
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_foreign_teacher
	}

	is_triggered_only = yes
	hide_new = yes

	option = {
		name = EVTOPTAHF20329

		FROM = {
			show_scope_change = no

			character_event = {
				id = HF.20330
				tooltip = EVTTOOLTIPHF20330
			}
		}

		change_stewardship = 2

		reverse_opinion = {
			name = opinion_impressed
			who = FROM
			years = 10
		}

		ai_chance = {
			factor = 80

			mult_modifier = {
				factor = 0.5
				trait = slothful
			}

			mult_modifier = {
				factor = 0.5
				trait = indolent
			}

			mult_modifier = {
				factor = 0.5
				trait = haughty
			}

			mult_modifier = {
				factor = 1.75
				trait = conscientious
			}
		}
	}

	option = {
		name = EVTOPTBHF20329

		FROM = {
			show_scope_change = no

			character_event = {
				id = HF.20331
				tooltip = EVTTOOLTIPHF20331
			}

			opinion = {
				name = opinion_dislike
				who = ROOT
				years = 10
			}
		}

		if = {
			limit = { has_dlc = "Conclave" }

			random = {
				chance = 50

				if = {
					limit = { trait = conscientious }
					remove_trait = conscientious
				}
				else_if = {
					limit = { NOT = { trait = indolent } }
					add_trait = indolent
				}
			}
		}

		ai_chance = { factor = 20 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Foreign Coronation guest: Child Ruler appreciated your help
character_event = {
	id = HF.20330
	desc = EVTDESCHFA20330
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20330

		tooltip = {
			opinion = {
				name = opinion_impressed
				who = FROM
				years = 10
			}
		}
	}
}

# Foreign Coronation guest: Child Ruler did not appreciate your help
character_event = {
	id = HF.20331
	desc = EVTDESCHFA20331
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20331

		tooltip = {
			opinion = {
				name = opinion_dislike
				who = FROM
				years = 10
			}
		}
	}
}

# Ruler: coronation_priest is displeased by the feast
character_event = {
	id = HF.20332
	desc = EVTDESCHFA20332
	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_priest_disapproves
	}

	option = {
		name = EVTOPTAHF20332

		if = {
			limit = { is_adult = yes }
			piety = -75
		}
		else = {
			piety = -25
		}

		reverse_opinion = {
			name = opinion_disapprove
			who = event_target:coronation_priest
			years = 10
		}

		any_player = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}
			}

			character_event = { id = HF.20333 }
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Coronation guest: coronation_priest is displeased by the feast
character_event = {
	id = HF.20333
	desc = EVTDESCHFA20333
	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20333
	}
}

# Foreign Coronation guest: you become (or are) rival with another guest (hidden)
character_event = {
	id = HF.20334

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	immediate = {
		if = {
			limit = {
				any_rival = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = event_target:coronation_ruler
					}

					independent = yes
				}
			}

			set_character_flag = flag_met_old_rival

			random_rival = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = event_target:coronation_ruler
					}

					independent = yes
				}

				character_event = { id = HF.20335 }
			}
		}
		else = {
			random_independent_ruler = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = event_target:coronation_ruler
					}

					opinion = {
						who = ROOT
						value < -30
					}
				}

				character_event = { id = HF.20335 }
			}
		}
	}
}

# Coronation guest 2: new or old rivalry disrupts the feast
character_event = {
	id = HF.20335
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20335
		trigger = {
			FROM = { has_character_flag = flag_met_old_rival }
		}
	}
	desc = {
		text = EVTDESCHFB20335
		trigger = {
			NOT = { FROM = { has_character_flag = flag_met_old_rival } }
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20335

		tooltip = {
			if = {
				limit = { NOT = { is_rival = FROM } }
				add_rival = FROM
			}
		}

		FROM = { character_event = { id = HF.20336 } }
		event_target:coronation_ruler = { character_event = { id = HF.20337 } }
	}
}

# Coronation guest 1: new or old rivalry disrupts the feast
character_event = {
	id = HF.20336
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20336
		trigger = { has_character_flag = flag_met_old_rival }
	}
	desc = {
		text = EVTDESCHFB20336
		trigger = {
			NOT = { has_character_flag = flag_met_old_rival }
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20336

		if = {
			limit = { NOT = { is_rival = FROM } }
			add_rival = FROM
		}

		clr_character_flag = flag_met_old_rival
	}
}

# Ruler: two foreign rulers are bickering, do you interfere?
character_event = {
	id = HF.20337
	desc = EVTDESCHFA20337
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_diplomatic_incident
	}

	option = {
		name = EVTOPTAHF20337
		tooltip_info = diplomacy

		custom_tooltip = {
			text = EVTTOOLTIPAHF20337

			random_list = {
				# Critical Success
				# Success
				# Failure
				# Critical Failure

				10 = {
					trigger = { num_of_friends < 3 }

					mult_modifier = {
						factor = 0.1

						diplomacy < 15
						has_education_diplomacy_trigger = no
					}

					mult_modifier = {
						factor = 0.5

						OR = {
							FROM = { trait = stubborn }
							FROMFROM = { trait = stubborn }
						}
					}

					character_event = { id = HF.20338 } # Ruler succeeds and becomes friends with the rulers
					FROM = { character_event = { id = HF.20338 } }
					FROMFROM = { character_event = { id = HF.20338 } }
				}

				40 = {
					mult_modifier = {
						factor = 0.8
						has_education_diplomacy_trigger = no
					}

					mult_modifier = {
						factor = 0.5

						OR = {
							FROM = { trait = stubborn }
							FROMFROM = { trait = stubborn }
						}
					}

					mult_modifier = {
						factor = 0.25
						diplomacy < 1
					}

					mult_modifier = {
						factor = 0.5
						diplomacy < 2
					}

					mult_modifier = {
						factor = 0.75
						diplomacy < 4
					}

					mult_modifier = {
						factor = 0.75
						diplomacy < 6
					}

					mult_modifier = {
						factor = 0.75
						diplomacy < 8
					}

					character_event = { id = HF.20339 } # Ruler succeeds, ending the rivalry
					FROM = { character_event = { id = HF.20339 } }
					FROMFROM = { character_event = { id = HF.20339 } }
				}

				40 = {
					mult_modifier = {
						factor = 0.75
						diplomacy >= 8
					}

					mult_modifier = {
						factor = 0.75
						diplomacy >= 10
					}

					mult_modifier = {
						factor = 0.75
						diplomacy >= 12
					}

					mult_modifier = {
						factor = 0.75
						diplomacy >= 14
					}

					mult_modifier = {
						factor = 0.5
						diplomacy >= 16
					}

					mult_modifier = {
						factor = 0.5
						diplomacy >= 18
					}

					mult_modifier = {
						factor = 0.25
						diplomacy >= 20
					}

					mult_modifier = {
						factor = 0.5
						trait = charismatic_negotiator
					}

					mult_modifier = {
						factor = 0.25
						trait = grey_eminence
					}

					mult_modifier = {
						factor = 0.75
						trait = gregarious
					}

					mult_modifier = {
						factor = 0.75
						trait = honest
					}

					# Ruler fails
					character_event = { id = HF.20340 }
					FROM = { character_event = { id = HF.20340 } }
					FROMFROM = { character_event = { id = HF.20340 } }
				}

				10 = {
					trigger = { num_of_rivals < 3 }

					mult_modifier = {
						factor = 0.1

						OR = {
							diplomacy >= 15
							has_education_diplomacy_trigger = yes
						}
					}

					# Ruler fails and becomes rival with rulers
					character_event = { id = HF.20341 }
					FROM = { character_event = { id = HF.20341 } }
					FROMFROM = { character_event = { id = HF.20341 } }
				}
			}
		}

		ai_chance = {
			factor = 75

			mult_modifier = {
				factor = 0.5
				diplomacy < 10
			}

			mult_modifier = {
				factor = 0.5
				trait = shy
			}
		}
	}

	option = {
		name = EVTOPTBHF20337

		prestige = -50
		piety = -25

		ai_chance = {
			factor = 25

			mult_modifier = {
				factor = 0.5
				trait = gregarious
			}

			mult_modifier = {
				factor = 0.5
				trait = proud
			}

			mult_modifier = {
				factor = 1.75
				trait = shy
			}
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Foreign incident: Critical success
character_event = {
	id = HF.20338
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20338
		trigger = { character = FROM } # Host
	}
	desc = {
		text = EVTDESCHFB20338
		trigger = {
			NOT = { character = FROM } # Guests
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EXCELLENT

		if = {
			limit = { character = FROMFROM }
			remove_rival = FROMFROMFROM
		}
		else_if = {
			limit = { character = FROMFROMFROM }
			remove_rival = FROMFROM
		}
		else = {
			add_friend = FROMFROM
			add_friend = FROMFROMFROM
		}
	}
}

# Foreign incident: success
character_event = {
	id = HF.20339
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20339
		trigger = { character = FROM } # Host
	}
	desc = {
		text = EVTDESCHFB20339
		trigger = {
			NOT = { character = FROM } # Guests
		}
	}

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	is_triggered_only = yes
	hide_new = yes

	option = {
		name = GOOD

		if = {
			limit = { character = FROMFROM }
			remove_rival = FROMFROMFROM
		}
		else_if = {
			limit = { character = FROMFROMFROM }
			remove_rival = FROMFROM
		}
		else = {
			prestige = 100
		}
	}
}

# Foreign incident: failure
character_event = {
	id = HF.20340
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20340
		trigger = { character = FROM } # Host
	}
	desc = {
		text = EVTDESCHFB20340
		trigger = {
			NOT = { character = FROM } # Guests
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20340

		if = {
			limit = { character = FROMFROM }

			opinion = {
				name = opinion_angry
				who = FROM
				months = 30
			}
		}
		else_if = {
			limit = { character = FROMFROMFROM }

			opinion = {
				name = opinion_angry
				who = FROM
				months = 30
			}
		}
		else = {
			prestige = -100
		}
	}
}

# Foreign incident: critical failure, gained new rivals
character_event = {
	id = HF.20341
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20341
		trigger = { character = FROM } # Host
	}
	desc = {
		text = EVTDESCHFB20341
		trigger = {
			NOT = { character = FROM } # Guests
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20341

		if = {
			limit = { character = FROMFROM }
			add_rival = FROM
		}
		else_if = {
			limit = { character = FROMFROMFROM }
			add_rival = FROM
		}
		else = {
			prestige = -100
			add_rival = FROMFROM
			add_rival = FROMFROMFROM
		}
	}
}

# Cynical/Wicked guest annoys coronation_priest
character_event = {
	id = HF.20342
	desc = EVTDESCHFA20342
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20342

		reverse_opinion = {
			name = opinion_insulted
			who = event_target:coronation_priest
			months = 30
		}

		hidden_effect = {
			event_target:coronation_ruler = {
				character_event = { id = HF.20364 }
			}
		}
	}

	option = {
		name = EVTOPTBHF20342
	}
}

# Ruler notified that coronation_priest has been offended, decide what to do
character_event = {
	id = HF.20364
	desc = EVTDESCHFA20364
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_cynic_taunts
	}

	option = { # Use high diplomacy to make both happy
		name = EVTOPTAHF20364
		tooltip_info = diplomacy

		trigger = { diplomacy >= 10 }

		prestige = 75
		piety = 25

		reverse_opinion = {
			name = opinion_feast_friend
			who = event_target:coronation_priest
			months = 30
		}

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_feast_friend
				who = ROOT
				months = 30
			}

			character_event = { id = HF.20343 }
		}

		ai_chance = { factor = 100 }
	}

	option = { # Support coronation_priest
		name = EVTOPTBHF20364

		piety = 75

		reverse_opinion = {
			name = opinion_feast_friend
			who = event_target:coronation_priest
			months = 30
		}

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_insulted
				who = ROOT
				months = 30
			}

			character_event = { id = HF.20344 }
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				trait = cynical
			}
		}
	}

	option = { # Support guest
		name = EVTOPTCHF20364

		prestige = 75

		reverse_opinion = {
			name = opinion_insulted
			who = event_target:coronation_priest
			months = 30
		}

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_feast_friend
				who = ROOT
				months = 30
			}

			character_event = { id = HF.20345 }
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				trait = zealous
			}
		}
	}

	option = { # Support neither
		name = EVTOPTDHF20364

		ai_chance = {
			factor = 1

			mult_modifier = {
				factor = 10
				trait = shy
			}
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Cynical/Wicked learns lesson
character_event = {
	id = HF.20343
	desc = EVTDESCHFA20343
	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20343

		tooltip = {
			opinion = {
				name = opinion_feast_friend
				who = FROM
				months = 30
			}
		}
	}
}

# Cynical/Wicked insulted
character_event = {
	id = HF.20344
	desc = EVTDESCHFA20344
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20344

		tooltip = {
			opinion = {
				name = opinion_insulted
				who = FROM
				months = 30
			}
		}
	}
}

# Cynical/Wicked glad of support
character_event = {
	id = HF.20345
	desc = EVTDESCHFA20345
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20345

		tooltip = {
			opinion = {
				name = opinion_feast_friend
				who = FROM
				months = 30
			}
		}
	}
}

# Ruler: A valiant knight has come to offer his services
character_event = {
	id = HF.20346
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:coronation_knight

	desc = {
		text = EVTDESCHFA20346
		trigger = {
			is_female = no
			is_adult = yes
		}
	}
	desc = {
		text = EVTDESCHFB20346
		trigger = {
			is_female = yes
			is_adult = yes
		}
	}
	desc = {
		text = EVTDESCHFC20346
		trigger = { is_adult = no }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_wandering_knight

		create_random_soldier = {
			random_traits = yes
			dynasty = none
			culture = ROOT
			religion = ROOT
			female = no
			age = 24

			attributes = {
				learning = 10
				martial = 15
			}
		}

		new_character = {
			save_event_target_as = coronation_knight

			remove_trait = slow
			remove_trait = imbecile
			remove_trait = dull

			remove_trait = mystic
			remove_trait = socializer
			remove_trait = game_master
			remove_trait = hedonist
			remove_trait = strategist
			remove_trait = administrator
			remove_trait = architect
			remove_trait = gardener
			remove_trait = master_schemer
			remove_trait = impaler
			remove_trait = master_seducer
			remove_trait = master_seductress
			remove_trait = theologian
			remove_trait = scholar

			remove_trait = craven
			add_trait = brave

			random = {
				chance = 10
				add_trait = zealous
			}

			random = {
				chance = 30
				add_trait = charitable
			}

			random = {
				chance = 30
				add_trait = kind
			}

			random = {
				chance = 40
				add_trait = celibate
			}

			if = {
				limit = {
					year >= 1100
					has_global_flag = christian_crusades_unlocked
				}

				random = {
					chance = 30
					add_trait = crusader
				}
			}
		}
	}

	option = {
		name = EVTOPTAHF20346

		event_target:coronation_knight = {
			show_scope_change = no

			move_character = ROOT

			opinion = {
				name = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}

		hidden_effect = {
			random_list = {
				30 = { }

				40 = { # Court Love
					trigger = {
						is_female = yes
						is_adult = yes
						num_of_lovers < 3

						event_target:coronation_knight = {
							NOT = { trait = homosexual }
						}
					}

					mult_modifier = {
						factor = 1.5
						has_fair_trait_trigger = yes
					}

					mult_modifier = {
						factor = 0.5
						has_ugly_trait_trigger = yes
					}

					mult_modifier = {
						factor = 0.5
						trait = inbred
					}

					mult_modifier = {
						factor = 0.75
						trait = harelip
					}

					mult_modifier = {
						factor = 0.75
						trait = lisp
					}

					mult_modifier = {
						factor = 0.75
						trait = hunchback
					}

					mult_modifier = {
						factor = 0.75
						trait = dwarf
					}

					mult_modifier = {
						factor = 1.5
						trait = gregarious
					}

					mult_modifier = {
						factor = 1.5
						trait = quick
					}

					mult_modifier = {
						factor = 1.5
						trait = genius
					}

					mult_modifier = {
						factor = 1.5
						trait = chaste
					}

					mult_modifier = {
						factor = 1.5
						trait = celibate
					}

					mult_modifier = {
						factor = 0.5
						practical_age >= 40
					}

					mult_modifier = {
						factor = 1.75
						is_married = no
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_knight = { trait = lustful }
					}

					character_event = {
						id = HF.20347
						days = 2
						random = 2
					}
				}

				40 = { # Squire Ruler
					trigger = { is_adult = no }

					mult_modifier = {
						factor = 1.5
						trait = brave
					}

					mult_modifier = {
						factor = 1.5
						trait = strong
					}

					mult_modifier = {
						factor = 1.5
						trait = brawny
					}

					mult_modifier = {
						factor = 1.5
						trait = rowdy
					}

					mult_modifier = {
						factor = 0.75
						trait = hunchback
					}

					mult_modifier = {
						factor = 0.75
						trait = dwarf
					}

					mult_modifier = {
						factor = 0.5
						trait = inbred
					}

					mult_modifier = {
						factor = 0.5
						trait = weak
					}

					mult_modifier = {
						factor = 0.75
						trait = slow
					}

					mult_modifier = {
						factor = 0.5
						trait = imbecile
					}

					mult_modifier = {
						factor = 0.75
						trait = frail
					}

					character_event = {
						id = HF.20350
						days = 2
						random = 2
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTBHF20346

		hidden_effect = {
			event_target:coronation_knight = {
				death = { death_reason = death_missing }
			}
		}

		ai_chance = { factor = 0 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Queen: Travelling knight has fallen in love with you
character_event = {
	id = HF.20347
	desc = EVTDESCHFA20347
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	option = {
		name = EVTOPTAHF20347

		add_lover = event_target:coronation_knight

		hidden_effect = {
			# Chance affair is discovered
			random = {
				chance = 50

				character_event = {
					id = HF.20348
					days = 1
				}

				any_player = {
					limit = {
						has_opinion_modifier = {
							name = opinion_coronation_guest
							who = ROOT
						}
					}

					character_event = {
						id = HF.20349
						days = 1
					}
				}
			}
		}

		ai_chance = {
			factor = 80

			trigger = {
				NOT = { trait = homosexual }
			}

			mult_modifier = {
				factor = 0.25
				is_married = yes
			}

			mult_modifier = {
				factor = 0.25
				has_lover = yes
			}

			mult_modifier = {
				factor = 0.5
				event_target:coronation_knight = { has_ugly_trait_trigger = yes }
			}

			mult_modifier = {
				factor = 0.5
				event_target:coronation_knight = { trait = weak }
			}
		}
	}

	option = { # Let's just be friends
		name = EVTOPTBHF20347
		tooltip_info = diplomacy

		trigger = { diplomacy >= 10 }

		add_friend = event_target:coronation_knight

		ai_chance = { factor = 10 }
	}

	option = {
		name = EVTOPTCHF20347

		custom_tooltip = {
			text = EVTTOOLTIPBHF20347

			event_target:coronation_knight = {
				death = { death_reason = death_missing }
			}
		}

		ai_chance = { factor = 10 }
	}
}

# Queen: your affair with the knight has been discovered
character_event = {
	id = HF.20348
	desc = EVTDESCHFA20348
	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_knight = { is_alive = yes } # Check if the knight is still alive
	}

	option = {
		name = EVTOPTAHF20348

		piety = -50

		if = {
			limit = {
				is_married = yes
				NOT = { has_character_modifier = adulteress }
			}

			add_character_modifier = {
				name = adulteress
				duration = -1
			}

			reverse_opinion = {
				name = opinion_cuckolded
				who = spouse
				years = 100
			}
		}
	}
}

# Crowning guest: the Queen's affair has been revealed
character_event = {
	id = HF.20349
	desc = EVTDESCHFA20349
	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
		event_target:coronation_knight = { is_alive = yes } # Check if the knight is still alive
	}

	option = {
		name = EVTOPTAHF20349
	}
}

# Child Ruler: the knight wants to teach you combat
character_event = {
	id = HF.20350
	desc = EVTDESCHFA20350
	picture = GFX_evt_child_sword
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_knight = { is_alive = yes } # Check if the knight is still alive
	}

	option = {
		name = EVTOPTAHF20350

		change_martial = 2

		if = {
			limit = {
				NOR = {
					trait = brawny
					trait = frail
				}
			}

			random = {
				chance = 25
				add_trait = brawny
			}
		}

		ai_chance = {
			factor = 80

			mult_modifier = {
				factor = 0.5
				trait = indolent
			}
		}
	}

	option = {
		name = EVTOPTBHF20350

		prestige = 100

		if = {
			limit = {
				NOR = {
					trait = willful
					trait = timid
				}
			}

			random = {
				chance = 25
				add_trait = willful
			}
		}

		ai_chance = {
			factor = 20

			trigger = {
				NOT = { trait = rowdy }
			}
		}
	}
}

# Ruler: A wandering priest has come to offer his services
character_event = {
	id = HF.20351
	desc = EVTDESCHFA20351
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_wandering_priest

		create_random_priest = {
			random_traits = yes
			dynasty = none
			culture = ROOT
			religion = ROOT
			female = no
			age = 37

			attributes = {
				learning = 15
				diplomacy = 10
			}
		}

		new_character = {
			save_event_target_as = coronation_scholar

			remove_lifestyle_trait_effect = yes
			remove_trait = slow
			remove_trait = imbecile
			remove_trait = dull

			remove_trait = craven
			add_trait = brave

			random = {
				chance = 10
				add_trait = zealous
			}

			random = {
				chance = 30
				add_trait = temperate
			}

			random = {
				chance = 30
				add_trait = diligent
			}

			random = {
				chance = 40
				add_trait = scholar
			}

			if = {
				limit = { has_dlc = "Mystics" }

				random_list = {
					50 = { join_society = monastic_order_benedictine }
					50 = { join_society = monastic_order_dominican }
				}
			}
		}
	}

	option = {
		name = EVTOPTAHF20351
		tooltip_info = learning

		trigger = {
			OR = {
				learning >= 10
				has_education_learning_trigger = yes
			}
		}

		change_learning = 2
		piety = 30

		event_target:coronation_scholar = {
			show_scope_change = no

			move_character = ROOT

			opinion = {
				name = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}

		ai_chance = { factor = 100 }
	}

	option = {
		name = EVTOPTBHF20351

		event_target:coronation_scholar = {
			show_scope_change = no

			move_character = ROOT

			opinion = {
				name = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}

		ai_chance = { factor = 50 }
	}

	option = {
		name = EVTOPTCHF20351

		hidden_effect = {
			event_target:coronation_scholar = {
				death = { death_reason = death_missing }
			}
		}

		ai_chance = { factor = 0 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Envious/Hateful Vassal guest becomes rival of host (or shows older rivalry)
character_event = {
	id = HF.20352
	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20352
		trigger = {
			NOT = { is_rival = FROM }
		}
	}
	desc = {
		text = EVTDESCHFB20352
		trigger = { is_rival = FROM }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20352

		if = {
			limit = { NOT = { is_rival = FROM } }
			add_rival = FROM
			set_character_flag = flag_new_rivalry
		}

		FROM = {
			character_event = { id = HF.20353 }
		}
	}

	option = {
		name = EVTOPTBHF20352

		trigger = {
			NOT = { is_rival = FROM }
		}

		ai_chance = { factor = 0 }
	}
}

# Ruler: one of your vassals has become your rival
character_event = {
	id = HF.20353
	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20353
		trigger = {
			FROM = { NOT = { has_character_flag = flag_new_rivalry } }
		}
	}
	desc = {
		text = EVTDESCHFB20353
		trigger = {
			FROM = { has_character_flag = flag_new_rivalry }
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_random_rivalry
	}

	option = {
		name = EVTOPTAHF20353
		tooltip_info = diplomacy

		trigger = { diplomacy >= 10 }

		FROM = {
			character_event = { id = HF.20354 }
		}
	}

	option = {
		name = EVTOPTBHF20353

		add_rival = FROM

		ai_chance = {
			factor = 1

			trigger = { diplomacy < 10 }
		}
	}

	after = {
		FROM = { clr_character_flag = flag_new_rivalry }

		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Rival Vassal: Ruler has convinced you to not be his rival anymore
character_event = {
	id = HF.20354
	desc = EVTDESCHFA20354
	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	hide_new = yes
	is_triggered_only = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20354

		remove_rival = FROM
	}
}

# Secluded Ruler: poor coronation makes you embarassed. Chance for paranoid or stressed.
character_event = {
	id = HF.20355
	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20355
		trigger = { war = no }
	}
	desc = {
		text = EVTDESCHFB20355
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_secluded_embarassed
	}

	option = {
		name = EVTOPTAHF20355

		prestige = -75
		add_trait_fully_silently_paranoid_effect = yes
	}

	option = {
		name = EVTOPTBHF20355

		if = {
			limit = { trait = stressed }
			piety = -30
		}
		else = {
			random = {
				chance = 50
				add_trait_stressed_effect = yes
			}
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Secluded Ruler: poor coronation makes the uninvited vassals unhappy
character_event = {
	id = HF.20356
	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20356
		trigger = { war = no }
	}
	desc = {
		text = EVTDESCHFB20356
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_secluded_vassals
	}

	option = {
		name = EVTOPTAHF20356

		custom_tooltip = {
			text = tooltip_EVTHF20356_A

			any_vassal = {
				limit = { is_councillor = no }
				character_event = { id = HF.20357 }
			}
		}

		prestige = -35
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Uninvited vassal of secluded coronation is unhappy with his liege
character_event = {
	id = HF.20357
	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20357
		trigger = { war = no }
	}
	desc = {
		text = EVTDESCHFB20357
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20357

		opinion = {
			who = FROM
			name = opinion_offended
			years = 5
		}
	}
}

# Ruler: Coronation_priest is unhappy with secluded coronation
character_event = {
	id = HF.20358
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20358
		trigger = {
			event_target:coronation_priest = { lower_real_tier_than = KING }
		}
	}
	desc = {
		text = EVTDESCHFB20358
		trigger = {
			war = no
			event_target:coronation_priest = { higher_real_tier_than = DUKE }
		}
	}
	desc = {
		text = EVTDESCHFC20358 # Papal Envoy
		picture = GFX_evt_mounted_combat_day_hf
		trigger = {
			war = yes
			event_target:coronation_priest = { higher_real_tier_than = DUKE }
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_secluded_priest
	}

	option = {
		name = {
			text = EVTOPTAHF20358
			trigger = {
				OR = {
					war = yes
					event_target:coronation_priest = { lower_real_tier_than = KING }
				}
			}
		}
		name = {
			text = EVTOPTAHF20358_B
			trigger = {
				war = no
				event_target:coronation_priest = { higher_real_tier_than = DUKE }
			}
		}
		tooltip_info = diplomacy

		trigger = { diplomacy >= 10 }

		event_target:coronation_priest = {
			show_scope_change = no

			if = {
				limit = { higher_real_tier_than = DUKE }

				add_character_modifier = {
					name = mud_splatter
					months = 4
				}
			}
		}

		ai_chance = { factor = 90 }
	}

	option = {
		name = {
			text = EVTOPTBHF20358
			trigger = {
				OR = {
					war = yes
					event_target:coronation_priest = { lower_real_tier_than = KING }
				}
			}
		}
		name = {
			text = EVTOPTBHF20358_B
			trigger = {
				war = no
				event_target:coronation_priest = { higher_real_tier_than = DUKE }
			}
		}

		piety = -75

		event_target:coronation_priest = {
			show_scope_change = no

			if = {
				limit = { higher_real_tier_than = DUKE }

				add_character_modifier = {
					name = mud_splatter
					months = 4
				}
			}

			opinion = {
				name = opinion_very_disappointed
				who = ROOT
				years = 20
			}
		}

		any_player = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}
			}

			character_event = { id = HF.20359 }
		}

		ai_chance = { factor = 10 }
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Guests of secluded ceremony informed that coronation_priest dislikes it
character_event = {
	id = HF.20359
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20359
		trigger = { war = no }
	}
	desc = {
		text = EVTDESCHFB20359
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes
	hide_new = yes

	ai = no

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20359
	}
}

# Ruler depressed by secluded coronation, chance to lose ambitious or gain slothful
character_event = {
	id = HF.20360
	desc = EVTDESCHFA20360
	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_secluded_ambitious
	}

	option = {
		name = EVTOPTAHF20360

		trigger = { trait = ambitious }

		prestige = -35

		random = {
			chance = 50
			remove_trait_ambitious_effect = yes
		}
	}

	option = {
		name = EVTOPTBHF20360

		random = {
			chance = 50

			if = {
				limit = { trait = slothful }
				piety = -50
			}
			else = {
				add_trait_partially_slothful_effect = yes
			}
		}
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Proud Ruler humbled by secluded coronation
character_event = {
	id = HF.20361
	desc = EVTDESCHFA20361
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_secluded_proud
	}

	option = {
		name = EVTOPTAHF20361

		add_trait_fully_silently_humble_effect = yes
	}

	option = {
		name = EVTOPTBHF20361

		piety = -100
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Ruler in secluded Coronation mad at Steward
character_event = {
	id = HF.20362
	desc = EVTDESCHFA20362
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:lazy_treasurer

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		# To avoid the same event happening twice during the coronation
		set_character_flag = flag_coronation_secluded_steward

		job_treasurer = {
			save_event_target_as = lazy_treasurer
		}
	}

	option = {
		name = EVTOPTAHF20362

		event_target:lazy_treasurer = {
			show_scope_change = no

			add_rival = ROOT
			character_event = { id = HF.20363 }
		}
	}

	option = {
		name = EVTOPTBHF20362

		prestige = -100
	}

	after = {
		character_event = {
			id = HF.20365 # Second row of random events, else coronation itself
			days = 3
			random = 5
		}
	}
}

# Notify Steward of new rivalry
character_event = {
	id = HF.20363
	desc = EVTDESCHFA20363
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	option = {
		name = EVTOPTAHF20363

		add_rival = FROM
	}
}

# HF.20364 already taken by previous doubled event

# Hidden event fired twice at different days, holding the scripted_effect containing the long random_list of possible events that can happen during the ceremony.
character_event = {
	id = HF.20365

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}

		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}

		NOR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}

		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
	}

	immediate = {
		if = {
			limit = {
				check_variable = {
					which = coronation_count
					value >= 2
				}
			}

			character_event = {
				id = HF.20366 # THE CORONATION ITSELF
				days = 15
			}
		}
		else = {
			change_variable = {
				which = coronation_count
				value = 1
			}

			random_list = {
				# King befriends foreign ruler
				# King befriends vassal
				# King's new acquaintances improve his diplomacy/stewardship
				# King's new acquaintances improve his intrigue/learning
				# King's diplomacy helps him improve opinion of all guests
				# King's new resolve makes him lose slothful/content
				# Proud King's trepidation makes him gain ambitious
				# Child King's flattered and can become haughty or conscientious
				# The coronation_priest approves of the ceremony
				# Temperate/Celibate coronation_priest disapproves of the extravagant ceremony
				# HRE/Francia Emperor gets a talk from the priest about being the heir of Charlemagne (chance for prestige, learning, diligent)
				# The Pope talks to the King about his duties as protector of Christendom (chance to gain zealous, cynical, learning)
				# Child king is taught by foreign ruler about stewardship
				# Two foreign Kings (guests) become (or are) rivals, coronation_ruler with high diplomacy can help them lose rivalry and become his friends
				# Cynical vassal (or wicked priest) annoys the coronation_priest. High diplomacy ruler may help and gain gregarious
				# A knight comes to pledge his service to the new King/Emperor, if ruler is female/child, chance to become friend/lover or increase martial
				# A wise priest joins the court
				# King becomes rival of one of his vassals

				# King is embarrassed by secluded coronation, chance to gain stressed or paranoid
				# King's vassals are offended by secluded coronation (chance to avoid with high diplomacy)
				# Coronation_priest is disappointed by secluded ceremony
				# King is distraught by secluded ceremony (chance to lose ambitious, gain content/slothful)
				# King reflects upon secluded coronation (chance to lose proud, gain humble)
				# King's Councillor becomes his rival due to secluded coronation

				1 = { # No events
					mult_modifier = {
						factor = 0.1
						has_character_flag = flag_extravagant_coronation
					}

					event_target:coronation_ruler = {
						character_event = {
							id = HF.20366 # Directly fire coronation
							days = 15
						}
					}
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_foreign_friendship
							has_character_flag = flag_secluded_coronation
							num_of_friends >= 3
						}

						any_independent_ruler = {
							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							NOR = {
								is_rival = ROOT
								is_friend = ROOT
								is_lover = ROOT
								is_married = ROOT
								num_of_friends >= 3
							}

							opinion = {
								who = FROM
								value >= -20
							}
						}
					}

					mult_modifier = {
						factor = 2
						num_of_friends > 1
					}

					mult_modifier = {
						factor = 1.5
						real_tier = EMPEROR
					}

					mult_modifier = {
						factor = 1.5
						trait = gregarious
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					character_event = { id = HF.20306 } # Frendship with foreign ruler guest
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_vassal_friendship
							num_of_friends >= 3
						}

						any_vassal = {
							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							NOR = {
								is_rival = ROOT
								is_friend = ROOT
								is_lover = ROOT
								is_married = ROOT
								num_of_friends >= 3
							}

							opinion = {
								who = FROM
								value >= -20
							}
						}
					}

					mult_modifier = {
						factor = 2
						num_of_friends < 1
					}

					mult_modifier = {
						factor = 1.5
						real_tier = EMPEROR
					}

					mult_modifier = {
						factor = 1.5
						trait = gregarious
					}

					mult_modifier = {
						factor = 0.1
						has_character_flag = flag_secluded_coronation
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					character_event = { id = HF.20310 } # Frendship with vassal guest
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_diplomacy_boost
							has_character_flag = flag_secluded_coronation
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.5
						trait = gregarious
					}

					character_event = { id = HF.20311 } # Increase diplomacy/stewardship
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_learning_boost
							has_character_flag = flag_secluded_coronation
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.5
						trait = shy
					}

					character_event = { id = HF.20314 } # Increase intrigue/learning
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_guest_opinions
							has_character_flag = flag_secluded_coronation
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.5
						trait = gregarious
					}

					mult_modifier = {
						factor = 0.75
						diplomacy < 10
					}

					character_event = { id = HF.20316 } # Improve guests opinion
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_gain_diligent
							has_character_flag = flag_secluded_coronation
						}

						OR = {
							trait = content
							trait = slothful
						}
					}

					mult_modifier = {
						factor = 2

						trait = content
						trait = slothful
					}

					character_event = { id = HF.20321 } # Gain diligent
				}

				4 = {
					trigger = {
						trait = proud

						NOR = {
							has_character_flag = flag_coronation_gain_ambitious
							has_character_flag = flag_secluded_coronation
							trait = ambitious
						}
					}

					mult_modifier = {
						factor = 2
						has_character_flag = flag_extravagant_coronation
					}

					character_event = { id = HF.20322 } # Gain ambitious
				}

				4 = {
					trigger = {
						is_adult = no

						NOR = {
							has_character_flag = flag_coronation_haughty_child
							has_character_flag = flag_secluded_coronation
						}
					}

					mult_modifier = {
						factor = 2
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.5

						NOR = {
							trait = haughty
							trait = conscientious
						}
					}

					character_event = { id = HF.20323 } # Child becomes haughty
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_priest_approves
							has_character_flag = flag_coronation_priest_disapproves # Can't approve and disapprove within the course of the same ceremony
							has_character_flag = flag_secluded_coronation
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.75
						event_target:coronation_priest = { trait = hedonist }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { trait = gluttonous }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { trait = drunkard }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { trait = gregarious }
					}

					character_event = { id = HF.20324 } # Priest approves of ceremony
				}

				4 = {
					trigger = {
						has_landed_title = e_hre

						NOR = {
							has_character_flag = flag_coronation_hre_talk
							has_character_flag = is_charlemagne # Shouldn't happen anyway, but, just to be safe...
						}
					}

					mult_modifier = {
						factor = 0.5
						has_character_flag = flag_secluded_coronation
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { trait = zealous }
					}

					character_event = { id = HF.20326 } # Priest talks about responsibilities of HRE
				}

				4 = {
					trigger = {
						NOT = { has_character_flag = flag_coronation_pope_talk }

						event_target:coronation_priest = {
							has_landed_title = k_papacy
						}
					}

					mult_modifier = {
						factor = 0.5
						has_character_flag = flag_secluded_coronation
					}

					mult_modifier = {
						factor = 2
						has_character_flag = flag_extravagant_coronation
					}

					character_event = { id = HF.20327 } # Pope talks about responsibilities of Christian King
				}

				4 = {
					trigger = {
						is_adult = no

						NOR = {
							has_character_flag = flag_coronation_foreign_teacher
							has_character_flag = flag_secluded_coronation
						}

						any_independent_ruler = {
							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							NOT = { is_rival = ROOT }
							stewardship >= 8

							opinion = {
								who = ROOT
								value > 0
							}
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					random_independent_ruler = {
						limit = {
							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							NOT = { is_rival = ROOT }
							stewardship >= 8

							opinion = {
								who = ROOT
								value >= 0
							}
						}

						character_event = { id = HF.20328 } # Foreign ruler teaches child statemanship
					}
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_priest_disapproves
							has_character_flag = flag_coronation_priest_approves # Can't approve and disapprove within the course of the same ceremony
							has_character_flag = flag_secluded_coronation # This event is for disapproving of excess
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 0.25

						NOR = {
							trait = hedonist
							trait = drunkard
							trait = gluttonous
						}
					}

					mult_modifier = {
						factor = 1.5
						trait = hedonist
					}

					mult_modifier = {
						factor = 1.5
						trait = gluttonous
					}

					mult_modifier = {
						factor = 1.5
						trait = drunkard
					}

					mult_modifier = {
						factor = 0.1
						event_target:coronation_priest = { trait = hedonist }
					}

					mult_modifier = {
						factor = 0.5
						event_target:coronation_priest = { trait = gluttonous }
					}

					mult_modifier = {
						factor = 0.5
						event_target:coronation_priest = { trait = drunkard }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { trait = temperate }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { trait = celibate }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { lower_real_tier_than = KING }
					}

					mult_modifier = {
						factor = 1.5
						event_target:coronation_priest = { religion = fraticelli }
					}

					character_event = { id = HF.20332 } # Priests disapproves of ceremony
				}

				4 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_diplomatic_incident
							has_character_flag = flag_secluded_coronation
						}

						any_independent_ruler = {
							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								any_rival = {
									independent = yes

									has_opinion_modifier = {
										name = opinion_coronation_guest
										who = event_target:coronation_ruler
									}
								}

								any_independent_ruler = {
									has_opinion_modifier = {
										name = opinion_coronation_guest
										who = event_target:coronation_ruler
									}

									reverse_opinion = {
										who = PREV
										value < -30
									}
								}
							}
						}
					}

					random_independent_ruler = { # Check for two potential rivals amongst the foreign guests at the coronation ceremony
						limit = {
							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								any_rival = {
									independent = yes

									has_opinion_modifier = {
										name = opinion_coronation_guest
										who = event_target:coronation_ruler
									}
								}

								any_independent_ruler = {
									has_opinion_modifier = {
										name = opinion_coronation_guest
										who = event_target:coronation_ruler
									}

									reverse_opinion = {
										who = PREV
										value < -30
									}
								}
							}
						}

						character_event = { id = HF.20334 } # Foreign ruler guests are rivals
					}
				}

				# One version for vassal guests, one for foreign guests
				2 = {
					trigger = {
						NOR = {
							has_character_flag = flag_coronation_cynic_taunts
							has_character_flag = flag_secluded_coronation
						}

						any_independent_ruler = {
							NOR = {
								character = event_target:coronation_priest
								character = event_target:coronation_ruler
							}

							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								trait = cynical
								trait = bad_priest_christian
							}
						}
					}

					mult_modifier = {
						factor = 0.75
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 0.5

						NOT = { # Prefer higher tier independent rulers
							any_independent_ruler = {
								higher_real_tier_than = COUNT

								NOR = {
									character = event_target:coronation_priest
									character = event_target:coronation_ruler
								}

								has_opinion_modifier = {
									name = opinion_coronation_guest
									who = ROOT
								}

								OR = {
									trait = cynical
									trait = bad_priest_christian
								}
							}
						}
					}

					random_independent_ruler = {
						limit = {
							NOR = {
								character = event_target:coronation_priest
								character = event_target:coronation_ruler
							}

							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								trait = cynical
								trait = bad_priest_christian
							}
						}

						preferred_limit = {
							higher_real_tier_than = DUKE

							OR = {
								trait = possessed
								trait = lunatic
							}
						}

						preferred_limit = {
							higher_real_tier_than = DUKE
						}

						character_event = { id = HF.20342 } # Cynic/wicked foreign guest offends the coronation_priest
					}
				}

				2 = {
					trigger = {
						NOT = { has_character_flag = flag_coronation_cynic_taunts }

						any_vassal = {
							NOR = {
								character = event_target:coronation_priest
								character = event_target:coronation_ruler
							}

							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								trait = cynical
								trait = bad_priest_christian
							}
						}
					}

					random_vassal = {
						limit = {
							NOT = { character = event_target:coronation_priest }

							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								trait = cynical
								trait = bad_priest_christian
							}
						}

						character_event = { id = HF.20342 } # Cynic/wicked vassal guest offends the coronation_priest
					}
				}

				4 = {
					trigger = {
						NOT = { has_character_flag = flag_coronation_wandering_knight }
					}

					mult_modifier = {
						factor = 0.25
						has_character_flag = flag_secluded_coronation
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.25
						is_female = yes
					}

					mult_modifier = {
						factor = 1.25
						is_adult = no
					}

					mult_modifier = {
						factor = 1.5
						real_tier = EMPEROR
					}

					character_event = { id = HF.20346 } # Wandering knight reaches court
				}

				4 = {
					trigger = {
						NOT = { has_character_flag = flag_coronation_wandering_priest }
					}

					mult_modifier = {
						factor = 0.5
						has_character_flag = flag_secluded_coronation
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					mult_modifier = {
						factor = 1.5
						real_tier = EMPEROR
					}

					mult_modifier = {
						factor = 1.5
						piety >= 300
					}

					character_event = { id = HF.20351 } # Wandering priest reaches court
				}

				4 = {
					trigger = {
						NOT = { has_character_flag = flag_coronation_random_rivalry }

						any_vassal = {
							NOT = { character = event_target:coronation_priest }

							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								trait = envious
								is_rival = ROOT

								opinion = {
									who = ROOT
									value >= -30
								}
							}
						}
					}

					mult_modifier = {
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}

					random_vassal = {
						limit = {
							NOT = { character = event_target:coronation_priest }

							has_opinion_modifier = {
								name = opinion_coronation_guest
								who = ROOT
							}

							OR = {
								trait = envious
								is_rival = ROOT

								opinion = {
									who = ROOT
									value >= -30
								}
							}
						}

						character_event = { id = HF.20352 } # Envious/Hateful vassal shows rivalry
					}
				}

				4 = {
					trigger = {
						has_character_flag = flag_secluded_coronation

						NOR = {
							has_character_flag = flag_coronation_secluded_embarassed
							trait = stressed
							trait = paranoid
						}
					}

					character_event = { id = HF.20355 } # Secluded coronation: ruler embarassed
				}

				4 = {
					trigger = {
						has_character_flag = flag_secluded_coronation
						NOT = { has_character_flag = flag_coronation_secluded_vassals }
					}

					character_event = { id = HF.20356 } # Secluded coronation: uninvited vassals are upset
				}

				4 = {
					trigger = {
						has_character_flag = flag_secluded_coronation
						NOT = { has_character_flag = flag_coronation_secluded_priest }
					}

					character_event = { id = HF.20358 } # Secluded coronation: priest is upset of poor ceremony
				}

				4 = {
					trigger = {
						has_character_flag = flag_secluded_coronation
						war = no

						NOR = {
							has_character_flag = flag_coronation_secluded_ambitious
						}
					}

					mult_modifier = {
						factor = 0.25
						NOT = { trait = ambitious }
					}

					character_event = { id = HF.20360 } # Secluded coronation: ruler loses ambition
				}

				4 = {
					trigger = {
						has_character_flag = flag_secluded_coronation
						war = no

						NOR = {
							has_character_flag = flag_coronation_secluded_proud
							trait = humble
						}
					}

					mult_modifier = {
						factor = 0.25
						NOT = { trait = proud }
					}

					character_event = { id = HF.20361 } # Secluded coronation: ruler humbled
				}

				4 = {
					trigger = {
						has_character_flag = flag_secluded_coronation
						war = no

						job_treasurer = {
							employer = {
								character = ROOT
							}
						}

						NOR = {
							has_character_flag = flag_coronation_secluded_steward

							job_treasurer = {
								is_rival = ROOT
							}
						}
					}

					character_event = { id = HF.20362 } # Secluded coronation: ruler hates steward for poor ceremony
				}
			}
		}
	}
}

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

# CORONATION EVENT
character_event = {
	id = HF.20366
	title = EVTTITLE20366
	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20366 # Top localization for a Holy Roman Emperor crowned by the Pope (not in a barn)
		picture = GFX_evt_found_hre
		trigger = {
			OR = {
				has_landed_title = e_hre
				has_landed_title = e_francia
			}

			has_character_flag = flag_crowned_by_pope
			NOT = { has_character_flag = flag_secluded_coronation }
			war = no
		}
	}
	desc = {
		text = EVTDESCHFB20366 # Localization for any adult Emperor crowned by the Pope (not in a barn)
		picture = GFX_evt_found_hre
		trigger = {
			real_tier = EMPEROR
			has_character_flag = flag_crowned_by_pope
			is_adult = yes
			war = no

			NOR = {
				has_character_flag = flag_secluded_coronation
				has_landed_title = e_hre
				has_landed_title = e_francia
			}
		}
	}
	desc = {
		text = EVTDESCHFC20366 # Localization for any child Emperor crowned by the Pope (not in a barn)
		picture = GFX_evt_found_hre
		trigger = {
			real_tier = EMPEROR
			is_adult = no
			has_character_flag = flag_crowned_by_pope
			war = no

			NOR = {
				has_landed_title = e_hre
				has_landed_title = e_francia
				has_character_flag = flag_secluded_coronation
			}
		}
	}
	desc = {
		text = EVTDESCHFD20366 # Localization for any adult Ruler crowned by the Pope (not in a barn)
		trigger = {
			has_character_flag = flag_crowned_by_pope
			real_tier = KING
			is_adult = yes
			war = no
			NOT = { has_character_flag = flag_secluded_coronation }
		}
	}
	desc = {
		text = EVTDESCHFE20366 # Localization for any child Ruler crowned by the Pope (not in a barn)
		trigger = {
			has_character_flag = flag_crowned_by_pope
			real_tier = KING
			is_adult = no
			war = no
			NOT = { has_character_flag = flag_secluded_coronation }
		}
	}
	desc = {
		text = EVTDESCHFF20366 # Localization for any adult ruler crowned by a Bishop or Priest (not in a barn)
		trigger = {
			is_adult = yes
			war = no

			NOR = {
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
			}
		}
	}
	desc = {
		text = EVTDESCHFG20366 # Localization for any child ruler crowned by a Bishop or Priest (not in a barn)
		trigger = {
			is_adult = no
			war = no

			NOR = {
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
			}
		}
	}
	desc = {
		text = EVTDESCHFH20366 # Localization for any adult ruler crowned by the Pope in a barn
		trigger = {
			has_character_flag = flag_secluded_coronation
			has_character_flag = flag_crowned_by_pope
			is_adult = yes
			war = no
		}
	}
	desc = {
		text = EVTDESCHFI20366 # Localization for any child ruler crowned by the Pope in a barn
		trigger = {
			is_adult = no
			has_character_flag = flag_crowned_by_pope
			has_character_flag = flag_secluded_coronation
			war = no
		}
	}
	desc = {
		text = EVTDESCHFL20366 # Localization for any ruler crowned by a Bishop or Priest in a barn
		trigger = {
			has_character_flag = flag_secluded_coronation
			war = no
			NOT = { has_character_flag = flag_crowned_by_pope }
		}
	}
	desc = {
		text = EVTDESCHFM20366 # War Coronation description
		picture = GFX_evt_mounted_combat_day_hf
		trigger = {
			war = yes
			NOT = { has_character_flag = flag_crowned_by_pope }
		}
	}

	desc = {
		text = EVTDESCHFN20366 # War Coronation description
		picture = GFX_evt_mounted_combat_day_hf
		trigger = {
			war = yes
			has_character_flag = flag_crowned_by_pope
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		character = event_target:coronation_ruler
		NOT = { has_character_flag = flag_being_coronated }
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive

		OR = {
			religion = catholic
			religion = fraticelli
		}

		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}

		NOR = {
			trait = crowned_by_myself
			trait = crowned_by_pope
			trait = crowned_by_bishop
			trait = crowned_by_priest
		}
	}


	immediate = {
		if = {
			limit = {
				has_character_flag = flag_secluded_coronation
				war = no
			}
			sound_effect = coronation_barn
		}
		else_if = {
			limit = { has_character_flag = flag_extravagant_coronation }
			sound_effect = coronation_extravagant
		}
		else = {
			sound_effect = coronation_normal
		}

		remove_trait = uncrowned

		set_character_flag = flag_being_coronated # Safety check to avoid double event

		# Needed to localize the trait properly
		save_persistent_event_target = {
			name = coronation_priest_per
			scope = event_target:coronation_priest
		}
	}

	option = { # Napoleon option
		name = EVTOPTZHF20366

		trigger = {
			real_tier = EMPEROR
			religion = catholic
			is_adult = yes # Has to be strong enough to grab the crown from the Pope's clutches
			has_character_flag = flag_extravagant_coronation # Only allowed to screw everything up if you have spent the most money in it already.

			OR = {
				trait = lunatic
				trait = possessed
				society_member_of = the_satanists

				trigger_if = {
					limit = { trait = ambitious }

					OR = {
						has_law = imperial_administration
						has_law = ze_administration_laws_2
					}
				}
			}
		}

		add_trait = crowned_by_myself
		remove_trait = uncrowned

		add_character_modifier = {
			name = extravagant_coronation
			years = 20
		}

		# Notify all guests, then conclude the ceremony
		character_event = { id = HF.20371 } # Self-Coronation scandal
		character_event = { id = HF.20369 days = 3 random = 3 } # Wrap up, clear all flags

		any_vassal = {
			if = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = ROOT
					}
				}

				character_event = { id = HF.20371 } # Self-Coronation event for guests
				character_event = { id = HF.20370 days = 3 random = 3 } # Wrap up, clear all flags
			}
			else = {
				character_event = { id = HF.20371 } # Self-Coronation event for vassals who did not attend to the ceremony
			}
		}

		any_independent_ruler = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}
			}

			character_event = { id = HF.20371 } # Coronation event for guests.
			character_event = { id = HF.20370 days = 3 random = 3 } # Wrap up, clear all flags
		}

		if = {
			limit = {
				ai = no
				is_ironman = yes
			}

			set_character_flag = achievement_leglise_cest_moi
		}

		ai_chance = { factor = 5 }
	}

	option = {
		name = EVTOPTAHF20366

		hidden_effect = {
			remove_trait = uncrowned
		}

		# Assign proper trait
		trigger_switch = {
			on_trigger = has_character_flag

			flag_crowned_by_pope = {
				custom_tooltip = {
					text = tooltip_gain_crowned_by_pope
					add_trait = crowned_by_pope
				}
			}

			flag_crowned_by_bishop = {
				custom_tooltip = {
					text = tooltip_gain_crowned_by_bishop
					add_trait = crowned_by_bishop
				}
			}

			flag_crowned_by_priest = {
				custom_tooltip = {
					text = tooltip_gain_crowned_by_priest
					add_trait = crowned_by_priest
				}
			}
		}

		# Assign possible modifier
		if = {
			limit = {
				war = no
				has_character_flag = flag_secluded_coronation
				NOT = { has_character_flag = flag_crowned_by_pope }
			}

			add_character_modifier = {
				name = crowned_in_barn
				duration = -1
			}
		}
		else_if = {
			limit = {
				war = yes
				has_character_flag = flag_secluded_coronation
			}

			add_character_modifier = {
				name = crowned_in_war
				duration = -1
			}
		}

		if = {
			limit = {
				has_character_flag = flag_extravagant_coronation
				NOT = { has_character_flag = flag_crowned_by_priest }
			}

			add_character_modifier = {
				name = extravagant_coronation
				years = 2
			}
		}

		# Notify all guests, then conclude the ceremony
		character_event = { id = HF.20369 days = 3 random = 3 } # Wrap up, clear all flags

		any_vassal = {
			if = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = ROOT
					}
				}

				character_event = { id = HF.20367 } # Coronation event for guests
				character_event = { id = HF.20370 days = 3 random = 3 } # Wrap up, clear all flags
			}
			else = {
				character_event = { id = HF.20368 } # Smaller notification for vassals who did not attend to the ceremony
			}
		}

		any_independent_ruler = {
			limit = {
				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = ROOT
				}
			}

			character_event = { id = HF.20367 } # Coronation event for guests
			character_event = { id = HF.20370 days = 3 random = 3 } # Wrap up, clear all flags
		}

		ai_chance = { factor = 95 }
	}

	after = {
		hidden_effect = { remove_character_modifier = coronation_request_cooldown }
		clr_character_flag = flag_being_coronated
	}
}

# CORONATION EVENT (for guests)
character_event = {
	id = HF.20367
	title = EVTTITLE20366
	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20367 # Top localization for an Holy Roman Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
		trigger = {
			FROM = {
				OR = {
					has_landed_title = e_hre
					has_landed_title = e_francia
				}

				war = no
				has_character_flag = flag_crowned_by_pope
				NOT = { has_character_flag = flag_secluded_coronation }
			}
		}
	}
	desc = {
		text = EVTDESCHFB20367 # Localization for any adult Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
		trigger = {
			FROM = {
				real_tier = EMPEROR
				has_character_flag = flag_crowned_by_pope
				is_adult = yes
				war = no

				NOR = {
					has_landed_title = e_hre
					has_landed_title = e_francia
					has_character_flag = flag_secluded_coronation
				}
			}
		}
	}
	desc = {
		text = EVTDESCHFC20367 # Localization for any child Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
		trigger = {
			FROM = {
				is_adult = no
				real_tier = EMPEROR
				has_character_flag = flag_crowned_by_pope
				war = no

				NOR = {
					has_landed_title = e_hre
					has_landed_title = e_francia
					has_character_flag = flag_secluded_coronation
				}
			}
		}
	}
	desc = {
		text = EVTDESCHFD20367 # Localization for any adult Ruler crowned by the Pope (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				has_character_flag = flag_crowned_by_pope
				real_tier = KING
				is_adult = yes
				war = no
				NOT = { has_character_flag = flag_secluded_coronation }
			}
		}
	}
	desc = {
		text = EVTDESCHFE20367 # Localization for any child Ruler crowned by the Pope (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				is_adult = no
				real_tier = KING
				has_character_flag = flag_crowned_by_pope
				war = no
				NOT = { has_character_flag = flag_secluded_coronation }
			}
		}
	}
	desc = {
		text = EVTDESCHFF20367 # Localization for any adult ruler crowned by a Bishop or Priest (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				is_adult = yes
				war = no

				NOR = {
					has_character_flag = flag_secluded_coronation
					has_character_flag = flag_crowned_by_pope
				}
			}
		}
	}
	desc = {
		text = EVTDESCHFG20367 # Localization for any child ruler crowned by a Bishop or Priest (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				is_adult = no
				war = no
				NOR = {
					has_character_flag = flag_secluded_coronation
					has_character_flag = flag_crowned_by_pope
				}
			}
		}
	}
	desc = {
		text = EVTDESCHFH20367 # Localization for any adult ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
				is_adult = yes
				war = no
			}
		}
	}
	desc = {
		text = EVTDESCHFI20367 # Localization for any child ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				is_adult = no
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
				war = no
			}
		}
	}
	desc = {
		text = EVTDESCHFL20367 # Localization for any ruler crowned by a Bishop or Priest in a barn.
		picture = GFX_evt_a_crowning_ceremony
		trigger = {
			FROM = {
				has_character_flag = flag_secluded_coronation
				war = no
				NOT = { has_character_flag = flag_crowned_by_pope }
			}
		}
	}
	desc = {
		text = EVTDESCHFM20367 # War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
		trigger = {
			FROM = {
				war = yes
				NOT = { has_character_flag = flag_crowned_by_pope }
			}
		}
	}
	desc = {
		text = EVTDESCHFN20367 # War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
		trigger = {
			FROM = {
				war = yes
				has_character_flag = flag_crowned_by_pope
			}
		}
	}

	trigger = {
		# Check if the priest supposed to be crowning you is still alive
		has_opinion_modifier = {
			name = opinion_coronation_guest
			who = event_target:coronation_ruler
		}
	}

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				FROM = {
					has_character_modifier = crowned_in_barn
					war = no
				}
			}
			sound_effect = coronation_barn
		}
		else_if = {
			limit = {
				FROM = { has_character_modifier = extravagant_coronation }
			}
			sound_effect = coronation_extravagant
		}
		else = {
			sound_effect = coronation_normal
		}
	}

	option = {
		name = EVTOPTAHF20367

		# Assign scaled piety
		if = {
			limit = { FROM = { has_character_flag = flag_crowned_by_pope } }
			piety = 10
		}
		else_if = {
			limit = { FROM = { has_character_flag = flag_crowned_by_bishop } }
			piety = 20
		}
		else_if = {
			limit = { FROM = { has_character_flag = flag_crowned_by_priest } }
			piety = 30
		}

		# Assign scaled prestige
		if = {
			limit = {
				FROM = {
					has_character_flag = flag_secluded_coronation
					NOT = { has_character_flag = flag_crowned_by_pope }
				}
			}
			prestige = -25
		}
		else_if = {
			limit = { FROM = { has_character_flag = flag_regular_coronation } }
			prestige = 50
		}
		else_if = {
			limit = {
				FROM = {
					has_character_flag = flag_extravagant_coronation
					NOT = { has_character_flag = flag_crowned_by_pope }
				}
			}
			prestige = 75
		}
		else_if = {
			limit = {
				FROM = {
					has_character_flag = flag_extravagant_coronation
					has_character_flag = flag_crowned_by_pope
				}
			}
			prestige = 100
		}
	}
}

# Notifications for vassals who did not attend
character_event = {
	id = HF.20368
	title = EVTTITLE20366
	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20368
		trigger = { war = no }
	}
	desc = {
		text = EVTDESCHFA20368
		picture = GFX_evt_mounted_combat_day_hf
		trigger = { war = yes }
	}

	is_triggered_only = yes

	trigger = {
		event_target:coronation_priest = { is_alive = yes } # Check if the priest supposed to be crowning you is still alive
		event_target:coronation_ruler = { is_alive = yes } # Check if the ruler supposed to be crowned is still alive (check for guests)
	}

	immediate = {
		if = {
			limit = {
				FROM = {
					has_character_modifier = crowned_in_barn
					war = no
				}
			}
			sound_effect = coronation_barn
		}
		else_if = {
			limit = { FROM = { has_character_modifier = extravagant_coronation } }
			sound_effect = coronation_extravagant
		}
		else = {
			sound_effect = coronation_normal
		}
	}

	option = {
		name = EVTOPTAHF20368
	}
}

# Crowned Ruler: the Coronation ceremony has concluded. END OF THE LINE. HIDDEN FOR REDUNDANCY.
character_event = {
	id = HF.20369
#	desc = EVTDESCHFA20369
#	picture = GFX_evt_pope
#	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_window = yes

	# option = {
	#	name = EXCELLENT

	immediate = {
		# Post-ceremony flavor.
		if = {
			limit = { has_character_modifier = crowned_in_barn }

			random = {
				chance = 30
				character_event = { id = HF.20388 days = 100 random = 100 } # Emperor humbled by Crowning in a barn
			}
		}

		if = {
			limit = { has_character_flag = flag_extravagant_coronation }

			random = {
				chance = 30
				character_event = { id = HF.20389 days = 50 random = 50 } # Peasants are still celebrating after the coronation. What do you do?
			}

			random = {
				chance = 30
				character_event = { id = HF.20390 days = 50 random = 50 } # Word of great coronation spreads, giving additional prestige
			}

			random = {
				chance = 30
				character_event = { id = HF.20391 days = 150 random = 150 } # Capital economy increased because of coronation
			}
		}

		set_variable = {
			which = coronation_count
			value = 0
		}

		remove_trait = travelling
		remove_character_modifier = out_traveling

		clr_character_flag = flag_preparing_coronation
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		clr_character_flag = flag_pepin_for_coronation
		clr_character_flag = flag_extravagant_coronation
		clr_character_flag = flag_regular_coronation
		clr_character_flag = flag_secluded_coronation

		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope

		clr_character_flag = flag_coronation_foreign_friendship
		clr_character_flag = flag_coronation_vassal_friendship
		clr_character_flag = flag_coronation_diplomacy_boost
		clr_character_flag = flag_coronation_learning_boost
		clr_character_flag = flag_coronation_guest_opinions
		clr_character_flag = flag_coronation_gain_diligent
		clr_character_flag = flag_coronation_gain_ambitious
		clr_character_flag = flag_coronation_haughty_child
		clr_character_flag = flag_coronation_priest_approves
		clr_character_flag = flag_coronation_hre_talk
		clr_character_flag = flag_coronation_pope_talk
		clr_character_flag = flag_coronation_foreign_teacher
		clr_character_flag = flag_coronation_priest_disapproves
		clr_character_flag = flag_coronation_diplomatic_incident
		clr_character_flag = flag_coronation_cynic_taunts
		clr_character_flag = flag_coronation_wandering_knight
		clr_character_flag = flag_coronation_wandering_priest
		clr_character_flag = flag_coronation_random_rivalry
		clr_character_flag = flag_coronation_secluded_embarassed
		clr_character_flag = flag_coronation_secluded_vassals
		clr_character_flag = flag_coronation_secluded_priest
		clr_character_flag = flag_coronation_secluded_ambitious
		clr_character_flag = flag_coronation_secluded_proud
		clr_character_flag = flag_coronation_secluded_steward
	}
}

# Coronation Guest: the Coronation ceremony has concluded. END OF THE LINE.
character_event = {
	id = HF.20370
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFB20370
		trigger = { FROM = { war = no } }
	}
	desc = {
		text = EVTDESCHFC20370
		trigger = { FROM = {  war = yes } }
		picture = GFX_evt_mounted_combat_day_hf
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20370

		if = {
			limit = { trait = travelling }
			remove_trait = travelling
		}

		if = {
			limit = { has_character_modifier = out_traveling }
			remove_character_modifier = out_traveling
		}

		hidden_effect = {
			remove_opinion = {
				name = opinion_coronation_guest
				who = FROM
			}
		}

		if = {
			limit = {
				independent = yes
				FROM = { has_character_modifier = extravagant_coronation }
				higher_real_tier_than = DUKE

				OR = {
					has_character_modifier = crowned_in_barn

					NOR = {
						trait = crowned_by_priest
						trait = crowned_by_bishop
						trait = crowned_by_pope
						trait = crowned_by_myself
					}
				}
			}

			character_event = {
				id = HF.20392 # Envious ruler who isn't crowned or is crowned in barn is upset that his host had a good coronation
				days = 50
				random = 50
			}
		}
	}
}

# Crazy Napoleon ruler snatched the crown from the Pope's hands and crowned himself Emperor
character_event = {
	id = HF.20371
	title = EVTTITLE20371
	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20371
		trigger = { character = FROM } # Ruler
	}
	desc = {
		text = EVTDESCHFB20371
		trigger = {
			has_opinion_modifier = { # Guests
				name = opinion_coronation_guest
				who = event_target:coronation_ruler
			}
		}
	}
	desc = {
		text = EVTDESCHFC20371
		trigger = {
			vassal_of = FROM

			NOR = {
				character = FROM
				has_opinion_modifier = { # Vassals who did not attend
					name = opinion_coronation_guest
					who = event_target:coronation_ruler
				}
			}
		}
	}

	is_triggered_only = yes

	trigger = {
		OR = {
			character = FROM # Ruler
			vassal_of = FROM # Vassals

			has_opinion_modifier = { # Guests
				name = opinion_coronation_guest
				who = event_target:coronation_ruler
			}
		}
	}

	option = {
		name = EVTOPTAHF20371

		trigger = { character = FROM }

		add_trait = excommunicated
		prestige = 400
		piety = -250
	}

	option = {
		name = EVTOPTBHF20371

		trigger = {
			has_opinion_modifier = {
				name = opinion_coronation_guest
				who = event_target:coronation_ruler
			}
		}
	}

	option = {
		name = EVTOPTCHF20371

		trigger = {
			vassal_of = FROM

			NOR = {
				character = FROM

				has_opinion_modifier = {
					name = opinion_coronation_guest
					who = event_target:coronation_ruler
				}
			}
		}
	}
}

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

# on_start event to assign crowned_by_traits to existing rulers, so as to prevent a cascade of coronation ceremonies at the beginning of every game
character_event = {
	id = HF.20372

	is_triggered_only = yes # on_startup
	hide_window = yes

	has_dlc = "Holy Fury"

	trigger = {
		always = no # Not used in Plus
		owns = event_target:pulse_province
		is_save_game = no
	}

	immediate = {
		set_global_flag = flag_crowns_delivered

		k_papacy = {
			holder_scope = {
				save_event_target_as = the_pope
			}
		}

		any_playable_ruler = {
			limit = {
				is_decision_potential = prepare_coronation_ceremony
				is_adult = yes

				NOR = {
					has_character_flag = is_charlemagne
					has_character_flag = is_carloman
					has_landed_title = e_byzantium
					has_landed_title = e_hre
					has_landed_title = e_karling
				}
			}

			random_list = {
				# Crowned by Pope
				# Crowned by Bishop
				# Crowned by Priest

				10 = {
					trigger = { # Excommunicated rulers, possessed rulers, or rulers under an Antipope are never assigned Crowned by the Pope
						rightful_religious_head_scope = { controls_religion = yes }

						NOR = {
							trait = excommunicated
							trait = possessed
							has_landed_title = e_latin_empire # Disavowed historically
						}
					}

					mult_modifier = { # More distant/Less powerful Kingdom less likely to be crowned by the Pope
						factor = 0.5

						NOR = {
							has_landed_title = k_france
							has_landed_title = k_burgundy
							has_landed_title = k_aquitaine
							has_landed_title = k_germany
							has_landed_title = k_lotharingia
							has_landed_title = k_italy
							has_landed_title = k_sicily
							has_landed_title = k_naples
						}
					}

					mult_modifier = { # If the Pope disliked him, less likely to be crowned by him
						factor = 0.5

						reverse_opinion = {
							who = event_target:the_pope
							value < 0
						}
					}

					mult_modifier = { # Historically more likely
						factor = 10

						OR = {
							has_landed_title = k_italy
							has_landed_title = e_hre
						}
					}

					save_persistent_event_target = {
						name = coronation_priest_per # Needed to localize the trait properly
						scope = event_target:the_pope
					}

					add_trait = crowned_by_pope
					remove_trait = uncrowned
				}

				80 = {
					trigger = {
						# Checking if Emperor, Bishop Coronation unavailable when without investiture law
						trigger_if = {
							limit = { real_tier = EMPEROR }
							has_law = investiture_law_0
						}

						# Checking if there is an available powerful theocrat
						any_realm_character = {
							is_theocracy = yes
							religion = event_target:the_pope
							controls_religion = no

							OR = {
								higher_real_tier_than = BARON
								is_cardinal = yes
								is_antipope = yes
							}
						}
					}

					# Checking if there is no Antipope, and you are not excommunicated, go for the Pope
					mult_modifier = {
						factor = 0.1

						real_tier = EMPEROR
						rightful_religious_head_scope = { controls_religion = yes }

						NOR = {
							trait = excommunicated
							trait = possessed
						}
					}

					random_realm_lord = {
						limit = {
							is_theocracy = yes
							religion = event_target:the_pope
							controls_religion = no

							OR = {
								higher_real_tier_than = BARON
								is_cardinal = yes
								is_antipope = yes
							}
						}

						save_event_target_as = bishop
					}

					add_trait = crowned_by_bishop
					remove_trait = uncrowned

					save_persistent_event_target = {
						name = coronation_priest_per
						scope = event_target:bishop
					}
				}

				10 = {
					trigger = {
						# Holy Roman Emperors always crowned by somebody important
						trigger_if = {
							limit = { real_tier = EMPEROR }

							OR = {
								trait = excommunicated
								trait = possessed
								has_landed_title = e_latin_empire
							}
						}
						# Respectable Kings are crowned by Bishops
						trigger_else = {
							OR = {
								trait = excommunicated
								trait = possessed

								NOT = {
									any_realm_lord = {
										is_theocracy = yes
										religion = event_target:the_pope
										controls_religion = no

										OR = {
											higher_real_tier_than = BARON
											is_cardinal = yes
											is_antipope = yes
										}
									}
								}
							}
						}
					}

					add_trait = crowned_by_priest
					remove_trait = uncrowned
				}
			}

			# Second list to determine which modifier
			random_list = {
				40 = {
					trigger = { ruled_years < 20 }

					mult_modifier = {
						factor = 0.1

						OR = {
							trait = excommunicated
							trait = possessed
						}
					}

					mult_modifier = {
						factor = 0.5
						real_tier = KING
					}

					mult_modifier = {
						factor = 2
						trait = crowned_by_pope
					}

					add_character_modifier = {
						name = extravagant_coronation
						days = 6000 # Has probably already ruled for a while
					}
				}

				50 = { }

				10 = {
					add_character_modifier = {
						name = crowned_in_barn
						duration = -1
					}
				}
			}
		}
	}
}

# on_death: ruler who died uncrowned will gain uncrowned trait, so that his portrait doesn't default to the royal/imperial crown
character_event = {
	id = HF.20374

	is_triggered_only = yes # on_death
	hide_window = yes

	only_playable = yes

	trigger = {
		is_decision_potential = prepare_coronation_ceremony

		NOR = {
			has_landed_title = e_byzantium
			has_landed_title = e_hre
			has_landed_title = e_karling
		}
	}

	immediate = {
		add_trait = uncrowned
	}
}

# Five-yearly random bad events for uncrowned rulers
character_event = {
	id = HF.20375

	is_triggered_only = yes
	hide_window = yes

	only_playable = yes
	has_dlc = "Holy Fury"

	trigger = {
		is_decision_potential = prepare_coronation_ceremony
		is_adult = yes
		ruled_years >= 5

		NOR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
			has_landed_title = e_byzantium
			has_landed_title = e_hre
			has_landed_title = e_karling
		}
	}

	immediate = {
		# Random negative flavour
		random_list = {
			20 = {
				character_event = {
					id = HF.20376 # Peasants are upset
					days = 100
					random = 100
				}
			}

			20 = {
				trigger = {
					any_vassal = {
						is_theocracy = yes
						count >= 2
					}
				}

				character_event = {
					id = HF.20377 # Priests are upset
					days = 100
					random = 100
				}
			}

			20 = {
				trigger = {
					is_married = yes

					spouse = {
						OR = {
							religion = catholic
							religion = fraticelli
						}
					}
				}

				mult_modifier = {
					factor = 1.75
					spouse = { trait = wroth }
				}

				mult_modifier = {
					factor = 1.75

					spouse = {
						OR = {
							trait = crowned_by_priest
							trait = crowned_by_bishop
							trait = crowned_by_pope
							trait = crowned_by_myself
						}
					}
				}

				mult_modifier = {
					factor = 1.5
					spouse = { higher_real_tier_than = ROOT }
				}

				spouse = {
					character_event = {
						id = HF.20378 # Spouse is upset
						days = 100
						random = 100
					}
				}
			}

			20 = {
				trigger = {
					job_chancellor = { always = yes }
				}

				mult_modifier = {
					factor = 1.75
					job_chancellor = { trait = wroth }
				}

				job_chancellor = {
					character_event = {
						id = HF.20384 # Chancellor is upset
						days = 100
						random = 100
					}
				}
			}

			10 = {
				trigger = {
					job_spiritual = { always = yes }
				}

				mult_modifier = {
					factor = 0.25
					dynasty = job_spiritual
				}

				mult_modifier = {
					factor = 1.75
					job_spiritual = { trait = zealous }
				}

				mult_modifier = {
					factor = 1.75
					job_spiritual = { trait = diligent }
				}

				mult_modifier = {
					factor = 1.75
					job_spiritual = { trait = temperate }
				}

				mult_modifier = {
					factor = 1.75
					job_spiritual = {  trait = wroth }
				}

				job_spiritual = {
					character_event = {
						id = HF.20386 # Court chaplain resigns in protest
						days = 100
						random = 100
					}
				}
			}

			10 = {
				mult_modifier = {
					factor = 0.5
					real_tier = EMPEROR
				}

				mult_modifier = {
					factor = 0.5
					has_landed_title = e_hre
				}

				mult_modifier = {
					factor = 1.5
					piety >= 200
				}

				mult_modifier = {
					factor = 1.5
					piety >= 300
				}

				mult_modifier = {
					factor = 1.5
					piety >= 400
				}

				mult_modifier = {
					factor = 1.5
					piety >= 500
				}

				mult_modifier = {
					factor = 1.5
					piety >= 600
				}

				mult_modifier = {
					factor = 1.5
					piety >= 700
				}

				mult_modifier = {
					factor = 1.5
					piety >= 800
				}

				mult_modifier = {
					factor = 1.5
					piety >= 900
				}

				mult_modifier = {
					factor = 2
					piety >= 1000
				}

				# Nothing happens
			}
		}
	}
}

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

## Generic Flavor events related to coronation and crowns

# Peasants are restless because ruler is uncrowned
character_event = {
	id = HF.20376
	desc = EVTDESCHFA20376
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	only_playable = yes
	has_dlc = "Holy Fury"

	trigger = {
		is_decision_potential = prepare_coronation_ceremony
		religion = capital_scope
	}

	option = {
		name = EVTOPTAHF20376

		capital_scope = {
			show_scope_change = no

			add_province_modifier = {
				name = peasant_unrest
				years = 1
				stacking = yes
			}
		}
	}
}

# Church vassals upset because of uncrowned ruler
character_event = {
	id = HF.20377
	desc = EVTDESCHFA20377
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_diplomacy

	only_playable = yes
	has_dlc = "Holy Fury"

	trigger = {
		is_decision_potential = prepare_coronation_ceremony
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20377
		tooltip_info = learning

		trigger = { learning >= 12 }

		custom_tooltip = { text = tooltip_explain_coronation }

		piety = 50

		ai_chance = { factor = 100 }
	}

	option = {
		name = EVTOPTBHF20377
		tooltip_info = diplomacy

		trigger = { diplomacy >= 12 }

		custom_tooltip = { text = tooltip_explain_coronation_2 }

		prestige = 75

		ai_chance = { factor = 100 }
	}

	option = {
		name = EVTOPTCHF20377

		trigger = { wealth >= 100 }

		custom_tooltip = { text = tooltip_bribe_church }

		religion_head = {
			show_scope_change = no

			transfer_scaled_wealth = {
				from = ROOT
				value = 1
				min = 100
				max = 100
			}
		}

		ai_chance = { factor = 50 }
	}

	option = {
		name = EVTOPTDHF20377

		any_vassal = {
			show_scope_change = no

			limit = {
				is_theocracy = yes
				religion = ROOT
			}

			opinion = {
				name = opinion_uncrowned_ruler
				who = ROOT
				years = 1
			}
		}

		ai_chance = { factor = 50 }
	}
}

# Spouse: Your spouse is still not crowned
character_event = {
	id = HF.20378
	desc = EVTDESCHFA20378
	picture = GFX_evt_daughter_asking_father
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Holy Fury"

	trigger = {
		is_married = FROM

		FROM = {
			is_decision_potential = prepare_coronation_ceremony
		}
	}

	option = {
		name = EVTOPTAHF20378

		FROM = {
			show_scope_change = no

			character_event = {
				id = HF.20379
				tooltip = spouse_informed_uncrowned
			}
		}

		opinion = {
			name = opinion_uncrowned_failure
			who = FROM
			years = 5
		}

		ai_chance = { factor = 75 }
	}

	option = {
		name = EVTOPTBHF20378

		ai_chance = {
			factor = 25

			trigger = {
				OR = {
					trait = kind
					trait = patient
				}
			}
		}
	}
}

# Ruler: Your spouse is upset
character_event = {
	id = HF.20379
	desc = EVTDESCHFA20379
	picture = GFX_evt_daughter_asking_father
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = { # Look who's talking
		name = EVTOPTAHF20379

		trigger = {
			FROM = {
				is_decision_potential = prepare_coronation_ceremony
			}
		}

		FROM = {
			show_scope_change = no

			prestige = -75

			tooltip = {
				opinion = {
					name = opinion_uncrowned_failure
					who = ROOT
					years = 5
				}
			}

			character_event = { id = HF.20380 }
		}

		add_rival = FROM

		ai_chance = {
			factor = 25

			mult_modifier = {
				factor = 3
				trait = envious
			}

			mult_modifier = {
				factor = 3
				trait = proud
			}
		}
	}

	option = {
		name = EVTOPTBHF20379
		tooltip_info = diplomacy

		trigger = { diplomacy >= 15 }

		prestige = 75

		FROM = {
			show_scope_change = no

			remove_opinion = {
				name = opinion_uncrowned_failure
				who = ROOT
			}

			character_event = { id = HF.20381 }
		}

		ai_chance = { factor = 50 }
	}

	option = {
		name = EVTOPTCHF20379
		tooltip_info = lustful

		trigger = {
			OR = {
				trait = lustful
				is_lover = FROM
			}

			FROM = {
				NOR = {
					trait = chaste
					trait = celibate
				}
			}
		}

		piety = -20

		FROM = {
			show_scope_change = no

			tooltip = {
				remove_opinion = {
					name = opinion_uncrowned_failure
					who = ROOT
				}
			}

			character_event = { id = HF.20382 }
		}

		ai_chance = { factor = 50 }
	}

	option = {
		name = EVTOPTDHF20379

		tooltip = {
			reverse_opinion = {
				name = opinion_uncrowned_failure
				who = FROM
				years = 5
			}
		}

		ai_chance = {
			factor = 25

			trigger = {
				OR = {
					trait = kind
					trait = patient
				}
			}
		}
	}
}

# Spouse: Your spouse pointed out that you aren't crowned either
character_event = {
	id = HF.20380
	desc = EVTDESCHFA20380
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20380

		prestige = -75
		add_rival = FROM
	}
}

# Spouse: Used diplomacy on you
character_event = {
	id = HF.20381
	desc = EVTDESCHFA20381
	picture = GFX_evt_daughter_asking_father
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20381

		tooltip = {
			remove_opinion = {
				name = opinion_uncrowned_failure
				who = FROM
			}
		}
	}
}

# Spouse: Used sex on you
character_event = {
	id = HF.20382
	desc = EVTDESCHFA20382
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20382

		remove_opinion = {
			name = opinion_uncrowned_failure
			who = FROM
		}

		# CleanSlate: Wouldn't it make sense to have unprotected_sex_effect here?

		ai_chance = {
			factor = 90

			trigger = {
				NOT = { is_rival = FROM }
				FROM = { root_attraction_trigger = yes }
			}

			mult_modifier = {
				factor = 1.5
				FROM = { has_fair_trait_trigger = yes }
			}

			mult_modifier = {
				factor = 0.5
				FROM = { has_ugly_trait_trigger = yes }
			}

			mult_modifier = {
				factor = 0.25
				FROM = { trait = inbred }
			}

			mult_modifier = {
				factor = 0.5
				FROM = { trait = hunchback }
			}

			mult_modifier = {
				factor = 0.5
				FROM = { trait = harelip }
			}

			mult_modifier = {
				factor = 0.5
				practical_age < 40
				FROM = { practical_age >= 40 }
			}

			mult_modifier = {
				factor = 0.25
				practical_age < 60
				FROM = { practical_age >= 60 }
			}

			mult_modifier = {
				factor = 0.2

				any_lover = {
					NOT = { character = FROM }
				}
			}
		}
	}

	option = {
		name = EVTOPTBHF20382

		FROM = {
			character_event = { id = HF.20383 }
		}

		ai_chance = {
			factor = 10

			trigger = {
				OR = {
					NOT = { trait = lustful }
					is_rival = FROM
					FROM = { root_attraction_trigger = no }
				}
			}
		}
	}
}

# Ruler: Spouse did not care for sex
character_event = {
	id = HF.20383
	desc = EVTDESCHFA20383
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20383

		tooltip = {
			opinion = {
				name = opinion_uncrowned_failure
				who = FROM
				years = 5
			}
		}
	}
}

# Chancellor: Should remember that liege is still uncrowned
character_event = {
	id = HF.20384
	desc = EVTDESCHFA20384
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Holy Fury"

	trigger = {
		liege = {
			is_decision_potential = prepare_coronation_ceremony
		}
	}

	option = {
		name = EVTOPTAHF20384

		FROM = {
			character_event = { id = HF.20385 }
		}

		opinion = {
			name = opinion_uncrowned_ruler
			who = FROM
			years = 5
		}
	}
}

# Ruler: Chancellor reminded you that you are still uncrowned
character_event = {
	id = HF.20385
	desc = EVTDESCHFA20385
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20385

		add_character_modifier = {
			name = chancellor_of_uncrowned
			years = 10
			stacking = yes
		}

		tooltip = {
			reverse_opinion = {
				name = opinion_uncrowned_ruler
				who = FROM
				years = 5
			}
		}

		opinion = {
			name = opinion_dislike
			who = FROM
			years = 5
		}
	}
}

# Court Chaplain: You resign out of protest because liege is uncrowned
character_event = {
	id = HF.20386
	desc = EVTDESCHFA20386
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Holy Fury"

	trigger = {
		liege = {
			is_decision_potential = prepare_coronation_ceremony
		}
	}

	option = {
		name = EVTOPTAHF20386

		FROM = {
			character_event = { id = HF.20387 }
		}

		remove_title = job_spiritual

		add_character_modifier = {
			name = resigned_in_anger
			duration = -1
		}

		piety = 50

		opinion = {
			name = opinion_uncrowned_ruler
			who = FROM
			years = 15
		}
	}

	option = {
		name = EVTOPTBHF20386

		ai_chance = { factor = 0 }
	}
}

# Liege: Your court chaplain resigns out of protest because you are uncrowned
character_event = {
	id = HF.20387
	desc = EVTDESCHFA20387
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20387

		FROM = {
			show_scope_change = no

			tooltip = {
				remove_title = job_spiritual

				add_character_modifier = {
					name = resigned_in_anger
					duration = -1
				}
			}

			hidden_effect = {
				remove_opinion = {
					name = opinion_fired_from_council
					who = ROOT
				}
			}
		}
	}
}

# Emperor crowned in barn humbled
character_event = {
	id = HF.20388
	desc = EVTDESCHFA20388
	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		real_tier = EMPEROR
		has_character_modifier = crowned_in_barn

		OR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = {
		name = EVTOPTAHF20388

		trigger = {
			NOT = { trait = humble }
		}

		prestige = -100
		remove_trait_silently_proud_effect = yes
		add_trait = humble

		ai_chance = { factor = 40 }
	}

	option = {
		name = EVTOPTBHF20388
		tooltip_info = humble

		trigger = { trait = humble }

		prestige = -150
		piety = 50

		ai_chance = { factor = 40 }
	}

	option = {
		name = EVTOPTCHF20388

		piety = -50
		remove_trait_silently_humble_effect = yes

		ai_chance = { factor = 20 }
	}
}

# Peasants are still celebrating coronation
character_event = {
	id = HF.20389
	desc = EVTDESCHFA20389
	picture = GFX_evt_market_hf
	border = GFX_event_normal_frame_economy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		has_character_modifier = extravagant_coronation

		OR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = { # Use excitement to build trade
		name = EVTOPTAHF20389
		tooltip_info = stewardship

		trigger = { stewardship >= 12 }

		wealth = 50
		prestige = 100

		capital_scope = {
			show_scope_change = no

			add_province_modifier = {
				name = coronation_improved_trade
				days = 1265
				stacking = yes
			}
		}

		ai_chance = { factor = 100 }
	}

	option = { # Let peasants have their fun
		name = EVTOPTBHF20389

		prestige = 100

		capital_scope = {
			show_scope_change = no

			add_province_modifier = {
				name = coronation_peasants_happy
				days = 600
				stacking = yes
			}
		}

		ai_chance = { factor = 30 }
	}

	option = { # Have peasants return to work
		name = EVTOPTCHF20389

		prestige = -100

		capital_scope = {
			show_scope_change = no

			add_province_modifier = {
				name = peasants_scorned
				days = 400
				stacking = yes
			}
		}

		ai_chance = { factor = 10 }
	}
}

# Word of the great coronation has spread across the realm, bringing even more prestige to the new ruler
character_event = {
	id = HF.20390
	desc = EVTDESCHFA20390
	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_economy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		has_character_modifier = extravagant_coronation

		OR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = {
		name = EVTOPTAHF20390

		prestige = 200
	}
}

# Festivities for the coronation have brought in more trade
character_event = {
	id = HF.20391
	desc = EVTDESCHFA20391
	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_economy

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		has_character_modifier = extravagant_coronation

		OR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = { # Use excitement to build trade
		name = EVTOPTAHF20391

		wealth = 75

		capital_scope = {
			show_scope_change = no

			add_province_modifier = {
				name = coronation_improved_trade
				days = 1265
				stacking = yes
			}
		}
	}
}

# Former guest is envious of extravagant coronation
character_event = {
	id = HF.20392
	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20392
		trigger = { has_character_modifier = crowned_in_barn }
	}
	desc = {
		text = EVTDESCHFB20392
		trigger = {
			NOT = { has_character_modifier = crowned_in_barn }
		}
	}

	is_triggered_only = yes
	hide_new = yes

	trigger = {
		FROMFROM = { has_character_modifier = extravagant_coronation }

		OR = {
			has_character_modifier = crowned_in_barn

			NOR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
		}
	}

	option = {
		name = EVTOPTAHF20392
		tooltip_info = humble

		trigger = { trait = humble }

		piety = 50
	}

	option = {
		name = EVTOPTBHF20392

		if = {
			limit = { trait = kind }
			remove_trait = kind
		}
		else_if = {
			limit = { trait = envious }
			piety = -50
		}
		else = {
			add_trait = envious
		}
	}
}

###############################
# New Vassals must pay homage to a crowned Ruler

# on_death event for vassal of crowned ruler
character_event = {
	id = HF.20393

	is_triggered_only = yes # on_death
	hide_window = yes

	only_playable = yes
	religion_group = christian
	has_dlc = "Holy Fury"

	trigger = {
		higher_real_tier_than = COUNT # Avoid spamming
		is_feudal = yes
		independent = no

		current_heir = {
			age >= 12 # At the very least

			# Prevent same vassal from giving homage multiple times when inheriting new titles within the realm (from siblings and such)
			trigger_if = {
				limit = { higher_real_tier_than = COUNT }
				NOT = { same_liege = ROOT }
			}
		}

		liege = {
			higher_real_tier_than = DUKE
			religion_group = christian
			in_command = no

			OR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
		}
	}

	immediate = {
		current_heir = {
			character_event = {
				id = HF.20394
				days = 4
				random = 4
			}
		}
	}
}

# Heir is prompted to go to his liege
character_event = {
	id = HF.20394
	desc = EVTDESCHFA20394
	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	religion_group = christian

	trigger = {
		independent = no
		age >= 12
		is_feudal = yes

		liege = {
			higher_real_tier_than = DUKE
			is_inaccessible_trigger = no

			OR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
		}
	}

	option = { # Will go
		name = EVTOPTAHF20394

		prestige = -50

		add_character_modifier = {
			name = out_traveling
			duration = 50
		}

		liege = {
			character_event = {
				id = HF.20396
				days = 25
				random = 10
			}
		}

		ai_chance = { factor = 80 }
	}

	option = { # Will not go
		name = EVTOPTBHF20394

		liege = {
			show_scope_change = no

			opinion = {
				name = opinion_didnot_pay_homage
				who = ROOT
				years = 15
			}

			character_event = {
				id = HF.20395 # Notify
				days = 15
				random = 15
			}
		}

		ai_chance = {
			factor = 20

			trigger = {
				NOR = {
					is_friend = liege
					is_lover = liege
				}
			}

			mult_modifier = {
				factor = 0.5
				is_married = liege
			}

			mult_modifier = {
				factor = 0.5
				is_close_relative = liege
			}

			mult_modifier = {
				factor = 4
				is_rival = liege
			}

			mult_modifier = {
				factor = 1.5
				trait = slothful
			}

			mult_modifier = {
				factor = 2
				trait = proud
			}

			mult_modifier = {
				factor = 1.5
				trait = stubborn
			}

			mult_modifier = {
				factor = 1.5
				trait = shy
			}

			mult_modifier = {
				factor = 1.5
				NOT = { religion = liege }
			}

			mult_modifier = {
				factor = 1.5

				opinion = {
					who = liege
					value < 0
				}
			}

			mult_modifier = {
				factor = 1.5

				opinion = {
					who = liege
					value < -20
				}
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = liege
					value < -40
				}
			}

			mult_modifier = {
				factor = 3

				opinion = {
					who = liege
					value < -60
				}
			}
		}
	}
}

# Liege notified new vassal won't pay him homage
character_event = {
	id = HF.20395
	desc = EVTDESCHFA20395
	picture = GFX_evt_courier
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = {
		higher_real_tier_than = DUKE
		is_inaccessible_trigger = no

		OR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = {
		name = EVTOPTAHF20395

		prestige = -50

		tooltip = {
			opinion = {
				name = opinion_didnot_pay_homage
				who = FROM
				years = 15
			}
		}
	}
}

# Liege receives homage from vassal
character_event = {
	id = HF.20396
	desc = EVTDESCHFA20396
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = {
		higher_real_tier_than = DUKE

		OR = {
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = { # Accept homage
		name = EVTOPTAHF20396

		custom_tooltip = {
			text = tooltip_HF20396_A

			random_list = {
				20 = {
					trigger = {
						NOT = { religion = FROM }
					}

					set_character_flag = flag_homage_infidel
				}

				20 = {
					trigger = {
						FROM = { is_adult = no }
					}

					set_character_flag = flag_homage_child
				}

				20 = {
					trigger = {
						FROM = { practical_age >= 50 }
					}

					set_character_flag = flag_homage_old
				}

				20 = {
					trigger = {
						is_adult = yes

						FROM = {
							is_adult = yes
							is_attractive_trigger = yes
							root_attraction_trigger = yes
						}
					}

					set_character_flag = flag_homage_attractive
				}

				20 = {
					trigger = {
						FROM = { is_unattractive_trigger = yes }
					}

					set_character_flag = flag_homage_deformed
				}

				20 = {
					trigger = {
						trigger_if = {
							limit = { FROM = { is_female = no } }

							NOR = {
								has_law = agnatic_succession
								has_law = cognatic_succession
							}
						}
						trigger_else = {
							NOR = {
								has_law = enatic_cognatic_succession
								has_law = enatic_succession
							}
						}
					}

					set_character_flag = flag_homage_sex
				}

				20 = {
					trigger = {
						FROM = { is_evil_trigger = yes }
					}

					set_character_flag = flag_homage_evil
				}

				20 = {
					trigger = {
						FROM = { has_virtue_trigger = yes }
					}

					set_character_flag = flag_homage_good
				}

				1 = {
					set_character_flag = flag_homage_generic
				}
			}

			character_event = { id = HF.20410 } # Reaction event
		}

		ai_chance = { factor = 95 }
	}

	option = { # Refuse homage
		name = EVTOPTBHF20396

		prestige = 100

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_offended
				who = ROOT
				years = 15
			}

			character_event = { id = HF.20398 } # Notify
		}

		ai_chance = {
			factor = 5

			trigger = {
				NOR = {
					is_friend = FROM
					is_lover = FROM
				}
			}

			mult_modifier = {
				factor = 0.5
				is_married = FROM
			}

			mult_modifier = {
				factor = 0.5
				is_close_relative = FROM
			}

			mult_modifier = {
				factor = 6
				is_rival = FROM
			}

			mult_modifier = {
				factor = 1.5
				trait = envious
			}

			mult_modifier = {
				factor = 1.5
				trait = proud
			}

			mult_modifier = {
				factor = 1.5
				trait = stubborn
			}

			mult_modifier = {
				factor = 1.5

				opinion = {
					who = FROM
					value < 0
				}
			}

			mult_modifier = {
				factor = 1.75

				opinion = {
					who < FROM
					value = -20
				}
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = FROM
					value < -40
				}
			}

			mult_modifier = {
				factor = 3

				opinion = {
					who = FROM
					value < -60
				}
			}
		}
	}
}

# Vassal notified liege accepted homage. - OBSOLETE, now chain leads into HF.20410
# character_event = {
#	id = HF.20397
#	desc = EVTDESCHFA20397
#
#	picture = GFX_evt_emissary
#	border = GFX_event_normal_frame_diplomacy
#
#	is_triggered_only = yes
#
#	option = {
#		name = EVTOPTAHF20397
#
#		prestige = 100
#
#		tooltip = {
#			opinion = {
#				modifier = opinion_kind
#				who = FROM
#				years = 15
#			}
#		}
#	}
# }

# Vassal notified liege did not accept homage
character_event = {
	id = HF.20398
	desc = EVTDESCHFA20398
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20398

		prestige = -75

		tooltip = {
			opinion = {
				name = opinion_offended
				who = FROM
				years = 15
			}
		}
	}
}

################################################
## Crown-related flavor

# The nail in the Iron Cross
character_event = {
	id = HF.20399
	desc = EVTDESCHFA20399
	picture = GFX_evt_holy_emperor
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # on_five_year_pulse, random_events

	ai = no
	religion_group = christian
	min_age = 8

	trigger = {
		any_artifact = {
			artifact_type = iron_crown_of_lombardy
			is_artifact_equipped = yes
		}

		NOT = { has_dynasty_flag = flag_nail_in_crown }
		is_inaccessible_trigger = no
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 1.5
			trait = shrewd
		}

		mult_modifier = {
			factor = 0.5
			trait = dull
		}

		mult_modifier = {
			factor = 1.25
			trait = scholar
		}

		mult_modifier = {
			factor = 2
			trait = cynical
		}

		mult_modifier = {
			factor = 2
			is_adult = no
		}
	}

	immediate = {
		set_dynasty_flag = flag_nail_in_crown
	}

	option = { # Look for it
		name = EVTOPTAHF20399

		change_learning = 3

		random = {
			chance = 10

			piety = -100

			custom_tooltip = {
				text = iron_cross_broken

				any_artifact = {
					limit = { artifact_type = iron_crown_of_lombardy }
					unsafe_destroy_artifact = yes
				}

				add_artifact = fragment_of_true_cross
			}
		}
	}

	option = { # Better not to touch
		name = EVTOPTBHF20399

		piety = 75
	}
}

# The HRE crown and the prince
character_event = {
	id = HF.20400

	is_triggered_only = yes # on_five_year_pulse, random_events
	hide_window = yes

	ai = no
	religion_group = christian

	trigger = {
		has_landed_title = e_hre

		any_artifact = {
			artifact_type = crown_hre
			is_artifact_equipped = yes
		}

		NOR = {
			has_dynasty_flag = flag_hre_crown_prince
			has_character_flag = is_charlemagne
		}

		is_inaccessible_trigger = no

		any_child = {
			age >= 7
			age < 14
			at_location = ROOT
			is_inaccessible_or_incapable_trigger = no
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 1.75

			any_child = {
				trait = curious
				age >= 7
				age < 14
				at_location = ROOT
				is_inaccessible_or_incapable_trigger = no
			}
		}

		mult_modifier = {
			factor = 1.5

			any_child = {
				trait = rowdy
				age >= 7
				age < 14
				at_location = ROOT
				is_inaccessible_or_incapable_trigger = no
			}
		}
	}


	immediate = {
		set_dynasty_flag = flag_hre_crown_prince

		random_child = {
			limit = {
				age >= 7
				age < 14
				at_location = ROOT
				is_inaccessible_or_incapable_trigger = no
			}

			preferred_limit = { trait = curious }
			preferred_limit = { trait = rowdy }

			character_event = { id = HF.20401 }
		}
	}
}

# Child picks the crown
character_event = {
	id = HF.20401
	desc = EVTDESCHFA20401
	picture = GFX_evt_holy_emperor
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20401

		prestige = 100

		FROM = {
			character_event = { id = HF.20402 }
		}
	}
}

# Emperor notified
character_event = {
	id = HF.20402
	desc = EVTDESCHFA20402
	picture = GFX_evt_holy_emperor
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = { # Teach about the crown's history
		name = EVTOPTAHF20402
		tooltip_info = learning

		trigger = {
			OR = {
				learning >= 12
				trait = scholar
			}
		}

		piety = 30

		FROM = {
			show_scope_change = no

			prestige = -75
			change_learning = 1
			character_event = { id = HF.20403 }
		}
	}

	option = { # Pick back crown
		name = EVTOPTBHF20402

		piety = 50

		FROM = {
			show_scope_change = no

			prestige = -100

			opinion = {
				name = opinion_scolded
				who = ROOT
				years = 5
			}

			character_event = { id = HF.20404 }
		}
	}

	option = { # Let the child have his fun
		name = EVTOPTCHF20402

		piety = -50

		FROM = {
			show_scope_change = no

			tooltip = { prestige = 100 }

			opinion = {
				name = opinion_forgiving_parent
				who = ROOT
				years = 5
			}
		}
	}
}

# Child taught lesson
character_event = {
	id = HF.20403
	desc = EVTDESCHFA20403
	picture = GFX_evt_child_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20403

		tooltip = {
			prestige = -75
			change_learning = 1
		}
	}
}

# Child reprimanded
character_event = {
	id = HF.20404
	desc = EVTDESCHFA20404
	picture = GFX_evt_child_bully
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20404

		tooltip = {
			prestige = -100

			opinion = {
				name = opinion_scolded
				who = FROM
				years = 5
			}
		}
	}
}

# Ticking negative modifier for uncrowned rulers
character_event = {
	id = HF.20405

	is_triggered_only = yes # on_yearly_pulse
	hide_window = yes

	only_playable = yes

	trigger = {
		always = no # Not used in Plus
		is_decision_potential = prepare_coronation_ceremony
		is_adult = yes

		has_instances_of_character_modifier = {
			name = uncrowned_modifier
			amount < 30
		}

		NOR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}

	immediate = {
		add_character_modifier = {
			name = uncrowned_modifier
			duration = -1
			stacking = yes
		}
	}
}

# on_conversion. Ruler converted when in the middle of a coronation, cancel everything
character_event = {
	id = HF.20408
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESCHFA20408
		trigger = {
			NOR = {
				religion = fraticelli
				religion = catholic
			}
		}
	}
	desc = {
		text = EVTDESCHFB20408
		trigger = {
			OR = {
				religion = fraticelli
				religion = catholic
			}
		}
	}

	is_triggered_only = yes

	only_rulers = yes
	min_age = 11

	trigger = {
		OR = {
			has_character_flag = flag_preparing_coronation
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
			has_character_flag = flag_antipope_for_coronation
			has_character_flag = flag_excommunicated_for_coronation
			has_character_flag = flag_pepin_for_coronation
		}

		# Previous religion
		FROM = {
			OR = {
				religion = catholic
				religion = fraticelli
			}
		}
	}

	immediate = {
		clr_character_flag = flag_preparing_coronation
		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		clr_character_flag = flag_pepin_for_coronation
	}

	option = {
		name = {
			text = EVTOPTAHF20408
			trigger = {
				NOR = {
					religion = catholic
					religion = fraticelli
				}
			}
		}
		name = {
			text = I_SEE
			trigger = {
				OR = {
					religion = catholic
					religion = fraticelli
				}
			}
		}

		hidden_effect = {
			remove_trait = travelling
			remove_character_modifier = out_traveling

			set_variable = {
				which = coronation_count
				value = 0
			}
		}

		clr_character_flag = flag_preparing_coronation # Still used when after waging wars
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		clr_character_flag = flag_pepin_for_coronation
		clr_character_flag = flag_extravagant_coronation
		clr_character_flag = flag_regular_coronation
		clr_character_flag = flag_secluded_coronation
		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope

		clr_character_flag = flag_coronation_foreign_friendship
		clr_character_flag = flag_coronation_vassal_friendship
		clr_character_flag = flag_coronation_diplomacy_boost
		clr_character_flag = flag_coronation_learning_boost
		clr_character_flag = flag_coronation_guest_opinions
		clr_character_flag = flag_coronation_gain_diligent
		clr_character_flag = flag_coronation_gain_ambitious
		clr_character_flag = flag_coronation_haughty_child
		clr_character_flag = flag_coronation_priest_approves
		clr_character_flag = flag_coronation_hre_talk
		clr_character_flag = flag_coronation_pope_talk
		clr_character_flag = flag_coronation_foreign_teacher
		clr_character_flag = flag_coronation_priest_disapproves
		clr_character_flag = flag_coronation_diplomatic_incident
		clr_character_flag = flag_coronation_cynic_taunts
		clr_character_flag = flag_coronation_wandering_knight
		clr_character_flag = flag_coronation_wandering_priest
		clr_character_flag = flag_coronation_random_rivalry
		clr_character_flag = flag_coronation_secluded_embarassed
		clr_character_flag = flag_coronation_secluded_vassals
		clr_character_flag = flag_coronation_secluded_priest
		clr_character_flag = flag_coronation_secluded_ambitious
		clr_character_flag = flag_coronation_secluded_proud
		clr_character_flag = flag_coronation_secluded_steward


		hidden_effect = {
			any_opinion_modifier_target = {
				limit = {
					has_opinion_modifier = {
						name = opinion_coronation_guest
						who = ROOT
					}
				}

				remove_trait = travelling
				remove_character_modifier = out_traveling
				character_event = { id = HF.20409 }

				remove_opinion = {
					name = opinion_coronation_guest
					who = ROOT
				}
			}
		}
	}
}

# Guest: Ruler to be crowned converted. Coronation has been cancelled.
character_event = {
	id = HF.20409
	desc = EVTDESCHFA20409
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20409
	}
}

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

# Liege receives homage from vassal - Expanded flavor
character_event = {
	id = HF.20410
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20410
		trigger = { has_character_flag = flag_homage_infidel }
	}
	desc = {
		text = EVTDESCHFB20410
		trigger = { has_character_flag = flag_homage_child }
	}
	desc = {
		text = EVTDESCHFC20410
		trigger = { has_character_flag = flag_homage_old }
	}
	desc = {
		text = EVTDESCHFD20410
		trigger = {
			has_character_flag = flag_homage_attractive
			FROMFROM = { is_female = no }
		}
	}
	desc = {
		text = EVTDESCHFDD20410
		trigger = {
			has_character_flag = flag_homage_attractive
			FROMFROM = { is_female = yes }
		}
	}
	desc = {
		text = EVTDESCHFF20410
		trigger = { has_character_flag = flag_homage_deformed }
	}
	desc = {
		text = EVTDESCHFG20410
		trigger = { has_character_flag = flag_homage_sex }
	}
	desc = {
		text = EVTDESCHFH20410
		trigger = { has_character_flag = flag_homage_evil }
	}
	desc = {
		text = EVTDESCHFI20410
		trigger = { has_character_flag = flag_homage_good }
	}
	desc = {
		text = EVTDESCHFL20410
		trigger = { has_character_flag = flag_homage_generic }
	}

	picture = {
		picture = GFX_evt_throne_room
		trigger = { is_female = no }
	}
	picture = {
		picture = GFX_evt_homage_hf
		trigger = { is_female = yes }
	}

	is_triggered_only = yes
	show_from_from = yes # Vassal

	immediate = {
		FROMFROM = { # Setup reaction for vassal
			random_list = {
				20 = {
					trigger = {
						NOT = { religion = ROOT }
					}

					set_character_flag = flag_homage_infidel
				}

				20 = {
					trigger = {
						ROOT = { is_adult = no }
					}

					set_character_flag = flag_homage_child
				}

				20 = {
					trigger = {
						ROOT = { practical_age >= 50 }
					}

					set_character_flag = flag_homage_old
				}

				20 = {
					trigger = {
						ROOT = {
							is_attractive_trigger = yes
							prev_attraction_trigger = yes
						}
					}

					set_character_flag = flag_homage_attractive
				}

				20 = {
					trigger = {
						ROOT = { is_unattractive_trigger = yes }
					}

					set_character_flag = flag_homage_deformed
				}

				20 = {
					trigger = {
						ROOT = {
							trigger_if = {
								limit = { is_female = no }

								NOR = {
									has_law = agnatic_succession
									has_law = cognatic_succession
								}
							}
							trigger_else = {
								NOR = {
									has_law = enatic_cognatic_succession
									has_law = enatic_succession
								}
							}
						}
					}

					set_character_flag = flag_homage_sex
				}

				20 = {
					trigger = {
						ROOT = { is_evil_trigger = yes }
					}

					set_character_flag = flag_homage_evil
				}

				20 = {
					trigger = {
						ROOT = { has_virtue_trigger = yes }
					}

					set_character_flag = flag_homage_good
				}

				1 = {
					set_character_flag = flag_homage_generic
				}
			}
		}
	}

	option = { # Children play
		name = EVTOPTAHF20410

		trigger = {
			has_character_flag = flag_homage_child
			is_adult = no
		}

		custom_tooltip = {
			text = tooltip_HF20410_A

			FROMFROM = {
				random_list = {
					75 = {
						mult_modifier = {
							factor = 0.5
							trait = timid
						}

						mult_modifier = {
							factor = 0.5
							trait = shy
						}

						mult_modifier = {
							factor = 1.5
							trait = playful
						}

						mult_modifier = {
							factor = 1.5
							trait = idolizer
						}

						set_character_flag = flag_homage_play_success
					}

					25 = {
						set_character_flag = flag_homage_play_failure
					}
				}
			}
		}

		ai_chance = {
			factor = 100

			mult_modifier = {
				factor = 0.5
				trait = shy
			}

			mult_modifier = {
				factor = 0.5
				trait = timid
			}
		}
	}

	option = { # Attracted
		name = EVTOPTBHF20410

		trigger = { has_character_flag = flag_homage_attractive }

		custom_tooltip = {
			text = tooltip_HF20410_B

			FROMFROM = {
				random_list = {
					50 = {
						trigger = { attracted_to_prev_trigger = yes }

						mult_modifier = {
							factor = 0.5
							trait = chaste
						}

						mult_modifier = {
							factor = 0.1
							trait = celibate
						}

						mult_modifier = {
							factor = 0.25
							ROOT = { is_unattractive_trigger = yes }
						}

						mult_modifier = {
							factor = 1.75
							ROOT = { is_attractive_trigger = yes }
						}

						mult_modifier = {
							factor = 1.5
							trait = lustful
						}

						mult_modifier = {
							factor = 1.5
							trait = hedonist
						}

						set_character_flag = flag_homage_seduce_success
					}

					50 = {
						set_character_flag = flag_homage_seduce_failure
					}
				}
			}
		}

		ai_chance = {
			factor = 50

			trigger = {
				NOT = { trait = celibate }
			}

			mult_modifier = {
				factor = 0.5
				trait = chaste
			}

			mult_modifier = {
				factor = 1.5
				trait = lustful
			}

			mult_modifier = {
				factor = 1.5
				trait = hedonist
			}
		}
	}

	option = { # Mock
		name = EVTOPTCHF20410

		trigger = { has_character_flag = flag_homage_deformed }

		custom_tooltip = {
			text = tooltip_HF20410_C

			FROMFROM = {
				random_list = {
					30 = {
						mult_modifier = {
							factor = 0.5
							trait = envious
						}

						mult_modifier = {
							factor = 0.1
							trait = proud
						}

						mult_modifier = {
							factor = 0.5
							trait = ambitious
						}

						mult_modifier = {
							factor = 0.5
							trait = wroth
						}

						mult_modifier = {
							factor = 1.75
							trait = humble
						}

						mult_modifier = {
							factor = 1.75
							trait = content
						}

						mult_modifier = {
							factor = 1.75
							trait = kind
						}

						mult_modifier = {
							factor = 1.75
							trait = patient
						}

						set_character_flag = flag_homage_mock_success
					}

					70 = {
						set_character_flag = flag_homage_mock_failure
					}
				}
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.5
				trait = kind
			}

			mult_modifier = {
				factor = 0.5
				trait = humble
			}

			mult_modifier = {
				factor = 1.5
				trait = cruel
			}

			mult_modifier = {
				factor = 1.5
				trait = envious
			}
		}
	}

	option = { # Formal greeting
		name = EVTOPTDHF20410

		custom_tooltip = {
			text = tooltip_HF20410_D

			FROMFROM = {
				random_list = {
					65 = {
						mult_modifier = {
							factor = 0.5
							trait = gregarious
						}

						mult_modifier = {
							factor = 0.1
							trait = socializer
						}

						mult_modifier = {
							factor = 0.5
							trait = arbitrary
						}

						mult_modifier = {
							factor = 1.75
							trait = shy
						}

						mult_modifier = {
							factor = 1.75
							trait = content
						}

						mult_modifier = {
							factor = 1.75
							trait = trusting
						}

						set_character_flag = flag_homage_formal_success
					}

					35 = {
						set_character_flag = flag_homage_formal_failure
					}
				}
			}
		}

		ai_chance = {
			factor = 30

			mult_modifier = {
				factor = 0.5
				trait = gregarious
			}

			mult_modifier = {
				factor = 0.5
				trait = socializer
			}

			mult_modifier = {
				factor = 0.5
				trait = arbitrary
			}

			mult_modifier = {
				factor = 1.5
				trait = paranoid
			}
		}
	}

	option = { # Informal greeting
		name = EVTOPTEHF20410

		custom_tooltip = {
			text = tooltip_HF20410_E

			FROMFROM = {
				random_list = {
					65 = {
						mult_modifier = {
							factor = 0.5
							trait = shy
						}

						mult_modifier = {
							factor = 0.1
							trait = humble
						}

						mult_modifier = {
							factor = 0.5
							trait = just
						}

						mult_modifier = {
							factor = 1.75
							trait = gregarious
						}

						mult_modifier = {
							factor = 1.5
							trait = proud
						}

						mult_modifier = {
							factor = 1.75
							trait = content
						}

						mult_modifier = {
							factor = 1.75
							trait = trusting
						}

						set_character_flag = flag_homage_informal_success
					}

					35 = {
						set_character_flag = flag_homage_informal_failure
					}
				}
			}
		}

		ai_chance = {
			factor = 30

			mult_modifier = {
				factor = 0.5
				trait = shy
			}

			mult_modifier = {
				factor = 0.5
				trait = humble
			}

			mult_modifier = {
				factor = 0.5
				trait = just
			}

			mult_modifier = {
				factor = 1.5
				trait = trusting
			}
		}
	}

	after = {
		clr_character_flag = flag_homage_infidel
		clr_character_flag = flag_homage_child
		clr_character_flag = flag_homage_old
		clr_character_flag = flag_homage_attractive
		clr_character_flag = flag_homage_deformed
		clr_character_flag = flag_homage_sex
		clr_character_flag = flag_homage_evil
		clr_character_flag = flag_homage_good
		clr_character_flag = flag_homage_generic

		FROMFROM = {
			character_event = { id = HF.20411 }
		}
	}
}

# Vassal receives homage from vassal - Expanded flavor
character_event = {
	id = HF.20411
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCHFA20411
		trigger = { has_character_flag = flag_homage_infidel }
	}
	desc = {
		text = EVTDESCHFB20411
		trigger = { has_character_flag = flag_homage_child }
	}
	desc = {
		text = EVTDESCHFC20411
		trigger = { has_character_flag = flag_homage_old }
	}
	desc = {
		text = EVTDESCHFD20411
		trigger = {
			has_character_flag = flag_homage_attractive
			is_female = no
		}
	}
	desc = {
		text = EVTDESCHFDD20411
		trigger = {
			has_character_flag = flag_homage_attractive
			is_female = yes
		}
	}
	desc = {
		text = EVTDESCHFF20411
		trigger = { has_character_flag = flag_homage_deformed }
	}
	desc = {
		text = EVTDESCHFG20411
		trigger = { has_character_flag = flag_homage_sex }
	}
	desc = {
		text = EVTDESCHFH20411
		trigger = { has_character_flag = flag_homage_evil }
	}
	desc = {
		text = EVTDESCHFI20411
		trigger = { has_character_flag = flag_homage_good }
	}
	desc = {
		text = EVTDESCHFL20411
		trigger = { has_character_flag = flag_homage_generic }
	}

	picture = {
		picture = GFX_evt_emissary
		trigger = { is_female = no }
	}
	picture = {
		picture = GFX_evt_homage_hf
		trigger = { is_female = yes }
	}

	is_triggered_only = yes

	option = { # Pleased
		name = {
			text = EVTOPTAHF20411_A
			trigger = {
				OR = {
					has_character_flag = flag_homage_play_success
					has_character_flag = flag_homage_seduce_success
					has_character_flag = flag_homage_mock_success
					has_character_flag = flag_homage_formal_success
					has_character_flag = flag_homage_informal_success
				}
			}
		}
		name = {
			text = EVTOPTAHF20411_B
			trigger = {
				OR = {
					has_character_flag = flag_homage_play_failure
					has_character_flag = flag_homage_seduce_failure
					has_character_flag = flag_homage_mock_failure
					has_character_flag = flag_homage_formal_failure
					has_character_flag = flag_homage_informal_failure
				}
			}
		}

		opinion = {
			name = opinion_pleased
			who = FROM
			years = 5
		}

		FROM = {
			character_event = { id = HF.20412 }
		}

		ai_chance = {
			factor = 50

			trigger = {
				OR = {
					has_character_flag = flag_homage_play_success
					has_character_flag = flag_homage_seduce_success
					has_character_flag = flag_homage_mock_success
					has_character_flag = flag_homage_formal_success
					has_character_flag = flag_homage_informal_success
				}
			}
		}
	}

	option = { # Offended
		name = {
			text = EVTOPTBHF20411_A
			trigger = {
				OR = {
					has_character_flag = flag_homage_play_success
					has_character_flag = flag_homage_seduce_success
					has_character_flag = flag_homage_mock_success
					has_character_flag = flag_homage_formal_success
					has_character_flag = flag_homage_informal_success
				}
			}
		}
		name = {
			text = EVTOPTBHF20411_B
			trigger = {
				OR = {
					has_character_flag = flag_homage_play_failure
					has_character_flag = flag_homage_seduce_failure
					has_character_flag = flag_homage_mock_failure
					has_character_flag = flag_homage_formal_failure
					has_character_flag = flag_homage_informal_failure
				}
			}
		}

		opinion = {
			name = opinion_irritated
			who = FROM
			years = 5
		}

		FROM = {
			character_event = { id = HF.20413 }
		}

		ai_chance = {
			factor = 50

			trigger = {
				OR = {
					has_character_flag = flag_homage_play_failure
					has_character_flag = flag_homage_seduce_failure
					has_character_flag = flag_homage_mock_failure
					has_character_flag = flag_homage_formal_failure
					has_character_flag = flag_homage_informal_failure
				}
			}
		}
	}

	after = {
		clr_character_flag = flag_homage_infidel
		clr_character_flag = flag_homage_child
		clr_character_flag = flag_homage_old
		clr_character_flag = flag_homage_attractive
		clr_character_flag = flag_homage_deformed
		clr_character_flag = flag_homage_sex
		clr_character_flag = flag_homage_evil
		clr_character_flag = flag_homage_good
		clr_character_flag = flag_homage_generic
		clr_character_flag = flag_homage_play_success
		clr_character_flag = flag_homage_seduce_success
		clr_character_flag = flag_homage_mock_success
		clr_character_flag = flag_homage_formal_success
		clr_character_flag = flag_homage_informal_success
		clr_character_flag = flag_homage_play_failure
		clr_character_flag = flag_homage_seduce_failure
		clr_character_flag = flag_homage_mock_failure
		clr_character_flag = flag_homage_formal_failure
		clr_character_flag = flag_homage_informal_failure
	}
}

# Ruler notified: New vassal was pleased with your greeting
character_event = {
	id = HF.20412
	desc = EVTDESCHFA20412
	border = GFX_event_normal_frame_diplomacy

	picture = {
		picture = GFX_evt_throne_room
		trigger = { is_female = no }
	}
	picture = {
		picture = GFX_evt_homage_hf
		trigger = { is_female = yes }
	}

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20412

		tooltip = {
			reverse_opinion = {
				name = opinion_pleased
				who = FROM
				years = 5
			}
		}
	}
}

# Ruler notified: New vassal was not pleased with your greeting
character_event = {
	id = HF.20413
	desc = EVTDESCHFA20413
	border = GFX_event_normal_frame_diplomacy

	picture = {
		picture = GFX_evt_throne_room
		trigger = { is_female = no }
	}
	picture = {
		picture = GFX_evt_homage_hf
		trigger = { is_female = yes }
	}

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTAHF20413

		tooltip = {
			reverse_opinion = {
				name = opinion_irritated
				who = FROM
				years = 5
			}
		}
	}
}

# on_title_usurped: move special crowns to new holder
# FROMFROM is old holder
# FROM is title
# ROOT is new holder
character_event = {
	id = HF.20414

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		FROM = {
			OR = {
				title = e_hre
				title = e_persia
				title = e_byzantium
				title = k_italy
				controls_religion = yes # Pagan religion head titles
			}
		}
	}

	immediate = {
		FROMFROM = {
			any_artifact = {
				limit = {
					trigger_if = {
						limit = { artifact_type = crown_hre }
						ROOT_FROM = { title = e_hre }
					}
					trigger_else_if = {
						limit = { artifact_type = iron_crown_of_lombardy }
						ROOT_FROM = { title = k_italy }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_pahlavi }
						ROOT_FROM = { title = e_persia }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_byzantine }
						ROOT_FROM = { title = e_byzantium }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_fylkir }
						ROOT_FROM = { title = d_norse_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_tengri_fylkir }
						ROOT_FROM = { title = d_tengri_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_west_african_fylkir }
						ROOT_FROM = { title = d_west_african_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_zun_fylkir }
						ROOT_FROM = { title = d_zun_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_slavic_fylkir }
						ROOT_FROM = { title = d_slavic_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_romuva_fylkir }
						ROOT_FROM = { title = d_baltic_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_aztec_fylkir }
						ROOT_FROM = { title = d_aztec_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = scepter_bon_fylkir }
						ROOT_FROM = { title = d_bon_pagan_reformed }
					}
					trigger_else = {
						artifact_type = scepter_hellenic_fylkir
						ROOT_FROM = { title = k_hellenic_pagan_reformed }
					}
				}

				transfer_artifact = {
					from = PREV
					to = ROOT
				}
			}
		}
	}
}

character_event = {
	id = HF.20406

	is_triggered_only = yes # on_death
	hide_window = yes

	only_rulers = yes

	trigger = {
		any_artifact = {
			trigger_if = {
				limit = { artifact_type = crown_hre }
				ROOT = { has_landed_title = e_hre }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_byzantine }
				ROOT = { has_landed_title = e_byzantium }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_pahlavi }
				ROOT = { has_landed_title = e_persia }
			}
			trigger_else_if = {
				limit = { artifact_type = iron_crown_of_lombardy }

				ROOT = {
					OR = {
						has_landed_title = e_hre
						has_landed_title = k_italy
					}
				}
			}
			trigger_else_if = {
				limit = { artifact_type = scepter_hellenic_fylkir }
				ROOT = { has_landed_title = k_hellenic_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_fylkir }
				ROOT = { has_landed_title = d_norse_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_tengri_fylkir }
				ROOT = { has_landed_title = d_tengri_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_finnish_fylkir }
				ROOT = { has_landed_title = d_finnish_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_west_african_fylkir }
				ROOT = { has_landed_title = d_west_african_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_slavic_fylkir }
				ROOT = { has_landed_title = d_slavic_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_romuva_fylkir }
				ROOT = { has_landed_title = d_baltic_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = scepter_bon_fylkir }
				ROOT = { has_landed_title = d_bon_pagan_reformed }
			}
			trigger_else_if = {
				limit = { artifact_type = crown_zun_fylkir }
				ROOT = { has_landed_title = d_zun_pagan_reformed }
			}
			trigger_else = {
				artifact_type = crown_aztec_fylkir
				ROOT = { has_landed_title = d_aztec_pagan_reformed }
			}
		}
	}

	immediate = {
		# Add special dead_crown trait to make the dead Emperors wear their special artifacts even after they've given up the artifact itself
		if = {
			limit = {
				primary_title = { title = e_hre }
				any_artifact = { artifact_type = crown_hre }
			}
			add_trait = dead_crown_hre
		}
		else_if = {
			limit = {
				primary_title = { title = e_byzantium }
				any_artifact = { artifact_type = crown_byzantine }
			}
			add_trait = dead_crown_byzantine
		}
		else_if = {
			limit = {
				primary_title = { title = e_persia }
				any_artifact = { artifact_type = crown_pahlavi }
			}
			add_trait = dead_crown_pahlavi
		}
		else_if = {
			limit = {
				primary_title = { title = k_italy }
				any_artifact = { artifact_type = iron_crown_of_lombardy }
			}
			add_trait = dead_iron_crown_lombardy
		}
		else_if = {
			limit = {
				has_landed_title = k_hellenic_pagan_reformed
				religion = hellenic_pagan_reformed
				any_artifact = { artifact_type = scepter_hellenic_fylkir }
			}
			add_trait = dead_scepter_hellenic_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_norse_pagan_reformed
				religion = norse_pagan_reformed
				any_artifact = { artifact_type = crown_fylkir }
			}
			add_trait = dead_crown_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_tengri_pagan_reformed
				religion = tengri_pagan_reformed
				any_artifact = { artifact_type = crown_tengri_fylkir }
			}
			add_trait = dead_crown_tengri_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_finnish_pagan_reformed
				religion = finnish_pagan_reformed
				any_artifact = { artifact_type = crown_finnish_fylkir }
			}
			add_trait = dead_crown_finnish_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_west_african_pagan_reformed
				religion = west_african_pagan_reformed
				any_artifact = { artifact_type = crown_west_african_fylkir }
			}
			add_trait = dead_crown_west_african_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_slavic_pagan_reformed
				religion = slavic_pagan_reformed
				any_artifact = { artifact_type = crown_slavic_fylkir }
			}
			add_trait = dead_crown_slavic_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_baltic_pagan_reformed
				religion = baltic_pagan_reformed
				any_artifact = { artifact_type = crown_romuva_fylkir }
			}
			add_trait = dead_crown_romuva_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_bon_pagan_reformed
				religion = bon_pagan_reformed
				any_artifact = { artifact_type = scepter_bon_fylkir }
			}
			add_trait = dead_scepter_bon_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_zun_pagan_reformed
				religion = zun_pagan_reformed
				any_artifact = { artifact_type = crown_zun_fylkir }
			}
			add_trait = dead_crown_zun_fylkir
		}
		else_if = {
			limit = {
				has_landed_title = d_aztec_pagan_reformed
				religion = aztec_pagan_reformed
				any_artifact = { artifact_type = crown_aztec_fylkir }
			}
			add_trait = dead_crown_aztec_fylkir
		}

		# Artifact inheritance for special artifacts, should always go along with the title
		any_demesne_title = {
			limit = {
				OR = {
					title = e_hre
					title = e_byzantium
					title = e_persia
					title = k_italy
					title = k_hellenic_pagan_reformed
					title = d_norse_pagan_reformed
					title = d_tengri_pagan_reformed
					title = d_finnish_pagan_reformed
					title = d_west_african_pagan_reformed
					title = d_slavic_pagan_reformed
					title = d_baltic_pagan_reformed
					title = d_bon_pagan_reformed
					title = d_zun_pagan_reformed
					title = d_aztec_pagan_reformed
				}

				current_heir = {
					NOT = { dynasty = ROOT }
				}
			}

			current_heir = {
				save_event_target_as = worthy_crown
			}

			ROOT = {
				any_artifact = {
					limit = {
						trigger_if = {
							limit = { PREVPREV = { title = e_hre } }
							artifact_type = crown_hre
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = e_persia } }
							artifact_type = crown_pahlavi
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = e_byzantium } }
							artifact_type = crown_byzantine
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_norse_pagan_reformed }}
							artifact_type = crown_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_tengri_pagan_reformed }}
							artifact_type = crown_tengri_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_west_african_pagan_reformed } }
							artifact_type = crown_west_african_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_zun_pagan_reformed } }
							artifact_type = crown_zun_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_slavic_pagan_reformed }}
							artifact_type = crown_slavic_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_baltic_pagan_reformed } }
							artifact_type = crown_romuva_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_aztec_pagan_reformed } }
							artifact_type = crown_aztec_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = d_bon_pagan_reformed } }
							artifact_type = scepter_bon_fylkir
						}
						trigger_else_if = {
							limit = { PREVPREV = { title = k_hellenic_pagan_reformed } }
							artifact_type = scepter_hellenic_fylkir
						}
						trigger_else = {
							artifact_type = iron_crown_of_lombardy

							PREVPREV = {
								OR = {
									title = k_italy
									title = e_hre
								}
							}
						}
					}

					transfer_artifact = {
						from = ROOT
						to = event_target:worthy_crown
					}
				}
			}
		}
	}
}

# Inherit special crowns on abdication
character_event = {
    id = HF.20407

    is_triggered_only = yes # on_new_holder_inheritance
    hide_window = yes

    trigger = {
		FROMFROM = {
			any_artifact = {
				trigger_if = {
					limit = { artifact_type = crown_hre }
					ROOT_FROM = { title = e_hre }
				}
				trigger_else_if = {
					limit = { artifact_type = iron_crown_of_lombardy }
					ROOT_FROM = { title = k_italy }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_pahlavi }
					ROOT_FROM = { title = e_persia }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_byzantine }
					ROOT_FROM = { title = e_byzantium }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_fylkir }
					ROOT_FROM = { title = d_norse_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_tengri_fylkir }
					ROOT_FROM = { title = d_tengri_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_west_african_fylkir }
					ROOT_FROM = { title = d_west_african_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_zun_fylkir }
					ROOT_FROM = { title = d_zun_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_slavic_fylkir }
					ROOT_FROM = { title = d_slavic_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_romuva_fylkir }
					ROOT_FROM = { title = d_baltic_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = crown_aztec_fylkir }
					ROOT_FROM = { title = d_aztec_pagan_reformed }
				}
				trigger_else_if = {
					limit = { artifact_type = scepter_bon_fylkir }
					ROOT_FROM = { title = d_bon_pagan_reformed }
				}
				trigger_else = {
					artifact_type = scepter_hellenic_fylkir
					ROOT_FROM = { title = k_hellenic_pagan_reformed }
				}
			}
		}
	}

	immediate = {
		FROMFROM = {
			any_artifact = {
				limit = {
					trigger_if = {
						limit = { artifact_type = crown_hre }
						ROOT_FROM = { title = e_hre }
					}
					trigger_else_if = {
						limit = { artifact_type = iron_crown_of_lombardy }
						ROOT_FROM = { title = k_italy }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_pahlavi }
						ROOT_FROM = { title = e_persia }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_byzantine }
						ROOT_FROM = { title = e_byzantium }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_fylkir }
						ROOT_FROM = { title = d_norse_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_tengri_fylkir }
						ROOT_FROM = { title = d_tengri_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_west_african_fylkir }
						ROOT_FROM = { title = d_west_african_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_zun_fylkir }
						ROOT_FROM = { title = d_zun_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_slavic_fylkir }
						ROOT_FROM = { title = d_slavic_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_romuva_fylkir }
						ROOT_FROM = { title = d_baltic_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = crown_aztec_fylkir }
						ROOT_FROM = { title = d_aztec_pagan_reformed }
					}
					trigger_else_if = {
						limit = { artifact_type = scepter_bon_fylkir }
						ROOT_FROM = { title = d_bon_pagan_reformed }
					}
					trigger_else = {
						artifact_type = scepter_hellenic_fylkir
						ROOT_FROM = { title = k_hellenic_pagan_reformed }
					}
				}

				transfer_artifact = {
					from = ROOT_FROMFROM
					to = ROOT
				}
			}
		}
	}
}

# on_conversion: Clean up uncrowned modifier
character_event = {
	id = HF.20416

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_character_modifier = uncrowned_modifier
		NOT = { is_decision_potential = prepare_coronation_ceremony }
	}

	immediate = {
		remove_character_modifiers = {
			name = uncrowned_modifier
			amount = 30
		}
	}
}

# on_new_holder: clean up uncrowned modifier. FROMFROM = Title's old holder.
character_event = {
	id = HF.20417

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		FROMFROM = {
			has_character_modifier = uncrowned_modifier
			NOT = { is_decision_potential = prepare_coronation_ceremony }
		}
	}

	immediate = {
		FROMFROM = {
			remove_character_modifiers = {
				name = uncrowned_modifier
				amount = 30
			}
		}
	}
}