namespace = cato_education_events_setup_hereditary
###1-4 The player picking an education
###5-8 Hidden events where the AI picks an education if given a choice by player
###10-11 Marks the heir's education as finished and subsequentially assign them an appropriate trait
country_event = {
	id = cato_education_events_setup_hereditary.1 ###Educate Heir
	title = cato_education_events_setup_hereditary.1.title
	desc = cato_education_events_setup_hereditary.1.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes
	trigger = {
		has_heir = yes
		is_lesser_in_union = no
		government_does_not_use_hereditary_heir = no
	}
	immediate = {
		hidden_effect = {
			set_variable = {
				which = heirEducationalLevel
				value = 0
			}
			set_variable = {
				which = heir_education_event_number
				value = 0
			}
			set_heir_flag = heir_started_education
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.a
		set_heir_flag = started_adm_education
		country_event = {
			id = cato_education_events_setup_hereditary.2
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.b
		set_heir_flag = started_dip_education
		country_event = {
			id = cato_education_events_setup_hereditary.3
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.c
		set_heir_flag = started_mil_education
		country_event = {
			id = cato_education_events_setup_hereditary.4
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.d
		set_heir_flag = started_chosen_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_setup_hereditary.5
			}
			change_variable = {
				which = heirEducationalLevel
				value = 30
			}
			set_heir_flag = heir_chose_education_category
		}
		ai_chance = {
			factor = 1
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.2 ###Picking an administration sub-category
	title = cato_education_events_setup_hereditary.2.title
	desc = cato_education_events_setup_hereditary.2.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes

	trigger = {
	}

	option = {
		name = cato_education_events_setup_hereditary.2.a
		set_heir_flag = clerical_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.2.b
		set_heir_flag = administrative_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.2.c
		set_heir_flag = scholastic_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.2.e
		set_heir_flag = industrial_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.2.d
		hidden_effect = {
			set_heir_flag = heir_chose_education_subcategory
			country_event = {
				id = cato_education_events_setup_hereditary.6
			}
			change_variable = {
				which = heirEducationalLevel
				value = 15
			}
		}
		ai_chance = {
			factor = 1
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.3 ### Picking a diplomatic sub-category
	title = cato_education_events_setup_hereditary.3.title
	desc = cato_education_events_setup_hereditary.3.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes

	trigger = {
	}

	option = {
		name = cato_education_events_setup_hereditary.3.a
		set_heir_flag = diplomacy_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.3.b
		set_heir_flag = intrigue_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.3.c
		set_heir_flag = trade_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.3.e
		set_heir_flag = colonial_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.3.d
		hidden_effect = {
			set_heir_flag = heir_chose_education_subcategory
			country_event = {
				id = cato_education_events_setup_hereditary.7
			}
			change_variable = {
				which = heirEducationalLevel
				value = 15
			}
		}
		ai_chance = {
			factor = 1
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.4 ### Picking a military sub-category
	title = cato_education_events_setup_hereditary.4.title
	desc = cato_education_events_setup_hereditary.4.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes

	trigger = {
	}

	option = {
		name = cato_education_events_setup_hereditary.4.a
		set_heir_flag = martial_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.4.b
		set_heir_flag = naval_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.4.c
		set_heir_flag = logistics_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.4.e
		set_heir_flag = modern_army_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.4.d
		hidden_effect = {
			set_heir_flag = heir_chose_education_subcategory
			country_event = {
				id = cato_education_events_setup_hereditary.8
			}
			change_variable = {
				which = heirEducationalLevel
				value = 15
			}
		}
		ai_chance = {
			factor = 1
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.5 ###Hidden event where the heir selects a category, based on things like personality traits, advisors, ideas, etc.
	title = cato_education_events_setup_hereditary.0.title
	desc = cato_education_events_setup_hereditary.0.desc
	picture = ECONOMY_eventPicture
	is_triggered_only = yes
	hidden = yes
	trigger = {
		has_heir = yes
		is_lesser_in_union = no
	}
	immediate = {
	}
	option = {
		name = cato_education_events_setup_hereditary.1.a
		set_heir_flag = started_adm_education
		country_event = {
			id = cato_education_events_setup_hereditary.6
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = economic_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = administrative_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = innovativeness_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = religious_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = humanist_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = expansion_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = aristocracy_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = plutocracy_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = trade_ideas
			}
			modifier = {
				factor = 1.2
				heir_adm = 3
			}
			modifier = {
				factor = 0.5
				NOT = { heir_adm = 1 }
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.b
		set_heir_flag = started_dip_education
		country_event = {
			id = cato_education_events_setup_hereditary.7
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = trade_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = spy_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = influence_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = diplomatic_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = exploration_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = expansion_ideas
			}
			modifier = {
				factor = 1.2
				heir_dip = 3
			}
			modifier = {
				factor = 0.5
				NOT = { heir_dip = 1 }
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.c
		set_heir_flag = started_mil_education
		country_event = {
			id = cato_education_events_setup_hereditary.8
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = quality_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = quantity_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = offensive_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = defensive_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = naval_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = quality_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = maritime_ideas
			}
			modifier = {
				factor = 1.2
				heir_mil = 3
			}
			modifier = {
				factor = 0.5
				NOT = { heir_mil = 1 }
			}
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.6 ###Hidden event where the heir picks an admin sub-category.
	title = cato_education_events_setup_hereditary.0.title
	desc = cato_education_events_setup_hereditary.0.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes
	hidden = yes
	trigger = {
		has_heir = yes
		is_lesser_in_union = no
	}

	option = {
		name = cato_education_events_setup_hereditary.1.a
		set_heir_flag = clerical_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = religious_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = humanist_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.b
		set_heir_flag = administrative_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = administrative_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.c
		set_heir_flag = scholastic_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = innovativeness_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.d
		set_heir_flag = industrial_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = economic_ideas
			}
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.7 ###Hidden event where the heir picks an diplomatic sub-category.
	title = cato_education_events_setup_hereditary.0.title
	desc = cato_education_events_setup_hereditary.0.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes
	hidden = yes
	trigger = {
		has_heir = yes
		is_lesser_in_union = no
	}

	option = {
		name = cato_education_events_setup_hereditary.1.a
		set_heir_flag = diplomacy_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = diplomatic_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = influence_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.b
		set_heir_flag = intrigue_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = spy_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.c
		set_heir_flag = trade_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = trade_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = economic_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.d
		set_heir_flag = colonial_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = expansion_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = exploration_ideas
			}
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.8 ###Hidden event where the heir picks an military sub-category.
	title = cato_education_events_setup_hereditary.0.title
	desc = cato_education_events_setup_hereditary.0.desc
	picture = ECONOMY_eventPicture

	is_triggered_only = yes
	hidden = yes
	trigger = {
		has_heir = yes
		is_lesser_in_union = no
	}

	option = {
		name = cato_education_events_setup_hereditary.1.a
		set_heir_flag = martial_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = quality_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = quantity_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.b
		set_heir_flag = naval_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = maritime_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = naval_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.c
		set_heir_flag = logistics_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = offensive_ideas
			}
			modifier = {
				factor = 1.2
				has_idea_group = defensive_ideas
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.1.c
		set_heir_flag = modern_army_education
		hidden_effect = {
			country_event = {
				id = cato_education_events_education_progress.0001
				days = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 1.2
				has_idea_group = quality_ideas
			}
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.10 ###Preparation event that fires when either an heir finishes their education after 8 years or they ascend the throne. Calculates their educational level and assigns them a flag which is used in the next event to add the modifier.
	title = cato_education_events_setup_hereditary.10.title
	desc = {
		trigger = {
			check_variable = {
				which = heir_education_event_number
				value = 16
			}
		}
		desc = "cato_education_events_setup_hereditary.10.desc.a"###Description for if the heir completes their education successfully.
	}
	desc = {
		trigger = {
			has_ruler_flag = heir_started_education
		}
		desc = "cato_education_events_setup_hereditary.10.desc.b"###Description for if the heir is forced to the throne before they complete it.
	}
	picture = ECONOMY_eventPicture
	trigger = {
		OR = {
			AND = {
				check_variable = {
					which = heir_education_event_number
					value = 16
				}
				heir_available = yes
				has_heir_flag = heir_started_education
			}
			has_ruler_flag = heir_started_education
		}
		is_lesser_in_union = no
	}
	immediate = {
		hidden_effect = {
			if = {
				limit = {
					NOT = {
						check_variable = {
							which = heirEducationalLevel
							value = 20
						}
					}
				}
				set_country_flag = poor_education
			}
			else_if = {
				limit = {
					check_variable = {
						which = heirEducationalLevel
						value = 20
					}
					NOT = {
						check_variable = {
							which = heirEducationalLevel
							value = 50
						}
					}
				}
				set_country_flag = okay_education
			}
			else_if = {
				limit = {
					check_variable = {
						which = heirEducationalLevel
						value = 50
					}
					NOT = {
						check_variable = {
							which = heirEducationalLevel
							value = 80
						}
					}
				}
				set_country_flag = good_education
			}
			else_if = {
				limit = {
					check_variable = {
						which = heirEducationalLevel
						value = 80
					}
				}
				set_country_flag = best_education
			}
		}
	}
	option = {
		name = cato_education_events_setup_hereditary.10.a
		if = { ### For those who have completed their full eight years of education.
			limit = {
				has_heir_flag = heir_started_education
			}
			if = {
				limit = {
					has_heir_flag = clerical_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_clerical_education
			}
			else_if = {
				limit = {
					has_heir_flag = clerical_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_clerical_education
			}
			else_if = {
				limit = {
					has_heir_flag = clerical_education
					has_country_flag = good_education
				}
				set_heir_flag = good_clerical_education
			}
			else_if = {
				limit = {
					has_heir_flag = clerical_education
					has_country_flag = best_education
				}
				set_heir_flag = best_clerical_education
			}
			else_if = {
				limit = {
					has_heir_flag = administrative_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_administrative_education
			}
			else_if = {
				limit = {
					has_heir_flag = administrative_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_administrative_education
			}
			else_if = {
				limit = {
					has_heir_flag = administrative_education
					has_country_flag = good_education
				}
				set_heir_flag = good_administrative_education
			}
			else_if = {
				limit = {
					has_heir_flag = administrative_education
					has_country_flag = best_education
				}
				set_heir_flag = best_administrative_education
			}
			else_if = {
				limit = {
					has_heir_flag = scholastic_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_scholastic_education
			}
			else_if = {
				limit = {
					has_heir_flag = scholastic_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_scholastic_education
			}
			else_if = {
				limit = {
					has_heir_flag = scholastic_education
					has_country_flag = good_education
				}
				set_heir_flag = good_scholastic_education
			}
			else_if = {
				limit = {
					has_heir_flag = scholastic_education
					has_country_flag = best_education
				}
				set_heir_flag = best_scholastic_education
			}
			else_if = {
				limit = {
					has_heir_flag = industrial_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_industrial_education
			}
			else_if = {
				limit = {
					has_heir_flag = industrial_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_industrial_education
			}
			else_if = {
				limit = {
					has_heir_flag = industrial_education
					has_country_flag = good_education
				}
				set_heir_flag = good_industrial_education
			}
			else_if = {
				limit = {
					has_heir_flag = industrial_education
					has_country_flag = best_education
				}
				set_heir_flag = best_industrial_education
			}
			else_if = {
				limit = {
					has_heir_flag = diplomacy_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_diplomacy_education
			}
			else_if = {
				limit = {
					has_heir_flag = diplomacy_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_diplomacy_education
			}
			else_if = {
				limit = {
					has_heir_flag = diplomacy_education
					has_country_flag = good_education
				}
				set_heir_flag = good_diplomacy_education
			}
			else_if = {
				limit = {
					has_heir_flag = diplomacy_education
					has_country_flag = best_education
				}
				set_heir_flag = best_diplomacy_education
			}
			else_if = {
				limit = {
					has_heir_flag = intrigue_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_intrigue_education
			}
			else_if = {
				limit = {
					has_heir_flag = intrigue_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_intrigue_education
			}
			else_if = {
				limit = {
					has_heir_flag = intrigue_education
					has_country_flag = good_education
				}
				set_heir_flag = good_intrigue_education
			}
			else_if = {
				limit = {
					has_heir_flag = intrigue_education
					has_country_flag = best_education
				}
				set_heir_flag = best_intrigue_education
			}
			else_if = {
				limit = {
					has_heir_flag = trade_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_trade_education
			}
			else_if = {
				limit = {
					has_heir_flag = trade_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_trade_education
			}
			else_if = {
				limit = {
					has_heir_flag = trade_education
					has_country_flag = good_education
				}
				set_heir_flag = good_trade_education
			}
			else_if = {
				limit = {
					has_heir_flag = trade_education
					has_country_flag = best_education
				}
				set_heir_flag = best_trade_education
			}
			else_if = {
				limit = {
					has_heir_flag = colonial_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_colonial_education
			}
			else_if = {
				limit = {
					has_heir_flag = colonial_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_colonial_education
			}
			else_if = {
				limit = {
					has_heir_flag = colonial_education
					has_country_flag = good_education
				}
				set_heir_flag = good_colonial_education
			}
			else_if = {
				limit = {
					has_heir_flag = colonial_education
					has_country_flag = best_education
				}
				set_heir_flag = best_colonial_education
			}
			else_if = {
				limit = {
					has_heir_flag = martial_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_martial_education
			}
			else_if = {
				limit = {
					has_heir_flag = martial_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_martial_education
			}
			else_if = {
				limit = {
					has_heir_flag = martial_education
					has_country_flag = good_education
				}
				set_heir_flag = good_martial_education
			}
			else_if = {
				limit = {
					has_heir_flag = martial_education
					has_country_flag = best_education
				}
				set_heir_flag = best_martial_education
			}
			else_if = {
				limit = {
					has_heir_flag = naval_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_naval_education
			}
			else_if = {
				limit = {
					has_heir_flag = naval_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_naval_education
			}
			else_if = {
				limit = {
					has_heir_flag = naval_education
					has_country_flag = good_education
				}
				set_heir_flag = good_naval_education
			}
			else_if = {
				limit = {
					has_heir_flag = naval_education
					has_country_flag = best_education
				}
				set_heir_flag = best_naval_education
			}
			else_if = {
				limit = {
					has_heir_flag = logistics_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_logistics_education
			}
			else_if = {
				limit = {
					has_heir_flag = logistics_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_logistics_education
			}
			else_if = {
				limit = {
					has_heir_flag = logistics_education
					has_country_flag = good_education
				}
				set_heir_flag = good_logistics_education
			}
			else_if = {
				limit = {
					has_heir_flag = logistics_education
					has_country_flag = best_education
				}
				set_heir_flag = best_logistics_education
			}
			else_if = {
				limit = {
					has_heir_flag = modern_army_education
					has_country_flag = poor_education
				}
				set_heir_flag = poor_modern_army_education
			}
			else_if = {
				limit = {
					has_heir_flag = modern_army_education
					has_country_flag = okay_education
				}
				set_heir_flag = okay_modern_army_education
			}
			else_if = {
				limit = {
					has_heir_flag = modern_army_education
					has_country_flag = good_education
				}
				set_heir_flag = good_modern_army_education
			}
			else_if = {
				limit = {
					has_heir_flag = modern_army_education
					has_country_flag = best_education
				}
				set_heir_flag = best_modern_army_education
			}
			set_heir_flag = heir_finished_education
			clr_heir_flag = heir_started_education
			clear_country_education_quality_flags = yes
		}
		else_if = { ###Now for those whose education ended because they ascended the throne.
			limit = {
				has_ruler_flag = heir_started_education
			}
			if = {
				limit = {
					has_ruler_flag = clerical_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_clerical_education
			}
			else_if = {
				limit = {
					has_ruler_flag = clerical_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_clerical_education
			}
			else_if = {
				limit = {
					has_ruler_flag = clerical_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_clerical_education
			}
			else_if = {
				limit = {
					has_ruler_flag = clerical_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_clerical_education
			}
			else_if = {
				limit = {
					has_ruler_flag = administrative_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_administrative_education
			}
			else_if = {
				limit = {
					has_ruler_flag = administrative_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_administrative_education
			}
			else_if = {
				limit = {
					has_ruler_flag = administrative_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_administrative_education
			}
			else_if = {
				limit = {
					has_ruler_flag = administrative_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_administrative_education
			}
			else_if = {
				limit = {
					has_ruler_flag = scholastic_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_scholastic_education
			}
			else_if = {
				limit = {
					has_ruler_flag = scholastic_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_scholastic_education
			}
			else_if = {
				limit = {
					has_ruler_flag = scholastic_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_scholastic_education
			}
			else_if = {
				limit = {
					has_ruler_flag = scholastic_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_scholastic_education
			}
			else_if = {
				limit = {
					has_ruler_flag = industrial_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_industrial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = industrial_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_industrial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = industrial_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_industrial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = industrial_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_industrial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = diplomacy_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_diplomacy_education
			}
			else_if = {
				limit = {
					has_ruler_flag = diplomacy_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_diplomacy_education
			}
			else_if = {
				limit = {
					has_ruler_flag = diplomacy_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_diplomacy_education
			}
			else_if = {
				limit = {
					has_ruler_flag = diplomacy_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_diplomacy_education
			}
			else_if = {
				limit = {
					has_ruler_flag = intrigue_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_intrigue_education
			}
			else_if = {
				limit = {
					has_ruler_flag = intrigue_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_intrigue_education
			}
			else_if = {
				limit = {
					has_ruler_flag = intrigue_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_intrigue_education
			}
			else_if = {
				limit = {
					has_ruler_flag = intrigue_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_intrigue_education
			}
			else_if = {
				limit = {
					has_ruler_flag = trade_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_trade_education
			}
			else_if = {
				limit = {
					has_ruler_flag = trade_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_trade_education
			}
			else_if = {
				limit = {
					has_ruler_flag = trade_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_trade_education
			}
			else_if = {
				limit = {
					has_ruler_flag = trade_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_trade_education
			}
			else_if = {
				limit = {
					has_ruler_flag = colonial_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_colonial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = colonial_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_colonial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = colonial_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_colonial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = colonial_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_colonial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = martial_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_martial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = martial_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_martial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = martial_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_martial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = martial_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_martial_education
			}
			else_if = {
				limit = {
					has_ruler_flag = naval_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_naval_education
			}
			else_if = {
				limit = {
					has_ruler_flag = naval_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_naval_education
			}
			else_if = {
				limit = {
					has_ruler_flag = naval_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_naval_education
			}
			else_if = {
				limit = {
					has_ruler_flag = naval_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_naval_education
			}
			else_if = {
				limit = {
					has_ruler_flag = logistics_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_logistics_education
			}
			else_if = {
				limit = {
					has_ruler_flag = logistics_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_logistics_education
			}
			else_if = {
				limit = {
					has_ruler_flag = logistics_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_logistics_education
			}
			else_if = {
				limit = {
					has_ruler_flag = logistics_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_logistics_education
			}
			else_if = {
				limit = {
					has_ruler_flag = modern_army_education
					has_country_flag = poor_education
				}
				set_ruler_flag = poor_modern_army_education
			}
			else_if = {
				limit = {
					has_ruler_flag = modern_army_education
					has_country_flag = okay_education
				}
				set_ruler_flag = okay_modern_army_education
			}
			else_if = {
				limit = {
					has_ruler_flag = modern_army_education
					has_country_flag = good_education
				}
				set_ruler_flag = good_modern_army_education
			}
			else_if = {
				limit = {
					has_ruler_flag = modern_army_education
					has_country_flag = best_education
				}
				set_ruler_flag = best_modern_army_education
			}
			clear_country_education_quality_flags = yes
			set_ruler_flag = heir_finished_education
			clr_ruler_flag = heir_started_education
		}
		ai_chance = {
			factor = 1
		}
	}
}
country_event = {
	id = cato_education_events_setup_hereditary.11 ###This event actually adds the proper modifier to the ruler based on their education level. The reason this is done here and not the previous one is that we don't want to accidentally add the modifier to the current ruler if the heir is still a child.
	title = cato_education_events_setup_hereditary.11.title
	desc = cato_education_events_setup_hereditary.11.desc
	picture = ECONOMY_eventPicture

	trigger = {
		NOT = {
			government = theocracy
			government = republic
		}
		has_ruler_flag = heir_finished_education
		no_education_trait_ruler = yes
		is_lesser_in_union = no
		NOT = {
			has_ruler_flag = assigned_education
		}
	}
	immediate = {
		set_ruler_flag = assigned_education
	}

	option = {
		name = cato_education_events_setup_hereditary.11.a
		if = {
			limit = {
				has_ruler_flag = poor_clerical_education
			}
			add_ruler_modifier = {
				name = poor_clerical_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_clerical_education
			}
			add_ruler_modifier = {
				name = okay_clerical_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_clerical_education
			}
			add_good_clerical_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_clerical_education
			}
			add_best_clerical_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_administrative_education
			}
			add_ruler_modifier = {
				name = poor_administrative_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_administrative_education
			}
			add_ruler_modifier = {
				name = okay_administrative_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_administrative_education
			}
			add_good_administrative_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_administrative_education
			}
			add_best_administrative_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_scholastic_education
			}
			add_ruler_modifier = {
				name = poor_scholastic_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_scholastic_education
			}
			add_ruler_modifier = {
				name = okay_scholastic_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_scholastic_education
			}
			add_good_scholastic_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_scholastic_education
			}
			add_best_scholastic_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_industrial_education
			}
			add_ruler_modifier = {
				name = poor_industrial_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_industrial_education
			}
			add_ruler_modifier = {
				name = okay_industrial_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_industrial_education
			}
			add_good_industrial_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_industrial_education
			}
			add_best_industrial_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_diplomacy_education
			}
			add_ruler_modifier = {
				name = poor_diplomacy_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_diplomacy_education
			}
			add_ruler_modifier = {
				name = okay_diplomacy_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_diplomacy_education
			}
			add_good_diplomacy_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_diplomacy_education
			}
			add_best_diplomacy_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_intrigue_education
			}
			add_ruler_modifier = {
				name = poor_intrigue_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_intrigue_education
			}
			add_ruler_modifier = {
				name = okay_intrigue_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_intrigue_education
			}
			add_good_intrigue_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_intrigue_education
			}
			add_best_intrigue_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_trade_education
			}
			add_ruler_modifier = {
				name = poor_trade_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_trade_education
			}
			add_ruler_modifier = {
				name = okay_trade_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_trade_education
			}
			add_good_trade_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_trade_education
			}
			add_best_trade_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_colonial_education
			}
			add_ruler_modifier = {
				name = poor_colonial_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_colonial_education
			}
			add_ruler_modifier = {
				name = okay_colonial_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_colonial_education
			}
			add_good_colonial_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_colonial_education
			}
			add_best_colonial_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_martial_education
			}
			add_ruler_modifier = {
				name = poor_martial_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_martial_education
			}
			add_ruler_modifier = {
				name = okay_martial_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_martial_education
			}
			add_good_martial_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_martial_education
			}
			add_best_martial_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_naval_education
			}
			add_ruler_modifier = {
				name = poor_naval_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_naval_education
			}
			add_ruler_modifier = {
				name = okay_naval_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_naval_education
			}
			add_good_naval_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_naval_education
			}
			add_best_naval_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_logistics_education
			}
			add_ruler_modifier = {
				name = poor_logistics_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_logistics_education
			}
			add_ruler_modifier = {
				name = okay_logistics_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_logistics_education
			}
			add_good_logistics_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_logistics_education
			}
			add_best_logistics_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = poor_modern_army_education
			}
			add_ruler_modifier = {
				name = poor_modern_army_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = okay_modern_army_education
			}
			add_ruler_modifier = {
				name = okay_modern_army_education
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_ruler_flag = good_modern_army_education
			}
			add_good_modern_army_education = yes
		}
		else_if = {
			limit = {
				has_ruler_flag = best_modern_army_education
			}
			add_best_modern_army_education = yes
		}
		clr_ruler_flag = poor_clerical_education
		clr_ruler_flag = okay_clerical_education
		clr_ruler_flag = good_clerical_education
		clr_ruler_flag = best_clerical_education
		clr_ruler_flag = poor_administrative_education
		clr_ruler_flag = okay_administrative_education
		clr_ruler_flag = good_administrative_education
		clr_ruler_flag = best_administrative_education
		clr_ruler_flag = poor_scholastic_education
		clr_ruler_flag = okay_scholastic_education
		clr_ruler_flag = good_scholastic_education
		clr_ruler_flag = best_scholastic_education
		clr_ruler_flag = poor_industrial_education
		clr_ruler_flag = okay_industrial_education
		clr_ruler_flag = good_industrial_education
		clr_ruler_flag = best_industrial_education
		clr_ruler_flag = poor_diplomacy_education
		clr_ruler_flag = okay_diplomacy_education
		clr_ruler_flag = good_diplomacy_education
		clr_ruler_flag = best_diplomacy_education
		clr_ruler_flag = poor_intrigue_education
		clr_ruler_flag = okay_intrigue_education
		clr_ruler_flag = good_intrigue_education
		clr_ruler_flag = best_intrigue_education
		clr_ruler_flag = poor_trade_education
		clr_ruler_flag = okay_trade_education
		clr_ruler_flag = good_trade_education
		clr_ruler_flag = best_trade_education
		clr_ruler_flag = poor_colonial_education
		clr_ruler_flag = okay_colonial_education
		clr_ruler_flag = good_colonial_education
		clr_ruler_flag = best_colonial_education
		clr_ruler_flag = poor_martial_education
		clr_ruler_flag = okay_martial_education
		clr_ruler_flag = good_martial_education
		clr_ruler_flag = best_martial_education
		clr_ruler_flag = poor_naval_education
		clr_ruler_flag = okay_naval_education
		clr_ruler_flag = good_naval_education
		clr_ruler_flag = best_naval_education
		clr_ruler_flag = poor_logistics_education
		clr_ruler_flag = okay_logistics_education
		clr_ruler_flag = good_logistics_education
		clr_ruler_flag = best_logistics_education
		clr_ruler_flag = poor_modern_army_education
		clr_ruler_flag = okay_modern_army_education
		clr_ruler_flag = good_modern_army_education
		clr_ruler_flag = best_modern_army_education
	}
}