namespace = Plus

#reserved: Plus.3300 to Plus.3399

#######################################
# MORE IMPERIAL EVENTS
# Written by Rylock
#######################################

# Relative wants to go to the imperial capital to serve
character_event = {
	id = Plus.3300
	
	hide_window = yes
	
	min_age = 16
	max_age = 40
	capable_only = yes
	prisoner = no
	ai = yes

	trigger = {
		independent = no
		is_ruler = no
		liege = {
			higher_real_tier_than = COUNT
			is_feudal = yes
			religion = ROOT
			has_regent = no
			war = no
			is_close_relative = ROOT
		}
		top_liege = {
			real_tier = EMPEROR
			is_feudal = yes
			religion = ROOT
			war = no
			NOR = {
				is_liege_of = ROOT
				any_courtier = {
					is_ruler = no
					count = 50
				}
			}
		}
		OR = {
			is_female = no
			AND = {
				is_married = no
				liege = {
					OR = {
						has_law = true_cognatic_succession
						has_law = enatic_cognatic_succession
						has_law = enatic_succession
					}
				}
				top_liege = {
					OR = {
						has_law = true_cognatic_succession
						has_law = enatic_cognatic_succession
						has_law = enatic_succession
					}
				}
			}
		}
		OR = {
			trait = ambitious
			trait = diligent
			trait = proud
			martial = 8
			diplomacy = 8
			stewardship = 8
			intrigue = 8
		}
		NOR = {
			is_ill = yes
			in_command_trigger = yes
			is_voter = yes
			trait = slothful
			trait = content
			trait = stressed
			trait = depressed
			is_inaccessible_trigger = yes
			trait = monk
			trait = nun
			trait = desert_mother
			trait = desert_father
			any_spouse = {
				trait = pregnant
				father_of_unborn = { character = ROOT }
			}
			any_child = {
				NOT = { trait = bastard }
				is_adult = no
			}
			any_liege = { holy_order = yes }
			any_liege = { mercenary = yes }
			has_minor_title = title_appointed_regent
			has_minor_title = title_commander
			has_character_modifier = planning_claimant_adventure
			has_character_modifier = planning_new_temple
			has_character_flag = serving_fianna
			has_character_flag = serving_gwydion
			has_character_flag = serving_varangian
			has_character_flag = served_empire
			has_character_flag = serving_empire
			has_character_flag = denied_serving_empire
		}
	}
	
	mean_time_to_happen = {
		months = 60
		modifier = {
			factor = 0.5
			top_liege = { has_imperial_government_trigger = yes }
		}
		modifier = {
			factor = 0.75
			OR = {
				martial = 12
				diplomacy = 12
				stewardship = 12
				intrigue = 12
			}
		}
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			trait = diligent
		}
		modifier = {
			factor = 0.5
			OR = {
				trait = administrator
				trait = socializer
				trait = schemer
			}
		}
		modifier = {
			factor = 0.5
			NOT = { any_heir_title = { always = yes } }
		}
		modifier = {
			factor = 1.5
			trait = humble
		}
		modifier = {
			factor = 1.5
			trait = shy
		}
		modifier = {
			factor = 1.5
			any_heir_title = { always = yes }
		}
	}
	
	immediate = {
		liege = { character_event = { id = Plus.3301 } }
	}
}

# Liege is asked to let them go to the capital
character_event = {
	id = Plus.3301
	desc = EVTDESC_Plus_3301
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_3301 # Refuse
		ai_chance = {
			factor = 25
			modifier = {
				factor = 3
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = paranoid
			}
			modifier = {
				factor = 2
				trait = slothful
			}
			modifier = {
				factor = 0.5
				trait = diligent
			}
			modifier = {
				factor = 0.5
				trait = kind
			}
			modifier = {
				factor = 0.5
				trait = trusting
			}
			modifier = {
				factor = 3
				current_heir = { character = FROM }
			}
			modifier = {
				factor = 2
				FROM = { is_female = yes }
			}
			modifier = {
				factor = 0.5
				FROM = { is_married = no }
			}
			modifier = {
				factor = 1.5
				FROM = { is_married = yes }
			}
			modifier = {
				factor = 1.5
				FROM = {
					any_child = { NOT = { trait = bastard } }
				}
			}
			modifier = {
				factor = 0.5
				top_liege = { has_imperial_government_trigger = yes }
			}
		}
		FROM = {
			prestige = -50
			set_character_flag = denied_serving_empire
			opinion = {
				modifier = opinion_very_disappointed
				years = 10
				who = ROOT
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3301 # Permit it
		ai_chance = {
			factor = 75
		}
		FROM = {
			prestige = 50
			set_character_flag = serving_empire
			opinion = {
				modifier = allowed_to_serve_empire
				years = 100
				who = ROOT
			}
		}
		top_liege = {
			FROM = { move_character = PREV }
		}
	}
}	
	
# Relative remains where they are
character_event = {
	id = Plus.3302
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		is_ruler = no
		liege = { real_tier = EMPEROR }
		OR = {
			is_voter = yes
			has_minor_title = title_appointed_regent
			has_minor_title = title_commander
		}
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			letter_event = { id = Plus.3303 }
		}
	}
}

# Inform liege
letter_event = {
	id = Plus.3303
	desc = EVTDESC_Plus_3303
	
	is_triggered_only = yes
	
	option = {
		name = SO_BE_IT
	}
}

# Relative has become a ruler
character_event = {
	id = Plus.3304
	
	hide_window = yes
	
	only_rulers = yes
	min_age = 16
	has_character_flag = serving_empire
	prisoner = no
	
	trigger = {
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
	}
}

# Relative has become incapable
character_event = {
	id = Plus.3305
	
	hide_window = yes
	
	min_age = 16
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		trait = incapable
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3306 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3306
	desc = EVTDESC_Plus_3306
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		return_home_effect = yes
	}
}

# Relative returns - increased education
character_event = {
	id = Plus.3307
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOR = {
			trait = elusive_shadow
			trait = grey_eminence
			trait = midas_touched
			trait = brilliant_strategist
			trait = mastermind_theologian
		}
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
		modifier = {
			factor = 0.5
			is_smart_trigger = yes
		}
		modifier = {
			factor = 2.0
			is_dumb_trigger = yes
		}
		modifier = {
			factor = 0.75
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = slothful
		}
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3308 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3308
	desc = EVTDESC_Plus_3308
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		FROM = {
			if = {
				limit = { trait = intricate_webweaver }
				remove_trait = intricate_webweaver
				add_trait = elusive_shadow
			}
			if = {
				limit = { trait = flamboyant_schemer }
				remove_trait = flamboyant_schemer
				add_trait = intricate_webweaver
			}
			if = {
				limit = { trait = amateurish_plotter }
				remove_trait = amateurish_plotter
				add_trait = flamboyant_schemer
			}
			if = {
				limit = { trait = charismatic_negotiator }
				remove_trait = charismatic_negotiator
				add_trait = grey_eminence
			}
			if = {
				limit = { trait = underhanded_rogue }
				remove_trait = underhanded_rogue
				add_trait = charismatic_negotiator
			}
			if = {
				limit = { trait = naive_appeaser }
				remove_trait = naive_appeaser
				add_trait = underhanded_rogue
			}
			if = {
				limit = { trait = fortune_builder }
				remove_trait = fortune_builder
				add_trait = midas_touched
			}
			if = {
				limit = { trait = thrifty_clerk }
				remove_trait = thrifty_clerk
				add_trait = fortune_builder
			}
			if = {
				limit = { trait = indulgent_wastrel }
				remove_trait = indulgent_wastrel
				add_trait = thrifty_clerk
			}
			if = {
				limit = { trait = skilled_tactician }
				remove_trait = skilled_tactician
				add_trait = brilliant_strategist
			}
			if = {
				limit = { trait = tough_soldier }
				remove_trait = tough_soldier
				add_trait = skilled_tactician
			}
			if = {
				limit = { trait = misguided_warrior }
				remove_trait = misguided_warrior
				add_trait = tough_soldier
			}
			if = {
				limit = { trait = scholarly_theologian }
				remove_trait = scholarly_theologian
				add_trait = mastermind_theologian
			}
			if = {
				limit = { trait = martial_cleric }
				remove_trait = martial_cleric
				add_trait = scholarly_theologian
			}
			if = {
				limit = { trait = detached_priest }
				remove_trait = detached_priest
				add_trait = martial_cleric
			}
		}
		return_home_effect = yes
	}
}

# Relative returns = increased stat
character_event = {
	id = Plus.3309
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
		modifier = {
			factor = 0.5
			is_smart_trigger = yes
		}
		modifier = {
			factor = 2.0
			is_dumb_trigger = yes
		}
		modifier = {
			factor = 0.75
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = slothful
		}
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3310 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3310
	desc = EVTDESC_Plus_3308
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		FROM = {
			if = {
				limit = {
					OR = {
						trait = amateurish_plotter
						trait = flamboyant_schemer
						trait = intricate_webweaver
						trait = elusive_shadow
					}
				}
				change_intrigue = 2
			}
			if = {
				limit = {
					OR = {
						trait = naive_appeaser
						trait = underhanded_rogue
						trait = charismatic_negotiator
						trait = grey_eminence
					}
				}
				change_diplomacy = 2
			}
			if = {
				limit = {
					OR = {
						trait = indulgent_wastrel
						trait = thrifty_clerk
						trait = fortune_builder
						trait = midas_touched
					}
				}
				change_stewardship = 2
			}
			if = {
				limit = {
					OR = {
						trait = misguided_warrior
						trait = tough_soldier
						trait = skilled_tactician
						trait = brilliant_strategist
					}
				}
				change_martial = 2
			}
			if = {
				limit = {
					OR = {
						trait = detached_priest
						trait = martial_cleric
						trait = scholarly_theologian
						trait = mastermind_theologian
					}
				}
				change_learning = 2
			}
		}
		return_home_effect = yes
	}
}

# Relative returns with a lifestyle trait
character_event = {
	id = Plus.3311
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { lifestyle_traits = 1 }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
		modifier = {
			factor = 0.75
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = slothful
		}
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3312 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3312
	desc = EVTDESC_Plus_3308
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		FROM = {
			if = {
				limit = {
					OR = {
						trait = amateurish_plotter
						trait = flamboyant_schemer
						trait = intricate_webweaver
						trait = elusive_shadow
					}
				}
				add_trait = schemer
			}
			if = {
				limit = {
					OR = {
						trait = naive_appeaser
						trait = underhanded_rogue
						trait = charismatic_negotiator
						trait = grey_eminence
					}
				}
				add_trait = socializer
			}
			if = {
				limit = {
					OR = {
						trait = indulgent_wastrel
						trait = thrifty_clerk
						trait = fortune_builder
						trait = midas_touched
					}
				}
				add_trait = administrator
			}
			if = {
				limit = {
					OR = {
						trait = misguided_warrior
						trait = tough_soldier
						trait = skilled_tactician
						trait = brilliant_strategist
					}
				}
				add_trait = duelist
			}
			if = {
				limit = {
					OR = {
						trait = detached_priest
						trait = martial_cleric
						trait = scholarly_theologian
						trait = mastermind_theologian
					}
				}
				add_trait = theologian
			}
		}
		return_home_effect = yes
	}
}

# Relative returns with a wife
character_event = {
	id = Plus.3313
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	only_men = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		is_married = no
		can_marry = yes
		NOT = { trait = homosexual }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3314 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3314
	desc = EVTDESC_Plus_3314
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		hidden_tooltip = {
			top_liege = {
				create_character = {
					random_traits = yes
					culture = THIS
					religion = THIS
					female = yes
					age = 17
				}
				new_character = {
					save_event_target_as = new_wife
				}
			}
		}
		FROM = { add_spouse = event_target:new_wife }
		return_home_effect = yes
	}
}

# Relative returns with a bastard child
character_event = {
	id = Plus.3315
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	only_men = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		is_married = no
		fertility = 0.25
		NOT = { trait = homosexual }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3316 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3316
	picture = GFX_evt_emissary
	
	desc = {
		text = EVTDESC_Plus_3316_male
		trigger = { FROM = { is_female = no } }
	}
	desc = {
		text = EVTDESC_Plus_3316_female
		trigger = { FROM = { is_female = yes } }
	}
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		hidden_tooltip = {
			create_character = {
				age = 0
				female = no
				trait = bastard
				culture = FROM
				religion = FROM
			}
			new_character = {
				if = {
					limit = { FROM = { is_female = no } }
					set_father = FROM
				}
				if = {
					limit = { FROM = { is_female = yes } }
					set_mother = FROM
				}
			}
			recalc_succession = yes
		}
		return_home_effect = yes
	}
}

# Relative returns depressed
character_event = {
	id = Plus.3317
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { trait = depressed }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 0.75
			trait = slothful
		}
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3318 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3318
	desc = EVTDESC_Plus_3318
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		FROM = { add_trait = depressed }
		return_home_effect = yes
	}
}

# Relative returns a drunkard
character_event = {
	id = Plus.3319
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { trait = drunkard }
		NOT = { trait = temperate }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
		modifier = {
			factor = 0.75
			trait = gluttonous
		}
		modifier = {
			factor = 0.75
			trait = gregarious
		}
		modifier = {
			factor = 1.5
			trait = shy
		}
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3320 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3320
	desc = EVTDESC_Plus_3320
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		FROM = { add_trait = drunkard }
		return_home_effect = yes
	}
}

# Relative returns more diligent
character_event = {
	id = Plus.3321
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { trait = diligent }
		NOT = { trait = slothful }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3322 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3322
	desc = EVTDESC_Plus_3322
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		FROM = { add_trait = diligent }
		return_home_effect = yes
	}
}

# Relative returns slothful
character_event = {
	id = Plus.3323
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { trait = diligent }
		NOT = { trait = slothful }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3324 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3324
	desc = EVTDESC_Plus_3324
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		FROM = { add_trait = slothful }
		return_home_effect = yes
	}
}

# Relative returns a zealot
character_event = {
	id = Plus.3325
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { trait = zealous }
		NOT = { trait = cynical }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3326 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3326
	desc = EVTDESC_Plus_3326
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		FROM = { add_trait = zealous }
		return_home_effect = yes
	}
}

# Relative returns a cynic
character_event = {
	id = Plus.3327
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = serving_empire
	
	trigger = {
		NOT = { trait = zealous }
		NOT = { trait = cynical }
		NAND = {
			liege = { real_tier = EMPEROR }
			OR = {
				is_voter = yes
				has_minor_title = title_appointed_regent
				has_minor_title = title_commander
			}
		}
		is_ruler = no
		had_character_flag = { flag = serving_empire days = 1460 }
	}
	
	mean_time_to_happen = {
		months = 48
	}
	
	immediate = {
		clr_character_flag = serving_empire
		set_character_flag = served_empire
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			character_event = { id = Plus.3328 }
		}
	}
}

# Inform liege
character_event = {
	id = Plus.3328
	desc = EVTDESC_Plus_3328
	picture = GFX_evt_emissary
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
		FROM = { add_trait = cynical }
		return_home_effect = yes
	}
}

# Ruler dies while a relative is away at the capital
character_event = {
	id = Plus.3329
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		any_close_relative = {
			has_character_flag = serving_empire
			has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire }
		}
	}
	
	immediate = {
		any_character = {
			limit = {
				has_character_flag = serving_empire
				has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire }
			}
			clr_character_flag = serving_empire
			if = {
				limit = {
					NOR = {
						prisoner = yes
						is_ruler = yes
						AND = {
							liege = { real_tier = EMPEROR }
							OR = {
								is_voter = yes
								has_minor_title = title_appointed_regent
								has_minor_title = title_commander
							}
						}
					}
				}
				move_character = ROOT
			}
		}
	}
}

# Ruler is unlanded while a relative is away at the capital
character_event = {
	id = Plus.3330
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		any_close_relative = {
			has_character_flag = serving_empire
			has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire }
		}
	}
	
	immediate = {
		any_character = {
			limit = {
				has_character_flag = serving_empire
				has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire }
			}
			clr_character_flag = serving_empire
			remove_opinion = { who = ROOT modifier = allowed_to_serve_empire }
			if = {
				limit = {
					NOR = {
						prisoner = yes
						is_ruler = yes
						AND = {
							liege = { real_tier = EMPEROR }
							OR = {
								is_voter = yes
								has_minor_title = title_appointed_regent
								has_minor_title = title_commander
							}
						}
					}
				}
				random_dynasty_member = {
					limit = { higher_tier_than = COUNT }
					reverse_banish = PREV
					break = yes
				}
				random_dynasty_member = {
					limit = { higher_tier_than = BARON }
					reverse_banish = PREV
					break = yes
				}
				random_dynasty_member = {
					limit = { is_ruler = yes }
					reverse_banish = PREV
					break = yes
				}
			}
		}
	}
}

# Relative's liege is no longer the emperor
character_event = {
	id = Plus.3331
	
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	only_men = yes
	prisoner = no
	has_character_flag = serving_empire

	trigger = {
		is_ruler = no
		is_voter = no
		liege = { NOT = { real_tier = EMPEROR } }
	}
	
	mean_time_to_happen = {
		months = 6
	}
	
	immediate = {
		#find original liege
		random_opinion_modifier_target = {
			limit = { reverse_has_opinion_modifier = { who = ROOT modifier = allowed_to_serve_empire } }
			save_event_target_as = original_liege
		}
		#move the relative to the new emperor, if they're not their original liege
		if = {
			limit = {
				top_liege = {
					real_tier = EMPEROR
					same_realm = event_target:original_liege
					NOT = { character = event_target:original_liege }
				}
			}
			top_liege = {
				ROOT = { move_character = PREV }
			}
			break = yes
		}
		#otherwise, return home immediately
		clr_character_flag = serving_empire
		event_target:original_liege = {
			ROOT = { move_character = PREV }
		}
	}
}

### IMPERIAL COUP EVENTS

# Opportunity to begin coup arises
character_event = {
	id = Plus.3340
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_intrigue
	
	desc = {
		text = EVTDESC_Plus_3340_low_home
		trigger = {
			has_character_flag = chance_low_home
		}
	}
	desc = {
		text = EVTDESC_Plus_3340_med_home
		trigger = {
			has_character_flag = chance_med_home
		}
	}
	desc = {
		text = EVTDESC_Plus_3340_high_home
		trigger = {
			has_character_flag = chance_high_home
		}
	}
	desc = {
		text = EVTDESC_Plus_3340_low_not_home
		trigger = {
			has_character_flag = chance_low_not_home
		}
	}
	desc = {
		text = EVTDESC_Plus_3340_med_not_home
		trigger = {
			has_character_flag = chance_med_not_home
		}
	}
	desc = {
		text = EVTDESC_Plus_3340_high_not_home
		trigger = {
			has_character_flag = chance_high_not_home
		}
	}
	
	min_age = 16
	capable_only = yes
	prisoner = no
	is_part_of_plot = yes
	
	trigger = {
		has_plot = plot_overthrow_empire
		num_of_plot_backers = 1
		plot_power = 0.75
		plot_target_char = {
			tier = EMPEROR
			is_liege_of = ROOT
			has_imperial_government_trigger = yes
		}
		NOT = { has_character_flag = plot_in_action }
	}
	
	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 0.75
			has_character_modifier = plot_assisted_spying
		}
		modifier = {
			factor = 0.60
			has_character_modifier = plot_assisted_spying2
		}
		modifier = {
			factor = 0.45
			has_character_modifier = plot_assisted_spying3
		}
		modifier = {
			factor = 0.30
			has_character_modifier = plot_assisted_spying4
		}
		modifier = {
			factor = 0.15
			has_character_modifier = plot_assisted_spying5
		}
		modifier = {
			factor = 1.2
			plot_target_char = { check_variable = { which = "personal_spy_network" value = 10 } }
		}
		modifier = {
			factor = 1.2
			plot_target_char = { check_variable = { which = "personal_spy_network" value = 20 } }
		}
		modifier = {
			factor = 1.2
			plot_target_char = { check_variable = { which = "personal_spy_network" value = 30 } }
		}
		modifier = {
			factor = 1.2
			plot_target_char = { check_variable = { which = "personal_spy_network" value = 40 } }
		}
		modifier = {
			factor = 1.2
			plot_target_char = { check_variable = { which = "personal_spy_network" value = 50 } }
		}
		modifier = {
			factor = 0.75
			NOT = {
				plot_target_char = {
					location = {
						PREV = {
							capital_scope = { province_id = PREVPREV }
						}
					}
				}
			}			
		}
		modifier = {
			factor = 0.5
			trait = genius
		}
		modifier = {
			factor = 0.75
			OR = {
				trait = quick
				trait = shrewd
			}
		}
		modifier = {
			factor = 0.75
			plot_target_char = { trait = trusting }
		}
		modifier = {
			factor = 1.25
			plot_target_char = { trait = paranoid }
		}
		modifier = {
			factor = 0.75
			plot_target_char = {
				OR = {
					is_ill = yes
					trait = infirm
					is_dumb_trigger = yes
				}
			}
		}
		modifier = {
			factor = 0.75
			plot_power = 1.0
		}
		modifier = {
			factor = 0.75
			plot_power = 1.25
		}
		modifier = {
			factor = 0.75
			plot_power = 1.50
		}
		modifier = {
			factor = 0.75
			plot_power = 1.75
		}
		modifier = {
			factor = 0.75
			plot_power = 2.0
		}
	}

	immediate = {
		clr_character_flag = lost_plotter
		clr_character_flag = chance_low_home
		clr_character_flag = chance_med_home
		clr_character_flag = chance_high_home
		clr_character_flag = chance_low_not_home
		clr_character_flag = chance_med_not_home
		clr_character_flag = chance_high_not_home
		clr_character_flag = killed_during_coup
		clr_character_flag = captured_during_coup
		clr_character_flag = coup_succeeds
		if = {
			limit = {
				NOT = { plot_power = 1.0 }
				plot_target_char = {
					NOT = { has_character_modifier = away_from_court }
				}
			}
			set_character_flag = chance_low_home
			break = yes
		}
		if = {
			limit = {
				plot_power = 1.0
				NOT = { plot_power = 2.0 }
				plot_target_char = {
					NOT = { has_character_modifier = away_from_court }
				}
			}
			set_character_flag = chance_med_home
			break = yes
		}
		if = {
			limit = {
				plot_power = 2.0
				plot_target_char = {
					NOT = { has_character_modifier = away_from_court }
				}
			}
			set_character_flag = chance_high_home
			break = yes
		}
		if = {
			limit = {
				NOT = { plot_power = 1.0 }
				plot_target_char = {
					has_character_modifier = away_from_court
				}
			}
			set_character_flag = chance_low_not_home
			break = yes
		}
		if = {
			limit = {
				plot_power = 1.0
				NOT = { plot_power = 2.0 }
				plot_target_char = {
					has_character_modifier = away_from_court
				}
			}
			set_character_flag = chance_med_not_home
			break = yes
		}
		if = {
			limit = {
				plot_power = 2.0
				plot_target_char = {
					has_character_modifier = away_from_court
				}
			}
			set_character_flag = chance_high_not_home
			break = yes
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3340 # Get ready
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				NOT = { plot_power = 1.0 }
			}
			modifier = {
				factor = 0.5
				NOT = { plot_power = 1.5 }
			}
			modifier = {
				factor = 0.5
				plot_target_char = { has_character_modifier = away_from_court }
			}
			modifier = {
				factor = 3
				trait = lunatic
			}
			modifier = {
				factor = 3
				trait = possessed
			}
			modifier = {
				factor = 1.5
				trait = brave
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
		}
		set_character_flag = plot_in_action
		custom_tooltip = {
			text = TELL_PLOTTERS_GET_READY
			hidden_tooltip = {
				#notify backers
				any_plot_backer = { character_event = { id = Plus.3341 } }
				#double-check
				character_event = { id = Plus.3344 days = 7 }
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3340 # We should wait
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2.0
				NOT = { plot_power = 2.0 }
				trait = craven
			}
			modifier = {
				factor = 1.5
				NOT = { plot_power = 1.5 }
				trait = patient
			}
		}
	}
}

# Co-conspirators informed; remain or drop out?
character_event = {
	id = Plus.3341
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_intrigue
	
	desc = {
		text = EVTDESC_Plus_3341_low_home
		trigger = {
			FROM = { has_character_flag = chance_low_home }
		}
	}
	desc = {
		text = EVTDESC_Plus_3341_med_home
		trigger = {
			FROM = { has_character_flag = chance_med_home }
		}
	}
	desc = {
		text = EVTDESC_Plus_3341_high_home
		trigger = {
			FROM = { has_character_flag = chance_high_home }
		}
	}
	desc = {
		text = EVTDESC_Plus_3341_low_not_home
		trigger = {
			FROM = { has_character_flag = chance_low_not_home }
		}
	}
	desc = {
		text = EVTDESC_Plus_3341_med_not_home
		trigger = {
			FROM = { has_character_flag = chance_med_not_home }
		}
	}
	desc = {
		text = EVTDESC_Plus_3341_high_not_home
		trigger = {
			FROM = { has_character_flag = chance_high_not_home }
		}
	}
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		FROM = {
			has_plot = plot_overthrow_empire
			plot_target_char = {
				tier = EMPEROR
				is_liege_of = ROOT
				has_imperial_government_trigger = yes
			}
		}
	}

	immediate = {
		clr_character_flag = informed_liege
	}
	
	option = {
		name = EVTOPTA_Plus_3341 # I'm still in
		ai_chance = {
			factor = 70
			modifier = {
				factor = 0
				FROM = {
					plot_target_char = {
						OR = {
							reverse_opinion = { who = ROOT value = 40 }
							current_heir = { character = ROOT }
							AND = {
								is_married = ROOT
								ROOT = { is_ruler = no }
							}
						}
					}
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3341 # No, this is too risky
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.1
				is_ruler = yes
				is_voter = no
			}
			modifier = {
				factor = 0.1
				OR = {
					trait = lunatic
					trait = possessed
				}
			}
			modifier = {
				factor = 0.5
				trait = brave
			}
			modifier = {
				factor = 2
				trait = craven
			}
		}
		tooltip = { leave_plot = FROM }
		hidden_tooltip = {
			FROM = { character_event = { id = Plus.3342 days = 1 random = 5 } }
		}
	}
	option = {
		name = EVTOPTC_Plus_3341 # Inform the liege
		trigger = { intrigue = 10 }
		ai_chance = {
			factor = 5
			modifier = {
				factor = 2
				trait = deceitful
			}
			modifier = {
				factor = 2
				intrigue = 14
			}
			modifier = {
				factor = 2
				intrigue = 16
			}
			modifier = {
				factor = 2
				intrigue = 18
			}
			modifier = {
				factor = 2
				intrigue = 20
			}
			modifier = {
				factor = 0.01
				FROM = {
					plot_target_char = {
						NOT = { reverse_opinion = { who = ROOT value = 25 } }
					}
				}
			}
			modifier = {
				factor = 0.01
				OR = {
					trait = honest
					trait = craven
					FROM = { reverse_opinion = { who = ROOT value = 0 } }
					is_close_relative = ROOT
				}
			}
			modifier = {
				factor = 0.01
				NOR = {
					trait = ambitious
					trait = deceitful
					FROM = { plot_target_char = { is_close_relative = ROOT } }
				}
			}
		}
		tooltip_info = intrigue
		tooltip = { leave_plot = FROM }
		FROM = {
			plot_target_char = {
				letter_event = { id = Plus.3343 days = 5 tooltip = INFORM_LIEGE_PLOT }
			}
		}
		random_list = {
			50 = {
				custom_tooltip = {
					text = PLOT_LEADER_FINDS_OUT
					hidden_tooltip = {
						set_character_flag = informed_liege
						FROM = { character_event = { id = Plus.3342 days = 1 random = 5 } }
					}
				}
			}
			50 = {
				custom_tooltip = {
					text = PLOT_LEADER_DOESNT_FIND_OUT
				}
			}
		}
		if = {
			limit = {
				NOT = { trait = honest }
				NOT = { trait = deceitful }
			}
			random = {
				chance = 50
				add_trait = deceitful
				
			}
		}
		if = {
			limit = { trait = honest }
			remove_trait = honest
			
		}
	}
}

# Coup leader informed that co-conspirator has dropped out
character_event = {
	id = Plus.3342
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_intrigue
	
	desc = {
		text = EVTDESC_Plus_3342
		trigger = {
			FROM = { NOT = { has_character_flag = informed_liege } }
		}
	}
	desc = {
		text = EVTDESC_Plus_3342_informed
		trigger = {
			FROM = { has_character_flag = informed_liege }
		}
	}

	is_triggered_only = yes
	capable_only = yes
	is_part_of_plot = yes
	prisoner = no
	
	trigger = {
		has_plot = plot_overthrow_empire
		plot_target_char = {
			tier = EMPEROR
			is_liege_of = ROOT
			has_imperial_government_trigger = yes
		}
	}
	
	option = {
		name = CURSES
		set_character_flag = lost_plotter
		FROM = { leave_plot = ROOT }
		if = {
			limit = { FROM = { has_character_flag = informed_liege } }
			opinion = { who = FROM modifier = grievously_offended years = 5 }
		}
		hidden_tooltip = {
			if = {
				limit = { FROM = { NOT = { has_character_flag = informed_liege } } }
				opinion = { who = FROM modifier = grievously_offended years = 5 }
			}
			reverse_opinion = { who = FROM modifier = opinion_left_plot years = 5 }
		}
	}
}

# Ruler given advance notice of coup plan
letter_event = {
	id = Plus.3343
	desc = EVTDESC_Plus_3343
	border = GFX_event_letter_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3343
		set_character_flag = on_guard_coup
		opinion = { who = FROM modifier = opinion_very_grateful years = 5 }
	}
}

# Coup is ready to begin: proceed?
character_event = {
	id = Plus.3344
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_intrigue
	
	desc = {
		text = EVTDESC_Plus_3344_low
		trigger = {
			NOT = { plot_power = 1.0 }
			NOT = { has_character_flag = lost_plotter }
		}
	}
	desc = {
		text = EVTDESC_Plus_3344_med
		trigger = {
			plot_power = 1.0
			NOT = { plot_power = 2.0 }
			NOT = { has_character_flag = lost_plotter }
		}
	}
	desc = {
		text = EVTDESC_Plus_3344_high
		trigger = {
			plot_power = 2.0
			NOT = { has_character_flag = lost_plotter }
		}
	}
	desc = {
		text = EVTDESC_Plus_3344_low_lost
		trigger = {
			NOT = { plot_power = 1.0 }
			has_character_flag = lost_plotter
		}
	}
	desc = {
		text = EVTDESC_Plus_3344_med_lost
		trigger = {
			plot_power = 1.0
			NOT = { plot_power = 2.0 }
			has_character_flag = lost_plotter
		}
	}
	desc = {
		text = EVTDESC_Plus_3344_high_lost
		trigger = {
			plot_power = 2.0
			has_character_flag = lost_plotter
		}
	}

	is_triggered_only = yes
	capable_only = yes
	is_part_of_plot = yes
	prisoner = no
	
	trigger = {
		has_plot = plot_overthrow_empire
		plot_target_char = {
			tier = EMPEROR
			is_liege_of = ROOT
			has_imperial_government_trigger = yes
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3344 # Begin!
		ai_chance = {
			factor = 70
			modifier = {
				factor = 0
				NOT = { plot_power = 1.0 }
			}
			modifier = {
				factor = 2
				plot_power = 1.5
			}
		}
		hidden_tooltip = {
			diplomatic_immunity = yes
			any_plot_backer = { diplomatic_immunity = yes }
			plot_target_char = {
				clr_character_flag = captured_during_coup
				clr_character_flag = killed_during_coup
				clr_character_flag = coup_not_in_capital
				save_event_target_as = coup_target
				capital_scope = { save_event_target_as = coup_target_capital }
				if = {
					limit = { NOT = { has_character_modifier = away_from_court } }
					character_event = { id = Plus.3348 } # Notification of coup start
				}
				any_courtier = {
					limit = {
						prisoner = no
						OR = {
							in_command = no
							event_target:coup_target = { war = no }
						}
						NOT = {
							any_backed_character = {
								character = ROOT
							}
						}
					}
					character_event = { id = Plus.3348 } # Notification of coup start
				}
			}
		}
		random_list = {
			50 = {
				modifier = {
					factor = 0.5
					plot_target_char = { has_character_flag = on_guard_coup }
				}
				modifier = {
					factor = 1.5
					trait = genius
				}
				modifier = {
					factor = 1.2
					OR = {
						trait = quick
						trait = shrewd
					}
				}
				modifier = {
					factor = 0.5
					trait = imbecile
				}
				modifier = {
					factor = 0.8
					OR = {
						trait = dull
						trait = slow
					}
				}
				modifier = {
					factor = 1.1
					OR = {
						has_job_title = job_marshal
						any_plot_backer = { has_job_title = job_marshal }
					}
				}
				modifier = {
					factor = 1.2
					OR = {
						has_job_title = job_spymaster
						any_plot_backer = { has_job_title = job_spymaster }
					}
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 0.7 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 0.8 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 0.9 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 1.0 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 1.1 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 1.2 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 1.3 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 1.4 }
				}
				modifier = {
					factor = 0.9
					NOT = { plot_power = 1.5 }
				}
				modifier = {
					factor = 1.1
					plot_power = 1.6
				}
				modifier = {
					factor = 1.1
					plot_power = 1.7
				}
				modifier = {
					factor = 1.1
					plot_power = 1.8
				}
				modifier = {
					factor = 1.1
					plot_power = 1.9
				}
				modifier = {
					factor = 1.1
					plot_power = 2.0
				}
				modifier = {
					factor = 1.1
					plot_power = 2.1
				}
				modifier = {
					factor = 1.1
					plot_power = 2.2
				}
				modifier = {
					factor = 1.1
					plot_power = 2.3
				}
				modifier = {
					factor = 1.1
					plot_power = 2.4
				}
				modifier = {
					factor = 1.1
					plot_power = 2.5
				}
				custom_tooltip = {
					text = COUP_SUCCESSFUL
					hidden_tooltip = {
						set_character_flag = coup_succeeds
						event_target:coup_target = {
							primary_title = { save_event_target_as = usurped_title }
							clr_character_flag = on_guard_coup
							if = {
								limit = { NOT = { has_character_modifier = away_from_court } }
								random = {
									chance = 50
									# Ruler is injured/maimed/killed/captured in successful coup (days = 2)
									character_event = { id = Plus.3359 days = 2 }
								}
							}
							if = {
								limit = { has_character_modifier = away_from_court }
								# Ruler is not in the capital during successful coup (days = 2)
								character_event = { id = Plus.3358 days = 2 }
							}
						}
						random = {
							chance = 25
							# Coup leader is injured/maimed in successful coup (days = 2)
							character_event = { id = Plus.3357 days = 2 }
						}
						# Notification of coup success
						narrative_event = { id = Plus.3361 days = 3 }
						character_event = { id = Plus.3362 days = 3 }
					}
				}
			}
			50 = {
				modifier = {
					factor = 1.5
					plot_target_char = { demesne_garrison_size = 500 }
				}
				modifier = {
					factor = 1.5
					plot_target_char = { trait = genius }
				}
				modifier = {
					factor = 1.2
					plot_target_char = {
						OR = {
							trait = quick
							trait = shrewd
							trait = paranoid
						}
					}
				}
				modifier = {
					factor = 0.5
					plot_target_char = {
						OR = {
							trait = imbecile
							trait = incapable
							is_adult = no
						}
					}
				}
				modifier = {
					factor = 0.8
					plot_target_char = {
						OR = {
							trait = dull
							trait = slow
							trait = trusting
						}
					}
				}
				modifier = {
					factor = 0.8
					plot_target_char = {
						has_character_modifier = away_from_court
					}
				}
				custom_tooltip = {
					text = COUP_FAILS
					hidden_tooltip = {
						event_target:coup_target = {
							clr_character_flag = on_guard_coup
							if = {
								limit = { NOT = { has_character_modifier = away_from_court } }
								random = {
									chance = 25
									# Ruler is injured/maimed/killed in failed coup (days = 2)
									character_event = { id = Plus.3355 days = 2 }
								}
							}
							if = {
								limit = { has_character_modifier = away_from_court }
								# Ruler is not in the capital during failed coup (days = 2)
								character_event = { id = Plus.3356 days = 2 }
							}
						}
						random = {
							chance = 50
							# Coup leader is injured/maimed/killed/captured in failed coup (days = 2)
							character_event = { id = Plus.3354 days = 2 }
						}
						# Notification of coup failure
						narrative_event = { id = Plus.3360 days = 3 }
					}
				}
			}
		}
		hidden_tooltip = {
			any_plot_backer = {
				limit = {
					OR = {
						AND = {
							host = { character = event_target:coup_target }
							OR = {
								in_command = no
								event_target:coup_target = { war = no }
							}
						}
						is_voter = yes
					}
				}
				character_event = { id = Plus.3346 days = 1 } # Assigning events during coup
			}
			event_target:coup_target = {
				any_courtier = {
					limit = {
						prisoner = no
						OR = {
							in_command = no
							event_target:coup_target = { war = no }
						}
						NOT = {
							any_backed_character = {
								character = ROOT
							}
						}
					}
					character_event = { id = Plus.3347 days = 1 } # Assigning events during coup
				}
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3344 # Wait for a better time
		ai_chance = {
			factor = 30
		}
		clr_character_flag = plot_in_action
		hidden_tooltip = {
			plot_target_char = { clr_character_flag = on_guard_coup }
			any_plot_backer = {
				limit = { ai = no }
				letter_event = { id = Plus.3345 }
			}
		}
	}
	option = {
		name = EVTOPTC_Plus_3344 # Scrap all plans
		ai_chance = {
			factor = 0
		}
		hidden_tooltip = { plot_target_char = { clr_character_flag = on_guard_coup } }
		set_character_flag = abort_plot
		cancel_plot = plot_overthrow_empire
	}
}

# Plot leader has called off the coup
letter_event = {
	id = Plus.3345
	desc = EVTDESC_Plus_3345
	border = GFX_event_letter_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = I_SEE
	}
}

# Bounce event (for assigning results to co-conspirators)
character_event = {
	id = Plus.3346
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			20 = {
				modifier = {
					factor = 0.5
					FROM = { has_character_flag = coup_succeeds }
				}
				# Co-conspirator injured/maimed/killed during coup
				character_event = { id = Plus.3349 }
			}
			20 = {
				modifier = {
					factor = 0
					FROM = { has_character_flag = coup_succeeds }
				}
				modifier = {
					factor = 0
					event_target:coup_target = {
						has_character_modifier = away_from_court
					}
				}
				# Co-conspirator comes to ruler's attention in failed coup
				character_event = { id = Plus.3353 }
			}
			3 = {
				modifier = {
					factor = 0
					OR = {
						is_adult = no
						is_female = yes
						is_inaccessible_trigger = yes
						trait = incapable
						trait = infirm
						NOT = { martial = 10 }
					}
				}
				# Co-conspirator saves the coup leader's life
				character_event = { id = Plus.3351 }
			}
			40 = {
				# Nothing
			}
		}
	}
}

# Bounce event (for assigning results to courtiers)
character_event = {
	id = Plus.3347
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_list = {
			20 = {
				modifier = {
					factor = 0.5
					FROM = { has_character_flag = coup_succeeds }
				}
				# Courtier injured/maimed/killed during coup
				character_event = { id = Plus.3350 }
			}
			3 = {
				modifier = {
					factor = 0
					event_target:coup_target = {
						has_character_modifier = away_from_court
					}
				}
				modifier = {
					factor = 0
					OR = {
						is_adult = no
						is_female = yes
						is_inaccessible_trigger = yes
						trait = incapable
						trait = infirm
						NOT = { martial = 10 }
					}
				}
				# Courtier saves the ruler's life
				character_event = { id = Plus.3352 }
			}
			40 = {
				# Nothing
			}
		}
	}
}

# Notification to ruler & courtiers that coup has begun
character_event = {
	id = Plus.3348
	desc = EVTDESC_Plus_3348
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	hide_from = yes
	
	option = {
		name = EVTOPTA_Plus_3348
	}
}

# Co-conspirator injured/maimed/killed during coup
character_event = {
	id = Plus.3349
	desc = EVTDESC_Plus_3349
	picture = GFX_evt_melee
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3349
		random_list = {
			20 = {
				modifier = {
					factor = 0
					OR = {
						trait = wounded
						is_maimed_trigger = yes
					}
				}
				add_trait = wounded
			}
			10 = {
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				add_maimed_trait_effect = yes
			}
			5 = {
				death = { death_reason = death_battle }
			}
		}
	}
}

# Courtier injured/maimed/killed during coup
character_event = {
	id = Plus.3350
	desc = EVTDESC_Plus_3350
	picture = GFX_evt_melee
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	hide_from = yes
	
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3350
		random_list = {
			20 = {
				modifier = {
					factor = 0
					OR = {
						trait = wounded
						is_maimed_trigger = yes
					}
				}
				add_trait = wounded
			}
			10 = {
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				add_maimed_trait_effect = yes
			}
			5 = {
				death = { death_reason = death_battle }
			}
		}
	}
}

# Co-conspirator saves the coup leader's life
character_event = {
	id = Plus.3351
	desc = EVTDESC_Plus_3351
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	major = yes
	
	major_trigger = {
		OR = {
			character = FROM
			character = FROMFROM
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3351
		trigger = { character = FROM }
		add_friend = FROMFROM
	}
	option = {
		name = EVTOPTB_Plus_3351
		trigger = { character = FROMFROM }
		tooltip = { add_friend = FROM }
	}
}

# Courtier saves the ruler's life
character_event = {
	id = Plus.3352
	desc = EVTDESC_Plus_3352
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	major = yes
	
	major_trigger = {
		OR = {
			character = FROM
			character = event_target:coup_target
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3351
		trigger = { character = FROM }
		add_friend = event_target:coup_target
	}
	option = {
		name = EVTOPTB_Plus_3351
		trigger = { character = event_target:coup_target }
		tooltip = { add_friend = FROM }
	}
}

# Co-conspirator comes to ruler's attention in failed coup
character_event = {
	id = Plus.3353
	desc = EVTDESC_Plus_3353
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	major = yes
	
	major_trigger = {
		OR = {
			character = FROM
			character = event_target:coup_target
		}
	}
	
	option = {
		name = CURSES
		trigger = { character = FROM }
		tooltip = {
			reverse_opinion = { who = event_target:coup_target modifier = opinion_traitor years = 5 }
		}
	}
	option = {
		name = EVTOPTB_Plus_3353
		trigger = { character = event_target:coup_target }
		opinion = { who = FROM modifier = opinion_traitor years = 5 }
	}
}

# Coup leader is injured/maimed/killed/captured in failed coup
character_event = {
	id = Plus.3354
	desc = EVTDESC_Plus_3354
	picture = GFX_evt_melee
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3354
		random_list = {
			10 = {
				custom_tooltip = {
					text = CAPTURED_DURING_COUP
					hidden_tooltip = { set_character_flag = captured_during_coup }
				}
			}
			20 = {
				modifier = {
					factor = 0
					OR = {
						trait = wounded
						is_maimed_trigger = yes
					}
				}
				custom_tooltip = {
					text = WOUNDED_MAYBE_CAPTURED
					hidden_tooltip = {
						add_trait = wounded
						random = {
							chance = 25
							set_character_flag = captured_during_coup
						}
					}
				}
			}
			10 = {
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				custom_tooltip = {
					text = MAIMED_MAYBE_CAPTURED
					hidden_tooltip = {
						add_maimed_trait_effect = yes
						random = {
							chance = 50
							set_character_flag = captured_during_coup
						}
					}
				}
			}
			5 = {
				set_character_flag = killed_during_coup
				custom_tooltip = { text = DIES_DURING_COUP }
			}
		}
	}
}

# Ruler is injured/maimed/killed in failed coup
character_event = {
	id = Plus.3355
	desc = EVTDESC_Plus_3355
	picture = GFX_evt_melee
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	hide_from = yes
	
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3355
		random_list = {
			40 = {
				modifier = {
					factor = 0
					OR = {
						trait = wounded
						is_maimed_trigger = yes
					}
				}
				add_trait = wounded
			}
			10 = {
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				add_maimed_trait_effect = yes
			}
			5 = {
				set_character_flag = killed_during_coup
				custom_tooltip = { text = DIES_DURING_COUP }
			}
		}
	}
}

# Ruler is not in the capital during failed coup
character_event = {
	id = Plus.3356
	desc = EVTDESC_Plus_3356
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	hide_from = yes
	
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3356
		set_character_flag = coup_not_in_capital
	}
}

# Coup leader is injured/maimed in successful coup
character_event = {
	id = Plus.3357
	desc = EVTDESC_Plus_3357
	picture = GFX_evt_melee
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		can_be_maimed_trigger = yes
	}
	
	option = {
		name = CURSES
		random_list = {
			20 = {
				modifier = {
					factor = 0
					OR = {
						trait = wounded
						is_maimed_trigger = yes
					}
				}
				add_trait = wounded
			}
			5 = {
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				add_maimed_trait_effect = yes
			}
		}
	}
}

# Ruler is not in the capital during successful coup
character_event = {
	id = Plus.3358
	desc = EVTDESC_Plus_3358
	picture = GFX_evt_siege
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	hide_from = yes
	
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3358
		set_character_flag = coup_not_in_capital
	}
}

# Ruler is injured/maimed/killed/captured in successful coup
character_event = {
	id = Plus.3359
	desc = EVTDESC_Plus_3359
	picture = GFX_evt_melee
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	hide_from = yes
	
	capable_only = yes
	prisoner = no
	
	option = {
		name = EVTOPTA_Plus_3359
		random_list = {
			10 = {
				custom_tooltip = {
					text = CAPTURED_DURING_COUP
					hidden_tooltip = { set_character_flag = captured_during_coup }
				}
			}
			20 = {
				modifier = {
					factor = 0
					OR = {
						trait = wounded
						is_maimed_trigger = yes
					}
				}
				custom_tooltip = {
					text = WOUNDED_MAYBE_CAPTURED
					hidden_tooltip = {
						add_trait = wounded
						random = {
							chance = 25
							set_character_flag = captured_during_coup
						}
					}
				}
			}
			10 = {
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				custom_tooltip = {
					text = MAIMED_MAYBE_CAPTURED
					hidden_tooltip = {
						add_maimed_trait_effect = yes
						random = {
							chance = 50
							set_character_flag = captured_during_coup
						}
					}
				}
			}
			5 = {
				set_character_flag = killed_during_coup
				custom_tooltip = { text = DIES_DURING_COUP }
			}
		}
	}
}

# News of failed coup
narrative_event = {
	id = Plus.3360
	title = EVTNAME_Plus_3360
	picture = GFX_evt_siege
	border = GFX_event_narrative_frame_intrigue
	
	desc = {
		text = EVTDESC_Plus_3360_1
		trigger = {
			event_target:coup_target = { has_character_flag = coup_not_in_capital }
			ROOT = { NOT = { has_character_flag = captured_during_coup } }
			ROOT = { NOT = { has_character_flag = killed_during_coup } }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_2
		trigger = {
			event_target:coup_target = { has_character_flag = coup_not_in_capital }
			ROOT = { has_character_flag = captured_during_coup }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_3
		trigger = {
			event_target:coup_target = { has_character_flag = coup_not_in_capital }
			ROOT = { has_character_flag = killed_during_coup }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_4
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { NOT = { has_character_flag = captured_during_coup } }
			event_target:coup_target = { NOT = { has_character_flag = killed_during_coup } }
			ROOT = { NOT = { has_character_flag = captured_during_coup } }
			ROOT = { NOT = { has_character_flag = killed_during_coup } }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_5
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { has_character_flag = killed_during_coup }
			ROOT = { NOT = { has_character_flag = captured_during_coup } }
			ROOT = { NOT = { has_character_flag = killed_during_coup } }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_6
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { NOT = { has_character_flag = captured_during_coup } }
			event_target:coup_target = { NOT = { has_character_flag = killed_during_coup } }
			ROOT = { has_character_flag = captured_during_coup }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_7
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { has_character_flag = killed_during_coup }
			ROOT = { has_character_flag = captured_during_coup }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_8
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { NOT = { has_character_flag = captured_during_coup } }
			event_target:coup_target = { NOT = { has_character_flag = killed_during_coup } }
			ROOT = { has_character_flag = killed_during_coup }
		}
	}
	desc = {
		text = EVTDESC_Plus_3360_9
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { has_character_flag = killed_during_coup }
			ROOT = { has_character_flag = killed_during_coup }
		}
	}
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	major = yes
	
	major_trigger = {
		OR = {
			character = ROOT
			character = event_target:coup_target
			same_realm = event_target:coup_target
		}
	}
	
	option = {
		name = CURSES # Coup Leader
		trigger = { character = ROOT }
		prestige = -200
		if = {
			limit = { has_character_flag = captured_during_coup }
			imprison = event_target:coup_target
		}
		hidden_tooltip = {
			diplomatic_immunity = no
			any_plot_backer = { diplomatic_immunity = no }
			if = {
				limit = { event_target:coup_target = { has_character_flag = killed_during_coup } }
				event_target:coup_target = {
					save_event_target_as = target_victim
					current_heir = {
						if = {
							limit = { NOT = { character = ROOT } }
							opinion = { who = ROOT modifier = opinion_traitor years = 10 }
						}
					}
					death = {
						death_reason = death_murder
						killer = ROOT
					}
				}
				character_event = { id = 10 } # Consequences of discovery
				clear_event_target = target_victim
			}
		}
		if = {
			limit = { has_character_flag = killed_during_coup }
			death = { death_reason = death_battle }
		}
		set_character_flag = abort_plot
	}
	option = {
		name = EVTOPTB_Plus_3360 # Ruler
		trigger = { character = event_target:coup_target }
		prestige = 200
		imperial_decadence_minus_1_effect = yes
		opinion = { who = ROOT modifier = opinion_traitor years = 10 }
		if = {
			limit = { has_character_flag = killed_during_coup }
			tooltip = { death = { death_reason = death_battle } }
		}
	}
	option = {
		name = I_SEE # Everyone else
		trigger = {
			NOR = {
				character = ROOT
				character = event_target:coup_target
			}
		}
	}
}

# News of successful coup
narrative_event = {
	id = Plus.3361
	title = EVTNAME_Plus_3361
	picture = GFX_evt_siege
	border = GFX_event_narrative_frame_intrigue
	
	desc = {
		text = EVTDESC_Plus_3361_1
		trigger = {
			event_target:coup_target = { has_character_flag = coup_not_in_capital }
		}
	}
	desc = {
		text = EVTDESC_Plus_3361_2
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { NOT = { has_character_flag = captured_during_coup } }
			event_target:coup_target = { NOT = { has_character_flag = killed_during_coup } }
		}
	}
	desc = {
		text = EVTDESC_Plus_3361_3
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { has_character_flag = captured_during_coup }
		}
	}
	desc = {
		text = EVTDESC_Plus_3361_4
		trigger = {
			event_target:coup_target = { NOT = { has_character_flag = coup_not_in_capital } }
			event_target:coup_target = { has_character_flag = killed_during_coup }
		}
	}
	
	is_triggered_only = yes
	capable_only = yes
	prisoner = no
	major = yes
	
	major_trigger = {
		OR = {
			character = ROOT
			character = event_target:coup_target
			same_realm = event_target:coup_target
		}
	}
	
	option = {
		name = EXCELLENT # Coup Leader
		trigger = { character = ROOT }
		prestige = 200
		event_target:usurped_title = {
			tooltip = {
				usurp_title_plus_barony_if_unlanded = { target = ROOT type = claim }
			}
		}
		hidden_tooltip = {
			diplomatic_immunity = no
			any_plot_backer = { diplomatic_immunity = no }
			if = {
				limit = { event_target:coup_target = { has_character_flag = captured_during_coup } }
				event_target:coup_target = {
					imprison = ROOT
				}
			}
		}
		set_character_flag = plot_success
	}
	option = {
		name = EVTOPTB_Plus_3360 # Ruler
		trigger = { character = event_target:coup_target }
		event_target:usurped_title = {
			tooltip = {
				usurp_title_plus_barony_if_unlanded = { target = ROOT type = claim }
			}
		}
		prestige = -500
		opinion = { who = ROOT modifier = opinion_traitor years = 10 }
		if = {
			limit = { has_character_flag = captured_during_coup }
			tooltip = { imprison = ROOT }
		}
		if = {
			limit = { has_character_flag = killed_during_coup }
			tooltip = { death = { death_reason = death_battle } }
		}
	}
	option = {
		name = I_SEE # Everyone else
		trigger = {
			NOR = {
				character = ROOT
				character = event_target:coup_target
			}
		}
	}
}

# Usurpation event
character_event = {
	id = Plus.3362
	
	is_triggered_only = yes
	hide_window = yes
	
	immediate = {		
		event_target:usurped_title = {
			set_global_flag = pf_teardown_lock
			
			# the claimant has the wrong government type, take care of that first.
			if = {
				limit = {
					higher_tier_than = ROOT
					holder_scope = {
						OR = {
							is_feudal = yes
							is_tribal = yes
						}
					}
					ROOT = {
						is_ruler = yes
						OR = {
							is_theocracy = yes
							is_republic = yes
						}
					}
				}
				ROOT = { abdicate = yes }
			}
			
			event_target:coup_target = {
				# check to see if title will be destroyed
				any_demesne_title = {
					limit = { can_destroy_title_trigger = yes }
					custom_tooltip = { text = TITLE_ENDANGERED_NO_NAME }
					set_title_flag = destroy_title
				}
				# reduce CA & TO
				any_demesne_title = {
					title_reduce_CA_effect = yes
					title_reduce_TO_effect = yes
				}
				# usurp primary title
				primary_title = {
					usurp_title_plus_barony_if_unlanded = { target = ROOT type = claim }
					hidden_tooltip = { make_primary_title = yes }
				}
				# ruler stays within the realm
				set_defacto_liege = ROOT
			}

			# destroy primary title if it has been reduced too much
			hidden_tooltip = {
				if = {
					limit = { has_title_flag = destroy_title }
					ROOT = { character_event = { id = Plus.1620 days = 4 } }
				}
			}

			# check to see if the ruler needs to give the claimant a capital
			hidden_tooltip = {
				if = {
					limit = {
						event_target:coup_target = {
							ROOT = { 
								primary_title = { 
									NOT = { has_law = succ_feudal_elective } 
									event_target:coup_target = {
										capital_scope = {
											de_jure_liege_or_above = PREVPREV
										}
									}
								} 
							}
							OR = {
								num_of_count_titles = 2
								primary_title = { higher_tier_than = COUNT }
							}
						}
					}
					event_target:coup_target = {
						capital_scope = {
							county = {
								usurp_title_plus_barony_if_unlanded = { target = ROOT type = claim }
							}
						}
					}			
				}	
			}

			# set proper liege statuses
			hidden_tooltip = {
				event_target:coup_target = {
					set_defacto_liege = ROOT 
					any_vassal = {
						limit = { NOT = { primary_title = { de_jure_liege_or_above = PREVPREV } } }
						set_defacto_liege = ROOT 
					}
				}
			}
			
			clr_global_flag = pf_teardown_lock
		}		

		# Actual death of the former ruler must follow the usurpation
		if = {
			limit = { event_target:coup_target = { has_character_flag = killed_during_coup } }
			event_target:coup_target = {
				save_event_target_as = target_victim
				current_heir = {
					if = {
						limit = { NOT = { character = ROOT } }
						opinion = { who = ROOT modifier = opinion_traitor years = 10 }
					}
				}
				death = {
					death_reason = death_murder
					killer = ROOT
				}
			}
			character_event = { id = 10 } # Consequences of discovery
			clear_event_target = target_victim
		}
	}
}

### IMPERIAL COURT EVENTS

# Courtier gets a court trait
character_event = {
	id = Plus.3365
	
	hide_window = yes
	
	min_age = 20
	capable_only = yes
	prisoner = no
	ai = yes
	
	trigger = {
		is_ruler = no
		liege = {
			real_tier = EMPEROR
			is_feudal = yes
			religion = ROOT
		}
		OR = {
			is_female = no
			liege = {
				primary_title = {
					has_law = female_council_law_4
				}
			}
			AND = {
				can_be_chancellor_trigger = yes
				OR = {
					trait = underhanded_rogue
					trait = charismatic_negotiator
					trait = grey_eminence
				}
			}
			AND = {
				can_be_marshal_trigger = yes
				OR = {
					trait = tough_soldier
					trait = skilled_tactician
					trait = brilliant_strategist
				}
			}
			AND = {
				can_be_treasurer_trigger = yes
				OR = {
					trait = thrifty_clerk
					trait = fortune_builder
					trait = midas_touched
				}
			}
			AND = {
				can_be_spymaster_trigger = yes
				OR = {
					trait = flamboyant_schemer
					trait = intricate_webweaver
					trait = elusive_shadow
					
				}
			}
		}
		NOR = {
			is_dumb_trigger = yes
			trait = amateurish_plotter
			trait = naive_appeaser
			trait = indulgent_wastrel
			trait = misguided_warrior
			trait = detached_priest
			trait = imperial_bureaucrat
			trait = imperial_courtier
			trait = imperial_guard
		}
	}
	
	mean_time_to_happen = {
		months = 40
		modifier = {
			factor = 0.25
			has_character_flag = serving_empire
		}
		modifier = {
			factor = 0.5
			OR = {
				is_councillor = yes
				has_minor_title = title_commander
				liege = { has_imperial_government_trigger = yes }
			}
		}
		modifier = {
			factor = 0.5
			trait = genius
		}
		modifier = {
			factor = 0.75
			OR = {
				trait = quick
				trait = shrewd
			}
		}
		modifier = {
			factor = 0.75
			trait = diligent
		}
		modifier = {
			factor = 1.5
			trait = slothful
		}
		modifier = {
			factor = 1.5
			OR = {
				trait = flamboyant_schemer
				trait = underhanded_rogue
				trait = thrifty_clerk
				trait = tough_soldier
				trait = martial_cleric
			}
		}
		modifier = {
			factor = 0.5
			OR = {
				trait = elusive_shadow
				trait = grey_eminence
				trait = midas_touched
				trait = brilliant_strategist
				trait = mastermind_theologian
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				can_be_marshal_trigger = yes
				OR = {
					trait = tough_soldier
					trait = skilled_tactician
					trait = brilliant_strategist
				}
			}
			add_trait = imperial_guard
			set_character_flag = is_imperial_guard
			break = yes
		}
		if = {
			limit = {
				OR = {
					trait = thrifty_clerk
					trait = fortune_builder
					trait = midas_touched
					trait = martial_cleric
					trait = scholarly_theologian
					trait = mastermind_theologian
				}
			}
			add_trait = imperial_bureaucrat
			set_character_flag = is_imperial_bureaucrat
			break = yes
		}
		add_trait = imperial_courtier
		set_character_flag = is_imperial_courtier
	}
}

# Imperial Bureaucrat seeks employment in the empire
character_event = {
	id = Plus.3366
	
	hide_window = yes
	
	min_age = 20
	capable_only = yes
	prisoner = no
	ai = yes
	has_character_flag = is_imperial_bureaucrat
	is_sick = no
	
	trigger = {
		is_ruler = no
		is_voter = no
		health = 4
		stewardship = 8
		can_be_treasurer_trigger = yes
		liege = {
			real_tier = EMPEROR
			is_feudal = yes
			NOT = { dynasty = ROOT }
			war = no
			any_courtier = {
				prisoner = no
				is_ruler = no
				count = 30
			}
		}
		NOR = {
			#is_ill = yes
			trait = stressed
			trait = depressed
			has_minor_title = title_appointed_regent
			has_minor_title = title_commander
			has_character_flag = serving_empire
		}
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	immediate = {
		liege = {
			random_realm_lord = {
				limit = {
					higher_real_tier_than = COUNT
					religion = ROOT
					culture = ROOT
					has_regent = no
					reverse_opinion = { who = ROOT value = 0 }
					NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_disappointed } }
					OR = {
						NOT = { any_courtier = { has_job_title = job_treasurer } }
						job_treasurer = {
							NOT = { stewardship = ROOT }
							NOT = { among_most_powerful_vassals = 4 }
						}
					}
				}
				if = {
					limit = { ai = yes }
					ROOT = {
						move_character = PREV
						clr_character_flag = is_imperial_bureaucrat
					}
					break = yes
				}
				if = {
					limit = { ai = no }
					letter_event = { id = Plus.3369 }
					break = yes
				}
			}
			random_realm_lord = {
				limit = {
					higher_real_tier_than = COUNT
					religion = ROOT
					has_regent = no
					reverse_opinion = { who = ROOT value = 0 }
					NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_disappointed } }
					OR = {
						NOT = { any_courtier = { has_job_title = job_treasurer } }
						job_treasurer = {
							NOT = { stewardship = ROOT }
							NOT = { among_most_powerful_vassals = 4 }
						}
					}
				}
				if = {
					limit = { ai = yes }
					ROOT = {
						move_character = PREV
						clr_character_flag = is_imperial_bureaucrat
					}
					break = yes
				}
				if = {
					limit = { ai = no }
					letter_event = { id = Plus.3369 }
					break = yes
				}
			}
		}
	}
}

# Imperial Courtier seeks employment in the empire
character_event = {
	id = Plus.3367
	
	hide_window = yes
	
	min_age = 20
	capable_only = yes
	prisoner = no
	ai = yes
	has_character_flag = is_imperial_courtier
	is_sick = no
	
	trigger = {
		is_ruler = no
		is_voter = no
		health = 4
		OR = {
			diplomacy = 8
			intrigue = 8
		}
		OR = {
			can_be_chancellor_trigger = yes
			can_be_spymaster_trigger = yes
		}
		liege = {
			real_tier = EMPEROR
			is_feudal = yes
			NOT = { dynasty = ROOT }
			war = no
			any_courtier = {
				prisoner = no
				is_ruler = no
				count = 30
			}
		}
		NOR = {
			#is_ill = yes
			trait = stressed
			trait = depressed
			has_minor_title = title_appointed_regent
			has_minor_title = title_commander
			has_character_flag = serving_empire
		}
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	immediate = {
		if = {
			limit = { can_be_spymaster_trigger = yes }
			liege = {
				random_realm_lord = {
					limit = {
						higher_real_tier_than = COUNT
						religion = ROOT
						culture = ROOT
						has_regent = no
						reverse_opinion = { who = ROOT value = 0 }
						NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_disappointed } }
						OR = {
							NOT = { any_courtier = { has_job_title = job_spymaster } }
							job_spymaster = {
								NOT = { intrigue = ROOT }
								NOT = { among_most_powerful_vassals = 4 }
							}
						}
					}
					if = {
						limit = { ai = yes }
						ROOT = {
							move_character = PREV
							clr_character_flag = is_imperial_courtier
						}
						break = yes
					}
					if = {
						limit = { ai = no }
						letter_event = { id = Plus.3369 }
						break = yes
					}
				}
				random_realm_lord = {
					limit = {
						higher_real_tier_than = COUNT
						religion = ROOT
						has_regent = no
						reverse_opinion = { who = ROOT value = 0 }
						NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_disappointed } }
						OR = {
							NOT = { any_courtier = { has_job_title = job_spymaster } }
							job_spymaster = {
								NOT = { intrigue = ROOT }
								NOT = { among_most_powerful_vassals = 4 }
							}
						}
					}
					if = {
						limit = { ai = yes }
						ROOT = {
							move_character = PREV
							clr_character_flag = is_imperial_courtier
						}
						break = yes
					}
					if = {
						limit = { ai = no }
						letter_event = { id = Plus.3369 }
						break = yes
					}
				}
			}
		}
		if = {
			limit = { can_be_chancellor_trigger = yes }
			liege = {
				random_realm_lord = {
					limit = {
						higher_real_tier_than = COUNT
						religion = ROOT
						culture = ROOT
						has_regent = no
						reverse_opinion = { who = ROOT value = 0 }
						OR = {
							NOT = { any_courtier = { has_job_title = job_chancellor } }
							job_chancellor = {
								NOT = { diplomacy = ROOT }
								NOT = { among_most_powerful_vassals = 4 }
							}
						}
					}
					if = {
						limit = { ai = yes }
						ROOT = {
							move_character = PREV
							clr_character_flag = is_imperial_courtier
						}
						break = yes
					}
					if = {
						limit = { ai = no }
						letter_event = { id = Plus.3369 }
						break = yes
					}
				}
				random_realm_lord = {
					limit = {
						higher_real_tier_than = COUNT
						religion = ROOT
						has_regent = no
						reverse_opinion = { who = ROOT value = 0 }
						OR = {
							NOT = { any_courtier = { has_job_title = job_chancellor } }
							job_chancellor = {
								NOT = { diplomacy = ROOT }
								NOT = { among_most_powerful_vassals = 4 }
							}
						}
					}
					if = {
						limit = { ai = yes }
						ROOT = {
							move_character = PREV
							clr_character_flag = is_imperial_courtier
						}
						break = yes
					}
					if = {
						limit = { ai = no }
						letter_event = { id = Plus.3369 }
						break = yes
					}
				}
			}
		}
	}
}

# Imperial Guard seeks employment in the empire
character_event = {
	id = Plus.3368
	
	hide_window = yes
	
	min_age = 20
	capable_only = yes
	prisoner = no
	ai = yes
	has_character_flag = is_imperial_guard
	is_sick = no
	
	trigger = {
		is_ruler = no
		is_voter = no
		health = 4
		martial = 8
		can_be_marshal_trigger = yes
		liege = {
			real_tier = EMPEROR
			is_feudal = yes
			NOT = { dynasty = ROOT }
			war = no
			any_courtier = {
				prisoner = no
				is_ruler = no
				count = 30
			}
		}
		NOR = {
			#is_ill = yes
			trait = stressed
			trait = depressed
			has_minor_title = title_appointed_regent
			has_minor_title = title_commander
			has_character_flag = serving_empire
		}
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	immediate = {
		liege = {
			random_realm_lord = {
				limit = {
					higher_real_tier_than = COUNT
					religion = ROOT
					culture = ROOT
					has_regent = no
					reverse_opinion = { who = ROOT value = 0 }
					NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_disappointed } }
					OR = {
						NOT = { any_courtier = { has_job_title = job_marshal } }
						job_marshal = {
							NOT = { martial = ROOT }
							NOT = { among_most_powerful_vassals = 4 }
						}
					}
				}
				if = {
					limit = { ai = yes }
					ROOT = {
						move_character = PREV
						clr_character_flag = is_imperial_guard
					}
					break = yes
				}
				if = {
					limit = { ai = no }
					letter_event = { id = Plus.3369 }
					break = yes
				}
			}
			random_realm_lord = {
				limit = {
					higher_real_tier_than = COUNT
					religion = ROOT
					has_regent = no
					reverse_opinion = { who = ROOT value = 0 }
					NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = opinion_disappointed } }
					OR = {
						NOT = { any_courtier = { has_job_title = job_marshal } }
						job_marshal = {
							NOT = { martial = ROOT }
							NOT = { among_most_powerful_vassals = 4 }
						}
					}
				}
				if = {
					limit = { ai = yes }
					ROOT = {
						move_character = PREV
						clr_character_flag = is_imperial_guard
					}
					break = yes
				}
				if = {
					limit = { ai = no }
					letter_event = { id = Plus.3369 }
					break = yes
				}
			}
		}
	}
}

# Letter of introduction to the new liege
letter_event = {
	id = Plus.3369
	desc = EVTDESC_Plus_3369
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_3369 # You are welcome
		FROM = {
			move_character = ROOT
			clr_character_flag = is_imperial_bureaucrat
			clr_character_flag = is_imperial_courtier
			clr_character_flag = is_imperial_guard
		}
	}
	option = {
		name = EVTOPTB_Plus_3369 # Refuse
		reverse_opinion = { who = FROM modifier = opinion_disappointed }
	}
}

# Bureaucrat proposes lowering imperial decadence
character_event = {
	id = Plus.3375
	desc = EVTDESC_Plus_3375
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	war = no
	
	trigger = {
		uses_imperial_decadence_trigger = yes
		primary_title = {
			check_variable = { which = "imperial_decadence" value = 5.0 }
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_bureaucrat
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_bureaucrat
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOT = { trait = incapable }
			}
			save_event_target_as = bureaucrat
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3375 # Do it
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:bureaucrat = { stewardship = 12 }
			}
		}
		event_target:bureaucrat = {
			opinion = { who = ROOT modifier = opinion_approves multiplier = 4 years = 5 }
		}
		random_list = {
			10 = {
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 10 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 20 }
				}
				imperial_decadence_minus_2_effect = yes
			}
			35 = {
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 10 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 20 }
				}
				imperial_decadence_minus_1_effect = yes
			}
			25 = {
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 8 } }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 6 } }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 4 } }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 2 } }
				}
				imperial_decadence_plus_1_effect = yes
			}
			5 = {
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 8 } }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 6 } }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 4 } }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { NOT = { stewardship = 2 } }
				}
				add_character_modifier = {
					name = bureaucratic_chaos
					duration = 365
				}
			}
		}	
	}
	option = {
		name = EVTOPTB_Plus_3375 # Not now
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:bureaucrat = { NOT = { stewardship = 8 } }
			}
		}
		add_character_modifier = {
			name = bureaucratic_anger
			duration = 365
		}
		any_courtier = {
			limit = {
				trait = imperial_bureaucrat
				prisoner = no
				NOT = { trait = incapable }
			}
			opinion = { who = ROOT modifier = opinion_disapprove years = 3 }
		}
	}
}

# Bureaucrat proposes revisions to tax laws
character_event = {
	id = Plus.3376
	desc = EVTDESC_Plus_3376
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	war = no
	
	trigger = {
		tier = EMPEROR
		is_tribal = no
		is_nomadic = no
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_bureaucrat
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_bureaucrat
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOT = { trait = incapable }
			}
			save_event_target_as = bureaucrat
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3375 # Do it
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:bureaucrat = { stewardship = 12 }
			}
		}
		event_target:bureaucrat = {
			opinion = { who = ROOT modifier = opinion_approves multiplier = 4 years = 5 }
		}
		random_list = {
			15 = {
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 10 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 20 }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 8 } }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 6 } }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 4 } }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 2 } }
				}
				add_character_modifier = {
					name = bureaucratic_reform_2
					duration = 900
				}
			}
			30 = {
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 10 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:bureaucrat = { stewardship = 20 }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 8 } }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 6 } }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 4 } }
				}
				modifier = {
					factor = 0.9
					event_target:bureaucrat = { NOT = { stewardship = 2 } }
				}
				add_character_modifier = {
					name = bureaucratic_reform_1
					duration = 900
				}
			}
			15 = {
				add_character_modifier = {
					name = bureaucratic_chaos
					duration = 365
				}
			}
			5 = {
				imperial_decadence_plus_1_effect = yes
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3375 # Not now
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:bureaucrat = { NOT = { stewardship = 8 } }
			}
		}
		add_character_modifier = {
			name = bureaucratic_anger
			duration = 365
		}
		any_courtier = {
			limit = {
				trait = imperial_bureaucrat
				prisoner = no
				NOT = { trait = incapable }
			}
			opinion = { who = ROOT modifier = opinion_disapprove years = 3 }
		}
	}
}	

# Imperial coffers shrink
character_event = {
	id = Plus.3377
	desc = EVTDESC_Plus_3377
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	
	trigger = {
		tier = EMPEROR
		is_tribal = no
		is_nomadic = no
		wealth = 100
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_bureaucrat
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 1.5
			war = yes
		}
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
	}
	
	option = {
		name = EVTOPTA_Plus_3377
		scaled_wealth = { value = -0.5 min = -100 }
		hidden_tooltip = {
			any_courtier = {
				limit = {
					trait = imperial_bureaucrat
					is_ruler = no
					is_councillor = no
					prisoner = no
					NOT = { trait = incapable }
				}
				if = {
					limit = { trait = deceitful }
					wealth = 25
				}
				if = {
					limit = {
						NOT = { trait = honest }
						NOT = { trait = deceitful }
					}
					wealth = 10
					random = {
						chance = 50
						add_trait = deceitful
						
					}
				}
				if = {
					limit = { trait = honest }
					random = {
						chance = 50
						remove_trait = honest
						
					}
				}
			}
		}
	}
}

# Too many imperial bureaucrats!
character_event = {
	id = Plus.3378
	desc = EVTDESC_Plus_3378
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	
	trigger = {
		uses_imperial_decadence_trigger = yes
		NOT = { trait = imperial_bureaucrat }
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			count = 3
			trait = imperial_bureaucrat
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 1.5
			war = yes
		}
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
	}
	
	option = {
		name = CURSES
		imperial_decadence_plus_1_effect = yes
	}
}

# Imperial courtier offers to help emperor with problem vassal
character_event = {
	id = Plus.3379
	desc = EVTDESC_Plus_3379
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	war = no
	
	trigger = {
		tier = EMPEROR
		is_tribal = no
		is_nomadic = no
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_courtier
			is_ruler = no
			is_councillor = no
			prisoner = no
			religion = ROOT
			opinion = { who = ROOT value = 0 }
			NOT = { trait = incapable }
		}
		any_vassal = {
			ai = yes
			is_playable = yes
			religion = ROOT
			NOR = {
				has_opinion_modifier = { who = ROOT modifier = opinion_coerced_into_leaving_faction }
				opinion = { who = ROOT value = -25 }
			}
			OR = {
				in_faction = faction_court
				in_faction = faction_prosperity
				in_faction = faction_glory
				in_faction = faction_tradition
			}
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_courtier
				is_ruler = no
				is_councillor = no
				prisoner = no
				religion = ROOT
				opinion = { who = ROOT value = 0 }
				NOT = { trait = incapable }
			}
			save_event_target_as = courtier
		}
		random_vassal = {
			limit = {
				ai = yes
				is_playable = yes
				religion = ROOT
				NOR = {
					has_opinion_modifier = { who = ROOT modifier = opinion_coerced_into_leaving_faction }
					opinion = { who = ROOT value = -25 }
				}
				OR = {
					in_faction = faction_court
					in_faction = faction_prosperity
					in_faction = faction_glory
					in_faction = faction_tradition
				}
			}
			save_event_target_as = problem_vassal
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3379 # Do what you can
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:courtier = { intrigue = 12 }
			}
		}
		if = {
			limit = { num_of_friends = 5 }
			opinion = { who = event_target:courtier modifier = opinion_very_grateful years = 5 }
			reverse_opinion = { who = event_target:courtier modifier = opinion_very_grateful years = 5 }
		}
		if = {
			limit = { NOT = { num_of_friends = 5 } }
			add_friend = event_target:courtier
		}
		random_list = {
			25 = {
				modifier = {
					factor = 0.9
					event_target:courtier = { NOT = { intrigue = 8 } }
				}
				modifier = {
					factor = 0.9
					event_target:courtier = { NOT = { intrigue = 6 } }
				}
				modifier = {
					factor = 0.9
					event_target:courtier = { NOT = { intrigue = 4 } }
				}
				modifier = {
					factor = 0.9
					event_target:courtier = { NOT = { intrigue = 2 } }
				}
				modifier = {
					factor = 1.1
					event_target:courtier = { intrigue = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:courtier = { intrigue = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:courtier = { intrigue = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:courtier = { intrigue = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:courtier = { intrigue = 20 }
				}
				event_target:problem_vassal = {
					opinion = { who = ROOT modifier = opinion_coerced_into_leaving_faction years = 5 }
				}
			}
			10 = {
				event_target:problem_vassal = {
					opinion = { who = ROOT modifier = opinion_outraged years = 5 }
				}
			}
			5 = {
				modifier = {
					factor = 0
					OR = {
						is_rival = event_target:problem_vassal
						num_of_rivals = 5
					}
				}
				add_rival = event_target:problem_vassal
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3379 # I don't need your help
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:courtier = { NOT = { intrigue = 8 } }
			}
		}
		random_list = {
			50 = {
				reverse_opinion = { who = event_target:courtier modifier = opinion_outraged years = 5 }
			}
			25 = {
				modifier = {
					factor = 0
					OR = {
						is_rival = event_target:courtier
						num_of_rivals = 5
					}
				}
				add_rival = event_target:courtier
			}
			15 = {
				add_character_modifier = {
					name = courtier_anger
					duration = 365
				}
			}
		}
	}
}

# Incident during the imperial court
character_event = {
	id = Plus.3380
	desc = EVTDESC_Plus_3380
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	
	trigger = {
		tier = EMPEROR
		is_tribal = no
		is_nomadic = no
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			count = 2
			trait = imperial_courtier
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
			OR = {
				ROOT = { war = no }
				in_command = no
			}
		}
	}
	
	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 1.5
			war = yes
		}
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_courtier
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOT = { trait = incapable }
				OR = {
					ROOT = { war = no }
					in_command = no
				}
			}
			save_event_target_as = first_courtier
		}
		# first look for disliked courtier
		random_courtier = {
			limit = {
				OR = {
					trait = imperial_courtier
					trait = imperial_bureaucrat
					trait = imperial_guard
				}
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOR = {
					trait = incapable
					character = event_target:first_courtier
					reverse_opinion = { who = event_target:first_courtier value = -25 }
				}
				OR = {
					ROOT = { war = no }
					in_command = no
				}
			}
			save_event_target_as = second_courtier
		}
		# then anyone will do
		random_courtier = {
			limit = {
				NOT = { event_target:second_courtier = { always = yes } }
				OR = {
					trait = imperial_courtier
					trait = imperial_bureaucrat
					trait = imperial_guard
				}
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOR = {
					trait = incapable
					character = event_target:first_courtier
				}
				OR = {
					ROOT = { war = no }
					in_command = no
				}
			}
			save_event_target_as = second_courtier
		}
		if = {
			limit = { event_target:first_courtier = { is_friend = event_target:second_courtier } }
			event_target:first_courtier = { remove_friend = event_target:second_courtier }
		}
		event_target:first_courtier = { add_rival = event_target:second_courtier }
	}
	
	option = {
		name = EVTOPTA_Plus_3380 # Support first courtier
		if = {
			limit = {
				OR = {
					num_of_friends = 5
					is_friend = event_target:first_courtier
				}
			}
			opinion = { who = event_target:first_courtier modifier = opinion_very_grateful years = 5 }
			reverse_opinion = { who = event_target:first_courtier modifier = opinion_very_grateful years = 5 }
		}
		if = {
			limit = {
				NOR = {
					num_of_friends = 5
					is_friend = event_target:first_courtier
				}
			}
			add_friend = event_target:first_courtier
		}
		if = {
			limit = {
				OR = {
					num_of_rivals = 5
					is_rival = event_target:second_courtier
				}
			}
			reverse_opinion = { who = event_target:second_courtier modifier = opinion_hatred years = 5 }
		}
		if = {
			limit = {
				NOR = {
					num_of_rivals = 5
					is_rival = event_target:second_courtier
				}
			}
			add_rival = event_target:second_courtier
		}
	}
	option = {
		name = EVTOPTB_Plus_3380 # Support second courtier
		if = {
			limit = {
				OR = {
					num_of_friends = 5
					is_friend = event_target:second_courtier
				}
			}
			opinion = { who = event_target:second_courtier modifier = opinion_very_grateful years = 5 }
			reverse_opinion = { who = event_target:second_courtier modifier = opinion_very_grateful years = 5 }
		}
		if = {
			limit = {
				NOR = {
					num_of_friends = 5
					is_friend = event_target:second_courtier
				}
			}
			add_friend = event_target:second_courtier
		}
		if = {
			limit = {
				OR = {
					num_of_rivals = 5
					is_rival = event_target:first_courtier
				}
			}
			reverse_opinion = { who = event_target:first_courtier modifier = opinion_hatred years = 5 }
		}
		if = {
			limit = {
				NOR = {
					num_of_rivals = 5
					is_rival = event_target:first_courtier
				}
			}
			add_rival = event_target:first_courtier
		}
	}
	option = {
		name = EVTOPTC_Plus_3380 # Take neither side
		trigger = {
			NOT = { diplomacy = 15 }
		}
		reverse_opinion = { who = event_target:first_courtier modifier = opinion_furious years = 5 }
		reverse_opinion = { who = event_target:second_courtier modifier = opinion_furious years = 5 }
		add_character_modifier = {
			name = courtier_anger
			duration = 365
		}
	}
	option = {
		name = EVTOPTD_Plus_3380 # Help them work it out
		trigger = {
			diplomacy = 15
		}
		tooltip_info = diplomacy
		prestige = 50
		event_target:first_courtier = {
			remove_rival = event_target:second_courtier
		}
	}
}

# Too many imperial courtiers!
character_event = {
	id = Plus.3381
	desc = EVTDESC_Plus_3381
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	
	trigger = {
		uses_imperial_decadence_trigger = yes
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			count = 3
			trait = imperial_courtier
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 200
		modifier = {
			factor = 1.5
			war = yes
		}
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
	}
	
	option = {
		name = CURSES
		imperial_decadence_plus_1_effect = yes
	}
}

# Imperial guard proposes revisions to military training
character_event = {
	id = Plus.3382
	desc = EVTDESC_Plus_3382
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	
	trigger = {
		tier = EMPEROR
		is_tribal = no
		is_nomadic = no
		war = no
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_guard
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_guard
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOT = { trait = incapable }
			}
			save_event_target_as = guard
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3375 # Do it
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:guard = { martial = 12 }
			}
		}
		event_target:guard = {
			opinion = { who = ROOT modifier = opinion_approves multiplier = 4 years = 5 }
		}
		random_list = {
			15 = {
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 10 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 20 }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 8 } }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 6 } }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 4 } }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 2 } }
				}
				add_character_modifier = {
					name = military_reform_2
					duration = 900
				}
			}
			30 = {
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 10 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 12 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 14 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 16 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 18 }
				}
				modifier = {
					factor = 1.1
					event_target:guard = { martial = 20 }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 8 } }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 6 } }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 4 } }
				}
				modifier = {
					factor = 0.9
					event_target:guard = { NOT = { martial = 2 } }
				}
				add_character_modifier = {
					name = military_reform_1
					duration = 900
				}
			}
			15 = {
				add_character_modifier = {
					name = military_chaos
					duration = 365
				}
			}
			5 = {
				imperial_decadence_plus_1_effect = yes
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3375 # Not now
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				event_target:guard = { NOT = { martial = 8 } }
			}
		}
		add_character_modifier = {
			name = bureaucratic_anger
			duration = 365
		}
		any_courtier = {
			limit = {
				trait = imperial_guard
				prisoner = no
				NOT = { trait = incapable }
			}
			opinion = { who = ROOT modifier = opinion_disapprove years = 3 }
		}
	}
}

# The imperial bodyguards
character_event = {
	id = Plus.3383
	desc = EVTDESC_Plus_3383
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	war = no
	
	trigger = {
		tier = EMPEROR
		is_tribal = no
		is_nomadic = no
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_guard
			is_ruler = no
			is_councillor = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { age = 50 }
			opinion = { who = ROOT value = 25 }
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_guard
				is_ruler = no
				is_councillor = no
				prisoner = no
				NOT = { trait = incapable }
				NOT = { age = 50 }
				opinion = { who = ROOT value = 25 }
			}
			save_event_target_as = guard
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3383
		reverse_opinion = { who = event_target:guard modifier = opinion_loyal_servant years = 5 }
		add_character_modifier = {
			name = imperial_bodyguards
			duration = 1825
		}
	}
}
	
# Capable commander becomes popular
character_event = {
	id = Plus.3384
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		martial = 8
		is_ruler = no
		NOR = {
			trait = incapable
			is_maimed_trigger = yes
			trait = imbecile
			trait = infirm
			trait = inbred
			trait = weak
			trait = dwarf
			trait = imperial_courtier
			trait = imperial_bureaucrat
			age = 60
		}
		liege = {
			real_tier = EMPEROR
			has_imperial_government_trigger = yes
			is_tribal = no
			is_nomadic = no
			primary_title = {
				NOT = { claimed_by = ROOT }
			}
		}
	}
	
	immediate = {
		if = {
			limit = { trait = imperial_guard }
			random = {
				chance = 25
				modifier = {
					factor = 1.5
					is_strong_trigger = yes
				}
				modifier = {
					factor = 1.5
					trait = tall
				}
				modifier = {
					factor = 1.5
					trait = imposing
				}
				modifier = {
					factor = 1.5
					trait = ambitious
				}
				modifier = {
					factor = 0.5
					trait = content
				}
				modifier = {
					factor = 0.5
					trait = humble
				}
				modifier = {
					factor = 0.5
					NOT = { diplomacy = 4 }
				}
				modifier = {
					factor = 0.5
					NOT = { diplomacy = 8 }
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 12 }
				}
				modifier = {
					factor = 0.5
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 1.2
					martial = 14
				}
				modifier = {
					factor = 1.2
					martial = 16
				}
				modifier = {
					factor = 1.2
					martial = 18
				}
				modifier = {
					factor = 1.2
					martial = 20
				}
				modifier = {
					factor = 1.2
					diplomacy = 12
				}
				modifier = {
					factor = 1.2
					diplomacy = 14
				}
				modifier = {
					factor = 1.2
					diplomacy = 16
				}
				modifier = {
					factor = 1.2
					diplomacy = 18
				}
				prestige = 500
				liege = {
					primary_title = { add_claim = ROOT }
					opinion = { who = ROOT modifier = opinion_war_hero years = 10 }
					any_realm_character = { opinion = { who = ROOT modifier = opinion_war_hero years = 10 } }
					character_event = { id = Plus.3385 days = 1 }
				}
			}
			break = yes
		}
		add_trait = imperial_guard
	}
}

character_event = {
	id = Plus.3385
	title = EVTNAME_Plus_3385
	desc = EVTDESC_Plus_3385
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war	
	
	is_triggered_only = yes
	major = yes
	
	major_trigger = {
		OR = {
			character = FROM
			character = ROOT
			same_realm = ROOT
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3385
		trigger = { character = ROOT }
		tooltip = {
			primary_title = {
				add_claim = FROM
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_3385
		trigger = { NOT = { character = ROOT } }
	}
}

# Capable imperial guard is better than the emperor
character_event = {
	id = Plus.3386
	desc = EVTDESC_Plus_3386
	picture = GFX_evt_imperial_court
	
	only_independent = yes
	capable_only = yes
	min_age = 16
	prisoner = no
	war = no
	
	trigger = {
		tier = EMPEROR
		has_imperial_government_trigger = yes
		is_tribal = no
		is_nomadic = no
		primary_title = {
			OR = {
				NOT = { has_title_flag = imperial_court_event }
				had_title_flag = { flag = imperial_court_event days = 1825 }
			}
		}
		any_courtier = {
			trait = imperial_guard
			martial = 12
			attribute_diff = { character = ROOT attribute = martial value = 3 }
			prisoner = no
			is_ill = no
			NOR = {
				is_dumb_trigger = yes
				trait = incapable
				trait = content
				trait = humble
				trait = stressed
				trait = depressed
				is_maimed_trigger = yes
				opinion = { who = ROOT value = 0 }
				any_claim = {
					is_primary_holder_title = yes
					holder = ROOT
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		primary_title = { set_title_flag = imperial_court_event }
		random_courtier = {
			limit = {
				trait = imperial_guard
				martial = 12
				attribute_diff = { character = ROOT attribute = martial value = 3 }
				prisoner = no
				is_ill = no
				NOR = {
					is_dumb_trigger = yes
					trait = incapable
					trait = content
					trait = humble
					trait = stressed
					trait = depressed
					is_maimed_trigger = yes
					opinion = { who = ROOT value = 0 }
					any_claim = {
						is_primary_holder_title = yes
						holder = ROOT
					}
					ROOT = {
						any_courtier = {
							trait = imperial_guard
							martial = 12
							attribute_diff = { character = ROOT attribute = martial value = 3 }
							attribute_diff = { character = PREVPREV attribute = martial value = 1 }
							prisoner = no
							is_ill = no
							NOR = {
								is_dumb_trigger = yes
								trait = incapable
								trait = content
								trait = humble
								trait = stressed
								trait = depressed
								is_maimed_trigger = yes
								opinion = { who = ROOT value = 0 }
								any_claim = {
									is_primary_holder_title = yes
									holder = ROOT
								}
							}
						}
					}
				}
			}
			save_event_target_as = guard
		}
	}
	
	option = {
		name = EVTOPTA_Plus_3386
		primary_title = {
			add_claim = event_target:guard
		}
		event_target:guard = {
			if = {
				limit = { NOT = { trait = ambitious } }
				add_trait = ambitious
			}
		}
	}
}