﻿###DECISIONS LIST###

#decision_found_kingdom_of_oman (MENA Flavor)
#decision_found_kingdom_of_old_saxony (HRE Flavor)
#decision_form_grand_duchy_saxony (HRE Flavor)
#decision_form_grand_duchy_franconia (HRE Flavor)
#decision_form_grand_duchy_swabia (HRE Flavor)
#decision_form_bulgarian_empire (Bulgarian Flavor)
#decision_form_kingdom_of_leon (Iberian Flavor) (DEFUNCT WITH FATE OF IBERIA)
#decision_form_kingdom_of_castille (Iberian Flavor) (DEFUNCT WITH FATE OF IBERIA)
#decision_form_avar_khaganate (Avar Flavor)
#decision_integrate_aquitaine (Carolingian Flavor)
#decision_restore_aquitaine (Carolingian Flavor) 
#decision_form_samos_empire (Czech-Slovien Flavor) 
#decision_restore_frisian_kingdom (Frisian Flavor) # NOT CODED YET
# Fulfill the Hadith of Conquest
# Restore the Faith of Zoroaster
# Establish Cairo  
# Promulgate the Assizes of Ariano
# Establish a new Currency System (Ducat)
# Muslims in Sicily Question
# Restore Khwarazm
# Establish Transcaucasia

##############################
# Found the Kingdom of Oman	 #
# by Celticus Magnus	     # 
##############################

found_kingdom_of_oman_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	ai_check_interval = 36

	desc = found_kingdom_of_oman_decision_desc 
	selection_tooltip = found_kingdom_of_oman_decision_tooltip 

	is_shown = {
		culture = { has_cultural_pillar = heritage_arabic }
        faith = faith:ibadi
		exists = capital_province
        capital_province = { geographical_region = ghw_region_arabia }
		
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_kingdom_of_oman 
			}
		}
		has_government = clan_government
		highest_held_title_tier = tier_duchy
	}

	is_valid = {
		#You must have sufficient clout.
		is_independent_ruler = yes
        prestige_level >= high_prestige_level
        piety_level >= high_piety_level

        #You must be of the Ibadi Faith
        faith = faith:ibadi

		#You must control the kingdom's heartlands.
		has_title = title:d_oman
		completely_controls = title:d_oman

		# #You must be sufficiently advanced to unite the various tribes and peoples of your land under a formalized kingdom.
		# culture = { has_cultural_era_or_later = culture_era_early_medieval }
	}

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

	effect = {
		save_scope_as = founder
		show_as_tooltip = {
			found_kingdom_of_oman_scripted_effect = yes # HAVE TO MAKE
		}
		trigger_event = {
			id =  DE_decision_event.0001 # HAVE TO MAKE
		}
		hidden_effect = {
			found_kingdom_of_oman_scripted_effect = yes
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_kingdom_of_oman # DO WE HAVE TO MAKE THESE?
			}
			set_global_variable = {
				name = flag_founded_kingdom_of_oman
				value = root
			}
		}
	}

	cost = {
		gold = 200
		prestige = 300
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 1000
	}
}

#####################################
# Restore the Kingdom of Old Saxony	#
# by Celticus Magnus			    #
##################################### 

restore_saxony_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = restore_saxony_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = restore_saxony_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		exists = capital_province
		capital_province = { geographical_region = ghw_region_germany } #Will not be visible unless you are based in Germany.
		OR = {
			culture = culture:saxon	#We will allow all Saxons to make use if they are in the region.
			culture = culture:anglo_saxon 
			culture = culture:west_saxon 
			culture = culture:old_saxon
		}
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_restored_saxony
			}
		}
		OR = {	
			has_government = feudal_government
		}
		highest_held_title_tier <= tier_duchy
		current_date < 1066.1.1
	}


	is_valid = {
		#You must have sufficient clout.
		is_independent_ruler = yes
		prestige_level >= high_prestige_level

		#You must be a Duke in the region and own Old Saxony's de jure lands.
		OR = {	
			has_title = title:d_holstein
			has_title = title:d_ostfalen
			has_title = title:d_angria
			has_title = title:d_westfalen
			has_title = title:d_anhalt
		}
		NOR = {
			has_title = title:e_hre
			highest_held_title_tier = tier_empire
		}
		completely_controls_region = custom_saxony

		#You must have Saxon Culture present in the area.

		any_realm_province = { #You must have some realm support for your claims.
			OR = {
				culture = culture:saxon	
				culture = culture:anglo_saxon 
				culture = culture:old_saxon
			}
		}
	}

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

	effect = {
		save_scope_as = founder
		show_as_tooltip = {
			restore_saxony_decision_scripted_effect = yes #NEED TO MAKE
		}
		trigger_event = {
			id = DE_decision_event.0002 #NEED TO MAKE
		}
		hidden_effect = {
			restore_saxony_decision_scripted_effect = yes
			add_to_global_variable_list = { #DO WE HAVE TO MAKE THESE?
				name = unavailable_unique_decisions
				target = flag:flag_restored_saxony
			}
			set_global_variable = {
				name = flag_restored_saxony
				value = root
			}
		}
	}

	cost = {
		gold = 200
		prestige = 300
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 1000
	}
}

#####################################
# Form the Grand Duchy of Saxony 	#
# by Celticus Magnus			    # 
#####################################

form_grand_duchy_saxony_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = form_grand_duchy_saxony_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = form_grand_duchy_saxony_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_landed = yes
		OR = {
			#Must be a German within the HRE...
			culture = { has_cultural_pillar = heritage_central_germanic }
			#...*unless* you are a bonified member of the Saxon cultures.
			culture = culture:saxon	
			culture = culture:anglo_saxon 
			culture = culture:old_saxon
		}
		#The Kingdom of Saxony must not exist.
		NOT = { exists = title:k_saxony.holder }
		OR = {
			#No kings or emperors...
			AND = {
				highest_held_title_tier <= tier_duchy
				is_independent_ruler = no
			}
			#... *unless* you hold the HRE itself.
			#has_title = title:e_hre
		}
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_formed_grand_duchy_saxony
			}
		}
		#Must be within the HRE, else the bid & flavour make no sense.
		top_liege = { has_title = title:e_hre }
		#Must hold land within the relevant areas directly.
		any_held_title = {
			tier = tier_county
			OR = {
				title_province = { geographical_region = custom_grand_saxony }
			}
		}
	}

	is_valid = {
		#Must enjoy imperial immediacy.
		liege = title:e_hre.holder
		#Must be suitably prestigious.
		prestige_level >= high_prestige_level
		completely_controls_region = custom_grand_saxony
		OR = {
			# custom_description = {
			# 	#text = "form_grand_duchy_saxony_trigger"
			# 	dynasty = title:e_hre.holder.dynasty
			# }
			dynasty = title:e_hre.holder.dynasty
			has_strong_usable_hook = title:e_hre.holder
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_at_war = no
		faith = top_liege.faith	#Must share the faith of your emperor.
	}

	effect = {
		save_scope_as = founder
		top_liege = {
			save_scope_as = scoped_emperor
		}
		show_as_tooltip = {
			form_grand_duchy_saxony_decision_scripted_effect = yes #NEED TO MAKE
		}
		trigger_event = {
			id = DE_decision_event.0003 #NEED TO MAKE
		}
		hidden_effect = {
			form_grand_duchy_saxony_decision_scripted_effect = yes
			add_to_global_variable_list = { #DO WE HAVE TO MAKE THESE?
				name = unavailable_unique_decisions
				target = flag:flag_formed_grand_duchy_saxony
			}
			set_global_variable = {
				name = flag_formed_grand_duchy_saxony
				value = root
			}
		}
	}

	cost = {
		gold = 500
		prestige = 1000
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		#Only worth considering if you actually have your capital in Austria.		
		modifier = {
			add = 100
			capital_county.title_province = { geographical_region = custom_saxony }
		}

		#More brazen characters are more likely to have a bash.
		ai_value_modifier = {
			ai_boldness = 0.75
			ai_greed = 0.25
		}
	}
}

#####################################
# Form the Grand Duchy of Franconia #
# by Celticus Magnus			    # 
#####################################

form_grand_duchy_franconia_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = form_grand_duchy_franconia_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = form_grand_duchy_franconia_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_landed = yes
		OR = {
			#Must be a German within the HRE...
			culture = { has_cultural_pillar = heritage_central_germanic }
		}
		OR = {
			#No kings or emperors...
			AND = {
				highest_held_title_tier <= tier_duchy
				is_independent_ruler = no
			}
			#... *unless* you hold the HRE itself.
			#has_title = title:e_hre
		}
		NOR = {	#Can't form if you already own Kingdom of Germany. While the Emperor can found the Stem Duchy if they wish, Franconia should only exist if a Vassal usurps the area or Germany was destroyed.
			has_title = title:k_east_francia		
		}	
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_formed_grand_duchy_franconia
			}
		}
		# #Must be within the HRE, else the bid & flavour make no sense.
		top_liege = { has_title = title:e_hre }
		# #Must hold land within the relevant areas directly.
		any_held_title = {
			tier = tier_county
			OR = {
				title_province = { geographical_region = custom_core_franconia }
			}
		}
	}

	is_valid = {
		#Must enjoy imperial immediacy.
		liege = title:e_hre.holder
		#Must be suitably prestigious.
		prestige_level >= high_prestige_level
		completely_controls_region = custom_core_franconia
		OR = {
			dynasty = title:e_hre.holder.dynasty
			has_strong_usable_hook = title:e_hre.holder
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_at_war = no
		faith = top_liege.faith	#Must share the faith of your emperor.
	}

	effect = {
		save_scope_as = founder
		show_as_tooltip = {
			form_grand_duchy_franconia_decision_scripted_effect = yes #NEED TO MAKE
		}
		trigger_event = {
			id = DE_decision_event.0004 #NEED TO MAKE
		}
		hidden_effect = {
			form_grand_duchy_franconia_decision_scripted_effect = yes
			add_to_global_variable_list = { #DO WE HAVE TO MAKE THESE?
				name = unavailable_unique_decisions
				target = flag:flag_formed_grand_duchy_franconia
			}
			set_global_variable = {
				name = flag_formed_grand_duchy_franconia
				value = root
			}
		}
	}

	cost = {
		gold = 500
		prestige = 1000
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		#Only worth considering if you actually have your capital in Austria.		
		modifier = {
			add = 100
			capital_county.title_province = { geographical_region = custom_core_franconia }
		}

		#More brazen characters are more likely to have a bash.
		ai_value_modifier = {
			ai_boldness = 0.75
			ai_greed = 0.25
		}
	}
}

#####################################
# Form the Grand Duchy of Swabia    #
# by Celticus Magnus			    # 
#####################################

form_grand_duchy_swabia_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = form_grand_duchy_swabia_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = form_grand_duchy_swabia_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_landed = yes
		OR = {
			#Must be a German within the HRE...
			culture = { has_cultural_pillar = heritage_central_germanic }
		}
		OR = {
			#No kings or emperors...
			AND = {
				highest_held_title_tier <= tier_duchy
				is_independent_ruler = no
			}
			#... *unless* you hold the HRE itself.
			#has_title = title:e_hre
		}
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_formed_grand_duchy_swabia
			}
		}
		#Must be within the HRE, else the bid & flavour make no sense.
		top_liege = { has_title = title:e_hre }
		#Must hold land within the relevant areas directly.
		any_held_title = {
			tier = tier_county
			OR = {
				title_province = { geographical_region = custom_core_swabia }
			}
		}
	}

	is_valid = {
		#Must enjoy imperial immediacy.
		liege = title:e_hre.holder
		#Must be suitably prestigious.
		prestige_level >= high_prestige_level
		completely_controls_region = custom_core_swabia
		OR = {
			dynasty = title:e_hre.holder.dynasty
			has_strong_usable_hook = title:e_hre.holder
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_at_war = no
		faith = top_liege.faith	#Must share the faith of your emperor.
	}

	effect = {
		save_scope_as = founder
		show_as_tooltip = {
			form_grand_duchy_swabia_decision_scripted_effect = yes #NEED TO MAKE
		}
		trigger_event = {
			id = DE_decision_event.0005 #NEED TO MAKE
		}
		hidden_effect = {
			form_grand_duchy_swabia_decision_scripted_effect = yes
			add_to_global_variable_list = { #DO WE HAVE TO MAKE THESE?
				name = unavailable_unique_decisions
				target = flag:flag_formed_grand_duchy_swabia
			}
			set_global_variable = {
				name = flag_formed_grand_duchy_swabia
				value = root
			}
		}
	}

	cost = {
		gold = 500
		prestige = 1000
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		#Only worth considering if you actually have your capital in Austria.		
		modifier = {
			add = 100
			capital_county.title_province = { geographical_region = custom_core_swabia }
		}

		#More brazen characters are more likely to have a bash.
		ai_value_modifier = {
			ai_boldness = 0.75
			ai_greed = 0.25
		}
	}
}

#####################################
# Form the Bulgarian Empire	        #
# by Celticus Magnus			    # 
#####################################

form_bulgarian_empire_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = form_bulgarian_empire_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = form_bulgarian_empire_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		has_culture = culture:bulgarian	
		exists = capital_province
		capital_province = { geographical_region = custom_south_slavia } #Will not be visible unless you are based in South Slavia.
		highest_held_title_tier >= tier_kingdom
		OR = {	
			has_government = feudal_government
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_bulgarian_empire_decision
			}
		}		
		NOR = {	#Can't form if you already hold an Empire title.
			has_title = title:e_byzantium		
			has_title = title:e_hre
			has_title = title:e_carpathia
			highest_held_title_tier = tier_empire
		}		
	}	

	is_valid = {
		#You must have sufficient clout.
		is_independent_ruler = yes
        prestige_level >= very_high_prestige_level

        #You must be Christian

		religion = religion:christianity_religion
		
		#You must rule Bulgaria

		has_primary_title = title:k_bulgaria	
		completely_controls = title:k_bulgaria
		completely_controls = title:k_dacia
		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_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		is_at_war = no
	}
	
	cost = {
		gold = 500
		prestige = 1000
	}	

	effect = {
		show_as_tooltip = {
			form_bulgarian_empire_decision_effect = yes # DO WE NEED TO MAKE?
		}
		trigger_event = {
			id = DE_decision_event.0006 # NEED TO MAKE
		}		
		hidden_effect = {
			form_bulgarian_empire_decision_effect = yes
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_bulgarian_empire_decision # DO WE NEED TO MAKE DIS?
			}
		}		
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

#####################################
# Reform the Avar Khaganate	        #
# by Celticus Magnus			    # 
#####################################

form_avar_khaganate_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = form_avar_khaganate_decision_desc 
	selection_tooltip = form_avar_khaganate_decision_tooltip 

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		has_culture = culture:avar	
		exists = capital_province
		capital_province = { geographical_region = ghw_region_hungary } #Will not be visible unless you are based in Pannonia or its vicinity.
		highest_held_title_tier >= tier_duchy
		OR = {	
			has_government = tribal_government
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_avar_khaganate_decision
			}
		}		
		NOR = {	#Can't form if you already hold an Empire title.
			has_title = title:e_byzantium		
			has_title = title:e_hre
			has_title = title:e_carpathia
			highest_held_title_tier = tier_empire
		}		
	}	

	is_valid = {
		#You must have sufficient clout.
		is_independent_ruler = yes
        prestige_level >= very_high_prestige_level
		highest_held_title_tier >= tier_kingdom
		#You must rule Pannonia and control the Avar Khaganates former realms.
		has_primary_title = title:k_hungary	
		completely_controls_region = custom_avaria
		#You should probably be Tribal to want to reform the Khaganate.
		has_government = tribal_government
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		is_at_war = no
	}
	
	cost = {
		gold = 500
		prestige = 1000
	}	

	effect = {
		show_as_tooltip = {
			form_avar_khaganate_decision_effect = yes # DO WE NEED TO MAKE?
		}
		trigger_event = {
			id = DE_decision_event.0007 # NEED TO MAKE
		}		
		hidden_effect = {
			form_avar_khaganate_decision_effect = yes
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_avar_khaganate_decision # DO WE NEED TO MAKE DIS?
			}
		}		
	}
	
	ai_potential = {
		is_ruler = yes
	}

	ai_will_do = {
		base = 1000
	}
}

######################################
# Integrate the Kingdom of Aquitaine #       
# by Celticus Magnus			     # 
######################################

# Vanilla added a varant of this decision

######################################
# Restore the Kingdom of Aquitaine   #       
# by UberEpicZach   			     # 
######################################

decision_restore_aquitaine = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = restore_aquitaine_decision_desc
	selection_tooltip = restore_aquitaine_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		culture = { has_cultural_pillar = heritage_frankish }
		NOT = {
			has_title = title:k_france
			title:k_aquitaine = { any_in_de_jure_hierarchy = { tier = tier_county } }
		}
		OR = {
			highest_held_title_tier = tier_duchy
			highest_held_title_tier = tier_county
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restore_aquitaine_decision
			}
		}	
	}

	is_valid = {
		is_independent_ruler = yes
		completely_controls_region = custom_aquitaine
		prestige_level >= high_prestige_level
		highest_held_title_tier = tier_duchy
	}
	
	cost = {
		gold = 300
	}	
	
	effect = {
		show_as_tooltip = {
			restore_aquitaine_decision_effect = yes # DO WE NEED TO MAKE?
		}
		trigger_event = {
			id = DE_decision_event.0009
		}		
		hidden_effect = {
			restore_aquitaine_decision_effect = yes
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restore_aquitaine_decision # DO WE NEED TO MAKE DIS?
			}
		}		
	}
}

#####################################
# Reform Samo's Empire	            #
# by Celticus Magnus			    # 
#####################################

form_samos_empire_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = form_samos_empire_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = form_samos_empire_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_ruler = yes
		is_landed = yes
		culture = {
			any_parent_culture_or_above = {
				this = culture:frankish
			}
		}
		OR = {
			knows_language = language_czech_slovak
			knows_language = language_czecho_slovak
		}
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		exists = capital_province
		capital_province = { geographical_region = ghw_region_poland_bohemia_bavaria } #Will not be visible unless you are based in the area of Samo's Empire.
		highest_held_title_tier <= tier_duchy
		OR = {	
			has_government = feudal_government
			has_government = tribal_government
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_samos_empire_decision
			}
		}		
		NOR = {	#Can't form if you already hold an Empire title.
			has_title = title:e_hre
			has_title = title:e_wendish_empire
			has_title = title:e_carpathia
			highest_held_title_tier = tier_empire
		}		
	}	

	is_valid = {
		#You must have sufficient clout.
		is_independent_ruler = yes
        prestige_level >= high_prestige_level

        #You must be Christian or old Slavic Pagan
		OR = {
			religion = religion:christianity_religion
			religion = religion:slavic_religion
		}
		#Must be this peculiar combo akin to Samo himself.
		culture = {
			any_parent_culture_or_above = {
				this = culture:frankish
			}
		}
		OR = {
			knows_language = language_czech_slovak
			knows_language = language_czecho_slovak
		}
		#You must rule Moravia or Bohemia and posess the former realms held by Samos
		OR = {
			has_primary_title = title:k_moravia
			has_primary_title = title:k_bohemia
			completely_controls = title:k_moravia
		}
		completely_controls_region = custom_samos_empire
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		is_at_war = no
	}
	
	cost = {
		gold = 300
		prestige = 750
	}	

	effect = {
		show_as_tooltip = {
			form_samos_empire_decision_effect = yes # DO WE NEED TO MAKE?
		}
		trigger_event = {
			id = DE_decision_event.0010 # NEED TO MAKE
		}		
		hidden_effect = {
			form_samos_empire_decision_effect = yes
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_samos_empire_decision # DO WE NEED TO MAKE DIS?
			}
		}		
	}
	
	ai_potential = {
		is_ruler = yes
	}

	ai_will_do = {
		base = 1000
	}
}

#####################################
# Restore the Frisian Kingdom		#
# by Celticus Magnus			    #
##################################### 

restore_frisia_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	ai_check_interval = 120

	desc = restore_frisia_decision_desc # NEED TO LOCALIZE 
	selection_tooltip = restore_frisia_decision_tooltip # NEED TO LOCALIZE

	is_shown = {
		is_ruler = yes
		is_landed = yes
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		OR = {
			culture = culture:frisian	
			culture = culture:dutch #Should the Dutch also be able to do this to have a kingdom of their own?
		}
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_restored_frisia
			}
		}
		OR = {	
			has_government = feudal_government
		}
		highest_held_title_tier <= tier_duchy
	}


	is_valid = {
		#You must have sufficient clout.
		is_independent_ruler = yes
		prestige_level >= high_prestige_level

		#You must be a Duke in the region and own Old Saxony's de jure lands.
		OR = {	
			has_title = title:d_holland
			has_title = title:d_frisia
			has_title = title:d_utrecht
			has_title = title:d_gelre
		}
		NOT = {
			#has_title = title:e_france
			#has_title = title:e_hre
			#highest_held_title_tier = tier_empire
			highest_held_title_tier >= tier_kingdom
		}
		
		completely_controls_region = custom_frisia01

		#You must have Frisian or Dutch Culture present in the area.

		any_realm_province = { #You must have some realm support for your claims.
			OR = {
				culture = culture:frisian
				culture = culture:dutch
			}
		}
	}

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

	effect = {
		save_scope_as = founder
		show_as_tooltip = {
			restore_frisia_decision_scripted_effect = yes #NEED TO MAKE
		}
		trigger_event = {
			id = DE_decision_event.0011
		}
		hidden_effect = {
			restore_frisia_decision_scripted_effect = yes
			add_to_global_variable_list = { #DO WE HAVE TO MAKE THESE?
				name = unavailable_unique_decisions
				target = flag:flag_restored_frisia
			}
			set_global_variable = {
				name = flag_restored_frisia
				value = root
			}
		}
	}

	cost = {
		gold = 300
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 1000
	}
}

##################################################
# Fulfill the Hadith of Conquest
# By EmrysValdr
##################################################

fulfill_the_conquest_hadith_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}
	decision_group_type = major
	
	ai_check_interval = 120

	desc = fulfill_the_conquest_hadith_decision_desc
	selection_tooltip = fulfill_the_conquest_hadith_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		religion = religion:islam_religion
		NOT = { culture = culture:greek }
		capital_province = {
			OR = {
				geographical_region = world_persian_empire
				geographical_region = world_asia_minor
				geographical_region = custom_greater_armenia
				geographical_region = world_middle_east
				geographical_region = world_africa_north_east
			}
		}
		NOR = {
			top_liege = { has_title = title:e_byzantium }
			top_liege = { has_title = title:e_roman_empire }
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_fulfilled_conquest_hadith
			}
		}
	}
	
	is_valid = {
		# For the sake of feasibility, we require independence. Lieges of any kind really complicate likely outcomes.
		is_independent_ruler = yes
		
		# Have to be Muslim. You are fulfilling the words of the Prophet after all
		religion = religion:islam_religion
		
		# You know, actually hold Constantinople
		completely_controls = title:b_constantinople
		
		#prestige_level >= high_prestige_level
		#piety_level >= high_piety_level
	}

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

	effect = {
		show_as_tooltip = {
			fulfill_the_conquest_hadith_scripted_effect = yes
		}
		trigger_event = {
			id = DE_decision_event.0018 
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_fulfilled_conquest_hadith
			}
			set_global_variable = {
				name = flag_fulfilled_conquest_hadith
				value = root
			}
		}
	}

	cost = {
		piety = 250
		prestige = 500
	}

	ai_potential = {
		# AI will only even consider this if they're cynical and already high-tier.
		highest_held_title_tier >= tier_kingdom
		has_trait = cynical
	}

	ai_will_do = {
		base = 1000
	}
}

##################################################
# Restore the Faith of Zoroaster
# By EmrysValdr
# Inspired by Champion the Faith of the Country Basques
# by Ewan Cowhig Croft
##################################################

restore_the_faith_of_zoroaster_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_knight_kneeling.dds"
	}
	decision_group_type = major

	ai_check_interval = 120

	desc = restore_the_faith_of_zoroaster_decision_desc
	selection_tooltip = restore_the_faith_of_zoroaster_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		exists = dynasty
		#Musn't already be Zoroastrian.
		NOT = { religion = religion:zoroastrianism_religion } 
		#If you are fairly dedicated to your current faith then this shouldn't be available.
		NOT = { piety_level >= 2 }  

		# Must either have a Iranian county or be Iranian/recently Iranian (in some form).
		OR = {
			restore_the_faith_of_zoroaster_counts_as_persian_trigger = yes
			any_held_title = {
				tier = tier_county
				restore_the_faith_of_zoroaster_counts_as_persian_trigger = yes
			}
		}
		
		# # And we're before 1100 or so, so there's enough non-Muslimized ways left to try and forge something meaningful out of it.
		# current_date <= 1100.1.1
		
		# Will not be visible unless you are based in the Region
		capital_province = { geographical_region = world_persian_empire }
		
		# Filter out anyone who's their own HoF, since they can't convert.
		trigger_if = {
			limit = { exists = faith.religious_head }
			NOT = { this = faith.religious_head }
		}
		
		# The decision cannot have been taken yet.
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restored_the_ways_of_zoroaster
			}
		}
	}

	is_valid = {
		prestige_level >= high_prestige_level
		#Holds a holy site
		OR = {
			completely_controls = title:c_baduspan
			completely_controls = title:c_yazd
			completely_controls = title:c_riqan
			completely_controls = title:c_balkh
			completely_controls = title:c_urmiya
		}
		# You need some clear spiritual reasons for pulling the switcharoo.
		## We keep these isolated in a scripted trigger file so that we can maintain easy parity between the decision rationales & the event desc rationales.
		OR = {	
			custom_description = {
				text = restore_the_faith_of_zoroaster_decision.have_sinful_piety_level
				restore_the_faith_of_zoroaster_rationale_negative_piety_level_trigger = yes
			}
			
			restore_the_faith_of_zoroaster_rationale_sinful_traits_trigger = yes
			
			# custom_description = {
			# 	text = restore_the_faith_of_zoroaster_decision.you_have_x_or_more_traits_virtuous_to_zoroastrianism
			# 	restore_the_faith_of_zoroaster_rationale_virtuous_zoroastrian_traits_trigger = yes
			# }
			
			restore_the_faith_of_zoroaster_rationale_excommunicated_trigger = yes
			
			# AI need to be cynical to access the decision, so we require a little something extra from them first.
			restore_the_faith_of_zoroaster_rationale_naked_cynicism_trigger = yes
			#restore_the_faith_of_zoroaster_rationale_hof_rivalry_trigger = yes
			
			trigger_if = {
				limit = {
					exists = faith.religious_head
				}	
				restore_the_faith_of_zoroaster_rationale_hof_rivalry_trigger = yes
			}
		}
		
		# You must completely control at least X counties from within the (generously diasporic) region of the Persian Empire.
		# custom_description = {
		# 	text = restore_the_faith_of_zoroaster_decision.completely_control_X_counties_from_persian_empire
		# 	any_county_in_region = {
		# 		region = world_persian_empire
		# 		count >= restore_the_faith_of_zoroaster_decision_counties_to_control_value
		# 		save_temporary_scope_as = county_temp
		# 		root = { completely_controls = scope:county_temp }
		# 	}
		# }
		
		# # We repeat the date clause here so that folks know they're on a timer.
		# custom_description = {
		# 	text = restore_the_faith_of_zoroaster_decision.before_last_date
		# 	current_date <= 1100.1.1
		# }
		
		# For the sake of feasibility, we require independence. Lieges of any kind really complicate likely outcomes.
		is_independent_ruler = yes
	}

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

	effect = {
		# Grab some scopes for loc.
		save_scope_as = religious_leader
		faith = { save_scope_as = old_faith }
		faith:mazdayasna = { save_scope_as = mazdayasna }
		religion:islam_religion = { save_scope_as = islam_religion }
		
		## Try to pick a religious figure who can look upset in the events.
		if = {
			limit = { exists = faith.religious_head }
			faith.religious_head = { save_scope_as = scandalised_cleric }
		}
		else_if = {
			limit = { exists = cp:councillor_court_chaplain }
			cp:councillor_court_chaplain = { save_scope_as = scandalised_cleric }
		}
		else_if = {
			limit = {
				any_vassal_or_below = { has_government = theocracy_government }
			}
			random_vassal_or_below = {
				limit = { has_government = theocracy_government }
				save_scope_as = scandalised_cleric
			}
		}

		# Display the various paths.
		show_as_tooltip = {
			restore_the_faith_of_zoroaster_decision_generic_effects_scripted_effect = yes # Show the generic effect. (Hidden as it fires from follow-up event) -h
		}
		
		# Send the event.
		trigger_event = DE_decision_event.0017
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restored_the_ways_of_zoroaster
			}
		}
	}

	cost = {
		piety = 300
		prestige = 500
	}

	ai_potential = {
		# AI will only even consider this if they're cynical and already high-tier.
		highest_held_title_tier >= tier_kingdom
		has_trait = cynical
	}

	ai_will_do = {
		base = 0

		# Weight up a little if they think they know best.
		modifier = {
			add = 25
			has_trait = arrogant
		}
		modifier = {
			add = 25
			has_trait = stubborn
		}
		modifier = {
			add = 25
			has_trait = arbitrary
		}
		# If you've got a heavily Basque-leaning realm, that helps quite a lot too.
		modifier = {
			add = 75
			any_sub_realm_county = {
				percent >= 0.51
				restore_the_faith_of_zoroaster_counts_as_persian_trigger = yes
			}
		}
		# Plus, relations with their HoF are a clincher...
		## ... either positively...
		modifier = {
			add = 150
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_bad_relationship_with_root_trigger = yes }
			}
		}
		## ... or negatively.
		modifier = {
			add = -150
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_good_relationship_with_root_trigger = yes }
			}
		}
	}
}

##################################################
# Establish Cairo  
# By EmrysValdr
##################################################

establish_cairo_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major
	
	ai_check_interval = 36

	desc = establish_cairo_decision_desc
	selection_tooltip = establish_cairo_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes
		religion = religion:islam_religion
		capital_province = {
			OR = {
				geographical_region = world_middle_east_jerusalem # Syria & Jerusalem
				geographical_region = custom_roman_aegyptus # Egypt
				geographical_region = custom_roman_cyrenaica # Cyrenaica
				geographical_region = custom_roman_africa # Africa
			}
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_cairo
			}
		}
		current_date < 1066.1.1
	}
	
	is_valid = {
		# For the sake of feasibility, we require independence. Lieges of any kind really complicate likely outcomes.
		is_independent_ruler = yes
		
		# Completely controls the region of Egypt
		completely_controls_region = custom_roman_aegyptus

		has_title = title:d_shiite

		prestige_level >= high_prestige_level
		
		# We want to have the city established sometime around the historical date
		NOT = {
			culture = { has_cultural_era_or_later = culture_era_high_medieval }
		}
	}

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

	effect = {
		show_as_tooltip = { establish_cairo_scripted_effect = yes }
		trigger_event = {
			id = DE_decision_event.0020
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_cairo
			}
			set_global_variable = {
				name = flag_founded_cairo
				value = root
			}
		}
	}

	cost = {
		gold = 500
		prestige = 500
	}

	# ai_potential = {
		# # AI will only even consider this if they're diligent and already high-tier.
		# highest_held_title_tier >= tier_kingdom
		# has_trait = diligent
	# }

	ai_will_do = {
		base = 1000
	}
}

##################################################
# Promulgate the Assizes of Ariano
# By EmrysValdr
##################################################

promulgate_the_assizes_of_ariano_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major
	
	ai_check_interval = 120

	desc = promulgate_the_assizes_of_ariano_decision_desc
	selection_tooltip = promulgate_the_assizes_of_ariano_decision_tooltip

	is_shown = {
		is_ruler = yes
		is_landed = yes

		religion = religion:christianity_religion

		root.culture = { # Not Tribal Era
			has_cultural_era_or_later = culture_era_early_medieval
			NOT = { # Can not already have a unique legal code
				has_cultural_tradition = tradition_eastern_roman_law
			}
		}

		OR = {
			culture = { has_cultural_pillar = heritage_latin }
			culture = { has_cultural_pillar = heritage_central_germanic }	
			culture = { has_cultural_pillar = heritage_iberian }
			has_culture = culture:norman			
		}

		has_title = title:k_sicily

		capital_province = { geographical_region = custom_sicily }

		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_promulgated_the_assizes_of_ariano
			}
		}
	}
	
	is_valid = {
		# For the sake of feasibility, we require independence. Lieges of any kind really complicate likely outcomes.
		is_independent_ruler = yes

		root.culture = {
			has_innovation = innovation_royal_prerogative
			has_cultural_tradition = tradition_legalistic
		}
		
		prestige_level >= 3
		
		learning >= 15
		
		NOT = { has_realm_law = crown_authority_0 }
		
		completely_controls = title:d_sicily
	}

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

	effect = {
		show_as_tooltip = { promulgate_the_assizes_of_ariano_scripted_effect = yes }
		trigger_event = {
			id = DE_decision_event.0021
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_promulgated_the_assizes_of_ariano
			}
			set_global_variable = {
				name = flag_promulgated_the_assizes_of_ariano
				value = root
			}
		}
	}

	cost = {
		prestige = 1000
		gold = 500
	}

	# ai_potential = {
		# # AI will only even consider this if they're diligent and already high-tier.
		# highest_held_title_tier >= tier_kingdom
		# has_trait = diligent
	# }

	ai_will_do = {
		base = 1000
	}
}

##################################################
# Establish a new Currency System (Ducat)
# By EmrysValdr
##################################################

establish_the_ducat_coin_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major

	ai_check_interval = 120

	desc = establish_the_ducat_coin_decision_desc

	is_shown = {
		is_lowborn = no			
		is_landed = yes
		is_independent_ruler = yes
		root.culture = {
			has_cultural_era_or_later = culture_era_early_medieval
			has_cultural_tradition = tradition_assizes_ariano
		}		
		has_title = title:k_sicily		
		
		OR = {
			culture = { has_cultural_pillar = heritage_latin }
			culture = { has_cultural_pillar = heritage_central_germanic }	
			culture = { has_cultural_pillar = heritage_iberian }
			has_culture = culture:norman			
		}					
		
		NOR = {	#Title existence cnditions.
			has_title = title:e_byzantium		
			has_title = title:e_latin_empire
		}
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:established_the_ducat_coin
			}
		}		
	}	

	is_valid = {
		root.culture = {
				has_innovation = innovation_currency_02
			}

		prestige_level >= 3

		stewardship >= 15

		NOT = { has_realm_law = crown_authority_0 }

		completely_controls = title:d_sicily
	}

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

	cost = {
		prestige = 1000
		gold = 1000
	}

	effect = {
		show_as_tooltip = { establish_the_ducat_coin_decision_scripted_effect = yes }
		
		trigger_event = { id = DE_decision_event.0022 }

		if ={
			limit = { exists = title:k_italy }
			title:k_italy.holder = {
				trigger_event = {
					id = DE_decision_event.0023
					days = { 7 14 } # Within 2 weeks
				}
			}
		}

		if ={
			limit = { exists = title:k_romagna }
			title:k_romagna.holder = {
				trigger_event = {
					id = DE_decision_event.0023
					days = { 7 14 } # Within 2 weeks
				}
			}
		}

		if ={
			limit = { exists = title:k_venice }
			title:k_venice.holder = {
				trigger_event = {
					id = DE_decision_event.0023
					days = { 7 14 } # Within 2 weeks
				}
			}
		}

		if ={
			limit = { exists = title:k_genoa }
			title:k_genoa.holder = {
				trigger_event = {
					id = DE_decision_event.0023
					days = { 7 14 } # Within 2 weeks
				}
			}
		}

		if ={
			limit = { exists = title:k_pisa }
			title:k_pisa.holder = {
				trigger_event = {
					id = DE_decision_event.0023
					days = { 7 14 } # Within 2 weeks
				}
			}
		}

		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:established_the_ducat_coin
			}
		}		
	}

	ai_will_do = {
		base = 1000
	}
}

##################################################
# Muslims in Sicily Question
# By EmrysValdr
##################################################

resettle_sicilian_muslims_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major

	ai_check_interval = 120

	desc = resettle_sicilian_muslims_decision_desc

	is_shown = {
		is_lowborn = no			
		is_landed = yes
		is_independent_ruler = yes
		
		root.culture = {
			has_cultural_era_or_later = culture_era_early_medieval
		}
		
		religion = religion:christianity_religion
		
		has_title = title:k_sicily				

		NOR = {	#Title existence conditions.
			has_title = title:e_byzantium		
			has_title = title:e_latin_empire
		}	
		
		NOT = {  #Can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:resettled_sicilian_muslims
			}
		}		
	}	

	is_valid = {
		capital_province = { geographical_region = custom_sicily }

		completely_controls = title:k_sicily
		
		root.culture = {
			OR = {		
				has_cultural_tradition = tradition_assizes_ariano
				has_cultural_tradition = tradition_xenophilic
			}
		}
		
		prestige_level >= 4
		
		OR = { 
			has_realm_law = crown_authority_2
			has_realm_law = crown_authority_3
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_at_war = no
	}
	
	cost = {
		prestige = 1000
		gold = 500
	}

	effect = {
		show_as_tooltip = {
			custom_tooltip = decide_on_how_to_handle_sicilian_muslims_tt
		}
		
		trigger_event = DE_decision_event.0024
		
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:resettled_sicilian_muslims
			}
		}		
	}
	
	ai_potential = {
		is_ruler = yes
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = 100
			has_trait = cynical
		}
		modifier = {
			add = 50
			has_trait = ambitious
		}		
		modifier = {
			add = 50
			has_trait = arrogant
		}		
		modifier = {
			add = -300
			has_trait = zealous
		}
		modifier = {
			add = -50
			has_trait = humble
		}		
	}
}

#####################################
# Become the Khwarazmshah			#
# by Celticus Magnus			    #
##################################### 

# Turned into a De Jure Kingdom

							  
							
						 
							  

									
			
																			   
  
							
						

											  
															  

			 
						   
																		 
  
								   
										
									   
													   
	
   
  
																		  
  
																   
  

			 
								  
							
												  

													  
												   
  

								   
						
					
							
				
  

		   
						 
					 
												
   
				   
											  
   
				   
												
								  
									   
																				   
	
						  
												
				
	
   
  

		 
			
				 
  

				 
			  
  

			   
			 
  
 
