restore_european_union_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/found_european_union.dds"
	}
	desc = restore_european_union_decision_desc
	selection_tooltip = restore_european_union_decision_tooltip
	decision_group_type = major

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_playable_character = yes
		OR = {
			culture = { has_cultural_pillar = heritage_brythonic }
			culture = { has_cultural_pillar = heritage_goidelic }
			culture = { has_cultural_pillar = heritage_anglo_frisian }
			culture = { has_cultural_pillar = heritage_french }
			culture = { has_cultural_pillar = heritage_mosellic }
			culture = { has_cultural_pillar = heritage_west_germanic }
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_restored_european_union
			}
		}
		OR = {
			government_has_flag = government_is_feudal
			government_has_flag = government_is_republic
			government_has_flag = government_is_clan
			has_government = administrative_government
		}
	}

	is_valid = {
		prestige_level >= max_prestige_level

		completely_controls = title:d_meath
		completely_controls = title:d_london
		completely_controls = title:d_ile_de_france
		completely_controls = title:d_toledo
		completely_controls = title:d_beja
		completely_controls = title:d_brabant
		completely_controls = title:d_holland
		completely_controls = title:d_luxembourg
		completely_controls = title:d_transjurania
		completely_controls = title:d_latium
		completely_controls = title:d_ostmark
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
	}

	effect = {
		custom_tooltip = restore_european_union_decision_effect_tooltip
		#Create Roman Empire, shift dejure/history/laws, destroy e_byzantium.


		hidden_effect = {
			every_held_title = { #Should shift all dejure of all Empires owned at the time.
				limit = {
					tier = tier_empire
				}
				every_in_de_jure_hierarchy = {
					limit = {
						tier = tier_kingdom
					}
					set_de_jure_liege_title = title:e_european_union
					
				}
			}
			every_held_title = { #Completely Controlled Kingdoms as well.
				limit = {
					tier = tier_kingdom
					root = { completely_controls = prev }
				}
				set_de_jure_liege_title = title:e_european_union
			}
		}
		get_title = title:e_european_union
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
			add_claim_on_loss = no
		}
		resolve_title_and_vassal_change = scope:change
		if = { # Move your Title MaAs to your new title if you have any
			limit = {
				government_has_flag = government_is_administrative
				primary_title = {
					any_title_maa_regiment = { count >= 1 }
				}
			}
			hidden_effect = {
				primary_title = { transfer_title_maa_ownership = title:e_european_union }
			}
		}
		hidden_effect = { set_primary_title_to = title:e_european_union }
		every_held_title = { #Should destroy all other Empires owned at the time.
			limit = {
					tier = tier_empire
				NOT = { this = title:e_european_union }
			}
			root = { destroy_title = prev }
		}
		if = { #Automatically move capital to Constantinople, unless it's been set to Rome.
			limit = {
				NOT = { capital_county = { this = title:c_brabant } }
			}
			hidden_effect = {
				if = { #Usurp if not held personally.
					limit = {
						NOT = { this = title:c_brabant.holder }
					}
					create_title_and_vassal_change = {
						type = returned
						save_scope_as = change
						add_claim_on_loss = no
					}
					title:c_brabant = {
						change_title_holder = {
							holder = root
							change = scope:change
						}
					}
					resolve_title_and_vassal_change = scope:change
				}
			}
			root = { set_realm_capital = title:c_brabant }
		}
		#hidden_effect = {
		#	add_character_flag = flag_restorer_of_rome #used for Eulogy.
		#	title:e_roman_empire = {
		#		set_variable = rome_was_restored_by_byzantium
		#	}
		#}
		#trigger_event = roman_restoration.0001 ###to do later
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_restored_european_union
			}
			set_global_variable = {
				name = flag_restored_european_union
				value = root
			}
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}


form_the_kingdom_of_rhineland_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_found_kingdom.dds"
	}
	decision_group_type = major

	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = form_the_kingdom_of_rhineland_decision_desc
	selection_tooltip = form_the_kingdom_of_rhineland_decision_tooltip

	is_shown = {
		is_playable_character = yes
		highest_held_title_tier <= tier_duchy
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_formed_kingdom_of_rhineland
			}
		}	
		OR = {
			culture = culture:palatine
			culture = culture:rhinelander
			culture = culture:turkisch
			culture = culture:elsasse
			culture = culture:kleverlandish 			
		}
	}

	is_valid = {
		top_liege = this
		has_title = title:d_lower_lorraine
		has_title = title:d_cologne
		has_title = title:d_trier
		has_title = title:c_mainz
		completely_controls = title:d_lower_lorraine
		completely_controls = title:d_cologne
		completely_controls = title:d_trier
	}
	
	is_valid_showing_failures_only = {
		is_landed = yes
	}

	effect = {
		gain_heroic_legend_seed_tooltip_effect = yes
		save_scope_as = founder
		culture = { save_scope_as = founder_culture }
		title:k_rhineland = { save_scope_as = k_rhineland }
		title:d_trier = { save_scope_as = d_trier }
		title:d_cologne = { save_scope_as = d_cologne }		
		title:d_lower_lorraine = { save_scope_as = d_lower_lorraine }
		title:d_alsace = { save_scope_as = d_alsace }
		title:c_bitburg = { save_scope_as = c_bitburg }
		title:c_nassau = { save_scope_as = c_nassau }		
		create_title_and_vassal_change = {
			type = created
			save_scope_as = change
		}
		title:k_rhineland = {
			change_title_holder = {
				holder = scope:founder
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		add_prestige = major_prestige_gain
		custom_tooltip = form_the_kingdom_of_rhineland_decision_decision.tt.form_rhineland
		trigger_event = iberia_north_africa.0131
		# De jure shifts.
		## Take care of the preferred empire.
		if = {
			limit = { NOT = { title:k_rhineland.empire = title:d_lower_lorraine.empire } }
			title:k_rhineland = { set_de_jure_liege_title = title:d_lower_lorraine.empire }
		}
		## The heartlands drift over.
		title:d_lower_lorraine = { set_de_jure_liege_title = title:k_rhineland }
		## Various neighbouring duchies can be preemptively integrated.
		if = {
			limit = { completely_controls = title:d_alsace }
			title:d_alsace = { set_de_jure_liege_title = title:k_rhineland }
		}
		else = { custom_tooltip = form_the_kingdom_of_rhineland_decision.tt.drift.d_alsace }
		if = {
			limit = { completely_controls = title:c_bitburg }
			title:c_bitburg = { set_de_jure_liege_title = title:d_trier }
		}
		else = { custom_tooltip = form_the_kingdom_of_rhineland_decision.tt.drift.c_bitburg }
		if = {
			limit = { completely_controls = title:c_nassau }
			title:d_navarra = { set_de_jure_liege_title = title:d_lower_lorraine }
		}
		else = { custom_tooltip = form_the_kingdom_of_rhineland_decision.tt.drift.c_nassau }
		# Once per game.
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:flag_formed_kingdom_of_rhineland
		}
		# Note this for books and such.
		set_global_variable = {
			name = flag_formed_kingdom_of_rhineland
			value = scope:founder
		}
	}

	cost = {
		gold = {
			# Since we want this to happen, it free for the AI...
			value = 0
			# ... but costs for players
			if = {
				limit = {
					has_treasury = no
					is_ai = no
				}
				add = 200
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
					is_ai = no
				}
				add = 200
			}
		}
	}

	ai_potential = {
		any_held_title = { 
			this = title:d_lower_lorraine 
		}
	}

	ai_will_do = { base = 100 }
}