country_decisions = {

	restore_byzantine_empire = {
		major = yes
		potential = {
			OR = {
				was_never_end_game_tag_trigger = yes
				tag = MOE #To allow a Byzantium that has been forced to become Morea to still form it.
			}
			normal_or_historical_nations = yes
			NOT = { has_country_flag = formed_byzantium_flag }
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			OR = {
				is_free_or_tributary_trigger = yes
				ai = no
			}
			NOT = { exists = BYZ }
			NOT = { exists = GRE }
			NOT = { tag = HLR }
			NOT = { tag = ROM }
			#Byz_resurgence added
			NOT = { exists = ROM }
			#Byz_resurgence added
			NOT = { tag = LAE }
			NOT = { tag = TUR }
			OR = {
				AND = {
					culture_group = byzantine
					NOT = { primary_culture = goths }
				}
				AND = {
					has_idea = MFA_byzantine_claimants
					dynasty = "Palaiologos"
				}
			}
			OR = {
				religion = orthodox
				has_idea = MFA_byzantine_claimants
			}
			#Byz_resurgence adjusted: Theme system requirements.
			num_of_owned_provinces_with = {
				value = 5
				OR = {
					province_group = byz_deny_ottoman_access_provinces
					province_group = byz_reconquer_ottoman_greece_provinces
					province_group = byz_reconquer_west_anatolia_provinces
					province_group = byz_reclaim_anatolia_provinces
					province_group = byz_no_latins_in_greece_provinces
					province_group = byz_retake_greek_islands_provinces
				}
				is_core = ROOT
			}	#Requires at least 5 provinces to see the decision
		}
		provinces_to_highlight = {
			OR = {
				province_group = byz_deny_ottoman_access_provinces
				province_group = byz_reconquer_ottoman_greece_provinces
				province_group = byz_reconquer_west_anatolia_provinces
				province_group = byz_reclaim_anatolia_provinces
				province_group = byz_no_latins_in_greece_provinces
				province_group = byz_retake_greek_islands_provinces
			}
			NOT = { owned_by = ROOT }
		}
		allow = {
			owns_core_province = 148 # Thessaloniki
			owns_core_province = 151 # Constantinople
			#This replaces the various specific provinces required, leaving Constantinople and Thessaloniki, though, as the two primary cities of the empire
			#Byz_resurgence adjusted: Adjusted to that of the Theme System requirements.
			calc_true_if = {
				desc = byzantine_empire_provinces
				all_owned_province = {
					OR = {
						province_group = byz_deny_ottoman_access_provinces #10
						province_group = byz_reconquer_ottoman_greece_provinces #19
						province_group = byz_reconquer_west_anatolia_provinces #13
						province_group = byz_no_latins_in_greece_provinces #21
						province_group = byz_retake_greek_islands_provinces #13
						province_group = byz_reclaim_anatolia_provinces #45
					}
				}
				amount = 75 #Need to recover at least 75 provinces in Greece + Anatolia. This makes sense because we have 76 provinces alone in Greece+West Anatolia, for a total of 121 provinces overall.
			}
			is_at_war = no
			is_free_or_tributary_trigger = yes
			is_nomad = no
		}
		effect = {
			151 = {
				move_capital_effect = yes
			}
			change_tag = BYZ
			on_change_tag_effect = yes
			restore_country_name = yes
			# BT removed below, because makes no sense?
			#if = {
			#	limit = {
			#		NOT = { culture_group = byzantine }
			#		NOT = { accepted_culture = greek }
			#	}
			#	add_accepted_culture = greek
			#}
			#Byz_resurgence adjusted: Adjusted to the same claims granted upon reestablishing Theme System.
			custom_tooltip = byzantine_claims_tooltip
			hidden_effect = {
				every_province = {
					limit = {
						NOT = { owned_by = ROOT }
						OR = {
							province_group = byz_deny_ottoman_access_provinces
							province_group = byz_reconquer_ottoman_greece_provinces
							province_group = byz_reconquer_west_anatolia_provinces
							province_group = byz_reclaim_anatolia_provinces
							province_group = byz_no_latins_in_greece_provinces
							province_group = byz_retake_greek_islands_provinces
						}
					}
					add_permanent_claim = BYZ
				}
			}
			random_owned_province = {
				limit = { culture = greek }
				add_base_tax = 1
			}
			random_owned_province = {
				limit = { culture = greek }
				add_base_tax = 1
			}
			add_country_modifier = {
				name = "centralization_modifier"
				duration = 7300
			}
			add_prestige = 25			#10 to 25 prestige, this is quite an accomplishment -Draiocht
			BYZ = {
				add_core = 151 # Constantinople
				change_primary_culture = greek			#Culture turns to greek now, instead of BYZ changing to culture. Works better for events, and represents that standard 'greek' is whoever controls Constantinople
			}
			if = {
				limit = {
					is_part_of_hre = yes
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = { # BT
				limit = {
					NOT = { has_global_flag = constantinople_restored }
				}
				151 = {
					add_base_tax = 2
					add_base_production = 2
					add_base_manpower = 1
					#rename_capital = Constantinople
					if = {
						limit = { NOT = { culture = greek } }
						change_culture = greek
					}
				}
				set_global_flag = constantinople_restored
			}
			remove_non_electors_emperors_from_empire_effect = yes
			if = {
				limit = { has_global_flag = hagia_sophia_now_mosque }
				clr_global_flag = hagia_sophia_now_mosque
				show_ambient_object = hagia_sophia
				hide_ambient_object = hagia_sophia_minarets
			}
			if = {
				limit = { NOT = { government = monarchy } }
				change_government = monarchy
			}
			if = {
				limit = { has_not_locked_first_tier_reform = yes }
				add_government_reform = byzantine_autocracy_reform
			}
			set_government_rank = 3
			swap_ideas = yes
			set_country_flag = formed_byzantium_flag
			
			if = {
				limit = {
					has_country_flag = BYZ_accepted_ottoman_threat
				}
				clr_country_flag = BYZ_accepted_ottoman_threat 
			}
			
			#####################
			#Mission shenanigans#
			#####################
			
			#Completed missions
			hidden_effect = { #Realistically, you should have all of these lands upon restoring the Byzantine Empire. If not, you've gotten claims for them as part of the formation.
				complete_mission = byz_gather_alliances
				complete_mission = byz_turn_the_tide
				complete_mission = byz_deny_ottoman_access
				complete_mission = byz_reconquer_ottoman_greece
				complete_mission = byz_question_of_schismatics
				give_permaclaims_for_mission = { mission = byz_safeguard_balkan_border } #Missed this because they aren't granted from the nation formation and are granted by one of the above completed missions.
			}
			hidden_effect = { #Additional missions if you've completed certain missions, and claims as a result of them.
				if = { #West Anatolia
					limit = {
						mission_completed = tre_reconquer_west_anatolia
					}
					complete_mission = byz_reconquer_west_anatolia
				}
				if = { #Reclaim Anatolia
					limit = {
						mission_completed = tre_reclaim_anatolia
					}
					complete_mission = byz_reclaim_anatolia
				}
				if = { #Northern Allies
					limit = {
						mission_completed = tre_northern_allies
					}
					complete_mission = byz_northern_chersonese
				}
				if = { #Lesser Armenia
					limit = {
						mission_completed = tre_conquer_lesser_armenia
					}
					complete_mission = byz_reconquer_lesser_armenia
					give_permaclaims_for_mission = { mission = byz_conquer_armenia_major }
					give_permaclaims_for_mission = { mission = byz_subjugate_lazica }
				}
				if = { #Restore the Empire
					limit = {
						mission_completed = tre_restore_byzantine_empire
					}
					complete_mission = byz_no_latins_in_greece
					complete_mission = byz_expand_naval_dominance
					complete_mission = byz_retake_greek_islands
					give_permaclaims_for_mission = { mission = byz_reconquer_albania }
					give_permaclaims_for_mission = { mission = byz_gain_foothold_in_italy }
				}
			}
			swap_non_generic_missions = yes #Putting missions last because otherwise I'm sure things will break.
		}
		ai_will_do = {
			factor = 1
		}
	}
	
}
