#Written by Dub
#I am not a great artist myself, so the event pictures are taken directly from the Nobility event pictures. If someone wishes to create some, I'd be grateful, but as it stands it is not my forté.
namespace = exarches_estate_events

country_event = { #1 Shattered [Root.GetExarchesName]
	id = exarches_estate_events.1
	title = "exarches_estate_events.1.t" 
	desc = "exarches_estate_events.1.d"
	picture = DIET_eventPicture
	
	trigger = {
		has_government_attribute = enables_exarches
		OR = {
			has_estate = estate_exarches
			any_country = {
				is_exarch_tag_and_exarch_of_root_trigger = yes
			}
		}
		NOT = {
			has_estate_influence_modifier = {
				estate = estate_exarches
				modifier = EST_VAL_EXARCH_LOWERED_MERCANTILISM
			}
		}
		NOT = {
			has_estate_influence_modifier = {
				estate = estate_exarches
				modifier = EST_VAL_EXARCH_NOT_LOWERED_MERCANTILISM
			}
		}
		mercantilism = 10
	}

	is_triggered_only = yes
	
	mean_time_to_happen = {
		days = 1
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 50
			}
		}
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 70
			}
		}
		modifier = {
			factor = 2.0
			mercantilism = 25
		}
		modifier = {
			factor = 2.0
			mercantilism = 50
		}
		modifier = {
			factor = 2.0
			mercantilism = 75
		}
	}
	
	option = { #Lower mercantilism
		name = "exarches_estate_events.1.a"
		ai_chance = { 
			factor = 50
		}
		
		add_mercantilism = -1
		if = {
			limit = {
				has_estate = estate_exarches
			}
			add_estate_loyalty = {
				estate = estate_exarches
				loyalty = 15
			}
			add_estate_influence_modifier = {
				estate = estate_exarches
				desc = EST_VAL_EXARCH_LOWERED_MERCANTILISM
				influence = 10
				duration = 3650
			}
		}
		if = {
			limit = {
				any_country = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
			}
			random_country = {
				limit = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
				add_liberty_desire = -15
			}
		}
		
	}
	option = { #Do not
		name = "exarches_estate_events.1.b"
		ai_chance = { 
			factor = 50
		}
		
		if = {
			limit = {
				has_estate = estate_exarches
			}
			add_estate_loyalty = {
				estate = estate_exarches
				loyalty = -10
			}
			add_estate_influence_modifier = {
				estate = estate_exarches
				desc = EST_VAL_EXARCH_NOT_LOWERED_MERCANTILISM
				influence = -10
				duration = 3650
			}
		}
		if = {
			limit = {
				any_country = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
			}
			every_country = {
				limit = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
				add_liberty_desire = 10
			}
		}
	}
}

country_event = { #2 The [Root.GetExarchesName] are worried about military recruitment
	id = exarches_estate_events.2
	title = "exarches_estate_events.2.t" 
	desc = "exarches_estate_events.2.d"
	picture = DIET_eventPicture
	
	trigger = {
		has_government_attribute = enables_exarches
		OR = {
			has_estate = estate_exarches
			any_country = {
				is_exarch_tag_and_exarch_of_root_trigger = yes
			}
		}
		NOT = {
			has_estate_influence_modifier = {
				estate = estate_exarches
				modifier = EST_VAL_EXARCH_AGREED_TO_DECREASE_RECRUITMENT
			}
		}
		NOT = {
			has_estate_influence_modifier = {
				estate = estate_exarches
				modifier = EST_VAL_EXARCH_DISAGREED_TO_DECREASE_RECRUITMENT
			}
		}
		NOT = { manpower_percentage = 0.25 }
	}

	is_triggered_only = yes
	
	mean_time_to_happen = {
		days = 1
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 50
			}
		}
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 70
			}
		}
		modifier = {
			factor = 2.0
			NOT = { manpower_percentage = 0.15 }
		}
		modifier = {
			factor = 2.0
			NOT = { manpower_percentage = 0.5 }
		}
		modifier = {
			factor = 2.0
			NOT = { manpower_percentage = 0.1 }
		}
	}
	
	option = { #Promise not to draft [Root.GetExarchesName] troops
		name = "exarches_estate_events.2.a"
		ai_chance = { 
			factor = 50
		}
		
		add_country_modifier = {
			name = decreased_drafting
			duration = 3650
		}
		if = {
			limit = {
				has_estate = estate_exarches
			}
			add_estate_loyalty = {
				estate = estate_exarches
				loyalty = 15
			}
			add_estate_influence_modifier = {
				estate = estate_exarches
				desc = EST_VAL_EXARCH_AGREED_TO_DECREASE_RECRUITMENT
				influence = 10
				duration = 3650
			}
		}
		if = {
			limit = {
				any_country = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
			}
			random_country = {
				limit = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
				add_liberty_desire = -15
			}
		}
	}
	option = { #Disregard their opinions
		name = "exarches_estate_events.2.b"
		ai_chance = { 
			factor = 50
		}
		
		if = {
			limit = {
				has_estate = estate_exarches
			}
			add_estate_loyalty = {
				estate = estate_exarches
				loyalty = -10
			}
			add_estate_influence_modifier = {
				estate = estate_exarches
				desc = EST_VAL_EXARCH_DISAGREED_TO_DECREASE_RECRUITMENT
				influence = -10
				duration = 3650
			}
		}
		if = {
			limit = {
				any_country = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
			}
			every_country = {
				limit = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
				add_liberty_desire = 10
			}
		}
	}
}

country_event = { #3 The [Root.GetExarchesName] wish for more lenient taxation of their populace
	id = exarches_estate_events.3
	title = "exarches_estate_events.3.t" 
	desc = "exarches_estate_events.3.d"
	picture = DIET_eventPicture
	
	trigger = {
		has_government_attribute = enables_exarches
		OR = {
			has_estate = estate_exarches
			any_country = {
				is_exarch_tag_and_exarch_of_root_trigger = yes
			}
		}
		NOT = {
			has_estate_influence_modifier = {
				estate = estate_exarches
				modifier = EST_VAL_EXARCH_LENIENT_TAXATION
			}
		}
		NOT = {
			has_estate_influence_modifier = {
				estate = estate_exarches
				modifier = EST_VAL_EXARCH_NO_LENIENT_TAXATION
			}
		}
		OR = {
			NOT = { years_of_income = 1.0 }
			num_of_loans = 1
		}
	}

	is_triggered_only = yes
	
	mean_time_to_happen = {
		days = 1
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 50
			}
		}
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 70
			}
		}
		modifier = {
			factor = 2.0
			OR = {
				NOT = { years_of_income = 0.5 }
				num_of_loans = 3
			}
			
		}
		modifier = {
			factor = 2.0
			OR = {
				NOT = { years_of_income = 0.25 }
				num_of_loans = 5
			}
		}
		modifier = {
			factor = 2.0
			OR = {
				NOT = { years_of_income = 0.1 }
				num_of_loans = 10
			}
		}
	}
	
	option = { #Promise the [Root.GetExarchesName] to lower taxes
		name = "exarches_estate_events.3.a"
		ai_chance = { 
			factor = 50
		}
		
		add_country_modifier = {
			name = tax_income_loss
			duration = 7300
		}
		if = {
			limit = {
				has_estate = estate_exarches
			}
			add_estate_loyalty = {
				estate = estate_exarches
				loyalty = 15
			}
			add_estate_influence_modifier = {
				estate = estate_exarches
				desc = EST_VAL_EXARCH_LENIENT_TAXATION
				influence = 10
				duration = 7300
			}
		}
		if = {
			limit = {
				any_country = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
			}
			random_country = {
				limit = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
				add_liberty_desire = -15
			}
		}
	}
	option = { #Tax them even harder!
		name = "exarches_estate_events.3.b"
		ai_chance = { 
			factor = 50
		}
		
		add_country_modifier = {
			name = tax_income_boost
			duration = 7300
		}
		if = {
			limit = {
				has_estate = estate_exarches
			}
			add_estate_loyalty = {
				estate = estate_exarches
				loyalty = -10
			}
			add_estate_influence_modifier = {
				estate = estate_exarches
				desc = EST_VAL_EXARCH_NO_LENIENT_TAXATION
				influence = -10
				duration = 7300
			}
		}
		if = {
			limit = {
				any_country = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
			}
			every_country = {
				limit = {
					is_exarch_tag_and_exarch_of_root_trigger = yes
				}
				add_liberty_desire = 10
			}
		}
	}
}

country_event = { #4 The [Root.GetExarchesName] take issue with the current monarch!
	id = exarches_estate_events.4
	title = "exarches_estate_events.4.t" 
	desc = "exarches_estate_events.4.d"
	picture = NOBLE_ESTATE_TAKE_OVER_eventPicture
	
	trigger = {
		has_government_attribute = enables_exarches
		OR = {
			has_estate = estate_exarches
			any_country = {
				is_exarch_tag_and_exarch_of_root_trigger = yes
			}
		}
		OR = { #Incompetent ruler basically
			NOT = { legitimacy = 30 }
			NOT = { adm = 2 }
			NOT = { dip = 2 }
			NOT = { mil = 2 }
		}
		OR = {
			AND = {
				has_estate = estate_exarches
				NOT = { #Should not be loyal for this event to fire.
					estate_loyalty = {
						estate = estate_exarches
						loyalty = 60
					}
				}
			}
			any_country = {
				is_exarch_tag_and_exarch_of_root_trigger = yes
				liberty_desire = 50
			}
		}
		
	}

	is_triggered_only = yes
	
	mean_time_to_happen = {
		days = 1
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 50
			}
		}
		modifier = {
			factor = 2.0
			estate_influence = {
				estate = estate_exarches
				influence = 70
			}
		}
		modifier = {
			factor = 2.0
			NOT = { legitimacy = 15 }
		}
		modifier = {
			factor = 2.0
			NOT = { legitimacy = 5 }
		}
		modifier = {
			factor = 2.0
			NOT = { adm = 1 }
		}
		modifier = {
			factor = 2.0
			NOT = { dip = 1 }
		}
		modifier = {
			factor = 2.0
			NOT = { mil = 1 }
		}
	}
	
	option = { #They'll pay for this!
		name = "exarches_estate_events.4.a"
		ai_chance = { 
			factor = 100
		}
		
		add_estate_loyalty = {
			estate = estate_exarches
			loyalty = -10
		}
		capital_scope = {
			random_neighbor_province = {
				if = {
					limit = {
						has_estate_privilege = estate_exarches_dynastic_exarches
					}
					spawn_rebels = {
						type = pretender_rebels
						size = 4
						leader_dynasty = ROOT
					}
				}
				else = {
					spawn_rebels = {
						type = pretender_rebels
						size = 4
					}
				}
			}
		}
		random_owned_province = {
			limit = {
				development = 10
			}
			if = {
				limit = {
					has_estate_privilege = estate_exarches_dynastic_exarches
				}
				spawn_rebels = {
					type = pretender_rebels
					size = 3
					leader_dynasty = ROOT
				}
			}
			else = {
				spawn_rebels = {
					type = pretender_rebels
					size = 3
				}
			}
		}
		random_owned_province = {
			limit = {
				development = 10
			}
			if = {
				limit = {
					has_estate_privilege = estate_exarches_dynastic_exarches
				}
				spawn_rebels = {
					type = pretender_rebels
					size = 2
					leader_dynasty = ROOT
				}
			}
			else = {
				spawn_rebels = {
					type = pretender_rebels
					size = 2
				}
			}
		}
		random_owned_province = {
			limit = {
				development = 10
			}
			if = {
				limit = {
					has_estate_privilege = estate_exarches_dynastic_exarches
				}
				spawn_rebels = {
					type = pretender_rebels
					size = 1
					leader_dynasty = ROOT
				}
			}
			else = {
				spawn_rebels = {
					type = pretender_rebels
					size = 1
				}
			}
		}
	}
}

province_event = { #42 Mad Exarchos, mon
	id = exarches_estate_events.42
	title = exarches_estate_events.42.t
	desc = exarches_estate_events.42.d
	picture = NOBLE_ESTATE_DEMANDS_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = exarches_estate_events.42.a #Yes
	}
}

# The Exarches break free!
country_event = {
	id = exarches_estate_events.69
	title = exarches_estate_events.69.t
	desc = exarches_estate_events.69.d
	picture = NOBLE_ESTATE_TAKE_OVER_eventPicture
	
	major = yes
	is_triggered_only = yes
	
	immediate = {
		set_country_flag = exarch_estate_triggered
	}
	option = {
		name = exarches_estate_events.69.a	
		create_independent_estate = {
			estate = estate_exarches
			government = monarchy
			government_reform = exarchate_reform
			custom_national_ideas = exarchate_ideas
		}
		remove_government_reform = exarch_system_reform
	}
	
	option = {
		name = exarches_estate_events.69.b
		trigger = { 
			ai = no 
			
		}
		create_independent_estate = {
			estate = estate_exarches
			government = monarchy
			government_reform = exarchate_reform
			custom_national_ideas = exarchate_ideas
			play_as = yes
		}
		remove_government_reform = exarch_system_reform #Will remove the revoke thing as well.
	}
	
}
