namespace=FRC
########################################################################################################################################

####Coronation sponsor found, now decide how much money to invest in it. (REVISED WITH SCALED WEALTH)
character_event = {
	id = FRC.20300
	desc = {
		trigger = {			
			war = no
		}
		text = EVTDESCHFA20300
	}
	
	desc = {
		trigger = {
			war = yes
		}
		text = EVTDESCHFC20300
		picture = GFX_evt_mounted_combat_day_hf
	}

	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	immediate = {		
		save_event_target_as = coronation_ruler
		if = {
			limit = {
				OR = {
						religion = frtholic
						religion = frtholic_OLD
				}					 
			}
			b_reims = { owner = { save_event_target_as = coronation_priest } }
		}
		else = {
			random_realm_character = {
				limit = {
					NOT = { block_general_event_trigger = yes }
					is_theocracy = yes 
					religion = catholic
					any_liege = { character = ROOT }
				}
				save_event_target_as = coronation_priest
			}
		}		
	}

	option = { #flag_extravagant_coronation
		name = EVTOPTAHF20300
		trigger = { war = no }
		set_character_flag = flag_extravagant_coronation
		custom_tooltip = { text = send_extracoronation_invitations }
		if = { 
			limit = { ai = no } #Cheaty AI...
			scaled_wealth = { value = -1 min = -250 max = -1000 }
		}
		hidden_tooltip = {
			character_event = { id = FRC.20305 days = 11 } #Ceremony actually starts
			any_vassal = {
				limit =  {
					prisoner = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
				}
				character_event = { id = FRC.20301 } #Send Invitations
			}
			any_independent_ruler = {
				limit = { 
					war = no
					prisoner = no
					is_theocracy = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
					religion = ROOT 	
					is_within_diplo_range = ROOT
					higher_real_tier_than = DUKE
					NOT = { distance_from_realm = { who = ROOT value = 120 } }
				}
				character_event = { id = FRC.20302 } #Send Invitations to other Catholic neighbors
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 1 } 
			} 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 0.5 } 
			} 
			modifier = { 
				factor = 0.25
				NOT = { wealth = 0 } 
			} 
			modifier = { 
				factor = 0
				NOT = { wealth = -100 } 
			} 
			modifier = { 
				factor = 3
				tier = EMPEROR
			} 
			modifier = { 
				factor = 0.75
				trait = greedy
			} 
		}
	}
	option = { #flag_regular_coronation
		name = EVTOPTBHF20300
		trigger = { war = no }
		set_character_flag = flag_regular_coronation
		custom_tooltip = { text = send_coronation_invitations }
		hidden_tooltip = {
			character_event = { id = FRC.20305 days = 11 } #Ceremony actually starts
			any_vassal = {
				limit =  {
					prisoner = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
				}
				character_event = { id = FRC.20301 } #Send Invitations
			}
		}
		if = { 
			limit = { ai = no } #Cheaty AI...
			scaled_wealth = { value = -0.5 min = -100 max = -500 }
		}
		ai_chance = { 
			factor = 40 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 0.5 } 
			} 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 0.25 } 
			} 
			modifier = { 
				factor = 0.25
				NOT = { wealth = 0 } 
			} 
			modifier = { 
				factor = 0
				NOT = { wealth = -100 } 
			} 
			modifier = { 
				factor = 0.5
				tier = EMPEROR
			} 
			modifier = { 
				factor = 0.75
				trait = greedy
			} 
		}
	}
	option = { #flag_secluded_coronation
		name = {
			text = EVTOPTCHF20300
			trigger = {
				war = no
			}
		}
		name = {
			text = EVTOPTCHF20300_B
			trigger = {
				war = yes
			}
		}
		set_character_flag = flag_secluded_coronation
		custom_tooltip = { text = send_seclcoronation_invitations }
		if = { 
			limit = { ai = no } #Cheaty AI...
			scaled_wealth = { value = -0.05 min = -10 max = -150 }
		}
		hidden_tooltip = {
			character_event = { id = FRC.20305 days = 11 } #Ceremony actually starts
			any_courtier = {
				limit = { 
					is_councillor = yes 
					prisoner = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
				}
				character_event = { id = FRC.20301 } #Send Invitations
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = { 
				factor = 0.25
				NOT = { wealth = 0 } 
			} 
			modifier = { 
				factor = 3
				NOT = { wealth = -100 } 
			} 
			modifier = { 
				factor = 0.1
				tier = EMPEROR
			} 
			modifier = { 
				factor = 1.5
				trait = greedy
			}
		}
	}
}

#Vassal: King is inviting you to his coronation.
letter_event = {
	id = FRC.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
		hidden_tooltip = { FROM = { character_event = { id = FRC.20303 days = 3 random = 5 } } } #Notification.
		opinion = {
			modifier = opinion_coronation_guest
			months = 4
			who = FROM
		}
		add_character_modifier = {
			name = out_traveling #Vassal travel is short, so no regent needed.
			duration = 45
		}
		ai_chance = { 
			factor = 70 
		}
	}
	option = {	#End of the line
		name = EVTOPTBHF20301
		hidden_tooltip = { FROM = { character_event = { id = FRC.20304 days = 3 random = 5 } } } #Notification.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_dislike
				years = 10
				who = ROOT
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = {		#Of course he will be present.
				factor = 0
				event_target:coronation_priest = { character = ROOT }
			} 
			modifier = {
				factor = 0.3
				opinion = { who = from value = 100 }
			}
			modifier = {
				factor = 0.4
				opinion = { who = from value = 80 }
			}
			modifier = {
				factor = 0.5
				opinion = { who = from value = 60 }
			}
			modifier = {
				factor = 0.65
				opinion = { who = from value = 40 }
			}
			modifier = {
				factor = 0.75
				opinion = { who = from value = 20 }
			}
			modifier = {
				factor = 0.85
				opinion = { who = from value = 0 }
			}
			modifier = {
				factor = 1.15
				NOT = { opinion = { who = from value = 0 } }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = from value = -20 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -40 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -60 } }
			}
			modifier = {
				factor = 1.75
				NOT = { opinion = { who = from value = -80 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = from value = -100 } }
			}
		}
	}
}
#Foreign King: King is inviting you to his coronation.
letter_event = {
	id = FRC.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
		hidden_tooltip = { FROM = { character_event = { id = FRC.20303 days = 5 random = 5 } } } #Notification.
		FROM = { 
			prestige = 75	# Prestigious guests bring prestige.
		}
		opinion = {
			modifier = opinion_coronation_guest
			months = 4
			who = FROM
		}
		add_trait = travelling #Foreign King's travel is longer, it needs a regent, as if it were a pilgrimage.
		#add_character_modifier = {
		#	name = out_traveling
		#	duration = 45
		#}
		ai_chance = { 
			factor = 70 
		}
	}
	option = {	#End of the line
		name = EVTOPTBHF20302
		hidden_tooltip = { FROM = { character_event = { id = FRC.20304 days = 5 random = 5 } } } #Notification.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_dislike
				years = 10
				who = ROOT
			}
		}
		ai_chance = { 
			factor = 30
			modifier = {		#Of course he will be present.
				factor = 0
				event_target:coronation_priest = { character = ROOT }
			} 
			modifier = {
				factor = 0.3
				opinion = { who = from value = 100 }
			}
			modifier = {
				factor = 0.4
				opinion = { who = from value = 80 }
			}
			modifier = {
				factor = 0.5
				opinion = { who = from value = 60 }
			}
			modifier = {
				factor = 0.65
				opinion = { who = from value = 40 }
			}
			modifier = {
				factor = 0.75
				opinion = { who = from value = 20 }
			}
			modifier = {
				factor = 0.85
				opinion = { who = from value = 0 }
			}
			modifier = {
				factor = 1.15
				NOT = { opinion = { who = from value = 0 } }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = from value = -20 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -40 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -60 } }
			}
			modifier = {
				factor = 1.75
				NOT = { opinion = { who = from value = -80 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = from value = -100 } }
			}
		}
	}
}
#King Notification: Vassal will come to the Coronation Ceremony
letter_event = {
	id = FRC.20303
	desc = EVTDESCHF20303

	trigger = {		
		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}
	notification = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20303
	}
}
#King Notification: Vassal will not come to the Coronation Ceremony
letter_event = {
	id = FRC.20304
	desc = EVTDESCHF20304

	trigger = {		
		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}
	notification = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20304
	}
}

#King: Day 11 from budget, ceremony starts.
character_event = {
	id = FRC.20305
	desc = {
		trigger = {
			has_character_flag = flag_extravagant_coronation 
			war = no
		}
		text = EVTDESCHFA20305
	}
	desc = {
		trigger = {
			has_character_flag = flag_regular_coronation
			war = no
		}
		text = EVTDESCHFB20305
	}
	desc = {
		trigger = {
			has_character_flag = flag_secluded_coronation
			war = no
		}
		text = EVTDESCHFC20305
	}
	desc = {
		trigger = {
			war = yes
		}
		text = EVTDESDHFD20305
		picture = GFX_evt_mounted_combat_day_hf
	}
	picture = GFX_evt_magnificent_castle
	border = GFX_event_normal_frame_religion

	trigger = { 		
		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.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20305			
		hidden_tooltip = { set_variable = { which = coronation_count value = 0 } } 
		hidden_tooltip = { character_event = { id = FRC.20365 days = 3 random = 3 } } # First and second row of random list.
		hidden_tooltip = { character_event = { id = FRC.20366 days = 32 } } #THE CORONATION ITSELF # For safety reasons, just in case guests die in the middle of the feast and prevent the last event from firing.		
	}
}

#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 = FRC.20365
	hide_window = yes

	trigger = { 
		event_target:coronation_ruler = {			
			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.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crownied is still alive.		
	}

	is_triggered_only = yes
	
	immediate = {
		character_event = { id = FRC.20366 days = 15 } 
	}
}

#CORONATION EVENT
character_event = {
	id = FRC.20366
	title = EVTTITLE20366
	desc = {
		trigger = {
			ROOT = { 
				war = no
				#has_landed_title = e_french_religions_head
				primary_title = { has_law = succ_hre_elective }					
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
			}
		}
		text = EVTDESC_FRC_A20366		# Top localization for an Holy Roman Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no				
				#has_landed_title = e_french_religions_head
				NOT = { primary_title = { has_law = succ_hre_elective } }				
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope				
			}
		}
		text = EVTDESC_FRC_B20366		# Localization for any adult Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}	
	desc = {
		trigger = {
			ROOT = { 
				war = no
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope				
			}
		}
		text = EVTDESC_FRC_C20366		# Localization for any adult ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = yes
				has_character_flag = flag_crowned_by_pope
			}
		}
		text = EVTDESC_FRC_D20366		# War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
	}
	picture = GFX_evt_found_hre
	border = GFX_event_normal_frame_religion
	hide_new = yes
	trigger = { 
		NOT = { has_character_flag = flag_being_coronated }
		event_target:coronation_ruler = { 			
			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
			} 
		}
		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_ruler = { character = ROOT }
	}

	is_triggered_only = yes

	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
		}
		ROOT = {
			remove_character_modifiers = { modifier = uncrowned_modifier amount = 30 } 
			set_variable = { which = uncrowned_count value = 0 }
			set_character_flag = flag_being_coronated #Safety check to avoid double event.
		}
		ROOT = { save_persistent_event_target = { name = coronation_priest_per scope = event_target:coronation_priest } } #Needed to localize the trait properly.
	} 	
	
	option = {
		name = EVTOPTAHF20366
		#Assign proper trait.
		custom_tooltip = { text = tooltip_gain_crowned_by_pope }
		hidden_tooltip = { add_trait = crowned_by_pope }
		#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
				days = -1
			}
		}
		if = { 
			limit = { 
				war = yes
				has_character_flag = flag_secluded_coronation 
			} 
			add_character_modifier = {
				name = crowned_in_war
				days = -1
			}
		}
		if = { 
			limit = { 
				has_character_flag = flag_extravagant_coronation 
				NOT = { has_character_flag = flag_crowned_by_priest } 
			} 
			add_character_modifier = {
				name = extravagant_coronation
				days = 7300
			}
		}
		#Notify all guests, then conclude the ceremony.
		hidden_tooltip = {  
			character_event = { id = HF.20369 days = 3 random = 3 } #wrap up, clear all flags.
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				}
				character_event = { id = HF.20367 } #Coronation event for guests.
				character_event = { id = HF.20370 days = 3 random = 3 } #wrap up, clear all flags.
			}
			any_vassal = { 
				limit = { 
					NOT = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
					}
				}
				character_event = { id = HF.20368 } #Smaller notification for vassals who did not attend to the ceremony.
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				}
				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_tooltip = { remove_character_modifier = coronation_request_cooldown }
		clr_character_flag = flag_being_coronated
	}
}

############ For Cathoic
character_event = {
	id = FRC.20200
	title = EVTTITLE20200
	desc = EVTDESCHF20200

	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = { #Ask to be crowned by the Pope
		name = EVTOPTAHF20200
		trigger = { 
			NOT = { trait = excommunicated }
			rightful_religious_head_scope = { 
				is_alive = yes 
				NOT = { block_general_event_trigger = yes }
				has_landed_title = k_catholic_head
			} 
		}
		religion_head = { show_portrait = THIS }
		custom_tooltip = { text = EVTTOOLTIPHF20201 }
		hidden_tooltip = { religion_head = { letter_event = { id = HF.20201 days = 30 random = 5 } } }
		ai_chance = { 
			factor = 70
			modifier = {
				factor = 0.7
				tier = EMPEROR
			}
			modifier = {
				factor = 0.1
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = -80 
						} 
					}
				}
			}
			modifier = {
				factor = 0.25
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = -60 
						} 
					}
				}
			}
			modifier = {
				factor = 0.5
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = -40 
						} 
					}
				}
			}
			modifier = {
				factor = 0.7
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = -20 
						} 
					}
				}
			}
			modifier = {
				factor = 0.8
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = 0 
						} 
					}
				}
			}
			modifier = {
				factor = 1.25
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = 20 
						} 
					}
				}
			}
			modifier = {
				factor = 1.25
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = 40 
						} 
					}
				}
			}
			modifier = {
				factor = 1.5
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = 60 
						} 
					}
				}
			}
			modifier = {
				factor = 1.75
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = 80 
						} 
					}
				}
			}
			modifier = {
				factor = 2
				religion_head = { 
					has_landed_title = k_catholic_head
					NOT = { 
						opinion = { 
							who = ROOT
							value = 100 
						} 
					}
				}
			}
		}
	}
	option = { #Invested by powerful Bishop
		name = EVTOPTBHF20200
		trigger = { 
			NOT = { trait = excommunicated }
			OR = { 
				lower_tier_than = EMPEROR
				primary_title = { has_law = investiture_law_1 }
			} 
			any_realm_character = { 
				is_theocracy = yes 
				any_liege = { character = ROOT }
				religion = ROOT
				NOT = { block_general_event_trigger = yes }
				OR = { 
					higher_tier_than = BARON  
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } #Antipope
				}
				NOT = { has_landed_title = k_papal_state }
				NOT = { has_landed_title = d_fraticelli }
			}
		}
		custom_tooltip = { text = EVTTOOLTIPBHF20200 }
		if = { #If Pope is available but he's snubbed by an Emperor, he'll get mad.
			limit = { 
				tier = EMPEROR
				religion_head = { 
					is_alive = yes 
					has_landed_title = k_catholic_head 
				}
			}
			custom_tooltip = { text = scorned_the_pope }
			hidden_tooltip = { 
				religion_head = { 		
					show_scope_change = no	
					opinion = {
						modifier = opinion_offended
						years = 30
						who = ROOT
					} 
				} 
			}
		}
		
		random_realm_character = { 
			limit = { 
				is_theocracy = yes 
				any_liege = { character = ROOT }
				religion = ROOT
				NOT = { block_general_event_trigger = yes }
				OR = { 
					higher_tier_than = BARON  
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } #Antipope
				}
				NOT = { has_landed_title = k_papal_state }
				NOT = { has_landed_title = d_fraticelli }
			}
			preferred_limit = { #First search for a possible antipopes.
				any_claim = { title = k_papal_state } 
			}
			preferred_limit = { 
				any_claim = { title = d_fraticelli } 
			}
			preferred_limit = { 
				has_minor_title = title_cardinal
			}
			preferred_limit = { 
				has_minor_title = title_fraticelli_cardinal
			}
			hidden_tooltip = { letter_event = { id = HF.20201 days = 30 random = 5 } } 
			break = yes
		}
		ai_chance = { 
			factor = 30
			modifier = { factor = 1 

			} 
		}
	}
	option = { #Invested by random priest
		name = EVTOPTCHF20200
		trigger = { 
			OR = { 
				lower_tier_than = EMPEROR
				primary_title = { has_law = investiture_law_1 }
			} 
			any_realm_character = { 
				is_theocracy = yes 
				any_liege = { character = ROOT }
				lower_tier_than = COUNT
				religion = ROOT
				NOR = { 
					has_landed_title = k_papal_state
					has_landed_title = d_fraticelli
					higher_real_tier_than = BARON 
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } #Antipope
				}
			}
		}
		custom_tooltip = { text = EVTTOOLTIPCHF20200 }
		if = { #Emperors not crowned by Pope or Antipope receive an additional penalty
			limit = { tier = EMPEROR }
			prestige = -300
			piety = -75
		}
		if = { #If Pope is available but he's snubbed by an Emperor, he'll get mad.
			limit = { 
				tier = EMPEROR
				religion_head = { 
					is_alive = yes 
					has_landed_title = k_catholic_head 
				}
			}
			custom_tooltip = { text = scorned_the_pope }
			hidden_tooltip = { 
				religion_head = { 		
					show_scope_change = no	
					opinion = {
						modifier = opinion_offended
						years = 30
						who = ROOT
					} 
				} 
			}
		}
		if = { #If powerful theocrats are available but player picks random priest, the other theocrats will be mad.
			limit = { 
				OR = { 
					lower_tier_than = EMPEROR
					primary_title = { has_law = investiture_law_1 }
				} 
				NOT = { trait = excommunicated }
				any_realm_character = { 
					is_theocracy = yes 
					religion = ROOT
					any_liege = { character = ROOT }
					NOT = { block_general_event_trigger = yes }
					OR = { 
						higher_real_tier_than = BARON 
						has_minor_title = title_cardinal
						has_minor_title = title_fraticelli_cardinal
						any_claim = { title = k_papal_state } #Antipope
						any_claim = { title = d_fraticelli } 
					}
					NOT = { has_landed_title = k_papal_state }
					NOT = { has_landed_title = d_fraticelli }
				}
			}
			custom_tooltip = { text = scorned_powerful_theocrats }
			hidden_tooltip = { 
				any_realm_character = { 
					limit = {
						is_theocracy = yes 
						religion = ROOT
						any_liege = { character = ROOT }
						NOT = { block_general_event_trigger = yes }
						OR = { 
							higher_real_tier_than = BARON 
							has_minor_title = title_cardinal
							has_minor_title = title_fraticelli_cardinal
							any_claim = { title = k_papal_state } #Antipope
							any_claim = { title = d_fraticelli } 
						}
						NOT = { has_landed_title = k_papal_state }
						NOT = { has_landed_title = d_fraticelli }
					}			
					opinion = {
						modifier = opinion_offended
						years = 10
						who = ROOT
					} 
				}
			}
		}
		random_realm_character = { 
			limit = {
				is_theocracy = yes 
				lower_tier_than = COUNT
				religion = ROOT
				any_liege = { character = ROOT }
				NOT = { block_general_event_trigger = yes }
				NOR = { 
					has_landed_title = k_papal_state
					has_landed_title = d_fraticelli
					higher_real_tier_than = BARON 
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } 
				}
			}
			preferred_limit = { 
				opinion = { 
					who = ROOT
					value = 50 
				}
			}
			preferred_limit = { 
				opinion = { 
					who = ROOT
					value = 20 
				}
			}
			hidden_tooltip = { letter_event = { id = HF.20201 days = 30 random = 5 } } 
			break = yes
		}
		ai_chance = { 
			factor = 10
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 1.5
				trait = shy
			}
			modifier = {
				factor = 1.25
				trait = content
			}
			modifier = {
				factor = 0.7
				trait = proud
			}
			modifier = {
				factor = 0.7
				trait = ambitious
			}
			modifier = {
				factor = 0.7
				tier = EMPEROR
			}
			modifier = {
				factor = 0.5
				has_landed_title = e_hre
			}
		}
	}
	option = { #Changed your mind, not yet.
		name = EVTOPTDHF20200
		custom_tooltip = { text = coronation_canceled }
		##clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		hidden_tooltip = { remove_character_modifier = coronation_request_cooldown }
		ai_chance = { factor = 0 }	
	}
}