# Create the Province of Dacia
create_the_province_of_dacia_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_dacia.dds"

	desc = create_the_province_of_dacia_decision_desc
	selection_tooltip = create_the_province_of_dacia_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes

		OR = {
			any_vassal = {
				has_title = title:k_daciae
				has_title = title:k_serbia
			}
			any_vassal = {
				has_title = title:k_pannonia
			}
			has_title = title:k_daciae
			has_title = title:k_pannonia
			has_title = title:k_serbia
		}
		OR = {
			has_title = title:e_byzantium
			has_title = title:e_western_roman_empire
			has_title = title:e_roman_empire
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:created_province_of_dacia
			}
		}
		
	}

	is_valid = {
		prestige_level >= medium_prestige_level
		OR = {
			religion = religion:christianity_religion
			religion = religion:hellenism_religion
			is_greek_or_roman = yes
		}

		completely_controls_region = custom_roman_dacia
		
	}

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

	effect = {
		create_title_and_vassal_change = {
			type = created
			save_scope_as = title_change
			add_claim_on_loss = no
		}
		title:k_roman_dacia = {
			save_scope_as = title_k_roman_dacia
		}
		title:k_roman_dacia = {
			change_title_holder = {
				holder = root
				change = scope:title_change
			}
			save_scope_as = title_k_roman_dacia
		}
		resolve_title_and_vassal_change = scope:title_change

		hidden_effect = {
			title:d_oltenia = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:d_transylvania = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:d_temes = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:d_bihar = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:k_roman_dacia = {
				set_de_jure_liege_title = root.primary_title
			}
			if = {
				limit = {
				game_start_date >= 867.1.1
			}
			title:d_vidin = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:d_macva = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:d_rashka = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			title:d_duklja = {
				set_de_jure_liege_title = title:k_roman_dacia
			}
			
			destroy_title = title:k_serbia
			destroy_title = title:k_bulgaria
	

				
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:created_province_of_dacia
				}
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}


#Expand Thrace
expand_the_diocese_of_thrace_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	desc = expand_the_diocese_of_thrace_decision_desc
	selection_tooltip = expand_the_diocese_of_thrace_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date >= 867.1.1
		OR = {
			has_title = title:e_byzantium
			has_title = title:e_western_roman_empire
			has_title = title:e_roman_empire
		}

		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:expand_the_diocese_of_thrace
				game_start_date >= 867.1.1
				}
			}
		}

	is_valid = {
		prestige_level >= medium_prestige_level

		completely_controls_region = custom_thrace
	}

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

	cost = {
		gold = {
			value = medium_gold_value
		}
		prestige = {
			value = major_prestige_value
		}
	}

	effect = {
		hidden_effect = {
			dejure_shift_expand_thrace_effect = yes

			}
			resolve_title_and_vassal_change = scope:title_change

			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:expand_the_diocese_of_thrace
			}
		}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}


#Recreate Macedon
recreate_the_diocese_of_macedon_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	desc = recreate_the_diocese_of_macedon_decision_desc
	selection_tooltip = recreate_the_diocese_of_macedon_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date >= 867.1.1
		OR = {
			has_title = title:e_byzantium
			has_title = title:e_western_roman_empire
			has_title = title:e_roman_empire
		}

		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:recreate_the_diocese_of_macedon
				game_start_date >= 867.1.1
				}
			}
		}

	is_valid = {
		prestige_level >= medium_prestige_level

		completely_controls_region = custom_macedon
	}

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

	cost = {
		gold = {
			value = medium_gold_value
		}
		prestige = {
			value = major_prestige_value
		}
	}

	effect = {
		hidden_effect = {
			dejure_shift_expand_macedon_effect = yes

			}
			resolve_title_and_vassal_change = scope:title_change

			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:recreate_the_diocese_of_macedon
			}
		}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

#Integrate Aegyptus
integrate_aegyptus_to_rome_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	desc = integrate_aegyptus_to_rome_decision_desc
	selection_tooltip = integrate_aegyptus_to_rome_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date >= 867.1.1
		OR = {
			has_title = title:e_byzantium
			has_title = title:e_western_roman_empire
			has_title = title:e_roman_empire
		}

		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:integrate_aegyptus_to_rome
				game_start_date >= 867.1.1
				}
			}
		}

	is_valid = {
		prestige_level >= medium_prestige_level

		completely_controls_region = ghw_region_egypt
	}

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

	cost = {
		gold = {
			value = medium_gold_value
		}
		prestige = {
			value = major_prestige_value
		}
	}

	effect = {
		hidden_effect = {
			dejure_shift_integrate_aegyptus_effect = yes

			}
			resolve_title_and_vassal_change = scope:title_change

			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:integrate_aegyptus_to_rome
			}
		}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}


#Restore Orientis
restore_orientis_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	desc = restore_orientis_decision_desc
	selection_tooltip = restore_orientis_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date >= 867.1.1
		OR = {
			has_title = title:e_byzantium
			has_title = title:e_western_roman_empire
			has_title = title:e_roman_empire
		}

		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restore_orientis_decision
				game_start_date >= 867.1.1
				}
			}
		}

	is_valid = {
		prestige_level >= medium_prestige_level

		has_title = title:k_jerusalem
		has_title = title:k_syria
		has_title = title:k_cyprus
	}

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

	cost = {
		gold = {
			value = medium_gold_value
		}
		prestige = {
			value = major_prestige_value
		}
	}

	effect = {
		hidden_effect = {
			dejure_shift_restore_orientis_effect = yes

			}
			resolve_title_and_vassal_change = scope:title_change

			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restore_orientis_decision
			}
		}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

embrace_latin_language_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"
	sort_order = 80

	ai_check_interval = 120

	cooldown = { years = 5 }
	
	desc = embrace_latin_language_decision_desc
	major = yes

	is_shown = {
		culture.culture_head = root
		culture = { has_cultural_pillar = heritage_latin }
		NOT = { culture = { has_cultural_pillar = language_latin } }
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		highest_held_title_tier > 3 #Only Kings and Emperors
		# There must be enough Jewish counties in your realm to declare the exile "over"
		custom_description = {
			text = at_least_10_latin_counties_tt
			any_sub_realm_county = {
				count >= 10
				culture = root.culture
			}
		}
		OR = {
			has_title = title:e_roman_empire
			has_title = title:e_western_roman_empire
			custom_tooltip = {
				text = hof_exists_tt
			}
		}
	}

	effect = {
		random_culture_global = {
			limit = {
				has_same_culture_language = root.culture
			}
			save_scope_as = target_other_culture
		}
		custom_tooltip = {
			text = switch_to_latin_language_tt
			culture = {
				set_culture_pillar = language_latin
			}
		}
	}

	cost = {
		prestige = {
			value = massive_prestige_value
		}
	}

	ai_potential = {
	}

	ai_will_do = {
		base = 100

		modifier = {
			factor = 0
		}
	}
}

form_the_hre_TFE = {
	picture = "gfx/interface/illustrations/decisions/decision_emperor_apotheosis.dds"
	desc = form_the_hre_TFE_desc
	selection_tooltip = form_the_hre_TFE_tooltip
	major = yes

	ai_check_interval = 250

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date <= 866.1.1
		highest_held_title_tier >= tier_kingdom
		religion = religion:christianity_religion
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_the_hre_TFE
			}
		}
		AND = {
			title:e_western_roman_empire = {
				is_title_created = no
			}
			title:e_roman_empire = {
				is_title_created = no
			}
		}
		capital_county.title_province = {
			geographical_region = world_europe_west
		}
		NOT = {
			has_title = title:e_byzantium
		}
		NOT = {
			culture = {
				has_cultural_pillar = heritage_latin
			}
		}
	}

	is_valid = {
		is_independent_ruler = yes
		highest_held_title_tier >= tier_kingdom
		religion = religion:christianity_religion
		realm_size >= 60
		completely_controls = title:c_ravenna
		custom_description = {
			text = form_the_hre_TFE_trigger_01
			trigger_if = {
				limit = {
					title:e_byzantium = {
						is_title_created = yes
					}
				}
				title:e_byzantium.holder = {
					any_realm_county = {
						count <= form_hre_TFE_county_trigger
						title_province = { geographical_region = form_the_hre_TFE_ere_region }
					}
				}
			}
		}
		custom_description = {
			text = form_the_hre_TFE_trigger_02
			NOT = {
				any_independent_ruler = {
					AND = {
						is_landed = yes
						capital_county.title_province ?= {
							geographical_region = world_europe_west
						}
						highest_held_title_tier >= tier_kingdom
						current_military_strength > form_hre_TFE_strength_trigger
					}
				}
			}
		}
		
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		is_independent_ruler = yes
	}

	effect = {
		give_nickname = nick_the_great
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:form_the_hre_TFE
		}

		show_as_tooltip = {
			restore_holy_roman_empire_decision_scripted_effect = yes
		}
		save_scope_as = founder
		faith.religious_head = { save_scope_as = founder_hof }
		if = {
			limit = {
				faith.religious_head = { is_landed = yes }
			}
			faith.religious_head.capital_province = { save_scope_as = ceremony_locale }
		}
		else = {
			capital_province = { save_scope_as = ceremony_locale }
		}
		trigger_event = {
			id = tfe_title_event.0010
		}
		#Notify other players.
		every_player = {
			limit = {
				NOT = { this = root }
				is_within_diplo_range = { CHARACTER = root }
			}
			trigger_event = tfe_title_event.0011
		}
		if = {
			limit = {
				is_ai = no
				NOT = { exists = global_var:restore_holy_roman_empire_decision  }
			}
			set_global_variable = {
				name = restore_holy_roman_empire_decision
				value = root
			}
		}
		# Assign Dynamic Prince-Electors
		hidden_effect = {
			if = {
				limit = { has_global_variable_list = hre_elector_list }
				clear_global_variable_list = hre_elector_list
			}
			while = {
				count = 7
				random_vassal = {
					limit = {
						capital_province.empire = title:e_hre # must be de-jure vassal of empire
						OR = { # prince-bishopric or duchy
							AND = {
								government_has_flag = government_is_theocracy
								primary_title.tier >= tier_county
							}
							primary_title.tier >= tier_duchy
						}
						NOT = { # not already selected
							is_target_in_global_variable_list = {
								name = hre_elector_list
								target = primary_title
							}
						}
					}
					weight = {
						modifier = { # major vassals heavily weighted
							factor = 10
							is_powerful_vassal = yes
						}
						modifier = { # same culture as emperor preferred
							factor = 4
							culture = root.culture
						}
						modifier = { # we don't mind going outside Germania, but prefer it
							factor = 1.5
							trigger = { exists = primary_title.title_province }
							primary_title.title_province.barony = {
								OR = {
									target_is_de_jure_liege_or_above = title:k_bavaria
									target_is_de_jure_liege_or_above = title:k_bohemia
									target_is_de_jure_liege_or_above = title:k_east_francia
									target_is_de_jure_liege_or_above = title:k_frisia
									target_is_de_jure_liege_or_above = title:k_lotharingia
									target_is_de_jure_liege_or_above = title:k_pomerania
								}
							}
						}
						modifier = { # we want at least 3 theocracies ideally
							factor = 10
							any_in_global_list = {
								variable = hre_elector_list
								count < 3
								holder = { government_has_flag = government_is_theocracy }
							}
							government_has_flag = government_is_theocracy
						}
						modifier = { # 3 is enough theocracies unless we can't find feudal
							factor = 0.1
							any_in_global_list = {
								variable = hre_elector_list
								count >= 3
								holder = { government_has_flag = government_is_theocracy }
							}
							government_has_flag = government_is_theocracy
						}
					}
					add_to_global_variable_list = {
						name = hre_elector_list
						target = primary_title
					}
				}
			}
			hre_elector_list_save_effect = yes # saves list scopes to title as variables for tooltip
		}
		
	}

	ai_potential = {
		always = yes
	}

	cost = {
		gold = 250
	}

	ai_will_do = {
		base = 100
	}
}

concession_of_italy = {
	picture = "gfx/interface/illustrations/decisions/decision_germanic_warrior.dds"
	desc = concession_of_italy_decision_desc
	selection_tooltip = concession_of_italy_decision_tooltip
	major = yes
	ai_check_interval = 5
	cooldown = { years = 5 }

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_independent_ruler = yes
		game_start_date = 476.9.4
		NOT = { has_title = title:e_italy }
		AND = {
			NOT = { has_title = title:e_byzantium }
			NOT = { has_title = title:e_western_roman_empire }
			NOT = { has_title = title:e_roman_empire }
		}
		OR = {
			title:e_italy = {
				is_title_created = yes
			}
			AND = {
				title:k_italy = {
					is_title_created = yes
				}
				NOT = { has_title = title:k_italy }
				title:k_italy.holder = {
					is_independent_ruler = yes
				}
			}
			AND = {
				title:k_sicily = {
					is_title_created = yes
				}
				NOT = { has_title = title:k_sicily }
				title:k_sicily.holder = {
					is_independent_ruler = yes
				}
			}
		}
		any_sub_realm_county = {
			NOT = { this = title:c_trapani }
			NOT = { this = title:c_malta }
			duchy = title:d_sicily
			count >= 2
		}
		NOT = {
			capital_county = {
				duchy = title:d_sicily
			}
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:concession_of_italy_decision
			}
		}
	}
	is_valid = {
		is_at_war = no
		is_imprisoned = no
	}
	effect = {
		trigger_event = germanic_events.0012
		show_as_tooltip = {
			every_held_title = {
				limit = {
					tier = tier_county
					duchy = title:d_sicily
					NOT = { this = title:c_trapani }
					NOT = { this = title:c_malta }
				}
				create_title_and_vassal_change = {
					type = granted
					save_scope_as = change
					add_claim_on_loss = no
				}
				change_title_holder_include_vassals = {
					holder = title:k_italy.holder
					change = scope:change
				}
				resolve_title_and_vassal_change = scope:change
			}
			every_vassal = {
				limit = {
					capital_county = {
						duchy = title:d_sicily
					}
				}
				create_title_and_vassal_change = {
					type = granted
					save_scope_as = change
					add_claim_on_loss = no
				}
				change_liege = {
					liege = title:k_italy.holder
					change = scope:change
				}
				resolve_title_and_vassal_change = scope:change
			}
			add_opinion = {
				target = title:k_italy.holder
				opinion = 20
				modifier = friendliness_opinion
			}
			title:k_italy.holder = {
				add_opinion = {
					target = root
					opinion = 20
					modifier = friendliness_opinion
				}
			}
			title:k_italy.holder = {
				add_truce_both_ways = {
					character = root
					years = 10
					name = SICILY_TRUCE
					result = white_peace
				}
			}
		}
	}
	ai_potential = {
		always = yes
	}
	cost = { prestige = { value = 250 if = {limit = { is_ai = yes } multiply = 0 } } }
	ai_will_do = {
		base = 100
	}
}

#############################
# Refound HRE 				#
# by Ewan Cowhig Croft		#
#############################
restore_holy_roman_empire_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	major = yes

	ai_check_interval = 120

	desc = restore_holy_roman_empire_decision_desc
	selection_tooltip = restore_holy_roman_empire_decision_tooltip

	is_shown = {
		always = yes # until we maybe do charlemagne
		is_landed = yes
		game_start_date >= 867.1.1
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		NOR = {	#Title existence cnditions.
			exists = title:e_hre.holder	#Well, that'd be redundant.
			highest_held_title_tier = tier_empire	#Existing emperors likewise should not be giving up their empire.
		}
		AND = {	#Faith conditions.
			NOT = { this = faith.religious_head }	#Nice try, Mr. Pope.
			faith = {
				religion_tag = christianity_religion
				has_doctrine_parameter = spiritual_head_of_faith	#Gotta be invested with the authority by someone other than yourself.
			}
			NAND = {	#No need for a competing empire if your faith controls the ERE.
				exists = title:e_byzantium.holder
				faith = title:e_byzantium.holder.faith
			}
		}
		OR = {	#Government conditions.
			government_has_flag = government_is_feudal
			government_has_flag = government_is_clan
		}
		exists = faith.religious_head
	}

	is_valid = {
		#Standard requirements.
		is_independent_ruler = yes
		prestige_level >= high_prestige_level
		#Title ownership conditions.
		AND = {
			has_title = title:k_east_francia #Gotta be King of the Germans.
			custom_description = {	#And have some additional royal dignity for good measure.
				text = decision_refound_hre_own_three_kingdoms.tt
				any_held_title = {
					tier = tier_kingdom
					count >= 3
				}
			}
			sub_realm_size >= 140	#Plus your various kingdoms should be ruling something.
		}
		#HoF preference conditions.
		OR = {
			faith.religious_head = {	#And they have to actually like you enough to want to invest you.
				opinion = {
					target = root
					value >= high_positive_opinion
				}
			}
			root = { has_strong_usable_hook = faith.religious_head }	#Or you have a strong hook on them that you can actually use.
			root = { has_weak_hook = faith.religious_head }	#Or a regular hook, to be fair, provided you meet the other criteria.
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		faith.religious_head = { is_available_adult = yes }
		NOR = {
			has_trait = excommunicated
			is_at_war_with = faith.religious_head
		}
	}

	effect = {
		show_as_tooltip = {
			restore_holy_roman_empire_decision_scripted_effect = yes
		}
		gain_heroic_legend_seed_tooltip_effect = yes
		save_scope_as = founder
		faith.religious_head = { save_scope_as = founder_hof }
		if = {
			limit = {
				faith.religious_head = { is_landed = yes }
			}
			faith.religious_head.capital_province = { save_scope_as = ceremony_locale }
		}
		else = {
			capital_province = { save_scope_as = ceremony_locale }
		}
		trigger_event = {
			id = middle_europe_decisions.0015
		}
		#Notify other players.
		every_player = {
			limit = {
				NOT = { this = root }
				is_within_diplo_range = { CHARACTER = root }
			}
			trigger_event = middle_europe_decisions.0016
		}
		if = {
			limit = {
				is_ai = no
				NOT = { exists = global_var:restore_holy_roman_empire_decision  }
			}
			set_global_variable = {
				name = restore_holy_roman_empire_decision
				value = root
			}
		}
		# Assign Dynamic Prince-Electors
		hidden_effect = {
			if = {
				limit = { has_global_variable_list = hre_elector_list }
				clear_global_variable_list = hre_elector_list
			}
			while = {
				count = 7
				random_vassal = {
					limit = {
						capital_province.empire = title:e_hre # must be de-jure vassal of empire
						OR = { # prince-bishopric or duchy
							AND = {
								government_has_flag = government_is_theocracy
								primary_title.tier >= tier_county
							}
							primary_title.tier >= tier_duchy
						}
						NOT = { # not already selected
							is_target_in_global_variable_list = {
								name = hre_elector_list
								target = primary_title
							}
						}
					}
					weight = {
						modifier = { # major vassals heavily weighted
							factor = 10
							is_powerful_vassal = yes
						}
						modifier = { # same culture as emperor preferred
							factor = 4
							culture = root.culture
						}
						modifier = { # we don't mind going outside Germania, but prefer it
							factor = 1.5
							trigger = { exists = primary_title.title_province }
							primary_title.title_province.barony = {
								OR = {
									target_is_de_jure_liege_or_above = title:k_bavaria
									target_is_de_jure_liege_or_above = title:k_bohemia
									target_is_de_jure_liege_or_above = title:k_east_francia
									target_is_de_jure_liege_or_above = title:k_frisia
									target_is_de_jure_liege_or_above = title:k_lotharingia
									target_is_de_jure_liege_or_above = title:k_pomerania
								}
							}
						}
						modifier = { # we want at least 3 theocracies ideally
							factor = 10
							any_in_global_list = {
								variable = hre_elector_list
								count < 3
								holder = { government_has_flag = government_is_theocracy }
							}
							government_has_flag = government_is_theocracy
						}
						modifier = { # 3 is enough theocracies unless we can't find feudal
							factor = 0.1
							any_in_global_list = {
								variable = hre_elector_list
								count >= 3
								holder = { government_has_flag = government_is_theocracy }
							}
							government_has_flag = government_is_theocracy
						}
					}
					add_to_global_variable_list = {
						name = hre_elector_list
						target = primary_title
					}
				}
			}
			hre_elector_list_save_effect = yes # saves list scopes to title as variables for tooltip
		}
	}

	cost = {
		gold = 500
		piety = 200
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

change_to_islamic = {
	picture = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	desc = change_to_islamic_desc
	selection_tooltip = change_to_islamic_tooltip
	major = yes
	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date <= 866.1.1
		has_religion = religion:islam_religion
		NOT = {
			government_has_flag = government_is_muslim
		}
		NOT = {
			government_has_flag = government_is_caliphate
		}
	}

	is_valid = {
		prestige_level >= 3
		OR = {
			has_government = feudal_government
			has_government = clan_government
			government_has_flag = government_is_city_state
		}
	}

	effect = {
		change_government = muslim_government
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 90
	}
	cost = { gold = { value = 50 } prestige = { value = 200 } }
}

change_to_caliphate = {
	picture = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	desc = change_to_caliphate_desc
	selection_tooltip = change_to_caliphate_tooltip
	major = yes
	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		game_start_date <= 866.1.1
		has_religion = religion:islam_religion
		government_has_flag = government_is_muslim
		NOT = {
			government_has_flag = government_is_caliphate
		}
		any_liege_or_above = {
			NOT = {
				has_title = title:e_rashidun
			}
		}
	}

	is_valid = {
		prestige_level >= 3
	}

	effect = {
		change_government = caliphate_government
		if = {
			limit = {
				faith = {
					exists = religious_head
				}
			}
			faith = {
				religious_head = {
					add_opinion = {
						target = root
						opinion = -150
						years = 30
						modifier = hate_opinion
					}
				}
			}
		}
		save_scope_as = caliph
		set_variable = {
			name = cal_authority
			value = 10
		}
		set_variable = {
			name = zakah_balance
			value = 0
		}

		every_realm_province = {
			limit = {
				barony = { is_holy_site_of = scope:caliph.faith }
			}

			scope:caliph = {
				change_variable = {
					name = cal_authority
					add = 2
				}
			}
		}

		if = {
			limit = {
				NOT = { any_realm_province = { barony = { is_holy_site_of = scope:caliph.faith } } } 
			}
			change_variable = {
				name = cal_authority
				subtract = 2
			}
		}

		if = {
			limit = {
				piety_level = max_piety_level
			}
			change_variable = {
				name = cal_authority
				add = 5
			}
		}
		if = {
			limit = {
				piety_level = very_high_piety_level
			}
			change_variable = {
				name = cal_authority
				add = 2
			}
		}
		if = {
			limit = {
				piety_level = high_piety_level
			}
			change_variable = {
				name = cal_authority
				add = 1
			}
		}
		if = {
			limit = {
				piety_level = low_piety_level
			}
			change_variable = {
				name = cal_authority
				subtract = 2
			}
		}
		
		clamp_variable = {
			name = cal_authority
			max = 100
			min = 0
		}
		hidden_effect = {
			while = {
				count = var:cal_authority
				add_character_modifier = caliph_auth
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 10
	}
	cost = { gold = { value = 500 } prestige = { value = 500 } piety = { value = 700 } }
}

TFE_create_adurbadagan_kingdom = {
	picture = "gfx/interface/illustrations/decisions/decision_realm_persia.dds"
	major = yes
	desc = TFE_create_adurbadagan_kingdom_desc

	ai_check_interval = 120

	is_shown = {
		is_landed = yes
		NOT = { exists = title:k_adurbadagan.holder }
		NOT = {
			is_target_in_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:TFE_create_adurbadagan_kingdom
		}
	}
	culture = {
		has_cultural_pillar = heritage_caucasian
		}
	}

	is_valid = {
		prestige_level >=2
		has_title = title:d_azerbaijan
		has_title = title:d_shirvan
		culture = {
			has_cultural_pillar = heritage_caucasian
		}
	}

	is_valid_showing_failures_only = {
		is_adult = yes
		is_available = yes
		is_independent_ruler = yes
	}

	cost = {
		gold = {
			value = 250
		}
		Prestige = {
			value = 100
		}
	}

	effect = {
		custom_tooltip = TFE_create_adurbadagan_kingdom_tooltip
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:TFE_create_adurbadagan_kingdom
		}
		add_prestige = 350
		get_title = title:k_adurbadagan
		hidden_effect = {
			every_county_in_region = {
				region = adurbadagan
				limit = {
					NOT = {
						kingdom = title:k_adurbadagan
					}
				}
				duchy = {
					set_de_jure_liege_title = title:k_adurbadagan
				}
			}
		}
	}
		ai_will_do = {
		base = 100
	}
}



TFE_create_caucasian_empire = {
	picture = "gfx/interface/illustrations/decisions/decision_realm_persia.dds"
	major = yes
	desc = TFE_create_caucasian_empire_desc

	ai_check_interval = 120

	is_shown = {
		is_landed = yes
		highest_held_title_tier <= tier_kingdom
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:TFE_create_caucasian_empire
			}
		}
		culture = {
			has_cultural_pillar = heritage_caucasian
		}
	}

	is_valid = {
		highest_held_title_tier < tier_empire
		prestige_level >= 3
		has_title = title:k_adurbadagan
		has_title = title:k_armenia
		has_title = title:k_georgia
		has_title = title:k_caucasus
		completely_controls_region = custom_caucasian_empire
		culture = {
			has_cultural_pillar = heritage_caucasian
		}
	}

	is_valid_showing_failures_only = {
		is_adult = yes
		is_available = yes
		is_independent_ruler = yes
	}

	cost = {
		gold = {
			value = massive_gold_value
		}
		prestige = {
			value = major_prestige_value
		}
	}

	effect = {
		custom_tooltip = TFE_create_caucasian_empire_tooltip
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:TFE_create_caucasian_empire
		}
		add_prestige = 500
		dynasty = { add_dynasty_prestige = 1000 }
		get_title = title:e_caucasia
		hidden_effect = {
			every_county_in_region = {
				region = custom_caucasian_empire
				limit = {
					NOT = {
						empire = title:e_caucasia
					}
				}
				kingdom = {
					set_de_jure_liege_title = title:e_caucasia
				}
			}
		}
		give_nickname = nick_the_great
		
	}

	ai_will_do = {
		base = 100
	}
}

become_saoshyant_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"

	desc = become_saoshyant_decision_desc
	selection_tooltip = become_saoshyant_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		faith.religion = faith:mazdayasna.religion
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_became_saoshyant
			}
		}
	}

	is_valid = {
		piety_level >= very_high_piety_level
		has_title = title:e_persia
		completely_controls = title:e_persia
	}

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


	effect = {
		show_as_tooltip = {
			become_saoshyant_decision_effect = yes
		}
		trigger_event = {
			id = middle_east_decisions.0011
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_became_saoshyant
			}
		}
		change_government = eranshar_government
		every_vassal_or_below = {
			change_government = eranshar_government
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

mend_the_great_schism_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_major_religion.dds"

	desc = mend_the_great_schism_decision_desc
	selection_tooltip = mend_the_great_schism_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		### TFE EDIT: It's a bit too early for that, as the Church is still mostly united
		always = yes
		game_start_date >= 867.1.1
		is_ruler = yes
		is_landed = yes
		faith.religion = faith:catholic.religion #Christian Only
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_mended_great_schism
			}
		}
		highest_held_title_tier > 4 #Only Emperors
	}

	is_valid = {
		piety_level >= max_piety_level
		completely_controls = title:c_byzantion
		completely_controls = title:c_antiocheia
		completely_controls = title:c_jerusalem
		completely_controls = title:c_alexandria
		completely_controls = title:c_roma
		custom_description = {
			text = "mend_schism_byzantion_bishop"
			title:c_byzantion.holder.faith = root.faith  #Either own County directly, or have a vassal of same religion.
		}
		custom_description = {
			text = "mend_schism_antiocheia_bishop"
			title:c_antiocheia.holder.faith = root.faith #Either own County directly, or have a vassal of same religion.
		}
		custom_description = {
			text = "mend_schism_jerusalem_bishop"
			title:c_jerusalem.holder.faith = root.faith #Either own County directly, or have a vassal of same religion.
		}
		custom_description = {
			text = "mend_schism_alexandria_bishop"
			title:c_alexandria.holder.faith = root.faith #Either own County directly, or have a vassal of same religion.
		}
		custom_description = {
			text = "mend_schism_roma_bishop"
			title:c_roma.holder.faith = root.faith #Either own County directly, or have a vassal of same religion.
		}
	}

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

	effect = {
		gain_holy_legend_seed_tooltip_effect = yes
		custom_tooltip = mend_the_great_schism_decision_effect_tooltip
		show_as_tooltip = {
			mend_great_schism_scripted_effect = yes
		}
		trigger_event = roman_restoration.0100
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_mended_great_schism
			}
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

avenge_the_battle_of_carrhae_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_roman_knight.dds"
	desc = avenge_the_battle_of_carrhae_decision_desc
	selection_tooltip = avenge_the_battle_of_carrhae_decision_tooltip
	major = yes

	ai_check_interval = 10

	is_shown = {
		NOT = { game_start_date >= 867.1.1 }
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:avenge_the_battle_of_carrhae_decision
			}
		}
		OR = {
			culture = { has_cultural_pillar = heritage_latin }
			culture = { has_cultural_pillar = heritage_byzantine }
			culture = { has_cultural_pillar = heritage_hellenistic }
		}
		OR = {
			has_title = title:e_byzantium
			has_title = title:e_roman_empire
		}
	}

	is_valid = {  
		prestige_level >= 3

		completely_controls = title:k_mesopotamia
		completely_controls = title:c_ctesiphon
		title:k_mesopotamia = { title_held_years >= 10 }
		OR = {
			culture = { has_cultural_pillar = heritage_latin }
			culture = { has_cultural_pillar = heritage_byzantine }
			culture = { has_cultural_pillar = heritage_hellenistic }
		}
		NOT = {
			has_trait = forgiving 
		}
	}
	is_valid_showing_failures_only = {
		is_imprisoned = no
	}

	effect = {
		show_as_tooltip = {
			give_nickname = nick_parthicus
			add_prestige = 1000
			add_gold = 500
			capital_county = {
				add_county_modifier = {
					modifier = carrhae_avenged
					years = 50
				}
			}
			province:4796 = {
				remove_building = taq-kasra
			}
			title:k_mesopotamia = {
				change_development_level = -5
			}
			title:c_ctesiphon = {
				change_development_level = -5
			}
		}

		trigger_event = TFE_flavour_events.0008
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:avenge_the_battle_of_carrhae_decision
		}
	}

	ai_potential = {
		always = yes
	}
	cost = {
		prestige = 500
	}
	ai_will_do = {
		base = 100
	}
}

set_capital_rome_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"

	desc = set_capital_rome_decision_desc
	selection_tooltip = set_capital_rome_decision_tooltip
	major = yes

	is_shown = {
		is_ruler = yes
		is_landed = yes
		is_ai = no
		OR = {
			has_title = title:e_roman_empire
			has_title = title:e_western_roman_empire
		}
		NOT = { capital_county = { this = title:c_roma } }
		OR = {
			title:c_roma.holder = { 	
				any_liege_or_above = { this = root }
			}
			title:c_roma.holder = { this = root }
		}
	}

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

	effect = {
		if = { #Usurp if not held personally.
			limit = {
				NOT = { title:c_roma.holder = { this = root } }
			}
			create_title_and_vassal_change = {
				type = returned
				save_scope_as = change
				add_claim_on_loss = no
			}
			title:c_roma = {
				change_title_holder = {
					holder = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change

		}
		set_realm_capital = title:c_roma
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
		modifier = { # Prefer seducing if you've got the focus for it
			add = -100
			has_title = title:e_roman_empire
		}
	}
}

create_israel_kingdom_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_found_kingdom.dds"

	desc = create_israel_kingdom_decision_desc
	selection_tooltip = create_israel_kingdom_decision_tooltip
	major = yes

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		faith.religion = faith:rabbinism.religion
		NOT = {  
			exists = title:k_israel.holder
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:create_israel_kingdom
			}
		}
	}

	is_valid = {
		prestige_level >= high_prestige_level
		piety_level >= high_piety_level
		completely_controls_region = custom_jerusalem_submod
		custom_description = {
			text = "jerusalem_is_same_faith"
			title:c_jerusalem.faith = root.faith
		}
	}

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

	effect = {
		hidden_effect = {
			dejure_shift_restore_judea_effect = yes
		custom_tooltip = create_israel_kingdom_decision_effect_tooltip
		show_as_tooltip = {
				dejure_shift_restore_judea_effect
			}

		}
		trigger_event = {
			id = middle_east_decisions.0005
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:create_israel_kingdom
			}
			set_global_variable = {
				name = create_israel_kingdom
				value = root
			}
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}