
###########################################
#                                         #
# Charlemagne Story Events                #             
#                                         #
# ID CM.1000-CM.1999                      #
#                                         #
###########################################

# Written by Tobias Bodlund

namespace = CM


###########################################
# Charlemagne-Carloman rivalry            #
###########################################

# Charlemagne rivalry with brother
narrative_event = {
	id = CM.1000
	title = EVTTITLE_CM_1000
	desc = EVTDESC_CM_1000
	picture = GFX_evt_rival_rulers
	border = GFX_event_narrative_frame_war
	
	only_playable = yes
	religion_group = christian
	only_independent = yes
	only_capable = yes
	min_age = 16
	prisoner = no
	has_character_flag = is_charlemagne

	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { year = 780 }
		NOT = { has_character_flag = charlemagne_brother_rivalry }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		character_event = { id = CM.1040 days = 50 }
	}
	
	option = {
		name = EVTOPTA_CM_1000
		set_character_flag = charlemagne_brother_rivalry
		any_sibling = {
			limit = {
				has_character_flag = is_carloman
			}
			add_rival = ROOT
		}
		hidden_tooltip = { narrative_event = { id = CM.1010 days = 10  } }
		hidden_tooltip = { narrative_event = { id = CM.1120 days = 700 random = 50 } }
	}
}

# Carloman rivalry with brother
narrative_event = {
	id = CM.1001
	desc = EVTDESC_CM_1000
	title = EVTTITLE_CM_1000
	picture = GFX_evt_rival_rulers
	
	only_playable = yes
	religion_group = christian
	only_independent = yes
	only_capable = yes
	min_age = 16
	prisoner = no
	has_character_flag = is_carloman

	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { year = 780 }
		NOT = { has_character_flag = charlemagne_brother_rivalry }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	option = {
		name = EVTOPTA_CM_1000
		set_character_flag = charlemagne_brother_rivalry
		any_sibling = {
			limit = {
				has_character_flag = is_charlemagne
			}
			add_rival = ROOT
		}
	}
}

# Notify Carloman of Charlemagne's death, give him titles
narrative_event = {
	id = CM.1002
	title = EVTTITLE_CM_1002
	desc = EVTDESC_CM_1002
	picture = GFX_evt_emissary

	is_triggered_only = yes
	
	trigger = {
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
	}
	
	option = {
		name = EVTOPTA_CM_1002
	}
}

# Notify Charlemagne of Carloman's death, give him titles
narrative_event = {
	id = CM.1003
	title = EVTTITLE_CM_1003
	desc = EVTDESC_CM_1002
	picture = GFX_evt_emissary

	is_triggered_only = yes
	
	trigger = {
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
	}
	
	option = {
		name = EVTOPTA_CM_1002
	}
}

###########################################
# Desideria the Lombard Princess          #
###########################################

# Marriage to Desideria
narrative_event = {
	id = CM.1010
	title = EVTTITLE_CM_1010
	desc = EVTDESC_CM_1010
	picture = GFX_evt_marriage

	capable_only = yes
	prisoner = no
	has_dlc = "Charlemagne"
	has_character_flag = is_charlemagne
	is_married = no

	is_triggered_only = yes
	
	trigger = {
		any_sibling = {
			has_character_flag = is_carloman
			is_rival = ROOT
		}
		k_lombardy = {
			holder_scope = {
				culture = lombard
				ai = yes
				any_child = {
					is_adult = yes
					is_female = yes
					is_married = no
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_CM_1010   # Marry her
		k_lombardy = {
			holder_scope = {
				random_child = {
					limit = {
						religion = ROOT
						is_adult = yes
						is_female = yes
						is_married = no
					}
					add_spouse = ROOT
				}
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1010   # No Lombards in my bed!
		prestige = -30
	}
}

# Divorce from Desideria
narrative_event = {
	id = CM.1011
	title = EVTTITLE_CM_1011
	desc = EVTDESC_CM_1011
	picture = GFX_evt_scandal

	is_triggered_only = yes
	
	only_playable = yes
	capable_only = yes
	has_character_flag = is_charlemagne
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		year = 770
		NOT = { year = 850 }
		NOT = { has_character_flag = kept_lombard_queen }
		OR = {
			culture = frankish
			culture = old_frankish
		}
		spouse = {
			culture = lombard
			father = { culture = lombard }
		}
		NOT = {
			any_sibling = {
				has_character_flag = is_carloman
				spouse = { culture = lombard }
			}
		}
	}

	option = {
		name = EVTOPTA_CM_1011   # Divorce her
		piety = -100
		spouse = {
			any_child = {
				limit = {
					is_father = ROOT
					NOT = { culture = ROOT }
				}
				culture = ROOT
			}
			father = {
				set_character_flag = charlemagne_enemy
				opinion = {
					modifier = opinion_furious
					who = ROOT
					years = 10
				}
			}
			mother = {
				opinion = {
					modifier = opinion_furious
					who = ROOT
					years = 10
				}
			}
			hidden_tooltip = {
				father = {
					PREV = {
						move_character = PREV
					}
				}
			}
		}
		remove_spouse = spouse
		k_lombardy = {
			holder_scope = {
				if = {
					limit = { is_allied_with = ROOT }
					ROOT = { break_alliance = PREV }
				}
				if = {
					limit = { has_non_aggression_pact_with = ROOT }
					reverse_remove_opinion = { modifier = in_non_aggression_pact who = ROOT }
					opinion = { modifier = broken_non_aggression_pact who = ROOT years = 3 }
				}
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1011   # No, she's my wife
		set_character_flag = kept_lombard_queen
		custom_tooltip = { text = most_lords_angry }
		hidden_tooltip = {
			any_realm_lord = {
				limit = {
					OR = {
						culture = frankish
						culture = old_frankish
					}
					NOT = { spouse = { culture = lombard } }
				}
				opinion = {
					modifier = opinion_angry
					who = ROOT
					years = 5
				}
			}
		}
	}
}


###########################################
# Queen Bertrada                          #
###########################################

# Charlemagne dies and Bertrada approaches Carloman for reconciliation
character_event = {
	id = CM.1020

	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				prisoner = yes
			}
			repeat_event = { id = CM.1020 days = 30 }
			break = yes
		}
		any_child = {
			limit = {
				has_character_flag = is_carloman
			}
		}
		narrative_event = { id = CM.1021 }
	}
}

# Carloman receives her and gives his response
narrative_event = {
	id = CM.1021
	title = EVTTITLE_CM_1021
	desc = EVTDESC_CM_1021
	picture = GFX_evt_daughter_asking_father

	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		has_character_flag = is_charlemagne
		NOT = {
			any_sibling = {
				has_character_flag = is_charlemagne
			}
		}
	}
	
	option = {
		name = EVTOPTA_CM_1021 # I forgive you, Mother
		FROM = {
			move_character = ROOT
			opinion = {
				modifier = opinion_very_grateful
				who = ROOT
				years = 100
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1021 # Begone, witch
		FROM = {	
			opinion = {
				modifier = opinion_bitter
				who = ROOT
				years = 100
			}
		}
	}
}

# Bertrada sends letter to Carloman, asking him to stop petulantly interfering with his older brother's plans
character_event = {
	id = CM.1022

	hide_window = yes
	
	only_playable = yes
	only_capable = yes
	min_age = 16
	prisoner = no
	has_character_flag = charlemagne_brother_rivalry
	
	trigger = {
		has_character_flag = is_carloman
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { year = 780 }
		any_sibling = {
			has_character_flag = is_charlemagne
		}
		mother = {
			is_alive = yes
			NOT = { has_character_flag = bertrada_carloman_talk }
		}
	}
	
	mean_time_to_happen = {
		days = 60
	}
	
	immediate = {
		mother = { character_event = { id = CM.1023 } }
	}
}

character_event = {
	id = CM.1023
	
	hide_window = yes

	is_triggered_only = yes
	
	immediate = {
		set_character_flag = bertrada_carloman_talk
		FROM = { letter_event = { id = CM.1024 } }
	}
}
	
letter_event = {
	id = CM.1024
	desc = EVTDESC_CM_1024
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1024
		opinion = {
			modifier = opinion_unappreciated
			who = FROM
			years = 10
		}
		mother = {
			opinion = {
				modifier = opinion_disapprove
				who = ROOT
				years = 5
			}
		}
	}
}

# Bertrada talks to Charlemagne, expressing her support
character_event = {
	id = CM.1025

	hide_window = yes
	
	only_playable = yes
	only_capable = yes
	min_age = 16
	prisoner = no
	has_character_flag = charlemagne_brother_rivalry
	
	trigger = {
		has_character_flag = is_charlemagne
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { year = 780 }
		any_sibling = {
			has_character_flag = is_carloman
		}
		mother = {
			is_alive = yes
			prisoner = no
			NOT = { has_character_flag = bertrada_charlemagne_talk }
		}
	}
	
	mean_time_to_happen = {
		days = 60
	}
	
	immediate = {
		mother = { character_event = { id = CM.1026 } }
	}
}

character_event = {
	id = CM.1026
	
	hide_window = yes

	is_triggered_only = yes
	
	immediate = {
		set_character_flag = bertrada_charlemagne_talk
		FROM = { narrative_event = { id = CM.1027 } }
	}
}
	
narrative_event = {
	id = CM.1027
	desc = EVTDESC_CM_1027
	title = EVTTITLE_CM_1027
	picture = GFX_evt_daughter_asking_father
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1027
		opinion = {
			modifier = opinion_pleased
			who = FROM
			years = 5
		}
		mother = {
			opinion = {
				modifier = opinion_favorite
				who = ROOT
				years = 5
			}
		}
	}
}


##################
# Pepin le Bossu #
##################

character_event = {
	id = CM.1040
	desc = EVTDESC_CM_1040
	picture = GFX_evt_child_play
	
	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		any_child = {
			has_character_flag = is_pepin_le_bossu
			trait = bastard
		}
	}

	option = {
		name = EVTOPTA_CM_1040
		ai_chance = { factor = 0 }
		piety = -20
		any_child = {
			limit = {
				has_character_flag = is_pepin_le_bossu
			}
			dynasty = 25061
			remove_trait = bastard
			add_trait = legit_bastard
			recalc_succession = yes
			give_nickname = nick_the_hunchback
			mother = {
				opinion = {
					who = ROOT
					modifier = legitimized_child
					years = 10
				}
			}
		}
		spouse = {
			if = {
				limit = {
					NOT = {
						any_child = {
							has_character_flag = is_pepin_le_bossu
						}
					}
				}
				opinion = {
					who = ROOT
					modifier = legitimized_bastard
					years = 20
				}
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1040
		ai_chance = { factor = 100 }
		any_child = {
			limit = {
				has_character_flag = is_pepin_le_bossu
			}
			prestige = -50
			give_nickname = nick_the_hunchback
		}
	}
}


###########################################
# Roland                                  #
###########################################

# Roland arrives at court
narrative_event = {
	id = CM.1050
	title = EVTTITLE_CM_1050
	desc = EVTDESC_CM_1050
	picture = GFX_evt_emissary

	capable_only = yes
	min_age = 16
	only_playable = yes
	prisoner = no
	only_independent = yes
	religion_group = christian
	has_character_flag = is_charlemagne
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		OR = {
			primary_title = { tier = EMPEROR }
			primary_title = { tier = KING }
		}
		NOT = {
			any_sibling = {
				has_character_flag = is_carloman
			}
		}
		NOT = { has_global_flag = roland_spawned }
	}
	
	mean_time_to_happen = {
		months = 24
	}
	
	immediate = {
		set_global_flag = roland_spawned
	}
	
	option = {
		name = EVTOPTA_CM_1050
		custom_tooltip = { text = roland_arrives }
		hidden_tooltip = {
			create_character = {
				random_traits = no
				dynasty = 726
				religion = ROOT
				culture = breton
				age = 25
				trait = honest
				trait = brave
				trait = tough_soldier
				trait = strong
				trait = fair
				trait = aggressive_leader
				attributes = {
					diplomacy = 11
					martial = 12
					stewardship = 8
					intrigue = 5
					learning = 8
				}
			}
		}
		new_character = {
			set_name = Roland
			set_character_flag = is_roland
			set_character_flag = hero_knight
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
			character_event = { id = CM.1051 days = 350 }
		}
	}
	option = {
		name = EVTOPTB_CM_1050
		prestige = -5
	}
}

# Roland is a good friend
character_event = {
	id = CM.1051
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		liege = {
			has_character_flag = is_charlemagne
			NOT = {	is_friend = ROOT }
		}
	}
	
	immediate= {
		liege = {
			character_event = { id = CM.1052 }
		}
	}
}

character_event = {
	id = CM.1052
	desc = EVTDESC_CM_1052
	picture = GFX_evt_courtiers_talking

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1052
		add_friend = FROM
	}
}

# Roland is very brave on campaign
narrative_event = {
	id = CM.1053
	title = EVTTITLE_CM_1053
	desc = EVTDESC_CM_1053
	picture = GFX_evt_melee
	border = GFX_event_narrative_frame_war
	
	only_playable = yes
	only_capable = yes
	min_age = 16
	prisoner = no
	has_character_flag = is_charlemagne
	has_dlc = "Charlemagne"
	war = yes

	trigger = {
		OR = {
			any_courtier = {
				in_command_trigger = yes
				has_character_flag = is_roland
				NOT = { has_character_flag = roland_brave }
			}
			any_vassal = {
				in_command_trigger = yes
				has_character_flag = is_roland
				NOT = { has_character_flag = roland_brave }
			}
		}
	}

	mean_time_to_happen = {
		days = 60
	}
	
	option = {
		name = EVTOPTA_CM_1053
		any_realm_character = {
			limit = {
				has_character_flag = is_roland
			}
			prestige = 30
			set_character_flag = roland_brave
		}
	}
}

# Roland dies heroically in winning battle
character_event = {
	id = CM.1054
	
	hide_window = yes
	
	is_triggered_only = yes

	trigger = {
		has_dlc = "Charlemagne"
		has_character_flag = is_roland
	}
	
	immediate = {
		liege = { narrative_event = { id = CM.1055 } }
	}
}

narrative_event = {
	id = CM.1055
	title = EVTTITLE_CM_1055
	desc = EVTDESC_CM_1055
	picture = GFX_evt_pale_rider
	border = GFX_event_narrative_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1055
		FROM = {
			death = {
				death_reason = death_battle
			}
		}
		prestige = 100
	}
}

# Roland dies heroically in losing battle
character_event = {
	id = CM.1056
	
	hide_window = yes
	
	is_triggered_only = yes

	trigger = {
		has_dlc = "Charlemagne"
		has_character_flag = is_roland
	}
	
	immediate = {
		liege = { narrative_event = { id = CM.1057 } }
	}
}

narrative_event = {
	id = CM.1057
	title = EVTTITLE_CM_1055
	desc = EVTDESC_CM_1057
	picture = GFX_evt_pale_rider
	border = GFX_event_narrative_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1055
		FROM = {
			death = {
				death_reason = death_battle
			}
		}
		prestige = 100
	}
}


###########################################
# Carloman or Charlemagne dies            #
###########################################

# Carloman dies
character_event = {
	id = CM.1068

	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		has_character_flag = is_carloman
		OR = {
			ai = yes
			any_sibling = {
				ai = no
				has_character_flag = is_charlemagne
				is_primary_heir = ROOT
			}
		}
		any_sibling = {
			has_character_flag = is_charlemagne      # To ensure he has certain power and to avoid problems with ruler designer
			independent = yes
			higher_tier_than = DUKE
		}
	}
	
	immediate = {
		any_sibling = {
			limit = { has_character_flag = is_charlemagne }
			ROOT = {
				any_demesne_title = {
					grant_title = PREVPREV
				}
			}
			narrative_event = { id = CM.1003 }
		}
		spouse = {
			if = {
				limit = {
					ROOT = {
						any_sibling = {
							has_character_flag = is_charlemagne
							independent = yes
						}
						OR = {
							ai = yes
							any_sibling = {
								has_character_flag = is_charlemagne
								is_primary_heir = ROOT
							}
						}
					}
					OR = {
						trait = pregnant
						any_child = {
							father_even_if_dead = {
								any_sibling = {
									has_character_flag = is_charlemagne
								}
							}
						}
					}
				}
				character_event = { id = CM.1075 } # Flee to foreign court?
			}
		}
	}
}

# Charlemagne dies
character_event = {
	id = CM.1069

	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		has_character_flag = is_charlemagne
		OR = {
			ai = yes
			any_sibling = {
				ai = no
				has_character_flag = is_carloman
				is_primary_heir = ROOT
			}
		}
		any_sibling = {
			has_character_flag = is_carloman      # To ensure he has certain power and to avoid problems with ruler designer
			independent = yes
			higher_tier_than = DUKE
		}
	}
	
	immediate = {
		any_sibling = {
			limit = {
				has_character_flag = is_carloman
			}
			ROOT = {
				any_demesne_title = {
					grant_title = PREVPREV
				}
			}
			narrative_event = { id = CM.1002 }
		}
		if = {
			limit = {
				any_sibling = {
					has_character_flag = is_carloman
				}
				mother = {
					is_alive = yes
					NOT = {
						liege = {
							has_character_flag = is_carloman
						}
					}
				}
			}
			mother = { character_event = { id = CM.1020 days = 30 } } # Bertrada approaches Carloman for reconciliation
		}
	}
}


###########################################
# Ogier the Dane                          #
###########################################

# Ogier arrives
narrative_event = {
	id = CM.1070
	title = EVTTITLE_CM_1070
	desc = EVTDESC_CM_1070
	picture = GFX_evt_emissary

	capable_only = yes
	only_playable = yes
	only_independent = yes
	prisoner = no
	min_age = 16
	religion_group = christian

	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { year = 820 }
		OR = {
			primary_title = { tier = EMPEROR }
			primary_title = { tier = KING }
		}
		OR = {
			culture = frankish
			culture = old_frankish
		}
		OR = {
			AND = {
				has_character_flag = is_charlemagne
				NOT = {
					any_sibling = {
						has_character_flag = is_carloman
					}
				}
			}
			NOT = {
				any_independent_ruler = {
					OR = {
						has_character_flag = is_charlemagne
						has_character_flag = is_carloman
					}
				}
			}
		}
		NOT = { has_global_flag = ogier_spawned }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		set_global_flag = ogier_spawned
	}

	option = {
		name = EVTOPTA_CM_1070
		custom_tooltip = { text = ogier_arrives }
		hidden_tooltip = {
			create_character = {
				random_traits = no
				dynasty = random
				religion = ROOT
				culture = norse
				age = 35
				trait = honest
				trait = zealous
				trait = skilled_tactician
				trait = strong
				trait = trickster
				attributes = {
					diplomacy = 11
					martial = 12
					stewardship = 8
					intrigue = 5
					learning = 8
				}
			}
		}
		new_character = {
			set_name = Ogier
			set_character_flag = is_ogier
			set_character_flag = hero_knight
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1070
		prestige = -5
	}
}


###########################################
# Carloman's family flees after his death #
###########################################

# Wife
character_event = {
	id = CM.1075
	
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		random_independent_ruler = {
			limit = { has_character_flag = charlemagne_enemy }
			character_event = { id = CM.1076 }
			break = yes
		}
		random_independent_ruler = {
			limit = {
				OR = {
					has_landed_title = k_italy
					has_landed_title = k_lombardy
				}
				NOT = { any_allied_character = { has_character_flag = is_charlemagne } }
				NOT = { has_character_flag = is_charlemagne }
			}
			character_event = { id = CM.1076 }
			break = yes
		}
		random_independent_ruler = {
			limit = {
				tier = KING
				religion = chalcedonian
				is_feudal = yes
				NOT = { has_character_flag = is_charlemagne }
			}
			character_event = { id = CM.1076 }
			break = yes
		}
		random_independent_ruler = {
			limit = {
				tier = DUKE
				religion = chalcedonian
				is_feudal = yes
			}
			character_event = { id = CM.1076 }
		}
	}
}

# Foreign ruler receives Carloman's wife and children
character_event = {
	id = CM.1076
	desc = EVTDESC_CM_1076
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1076			# Grant refuge
		ai_chance = { factor = 100 }
		FROM = { set_character_flag = carloman_refugee_wife }
		FROM = {
			any_child = {
				limit = {
					at_location = FROM
					is_ruler = no
				}
				move_character = ROOT
			}
			move_character = ROOT
			opinion = {
				who = ROOT
				modifier = opinion_saved_me_and_child
				years = 10
			}
		}
		prestige = 300
		any_independent_ruler = {
			limit = { has_character_flag = is_charlemagne }
			opinion = {
				who = ROOT
				modifier = opinion_furious
				years = 10
			}
			ROOT = {
				primary_title = {
					add_claim = PREVPREV
				}
			}
			character_event = { id = CM.1077 }
		}
	}
	option = {
		name = EVTOPTB_CM_1076			# Don't grant refuge
		ai_chance = { factor = 0 }
		prestige = -30
		any_independent_ruler = {
			limit = { has_character_flag = is_charlemagne }
			opinion = {
				who = ROOT
				modifier = opinion_approves
				years = 10
			}
			character_event = { id = CM.1078 }
		}
	}
}

# Refuge - notify Charlemagne
character_event = {
	id = CM.1077
	desc = EVTDESC_CM_1077
	picture = GFX_evt_spymaster
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1077
		FROM = {
			primary_title = {
				add_claim = ROOT
			}
		}
	}
}
	
# No refuge - notify Charlemagne and receive wife and children
character_event = {
	id = CM.1078
	desc = EVTDESC_CM_1078
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1078
		FROMFROM = {
			move_character = ROOT
			add_trait = nun
			any_child = {
				limit = {
					at_location = FROMFROM
					is_female = yes
					father_even_if_dead = {
						any_sibling = {
							has_character_flag = is_charlemagne
						}
					}
				}
				move_character = ROOT
				add_trait = nun
			}
			any_child = {
				limit = {
					at_location = FROMFROM
					is_female = no
					father_even_if_dead = {
						any_sibling = {
							has_character_flag = is_charlemagne
						}
					}
				}
				move_character = ROOT
				add_trait = monk
			}
		}
	}

	option = {
		name = EVTOPTB_CM_1078
		FROMFROM = {
			any_child = {
				limit = {
					at_location = FROMFROM
					father_even_if_dead = {
						any_sibling = {
							has_character_flag = is_charlemagne
						}
					}
				}
				death = {
					death_reason = death_execution_hanging
					killer = ROOT
				}
			}
			death = {
				death_reason = death_execution_hanging
				killer = ROOT
			}
		}
		if = {
			limit = { NOT = { trait = cruel } }
			add_trait = cruel
		}
	}
}

# Dead Carloman's refugee wife surrenders to Charlemagne
character_event = {
	id = CM.1079

	hide_window = yes
	
	capable_only = yes
	prisoner = no
	only_capable = yes
	min_age = 16
	only_women = yes
	has_character_flag = carloman_refugee_wife
	
	trigger = {
		top_liege = {
			has_character_flag = is_charlemagne
		}
		any_child = {
			at_location = ROOT
			father_even_if_dead = {
				any_sibling = {
					has_character_flag = is_charlemagne
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 10
	}
	
	immediate = {
		clr_character_flag = carloman_refugee_wife
		top_liege = {
			character_event = { id = CM.1080 }
		}
	}
}

# Charlemagne receives Carloman's surrendered wife and children
character_event = {
	id = CM.1080
	desc = EVTDESC_CM_1080
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1080
		FROM = {
			move_character = ROOT
			add_trait = nun
			any_child = {
				limit = {
					at_location = FROM
					is_female = yes
					father_even_if_dead = {
						any_sibling = {
							has_character_flag = is_charlemagne
						}
					}
				}
				move_character = ROOT
				add_trait = nun
			}
			any_child = {
				limit = {
					at_location = FROM
					is_female = no
					father_even_if_dead = {
						any_sibling = {
							has_character_flag = is_charlemagne
						}
					}
				}
				move_character = ROOT
				add_trait = monk
			}
		}
	}

	option = {
		name = EVTOPTB_CM_1080
		FROM = {
			any_child = {
				limit = {
					at_location = FROM
					father_even_if_dead = {
						any_sibling = {
							has_character_flag = is_charlemagne
						}
					}
				}
				death = {
					death_reason = death_execution_hanging
					killer = ROOT
				}
			}
			death = {
				death_reason = death_execution_hanging
				killer = ROOT
			}
		}
		if = {
			limit = { NOT = { trait = cruel } }
			add_trait = cruel
		}
	}
}	

# Prompting the AI to attack Lombardy
character_event = {
	id = CM.1081
	
	hide_window = yes
	
	only_playable = yes
	only_independent = yes
	has_character_flag = is_charlemagne
	
	trigger = {
		ai = yes
		war = no
		has_strong_claim = k_lombardy
		k_lombardy = {
			is_contested = no
			holder_scope = {
				reverse_realm_levy_diff = { who = ROOT value = 5000 }
				NOR = {
					character = ROOT
					same_realm = ROOT
					reverse_has_truce = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
			}
		}
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			has_character_modifier = do_not_disturb
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	immediate = {
		k_lombardy = {
			holder_scope = {
				reverse_war = {
					target = ROOT
					casus_belli = claim
					thirdparty_title = PREV
					infamy = 0
				}
			}
		}
	}
}

# Prompting the AI to attack Saxony
character_event = {
	id = CM.1082
	
	hide_window = yes
	
	only_playable = yes
	only_independent = yes
	
	trigger = {
		ai = yes
		dynasty = 25061
		war = no
		has_strong_claim = k_saxony
		k_saxony = {
			is_contested = no
			holder_scope = {
				reverse_realm_levy_diff = { who = ROOT value = 5000 }
				NOR = {
					character = ROOT
					same_realm = ROOT
					reverse_has_truce = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
			}
		}
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			has_character_modifier = do_not_disturb
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	immediate = {
		k_saxony = {
			holder_scope = {
				reverse_war = {
					target = ROOT
					casus_belli = claim
					thirdparty_title = PREV
					infamy = 0
				}
			}
		}
	}
}


###########################################
# The Saxon Wars                          #
###########################################

# Saxon wars begin
narrative_event = {
	id = CM.1100
	title = EVTTITLE_CM_1100
	desc = EVTDESC_CM_1100
	picture = GFX_evt_irminsul_shrine
	
	only_playable = yes
	religion_group = christian
	only_independent = yes
	only_capable = yes
	only_men = yes
	min_age = 16
	prisoner = no 
	war = no

	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		year = 772
		OR = {
			has_character_flag = is_charlemagne
			AND = {
				OR = {
					culture = old_frankish
					culture = frankish
				}
				NOT = {
					any_independent_ruler = {
						has_character_flag = is_charlemagne
					}
				}
				NOT = { year = 830 }
				is_feudal = yes
			}
		}
		higher_real_tier_than = DUKE
		k_saxony = {
			is_contested = no
			holder_scope = {
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				culture = old_saxon
				OR = {
					religion = german_pagan
					religion = german_pagan_reformed
				}
				NOR = {
					reverse_has_truce = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					pays_tribute_to = ROOT
				}
			}
		}
		NOR = {
			has_character_modifier = do_not_disturb
			has_global_flag = saxon_wars
		}
	}
	
	mean_time_to_happen = {
		months = 8
	}
	
	option = {
		name = EVTOPTA_CM_1100 # Attack
		ai_chance = { factor = 100 }
		piety = 50
		add_claim = k_saxony
		k_saxony = {
			holder_scope = {
				reverse_war = {
					target = ROOT
					casus_belli = claim
					thirdparty_title = PREV
					infamy = 0
				}
			}
		}
		set_global_flag = saxon_wars
	}
	option = {
		name = EVTOPTB_CM_1100 # Not now
		ai_chance = { factor = 0 }
		prestige = -100
		piety = -100
		set_global_flag = saxon_wars
	}
}

# Destruction of Irminsul ( **on_siege_over_winner** )
narrative_event = {
	id = CM.1101
	desc = EVTDESC_CM_1101
	title = EVTTITLE_CM_1101
	picture = GFX_evt_irminsul_burning

	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		religion_group = christian
		has_global_flag = saxon_wars
		NOT = { has_global_flag = irminsul }
		FROM = {
			title = b_paderborn
			owner = {
				top_liege = {
					any_war = {
						attacker = { character = ROOT }
					}
				}
			}
		}
	}
	
	immediate = {
		set_global_flag = irminsul
		log = "Irminsul has been destroyed!"
	}
	
	option = {
		name = EVTOPTA_CM_1101 # Burn it!
		ai_chance = {
			factor = 1
		}
		prestige = 50
		piety = 100
		FROM = {
			owner = {
				religion_authority = {
					modifier = irminsul_destroyed
					years = 10
				}
			}
		}
		hidden_tooltip = {
			any_independent_ruler = {
				if = {
					limit = {
						OR = {
							religion = german_pagan
							religion = german_pagan_reformed
							religion = norse_pagan
							religion = norse_pagan_reformed
						}
					}
					opinion = {
						who = ROOT
						modifier = opinion_sacrilege
						years = 10
					}
				}
				any_realm_character = {
					limit = {
						OR = {
							religion = german_pagan
							religion = german_pagan_reformed
							religion = norse_pagan
							religion = norse_pagan_reformed
						}
					}
					opinion = {
						who = ROOT
						modifier = opinion_sacrilege
						years = 10
					}
				}
			}
			any_playable_ruler = {
				limit = {
					ai = no
					NOT = { character = ROOT }
					OR = {
						religion = german_pagan
						religion = german_pagan_reformed
						religion = norse_pagan
						religion = norse_pagan_reformed
						religion_group = christian
					}
				}
				narrative_event = { id = CM.1102 } # Notify players of this 
			}
		}
		custom_tooltip = { text = sacrilege_tooltip }
	}
	option = {
		name = EVTOPTB_CM_1101 # Keep it and build a new Christian church on the cite
		ai_chance = {
			factor = 0
		}
		wealth = -50
		prestige = 20
		piety = 20
	}
	option = {
		name = EVTOPTC_CM_1101 # Leave it be
		ai_chance = {
			factor = 0
		}
		piety = -30
	}
}

# Notify all Germanic and Christian players of destruction of Irminsul
narrative_event = {
	id = CM.1102
	desc = EVTDESC_CM_1102
	title = EVTTITLE_CM_1102
	picture = GFX_evt_irminsul_burning

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1102
		trigger = {
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			culture = old_saxon
		}
	}
	option = {
		name = EVTOPTB_CM_1102
		trigger = {
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			NOT = { culture = old_saxon }
		}
	}
	option = {
		name = EVTOPTC_CM_1102
		trigger = {
			religion_group = christian
		}
	}
}

# Blood court of Verden
narrative_event = {
	id = CM.1104
	desc = EVTDESC_CM_1104
	title = EVTTITLE_CM_1104
	picture = GFX_evt_beheading

	only_independent = yes
	only_playable = yes
	religion_group = christian
	only_capable = yes
	min_age = 16
	prisoner = no 
	war = no
	has_global_flag = saxon_wars
	has_dlc = "Charlemagne"
	
	trigger = {
		NOT = { year = 900 }
		NOT = { has_global_flag = blood_court_of_verden }
		higher_real_tier_than = DUKE
		NOT = { culture = old_saxon }
		NOT = { religion_group = pagan_group }
		any_realm_province = {
			culture = old_saxon
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
			}
		}
		any_courtier = {
			prisoner = yes
			host = { character = ROOT }
			culture = old_saxon
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
			}
		}
	}
	
	mean_time_to_happen = {
		months = 10
	}
	
	immediate = {
		set_global_flag = blood_court_of_verden
	}
	
	option = {
		name = EVTOPTA_CM_1104 # Executions
		prestige = 100
		if = {
			limit = { NOT = { trait = cruel } }
			add_trait = cruel
		}
		if = {
			limit = { NOT = { trait = zealous } }
			add_trait = zealous
		}
		any_courtier = {
			limit = {
				prisoner = yes
				host = { character = ROOT }
				culture = old_saxon
				OR = {
					religion = german_pagan
					religion = german_pagan_reformed
				}
			}
			death = {
				death_reason = death_execution_beheading
				killer = ROOT
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1104 # Stay your hand
		prestige = -5
	}
}	

# Emergence of Widukind
narrative_event = {
	id = CM.1105
	title = EVTTITLE_CM_1105
	desc = EVTDESC_CM_1105
	picture = GFX_evt_bandits

	only_independent = yes
	only_playable = yes
	has_dlc = "Charlemagne"
	has_global_flag = saxon_wars
	
	trigger = {
		higher_real_tier_than = DUKE
		NOT = { has_global_flag = widukind_spawned }
		NOT = { culture = old_saxon }
		NOT = { religion_group = pagan_group }
		OR = {
			has_landed_title = k_saxony
			any_realm_lord = { has_landed_title = k_saxony }
			has_landed_title = d_westphalia
			any_realm_lord = { has_landed_title = d_westphalia }
			has_landed_title = d_eastphalia
			any_realm_lord = { has_landed_title = d_eastphalia }
		}
		OR = {
			has_character_flag = is_charlemagne
			has_character_flag = is_carloman
			NOT = {
				any_independent_ruler = {
					OR = {
						has_character_flag = is_charlemagne
						has_character_flag = is_carloman
					}
				}
			}
		}
		any_realm_province = {
			culture = old_saxon
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
			}
		}
	}
	
	mean_time_to_happen = {
		months = 20
	}
	
	immediate = {
		set_global_flag = widukind_spawned
		set_character_flag = widukind_enemy
	}
	
	option = {
		name = EVTOPTA_CM_1105
		random_realm_province = {
			limit = {
				culture = old_saxon
				OR = {
					religion = german_pagan
					religion = german_pagan_reformed
				}
			}
			hidden_tooltip = { province_event = { id = CM.1106 } }
		}
	}
}

# Widukind
province_event = {
	id = CM.1106
	
	hide_window = yes
	
	is_triggered_only = yes

	immediate = {
		create_character = {
			random_traits = no
			dynasty = 7282
			religion = ROOT
			culture = old_saxon
			age = 35
			female = no
			trait = honest
			trait = brave
			trait = diligent
			trait = proud
			trait = brilliant_strategist
			trait = aggressive_leader
			attributes = {
				diplomacy = 10
				martial = 10
				stewardship = 5
				intrigue = 6
				learning = 7
			}
		}
		new_character = {
			set_name = Widukind
			set_character_flag = is_widukind
			set_character_flag = claimant_adventurer
			set_defacto_liege = THIS
			prestige = 100
			piety = 50
			add_claim = k_saxony
			add_claim = d_westphalia
			add_claim = d_eastphalia
			create_title = {
				tier = DUKE
				landless = yes
				temporary = yes
				culture = old_saxon
				name = "WIDUKIND_ARMY"
				holder = THIS
			}
			spawn_unit = {
				owner = THIS
				leader = THIS
				province = ROOT
				home = ROOT
				troops = {
					archers = { 1000 1000 }
					light_infantry = { 1500 1500 }
					heavy_infantry = { 1000 1000 }
					light_cavalry = { 500 500 }
				}
				attrition = 1.0
				cannot_inherit = yes
			}
			spawn_unit = {
				owner = THIS
				province = ROOT
				home = ROOT
				troops = {
					archers = { 1000 1000 }
					light_infantry = { 1500 1500 }
					heavy_infantry = { 1000 1000 }
					light_cavalry = { 500 500 }
				}
				attrition = 1.0
				disband_on_peace = yes
			}
			spawn_unit = {
				owner = THIS
				province = ROOT
				home = ROOT
				troops = {
					archers = { 1000 1000 }
					light_infantry = { 1500 1500 }
					heavy_infantry = { 1000 1000 }
					light_cavalry = { 500 500 }
				}
				attrition = 1.0
				disband_on_peace = yes
			}
			if = {
				limit = {
					FROM = { any_realm_title = { title = k_saxony }	}
				}
				k_saxony = {
					FROM = {
						reverse_war = {
							target = PREVPREV
							casus_belli = claim
							thirdparty_title = PREV
							infamy = 0
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { NOT = { any_realm_title = { title = k_saxony } } }
					FROM = { any_realm_title = { title = d_westphalia } }
				}
				d_westphalia = {
					FROM = {
						reverse_war = {
							target = PREVPREV
							casus_belli = claim
							thirdparty_title = PREV
							infamy = 0
						}
					}
				}
			}
			if = {
				limit = {
					FROM = { NOT = { any_realm_title = { title = k_saxony } } }
					FROM = { NOT = { any_realm_title = { title = d_westphalia } } }
					FROM = { any_realm_title = { title = d_eastphalia } }
				}
				d_eastphalia = {
					FROM = {
						reverse_war = {
							target = PREVPREV
							casus_belli = claim
							thirdparty_title = PREV
							infamy = 0
						}
					}
				}
			}
		}
	}
}

# Baptism of Widukind
narrative_event = {
	id = CM.1108
	desc = EVTDESC_CM_1108
	title = EVTTITLE_CM_1108
	picture = GFX_evt_bandits
	border = GFX_event_narrative_frame_religion
	
	only_playable = yes
	religion_group = christian
	only_independent = yes
	only_capable = yes
	min_age = 16
	prisoner = no
	has_character_flag = widukind_enemy	
	war = no

	trigger = {
		has_dlc = "Charlemagne"
		OR = {
			primary_title = { tier = EMPEROR }
			primary_title = { tier = KING }
		}

		any_independent_ruler = {
			any_realm_character = {
				has_character_flag = is_widukind
				is_ruler = no
				prisoner = no
				religion_group = pagan_group
				NOT = { trait = incapable }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				any_realm_character = {
					has_character_flag = is_widukind
					is_ruler = no
					prisoner = no
					religion_group = pagan_group
					NOT = { trait = incapable }
				}
			}
			random_realm_character = {
				limit = {
					has_character_flag = is_widukind
					is_ruler = no
					prisoner = no
					religion_group = pagan_group
					NOT = { trait = incapable }
				}
				save_event_target_as = widukind
			}
		}
	}
	
	option = {
		name = EVTOPTA_CM_1108 # Accept him and baptize him
		event_target:widukind = {
			move_character = ROOT
			religion = ROOT
			remove_trait = zealous
			add_trait = sympathy_pagans
			set_character_flag = hero_knight
		}
	}
	option = {
		name = EVTOPTB_CM_1108 # Invite him here then kill him
		prestige = 30
		event_target:widukind = {
			move_character = ROOT
			death = {
				death_reason = death_execution_beheading
				killer = ROOT
			}
		}
		if = {
			limit = { NOT = { trait = deceitful } }
			add_trait = deceitful
		}
	}
	option = {
		name = EVTOPTC_CM_1108 # Ignore him
		prestige = 10
	}
}

# Prompting the AI to create the Carolingian Empire
character_event = {
	id = CM.1115
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		dynasty = 25061
		ai = yes
		war = no
		higher_real_tier_than = DUKE
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			e_karling = { has_title_flag = carolingian_empire_formed }
			has_character_modifier = do_not_disturb
		}
		OR = {
			has_landed_title = k_saxony
			any_vassal = { has_landed_title = k_saxony }
			year = 774
		}
		any_independent_ruler = {
			religion = ROOT
			reverse_realm_levy_diff = { who = ROOT value = 7500 }
			any_realm_title = {
				count = 3
				tier = COUNT
				kingdom = { title = k_bavaria }
			}
			NOR = {
				reverse_has_truce = ROOT
				dynasty = ROOT
				is_allied_with = ROOT
				has_non_aggression_pact_with = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				pays_tribute_to = ROOT
				has_landed_title = k_papal_state
				ROOT = { rightful_religious_head = PREV }
			}
			capital_scope = {
				kingdom = {
					is_contested = no
					title = k_bavaria
					any_direct_de_jure_vassal_title = {
						any_direct_de_jure_vassal_title = {
							OR = {
								holder_scope = { same_realm = ROOT }
								location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
		modifier = {
			factor = 2.0
			NOT = {
				calc_true_if = {
					amount = 2
					has_landed_title = k_bavaria
					has_landed_title = k_saxony
					has_landed_title = k_lotharingia
					has_landed_title = k_lombardy
					has_landed_title = k_italy
				}
			}
		}
		modifier = {
			factor = 0.5
			calc_true_if = {
				amount = 2
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_lombardy
				has_landed_title = k_italy
			}
		}
		modifier = {
			factor = 0.25
			calc_true_if = {
				amount = 3
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_lombardy
				has_landed_title = k_italy
			}
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion = ROOT
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				any_realm_title = {
					count = 3
					tier = COUNT
					kingdom = { title = k_bavaria }
				}
				NOR = {
					reverse_has_truce = ROOT
					dynasty = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 25 }
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
				capital_scope = {
					kingdom = {
						title = k_bavaria
						any_direct_de_jure_vassal_title = {
							any_direct_de_jure_vassal_title = {
								OR = {
									holder_scope = { same_realm = ROOT }
									location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
								}
							}
						}
					}
				}
			}
			capital_scope = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = carolingian_manifest_destiny
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
							infamy = 0
						}
					}
				}
			}
		}
	}
}

character_event = {
	id = CM.1116
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		dynasty = 25061
		ai = yes
		war = no
		higher_real_tier_than = DUKE
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			e_karling = { has_title_flag = carolingian_empire_formed }
			has_character_modifier = do_not_disturb
		}
		any_independent_ruler = {
			religion = ROOT
			reverse_realm_levy_diff = { who = ROOT value = 7500 }
			any_realm_title = {
				count = 3
				tier = COUNT
				kingdom = { title = k_saxony }
			}
			NOR = {
				reverse_has_truce = ROOT
				dynasty = ROOT
				is_allied_with = ROOT
				has_non_aggression_pact_with = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				pays_tribute_to = ROOT
				has_landed_title = k_papal_state
				ROOT = { rightful_religious_head = PREV }
			}
			capital_scope = {
				kingdom = {
					is_contested = no
					title = k_saxony
					any_direct_de_jure_vassal_title = {
						any_direct_de_jure_vassal_title = {
							OR = {
								holder_scope = { same_realm = ROOT }
								location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
		modifier = {
			factor = 2.0
			NOT = {
				calc_true_if = {
					amount = 2
					has_landed_title = k_bavaria
					has_landed_title = k_saxony
					has_landed_title = k_lotharingia
					has_landed_title = k_italy
					has_landed_title = k_lombardy
				}
			}
		}
		modifier = {
			factor = 0.5
			calc_true_if = {
				amount = 2
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
		modifier = {
			factor = 0.25
			calc_true_if = {
				amount = 3
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion = ROOT
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				any_realm_title = {
					count = 3
					tier = COUNT
					kingdom = { title = k_saxony }
				}
				NOR = {
					reverse_has_truce = ROOT
					dynasty = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 25 }
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
				capital_scope = {
					kingdom = {
						title = k_saxony
						any_direct_de_jure_vassal_title = {
							any_direct_de_jure_vassal_title = {
								OR = {
									holder_scope = { same_realm = ROOT }
									location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
								}
							}
						}
					}
				}
			}
			capital_scope = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = carolingian_manifest_destiny
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
							infamy = 0
						}
					}
				}
			}
		}
	}
}

character_event = {
	id = CM.1117
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		dynasty = 25061
		ai = yes
		war = no
		higher_real_tier_than = DUKE
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			e_karling = { has_title_flag = carolingian_empire_formed }
			has_character_modifier = do_not_disturb
		}
		any_independent_ruler = {
			religion = ROOT
			reverse_realm_levy_diff = { who = ROOT value = 7500 }
			any_realm_title = {
				count = 3
				tier = COUNT
				kingdom = { title = k_lotharingia }
			}
			NOR = {
				reverse_has_truce = ROOT
				dynasty = ROOT
				is_allied_with = ROOT
				has_non_aggression_pact_with = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				pays_tribute_to = ROOT
				has_landed_title = k_papal_state
				ROOT = { rightful_religious_head = PREV }
			}
			capital_scope = {
				kingdom = {
					is_contested = no
					title = k_lotharingia
					any_direct_de_jure_vassal_title = {
						any_direct_de_jure_vassal_title = {
							OR = {
								holder_scope = { same_realm = ROOT }
								location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
		modifier = {
			factor = 2.0
			NOT = {
				calc_true_if = {
					amount = 2
					has_landed_title = k_bavaria
					has_landed_title = k_saxony
					has_landed_title = k_lotharingia
					has_landed_title = k_italy
					has_landed_title = k_lombardy
				}
			}
		}
		modifier = {
			factor = 0.5
			calc_true_if = {
				amount = 2
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
		modifier = {
			factor = 0.25
			calc_true_if = {
				amount = 3
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion = ROOT
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				any_realm_title = {
					count = 3
					tier = COUNT
					kingdom = { title = k_lotharingia }
				}
				NOR = {
					reverse_has_truce = ROOT
					dynasty = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 25 }
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
				capital_scope = {
					kingdom = {
						title = k_lotharingia
						any_direct_de_jure_vassal_title = {
							any_direct_de_jure_vassal_title = {
								OR = {
									holder_scope = { same_realm = ROOT }
									location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
								}
							}
						}
					}
				}
			}
			capital_scope = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = carolingian_manifest_destiny
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
							infamy = 0
						}
					}
				}
			}
		}
	}
}

character_event = {
	id = CM.1118
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		dynasty = 25061
		ai = yes
		war = no
		higher_real_tier_than = DUKE
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			e_karling = { has_title_flag = carolingian_empire_formed }
			has_character_modifier = do_not_disturb
		}
		any_independent_ruler = {
			religion = ROOT
			reverse_realm_levy_diff = { who = ROOT value = 7500 }
			any_realm_title = {
				count = 3
				tier = COUNT
				kingdom = { title = k_france }
			}
			NOR = {
				reverse_has_truce = ROOT
				dynasty = ROOT
				is_allied_with = ROOT
				has_non_aggression_pact_with = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				pays_tribute_to = ROOT
				has_landed_title = k_papal_state
				ROOT = { rightful_religious_head = PREV }
			}
			capital_scope = {
				kingdom = {
					is_contested = no
					title = k_france
					any_direct_de_jure_vassal_title = {
						any_direct_de_jure_vassal_title = {
							OR = {
								holder_scope = { same_realm = ROOT }
								location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
		modifier = {
			factor = 2.0
			NOT = {
				calc_true_if = {
					amount = 2
					has_landed_title = k_bavaria
					has_landed_title = k_saxony
					has_landed_title = k_lotharingia
				}
			}
		}
		modifier = {
			factor = 0.5
			calc_true_if = {
				amount = 2
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
			}
		}
		modifier = {
			factor = 0.25
			has_landed_title = k_bavaria
			has_landed_title = k_saxony
			has_landed_title = k_lotharingia
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion = ROOT
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				any_realm_title = {
					count = 3
					tier = COUNT
					kingdom = { title = k_france }
				}
				NOR = {
					reverse_has_truce = ROOT
					dynasty = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 25 }
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
				capital_scope = {
					kingdom = {
						title = k_france
						any_direct_de_jure_vassal_title = {
							any_direct_de_jure_vassal_title = {
								OR = {
									holder_scope = { same_realm = ROOT }
									location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
								}
							}
						}
					}
				}
			}
			capital_scope = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = carolingian_manifest_destiny
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
							infamy = 0
						}
					}
				}
			}
		}
	}
}

character_event = {
	id = CM.1119
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		dynasty = 25061
		ai = yes
		war = no
		higher_real_tier_than = DUKE
		NOR = {
			has_strong_claim = k_lombardy
			e_hre = { has_title_flag = hre_formed }
			e_karling = { has_title_flag = carolingian_empire_formed }
			has_character_modifier = do_not_disturb
		}
		OR = {
			has_character_flag = is_charlemagne
			NOT = { any_independent_ruler = { has_character_flag = is_charlemagne } }
		}
		any_independent_ruler = {
			religion = ROOT
			reverse_realm_levy_diff = { who = ROOT value = 7500 }
			any_realm_title = {
				count = 3
				tier = COUNT
				kingdom = { title = k_lombardy }
			}
			NOR = {
				reverse_has_truce = ROOT
				dynasty = ROOT
				is_allied_with = ROOT
				has_non_aggression_pact_with = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				pays_tribute_to = ROOT
				has_landed_title = k_papal_state
				ROOT = { rightful_religious_head = PREV }
			}
			capital_scope = {
				kingdom = {
					is_contested = no
					title = k_lombardy
					any_direct_de_jure_vassal_title = {
						any_direct_de_jure_vassal_title = {
							OR = {
								holder_scope = { same_realm = ROOT }
								location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
		modifier = {
			factor = 2.0
			NOT = {
				calc_true_if = {
					amount = 2
					has_landed_title = k_bavaria
					has_landed_title = k_saxony
					has_landed_title = k_lotharingia
					has_landed_title = k_italy
					has_landed_title = k_lombardy
				}
			}
		}
		modifier = {
			factor = 0.5
			calc_true_if = {
				amount = 2
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
		modifier = {
			factor = 0.25
			calc_true_if = {
				amount = 3
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion = ROOT
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				any_realm_title = {
					count = 3
					tier = COUNT
					kingdom = { title = k_lombardy }
				}
				NOR = {
					reverse_has_truce = ROOT
					dynasty = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 25 }
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
				capital_scope = {
					kingdom = {
						title = k_lombardy
						any_direct_de_jure_vassal_title = {
							any_direct_de_jure_vassal_title = {
								OR = {
									holder_scope = { same_realm = ROOT }
									location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
								}
							}
						}
					}
				}
			}
			capital_scope = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = carolingian_manifest_destiny
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
	}
}

character_event = {
	id = CM.1125
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		dynasty = 25061
		ai = yes
		war = no
		higher_real_tier_than = DUKE
		NOR = {
			e_hre = { has_title_flag = hre_formed }
			e_karling = { has_title_flag = carolingian_empire_formed }
			has_character_modifier = do_not_disturb
		}
		any_independent_ruler = {
			religion = ROOT
			reverse_realm_levy_diff = { who = ROOT value = 7500 }
			any_realm_title = {
				count = 3
				tier = COUNT
				kingdom = { title = k_italy }
			}
			NOR = {
				reverse_has_truce = ROOT
				dynasty = ROOT
				is_allied_with = ROOT
				has_non_aggression_pact_with = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				pays_tribute_to = ROOT
				has_landed_title = k_papal_state
				ROOT = { rightful_religious_head = PREV }
			}
			capital_scope = {
				kingdom = {
					is_contested = no
					title = k_italy
					any_direct_de_jure_vassal_title = {
						any_direct_de_jure_vassal_title = {
							OR = {
								holder_scope = { same_realm = ROOT }
								location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
		modifier = {
			factor = 2.0
			NOT = {
				calc_true_if = {
					amount = 2
					has_landed_title = k_bavaria
					has_landed_title = k_saxony
					has_landed_title = k_lotharingia
					has_landed_title = k_italy
					has_landed_title = k_lombardy
				}
			}
		}
		modifier = {
			factor = 0.5
			calc_true_if = {
				amount = 2
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
		modifier = {
			factor = 0.25
			calc_true_if = {
				amount = 3
				has_landed_title = k_bavaria
				has_landed_title = k_saxony
				has_landed_title = k_lotharingia
				has_landed_title = k_italy
				has_landed_title = k_lombardy
			}
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion = ROOT
				reverse_realm_levy_diff = { who = ROOT value = 7500 }
				any_realm_title = {
					count = 3
					tier = COUNT
					kingdom = { title = k_italy }
				}
				NOR = {
					reverse_has_truce = ROOT
					dynasty = ROOT
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 25 }
					pays_tribute_to = ROOT
					has_landed_title = k_papal_state
					ROOT = { rightful_religious_head = PREV }
				}
				capital_scope = {
					kingdom = {
						title = k_italy
						any_direct_de_jure_vassal_title = {
							any_direct_de_jure_vassal_title = {
								OR = {
									holder_scope = { same_realm = ROOT }
									location = { any_neighbor_province = { owner = { same_realm = ROOT } } }
								}
							}
						}
					}
				}
			}
			capital_scope = {
				kingdom = {
					ROOT = {
						war = {
							casus_belli = carolingian_manifest_destiny
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
	}
}

############################################
# Bertrada and Charlemagne murder Carloman #
############################################

# Bertrada suggests course of action - only hinting at murder
narrative_event = {
	id = CM.1120
	title = EVTTITLE_CM_1120
	desc = EVTDESC_CM_1120
	picture = GFX_evt_daughter_asking_father

	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		has_character_flag = is_charlemagne
		has_character_flag = charlemagne_brother_rivalry
		any_sibling = { has_character_flag = is_carloman }
		mother = { 
			is_alive = yes
			prisoner = no
		}
	}
	
	option = {
		name = EVTOPTA_CM_1120 # Yes do something
		ai_chance = { factor = 70 }
		hidden_tooltip = {
			any_sibling = {
				limit = { has_character_flag = is_carloman }
				character_event = { id = CM.1121 days = 30 random = 10 }
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1120  # No
		ai_chance = { factor = 30 }
	}
}

# Bertrada comes to see Carloman
character_event = {
	id = CM.1121
	desc = EVTDESC_CM_1121
	picture = GFX_evt_emissary

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1121
		ai_chance = { factor = 100 }
		hidden_tooltip = { narrative_event = { id = CM.1122 } } # Invite her in
	}
	option = {
		name = EVTOPTB_CM_1121 # Send her away
		ai_chance = { factor = 0 }
	}
}

# Bertrada offers Carloman poisoned wine
narrative_event = {
	id = CM.1122
	title = EVTTITLE_CM_1122
	desc = EVTDESC_CM_1122
	picture = GFX_evt_courtiers_talking

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1122
		ai_chance = { factor = 100 }
		hidden_tooltip = { character_event = { id = CM.1123 } } # Drink the wine...
	}
	option = {
		name = EVTOPTB_CM_1122       # I don't trust you, please leave
		ai_chance = { factor = 0 }
		trigger = {
			NOT = { trait = drunkard }
		}
		if = {
			limit = { trait = trusting }
			remove_trait = trusting
		}
	}
}

# Carloman feels sick (poisoned)
character_event = {
	id = CM.1123
	desc = EVTDESC_CM_1123
	picture = GFX_evt_bad_news

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1123
		trigger = {
			ai = yes
		}
		hidden_tooltip = { character_event = { id = CM.1124 days = 5 random = 3 } } # Death a few days later
	}
	option = {
		name = EVTOPTA_CM_1123
		trigger = {
			ai = no
		}
		if = {
			limit = {
				OR = {
					is_ill = yes
					trait = pneumonic
				}
			}
			add_trait = infirm
		}
		if = {
			limit = {
				is_ill = yes
				NOT = { trait = pneumonic }
			}
			if = {
				limit = {
					NOT = {
						has_dlc = "Reapers"
					}
				}
				add_trait = ill
			}
			if = {
				limit = {
					has_dlc = "Reapers"
				}
			set_character_flag = disease_not_serious
			add_trait = vomiting
			character_event = { id = RIP.11005 days = 10 random = 30 }
			}
		}
	}
}

character_event = {
	id = CM.1124

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		death = {
			death_reason = death_natural
		}
	}
}

# Vassal switches sides between Charlemagne/Carloman
character_event = {
	id = CM.1130

	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { year = 820 }
		has_character_flag = charlemagne_brother_rivalry
		any_sibling = {
			has_character_flag = charlemagne_brother_rivalry
		}
		any_vassal = {
			ai = yes
			NOT = { opinion = { who = ROOT value = 0 } }
		}
		OR = {
			AND = {
				NOT = { prestige = 0 }
				any_sibling = {
					has_character_flag = charlemagne_brother_rivalry
					prestige = 300
				}
			}
			AND = {
				NOT = { prestige = 200 }
				any_sibling = {
					has_character_flag = charlemagne_brother_rivalry
					prestige = 1000
				}
			}
			AND = {
				NOT = { prestige = 1000 }
				any_sibling = {
					has_character_flag = charlemagne_brother_rivalry
					prestige = 10000
				}
			}
		}
		in_revolt = no
		pf_war_trait_trigger = no
	}
	
	weight_multiplier = {
		days = 1
		
		modifier = {
			factor = 15
			any_sibling = { has_character_flag = charlemagne_brother_rivalry }
		}
		modifier = {
			factor = 0
			NOT = { any_sibling = { has_character_flag = charlemagne_brother_rivalry } }
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				ai = yes
				NOT = {	opinion = { who = ROOT value = 0 } }
			}
			character_event = { id = CM.1131 }
		}
	}
}

character_event = {
	id = CM.1131

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = { letter_event = { id = CM.1132 } }
	}
}

letter_event = {
	id = CM.1132
	desc = EVTDESC_CM_1132

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1132
		any_sibling = {
			limit = { has_character_flag = charlemagne_brother_rivalry }
			FROM = {
				set_defacto_liege = PREV
				pf_liege_change_effect = yes
			}
		}
	}
}


###################################################################
#                                                                 #
# Bertrada meddles in everything CM.1150-1399                     #
#                                                                 #
# Any of these events can happen to any player character's mother #
# when she gets the flag meddling_mother                            #
###################################################################

# Your mother starts to meddle in your affairs (hidden)
character_event = {
	id = CM.1150

	hide_window = yes
	
	is_triggered_only = yes

	ai = no
	
	trigger = {
		has_dlc = "Charlemagne"
		mother = {
			is_alive = yes
			is_ruler = no
			liege = { character = ROOT }
			OR = {
				trait = ambitious
				trait = proud
				trait = envious
				trait = intricate_webweaver
				trait = elusive_shadow
			}
		}
	}
	
	weight_multiplier = {
		days = 1
		
		modifier = {
			factor = 5
			mother = { culture = mongol }
		}
	}
	
	immediate = {
		mother = {
			set_character_flag = meddling_mother
		}
	}
}

# Mother dislikes your spouse
character_event = {
	id = CM.1160
	desc = EVTDESC_CM_1160
	picture = GFX_evt_daughter_asking_father

	is_triggered_only = yes

	ai = no
	min_age = 16
	capable_only = yes
	is_married = yes
	has_dlc = "Charlemagne"
	prisoner = no
	
	trigger = {
		NOT = { has_character_modifier = do_not_disturb }
		in_command_trigger = no
		mother = {
			has_character_flag = meddling_mother
			NOT = { trait = nun }
			NOT = { trait = incapable }
			prisoner = no
		}
		NOT = { religion_group = muslim }
		spouse = {
			NOT = { has_character_flag = meddling_mother_conflict }
			is_ruler = no
			liege = { character = ROOT }
			OR = {
				trait = ambitious
				trait = proud
				is_smart_trigger = yes
				trait = diligent
			}
		}
	}
	
	weight_multiplier = {
		days = 1
		
		modifier = {
			factor = 10
			mother = { has_character_flag = meddling_mother	}
		}
		modifier = {
			factor = 0
			mother = { NOT = { has_character_flag = meddling_mother	} }
		}
	}
	
	immediate = {
		spouse = { set_character_flag = meddling_mother_conflict }
	}
	
	option = {
		name = EVTOPTA_CM_1160 # Yes mother
		set_character_flag = meddling_mother_gone_too_far
		spouse = {
			if = {
				limit = { is_lover = ROOT }
				remove_lover = ROOT
			}
			opinion = {
				who = ROOT
				years = 5
				modifier = opinion_bitter
			}
			ROOT = {
				mother = {
					opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_dislike
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1160 # No mother
		spouse = {
			ROOT = {
				mother = {
					opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_hate
					}
					reverse_opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_dislike
					}
					opinion = {
						who = ROOT
						years = 3
						modifier = opinion_angry
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTC_CM_1160  # Send her to a convent
		trigger = {
			religion_group = christian
			NOT = { trait = craven }
			mother = {
				has_character_flag = meddling_mother_gone_too_far
			}
		}
		spouse = {
			ROOT = {
				mother = {
					add_trait = nun
					opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_hate
					}
					opinion = {
						who = ROOT
						years = 10
						modifier = opinion_bitter
					}
				}
			}
		}
	}
}

# Mother dislikes your councillor
character_event = {
	id = CM.1170

	hide_window = yes
	
	is_triggered_only = yes

	ai = no
	min_age = 16
	capable_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = { has_character_modifier = do_not_disturb }
		in_command_trigger = no
		prisoner = no
		mother = {
			has_character_flag = meddling_mother
			NOT = { trait = nun }
			NOT = { trait = incapable }
			prisoner = no
		}
		any_courtier = {
			NOT = { has_character_flag = meddling_mother_conflict }
			NOT = { has_character_flag = meddling_mother }
			NOT = { any_child = { character =  ROOT } }
			is_councillor = yes
			liege = { character = ROOT }
			OR = {
				trait = ambitious
				trait = proud
				is_smart_trigger = yes
				trait = diligent
			}
		}
	}

	weight_multiplier = {
		days = 1
		
		modifier = {
			factor = 10
			mother = { has_character_flag = meddling_mother	}
		}
		modifier = {
			factor = 0
			mother = { NOT = { has_character_flag = meddling_mother	} }
		}
	}

	immediate = {
		random_courtier = {
			limit = {
				is_councillor = yes
				NOT = { any_child = { character =  ROOT } }
				liege = { character = ROOT }
				OR = {
					trait = ambitious
					trait = proud
					is_smart_trigger = yes
					trait = diligent
				}
			}
			set_character_flag = meddling_mother_conflict
			character_event = { id = CM.1171 }
		}
	}
}

character_event = {
	id = CM.1171

	hide_window = yes
	
	is_triggered_only = yes

	immediate = {
		FROM = { character_event = { id = CM.1172 } }
	}
}

character_event = {
	id = CM.1172
	desc = EVTDESC_CM_1172
	picture = GFX_evt_daughter_asking_father

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1172 # Yes mother
		set_character_flag = meddling_mother_gone_too_far
		FROM = {
			if = {
				limit = { is_lover = ROOT }
				remove_lover = ROOT
			}
			if = {
				limit = { has_job_title = job_chancellor }
				remove_title = job_chancellor
			}
			if = {
				limit = { has_job_title = job_marshal }
				remove_title = job_marshal
			}
			if = {
				limit = { has_job_title = job_treasurer }
				remove_title = job_treasurer
			}
			if = {
				limit = { has_job_title = job_spymaster }
				remove_title = job_spymaster
			}
			if = {
				limit = { has_job_title = job_spiritual }
				remove_title = job_spiritual
			}
			if = {
				limit = { is_ruler = no }
				banish = yes
			}
			prestige = -30
			opinion = {
				modifier = opinion_fired_from_council
				who = ROOT
				years = 5
			}
			ROOT = {
				mother = {
					opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_dislike
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1172 # No mother
		FROM = {
			ROOT = {
				mother = {
					prestige = -30
					opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_hate
					}
					reverse_opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_dislike
					}
					opinion = {
						who = ROOT
						years = 3
						modifier = opinion_angry
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTC_CM_1172  # Send her to a convent
		trigger = {
			religion_group = christian
			NOT = { trait = craven }
			mother = {
				has_character_flag = meddling_mother_gone_too_far
			}
		}
		FROM = {
			ROOT = {
				mother = {
					add_trait = nun
					opinion = {
						who = PREVPREV
						years = 100
						modifier = opinion_hate
					}
					opinion = {
						who = ROOT
						years = 10
						modifier = opinion_bitter
					}
				}
			}
		}
	}
}

# Mother insists on being regent
character_event = {
	id = CM.1180

	hide_window = yes
	
	is_triggered_only = yes

	ai = no
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = { has_character_modifier = do_not_disturb }
		in_command_trigger = no
		prisoner = no
		has_regent = yes
		mother = {
			has_character_flag = meddling_mother
			NOT = { trait = nun }
			NOT = { trait = incapable }
			prisoner = no
			NOT = { has_minor_title = title_regent }
		}
		
		any_courtier = {
			has_minor_title = title_regent
			NOT = { has_character_flag = meddling_mother_conflict }
			ai = yes
		}
	}

	weight_multiplier = {
		days = 1
		
		modifier = {
			factor = 100
			mother = { has_character_flag = meddling_mother	}
		}
		modifier = {
			factor = 0
			mother = { NOT = { has_character_flag = meddling_mother	} }
		}
	}

	immediate = {
		regent = {
			set_character_flag = meddling_mother_conflict
			character_event = { id = CM.1181 }
		}
	}
}

character_event = {
	id = CM.1181
	desc = EVTDESC_CM_1181
	picture = GFX_evt_throne_room

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1181 # Accept
		ai_chance = {
			factor = 100
		}
		tooltip = {
			remove_title = title_regent
			FROM = { mother = { give_minor_title = title_regent } }
		}
		FROM = { character_event = { id = CM.1182 } }
	}
	option = {
		name = EVTOPTB_CM_1181 # Fight it
		ai_chance = {
			factor = 0
		}
		FROM = {
			mother = {
				add_rival = ROOT
			}
		}
	}
}

character_event = {
	id = CM.1182
	desc = EVTDESC_CM_1182
	picture = GFX_evt_throne_room

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1182 # Mother knows best
		trigger = {
			NOT = { has_character_flag = meddling_mother_gone_too_far }
		}
		set_character_flag = meddling_mother_gone_too_far
		FROM = { remove_title = title_regent }
		mother = { give_minor_title = title_regent }
	}
	option = {
		name = EVTOPTB_CM_1182 # Hmm, who really rules here?
		trigger = {
			has_character_flag = meddling_mother_gone_too_far
		}
		FROM = { remove_title = title_regent }
		mother = { give_minor_title = title_regent }
	}
}

# Mother seduces your spouse
character_event = {
	id = CM.1190

	hide_window = yes
	
	is_triggered_only = yes

	ai = no
	min_age = 16
	capable_only = yes
	prisoner = no
	is_married = yes
	has_dlc = "Charlemagne"
	
	trigger = {
		NOT = { has_character_modifier = do_not_disturb }
		in_command_trigger = no
		mother = {
			has_character_flag = meddling_mother
			NOT = { trait = nun }
			NOT = { trait = incapable }
			prisoner = no
			OR = {
				AND = {
					ROOT = {
						any_spouse = { is_female = yes }
					}
					trait = homosexual
				}
				ROOT = {
					any_spouse = { is_female = no }
				}
			}
		}
		any_spouse = {
			ai = yes
			NOT = { trait = celibate }
			NOT = { trait = incapable }
			NOT = { has_character_flag = meddling_mother_conflict }
			OR = {
				is_female = no
				AND = {
					is_female = yes
					trait = homosexual
				}
			}
			liege = { character = ROOT }
			OR = {
				trait = humble
				trait = fair
				trait = slow
				trait = dull
				trait = stressed
				trait = depressed
			}
		}
	}

	weight_multiplier = {
		days = 1
		
		modifier = {
			factor = 10
			mother = { has_character_flag = meddling_mother	}
		}
		modifier = {
			factor = 0
			mother = { NOT = { has_character_flag = meddling_mother	} }
		}
	}

	immediate = {
		random_spouse = {
			limit = {
				ai = yes
				NOT = { has_character_flag = meddling_mother_conflict }
				OR = {
					is_female = no
					AND = {
						is_female = yes
						trait = homosexual
					}
				}
				liege = { character = ROOT }
				OR = {
					trait = humble
					trait = fair
					trait = slow
					trait = dull
					trait = stressed
					trait = depressed
					NOT = { trait = celibate }
				}
			}
			character_event = { id = CM.1191 }
		}
	}
}

character_event = {
	id = CM.1191

	hide_window = yes
	
	is_triggered_only = yes

	immediate = {
		FROM = { character_event = { id = CM.1192 } }
	}
}

character_event = {
	id = CM.1192
	desc = EVTDESC_CM_1192
	picture = GFX_evt_lovers

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1192 # Accept
		set_character_flag = meddling_mother_gone_too_far
	}
	option = {
		name = EVTOPTB_CM_1192 # Send spouse to convent
		set_character_flag = meddling_mother_gone_too_far
		FROM = {
			if = {
				limit = { is_female = no }
				add_trait = monk
			}
			if = {
				limit = { is_female = yes }
				add_trait = nun
			}
		}
	}
	option = {
		name = EVTOPTC_CM_1192  # Send mother to a convent
		trigger = {
			religion_group = christian
			NOT = { trait = craven }
			mother = {
				liege = { character = ROOT }
				is_ruler = no
				has_character_flag = meddling_mother_gone_too_far
			}
		}
		FROM = {
			ROOT = {
				mother = {
					add_trait = nun
					remove_lover = FROM
					opinion = {
						who = FROM
						years = 100
						modifier = opinion_hate
					}
					opinion = {
						who = ROOT
						years = 10
						modifier = opinion_bitter
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTD_CM_1192  # Send them both to the orders
		trigger = {
			religion_group = christian
			NOT = { trait = craven }
			mother = {
				liege = { character = ROOT }
				is_ruler = no
				has_character_flag = meddling_mother_gone_too_far
			}
		}
		FROM = {
			if = {
				limit = { is_female = no }
				add_trait = monk
			}
			if = {
				limit = { is_female = yes }
				add_trait = nun
			}
		}
		FROM = {
			ROOT = {
				mother = {
					add_trait = nun
					remove_lover = FROM
					opinion = {
						who = FROM
						years = 100
						modifier = opinion_hate
					}
					opinion = {
						who = ROOT
						years = 10
						modifier = opinion_bitter
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTE_CM_1192 # The dungeon
		trigger = {
			NOT = { religion_group = christian }
			has_character_flag = meddling_mother_gone_too_far
		}
		mother = { imprison = yes }
		FROM = { imprison = yes }
	}
}


#################################
#  Spanish Campaign             #
#  CM.1400-1499                 #
#################################

# Umayyad vassal calls upon Charlemagne to support rebellion in exchange for vassalization
character_event = {
	id = CM.1400

	hide_window = yes
	
	min_age = 16
	capable_only = yes
	only_playable = yes
	prisoner = no
	religion_group = christian
	only_independent = yes
	war = no
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		NOT = { has_global_flag = charlemagne_spain_intervention }
		year = 777
		NOT = { year = 820 }
		higher_tier_than = DUKE
		in_revolt = no
		pf_war_trait_trigger = no
		OR = {
			has_character_flag = is_charlemagne
			AND = {
				has_character_flag = is_carloman
				NOT = { any_independent_ruler = { has_character_flag = is_charlemagne } }  # Charlemagne, or Carloman, or any Frankish or French King or above before 820
			}
			AND = {
				NOT = { any_independent_ruler = { has_character_flag = is_charlemagne } }
				NOT = { any_independent_ruler = { has_character_flag = is_carloman } }
				OR = {
					culture = frankish
					culture = old_frankish
				}
			}
		}
		any_playable_ruler = {
			has_regent = no
			in_revolt = no
			lower_tier_than = ROOT
			higher_tier_than = COUNT
			NOR = {
				dynasty = 597 # Ummayad
				trait = content
				trait = humble
				trait = craven
			}
			liege = {
				dynasty = 597 # Ummayad
				OR = {
					has_landed_title = e_spain
					has_landed_title = k_andalusia
				}
				NOR = {
					reverse_has_truce = PREV
					has_non_aggression_pact_with = PREV
					is_friend = PREV
				}
			}
			ROOT = {
				any_realm_province = {
					any_neighbor_province = {
						owner = {
							OR = {
								character = PREVPREVPREVPREV
								is_liege_or_above = PREVPREVPREVPREV
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 8
	}

	immediate = {
		set_global_flag = charlemagne_spain_intervention
		random_playable_ruler = {
			limit = {
				has_regent = no
				in_revolt = no
				lower_tier_than = ROOT
				higher_tier_than = COUNT
				NOR = {
					dynasty = 597 # Ummayad
					trait = content
					trait = humble
					trait = craven
				}
				liege = {
					dynasty = 597 # Ummayad
					OR = {
						has_landed_title = e_spain
						has_landed_title = k_andalusia
					}
					NOR = {
						reverse_has_truce = PREV
						has_non_aggression_pact_with = PREV
						is_friend = PREV
					}
				}
				ROOT = {
					any_realm_province = {
						any_neighbor_province = {
							owner = {
								OR = {
									character = PREVPREVPREVPREV
									is_liege_or_above = PREVPREVPREVPREV
								}
							}
						}
					}
				}
			}
			hidden_tooltip = { character_event = { id = CM.1401 } }
		}
	}
}

# Umayyad vassal - ask Charlemagne for support?
character_event = {
	id = CM.1401
	desc = EVTDESC_CM_1401
	picture = GFX_evt_throne_room
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	immediate = {
		if = {
			limit = { ai = yes }
			liege = {
				reverse_opinion = {
					who = ROOT
					years = 5
					modifier = opinion_hate
				}
				add_rival = ROOT
			}
		}
	}
	
	option = {
		name = EVTOPTA_CM_1401 # Send a message to Charlemagne
		ai_chance = { factor = 100 }
		hidden_tooltip = { FROM = { narrative_event = { id = CM.1402 days = 20 } } }
	}
	option = {
		name = EVTOPTB_CM_1401 # Don't send it
		ai_chance = { factor = 0 }
		if = {
			limit = { NOT = { trait = content } }
			random = {
				chance = 30
				add_trait = content
				hidden_tooltip = {
					character_event = {
						id = 38279 #Notify Content
					}
				}
			}
		}
	}
}

# Frankish King receives embassy
narrative_event = {
	id = CM.1402
	title = EVTTITLE_CM_1402
	desc = EVTDESC_CM_1402
	picture = GFX_evt_emissary
	border = GFX_event_narrative_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1402 # Sign an agreement and prepare for war
		ai_chance = { factor = 100 }
		hidden_tooltip = { FROM = { character_event = { id = CM.1404 days = 20 } } }
	}
	option = {
		name = EVTOPTB_CM_1402 # Decline
		ai_chance = { factor = 0 }
		hidden_tooltip = { FROM = { character_event = { id = CM.1403 days = 20 } } }
		prestige = -30
	}
}

# Vassal receives negative answer from Franks
character_event = {
	id = CM.1403
	desc = EVTDESC_CM_1403
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1403
	}
}

# Vassal receives positive answer from Franks
character_event = {
	id = CM.1404
	desc = EVTDESC_CM_1404
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTA_CM_1404 # Prepare for war
		set_character_flag = ummayad_vassal_independence
		FROM = { set_character_flag = ummayad_vassal_ally }
	}
}

# Vassal declares independence war
character_event = {
	id = CM.1405
	desc = EVTDESC_CM_1405
	picture = GFX_evt_large_army
	border = GFX_event_normal_frame_war
	
	has_character_flag = ummayad_vassal_independence

	trigger = {
		war = no
		any_independent_ruler = {
			has_character_flag = ummayad_vassal_ally
			war = no
		}
	}
	
	mean_time_to_happen = {
		days = 10
	}
	
	immediate = {
		clr_character_flag = ummayad_vassal_independence
		liege = { save_event_target_as = target_liege }
		random_independent_ruler = {
			limit = { has_character_flag = ummayad_vassal_ally }
			clr_character_flag = ummayad_vassal_ally
			save_event_target_as = ummayad_ally
		}
	}

	option = {
		name = EVTOPTA_CM_1405   # Declares independence war
		event_target:target_liege = {
			reverse_war = {
				target = ROOT
				casus_belli = bid_for_independence
			}
		}
		hidden_tooltip = {
			event_target:ummayad_ally = {
				character_event = { id = CM.1406 days = 1 } # Calls on Frankish ally
			}
		}
	}
}

# Frankish King decides whether to honor promise or not
character_event = {
	id = CM.1406
	desc = EVTDESC_CM_1406
	picture = GFX_evt_large_army
	border = GFX_event_normal_frame_war

	is_triggered_only = yes
	
	trigger = {
		FROM = { war = yes }
	}

	option = {
		name = EVTOPTA_CM_1406
		ai_chance = {
			factor = 80
			modifier = {
				factor = 1.5
				trait = brave
			}
			modifier = {
				factor = 0.5
				any_war = {
					using_cb = bid_for_independence
					attacker = { character = FROM }
					defender = { realm_levy_diff = { who = ROOT value = 1000 } }
				}
			}
			modifier = {
				factor = 0.5
				any_war = {
					using_cb = bid_for_independence
					attacker = { character = FROM }
					defender = { realm_levy_diff = { who = ROOT value = 10000 } }
				}
			}
			modifier = {
				factor = 5
				any_war = {
					using_cb = bid_for_independence
					attacker = { character = FROM }
					defender = { reverse_realm_levy_diff = { who = ROOT value = 2500 } }
				}
			}
		}
		reverse_opinion = { who = FROM modifier = honored_alliance years = 10 }
		join_attacker_wars = FROM
		set_character_flag = intervention_in_spain
		FROM = { set_character_flag = supported_by_franks }     # Go to war
	}
	option = {
		name = EVTOPTB_CM_1406
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0
				trait = honest
			}
			modifier = {
				factor = 2
				trait = deceitful
			}			
		}
		prestige = -100
		reverse_opinion = { who = FROM modifier = opinion_betrayed years = 10 }
		if = {
			limit = { NOT = { trait = deceitful } }
			add_trait = deceitful
		}
		FROM = { hidden_tooltip = { character_event = { id = CM.1410 days = 20 } } } # Betray promise
	}
}

# Peace is concluded with established independence
character_event = {
	id = CM.1407

	hide_window = yes
	
	is_triggered_only = yes
	only_independent = yes

	trigger = {
		OR = {
			has_character_flag = supported_by_franks
			FROM = { has_character_flag = supported_by_franks }
		}
		any_independent_ruler = {
			has_character_flag = intervention_in_spain
		}
	}
	
	immediate = {
		if = {
			limit = { has_character_flag = supported_by_franks }
			clr_character_flag = supported_by_franks
			character_event = { id = CM.1408 }
		}
		if = {
			limit = { FROM = { has_character_flag = supported_by_franks } }
			FROM = { 
				clr_character_flag = supported_by_franks
				character_event = { id = CM.1408 }
			}
		}
	}
}

# Fulfill promise to Frankish king?
character_event = {
	id = CM.1408
	desc = EVTDESC_CM_1408
	picture = GFX_evt_throne_room
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1408
		ai_chance = {
			factor = 80
			modifier = {
				factor = 0.5
				trait = deceitful
			}
		}
		random_independent_ruler = {
			limit = { has_character_flag = intervention_in_spain }  # Fullfill promise
			clr_character_flag = intervention_in_spain
			ROOT = {
				religion = PREV
				set_defacto_liege = PREV
				hidden_tooltip = {
					any_courtier = {
						limit = {
							is_ruler = no
							NOR = {
								prisoner = yes
								trait = incapable
								trait = zealous
							}
						}
						religion = PREV
					}
				}
			}
			opinion = { who = ROOT modifier = honored_alliance years = 10 }
			add_alliance = { who = ROOT years = 20 }
		}
	}
	option = {
		name = EVTOPTB_CM_1408
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.5
				trait = honest
			}
			modifier = {
				factor = 0.1
				any_independent_ruler = {
					has_character_flag = intervention_in_spain
					religion = ROOT
				}
			}
		}
		prestige = -50
		any_independent_ruler = {
			limit = { has_character_flag = intervention_in_spain }
			clr_character_flag = intervention_in_spain
			opinion = { who = ROOT modifier = opinion_betrayed years = 10 }
			hidden_tooltip = { character_event = { id = CM.1409 days = 20 } }  # Betray promise
		}
		if = {
			limit = { NOT = { trait = deceitful } }
			add_trait = deceitful
		}
	}
}

# Frankish King is notified of betrayal
character_event = {
	id = CM.1409
	desc = EVTDESC_CM_1409
	picture = GFX_evt_throne_room_arabic
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1409
		trigger = {
			FROM = { NOT = { culture = ROOT } }
		}
		FROM = {
			primary_title = {
				add_claim = ROOT
			}
		}
	}
	option = {
		name = EVTOPTB_CM_1409
		trigger = {
			FROM = { culture = ROOT }
		}
		FROM = {
			primary_title = {
				add_claim = ROOT
			}
		}
	}
}

# Umayyad vassal is notified of Frankish betrayal
character_event = {
	id = CM.1410
	desc = EVTDESC_CM_1410
	picture = GFX_evt_throne_room
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_CM_1409
		trigger = {
			FROM = { NOT = { culture = ROOT } }
		}
		opinion = {
			modifier = opinion_betrayed
			who = FROM
			years = 10
		}
	}
	option = {
		name = EVTOPTB_CM_1409
		trigger = {
			FROM = { culture = ROOT }
		}
	}
}


##########################
# Coronation to Emperor  #
##########################

# Coronation of Charlemagne
narrative_event = {
	id = CM.1500
	title = EVTTITLE_CM_1500
	desc = EVTDESC_CM_1500
	picture = GFX_evt_coronation

	major = yes
	
	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Charlemagne"
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
		has_character_flag = is_charlemagne
		NOT = { has_character_flag = charlemagne_coronation }
		tier = EMPEROR
	}
	
	major_trigger = {
		capital_scope = {
			FROM = {
				capital_scope = {
					NOT = {
						distance = {
							where = PREVPREV
							distance = 1200
						}
					}
				}
			}
		}
	}
	
	immediate = {
		set_character_flag = charlemagne_coronation
	}
	
	option = {
		name = EVTOPTA_CM_510
		trigger = {
			OR = {
				has_character_flag = is_charlemagne
				AND = {
					dynasty = ROOT
					NOT = { is_rival = ROOT }
				}
				liege = { character = ROOT }
			}
		}
		if = {
			limit = {
				has_nickname = no
				has_character_flag = is_charlemagne
			}
			give_nickname = nick_the_great
		}
		if = {
			limit = {
				OR = {
					trait = uncrowned
					AND = {
						NOT = { trait = crowned }
						NOT = { trait = uncrowned }
					}
				}
				NOR = {
					has_landed_title = e_hre
					has_landed_title = e_karling
				}
				has_character_flag = is_charlemagne
			}
			add_trait = crowned
		}
		if = {
			limit = {
				OR = {
					trait = uncrowned
					trait = crowned
					AND = {
						NOT = { trait = crowned }
						NOT = { trait = uncrowned }
						NOT = { trait = crowned_by_pope }
					}
				}
				OR = {
					has_landed_title = e_hre
					has_landed_title = e_karling
				}
				has_character_flag = is_charlemagne
			}
			add_trait = crowned_by_pope
		}
	}
	option = {
		name = EVTOPTB_CM_510
		trigger = {
			NOT = { has_character_flag = is_charlemagne }
			NOT = { has_landed_title = e_byzantium }
			OR = {
				NOT = { dynasty = ROOT }
				is_rival = ROOT
			}
			religion = ROOT
		}
	}
	option = {
		name = EVTOPTC_CM_510
		trigger = {
			NOT = { has_landed_title = e_byzantium }
			NOT = { religion = ROOT }
		}
	}
	option = {
		name = EVTOPTD_CM_510
		trigger = {
			has_landed_title = e_byzantium
			NOT = { character = ROOT }
		}
	}
}

# Trigger coronation event from on_create_title
character_event = {
	id = CM.1501
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		NOT = {
			has_game_rule = {
				name = charlemagne_story
				value = off
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				has_character_flag = is_charlemagne
				NOT = { has_character_flag = charlemagne_coronation }
				primary_title = { tier = EMPEROR }
			}
			hidden_tooltip = { narrative_event = { id = CM.1500 } }        # Spread the news
		}
	}
}

# Prompt AI to work towards HRE
character_event = {
	id = CM.1502
	desc = AI_EVENT
	picture = GFX_evt_council
	
	hide_window = yes
	
	only_playable = yes
	religion = chalcedonian
	only_independent = yes
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		ai = yes
		war = no
		wealth = 0
		higher_real_tier_than = DUKE
		e_karling = { has_title_flag = carolingian_empire_fallen }
		rightful_religious_head_scope = {
			NOT = { character = ROOT }
			has_landed_title = k_papal_chalcedon
		}
		OR = {
			has_landed_title = k_germany
			k_germany = { has_holder = no }
			k_germany = { holder_scope = { NOT = { realm_size = 75 } } }
		}
		NOR = {
			trait = content
			e_hre = { has_title_flag = hre_formed }
			is_title_active = e_karling
			has_character_flag = former_carolingian_emperor
			has_character_modifier = do_not_disturb
		}
		any_independent_ruler = {
			religion_group = ROOT
			NOT = { is_heresy_of = ROOT }
			NOT = { is_parent_religion = ROOT }
			reverse_realm_levy_diff = { who = ROOT value = 5000 }
			any_realm_title = {
				tier = DUKE
				de_jure_liege_or_above = e_hre
				any_direct_de_jure_vassal_title = {
					location = {
						any_neighbor_province = {
							owner = { same_realm = ROOT }
						}
					}
				}
			}
			OR = {
				NOR = {
					is_allied_with = ROOT
					has_non_aggression_pact_with = ROOT
				}
				ROOT = {
					OR = {
						trait = ambitious
						trait = deceitful
						trait = envious
					}
					prestige = 500
				}
			}
			NOR = {
				same_realm = ROOT
				reverse_has_truce = ROOT
				is_married = ROOT
				reverse_opinion = { who = ROOT value = 0 }
				pays_tribute_to = ROOT
				ROOT = { rightful_religious_head = PREV }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 6
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 2
			trait = humble
		}
	}
	
	immediate = {
		random_independent_ruler = {
			limit = {
				religion_group = ROOT
				NOT = { is_heresy_of = ROOT }
				NOT = { is_parent_religion = ROOT }
				reverse_realm_levy_diff = { who = ROOT value = 5000 }
				any_realm_title = {
					tier = DUKE
					de_jure_liege_or_above = e_hre
					any_direct_de_jure_vassal_title = {
						location = {
							any_neighbor_province = {
								owner = { same_realm = ROOT }
							}
						}
					}
				}
				OR = {
					NOR = {
						is_allied_with = ROOT
						has_non_aggression_pact_with = ROOT
					}
					ROOT = {
						OR = {
							trait = ambitious
							trait = deceitful
							trait = envious
						}
						prestige = 500
					}
				}
				NOR = {
					same_realm = ROOT
					reverse_has_truce = ROOT
					is_married = ROOT
					reverse_opinion = { who = ROOT value = 0 }
					pays_tribute_to = ROOT
					ROOT = { rightful_religious_head = PREV }
				}
			}
			if = {
				limit = { is_allied_with = ROOT }
				ROOT = { break_alliance = PREV }
			}
			if = {
				limit = { has_non_aggression_pact_with = ROOT }
				reverse_remove_opinion = { modifier = in_non_aggression_pact who = ROOT }
				opinion = { modifier = broken_non_aggression_pact who = ROOT years = 3 }
			}
			random_realm_title = {
				limit = {
					tier = DUKE
					de_jure_liege_or_above = e_hre
					any_direct_de_jure_vassal_title = {
						location = {
							any_neighbor_province = {
								owner = { same_realm = ROOT }
							}
						}
					}
				}
				ROOT = {
					war = {
						casus_belli = carolingian_reconquest
						target = PREVPREV
						thirdparty_title = PREV
						infamy = 0
					}
				}
			}
		}
	}
}
	