﻿### Establish [ROOT.Char.GetFaith.GetAdherentNameNoTooltip] Stronghold ###
restore_badd_fortress_decision = { #This allows a ruler with a Zandik or Chthonic Redoubts faith to restore the Badd fortress (it's in the barony Ahar, which you'll need to capture) and make it his capital.
	title = restore_badd_fortress_decision
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_sunder.dds"
	}
	desc = restore_badd_fortress_decision_desc
	selection_tooltip = restore_badd_fortress_decision_tooltip
	decision_group_type = major
	sort_order = 20
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 120
		kingdom = 120
		empire = 0
		hegemony = 0
	}

	is_shown = {
		faith = { #this is a decision for religious underdogs, needing a mountain home
			OR = { 
				has_doctrine = doctrine_heretic_branch_zandik
				has_doctrine = tenet_cthonic_redoubts
			}
		}

		NOT = { exists = root.faith.religious_head }
			
		is_playable_character = yes 
		exists = dynasty #just for sanity 

		#Must be in the region
		any_held_title = {
			title_tier = county
			title_province = {
				OR = {
					geographical_region = world_asia_minor
					geographical_region = world_middle_east_jerusalem
					geographical_region = world_middle_east_arabia
					geographical_region = world_middle_east_persia 
				}
			}
		}
		#Can't already be an empire, that'd ruin the underdog theme 
		highest_held_title_tier <= tier_kingdom
		#Not repeatable.
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:restored_badd_fortress #so it can't happen twice
			}
		}
	}

	is_valid = {
		#Should have decent piety
		piety_level >= medium_piety_level 
		#Completely controls Badd
		has_title = title:c_tabriz 
		has_title = title:b_ahar 
		faith = { 	#again, a decision for religious underdogs, needing a mountain home
			OR = { 
				has_doctrine = doctrine_heretic_branch_zandik
				has_doctrine = tenet_cthonic_redoubts
			}
		}

		custom_tooltip = {
			text = babak_fortress_faith_requirements 
			title:c_tabriz = {
				save_temporary_scope_as = tabriz
				county = { fp3_fortress_of_faith_county_trigger = yes }
			}
		}
	}

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

	effect = {

		# Trigger effects.
		show_as_tooltip = { restore_badd_fortress_scripted_effect = yes }
		trigger_event = fp3_decision.0003 

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

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = 600
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = 600
			}
		}
		prestige = 500
	}

	ai_potential = {
		top_liege = this #this is to make it unlikely that the AI takes the decision before the player has a chance to 
	}

	ai_will_do = {
		base = 50
	}
}

### Reform the [ROOT.Char.GetFaith.random_AltPriestTermPlural] ###
destroy_the_magi_decision = { #This allows a ruler with sufficient piety and control of holy sites to reform the Zoroastrian priesthood's hierarchy. 
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_strength.dds"
	}
	title = {
		first_valid = {
#			triggered_desc = {
#				trigger = {
#					AND = {
#						religion = religion:zoroastrianism_religion
#						OR = {
#							has_faith = faith:mazdakism
#							has_faith = faith:zurvanism 
#						}
#					}
#				}
#				desc = destroy_the_magi_decision_alternate 
#			}
			desc = destroy_the_magi_decision
		}
	}
	desc = {
		first_valid = {
#			triggered_desc = {
#				trigger = {
#					AND = {
#						religion = religion:zoroastrianism_religion
#						OR = {
#							has_faith = faith:mazdakism
#							has_faith = faith:zurvanism 
#						}
#					}
#				}
#				desc = destroy_the_magi_decision_alternate_desc
#			}
			desc = destroy_the_magi_decision_desc
		}
	}
	
	selection_tooltip = destroy_the_magi_decision_tooltip
	decision_group_type = major
	sort_order = 70
	ai_check_interval = 0

	is_shown = { #this is a decision for religious underdogs that have risen to prominence
		faith = { 
			AND = {
				has_doctrine = doctrine_heretic_branch_zandik 
				has_doctrine = doctrine_theocracy_temporal #you need to still have this doctrine for it to work 
				has_doctrine = doctrine_spiritual_head #you need to still have this doctrine for it to work 
			}
		}

		NOT = { exists = root.faith.religious_head } #if you have restored the Zoroastrian priesthood, you wouldn't wanna destroy it 

		is_ai = no #we don't want the AI to complicate things here 
		is_playable_character = yes 
		exists = dynasty #just for sanity 

		#Not repeatable.
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:destroyed_the_magi #so it can't happen twice
			}
		}
	}

	is_valid = {
		
		piety_level >= high_piety_level
		
		faith = { has_doctrine = doctrine_heretic_branch_zandik }
		
		custom_description = {
			text = "restore_high_priesthood_holy_sites"
			faith = {
				any_holy_site = {
					OR = {
						county.holder = root
						county.holder.top_liege = { this = root }
					}
					count >= 3
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_capable_adult = yes
		is_imprisoned = no
		top_liege = this
		is_at_war = no
	}

	effect = {
		show_as_tooltip = { destroy_the_magi_scripted_effect = yes }
		trigger_event = fp3_decision.0004
	

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

	cost = {
		piety = 1000
	}

	ai_will_do = {
		base = 0
	}
}

### Kindle Royal Fire ###
kindle_royal_fire_decision = {
	title = kindle_royal_fire_decision
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds"
	}
	desc = kindle_royal_fire_decision_desc
	selection_tooltip = kindle_royal_fire_decision_tooltip
	sort_order = 90

	is_shown = {
		is_playable_character = yes 
		religion = religion:zoroastrianism_religion
		NOT = { has_character_modifier = fp3_royal_fire_modifier }		
	}

	is_valid = {
		highest_held_title_tier >= tier_kingdom
		religion = religion:zoroastrianism_religion
		piety_level >= 3
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = pledged_to_quench_fire_tt
			NOT = { has_character_flag = pledged_to_quench_fire }
		}
		custom_tooltip = {
			text = fire_recently_quenched_tt
			NOT = { has_character_flag = fire_recently_quenched }
		}
	}

	effect = {

		#Describe vaguely what the fire does 
		custom_tooltip = kindle_royal_fire_decision_effects_list
		# Show a warning that it might be destroyed if someone takes over your capital
		custom_description_no_bullet = {
			text = kindle_royal_fire_decision_warning
		}
		# Moved ahead to selection.
		trigger_event = fp3_decision.0001 
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	ai_potential = {
		religion = religion:zoroastrianism_religion
		highest_held_title_tier >= tier_kingdom
		NOR = {
			has_trait = cynical 
			has_trait = content
			has_trait = greedy
			has_trait = temperate 
		}
	}

	ai_will_do = {
		base = 100
	}
}

###################################
# Embrace Zoroastrianism
# Adopt a Zoroastrian faith in secret, provided one of your counties follows the chosen faith
###################################
### Embrace Zoroastrianism ###
fp3_embrace_zoroastrianism_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_scenes/fp3_temple.dds"
	}
	desc = fp3_embrace_zoroastrianism_decision_desc
	selection_tooltip = fp3_embrace_zoroastrianism_decision_tooltip
	sort_order = 120
	
	is_shown = {
		culture = { has_cultural_pillar = heritage_iranian }
		# Narratively, this decision is about embracing the faith of your ancestors over newer "modern" faiths
		# Therefore, this decision should not be available to Zoroastrians looking to change their sect
		NOT = { has_religion = religion:zoroastrianism_religion }
		current_date <= 960.1.1
	}

	is_valid = {
		# Don't grant more than 1 secret faith at once
		custom_tooltip = {
			text = no_secret_faith_tt
			NOT = { exists = secret_faith }
		}
		custom_tooltip = {
			text = year_960_tt
			current_date <= 960.1.1
		}
		culture = { has_cultural_pillar = heritage_iranian }
		NOT = { has_religion = religion:zoroastrianism_religion }
	}

	is_valid_showing_failures_only = {
		is_physically_able_adult = yes
		custom_tooltip = {
			text = zoroastrian_county_tt
			any_sub_realm_county = {
				faith = {
					religion = religion:zoroastrianism_religion
				}
			}
		}
	}

	effect = {
		custom_tooltip = fp3_embrace_zoroastrianism_decision.tt
		trigger_event = fp3_misc_decisions.0015
	}

	cost = { piety = major_piety_value }
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}
	ai_potential = {
		ai_zeal <= -25
		ai_rationality <= -50
		OR = {
			has_trait = cynical
			has_trait = fickle
			has_trait = eccentric
			has_trait = lunatic
			has_trait = arbitrary
		}
	}
	ai_will_do = {
		base = 20
	}
}
