namespace = Plus

# Plus.1150 to Plus.1199

#######################################
# HRE / Carolingian Empire Events
# Written by Rylock
#######################################

# Upon a new Carolingian emperor ascending to the throne
character_event = {
	id = Plus.1150
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		FROM = { title = e_karling }
		e_karling = {
			OR = {
				has_law = crown_authority_0
				has_law = crown_authority_1
			}
		}
	}
	
	immediate = {
		character_event = { id = Plus.1151 days = 2 }
	}
}

character_event = {
	id = Plus.1151
	
	hide_window = yes
	is_triggered_only = yes
	
	only_independent = yes

	trigger = {
		has_landed_title = e_karling
	}
	
	immediate = {		
		# Send an acceptance event to all duke & king vassals
		any_vassal = {
			limit = { higher_tier_than = COUNT }
			character_event = { id = Plus.1152 days = 3 }
		}		
		# Follow-up succeed-or-fail events (only one will be valid}
		narrative_event = { id = Plus.1161 days = 15 } # coronated by the Pope
		narrative_event = { id = Plus.1162 days = 15 } # empire dissolves
	}
}

# Event to Carolingian vassals -- do you accept the new emperor or declare independence?
character_event = {
	id = Plus.1152
	title = EVTNAME_Plus_1152
	desc = EVTDESC_Plus_1152
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	trigger = {
		vassal_of = FROM
	}
	
	option = {
		name = EVTOPTA_Plus_1152 # declare independence
		trigger = {
			in_revolt = no
			prisoner = no
			is_adult = yes
			NOT = { trait = incapable }
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				religion = FROM
				is_close_relative = FROM
			}
			modifier = {
				factor = 0.5
				OR = {
					dynasty = FROM
					is_allied_with = FROM
				}
			}
			modifier = {
				factor = 3
				#the emperor is not a Karling
				FROM = { NOT = { dynasty = 25061 } }
			}
			modifier = {
				factor = 3
				NOT = { religion = FROM }
			}
			modifier = {
				factor = 1.25
				NOT = { culture = FROM }
				NAND = { # German cultures are more accepting of each other
					FROM = { german_cultures_trigger = yes }
					german_cultures_trigger = yes
				}
			}
			modifier = {
				factor = 1.25
				NOT = { culture_group = FROM }
			}
			modifier = {
				factor = 10
				in_faction = faction_separatist
			}
			modifier = {
				factor = 0.5
				NOT = { year = 880 }
			}
			modifier = {
				factor = 1.25
				year = 900
			}
			modifier = {
				factor = 1.25
				year = 925
			}
			modifier = {
				factor = 1.25
				year = 950
			}
			modifier = {
				factor = 1.25
				year = 975
			}
			modifier = {
				factor = 1.25
				year = 1000
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = -50 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = -75 } }
			}
			modifier = {
				factor = 1.5
				relative_power = { who = FROM power = 1.0 }
			}
			modifier = {
				factor = 2
				relative_power = { who = FROM power = 1.5 }
			}
			modifier = {
				factor = 2.5
				relative_power = { who = FROM power = 2.0 }
			}
			modifier = {
				factor = 1.5
				any_allied_character = {
					war = no
					independent = yes
					is_ruler = yes
					NOT = { same_realm = ROOT }
					higher_tier_than = DUKE
				}
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 1.5
				trait = envious
			}
			modifier = {
				factor = 1.5
				trait = greedy
			}
			modifier = {
				factor = 10
				trait = lunatic
			}
			modifier = {
				factor = 0.1
				trait = possessed
				has_character_modifier = voice_of_jesus
			}
			modifier = {
				factor = 10
				trait = possessed
				has_character_modifier = voice_of_satan
			}
		}
		set_defacto_liege = ROOT
		pf_liege_change_effect = yes
		hidden_tooltip = {
			FROM = { letter_event = { id = Plus.1153 } }
		}
	}
	option = {
		name = EVTOPTB_Plus_1152 # remain loyal vassal
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				OR = {
					dynasty = FROM
					is_allied_with = FROM
				}
			}
			modifier = {
				factor = 3
				tier = DUKE
			}
			modifier = {
				factor = 2
				e_karling = { has_law = crown_authority_1 }
			}
			modifier = {
				factor = 2
				in_faction = faction_court
			}
			modifier = {
				factor = 2
				NOT = { year = 880 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 1.5
				NOT = { relative_power = { who = FROM power = 0.5 } }
			}
			modifier = {
				factor = 1.5
				NOT = { relative_power = { who = FROM power = 0.25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { relative_power = { who = FROM power = 0.1 } }
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 1.5
				trait = patient
			}
			modifier = {
				factor = 1.5
				trait = humble
			}
		}
	}
}

# Notification to the new Carolingian emperor of a declaration of independence
letter_event = {
	id = Plus.1153
	desc = EVTDESC_Plus_1153
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_1153
		FROM = {
			any_demesne_title = {
				limit = {
					higher_tier_than = COUNT
					NOT = { ROOT = { has_claim = PREV } }
				}
				add_claim = ROOT
			}
			reverse_opinion = {
				modifier = opinion_traitor
				who = FROM
				multiplier = 2
				years = 25
			}
		}
	}
}

# Carolingian Emperor has a large enough empire
narrative_event = {
	id = Plus.1161
	title = EVTNAME_Plus_1161
	desc = EVTDESC_Plus_1161
	picture = GFX_evt_cathedral
	border = GFX_event_narrative_frame_diplomacy
	
	is_triggered_only = yes
	
	only_independent = yes
	
	trigger = {
		has_landed_title = e_karling
		any_realm_title = {
			tier = count
			count = 100
		}
	}
	
	option = {
		name = OK
		prestige = 100
	}
}

# Carolingian Emperor has a too-small domain, and the empire is dissolved
narrative_event = {
	id = Plus.1162
	title = EVTNAME_Plus_1162
	desc = EVTDESC_Plus_1162
	picture = GFX_evt_cathedral
	border = GFX_event_narrative_frame_diplomacy

	is_triggered_only = yes
	
	only_independent = yes
	
	trigger = {
		has_landed_title = e_karling
		NOT = {
			any_realm_title = {
				tier = count
				count = 100
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1162
		set_character_flag = former_carolingian_emperor
		hidden_tooltip = {
			e_karling = {
				any_direct_de_jure_vassal_title = {
					limit = {
						OR = {
							title = k_italy
							title = k_burgundy
							title = k_lotharingia
							title = k_frisia
							title = k_germany
						}
					}
					de_jure_liege = e_hre
				}
			}
			e_karling = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = e_placeholder
				}
			}
			any_character = {
				limit = { has_claim = e_karling }
				if = {
					limit = { has_weak_claim = e_karling }
					add_weak_pressed_claim = k_germany
					remove_claim = e_karling
				}
				if = {
					limit = { has_strong_claim = e_karling }
					add_pressed_claim = k_germany
					remove_claim = e_karling
				}
			}
			e_hre = {
				copy_title_laws = e_karling
				copy_title_history = e_karling
			}
		}
		e_karling = {
			set_title_flag = carolingian_empire_fallen
			destroy_landed_title = yes
		}
		if = {
			limit = { trait = crowned_by_pope }
			remove_trait = crowned_by_pope
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = END_OF_CAROLINGIAN_EMPIRE
				portrait = [Root.GetID]
				picture = GFX_evt_cathedral
			}
		}
		hidden_tooltip = {
			activate_title = { title = e_karling status = no }
			any_playable_ruler = {
				limit = {
					NOT = { character = ROOT }
					ai = no
				}
				narrative_event = { id = Plus.1163 }
			}
		}
	}
}

# Rulers informed of Carolingian Empire's demise
narrative_event = {
	id = Plus.1163
	title = EVTNAME_Plus_1162
	desc = EVTDESC_Plus_1163
	picture = GFX_evt_cathedral
	border = GFX_event_narrative_frame_diplomacy

	is_triggered_only = yes

	only_playable = yes
	
	option = {
		name = "EVTOPTA_Plus_1163"
		trigger = { religion_group = christian }
		if = {
			limit = { ai = no }
			chronicle = {
				entry = END_OF_CAROLINGIAN_EMPIRE_NEWS
				picture = GFX_evt_cathedral
			}
		}
	}
	option = {
		name = "EVTOPTB_Plus_1163"
		trigger = { NOT = { religion_group = christian } }
		if = {
			limit = { ai = no }
			chronicle = {
				entry = END_OF_CAROLINGIAN_EMPIRE_NEWS
				picture = GFX_evt_cathedral
			}
		}
	}
}

# Rulers informed of land given to Pope
character_event = {
	id = Plus.1164
	desc = EVTDESC_Plus_1164
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	immediate = {
		FROM = {
			rightful_religious_head_scope = {
				save_event_target_as = current_pope
			}
		}
	}
	
	option = {
		name = EVTOPTA_Plus_1164
		if = {
			limit = {
				any_demesne_title = {
					tier = COUNT
					NOR = {
						title = c_roma
						title = c_ravenna
						title = c_ferrara
						title = c_urbino
						title = c_spoleto
						title = c_orvieto
					}
				}
			}
			any_demesne_title = {
				limit = {
					OR = {
						title = c_roma
						title = c_ravenna
						title = c_ferrara
						title = c_urbino
						title = c_spoleto
						title = c_orvieto
					}
				}
				grant_title = event_target:current_pope
			}
			break = yes
		}
		if = {
			limit = { tier = KING }
			any_demesne_title = {
				limit = {
					location = { is_capital = no }
					OR = {
						title = c_roma
						title = c_ravenna
						title = c_ferrara
						title = c_urbino
						title = c_spoleto
						title = c_orvieto
					}
				}
				grant_title = event_target:current_pope
			}
			break = yes
		}
		event_target:current_pope = { set_defacto_vassal = ROOT }
		pf_liege_change_effect = yes
	}
}


### EVENTS TO FORM THE HRE AFTER CAROLINGIAN EMPIRE'S END

# Asking the pope for blessing to form the HRE
letter_event = {
	id = Plus.1155
	desc = "EVTDESC_Plus_1176"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1176"	# Accept
		ai_chance = {
			factor = 75
			modifier = {
				factor = 1.2
				opinion = {
					who = FROM
					value = 20
				}
			}
			modifier = {
				factor = 1.2
				opinion = {
					who = FROM
					value = 40
				}
			}
			modifier = {
				factor = 1.2
				opinion = {
					who = FROM
					value = 60
				}
			}
			modifier = {
				factor = 1.2
				opinion = {
					who = FROM
					value = 80
				}
			}
			modifier = {
				factor = 1.2
				opinion = {
					who = FROM
					value = 100
				}
			}
			modifier = {
				factor = 2.0
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 2.0
				FROM = { trait = crusader }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 400 }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 600 }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 800 }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 1000 }
			}
		}
		wealth = 100
		FROM = {
			character_event = { id = Plus.1157 days = 30 }
		}
	}
	option = {
		name = "EVTOPTB_Plus_1176"	# Reject
		ai_chance = {
			factor = 25
			modifier = {
				factor = 1.2
				NOT = {
					opinion = {
						who = FROM
						value = -100
					}
				}
			}
			modifier = {
				factor = 1.2
				NOT = {
					opinion = {
						who = FROM
						value = -80
					}
				}
			}
			modifier = {
				factor = 1.2
				NOT = {
					opinion = {
						who = FROM
						value = -60
					}
				}
			}
			modifier = {
				factor = 1.2
				NOT = {
					opinion = {
						who = FROM
						value = -40
					}
				}
			}
			modifier = {
				factor = 1.2
				NOT = {
					opinion = {
						who = FROM
						value = -20
					}
				}
			}
			modifier = {
				factor = 1.2
				NOT = {
					opinion = {
						who = FROM
						value = 0
					}
				}
			}
			modifier = {
				factor = 2.0
				FROM = {
					OR = {
						trait = lunatic
						trait = possessed
					}
				}
			}
			modifier = {
				factor = 2.0
				FROM = { trait = kinslayer }
			}
			modifier = {
				factor = 2.0
				FROM = { trait = cynical }
			}
			modifier = {
				factor = 0
				FROM = { ai = yes }
			}
		}
		FROM = {
			letter_event = { id = Plus.1156 days = 30 }
		}
		opinion = {
			modifier = coronation_rejected
			who = FROM
			years = 2
		}
	}
}

# The pope refuses the coronation
letter_event = {
	id = Plus.1156
	desc = "EVTDESC_Plus_1178"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1178"	# Maybe we should try again later
		FROM = { clr_character_flag = approached_for_coronation }
		prestige = -50
		opinion = {
			modifier = coronation_rejected 
			who = FROM
			years = 2
		}
	}
}

# The pope agrees to the coronation -- the HRE is formed
character_event = {
	id = Plus.1157
	title = "EVTNAME_Plus_1157"
	desc = "EVTDESC_Plus_1157"
	picture = "GFX_evt_holy_emperor"
	sound = church_bells

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1181"	# This is the happiest day of my life
		e_hre = { set_title_flag = hre_formed }
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_FOUNDED_HRE
				picture = GFX_evt_coronation
			}
		}
		if = {
			limit = { trait = crowned }
			remove_trait = crowned
		}
		add_trait = crowned_by_pope
		give_nickname = nick_the_great
		prestige = 500
		opinion = { modifier = opinion_grateful who = FROM years = 100 }
		
		# copy primary title laws but make HRE have feudal elective & no CA
		hidden_tooltip = {
			primary_title = {
				e_hre = {
					copy_title_laws = PREV
					add_law_w_cooldown = crown_authority_0
					add_law = succ_feudal_elective
					set_title_flag = do_not_destroy
				}
			}
		}
		
		# give the ERE title and destroy other imperial titles
		e_hre = { grant_title = ROOT }
		any_demesne_title = {
			limit = {
				tier = EMPEROR
				NOT = { title = e_hre }
			}
			hidden_tooltip = { any_direct_de_jure_vassal_title = { de_jure_liege = e_hre } }
			destroy_landed_title = THIS
		}
		
		hidden_tooltip = {
			if = {
				limit = { e_karling = { NOT = { has_title_flag = carolingian_empire_fallen } } }
				e_karling = { set_title_flag = carolingian_empire_fallen }
			}
			# reset East Francia to Germany
			k_germany = {
				set_name = ""
				adjective = ""
			}
			# rename West Francia if it hasn't been already
			if = {
				limit = { NOT = { has_global_flag = west_francia_renamed } }
				set_global_flag = west_francia_renamed
				k_france = {
					set_name = ""
					adjective = ""
				}
			}
			# reset Middle Francia to Lotharingia
			k_lotharingia = {
				set_name = ""
				adjective = ""
			}

			# stem duchy setup
			if = { # Austria Owner Check
				limit = { k_austria = { has_holder = no } }
				activate_title = { title = k_arch_austria status = yes }
				k_austria = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_arch_austria
					}
				}
				k_arch_austria = {
					copy_title_history = k_austria
				}
				any_realm_character = {
					limit = { has_claim = k_austria }
					k_arch_austria = { add_pressed_claim = PREV }
					remove_claim = k_austria
				}
				any_playable_ruler = {
					any_realm_character = {
						limit = { has_claim = k_austria }
						k_arch_austria = { add_pressed_claim = PREV }
						remove_claim = k_austria
					}
				}
				activate_title = { title = k_austria status = no }
			}
			if = { # Bavaria Owner Check
				limit = {
					k_bavaria = { has_holder = no }
				}
				activate_title = { title = k_grand_bavaria status = yes }
				k_bavaria = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_grand_bavaria
					}
				}
				k_grand_bavaria = {
					copy_title_history = k_bavaria
				}
				any_realm_character = {
					limit = { has_claim = k_bavaria }
					k_grand_bavaria = { add_pressed_claim = PREV }
					remove_claim = k_bavaria
				}
				any_playable_ruler = {
					any_realm_character = {
						limit = { has_claim = k_bavaria }
						k_grand_bavaria = { add_pressed_claim = PREV }
						remove_claim = k_bavaria
					}
				}
				activate_title = { title = k_bavaria status = no }
			}
			if = { # Franconia Owner Check
				limit = {
					k_franconia = { has_holder = no }
				}
				activate_title = { title = k_grand_franconia status = yes }
				k_franconia = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_grand_franconia
					}
				}
				k_grand_franconia = {
					copy_title_history = k_franconia
				}
				any_realm_character = {
					limit = { has_claim = k_franconia }
					k_grand_franconia = { add_pressed_claim = PREV }
					remove_claim = k_franconia
				}
				any_playable_ruler = {
					any_realm_character = {
						limit = { has_claim = k_franconia }
						k_grand_franconia = { add_pressed_claim = PREV }
						remove_claim = k_franconia
					}
				}
				activate_title = { title = k_franconia status = no }
			}
			if = { # Luxembourg Owner Check
				limit = {
					k_luxembourg = { has_holder = no }
				}
				activate_title = { title = k_grand_luxembourg status = yes }
				k_luxembourg = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_grand_luxembourg
					}
				}
				k_grand_luxembourg = {
					copy_title_history = k_luxembourg
				}
				any_realm_character = {
					limit = { has_claim = k_luxembourg }
					k_grand_luxembourg = { add_pressed_claim = PREV }
					remove_claim = k_luxembourg
				}
				any_playable_ruler = {
					any_realm_character = {
						limit = { has_claim = k_luxembourg }
						k_grand_luxembourg = { add_pressed_claim = PREV }
						remove_claim = k_luxembourg
					}
				}
				activate_title = { title = k_luxembourg status = no }
			}
			if = { # Saxony Owner Check
				limit = {
					k_saxony = { has_holder = no }
				}
				activate_title = { title = k_grand_saxony status = yes }
				k_saxony = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_grand_saxony
					}
				}
				k_grand_saxony = {
					copy_title_history = k_saxony
				}
				any_realm_character = {
					limit = { has_claim = k_saxony }
					k_grand_saxony = { add_pressed_claim = PREV }
					remove_claim = k_saxony
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_saxony }
						k_grand_saxony = { add_pressed_claim = PREV }
						remove_claim = k_saxony
					}
				}
				activate_title = { title = k_saxony status = no }
			}
			if = { # Swabia Owner Check
				limit = {
					k_swabia = { has_holder = no }
				}
				activate_title = { title = k_grand_swabia status = yes }
				k_swabia = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_grand_swabia
					}
				}
				k_grand_swabia = {
					copy_title_history = k_swabia
				}
				any_realm_character = {
					limit = { has_claim = k_swabia }
					k_grand_swabia = { add_pressed_claim = PREV }
					remove_claim = k_swabia
				}
				any_playable_ruler = {
					any_realm_character = {
						limit = { has_claim = k_swabia }
						k_grand_swabia = { add_pressed_claim = PREV }
						remove_claim = k_swabia
					}
				}
				activate_title = { title = k_swabia status = no }
			}
			if = { # Tuscany Owner Check
				limit = {
					k_tuscany = { has_holder = no }
				}
				activate_title = { title = k_grand_tuscany status = yes }
				k_tuscany = {
					any_direct_de_jure_vassal_title = {
						de_jure_liege = k_grand_tuscany
					}
				}
				k_grand_tuscany = {
					copy_title_history = k_tuscany
				}
				any_realm_character = {
					limit = { has_claim = k_tuscany }
					k_grand_tuscany = { add_pressed_claim = PREV }
					remove_claim = k_tuscany
				}
				any_playable_ruler = {
					any_realm_character = {
						limit = { has_claim = k_tuscany }
						k_grand_tuscany = { add_pressed_claim = PREV }
						remove_claim = k_tuscany
					}
				}
				activate_title = { title = k_tuscany status = no }
			}
			if = { # Brandenburg check
				limit = {
					completely_controls = d_brandenburg
					completely_controls = d_meissen
				}
				activate_title = { title = k_brandenburg status = yes }
				d_brandenburg = { de_jure_liege = k_brandenburg }
				d_meissen = { de_jure_liege = k_brandenburg }
			}
			
			# deal with k_germany
			if = {
				limit = { NOT = { is_title_active = k_germany } }
				activate_title = { title = k_germany status = yes }
				if = {
					limit = { k_germany = { is_titular = yes } }
					k_lotharingia = {
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_france } }
							de_jure_liege = k_france
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_aquitaine } }
							if = { 
								limit = { has_global_flag = west_francia_united }
								de_jure_liege = k_france
							}
							if = { 
								limit = { NOT = { has_global_flag = west_francia_united } }
								de_jure_liege = k_aquitaine
							}
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_frisia } }
							de_jure_liege = k_frisia
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_bohemia } }
							de_jure_liege = k_bohemia
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_pomerania } }
							de_jure_liege = k_pomerania
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_burgundy } }
							de_jure_liege = k_burgundy
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_italy } }
							de_jure_liege = k_italy
						}
						any_direct_de_jure_vassal_title = {
							limit = { capital_scope = { region = custom_poland } }
							de_jure_liege = k_poland
						}
					}
				}
				# put whatever portion of k_germany that the emperor has conquered into the kingdom so it can be distributed between stem duchies
				any_realm_province = {
					limit = {
						duchy = {
							capital_scope = { region = custom_germany }
							OR = {
								has_holder = no
								holder_scope = { same_realm = ROOT }
							}
						}
					}
					duchy = { de_jure_liege = k_germany }
				}
			}

			# change germany claims to hre claims
			any_character = {
				limit = { has_claim = k_germany }
				if = {
					limit = { has_weak_claim = k_germany }
					add_weak_pressed_claim = e_hre
					remove_claim = k_germany
				}
				if = {
					limit = { has_strong_claim = k_germany }
					add_pressed_claim = e_hre
					remove_claim = k_germany
				}
			}

			# break up germany into stem duchies
			k_germany = {
				any_direct_de_jure_vassal_title = { # Austria
					limit = {
						OR = {
							title = d_carinthia
							title = d_osterreich
						}
					}
					if = {
						limit = { is_title_active = k_austria }
						de_jure_liege = k_austria
					}
					if = {
						limit = { is_title_active = k_arch_austria }
						de_jure_liege = k_arch_austria
					}
				}
				any_direct_de_jure_vassal_title = { # Bavaria
					limit = {
						OR = {
							title = d_tyrol
							title = d_bavaria
						}
					}
					if = {
						limit = { is_title_active = k_bavaria }
						de_jure_liege = k_bavaria
					}
					if = {
						limit = { is_title_active = k_grand_bavaria }
						de_jure_liege = k_grand_bavaria
					}
				}
				any_direct_de_jure_vassal_title = { # Franconia
					limit = {
						OR = {
							title = d_thuringia
							title = d_franconia
						}
					}
					if = {
						limit = { is_title_active = k_franconia }
						de_jure_liege = k_franconia
					}
					if = {
						limit = { is_title_active = k_grand_franconia }
						de_jure_liege = k_grand_franconia
					}
				}
				any_direct_de_jure_vassal_title = { # Saxony
					limit = {
						OR = {
							title = d_westphalia
							title = d_eastphalia
						}
					}
					if = {
						limit = { is_title_active = k_saxony }
						de_jure_liege = k_saxony
					}
					if = {
						limit = { is_title_active = k_grand_saxony }
						de_jure_liege = k_grand_saxony
					}
				}
				any_direct_de_jure_vassal_title = { # Swabia
					limit = {
						OR = {
							title = d_swiss
							title = d_baden
							title = d_swabia
						}
					}
					if = {
						limit = { is_title_active = k_swabia }
						de_jure_liege = k_swabia
					}
					if = {
						limit = { is_title_active = k_grand_swabia }
						de_jure_liege = k_grand_swabia
					}
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_france } }
					de_jure_liege = k_france
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_aquitaine } }
					if = { 
						limit = { has_global_flag = west_francia_united }
						de_jure_liege = k_france
					}
					if = { 
						limit = { NOT = { has_global_flag = west_francia_united } }
						de_jure_liege = k_aquitaine
					}
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_lotharingia } }
					de_jure_liege = k_lotharingia
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_frisia } }
					de_jure_liege = k_frisia
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_bohemia } }
					de_jure_liege = k_bohemia
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_pomerania } }
					de_jure_liege = k_pomerania
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_burgundy } }
					de_jure_liege = k_burgundy
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_italy } }
					de_jure_liege = k_italy
				}
				any_direct_de_jure_vassal_title = {
					limit = { capital_scope = { region = custom_poland } }
					de_jure_liege = k_poland
				}
				destroy_landed_title = THIS
			}
			
			activate_title = { title = k_germany status = no }
			k_arch_austria = { de_jure_liege = e_hre }
			k_grand_bavaria = { de_jure_liege = e_hre }
			k_grand_franconia = { de_jure_liege = e_hre }
			k_grand_saxony = { de_jure_liege = e_hre }
			k_grand_swabia = { de_jure_liege = e_hre }
			k_grand_luxembourg = { de_jure_liege = e_hre }
			k_grand_tuscany = { de_jure_liege = e_hre }
			if = {
				limit = { is_title_active = k_brandenburg }
				k_brandenburg = { de_jure_liege = e_hre }
			}
		
			# send notification to potential HRE vassals
			any_independent_ruler = {
				limit = {
					religion = ROOT
					holy_order = no
					mercenary = no
					capital_scope = {
						OR = {
							empire = { title = e_hre }
							kingdom = { title = k_austria }
							kingdom = { title = k_bavaria }
							kingdom = { title = k_franconia }
							kingdom = { title = k_saxony }
							kingdom = { title = k_swabia }
							kingdom = { title = k_lotharingia }
							kingdom = { title = k_italy }
							kingdom = { title = k_frisia }
							kingdom = { title = k_burgundy }
							kingdom = { title = k_luxembourg }
							kingdom = { title = k_tuscany }
						}
					}
				}
				narrative_event = { id = Plus.1159 days = 10 }
			}
			# send notification to everyone else
			any_independent_ruler = {
				limit = {
					OR = {
						NOT = { religion = ROOT }
						holy_order = yes
						mercenary = yes
						capital_scope = {
							NOR = {
								empire = { title = e_hre }
								kingdom = { title = k_austria }
								kingdom = { title = k_bavaria }
								kingdom = { title = k_franconia }
								kingdom = { title = k_saxony }
								kingdom = { title = k_swabia }
								kingdom = { title = k_lotharingia }
								kingdom = { title = k_italy }
								kingdom = { title = k_frisia }
								kingdom = { title = k_burgundy }
								kingdom = { title = k_luxembourg }
								kingdom = { title = k_tuscany }
							}
						}
					}
				}
				narrative_event = { id = Plus.1158 days = 10 }
			}
		}
		any_demesne_title = {
			limit = {
				tier = KING
				NOR = {
					title = k_arch_austria
					title = k_austria
					title = k_grand_bavaria
					title = k_bavaria
					title = k_grand_franconia
					title = k_franconia
					title = k_grand_saxony
					title = k_saxony
					title = k_grand_swabia
					title = k_swabia
					title = k_grand_luxembourg
					title = k_luxembourg
					title = k_grand_tuscany
					title = k_tuscany
				}
			}
			if = {
				limit = {
					is_titular = no
					de_jure_liege = e_placeholder
				}
				de_jure_liege = e_hre
			}
			destroy_landed_title = THIS
		}

		# Byzantine Emperor will be very upset
		hidden_tooltip = {
			if = {
				limit = {
					e_byzantium = { has_holder = yes }
					NOT = { k_papal_state = { has_title_flag = schism_happened } }
					k_chalcedonian = { has_holder = no }
				}
				496 = { change_variable = { which = "schism_tracker" value = 1 } }
				rightful_religious_head_scope = {
					save_event_target_as = current_roman_pope
					e_byzantium = {
						holder_scope = {
							save_event_target_as = current_byzantine_emperor
							opinion = { who = ROOT modifier = opinion_unhappy months = 1200 }
							opinion = { who = PREVPREV modifier = opinion_unhappy multiplier = 2 months = 1200 }
							rightful_religious_head_scope = {
								opinion = { who = ROOT modifier = opinion_unhappy months = 1200 }
								opinion = { who = PREVPREVPREV modifier = opinion_unhappy multiplier = 2 months = 1200 }
							}
						}
					}
				}
				narrative_event = { id = Plus.2278 days = 3 }
			}
		}
	}
}

# Rulers not within the traditional HRE boundaries informed of the coronation
narrative_event = {
	id = Plus.1158
	title = "EVTNAME_Plus_1157"
	desc = "EVTDESC_CM_510"
	picture = "GFX_evt_holy_emperor"
	border = "GFX_event_narrative_frame_religion"

	is_triggered_only = yes

	option = {
		name = OK
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_FOUNDED_HRE_NEWS
				picture = GFX_evt_coronation
			}
		}
	}
}

# Rulers within the traditional HRE boundaries informed of the coronation
narrative_event = {
	id = Plus.1159
	title = "EVTNAME_Plus_1157"
	desc = "EVTDESC_CM_510"
	picture = "GFX_evt_holy_emperor"
	border = "GFX_event_narrative_frame_religion"

	is_triggered_only = yes
	only_rulers = yes

	option = {
		name = EVTOPTA_Plus_1159 # Offer to become his vassal
		trigger = {
			in_revolt = no
			lower_tier_than = FROM
			OR = {
				lower_tier_than = king
				has_landed_title = k_austria
				has_landed_title = k_bavaria
				has_landed_title = k_franconia
				has_landed_title = k_saxony
				has_landed_title = k_swabia
				has_landed_title = k_tuscany
				has_landed_title = k_luxembourg
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				capital_scope = {
					empire = { title = e_hre }
				}
			}
			modifier = {
				factor = 0.5
				tier = KING
			}
			modifier = {
				factor = 0
				OR = {
					controls_religion = yes
					rightful_religious_head = ROOT
				}
			}
			modifier = {
				factor = 0
				num_of_king_titles = 2
			}
			modifier = {
				factor = 1.5
				tier = COUNT
			}
			modifier = {
				factor = 1.5
				trait = zealous
			}
			modifier = {
				factor = 1.5
				any_realm_province = {
					has_province_flag = contingent_territory
					any_neighbor_province = {
						owner = {
							OR = {
								character = FROM
								any_liege = { character = FROM }
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.2
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 1.2
				dynasty = FROM
			}
			modifier = {
				factor = 0.1
				OR = {
					reverse_has_truce = FROM
					has_non_aggression_pact_with = FROM
				}
			}
			modifier = {
				factor = 0
				trait = excommunicated
			}
			modifier = {
				factor = 1.5
				OR = {
					is_friend = FROM
					any_allied_character = { character = FROM }
				}
			}		
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_FOUNDED_HRE_NEWS
				picture = GFX_evt_coronation
			}
		}
		FROM = {
			letter_event = { id = Plus.1160 tooltip = offer_to_become_vassal }
		}
	}
	option = {
		name = EVTOPTB_Plus_1159 # Wish him well
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				tier = KING
			}
			modifier = {
				factor = 3
				capital_scope = {
					NOT = { empire = { title = e_hre } }
				}
			}
			modifier = {
				factor = 2
				NOT = {
					any_realm_province = {
						has_province_flag = contingent_territory
						any_neighbor_province = {
							owner = {
								OR = {
									character = FROM
									any_liege = { character = FROM }
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				NOT = { culture = FROM }
				NAND = { # German cultures are more accepting of each other
					FROM = { german_cultures_trigger = yes }
					german_cultures_trigger = yes
				}
			}
			modifier = {
				factor = 1.5
				trait = cynical
			}
			modifier = {
				factor = 1.5
				trait = ambitious
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = FROM value = -50 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = FROM value = -75 } }
			}
			modifier = {
				factor = 0.5
				is_rival = FROM
			}
			modifier = {
				factor = 2
				realm_size = 50
			}
			modifier = {
				factor = 3
				realm_size = 75
			}
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_FOUNDED_HRE_NEWS
				picture = GFX_evt_coronation
			}
		}	
	}
}

# The ruler offers to become the new emperor's vassal
letter_event = {
	id = Plus.1160
	desc = "EVTDESC_Plus_1160"
	
	is_triggered_only = yes
	only_rulers = yes
	
	option = {
		name = EVTOPTA_Plus_1160 # Accept
		FROM = {
			set_defacto_liege = ROOT
			pf_liege_change_effect = yes
			any_demesne_title = {
				limit = {
					tier = KING
					NOT = { de_jure_liege = e_hre }
				}
				de_jure_liege = e_hre
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_1160 # Refuse
		trigger = { ai = no }
	}
}


### MAINTENANCE EVENTS

# Ruler has a stem duchy title but is not part of the HRE
character_event = {
	id = Plus.1170
	desc = EVTDESC_Plus_1170
	picture = GFX_evt_council
	
	is_triggered_only = yes
	
	only_rulers = yes
	
	trigger = {
		war = no
		OR = {
			has_landed_title = k_grand_saxony
			has_landed_title = k_grand_swabia
			has_landed_title = k_grand_franconia
			has_landed_title = k_grand_bavaria
			has_landed_title = k_grand_luxembourg
			has_landed_title = k_grand_tuscany
			has_landed_title = k_arch_austria
		}
		NOR = {
			top_liege = { has_landed_title = e_hre }
			top_liege = { liege_before_war = { has_landed_title = e_hre } } 
			liege_before_war = { has_landed_title = e_hre }
		}
	}
	
	option = {
		name = EXCELLENT
		if = {
			hidden_tooltip = { activate_title = { title = k_saxony status = yes } }
			limit = { has_landed_title = k_grand_saxony }
			k_grand_saxony = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_saxony
				}
			}
			hidden_tooltip = {
				k_saxony = {
					grant_title = ROOT
					copy_title_laws = k_grand_saxony
					copy_title_history = k_grand_saxony
				}		  
				any_realm_character = {
					limit = { has_claim = k_grand_saxony }
					k_saxony = { add_pressed_claim = PREV }
					remove_claim = k_grand_saxony
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_grand_saxony }
						k_saxony = { add_pressed_claim = PREV }
						remove_claim = k_grand_saxony
					}
				}
				k_grand_saxony = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_saxony = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_grand_saxony = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_grand_saxony status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_grand_swabia }
			hidden_tooltip = { activate_title = { title = k_swabia status = yes } }
			k_grand_swabia = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_swabia
				}
			}
			hidden_tooltip = {
				k_swabia = {
					grant_title = ROOT
					copy_title_laws = k_grand_swabia
					copy_title_history = k_grand_swabia
				}		  
				any_realm_character = {
					limit = { has_claim = k_grand_swabia }
					k_swabia = { add_pressed_claim = PREV }
					remove_claim = k_grand_swabia
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_grand_swabia }
						k_swabia = { add_pressed_claim = PREV }
						remove_claim = k_grand_swabia
					}
				}
				k_grand_swabia = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_swabia = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_grand_swabia = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_grand_swabia status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_grand_franconia }
			hidden_tooltip = { activate_title = { title = k_franconia status = yes } }
			k_grand_franconia = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_franconia
				}
			}
			hidden_tooltip = {
				k_franconia = {
					grant_title = ROOT
					copy_title_laws = k_grand_franconia
					copy_title_history = k_grand_franconia
				}		  
				any_realm_character = {
					limit = { has_claim = k_grand_franconia }
					k_franconia = { add_pressed_claim = PREV }
					remove_claim = k_grand_franconia
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_grand_franconia }
						k_franconia = { add_pressed_claim = PREV }
						remove_claim = k_grand_franconia
					}
				}
				k_grand_franconia = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_franconia = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_grand_franconia = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_grand_franconia status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_grand_bavaria }
			hidden_tooltip = { activate_title = { title = k_bavaria status = yes } }
			k_grand_bavaria = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_bavaria
				}
			}
			hidden_tooltip = {
				k_bavaria = {
					grant_title = ROOT
					copy_title_laws = k_grand_bavaria
					copy_title_history = k_grand_bavaria
				}		  
				any_realm_character = {
					limit = { has_claim = k_grand_bavaria }
					k_bavaria = { add_pressed_claim = PREV }
					remove_claim = k_grand_bavaria
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_grand_bavaria }
						k_bavaria = { add_pressed_claim = PREV }
						remove_claim = k_grand_bavaria
					}
				}
				k_grand_bavaria = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_bavaria = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_grand_bavaria = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_grand_bavaria status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_grand_luxembourg }
			hidden_tooltip = { activate_title = { title = k_luxembourg status = yes } }
			k_grand_luxembourg = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_luxembourg
				}
			}
			hidden_tooltip = {
				k_luxembourg = {
					grant_title = ROOT
					copy_title_laws = k_grand_luxembourg
					copy_title_history = k_grand_luxembourg
				}		  
				any_realm_character = {
					limit = { has_claim = k_grand_luxembourg }
					k_luxembourg = { add_pressed_claim = PREV }
					remove_claim = k_grand_luxembourg
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_grand_luxembourg }
						k_luxembourg = { add_pressed_claim = PREV }
						remove_claim = k_grand_luxembourg
					}
				}
				k_grand_luxembourg = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_luxembourg = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_grand_luxembourg = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_grand_luxembourg status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_grand_tuscany }
			hidden_tooltip = { activate_title = { title = k_tuscany status = yes } }
			k_grand_tuscany = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_tuscany
				}
			}
			hidden_tooltip = {
				k_tuscany = {
					grant_title = ROOT
					copy_title_laws = k_grand_tuscany
					copy_title_history = k_grand_tuscany
				}		  
				any_realm_character = {
					limit = { has_claim = k_grand_tuscany }
					k_tuscany = { add_pressed_claim = PREV }
					remove_claim = k_grand_tuscany
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_grand_tuscany }
						k_tuscany = { add_pressed_claim = PREV }
						remove_claim = k_grand_tuscany
					}
				}
				k_grand_tuscany = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_tuscany = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_grand_tuscany = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_grand_tuscany status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_arch_austria }
			hidden_tooltip = { activate_title = { title = k_austria status = yes } }
			k_arch_austria = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_austria
				}
			}
			hidden_tooltip = {
				k_austria = {
					grant_title = ROOT
					copy_title_laws = k_arch_austria
					copy_title_history = k_arch_austria
				}		  
				any_realm_character = {
					limit = { has_claim = k_arch_austria }
					k_austria = { add_pressed_claim = PREV }
					remove_claim = k_arch_austria
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_arch_austria }
						k_austria = { add_pressed_claim = PREV }
						remove_claim = k_arch_austria
					}
				}
				k_arch_austria = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_austria = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_arch_austria = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_arch_austria status = no }
			}
		}
	}
}

# Ruler has a kingdom version of a stem duchy title but is part of the HRE
character_event = {
	id = Plus.1171
	desc = EVTDESC_Plus_1171
	picture = GFX_evt_council
	
	is_triggered_only = yes
	
	only_rulers = yes
	
	trigger = {
		war = no
		OR = {
			has_landed_title = k_saxony
			has_landed_title = k_swabia
			has_landed_title = k_franconia
			has_landed_title = k_bavaria
			has_landed_title = k_luxembourg
			has_landed_title = k_tuscany
			has_landed_title = k_austria
		}
		top_liege = { has_landed_title = e_hre }
	}
	
	option = {
		name = OK
		if = {
			limit = { has_landed_title = k_saxony }
			hidden_tooltip = { activate_title = { title = k_grand_saxony status = yes } }
			k_saxony = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_grand_saxony
				}
			}
			hidden_tooltip = {
				k_grand_saxony = {
					grant_title = ROOT
					copy_title_laws = k_saxony
					copy_title_history = k_saxony
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_saxony }
					k_grand_saxony = { add_pressed_claim = PREV }
					remove_claim = k_saxony
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_saxony }
						k_grand_saxony = { add_pressed_claim = PREV }
						remove_claim = k_saxony
					}
				}
				k_saxony = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_grand_saxony = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_saxony = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_saxony status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_swabia }
			hidden_tooltip = { activate_title = { title = k_grand_swabia status = yes } }
			k_swabia = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_grand_swabia
				}
			}
			hidden_tooltip = {
				k_grand_swabia = {
					grant_title = ROOT
					copy_title_laws = k_swabia
					copy_title_history = k_swabia
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_swabia }
					k_grand_swabia = { add_pressed_claim = PREV }
					remove_claim = k_swabia
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_swabia }
						k_grand_swabia = { add_pressed_claim = PREV }
						remove_claim = k_swabia
					}
				}
				k_swabia = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_grand_swabia = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_swabia = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_swabia status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_franconia }
			hidden_tooltip = { activate_title = { title = k_grand_franconia status = yes } }
			k_franconia = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_grand_franconia
				}
			}
			hidden_tooltip = {
				k_grand_franconia = {
					grant_title = ROOT
					copy_title_laws = k_franconia
					copy_title_history = k_franconia
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_franconia }
					k_grand_franconia = { add_pressed_claim = PREV }
					remove_claim = k_franconia
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_franconia }
						k_grand_franconia = { add_pressed_claim = PREV }
						remove_claim = k_franconia
					}
				}
				k_franconia = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_grand_franconia = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_franconia = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_franconia status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_bavaria }
			hidden_tooltip = { activate_title = { title = k_grand_bavaria status = yes } }
			k_bavaria = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_grand_bavaria
				}
			}
			hidden_tooltip = {
				k_grand_bavaria = {
					grant_title = ROOT
					copy_title_laws = k_bavaria
					copy_title_history = k_bavaria
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_bavaria }
					k_grand_bavaria = { add_pressed_claim = PREV }
					remove_claim = k_bavaria
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_bavaria }
						k_grand_bavaria = { add_pressed_claim = PREV }
						remove_claim = k_bavaria
					}
				}
				k_bavaria = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_grand_bavaria = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_bavaria = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_bavaria status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_luxembourg }
			hidden_tooltip = { activate_title = { title = k_grand_luxembourg status = yes } }
			k_luxembourg = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_grand_luxembourg
				}
			}
			hidden_tooltip = {
				k_grand_luxembourg = {
					grant_title = ROOT
					copy_title_laws = k_luxembourg
					copy_title_history = k_luxembourg
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_luxembourg }
					k_grand_luxembourg = { add_pressed_claim = PREV }
					remove_claim = k_luxembourg
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_luxembourg }
						k_grand_luxembourg = { add_pressed_claim = PREV }
						remove_claim = k_luxembourg
					}
				}
				k_luxembourg = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_grand_luxembourg = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_luxembourg = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_luxembourg status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_tuscany }
			hidden_tooltip = { activate_title = { title = k_grand_tuscany status = yes } }
			k_tuscany = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_grand_tuscany
				}
			}
			hidden_tooltip = {
				k_grand_tuscany = {
					grant_title = ROOT
					copy_title_laws = k_tuscany
					copy_title_history = k_tuscany
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_tuscany }
					k_grand_tuscany = { add_pressed_claim = PREV }
					remove_claim = k_tuscany
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_tuscany }
						k_grand_tuscany = { add_pressed_claim = PREV }
						remove_claim = k_tuscany
					}
				}
				k_tuscany = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_grand_tuscany = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_tuscany = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_tuscany status = no }
			}
		}
		if = {
			limit = { has_landed_title = k_austria }
			hidden_tooltip = { activate_title = { title = k_arch_austria status = yes } }
			k_austria = {
				any_direct_de_jure_vassal_title = {
					de_jure_liege = k_arch_austria
				}
			}
			hidden_tooltip = {
				k_arch_austria = {
					grant_title = ROOT
					copy_title_laws = k_austria
					copy_title_history = k_austria
					de_jure_liege = e_hre
				}		  
				any_realm_character = {
					limit = { has_claim = k_austria }
					k_arch_austria = { add_pressed_claim = PREV }
					remove_claim = k_austria
				}		
				any_playable_ruler = {
				  any_realm_character = {
						limit = { has_claim = k_austria }
						k_arch_austria = { add_pressed_claim = PREV }
						remove_claim = k_austria
					}
				}
				k_austria = {
					dejure_liege_title = {
						save_event_target_as = djliege_title
					}
				}
				k_arch_austria = {
					de_jure_liege = event_target:djliege_title
					clear_event_target = djliege_title
				}
				k_austria = {
					destroy_landed_title = yes
				}
				activate_title = { title = k_austria status = no }
			}
		}
	}
}

### HRE -- Coronation events witten by Van Diemen

# Coronation inform Emperor -- triggered by decision: coronation
character_event = {
	id = Plus.1175 #formerly Plus.525
	desc = "EVTDESC_Plus_1175"
	picture = "GFX_evt_pope"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1175" # I will ask the pope
		hidden_tooltip = {
			rightful_religious_head_scope = {
				letter_event = { id = Plus.1176 }
			}
		}
	}
}

# Asking the pope for coronation
letter_event = {
	id = Plus.1176 #formerly 1000182428
	desc = "EVTDESC_Plus_1176"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1176"	# Accept
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 20
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 40
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 60
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 80
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 100
					}
				}
			}
			modifier = {
				factor = 2.0
				FROM = { trait = zealous }
			}
			modifier = {
				factor = 2.0
				FROM = { trait = crusader }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 400 }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 600 }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 800 }
			}
			modifier = {
				factor = 1.2
				FROM = { piety = 1000 }
			}
		}
		wealth = 100
		FROM = {
			letter_event = { id = Plus.1177 }
		}
	}
	option = {
		name = "EVTOPTB_Plus_1176"	# Reject
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -100
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -80
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -60
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -40
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -20
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = 0
						}
					}
				}
			}
			modifier = {
				factor = 2.0
				FROM = { trait = lunatic }
			}
			modifier = {
				factor = 2.0
				FROM = { trait = kinslayer }
			}
			modifier = {
				factor = 2.0
				FROM = { trait = cynical }
			}
		}
		FROM = {
			letter_event = { id = Plus.1178 }
		}
		ROOT = {
			opinion = {
				modifier = coronation_rejected
				who = FROM
				years = 10
			}
		}
	}
}
 
# Inform emperor that the pope agrees to the coronation & send out the invites to realm lords
letter_event = {
	id = Plus.1177 #formerly 1000182429
	desc = "EVTDESC_Plus_1177"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1177"	# Excellent, now invite all the lords
		hidden_tooltip = {
			any_vassal = {
				limit = {
					is_adult = yes
					OR = {
						tier = COUNT
						tier = DUKE
						tier = KING
					}
					NOR = {
						trait = excommunicated
						trait = incapable
						is_heretic = yes
					}
					religion_group = christian
					prisoner = no
				}
				letter_event = { id = Plus.1179 } # Invitation to coronation
			}
			character_event = { id = Plus.1181 days = 60 } # Coronation begins
		}
	}
}

# Inform emperor that the pope rejects coronation
letter_event = {
	id = Plus.1178 #formerly 1000182430
	desc = "EVTDESC_Plus_1178"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1178"	# Maybe we should try again later
		clr_character_flag = wants_coronation
		prestige = -50
		ROOT = {
			opinion = {
				modifier = coronation_rejected 
				who = FROM
				years = 2
			}
		}
	}
}

# Coronation invites to realm lords
letter_event = {
	id = Plus.1179 #formerly 1000182431
	desc = "EVTDESC_Plus_1179"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1179"	# I will attend the ceremony
		ai_chance = {
			factor = 80
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 20
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					opinion = {
						who = FROM
						value = 40
					}
				}
			}
			modifier = {
				factor = 1.6
				ROOT = {
					opinion = {
						who = FROM
						value = 60
					}
				}
			}
			modifier = {
				factor = 2.0
				ROOT = {
					opinion = {
						who = FROM
						value = 80
					}
				}
			}
			modifier = {
				factor = 2.0
				ROOT = {
					opinion = {
						who = FROM
						value = 100
					}
				}
			}
		}
		set_character_flag = attend_coronation
	}
	option = {
		name = "EVTOPTB_Plus_1179"	# I have more important things to do
		ai_chance = {
			factor = 20
			modifier = {
				factor = 4.0
				ROOT = {
					has_opinion_modifier = {
						who = FROM
						modifier = attempted_murder
					}
				}
			}
			modifier = {
				factor = 2.0
				ROOT = {
					has_opinion_modifier = {
						who = FROM
						modifier = attempted_murder_of_spouse
					}
				}
			}
			modifier = {
				factor = 4.0
				ROOT = {
					has_opinion_modifier = {
						who = FROM
						modifier = attempted_murder_of_child
					}
				}
			}
			modifier = {
				factor = 1.5
				ROOT = {
					has_opinion_modifier = {
						who = FROM
						modifier = attempted_murder_of_vassal
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -20
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -40
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -60
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -80
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				ROOT = {
					NOT = {
						opinion = {
							who = FROM
							value = -99
						}
					}
				}
			}
		}
		FROM = {
			letter_event = { id = Plus.1180 }
		}
	}
}

# Inform Emperor of NOT attending ceremony
letter_event = {
	id = Plus.1180 #formerly 1000182432
	desc = "EVTDESC_Plus_1180"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1180"	# I have no words for such dishonour
		ROOT = {
			opinion = {
				modifier = insulted
				who = FROM
				months = 60
			}
		}
	}
}

# Emperor crowned by pope
character_event = {
	id = Plus.1181 #formerly 1000182433
	title = "EVTNAME_Plus_1181"
	desc = "EVTDESC_Plus_1181"
	picture = "GFX_evt_holy_emperor"
	sound = church_bells

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1181"	# This is the happiest day of my life
		add_trait = crowned_by_pope
		prestige = 500
		ROOT = {
			custom_tooltip = { text = IMPERIAL_DECADENCE_MINUS_2 }
			hidden_tooltip = {
				primary_title = { change_variable = { which = "imperial_decadence" value = -2 } }
				character_event = { id = Plus.1852 } # change the decadence modifier
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 2 } }
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_tradition } }
			custom_tooltip = { text = TRADITIONFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_tradition } set_variable = { which = "faction_mood_increase" value = 4 } }
			}
		}
		hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } }
		hidden_tooltip = {
			rightful_religious_head_scope = {
				reverse_opinion = {
					modifier = opinion_grateful
					who = ROOT
					months = 60
				}
			}
			any_vassal = {
				limit = {
					has_character_flag = attend_coronation
				}
				character_event = { id = Plus.1182 }
				opinion = {
					modifier = opinion_attended_ceremony
					who = ROOT
					years = 5
				}
			}
			any_vassal = {
				limit = {
					NOT = { has_character_flag = attend_coronation }
				}
				letter_event = { id = Plus.1183 }
			}
			clr_character_flag = wants_coronation
			if = {
				limit = { has_landed_title = e_hre }
				narrative_event = { id = Plus.1184 }
			}
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_PAPAL_CORONATION
				portrait = [Root.GetID]
				picture = GFX_evt_holy_emperor
			}
		}
	}
}

# Emperor crowned by pope - attended realm lords informed of ceremony
character_event = {
	id = Plus.1182 #formerly 1000182434
	desc = "EVTDESC_Plus_1182"
	picture = "GFX_evt_holy_emperor"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA_Plus_1182"	# The coronation was beautiful
		prestige = 20
		clr_character_flag = attend_coronation
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_PAPAL_CORONATION_NEWS
				portrait = [From.GetID]
				picture = GFX_evt_holy_emperor
			}
		}
	}
}

# Emperor crowned by pope - non-attending realm lords informed of ceremony
letter_event = {
	id = Plus.1183 #formerly 1000182435
	desc = "EVTDESC_Plus_1183"

	is_triggered_only = yes

	option = {
		name = "OK"	# Ok
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_PAPAL_CORONATION_NEWS
				portrait = [From.GetID]
				picture = GFX_evt_holy_emperor
			}
		}
	}
}

# HRE Coronation narrative event
narrative_event = {
	id = Plus.1184 #formerly 1000182436
	title = "EVTNAME_Plus_1184"
	desc = "EVTDESC_Plus_1184"
	picture = "GFX_evt_holy_emperor"
	border = "GFX_event_narrative_frame_religion"

	major = yes

	is_triggered_only = yes

	option = {
		name = "OK"
	}
}


### AQUITAINE ABSORBED INTO WEST FRANCIA
narrative_event = {
	id = Plus.1185
	title = "EVTNAME_Plus_1185"
	desc = "EVTDESC_Plus_1185"
	picture = "GFX_evt_holy_emperor"
	
	major = yes
	
	only_playable = yes
	war = no
	
	trigger = {
		year = 869
		has_landed_title = k_aquitaine
		has_landed_title = k_france
		k_aquitaine = { is_titular = no }
		k_france = { is_primary_holder_title = yes }
		NOR = {
			trait = content
			trait = humble
			trait = excommunicated
			has_global_flag = west_francia_united
			has_character_flag = is_charlemagne # Probably redundant with the year trigger but better safe than sorry
		}
	}
	
	major_trigger = {
		ai = no
		OR = {
			culture = occitan
			culture = frankish
			capital_scope = { empire = { title = e_karling } }
			capital_scope = { empire = { title = e_hre } }
		}
	}

	mean_time_to_happen = {
		months = 12
		modifier = {
			factor = 10
			k_france = { has_law = succ_gavelkind }
			any_child = {
				NOT = { is_primary_heir = ROOT }
				NOT = { trait = bastard }
				is_female = no
			}
		}
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			trait = proud
		}
	}
	
	immediate = {
		set_global_flag = west_francia_united
		k_aquitaine = {
			any_direct_de_jure_vassal_title = {
				de_jure_liege = k_france
			}
		}     
        hidden_tooltip = {
			any_character = {
				limit = { has_claim = k_aquitaine }
				if = {
					limit = {
						has_weak_claim = k_aquitaine
						NOT = { has_weak_claim = k_france }
						NOT = { has_strong_claim = k_france }
					}
					add_weak_pressed_claim = k_france
					remove_claim = k_aquitaine
				}
				if = {
					limit = {
						has_strong_claim = k_aquitaine
						NOT = { has_strong_claim = k_france }
					}
					add_pressed_claim = k_france
					remove_claim = k_aquitaine
				}
			}
		}
	}
	
	option = {
		trigger = { has_landed_title = k_france }
		name = EXCELLENT
	}
	option = {
		trigger = { NOT = { has_landed_title = k_france } }
		name = OK
	}
}


### TREATY OF MEERSSEN EVENTS

# The Carolongian Emperor inherits both Lotharingia and Burgundy
character_event = {
	id = Plus.1186
	desc = "EVTDESC_Plus_1186"
	picture = "GFX_evt_council"
	
	is_triggered_only = yes
	
	only_independent = yes
	
	trigger = {
		has_landed_title = e_karling
		has_landed_title = k_lotharingia
		has_landed_title = k_burgundy
		num_of_king_titles = 3
		any_vassal = {
			has_landed_title = k_germany
			NOT = { has_landed_title = k_france }
			OR = {
				dynasty = ROOT
				is_close_relative = ROOT
			}
		}
		any_vassal = {
			has_landed_title = k_france
			NOT = { has_landed_title = k_germany }
			OR = {
				dynasty = ROOT
				is_close_relative = ROOT
			}
		}
		NOR = {
			has_character_flag = faction_court_war
			has_character_flag = faction_prosperity_war
			has_character_flag = faction_glory_war
			has_character_flag = faction_tradition_war
			has_character_flag = faction_separatist_war
			has_character_flag = faction_pretender_war
			has_character_flag = faction_religious_war
			has_character_flag = faction_succession_war
			has_global_flag = treaty_of_meerssen
		}
	}
	
	immediate = {
		set_global_flag = treaty_of_meerssen
	}
	
	option = {
		name = "EVTOPTA_Plus_1186" # Agree to the treaty
		ai_chance = {
			factor = 80
			modifier = {
				factor = 0.5
				any_vassal = {
					OR = {
						has_landed_title = k_germany
						has_landed_title = k_france
					}
					is_close_relative = ROOT
					prisoner = yes
				}
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 2
				trait = humble
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 4 } }
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_glory } }
			custom_tooltip = { text = GLORYFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_glory } set_variable = { which = "faction_mood_increase" value = 2 } }
			}
		}
		hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } }
		# ruler of West Francia receives Bar and Verdun
		random_vassal = {
			limit = { has_landed_title = k_france }
			ROOT = {
				any_demesne_title = {
					limit = {
						OR = {
							title = c_bar
							title = c_verdun
						}
					}
					grant_title = PREVPREV
				}
			}
		}
		# ruler of West Francia takes any vassals in Bar, Flanders, Brabant, Burgundy, or Dauphine
		random_vassal = {
			limit = { has_landed_title = k_france }
			custom_tooltip = {
				text = GAINS_WESTERN_MIDDLE_FRANCIA
				hidden_tooltip = {
					ROOT = {
						any_vassal = {
							limit = {
								in_revolt = no
								lower_tier_than = KING
								capital_scope = {
									OR = {
										duchy = { title = d_bar }
										duchy = { title = d_flanders }
										duchy = { title = d_brabant }
										duchy = { title = d_burgundy }
										duchy = { title = d_dauphine }
									}
								}
							}
							set_defacto_liege = PREVPREV
							pf_liege_change_effect = yes
						}
					}
				}
			}
		}
		# ruler of East Francia takes any vassals in Frisia
		random_vassal = {
			limit = { has_landed_title = k_germany }
			custom_tooltip = {
				text = GAINS_FRISIA
				hidden_tooltip = {
					ROOT = {
						any_vassal = {
							limit = {
								in_revolt = no
								lower_tier_than = KING
								capital_scope = {
									kingdom = { title = k_frisia }
									NOR = {
										duchy = { title = d_flanders }
										duchy = { title = d_brabant }
									}
								}
							}
							set_defacto_liege = PREVPREV
							pf_liege_change_effect = yes
						}
					}
				}
			}
		}
		# Hugh receives the Duchy of Alsace
		if = {
			limit = {
				any_realm_character = {
					character = 90102
					is_alive = yes
				}
				d_alsace = {
					has_holder = yes
					holder_scope = { is_liege_or_above = ROOT }
				}
			}
			random_realm_character = {
				limit = { character = 90102 }
				custom_tooltip = {
					text = GRANTED_DUCHY_ALSACE
					hidden_tooltip = {
						d_alsace = {
							usurp_title = PREV
							any_claimant = {
								limit = { higher_tier_than = DUKE }
								remove_claim = d_alsace
							}
						}
					}
				}
			}
		}
		if = {
			limit = {
				any_realm_character = {
					character = 90102
					is_alive = yes
				}
				d_alsace = { has_holder = no }
				c_nordgau = { holder_scope = { is_liege_or_above = ROOT } }
			}
			random_realm_character = {
				limit = { character = 90102 }
				custom_tooltip = {
					text = GRANTED_DUCHY_ALSACE
					hidden_tooltip = {
						c_nordgau = {
							usurp_title = PREV
							any_claimant = {
								limit = { higher_tier_than = DUKE }
								remove_claim = c_nordgau
							}
						}
						d_alsace = {
							gain_title = ROOT
							grant_title = PREV
							any_claimant = {
								limit = { higher_tier_than = DUKE }
								remove_claim = d_alsace
							}
						}
						if = {
							limit = {
								c_sundgau = { holder_scope = { is_liege_or_above = ROOT } }
							}
							c_sundgau = {
								holder_scope = {
									set_defacto_liege = PREVPREV
									pf_liege_change_effect = yes
								}
							}
						}
						hidden_tooltip = {
							set_defacto_liege = ROOT
							pf_liege_change_effect = yes
						}
					}
				}
			}
		}
		# when East Francia has no proper son, they split the kingdom titles
		if = {
			limit = {
				k_germany = {
					holder_scope = {
						NOT = {
							any_child = {
								lower_tier_than = KING
								is_female = no
								is_liege_or_above = PREV
								prisoner = no
								NOT = { is_primary_heir = PREV }
							}
						}
					}
				}
			}
			k_germany = {
				holder_scope = {
					ROOT = {
						any_demesne_title = {
							limit = { title = c_lorraine }
							grant_title = PREVPREV
						}
					}
					k_lotharingia = { grant_title = PREV }
				}
			}
			k_france = {
				holder_scope = {
					k_burgundy = { grant_title = PREV }
				}
			}
		}
		# when East Francia has a duke son, they take both kingdom titles
		if = {
			limit = {
				k_germany = {
					holder_scope = {
						any_child = {
							lower_tier_than = KING
							is_female = no
							is_liege_or_above = PREV
							prisoner = no
							NOT = { is_primary_heir = PREV }
						}
					}
				}
			}
			k_germany = {
				holder_scope = {
					random_child = {
						limit = {
							lower_tier_than = KING
							is_female = no
							is_liege_or_above = PREV
							prisoner = no
							NOT = { is_primary_heir = PREV }
						}
						ROOT = {
							any_demesne_title = {
								limit = { title = c_lorraine }
								gain_title = PREVPREV
							}
							hidden_tooltip = {
								any_vassal = {
									limit = {
										in_revolt = no
										lower_tier_than = KING
										capital_scope = {
											OR = {
												duchy = { title = d_upper_burgundy }
												kingdom = { title = k_lotharingia }
											}
										}
									}
									set_defacto_liege = PREVPREV
									pf_liege_change_effect = yes
								}
							}
						}
						k_lotharingia = { grant_title = PREV }
						k_burgundy = { grant_title = PREV }
						hidden_tooltip = {
							k_lotharingia = {
								make_primary_title = yes
								add_law = succ_gavelkind
							}
						}
					}
				}
			}
		}
		# notify the rulers
		hidden_tooltip = {
			any_vassal = {
				limit = {
					OR = {
						has_landed_title = k_france
						has_landed_title = k_germany
						has_landed_title = k_lotharingia
					}
				}
				character_event = { id = Plus.1187 }
			}
		}
	}
	option = {
		name = "EVTOPTB_Plus_1186" # No, the inheritance is rightfully mine
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.5
				war = yes
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = proud
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODMINUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_decrease" value = 4 } }
			}
		}
		hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } }
		any_vassal = {
			limit = {
				OR = {
					has_landed_title = k_france
					has_landed_title = k_germany
				}
			}
			character_event = { id = Plus.1188 tooltip = they_are_enraged }
		}
		hidden_tooltip = {
			random_realm_character = {
				limit = {
					character = 90102
					is_alive = yes
					is_ruler = no
					ai = yes
				}
				if = {
					limit = { d_alsace = { has_holder = yes } }
					add_pressed_claim = d_alsace
				}
				add_pressed_claim = k_lotharingia
				add_trait = ambitious
				set_character_flag = flag_denied_title
			}
		}
	}
}

# Rulers informed of the Treaty of Meerssen
character_event = {
	id = Plus.1187
	title = "EVTNAME_Plus_1187"
	desc = "EVTDESC_Plus_1187"
	picture = "GFX_evt_council"
	
	is_triggered_only = yes
	
	option = {
		name = "EXCELLENT"
		prestige = 100
		opinion = {
			who = FROM
			modifier = opinion_pleased
			multiplier = 2
			months = 60
		}
	}
}

# Rulers informed that the emperor has refused the treaty
character_event = {
	id = Plus.1188
	desc = "EVTDESC_Plus_1187"
	picture = "GFX_evt_council"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA_Plus_1188" #This is not worth fighting over
		ai_chance = {
			factor = 25
			modifier = {
				factor = 2
				war = yes
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 2
				trait = humble
			}
		}
		prestige = -100
		any_claim = {
			limit = {
				OR = {
					title = k_lotharingia
					title = k_burgundy
				}
			}
			remove_claim = ROOT
		}
	}
	option = {
		name = "EVTOPTB_Plus_1188" #This cannot be allowed to stand!
		ai_chance = {
			factor = 75
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = proud
			}
		}
		opinion = {
			who = FROM
			modifier = opinion_outraged
			months = 60
		}
		add_pressed_claim = k_lotharingia
		add_pressed_claim = k_burgundy
	}
}

