﻿call_constituent_assembly_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}

	desc = call_constituent_assembly_decision_desc
	selection_tooltip = call_constituent_assembly_decision_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = enables_constituent_assembly
		}
		has_title = root.faith.religious_head_title
		NOT = {
			has_character_flag = assembly_once_lifetime
		}
	}

	is_valid = {
		custom_description = {
			text = consituent_assembly_timing
			NOT = { has_global_variable = recent_constituent_assembly }
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		trigger_event = ate_religious_decision.81
		custom_tooltip = call_constituent_assembly_effect
		set_global_variable = {
			name = recent_constituent_assembly
			value = 1
			years = 40
		}
		add_character_flag = assembly_once_lifetime
	}

	ai_check_interval = 36

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

meditate_on_the_marquess_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	desc = meditate_on_the_marquess_decision_desc
	selection_tooltip = meditate_on_the_marquess_decision_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = meditate_on_the_marquess_active
		}
	}
	cooldown = {
		years = 20
	}
	is_valid = {
	}

	is_valid_showing_failures_only = {
	}
	cost = {
		piety = 100
	}
	effect = {
		custom_tooltip = meditate_on_the_marquess_decision_tt
		hidden_effect = {
			trigger_event = ate_religious_decision.89
		}
	}

	ai_check_interval = 96

	ai_potential = {
		piety >= 100
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

draw_geoglyph_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = draw_geoglyph_decision_desc
	selection_tooltip = draw_geoglyph_decision_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = draw_geoglyph_active
		}
	}

	cooldown = {
		years = 7
	}

	is_valid = {
		custom_description = {
			text = geoglyph_capital_desc
			capital_province = {
				county = {
					NOT = {
						OR = {
							has_county_modifier = county_drawn_geoglyph_modifier
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {

	}
	
	cost = {
		gold = standard_activity_cost
	}

	effect = {
		#The modifier will only be active if a character of your dynasty holds it

		random_list = {
			50 = {
				capital_province = {
					county = {
						add_county_modifier = {
							modifier = county_drawn_geoglyph_modifier
							years = 10
						}
					}
				}
			}
			30 = {
				capital_province = {
					county = {
						add_county_modifier = {
							modifier = county_drawn_bad_geoglyph_modifier
							years = 10
						}
					}
				}
			}
			20 = {
				capital_province = {
					county = {
						add_county_modifier = {
							modifier = county_drawn_good_geoglyph_modifier
							years = 10
						}
					}
				}
			}
		}
		add_piety = medium_piety_value
		every_vassal = {
			limit = {
				faith = {
					has_doctrine_parameter = draw_geoglyph_active
				}
			}
			custom = drawn_geoglyph_vassals
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
	}

	ai_check_interval = 36

	ai_potential = {
		always = yes
	}
	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

#calling_occupants_decision = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
#	}
#
#	desc = calling_occupants_decision_desc
#	selection_tooltip = calling_occupants_decision_tooltip
#
#	is_shown = {
#		faith = {
#			has_doctrine_parameter = draw_geoglyph_active
#		}
#		capital_province ?= {
#			county = { has_county_modifier = county_drawn_geoglyph_modifier }
#		}
#	}
#
#	is_valid = {
#		#nothing for now, we need to add a "contacting aliens" event chain
#	}
#
#	is_valid_showing_failures_only = {
#		#nothing for now, we need to add a "contacting aliens" event chain
#	}
#
#	effect = {
#		#nothing for now, we need to add a "contacting aliens" event chain
#	}
#
#	ai_check_interval = 36
#
#	ai_potential = {
#		always = yes
#	}
#	ai_will_do = {
#		base = 50
#
#		# 100% chance at 50 zeal, 0% chance at -50 zeal.
#		ai_value_modifier = {
#			ai_zeal = 1
#		}
#	}
#}

dedicate_anima_shrine = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp1_decision_raise_runestone.dds"
	}

	desc = dedicate_anima_shrine_desc
	selection_tooltip = dedicate_anima_shrine_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = anima_shrines_active
		}
		has_variable = tragical_anima
		capital_province = {
			county = {
				NOT = {
					has_county_modifier = county_dedicated_anima_shrine
				}
			}
		}
	}

	is_valid = {

	}

	is_valid_showing_failures_only = {

	}

	cost = { gold = standard_activity_cost }

	effect = {
		capital_province = {
			county = {
				add_county_modifier = {
					modifier = county_dedicated_anima_shrine
				}
				set_variable = {
					name = tragical_anima
					value = root.var:tragical_anima
				}
			}
		}
		add_piety = medium_piety_value
		stress_impact = {
			base = medium_stress_loss
			cynical = 20
		}
		remove_variable = tragical_anima
		hidden_effect = {
			trigger_event = {
				id = ate_religious_decision.102
				months = 1
			}
		}
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

select_a_patron_anima = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = select_a_patron_anima_desc
	selection_tooltip = select_a_patron_anima_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = anima_shrines_active
		}
		NOT = {
			has_variable = patron_anima
		}
		NOT = {
			OR = {
				has_trait = patron_difunta_correa
				has_trait = patron_balmaceda
				has_trait = patron_ceferino
			}
		}
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		trigger_event = ate_religious_decision.103
		custom_tooltip = select_a_patron_anima_effect
	}

	ai_check_interval = 1

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 1
	}
}

build_sanctuary_anima = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = build_sanctuary_anima_desc
	selection_tooltip = build_sanctuary_anima_tooltip

	is_shown = {
		#global_variable_list_size = { name = greater_animas value < 3 }
		highest_held_title_tier >= tier_kingdom
		faith = {
			has_doctrine_parameter = anima_shrines_active
		}
		has_variable = patron_anima
		NOT = {
			OR = {
				has_trait = patron_difunta_correa
				has_trait = patron_balmaceda
				has_trait = patron_ceferino
			}
		}
		capital_province = {
			county = {
				has_county_modifier = county_dedicated_anima_shrine
			}
		}
		capital_province = {
			county = {
				has_variable = established_anima
			}
		}
	}

	is_valid = {
		piety_level >= 4
		NOT = {
			has_global_variable = greater_anima_3
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		trigger_event = ate_religious_decision.104
		custom_tooltip = build_sanctuary_anima_tooltip
	}

	cost = {
		gold = 600
		prestige = 600
		piety = 1000
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

hold_challa_ritual_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = hold_challa_ritual_decision_desc
	selection_tooltip = hold_challa_ritual_decision_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = challa_ritual_enabled
		}
		NOR = {
			has_character_modifier = challa_blessing_1
			has_character_modifier = challa_blessing_2
			has_character_modifier = challa_blessing_3
		}
	}
	cooldown = {
		years = 1
	}
	is_valid = {

	}

	is_valid_showing_failures_only = {

	}

	effect = {
		hidden_effect = {
			trigger_event = ate_religious_decision.110
		}
		custom_tooltip = hold_challa_ritual_effect
		stress_impact = {
			cynical = 20
		}
	}

	cost = {
		gold = standard_activity_cost
	}

	ai_check_interval = 36

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

consult_the_huacas_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = consult_the_huacas_decision_desc
	selection_tooltip = consult_the_huacas_decision_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = consult_the_huacas_enabled
		}
	}
	cooldown = {
		years = 5
	}
	is_valid = {
		custom_description = {
			text = decision_has_court_chaplain
			exists = cp:councillor_court_chaplain
			cp:councillor_court_chaplain = {
				is_available_adult = yes
			}
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		hidden_effect = {
			trigger_event = ate_religious_decision.112
		}
		custom_tooltip = consult_the_huacas_effect
	}

	cost = {
		gold = standard_activity_cost
	}

	ai_check_interval = 36

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

get_initiated_mystery_cult_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_recruitment.dds"
	}

	desc = get_initiated_mystery_cult_decision_desc
	selection_tooltip = get_initiated_mystery_cult_decision_tooltip

	is_shown = {
		faith = {
			has_doctrine_parameter = dark_covens_active
			religion_tag = llanoism_religion
		}
		NOR = {
			has_character_modifier = hell_stallion
			has_character_modifier = night_mare
		}
	}
	is_valid = {
		is_adult = yes
		OR = {
			custom_description = {
				text = decision_has_court_chaplain_same_gender_male
				exists = cp:councillor_court_chaplain
				is_male = yes
				cp:councillor_court_chaplain = {
					is_available_adult = yes
					is_male = yes
				}
			}
			custom_description = {
				text = decision_has_court_chaplain_same_gender_female
				exists = cp:councillor_court_chaplain
				is_female = yes
				cp:councillor_court_chaplain = {
					is_available_adult = yes
					is_female = yes
				}
			}
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		hidden_effect = {
			trigger_event = ate_religious_decision.120
		}
		custom_tooltip = get_initiated_mystery_cult_effect
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

machete_pray_for_prosperity_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = machete_pray_for_prosperity_decision_desc
	selection_tooltip = machete_pray_for_prosperity_decision_tooltip
	cooldown = {
		years = 10
	}
	is_shown = {
		faith = {
			has_doctrine_parameter = dark_covens_active
			religion_tag = llanoism_religion
		}
		OR = {
			has_character_modifier = hell_stallion
			has_character_modifier = night_mare
		}
	}
	is_valid = {
		is_adult = yes
		OR = {
			has_character_modifier = hell_stallion
			has_character_modifier = night_mare
		}
		OR = {
			custom_description = {
				text = decision_has_court_chaplain_same_gender_male
				exists = cp:councillor_court_chaplain
				is_male = yes
				cp:councillor_court_chaplain = {
					is_available_adult = yes
					is_male = yes
				}
			}
			custom_description = {
				text = decision_has_court_chaplain_same_gender_female
				exists = cp:councillor_court_chaplain
				is_female = yes
				cp:councillor_court_chaplain = {
					is_available_adult = yes
					is_female = yes
				}
			}
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		hidden_effect = {
			random_list = {
				50 = {
					trigger_event = ate_religious_decision.121
				}
				50 = {
					trigger_event = ate_religious_decision.122
				}
			}
		}
		custom_tooltip = machete_pray_for_prosperity_effect
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

#Programming Spells CUT CONTENT
#get_initiated_programming_cult_decision = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_recruitment.dds"
#	}
#
#	desc = get_initiated_programming_cult_decision_desc
#	selection_tooltip = get_initiated_programming_cult_decision_tooltip
#
#	is_shown = {
#		faith = {
#			has_doctrine_parameter = dark_covens_active
#			religion_tag = digital_religion
#		}
#		NOR = {
#			has_character_modifier = hardware_magicks
#			has_character_modifier = software_magicks
#		}
#	}
#	is_valid = {
#		is_adult = yes
#		#OR = {
#		#	custom_description = {
#		#		text = decision_has_court_chaplain_same_gender_male
#		#		exists = cp:councillor_court_chaplain
#		#		is_male = yes
#		#		cp:councillor_court_chaplain = {
#		#			is_available_adult = yes
#		#			is_male = yes
#		#		}
#		#	}
#		#	custom_description = {
#		#		text = decision_has_court_chaplain_same_gender_female
#		#		exists = cp:councillor_court_chaplain
#		#		is_female = yes
#		#		cp:councillor_court_chaplain = {
#		#			is_available_adult = yes
#		#			is_female = yes
#		#		}
#		#	}
#		#}
#	}
#
#	is_valid_showing_failures_only = {
#
#	}
#
#	effect = {
#		hidden_effect = {
#			trigger_event = programming.001
#		}
#		custom_tooltip = get_initiated_programming_cult_effect
#	}
#
#	ai_check_interval = 12
#
#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 100
#	}
#}
#
#programming_pray_for_prosperity_decision = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
#	}
#
#	desc = programming_pray_for_prosperity_decision_desc
#	selection_tooltip = programming_pray_for_prosperity_decision_tooltip
#	cooldown = {
#		years = 10
#	}
#	is_shown = {
#		faith = {
#			has_doctrine_parameter = select_programming_spells_active
#		}
#		OR = {
#			has_character_modifier = hardware_magicks
#			has_character_modifier = software_magicks
#		}
#	}
#	is_valid = {
#		is_adult = yes
#		OR = {
#			has_character_modifier = hardware_magicks
#			has_character_modifier = software_magicks
#		}
#		#OR = {
#		#	custom_description = {
#		#		text = decision_has_court_chaplain_same_gender_male
#		#		exists = cp:councillor_court_chaplain
#		#		is_male = yes
#		#		cp:councillor_court_chaplain = {
#		#			is_available_adult = yes
#		#			is_male = yes
#		#		}
#		#	}
#		#	custom_description = {
#		#		text = decision_has_court_chaplain_same_gender_female
#		#		exists = cp:councillor_court_chaplain
#		#		is_female = yes
#		#		cp:councillor_court_chaplain = {
#		#			is_available_adult = yes
#		#			is_female = yes
#		#		}
#		#	}
#		#}
#	}
#
#	is_valid_showing_failures_only = {
#
#	}
#
#	effect = {
#		hidden_effect = {
#			random_list = {
#				50 = {
#					trigger_event = programming.002
#				}
#				50 = {
#					trigger_event = programming.003
#				}
#			}
#		}
#		custom_tooltip = programming_pray_for_prosperity_effect
#	}
#
#	ai_check_interval = 12
#
#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 100
#	}
#}

nguillatun_become_toqui_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = nguillatun_become_toqui_decision_desc
	selection_tooltip = nguillatun_become_toqui_decision_tooltip
	is_shown = {
		faith = faith:nguillatun
		title:d_toqui = {
			is_title_created = no
		}
		faith = {
			fervor <= 75
		}
	}
	is_valid = {
		faith = {
			AND = {
				fervor > 50
				fervor <= 75
			}
		}
		OR = {
			martial >= 13
			prowess >= 13
		}
		is_adult = yes
		is_independent_ruler = yes
		OR = {
			AND = {
				OR = {
					highest_held_title_tier = tier_kingdom
					highest_held_title_tier = tier_empire
				}
				prestige >= 400
				piety >= 650
			}
			AND = {
				highest_held_title_tier = tier_duchy
				prestige >= 650
				piety >= 900
			}
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		if = {
			limit = {
				root.faith  = {
					has_doctrine = doctrine_no_head
				}
			}
			root.faith = {
				remove_doctrine = doctrine_no_head
				add_doctrine = doctrine_temporal_head
			}
		}
		if = {
			limit = {
				highest_held_title_tier = tier_duchy
			}
			add_prestige = -750
			add_piety = -1000
		}
		if = {
			limit = {
				OR = {
					highest_held_title_tier = tier_kingdom
					highest_held_title_tier = tier_empire
				}
			}
			add_prestige = -500
			add_piety = -750
		}
		get_title = title:d_toqui
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

nguillatun_call_futakoyag_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = nguillatun_call_futakoyag_decision_desc
	selection_tooltip = nguillatun_call_futakoyag_decision_tooltip
	is_shown = {
		faith = faith:nguillatun
		title:d_toqui = {
			is_title_created = no
		}
		faith = {
			fervor > 75
		}
	}
	is_valid = {
		OR = {
			martial >= 10
			prowess >= 10
		}
		is_adult = yes
		is_independent_ruler = yes
		prestige >= 250
		piety >= 250
	}

	is_valid_showing_failures_only = {

	}
	cost = { gold = standard_activity_cost }
	effect = {
		stress_impact = {
			zealous = medium_stress_loss
			cynical = 20
		}
		hidden_effect = {
			trigger_event = ate_religious_decision.124
		}
		custom_tooltip = nguillatun_call_futakoyag_effect
		add_prestige = -250
		add_piety = -250
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}


nguillatun_ritual_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = nguillatun_ritual_decision_desc
	selection_tooltip = nguillatun_ritual_decision_tooltip
	is_shown = {
		faith = {
			has_doctrine_parameter = toqui_leadership_active
			religion_tag = mapuche_religion
		}
	}
	is_valid = {
		is_adult = yes
		NOT = {
			OR = {
				has_character_modifier = nguillatun_blessing_2
				has_character_modifier = nguillatun_blessing_1
				has_character_modifier = nguillatun_blessing_0
			}
		}
	}

	is_valid_showing_failures_only = {

	}
	cooldown = {
		years = 4
	}
	effect = {
		hidden_effect = {
			trigger_event = ate_religious_decision.131
		}
		custom_tooltip = hold_nguillatun_effect
		stress_impact = {
			cynical = 20
		}
	}

	cost = {
		gold = standard_activity_cost
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}


nguillatun_establish_nizol_machi_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = nguillatun_establish_nizol_machi_decision_desc
	selection_tooltip = nguillatun_establish_nizol_machi_decision_tooltip
	is_shown = {
		faith = faith:nguillatun
		highest_held_title_tier = tier_empire
		NOT = {
			OR = {
				root.faith = {
					doctrine_is_spiritual_type = yes
				}
				title:d_nizol_machi = {
					is_title_created = yes
				}
			}
		}
	}
	is_valid = {
		faith = {
			fervor < 50
		}
		has_title = title:c_villarrica
		is_adult = yes
		is_independent_ruler = yes

	}

	is_valid_showing_failures_only = {

	}
	cost = {
		gold = major_gold_value
	}
	effect = {
		title:d_toqui = {
			holder = {
				destroy_title = title:d_toqui
			}
		}
		faith = {
			set_religious_head_title = title:d_nizol_machi
		}
		if = {
			limit = {
				root.faith  = {
					has_doctrine = doctrine_no_head
				}
			}
			root.faith = {
				remove_doctrine = doctrine_no_head
				add_doctrine = doctrine_spiritual_head
			}
		}
		if = {
			limit = {
				root.faith  = {
					has_doctrine = doctrine_temporal_head
				}
			}
			root.faith = {
				remove_doctrine = doctrine_temporal_head
				add_doctrine = doctrine_spiritual_head
			}
		}
		if = {
			limit = {
				root.faith  = {
					has_doctrine = doctrine_theocracy_lay_clergy
				}
			}
			root.faith = {
				remove_doctrine = doctrine_theocracy_lay_clergy
				add_doctrine = doctrine_theocracy_temporal
			}
		}
		hidden_effect = {
			trigger_event = ate_religious_decision.129
		}
		custom_tooltip = nguillatun_establish_nizol_machi_effect
	}

	ai_check_interval = 12

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

call_interfaith_service_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = call_interfaith_service_decision_desc
	selection_tooltip = call_interfaith_service_decision_tooltip

	cost = { gold = standard_activity_base_cost }

	cooldown = { years = 5 }

	is_shown = {
		faith = { has_doctrine_parameter = inter_faith_services_active }
		is_landed = yes
		highest_held_title_tier > tier_barony
		any_vassal = {
			count > 1
		}
	}
	
	is_valid = {
		is_adult = yes
		any_vassal = {
			NOT = {
				faith = root.faith
			}
		}
	}

	effect = {
		trigger_event = ate_religious_decision.134
		custom_tooltip = call_interfaith_service_decision_effect_1
		custom_tooltip = call_interfaith_service_decision_effect_2
		custom_tooltip = call_interfaith_service_decision_effect_3
	}

	ai_check_interval = 12

	ai_will_do = {
		base = 100
	}

}

use_sacramental_herbs_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	desc = use_sacramental_herbs_decision_desc
	selection_tooltip = use_sacramental_herbs_decision_tooltip

	#desc = {
		#first_valid = {
			#triggered_desc = {  #TODO - unique, non-cannabis desc for peyotism
			#	trigger = {
			#		faith = peyotist
			#	}
			#	desc = use_sacramental_herbs_decision_peyotist_desc
			#}
			#desc = use_sacramental_herbs_decision_desc
		#}
	#}

	is_shown = {
		faith = { has_doctrine_parameter = tenet_sacramental_herbs_active }
	}
	cooldown = {
		years = 5
	}
	is_valid = {
	
	}

	is_valid_showing_failures_only = {

	}
	cost = {
		piety = 100
	}
	effect = {
		custom_tooltip = use_sacramental_herbs_decision_tt
		trigger_event =  ate_religious_decision.150 
		#hidden_effect = {
			#if = { #Special event chain for peyotists
			#	limit = {
			#		OR = {
			#		root = { has_faith = faith:half_moon }
			#		root = { has_faith = faith:fire_cross }
			#		}
			#	}
			#	trigger_event = ate_religious_decision.156
			#}
			#else = {
			#	trigger_event = ate_religious_decision.150
			#}
		#}
	}

	ai_check_interval = 96

	ai_potential = {
		piety >= 100
	}

	ai_will_do = {
		base = 50

		# 100% chance at 50 zeal, 0% chance at -50 zeal.
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}

#start_whale_hunt = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_activity.dds"
#	}
#
#	desc = start_whale_hunt_desc
#	selection_tooltip = start_whale_hunt_tooltip
#	major = no
#	cost = { gold = standard_activity_cost }
#	cooldown = { days = standard_feast_cooldown_time }
#
#	ai_check_interval = 120
#
#	is_shown = {
#		is_ruler = yes
#		is_landed = yes
#		culture = {
#			has_cultural_parameter = unlock_rice_whaling
#		}
#	}
#
#	is_valid_showing_failures_only = {
#		is_available_adult = yes
#	}
#
#	effect = {
#		trigger_event = {
#			id = whale.1
#			days = 10
#		}
#		add_stress = -30
#		add_piety = 50
#		capital_province = {
#			spawn_activity = {
#				type = activity_whale_hunt
#				owner = root
#			}
#		}
#	}
#
#	ai_will_do = {
#		base = 40
#	}
#}

# build_memento_crypt = {
# 	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
#	}
#
# 	desc = build_memento_crypt_desc
# 	selection_tooltip = build_memento_crypt_tooltip

# 	is_shown = {
# 		faith = {
# 			has_doctrine_parameter = enables_memento_mori
# 		}
# 		capital_province = {
# 			county = {
# 				NOT = {
# 					has_county_modifier = county_memento_crypt
# 				}
# 			}
# 		}
# 	}

# 	is_valid = {
# 		has_character_modifier = memento_mori_5
# 	}

# 	is_valid_showing_failures_only = {

# 	}

# 	cost = { gold = standard_activity_cost }

# 	effect = {
# 		capital_province = {
# 			county = {
# 				add_county_modifier = {
# 					modifier = county_memento_crypt
# 				}
# 			}
# 		}
# 		remove_character_modifier = memento_mori_5
# 		add_piety = medium_piety_value
# 	}

# 	ai_check_interval = 12

# 	ai_potential = {
# 		always = yes
# 	}

# 	ai_will_do = {
# 		base = 50

# 		# 100% chance at 50 zeal, 0% chance at -50 zeal.
# 		ai_value_modifier = {
# 			ai_zeal = 1
# 		}
# 	}
# }

# visit_memento_crypt = {
# 	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
#	}
#
# 	desc = visit_memento_crypt_desc
# 	selection_tooltip = visit_memento_crypt_tooltip
#
# 	is_shown = {
# 		faith = {
# 			has_doctrine_parameter = enables_memento_mori
# 		}
# 		capital_province ?= {
# 			county = {
# 				has_county_modifier = county_memento_crypt
# 			}
# 		}
# 	}
#
# 	is_valid = {
# 		NOT = {
# 			has_character_modifier = visited_crypt_recent
# 		}
# 	}
#
# 	is_valid_showing_failures_only = {
#
# 	}
#
# 	cost = { piety = 100 }
#
# 	effect = {
# 		add_character_modifier = {
# 			modifier = visited_crypt_recent
# 			years = 4
# 		}
# 		trigger_event = {
# 			id = ate_religious_decision.175
# 			days = 3
# 		}
# 	}
#
# 	ai_check_interval = 48
#
# 	ai_potential = {
# 		always = yes
# 	}
#
# 	ai_will_do = {
# 		base = 50
#
# 		# 100% chance at 50 zeal, 0% chance at -50 zeal.
# 		ai_value_modifier = {
# 			ai_zeal = 1
# 		}
# 	}
# }

get_washington_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}

	desc = get_washington_decision_desc
	selection_tooltip = get_washington_decision_tooltip
	decision_group_type = major

	ai_check_interval = 12

	is_shown = {
		is_ruler = yes
		is_landed = yes
		has_title = faith:principlist.religious_head_title
		NOT = { title:c_washington.holder = this }
	}
	
	is_valid = {
		title:c_washington.holder = {
			OR = {
				custom_description = { # holder is a vassal
					text = get_washington_decision_any_liege_or_above_tt
					any_liege_or_above = { this = root }	
				}
				custom_description = { # holder's faith sees the President as HoF
					text = get_washington_decision_americanist_faith_tt
					faith = { has_doctrine_parameter = follows_americanist_presidency }
				}
			}
		}
	}

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

	effect = {
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		title:c_washington = {
			change_title_holder = {
				holder = root
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		
		if = {
			limit = { NOT = { has_title = title:d_capital } }
			create_title_and_vassal_change = {
				type = returned
				save_scope_as = change
				add_claim_on_loss = no
			}
			title:d_capital = {
				change_title_holder = {
					holder = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
	}
}

restore_hcc_decision = { # "Reclaim Imperial Dignity"
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}

	desc = restore_hcc_decision_desc
	selection_tooltip = restore_hcc_decision_tooltip
	decision_group_type = major

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		OR = {
			capital_county.empire = title:e_hcc
			culture = { has_cultural_pillar = heritage_deep_south }
			culture = { has_cultural_pillar = heritage_old_south }
		}
		NOT = { exists = title:e_hcc.holder }
		NOT = { has_global_variable = hcc_restored }
		NOT = { has_title = title:e_usa }
	}
	
	is_valid = {
		# Majority of HCC counties are in realm
		OR = {
			realm_size >= 120
			AND = {
				realm_size >= 90
				custom_description = {
					text = restore_hcc_decision_acr_tt
					OR = { # Atlanta, Charleston, or Raleigh are in realm
						title:c_atlanta.holder.top_liege = this
						title:c_charleston.holder.top_liege = this
						title:c_raleigh.holder.top_liege = this
					}
				}
			}
			AND = {
				realm_size >= 50
				custom_description = {
					text = restore_hcc_decision_acr_two_tt
					OR = { # Any two of Atlanta, Charleston, or Raleigh are in realm
						AND = {
							title:c_atlanta.holder.top_liege = this
							title:c_charleston.holder.top_liege = this
						}
						AND = {
							title:c_atlanta.holder.top_liege = this
							title:c_raleigh.holder.top_liege = this
						}
						AND = {
							title:c_charleston.holder.top_liege = this
							title:c_raleigh.holder.top_liege = this
						}
					}
				}
				OR = {
					completely_controls = title:k_georgia
					completely_controls = title:k_palmetto
					completely_controls = title:k_tarheel
					completely_controls = title:k_alabama
				}
			}
		}
		prestige_level >= 4 # Exalted Among Men
	}

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

	cost = { # Same as forming a regular empire
		gold = 1200
		prestige = 2000
		piety = 600
	}

	effect = {
		set_global_variable = {
			name = hcc_restored
			value = yes
		}
		custom_description = {
			text = restore_hcc_decision_tt
			trigger_event = { id = ate_calvert_appeal.39 }
			# Launches "Restoration of the Southern Empire" event allowing player to:
			##- Create a new Empire,
			##- Retain their current one (if currently holding an Empire),
			##- Restore the HCC (if Evangelical/Evangheresy), or
			##- Restore the HCC but retain regnals of the currently held Empire rather than the old HCC
			### (i.e. destroy old Empire, create a new Empire called HCC, copy title history of current title; only if currently holding an Empire, and Christian or Christo-Syncretic)
		}
		# Assign Dynamic Prince-Electors
		custom_tooltip = hcc_elector_list_creation_tt
		hidden_effect = {
			if = {
				limit = { has_global_variable_list = hcc_elector_list }
				clear_global_variable_list = hcc_elector_list
			}
			while = {
				count = 7
				random_vassal = {
					limit = {
						capital_province.empire = title:e_hcc # 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 = hcc_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_georgia
									target_is_de_jure_liege_or_above = title:k_palmetto
									target_is_de_jure_liege_or_above = title:k_tarheel
									target_is_de_jure_liege_or_above = title:k_alabama
								}
							}
						}
						modifier = { # we want at least 3 theocracies ideally
							factor = 10
							any_in_global_list = {
								variable = hcc_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 = hcc_elector_list
								count >= 3
								holder = { government_has_flag = government_is_theocracy }
							}
							government_has_flag = government_is_theocracy
						}
					}
					add_to_global_variable_list = {
						name = hcc_elector_list
						target = primary_title
					}
				}
			}
			hcc_elector_list_save_effect = yes # saves list scopes to title as variables for tooltip
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
	}
}

america_combine_temporal_and_spiritual_usa_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	}

	desc = america_combine_temporal_decision_desc
	selection_tooltip = america_combine_temporal_tooltip
	decision_group_type = major

	ai_check_interval = 12

	is_shown = {
		is_ruler = yes
		is_landed = yes
		has_title = title:e_usa
		has_title = title:k_presidency
	}
	
	is_valid = {
		completely_controls = title:c_washington
	}

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

	effect = {
		custom_tooltip = combine_temporal_america_decision_effect_tooltip
		trigger_event = {
			id = american_restoration.1000
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
	}
}

# america_challenge_temporal_and_spiritual_usa_decision = {
# 	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
#	}

# 	desc = get_washington_decision_desc
# 	selection_tooltip = get_washington_decision_tooltip
# 	decision_group_type = major

# 	ai_check_interval = 12

# 	is_shown = {
# 		is_ruler = yes
# 		is_landed = yes
# 		has_title = title:e_usa
# 		NOT = { has_global_variable = spiritual_presidency_fused }
# 		exists = title:k_presidency.holder
# 	}
	
# 	is_valid = {
# 		completely_controls = title:c_washington
# 	}

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

# 	effect = {
# 		custom_tooltip = combine_temporal_america_decision_effect_tooltip
# 		trigger_event = {
# 			id = american_restoration.1000
# 		}
# 	}
	
# 	ai_potential = {
# 		always = yes
# 	}

# 	ai_will_do = { #Do it always, for coherence.
# 		base = 100
# 	}
# }

###Lakeshore add Detroit 

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

	ai_check_interval = 120

	desc = lakeshore_add_detroit_decision_desc
	selection_tooltip = lakeshore_add_detroit_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		# Must be lakeshore faith or reformed version (determined via hidden vir/sin doctrine), and decision has not been taken yet.
		faith = {
			has_doctrine = doctrine_lakeshore_virsin
		}
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:lakeshore_detroit_added
			}
		}
	}

	is_valid = {
		#independent
		is_independent_ruler = yes
		#Own Detroit
		has_title = title:c_detroit
		#have decent enough piety/prestige levels
		prestige_level >= 3
		piety_level >= 3
		#needs to be reformed
		NOT = {
			faith = {
				has_doctrine = unreformed_faith_doctrine
			}
		}
		#Detroit must be your faith (lakeshore)
		title:c_detroit = {
			faith = ROOT.faith
		}
	}
		

	is_valid_showing_failures_only = {
		is_available_at_peace_adult = yes
	}

	effect = {
		#save scope
		#save_scope_as = detroit_lakeshore_restorer
		# Send an event.
		#trigger_event = ate_religious_decision.lakeshore.detroit
		#activate the site
		faith:lakeshore = {
			activate_holy_site = lakeshore_detroit
		}
		#give the player some renown
		dynasty = {
			add_dynasty_prestige = medium_dynasty_prestige_value
		}
		#and a nickname
		give_nickname = nick_the_lightbringer
		#add the flag to prevent it from being repeated
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:lakeshore_detroit_added
			}
		}
	}

	cost = { 
		piety = 750
		prestige = 750
		gold = 500
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 20
	}
}

#Shoreline Reverence

recruit_water_specialist_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_invite_knights.dds"
	}
	sort_order = 75

	ai_check_interval = 120

	cooldown = { years = 5 }
	
	desc = recruit_water_specialist_decision_desc

	is_shown = {
		faith = {
			has_doctrine_parameter = can_recruit_forder_active
		}
	}

	effect = {
		custom_tooltip = recruit_water_specialist_decision.tt
		hidden_effect = {
			recruit_terrain_specialist_effect = {
				SPECIALIST_TRAIT = forder
				SPECIALIST_TEMPLATE_CHARACTER = water_commander_character
			}
		}
	}

	cost = {
		gold = {
			value = minor_gold_value
		}
		prestige = {
			value = medium_prestige_value
		}
	}

	ai_potential = {
		faith = {
			has_doctrine_parameter = can_recruit_forder_active
		}
	}

	ai_will_do = {
		base = 100

		modifier = {
			factor = 0
			any_courtier = {
				has_trait = forder
			}
		}
	}
}

###Occultism
perform_dark_ritual_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = perform_dark_ritual_decision_desc
	selection_tooltip = perform_dark_ritual_decision_tooltip
	decision_group_type = major

	ai_check_interval = 3

	is_shown = {
		is_ruler = yes
		is_landed = yes
		faith = { 	
			has_doctrine = tenet_dark_rituals
		}
	}
	
	cooldown = {
		years = 5
	}
	
	is_valid = {
		faith = { 	
			has_doctrine = tenet_dark_rituals
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		#is_imprisoned = no
	}

	effect = {
		add_piety = 250
		add_stress = 100
		
		hidden_effect = {
			random_list = {
				12 = {
					trigger_event = {
						id = ate_religious_decision.200
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.201
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.202
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.203
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.204
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.205
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.206
					}
				}
				12 = {
					trigger_event = {
						id = ate_religious_decision.207
					}
				}
			}
		}
	}
	ai_potential = {
		#Desperate times require desperate measures
		OR = {
			any_character_war = {
				exists = yes
				primary_attacker = prev
				attacker_war_score < -10
			}
			any_character_war = {
				exists = yes
				primary_defender = prev
				defender_war_score < -10
			}
			gold < -10
		}
	}
	ai_will_do = {
		base = 100
	}
}

###Water Burials

give_water_burial_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	sort_order = 75
	
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { 
					OR= { 
						has_religion = religion:conterraneo_religion
						has_religion = religion:catimbo_religion
						has_religion = religion:rezadeiros_religion
						}
					}
					desc = give_river_burial_decision_desc
				}
			desc = give_water_burial_decision_desc
		}
	}

	selection_tooltip = give_water_burial_decision_tooltip

	is_shown = {
		#faith = { has_doctrine_parameter = water_burials_active }
		#has_variable = ancestor_to_bury
		always = no
	}

	is_valid = { }
	is_valid_showing_failures_only = { }

	effect = {
		show_as_tooltip = {
		add_piety = major_piety_value
		if = {
			limit = { any_vassal = { faith = { has_doctrine_parameter = water_burials_active } } }
				every_vassal = { limit = { faith = { has_doctrine_parameter = water_burials_active } }
				custom = give_water_burial_vassals
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 20
					}
				}
			}
		}
		trigger_event = ate_religious_decision.185
	}

	ai_check_interval = 36
	cooldown = { months = 12 }
	ai_potential = { always = yes }
	ai_will_do = { base = 100 }
}

jolljepunco_break_with_inti_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_invite_knights.dds"
	}
	decision_group_type = major

	ai_check_interval = 120

	desc = jolljepunco_break_with_inti_decision_desc
	selection_tooltip = jolljepunco_break_with_inti_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		exists = dynasty
		# Must be relevant faith, and decision has not been taken yet.
		faith = faith:jolljepunco
		NOR = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:jolljepunco_bound_to_inti
			}
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:jolljepunco_broke_with_inti
			}
		}
		
		exists = faith.religious_head
	}

	is_valid = {
		# Requires a solid piety level.
		piety_level >= very_high_piety_level
		# Needs a solid chunk of counties.
		is_independent_ruler = yes
		OR = {
			custom_description = {
				text = jolljepunco_break_with_inti_decision.control_two_holy_sites
				faith = {
					any_holy_site = {
					count >= 2
					holder.top_liege = root
					}
				}
			}
			custom_description = {
				text = jolljepunco_break_with_inti_decision.inca_emperor_not_inti
				OR = {
					NOT = { exists = title:e_inca.holder }
					title:e_inca.holder = {
						NOT = {
							faith = faith:inti_religion
						}
					}
				}
			}
		}
	}
		

	is_valid_showing_failures_only = {
		is_available_at_peace_adult = yes
	}

	effect = {
		save_scope_as = religious_leader
		faith.religious_head = { save_scope_as = willaq_umu }
		custom_tooltip = jolljepunco_break_with_inti_decision.tt.hof_warning
		show_as_tooltip = {
			random_list = {
				100 = {
					show_chance = no
					desc = jolljepunco_break_with_inti_decision
					jolljepunco_break_with_inti_decision_scripted_effect = yes
				}
			}
		}
		# Send the event.
		trigger_event = ate_hof_replacement.0001
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:jolljepunco_broke_with_inti
			}
		}
	}

	cost = { piety = 1500 }

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		# The AI will only consider this if they match certain trait requirements.
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 25
			has_trait = theologian
		}
		modifier = {
			add = 25
			has_trait = scholar
		}
		# Or else they're just sufficiently nerdy.
		modifier = {
			add = 25
			learning >= extremely_high_skill_rating
		}
		# Plus, relations with the Willaq Umu are clinchers...
		## ... either positively...
		modifier = {
			add = -100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_good_relationship_with_root_trigger = yes }
			}
		}
		## ... or negatively.
		modifier = {
			add = 100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_bad_relationship_with_root_trigger = yes }
			}
		}
	}
}

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

	ai_check_interval = 120

	desc = jolljepunco_bind_with_inti_forever_decision_desc
	selection_tooltip = jolljepunco_bind_with_inti_forever_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		exists = dynasty
		# Must be Jolljepunco, and neither decision has been taken yet.
		faith = faith:jolljepunco
		NOR = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:jolljepunco_bound_to_inti
			}
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:jolljepunco_broke_with_inti
			}
		}
		exists = faith.religious_head
	}

	is_valid = {
		# Requires a solid piety level.
		piety_level >= very_high_piety_level
		# Needs a solid chunk of Jolljepunco counties.
		custom_description = {
			text = jolljepunco_county_count.need_at_least_ten_same_faith_counties
			any_sub_realm_county = {
				count >= jolljepunco_county_count
				faith = root.faith
			}
		}
		# The Willaq Umu's gotta be a big fan of yours.
		faith.religious_head = {
			opinion = {
				target = root
				value >= very_high_positive_opinion
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_at_peace_adult = yes
		# If you piss off the Willaq Umu badly enough, he'll just refuse your overtures.
		NOR = {
			has_relation_rival = faith.religious_head
			has_relation_nemesis = faith.religious_head
		}
	}

	effect = {
		save_scope_as = religious_leader
		faith.religious_head = { save_scope_as = willaq_umu }
		# Keep the WIllaq Umu forever, but stay ecumenical.
		custom_tooltip = jolljepunco_bind_with_inti_forever_decision.tt.hof_warning
		# Display the various paths.
		show_as_tooltip = {
			random_list = {
				100 = {
					show_chance = no
					desc = jolljepunco_bind_with_inti_forever_decision
					jolljepunco_bind_with_inti_forever_scripted_effect = yes
				}
			}
		}
		# Send the event.
		trigger_event = ate_hof_replacement.0003
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:jolljepunco_bound_to_inti
			}
		}
	}

	cost = { piety = 1000 }

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		# The AI will only consider this if they match certain trait requirements.
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 25
			has_trait = theologian
		}
		modifier = {
			add = 25
			has_trait = scholar
		}
		# Or else they're just sufficiently nerdy.
		modifier = {
			add = 25
			learning >= extremely_high_skill_rating
		}
		# Plus, relations with the Pope are clinchers...
		## ... either positively...
		modifier = {
			add = 100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_good_relationship_with_root_trigger = yes }
			}
		}
		## ... or negatively.
		modifier = {
			add = -100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_bad_relationship_with_root_trigger = yes }
			}
		}
	}
}

anahata_break_with_sahasrara_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_invite_knights.dds"
	}
	decision_group_type = major

	ai_check_interval = 120

	desc = anahata_break_with_sahasrara_decision_desc
	selection_tooltip = anahata_break_with_sahasrara_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		exists = dynasty
		# Must be relevant faith, and decision has not been taken yet.
		faith = faith:anahata
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:anahata_broke_with_sahasrara
			}
		}
		
		exists = faith.religious_head
	}

	is_valid = {
		# Requires a solid piety level.
		piety_level >= very_high_piety_level
		# Needs a solid chunk of counties.
		is_independent_ruler = yes
		custom_description = {
			text = anahata_break_with_sahasrara_decision.control_three_holy_sites
			faith = {
				any_holy_site = {
				count >= 3
				holder.top_liege = root
				}
			}
		}
	}
		

	is_valid_showing_failures_only = {
		is_available_at_peace_adult = yes
	}

	effect = {
		save_scope_as = religious_leader
		faith.religious_head = { save_scope_as = emperor }
		custom_tooltip = anahata_break_with_sahasrara_decision.tt.hof_warning
		show_as_tooltip = {
			random_list = {
				100 = {
					show_chance = no
					desc = anahata_break_with_sahasrara_decision
					anahata_break_with_sahasrara_decision_scripted_effect = yes
				}
			}
		}
		# Send the event.
		trigger_event = ate_hof_replacement.0005
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:anahata_broke_with_sahasrara
			}
		}
	}

	cost = { piety = 1500 }

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		# The AI will only consider this if they match certain trait requirements.
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 25
			has_trait = theologian
		}
		modifier = {
			add = 25
			has_trait = scholar
		}
		# Or else they're just sufficiently nerdy.
		modifier = {
			add = 25
			learning >= extremely_high_skill_rating
		}
		# Plus, relations with the Willaq Umu are clinchers...
		## ... either positively...
		modifier = {
			add = -100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_good_relationship_with_root_trigger = yes }
			}
		}
		## ... or negatively.
		modifier = {
			add = 100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_bad_relationship_with_root_trigger = yes }
			}
		}
	}
}


###Archipelagic
archipelagic_break_with_animist_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_invite_knights.dds"
	}
	decision_group_type = major

	ai_check_interval = 120

	desc = archipelagic_break_with_animist_decision_desc
	selection_tooltip = archipelagic_break_with_animist_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		exists = dynasty
		# Must be relevant faith, and decision has not been taken yet.
		faith = faith:archipelagic
		NOR = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:archipelagic_bound_to_animist
			}
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:archipelagic_broke_with_animist
			}
		}
		
		exists = faith.religious_head
	}

	is_valid = {
		# Requires a solid piety level.
		piety_level >= very_high_piety_level
		# Needs a solid chunk of counties.
		is_independent_ruler = yes
		custom_description = {
			text = archipelagic_county_count.need_at_least_ten_same_faith_counties
			any_sub_realm_county = {
				count >= archipelagic_county_count
				faith = root.faith
			}
		}
	}
		

	is_valid_showing_failures_only = {
		is_available_at_peace_adult = yes
	}

	effect = {
		save_scope_as = religious_leader
		faith.religious_head = { save_scope_as = patriarch }
		custom_tooltip = archipelagic_break_with_animist.tt.hof_warning
		show_as_tooltip = {
			random_list = {
				100 = {
					show_chance = no
					desc = archipelagic_break_with_animist_decision
					archipelagic_break_with_animist_decision_scripted_effect = yes
				}
			}
		}
		# Send the event.
		trigger_event = ate_hof_replacement.0007
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:archipelagic_broke_with_animist
			}
		}
	}

	cost = { piety = 1500 }

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		# The AI will only consider this if they match certain trait requirements.
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 25
			has_trait = theologian
		}
		modifier = {
			add = 25
			has_trait = scholar
		}
		# Or else they're just sufficiently nerdy.
		modifier = {
			add = 25
			learning >= extremely_high_skill_rating
		}
		# Plus, relations with the Willaq Umu are clinchers...
		## ... either positively...
		modifier = {
			add = -100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_good_relationship_with_root_trigger = yes }
			}
		}
		## ... or negatively.
		modifier = {
			add = 100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_bad_relationship_with_root_trigger = yes }
			}
		}
	}
}

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

	ai_check_interval = 120

	desc = archipelagic_bind_with_animist_forever_decision_desc
	selection_tooltip = archipelagic_bind_with_animist_decision_tooltip

	is_shown = {
		# Standard filter checks.
		is_landed = yes
		exists = dynasty
		# Must be Jolljepunco, and neither decision has been taken yet.
		faith = faith:archipelagic
		NOR = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:archipelagic_bound_to_animist
			}
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:archipelagic_broke_with_animist
			}
		}
		exists = faith.religious_head
	}

	is_valid = {
		# Requires a solid piety level.
		piety_level >= very_high_piety_level
		# Needs a solid chunk of Jolljepunco counties.
		custom_description = {
			text = archipelagic_county_count.need_at_least_ten_same_faith_counties
			any_sub_realm_county = {
				count >= archipelagic_county_count
				faith = root.faith
			}
		}
		# The Willaq Umu's gotta be a big fan of yours.
		faith.religious_head = {
			opinion = {
				target = root
				value >= very_high_positive_opinion
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_at_peace_adult = yes
		# If you piss off the Willaq Umu badly enough, he'll just refuse your overtures.
		NOR = {
			has_relation_rival = faith.religious_head
			has_relation_nemesis = faith.religious_head
		}
	}

	effect = {
		save_scope_as = religious_leader
		faith.religious_head = { save_scope_as = patriarch }
		# Keep the WIllaq Umu forever, but stay ecumenical.
		custom_tooltip = archipelagic_bind_with_animist_forever_decision.tt.hof_warning
		# Display the various paths.
		show_as_tooltip = {
			random_list = {
				100 = {
					show_chance = no
					desc = archipelagic_bind_with_animist_forever_decision
					archipelagic_bind_with_animist_forever_scripted_effect = yes
				}
			}
		}
		# Send the event.
		trigger_event = ate_hof_replacement.0009
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:archipelagic_bound_to_animist
			}
		}
	}

	cost = { piety = 1000 }

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0

		# The AI will only consider this if they match certain trait requirements.
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 25
			has_trait = theologian
		}
		modifier = {
			add = 25
			has_trait = scholar
		}
		# Or else they're just sufficiently nerdy.
		modifier = {
			add = 25
			learning >= extremely_high_skill_rating
		}
		# Plus, relations with the Pope are clinchers...
		## ... either positively...
		modifier = {
			add = 100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_good_relationship_with_root_trigger = yes }
			}
		}
		## ... or negatively.
		modifier = {
			add = -100
			AND = {
				exists = faith.religious_head
				faith.religious_head = { has_any_bad_relationship_with_root_trigger = yes }
			}
		}
	}
}

#General

build_holy_building = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = build_holy_building_desc
	selection_tooltip = build_holy_building_tooltip
	decision_group_type = major

	ai_check_interval = 24

	is_shown = {
		is_ruler = yes
		NOT = {
			has_character_flag = choosing_holy_building_site
		}
		faith = {
			any_holy_site = {
				county = {
					OR = {
						county.holder = root
						county.holder.top_liege = { this = root }
					}
					is_constructing_holy_building = no
					title_province = {
						has_holding = yes
						OR = {
							has_special_building_slot = no
							has_building = holy_site_ruins
						}
					}
				}
			}
		}
	}

	is_valid = {
		prestige_level >= 2
		gold >= 250
		culture = { has_innovation = innovation_crop_rotation }
		#culture = { has_innovation = innovation_manorialism }
		OR = {
			is_independent_ruler = yes
			custom_tooltip = {
				text = same_faith_liege_tt
				is_independent_ruler = no
				faith = top_liege.faith
			}
			custom_tooltip = {
				text = holy_site_held_not_liege_faith_tt
				is_independent_ruler = no
				NOT = { faith = top_liege.faith }
                faith = {
                    any_holy_site = {
						holder = { this = root }
						NOT = { is_holy_site_of = scope:top_liege.faith }
                    }
                }
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
	}

	effect = {
		custom_tooltip = build_holy_building_effect_message
		root = {
			save_scope_as = holy_site_builder
		}
		add_character_flag = choosing_holy_building_site
		trigger_event = holy_site.11
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50
		modifier = {
			add = -50
			gold <= 500
		}
		modifier = {
			factor = 2
			has_trait = zealous
		}
		modifier = {
			factor = 2
			has_trait = arrogant
		}
		modifier = {
			add = 50
			has_trait = greedy
		}
		modifier = {
			factor = 3
			#is_head_of_faith = yes
			faith.religious_head = this
		}
	}
}

convert_holy_building = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = convert_holy_building_desc
	selection_tooltip = convert_holy_building_tooltip
	decision_group_type = major

	ai_check_interval = 15

	is_shown = {
		is_ruler = yes
		NOT = {
			has_character_flag = choosing_holy_building_site
		}
		faith = {
			any_holy_site = {
				county = {
					OR = {
						holder = root
						holder.top_liege = { this = root }
					}
					is_constructing_holy_building = no
					NOT = {
						has_county_modifier = holy_building_protected
					}
					NOT = {
						holder = {
							is_at_war_with_liege = yes
						}
					}
					title_province = {
						has_holding = yes
						has_standard_holy_building = yes
						barony = { is_holy_site_of = root.faith } 
						has_correct_standard_holy_building = no
					}
				}
			}
		}
	}

	is_valid = {
		prestige_level >= 2
		gold >= 250
		culture = { has_innovation = innovation_crop_rotation }
		#culture = { has_innovation = innovation_manorialism }

		OR = {
			custom_tooltip = {
				text = holy_site_convert_not_holder_faith_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_standard_holy_building = yes
							has_correct_standard_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								is_holy_site_of = root.faith
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_convert_not_religious_rights_protected_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_standard_holy_building = yes
							has_correct_standard_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								is_holy_site_of = root.faith
								holder = {
									OR = {
										AND = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
										any_liege_or_above = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
									}
								}
							}
						}
					}
				}
			}
		}
		OR = {
			is_independent_ruler = yes
			AND = {
				custom_tooltip = {
					text = same_faith_liege_tt
					is_independent_ruler = no
					faith = top_liege.faith
				}
				custom_tooltip = {
					text = same_faith_liege_holy_war_tt
					top_liege = {
						NOR = {
							has_variable = chosen_holy_site_var
							has_variable = chosen_demo_site_var
							has_variable = holy_protection_war
							has_variable = stopped_holy_site_change
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_held_not_liege_faith_tt
				is_independent_ruler = no
				NOT = { faith = top_liege.faith }
                faith = {
                    any_holy_site = {
						holder = { this = root }
						NOT = { is_holy_site_of = scope:top_liege.faith }
                    }
                }
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
	}

	effect = {
		custom_tooltip = convert_holy_building_effect_message
		root = {
			save_scope_as = holy_site_builder
		}
		add_character_flag = choosing_holy_building_site
		trigger_event = holy_site.21
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50
		modifier = {
			add = -50
			gold <= 500
		}
		modifier = {
			factor = 2
			has_trait = zealous
		}
		modifier = {
			factor = 2
			has_trait = arrogant
		}
		modifier = {
			add = 50
			has_trait = greedy
		}
		modifier = {
			factor = 3
			is_head_of_faith = yes
		}
	}
}

destroy_holy_building = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = destroy_holy_building_desc
	selection_tooltip = destroy_holy_building_tooltip
	decision_group_type = major

	ai_check_interval = 19

	is_shown = {
		is_ruler = yes
		NOT = {
			has_character_flag = choosing_holy_building_site
		}
		any_sub_realm_county = {
			OR = {
				holder = root
				holder.top_liege = { this = root }
			}
			is_constructing_holy_building = no
			NOT = {
				has_county_modifier = holy_building_protected
			}
			NOT = {
				holder = {
					is_at_war_with_liege = yes
				}
			}
			title_province = {
				has_holding = yes
				has_standard_holy_building = yes
				has_correct_standard_holy_building = no
				barony = {
					NOT = {
						is_holy_site_of = root.faith
					}
				}
			}
		}
	}

	is_valid = {
		custom_tooltip = {
			text = holy_site_building_demolish_trigger_tt
			any_sub_realm_county = {
				OR = {
					holder = root
					holder.top_liege = { this = root }
				}
				is_constructing_holy_building = no
				title_province = {
					has_standard_holy_building = yes
					has_correct_standard_holy_building = no
					barony = {
						NOT = {
							is_holy_site_of = root.faith
						}
					}
				}
			}
		}

		OR = {
			custom_tooltip = {
				text = holy_site_demolish_not_holder_faith_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_correct_standard_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								trigger_if = {
									limit = {
										is_independent_ruler = no
									}
									NOT = {
										is_holy_site_of = scope:top_liege.faith
									}
								}
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_demolish_not_religious_rights_protected_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_correct_standard_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								trigger_if = {
									limit = {
										is_independent_ruler = no
									}
									NOT = {
										is_holy_site_of = scope:top_liege.faith
									}
								}
								holder = {
									OR = {
										AND = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
										any_liege_or_above = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
									}
								}
							}
						}
					}
				}
			}
		}
		OR = {
			is_independent_ruler = yes
			custom_tooltip = {
				text = same_faith_liege_tt
				is_independent_ruler = no
				faith = top_liege.faith
				top_liege = {
					NOR = {
						has_variable = chosen_holy_site_var
						has_variable = chosen_demo_site_var
						has_variable = holy_protection_war
						has_variable = stopped_holy_site_change
					}
				}
			}
			custom_tooltip = {
				text = holy_site_building_demolish_not_liege_faith_tt
				is_independent_ruler = no
				NOT = { faith = top_liege.faith }
				any_sub_realm_county = {
					is_constructing_holy_building = no
					title_province = {
						has_correct_standard_holy_building = no
						barony = {
							NOR = {
								is_holy_site_of = root.faith
								is_holy_site_of = scope:top_liege.faith
							}
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
	}

	effect = {
		custom_tooltip = destroy_holy_building_effect_message
		root = {
			save_scope_as = holy_site_builder
		}
		add_character_flag = choosing_holy_building_site
		trigger_event = holy_site.31
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50

		ai_value_modifier = {
			ai_zeal = 1
			ai_greed = 1
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_fundamentalist }
			add = 50
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_righteous }
			add = 20
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_pluralistic }
			add = -20
		}
		modifier = {
			root.faith = { has_doctrine = tenet_inquisition }
			factor = 4
		}
		modifier = {
			root.faith = { has_doctrine = tenet_wisdom_of_gurus }
			factor = 0
		}
		modifier = {
			root.faith = { has_doctrine = tenet_inter_faith_services }
			factor = 0
		}
	}
}

protect_holy_building = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = protect_holy_building_desc
	selection_tooltip = protect_holy_building_tooltip
	decision_group_type = major

	ai_check_interval = 2

	is_shown = {
		is_ruler = yes
		any_sub_realm_county = {
			holder = root
			is_constructing_holy_building = yes
			title_province = {
				OR = {
					has_correct_standard_holy_building = yes
					has_correct_special_holy_building = yes
				}
			}
		}
		NOT = {
			has_character_flag = choosing_holy_building_site
		}
	}

	is_valid = {
		OR = {
			is_independent_ruler = yes
			custom_tooltip = {
				text = holy_site_independence_war_tt
				any_character_war = {
					using_cb = independence_war
				}
			}
		}
		OR = {
			custom_tooltip = {
				text = holy_site_own_faith_tt
				any_sub_realm_county = {
					is_constructing_holy_building = yes
					title_province = {
						OR = {
							has_correct_standard_holy_building = yes
							has_correct_special_holy_building = yes
						}
						barony = {
							is_holy_site_of = root.faith
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_interfaith_tt
				root.faith = {
					has_doctrine = tenet_inter_faith_services
				}
			}			
		}
	}

	effect = {
		custom_tooltip = protect_holy_building_effect_message
		add_character_flag = choosing_holy_building_site
		root = {
			save_scope_as = holy_site_protector
		}
		trigger_event = holy_site.50
	}

	ai_potential = {
		always = yes
	}
}

elevate_holy_site = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = elevate_holy_site_desc
	selection_tooltip = elevate_holy_site_tooltip
	decision_group_type = major

	ai_check_interval = 30

	is_shown = {
		is_landed = yes
		is_independent_ruler = yes
		NOT = { has_character_flag = declared_mandatory_pilgrimage_site }
		#highest_held_title_tier > 3
		faith = {
			has_doctrine = doctrine_pilgrimage_mandatory
			OR = {
				has_doctrine = doctrine_temporal_head
				doctrine_is_spiritual_type = yes
			}
			NOT = {
				has_variable = mandatory_pilgrimage_site
			}
			any_holy_site = {
				OR = {
					county.holder = root
					county.holder.top_liege = { this = root }
				}
			}
		}
	}

	is_valid = {
		custom_description = {
			text = faith_is_reformed
			subject = root
			faith = { NOT = { has_doctrine_parameter = unreformed } }
		}
		trigger_if = {
			limit = {
				faith = {
					has_doctrine = doctrine_temporal_head
				}
			}
			custom_description = {
				text = "is_head_of_faith"
				faith = {
					religious_head = root
				}
			}
		}
		trigger_if = {
			limit = {
				faith = {
					doctrine_is_spiritual_type = yes
				}
			}
			OR = {
				custom_description = {
					text = "head_of_faith_vassal"
					faith = {
						religious_head = {
							is_vassal_of = root
						}
					}
				}
				custom_description = {
					text = "is_head_of_faith"
					faith = {
						religious_head = root
					}
				}
			}
		}
		trigger_if = {
			limit = {
				faith = {
					has_doctrine = doctrine_temporal_head
				}
			}
			piety_level >= 4
		}
		trigger_if = {
			limit = {
				faith = {
					doctrine_is_spiritual_type = yes
				}
			}
			piety_level >= 3
			prestige_level >= 4
		}
		
	}

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

	effect = {
		custom_tooltip = elevate_holy_site_effect_message
		add_character_flag = declared_mandatory_pilgrimage_site
		root = {
			save_scope_as = pilgrimage_reformer
		}
		root.faith = {
			every_holy_site = {
				add_to_list = elevate_holy_site_list
			}
		}
		trigger_event = {
			id = holy_site.71
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 20

		ai_value_modifier = {
			ai_rationality = 1
			ai_zeal = 3
			ai_honor = 1
		}
		modifier = {
			factor = 2
			has_trait = zealous
		}
		modifier = {
			factor = 2
			has_trait = arrogant
		}
		modifier = {
			factor = 3
			is_head_of_faith = yes
		}
	}
}

renovate_special_holy_building_washington = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = renovate_special_holy_building_washington_desc
	selection_tooltip = renovate_special_holy_building_washington_tooltip
	decision_group_type = major

	ai_check_interval = 10

	is_shown = {
		is_ruler = yes
		NOT = {
			has_character_flag = choosing_holy_building_site
		}
		OR = {
			completely_controls = title:c_washington
			any_vassal = {
				completely_controls = title:c_washington
			}
		}
		faith = {
			any_holy_site = {
				county = {
					is_constructing_holy_building = no
					title_province = {
						this = province:5485
						barony = { is_holy_site_of = root.faith } 
						has_correct_special_holy_building = no
					}
					NOT = {
						has_county_modifier = holy_building_protected
					}
				}
			}
		}
	}

	is_valid = {
		OR = {
			completely_controls = title:c_washington
			any_vassal = {
				completely_controls = title:c_washington
			}
		}
		gold >= 250
		prestige_level >= 2
		culture = { has_innovation = innovation_crop_rotation }
		#culture = { has_innovation = innovation_manorialism }

		OR = {
			custom_tooltip = {
				text = holy_site_convert_not_holder_faith_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_standard_holy_building = yes
							has_correct_standard_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								is_holy_site_of = root.faith
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_convert_not_religious_rights_protected_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_special_building = yes
							has_correct_special_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								is_holy_site_of = root.faith
								holder = {
									OR = {
										AND = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
										any_liege_or_above = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
									}
								}
							}
						}
					}
				}
			}
		}
		OR = {
			is_independent_ruler = yes
			AND = {
				custom_tooltip = {
					text = same_faith_liege_tt
					is_independent_ruler = no
					faith = top_liege.faith
				}
				custom_tooltip = {
					text = same_faith_liege_holy_war_tt
					top_liege = {
						NOR = {
							has_variable = chosen_holy_site_var
							has_variable = chosen_demo_site_var
							has_variable = holy_protection_war
							has_variable = stopped_holy_site_change
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_held_not_liege_faith_tt
				is_independent_ruler = no
				NOT = { faith = top_liege.faith }
                faith = {
                    any_holy_site = {
						holder = { this = root }
						NOT = { is_holy_site_of = scope:top_liege.faith }
                    }
                }
			}
		}
	}

	effect = {
		custom_tooltip = renovate_special_holy_building_effect_message
		root = {
			save_scope_as = holy_site_builder
		}
		province:5485 = {
			save_scope_as = chosen_holy_site
		}
		add_character_flag = choosing_holy_building_site
		trigger_event = { id = holy_site.101 }
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50
		modifier = {
			add = -50
			gold <= 500
		}
		modifier = {
			factor = 2
			has_trait = zealous
		}
		modifier = {
			factor = 2
			has_trait = arrogant
		}
		modifier = {
			add = 50
			has_trait = greedy
		}
		modifier = {
			factor = 3
			is_head_of_faith = yes
		}
		ai_value_modifier = {
			ai_zeal = 1
			ai_greed = 1
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_fundamentalist }
			add = 50
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_righteous }
			add = 20
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_pluralistic }
			add = -20
		}
		modifier = {
			root.faith = { has_doctrine = tenet_inquisition }
			factor = 4
		}
		modifier = {
			root.faith = { has_doctrine = tenet_wisdom_of_gurus }
			factor = 0
		}
		modifier = {
			root.faith = { has_doctrine = tenet_inter_faith_services }
			factor = 0
		}
	}

}

renovate_special_holy_building_detroit = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = renovate_special_holy_building_detroit_desc
	selection_tooltip = renovate_special_holy_building_detroit_tooltip
	decision_group_type = major

	ai_check_interval = 10

	is_shown = {
		is_ruler = yes
		NOT = {
			has_character_flag = choosing_holy_building_site
		}
		OR = {
			completely_controls = title:c_detroit
			any_vassal = {
				completely_controls = title:c_detroit
			}
		}
		faith = {
			any_holy_site = {
				county = {
					is_constructing_holy_building = no
					title_province = {
						this = province:571
						barony = { is_holy_site_of = root.faith } 
						has_correct_special_holy_building = no
					}
					NOT = {
						has_county_modifier = holy_building_protected
					}
				}
			}
		}
	}

	is_valid = {
		OR = {
			completely_controls = title:c_detroit
			any_vassal = {
				completely_controls = title:c_detroit
			}
		}
		gold >= 250
		prestige_level >= 2
		culture = { has_innovation = innovation_crop_rotation }
		#culture = { has_innovation = innovation_manorialism }

		OR = {
			custom_tooltip = {
				text = holy_site_convert_not_holder_faith_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_standard_holy_building = yes
							has_correct_standard_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								is_holy_site_of = root.faith
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_convert_not_religious_rights_protected_tt
				NOT = {
					any_sub_realm_county = {
						NOT = {
							holder = root
							holder = {
								faith = root.faith
							}
						}
						is_constructing_holy_building = no
						title_province = {
							has_special_building = yes
							has_correct_special_holy_building = no
							barony = {
								is_holy_site_of = holder.faith
								is_holy_site_of = root.faith
								holder = {
									OR = {
										AND = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
										any_liege_or_above = {
											top_liege = root
											is_ruler = yes
											is_independent_ruler = no
											vassal_contract_has_flag = religiously_protected
										}
									}
								}
							}
						}
					}
				}
			}
		}
		OR = {
			is_independent_ruler = yes
			AND = {
				custom_tooltip = {
					text = same_faith_liege_tt
					is_independent_ruler = no
					faith = top_liege.faith
				}
				custom_tooltip = {
					text = same_faith_liege_holy_war_tt
					top_liege = {
						NOR = {
							has_variable = chosen_holy_site_var
							has_variable = chosen_demo_site_var
							has_variable = holy_protection_war
							has_variable = stopped_holy_site_change
						}
					}
				}
			}
			custom_tooltip = {
				text = holy_site_held_not_liege_faith_tt
				is_independent_ruler = no
				NOT = { faith = top_liege.faith }
                faith = {
                    any_holy_site = {
						holder = { this = root }
						NOT = { is_holy_site_of = scope:top_liege.faith }
                    }
                }
			}
		}
	}

	effect = {
		custom_tooltip = renovate_special_holy_building_effect_message
		root = {
			save_scope_as = holy_site_builder
		}
		province:571 = {
			save_scope_as = chosen_holy_site
		}
		add_character_flag = choosing_holy_building_site
		trigger_event = { id = holy_site.111 }
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 50
		modifier = {
			add = -50
			gold <= 500
		}
		modifier = {
			factor = 2
			has_trait = zealous
		}
		modifier = {
			factor = 2
			has_trait = arrogant
		}
		modifier = {
			add = 50
			has_trait = greedy
		}
		modifier = {
			factor = 3
			is_head_of_faith = yes
		}
		ai_value_modifier = {
			ai_zeal = 1
			ai_greed = 1
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_fundamentalist }
			add = 50
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_righteous }
			add = 20
		}
		modifier = {
			root.faith = { has_doctrine = doctrine_pluralism_pluralistic }
			add = -20
		}
		modifier = {
			root.faith = { has_doctrine = tenet_inquisition }
			factor = 4
		}
		modifier = {
			root.faith = { has_doctrine = tenet_wisdom_of_gurus }
			factor = 0
		}
		modifier = {
			root.faith = { has_doctrine = tenet_inter_faith_services }
			factor = 0
		}
	}

}

#renovate_special_holy_building_sao_paulo = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
#	}
#
#	desc = renovate_special_holy_building_sao_paulo_desc
#	selection_tooltip = renovate_special_holy_building_sao_paulo_tooltip
#	decision_group_type = major
#
#	ai_check_interval = 10
#
#	is_shown = {
#		is_ruler = yes
#		NOT = {
#			has_character_flag = choosing_holy_building_site
#		}
#		OR = {
#			completely_controls = title:c_sao_paulo
#			any_vassal = {
#				completely_controls = title:c_sao_paulo
#			}
#		}
#		faith = {
#			any_holy_site = {
#				county = {
#					is_constructing_holy_building = no
#					title_province = {
#						this = province:5197
#						barony = { is_holy_site_of = root.faith } 
#						has_correct_special_holy_building = no
#					}
#					NOT = {
#						has_county_modifier = holy_building_protected
#					}
#				}
#			}
#		}
#	}
#
#	is_valid = {
#		OR = {
#			completely_controls = title:c_sao_paulo
#			any_vassal = {
#				completely_controls = title:c_sao_paulo
#			}
#		}
#		gold >= 250
#		prestige_level >= 2
#		culture = { has_innovation = innovation_crop_rotation }
#		#culture = { has_innovation = innovation_manorialism }
#
#		OR = {
#			custom_tooltip = {
#				text = holy_site_convert_not_holder_faith_tt
#				NOT = {
#					any_sub_realm_county = {
#						NOT = {
#							holder = root
#							holder = {
#								faith = root.faith
#							}
#						}
#						is_constructing_holy_building = no
#						title_province = {
#							has_standard_holy_building = yes
#							has_correct_standard_holy_building = no
#							barony = {
#								is_holy_site_of = holder.faith
#								is_holy_site_of = root.faith
#							}
#						}
#					}
#				}
#			}
#			custom_tooltip = {
#				text = holy_site_convert_not_religious_rights_protected_tt
#				NOT = {
#					any_sub_realm_county = {
#						NOT = {
#							holder = root
#							holder = {
#								faith = root.faith
#							}
#						}
#						is_constructing_holy_building = no
#						title_province = {
#							has_special_building = yes
#							has_correct_special_holy_building = no
#							barony = {
#								is_holy_site_of = holder.faith
#								is_holy_site_of = root.faith
#								holder = {
#									OR = {
#										AND = {
#											top_liege = root
#											is_ruler = yes
#											is_independent_ruler = no
#											vassal_contract_has_flag = religiously_protected
#										}
#										any_liege_or_above = {
#											top_liege = root
#											is_ruler = yes
#											is_independent_ruler = no
#											vassal_contract_has_flag = religiously_protected
#										}
#									}
#								}
#							}
#						}
#					}
#				}
#			}
#		}
#		OR = {
#			is_independent_ruler = yes
#			AND = {
#				custom_tooltip = {
#					text = same_faith_liege_tt
#					is_independent_ruler = no
#					faith = top_liege.faith
#				}
#				custom_tooltip = {
#					text = same_faith_liege_holy_war_tt
#					top_liege = {
#						NOR = {
#							has_variable = chosen_holy_site_var
#							has_variable = chosen_demo_site_var
#							has_variable = holy_protection_war
#							has_variable = stopped_holy_site_change
#						}
#					}
#				}
#			}
#			custom_tooltip = {
#				text = holy_site_held_not_liege_faith_tt
#				is_independent_ruler = no
#				NOT = { faith = top_liege.faith }
#               faith = {
#                   any_holy_site = {
#						holder = { this = root }
#						NOT = { is_holy_site_of = scope:top_liege.faith }
#                    }
#                }
#			}
#		}
#	}
#
#	effect = {
#		custom_tooltip = renovate_special_holy_building_effect_sao_paulo_message
#		root = {
#			save_scope_as = holy_site_builder
#		}
#		province:5197 = {
#			save_scope_as = chosen_holy_site
#		}
#		add_character_flag = choosing_holy_building_site
#		trigger_event = { id = holy_site.113 }
#	}
#
#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 50
#		modifier = {
#			add = -50
#			gold <= 500
#		}
#		modifier = {
#			factor = 2
#			has_trait = zealous
#		}
#		modifier = {
#			factor = 2
#			has_trait = arrogant
#		}
#		modifier = {
#			add = 50
#			has_trait = greedy
#		}
#		modifier = {
#			factor = 3
#			is_head_of_faith = yes
#		}
#		ai_value_modifier = {
#			ai_zeal = 1
#			ai_greed = 1
#		}
#		modifier = {
#			root.faith = { has_doctrine = doctrine_pluralism_fundamentalist }
#			add = 50
#		}
#		modifier = {
#			root.faith = { has_doctrine = doctrine_pluralism_righteous }
#			add = 20
#		}
#		modifier = {
#			root.faith = { has_doctrine = doctrine_pluralism_pluralistic }
#			add = -20
#		}
#		modifier = {
#			root.faith = { has_doctrine = tenet_inquisition }
#			factor = 4
#		}
#		modifier = {
#			root.faith = { has_doctrine = tenet_wisdom_of_gurus }
#			factor = 0
#		}
#		modifier = {
#			root.faith = { has_doctrine = tenet_inter_faith_services }
#			factor = 0
#		}
#	}
#
#}

#conduct_animal_sacrifice_at_peace = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
#	}
#
#	desc = {
#		first_valid = {
#				triggered_desc = {
#					trigger = {
#						has_religion = religion:mormon_religion
#					}
#					desc = conduct_animal_sacrifice_at_peace_desc.1
#				}
#				desc = conduct_animal_sacrifice_at_peace_desc.2
#			}
#	}
#	selection_tooltip = conduct_animal_sacrifice_at_peace_effect_tooltip
#
#	is_shown = {
#		faith = {
#			has_doctrine_parameter = animal_sacrifice_enabled
#		}
#		NOT = { religion = religion:conterraneo_religion }
#		is_at_war = no
#	}
#
#	is_valid = {
#		NOR = {
#			has_character_flag = waiting_for_peacetime_sacrifice_result
#			has_character_flag = recent_peacetime_sacrifice
#		}
#	}
#
#	is_valid_showing_failures_only = {
#		is_capable_adult = yes
#		is_imprisoned = no
#	}
#
#	effect = {
#		custom_tooltip = conduct_animal_sacrifice_at_peace_effect_message
#		root = {
#			save_scope_as = animal_sacrificer
#		}
#		trigger_event = {
#			id = ate_animal_sacrifice.1
#		}
#	}
#
#	ai_check_interval = 96
#
#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 100
#	}
#}
#
#conduct_animal_sacrifice_at_war = {
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
#	}
#
#	desc = {
#		first_valid = {
#				triggered_desc = {
#					trigger = {
#						has_religion = religion:mormon_religion
#					}
#					desc = conduct_animal_sacrifice_desc.1
#				}
#				desc = conduct_animal_sacrifice_desc.2
#			}
#	}
#	selection_tooltip = conduct_animal_sacrifice_at_war_tooltip
#
#	is_shown = {
#		faith = {
#			has_doctrine_parameter = animal_sacrifice_enabled
#		}
#		NOT = { religion = religion:conterraneo_religion }
#		is_at_war = yes
#	}
#
#	is_valid = {
#		NOR = {
#			has_character_flag = waiting_for_wartime_sacrifice_result
#			has_character_flag = recent_wartime_sacrifice
#		}
#	}
#
#	is_valid_showing_failures_only = {
#		is_capable_adult = yes
#		is_imprisoned = no
#	}
#
#	effect = {
#		custom_tooltip = conduct_animal_sacrifice_effect_at_war_message
#		root = {
#			save_scope_as = animal_sacrificer
#		}
#		trigger_event = {
#			id = ate_animal_sacrifice.20
#		}
#	}
#
#	ai_check_interval = 96
#
#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 100
#	}
#}

reform_amazonah_judaism_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = reform_amazonah_judaism_decision_desc
	selection_tooltip = reform_amazonah_judaism_decision_tooltip
	decision_group_type = major

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		faith = faith:edah_amazonah
		NOT = {
			faith:edah_amazonah = {
				has_variable = old_ways_been_broken
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		piety_level >= very_high_piety_level
		highest_held_title_tier > 3 #Only Kings and Emperors
		trigger_if = {
			limit = {
				faith = { exists = religious_head }
			}
			is_liege_or_above_of = root.faith.religious_head
		}
	}
	
	cost = {
		piety = 1500
	}

	effect = {
		trigger_event = ate_religious_decision.212
		show_as_tooltip = {
			root.faith = { remove_doctrine = unreformed_faith_doctrine }
			random_list = {
				100 = {
					show_chance = no
					desc = reform_amazonah_judaism_decision.path_amerindian
					root.faith = { reform_amazonah_judaism_become_amerindian_syncretic = yes }
				}
				100 = {
					show_chance = no
					desc = reform_amazonah_judaism_decision.path_righteous
					root.faith = { reform_amazonah_judaism_become_righteous = yes }
				}
				100 = {
					show_chance = no
					desc = reform_amazonah_judaism_decision.path_fundamentalist
					root.faith = { reform_amazonah_judaism_become_fundamentalist = yes }
				}
			}
		}
		hidden_effect = {
			faith:edah_amazonah = {
				set_variable = old_ways_been_broken
			}
		}
	}
	
	ai_potential = {
		faith = faith:edah_amazonah
	}

	ai_will_do = {
		base = 100
		modifier = {
			factor = 0
			has_trait = cynical
		}
	}
}


reform_toadas_bumba_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = reform_toadas_bumba_decision_desc
	selection_tooltip = reform_toadas_bumba_decision_tooltip
	decision_group_type = major

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		faith = faith:toadas_bumba
		NOT = {
			faith:toadas_bumba = {
				has_variable = old_ways_been_broken
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		piety_level >= very_high_piety_level
		highest_held_title_tier > 3 #Only Kings and Emperors
	}
	
	cost = {
		piety = 1500
	}

	effect = {
		save_scope_as = religious_leader
		trigger_event = ate_religious_decision.214
		show_as_tooltip = {
			root.faith = { remove_doctrine = unreformed_faith_doctrine }
			random_list = {
				100 = {
					show_chance = no
					desc = reform_toadas_bumba_decision.path_holy_order
					root.faith = { reform_toadas_bumba_become_militant = yes }
				}
				100 = {
					show_chance = no
					desc = reform_toadas_bumba_decision.path_temporal
					root.faith = { reform_toadas_bumba_become_megalithic = yes }
				}
				100 = {
					show_chance = no
					desc = reform_toadas_bumba_decision.path_spiritual
					root.faith = { reform_toadas_bumba_become_primitivist = yes }
				}
			}
		}
		hidden_effect = {
			faith:toadas_bumba = {
				set_variable = old_ways_been_broken
			}
		}
	}
	
	ai_potential = {
		faith = faith:toadas_bumba
	}

	ai_will_do = {
		base = 100
		modifier = {
			factor = 0
			has_trait = cynical
		}
	}
}

reform_veiled_cross_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = reform_veiled_cross_decision_desc
	selection_tooltip = reform_veiled_cross_decision_tooltip
	decision_group_type = major

	ai_check_interval = 120

	is_shown = {
		is_ruler = yes
		is_landed = yes
		faith = faith:veiled_cross
		NOT = {
			faith:veiled_cross = {
				has_variable = old_ways_been_broken
			}
		}
	}

	is_valid_showing_failures_only = {
		is_capable_adult = yes
		is_imprisoned = no
		is_independent_ruler = yes
		piety_level >= very_high_piety_level
		highest_held_title_tier > 3 #Only Kings and Emperors
	}
	
	cost = {
		piety = 1500
	}

	effect = {
		save_scope_as = religious_leader
		trigger_event = ate_religious_decision.216
		show_as_tooltip = {
			random_list = {
				100 = {
					show_chance = no
					desc = reform_veiled_cross_decision.path_maintain
					root.faith = { remove_doctrine = unreformed_faith_doctrine }
				}
				100 = {
					show_chance = no
					desc = reform_veiled_cross_decision.path_conclavian
					root.faith = { reform_veiled_cross_become_pro_conclavian = yes }
				}
				100 = {
					show_chance = no
					desc = reform_veiled_cross_decision.path_ursuline
					root.faith = { reform_veiled_cross_become_pro_ursuline = yes }
				}
				100 = {
					show_chance = no
					desc = reform_veiled_cross_decision.path_independent
					root.faith = { reform_veiled_cross_become_independent = yes }
				}
			}
		}
		hidden_effect = {
			faith:veiled_cross = {
				set_variable = old_ways_been_broken
			}
		}
	}
	
	ai_potential = {
		faith = faith:veiled_cross
	}

	ai_will_do = {
		base = 100
		modifier = {
			factor = 0
			has_trait = cynical
		}
	}
}

reveal_witchcraft_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = reveal_witchcraft_decision_desc
	selection_tooltip = reveal_witchcraft_decision_tt
	decision_group_type = major

	is_shown = {
		any_secret = { secret_type = secret_witch }
		faith = {
			OR = {
				has_doctrine = doctrine_witchcraft_accepted
				has_doctrine = doctrine_witchcraft_virtuous
			}
		}
	}

	effect = {
		add_trait = witch
	}

	ai_will_do = {
		base = 100
	}
}

reveal_cannibalism_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = reveal_cannibalism_decision_desc
	selection_tooltip = reveal_cannibalism_decision_tt
	decision_group_type = major

	is_shown = {
		any_secret = { secret_type = secret_cannibal }
		faith = {
			has_doctrine = tenet_ritual_cannibalism
		}
	}

	effect = {
		add_trait = cannibal
	}

	ai_will_do = {
		base = 100
	}
}

reveal_deviancy_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}

	desc = reveal_deviancy_decision_desc
	selection_tooltip = reveal_deviancy_decision_tt
	decision_group_type = major

	is_shown = {
		any_secret = { secret_type = secret_deviant }
		faith = {
			has_doctrine = doctrine_deviancy_virtuous
		}
	}

	effect = {
		add_trait = deviant
	}

	ai_will_do = {
		base = 100
	}
}

acquire_a_charm_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	
	desc = acquire_a_charm_decision_desc
	selection_tooltip = acquire_a_charm_decision_tooltip

	is_shown = {
		is_ruler = yes
		faith = {
			has_doctrine_parameter = charms_of_power_active
		}
	}

	cooldown = {
		years = 5
	}

	effect = {
		trigger_event = ate_religious_decision.222
	}
}

emancipate_hof_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = emancipate_hof_decision_desc
	selection_tooltip = emancipate_hof_decision_tooltip
	
	decision_group_type = major

	is_shown = {
		faith = {
			exists = religious_head
			NOT = {
				religious_head.faith = this
			}
			OR = {
				this = faith:ciceritism
				this = faith:santeiro
				this = faith:byzantine_rite
				this = faith:santa_gilada
				this = faith:santo_camba
				
				this = faith:reforged
				this = faith:economist
			}
		}
	}

	is_valid = {
		can_create_head_of_faith_title_trigger = {
			FAITH = faith
		}

		#do we want to enforce ruler independence?
		OR = {
			is_independent_ruler = yes
			AND = {
				NOT = {
					liege.faith = faith #if they have the same faith, let them do it
				}
				NOT = {
					liege.faith = faith.religious_head.faith #if they are part of the oppressor's faith, they won't agree with it
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		NOT = {
			faith = {
				has_locked_hof = yes
			}
		}
	}

	effect = {
		faith = {
			set_variable = {
				name = former_foreign_hof
				value = religious_head.faith
			}
		}
		trigger_event = ate_religious_decision.230
	}
	
	cost = {
		piety = major_piety_value
	}

	ai_check_interval = 36

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
		#TODO add logic so content etc won't do it
		#Should zealous character want to do it more or less?
	}
}

convert_to_torepraia_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_realm.dds" }
	decision_group_type = major
	desc = convert_to_torepraia_decision_desc
	selection_tooltip = convert_to_torepraia_decision_tooltip
	
	is_shown = {
		NOT = { has_faith = faith:torepraia }
		OR = {
		capital_province.kingdom = title:k_cariris	# must be de-jure vassal of k_cariris
		capital_province.kingdom = title:k_salvador	# must be de-jure vassal of k_salvador
		culture = { has_cultural_pillar = heritage_cariri }		# Cariri heritage (Pankararu, Xukuru, Potiguara)
		culture = { has_cultural_pillar = heritage_northern_sertanejo }
		culture = { has_cultural_pillar = heritage_costeiro }
		}
	}
	
	is_valid = {
		age >= 16
		piety_level >= 1
		sub_realm_size >= 5
		NOT = { has_faith = faith:torepraia }
		OR = {
			completely_controls = title:c_raso_da_catarina
			any_vassal = {	completely_controls = title:c_raso_da_catarina }
		}
		OR = {
		culture = { has_cultural_pillar = heritage_cariri }		# Cariri heritage (Pankararu, Xukuru, Potiguara)
		AND = {
					OR = {
					capital_province.kingdom = title:k_cariris	# must be de-jure vassal of k_cariris
					capital_province.kingdom = title:k_salvador	# must be de-jure vassal of k_salvador
					}
					OR = {
						culture = { has_cultural_pillar = heritage_northern_sertanejo }
						culture = { has_cultural_pillar = heritage_costeiro }
					}
			}
		}
	}
	
	is_valid_showing_failures_only = { }
	
	effect = { trigger_event = ate_religious_general.1004 }
	
	cost = {
		gold = medium_gold_value
		piety = medium_piety_value
	}
	
	ai_check_interval = 120
	ai_potential = { always = yes }
	
		ai_will_do = {
		base = 0
		# The AI will only consider this if they match certain trait requirements.
		modifier = {
			add = 25
			has_trait = zealous
		}	
		modifier = {
			add = 25
			has_trait = theologian
		}
		modifier = {
			add = 25
			has_religion = religion:catimbo_religion 
		}		
		}
}

subjugate_hof_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = subjugate_hof_decision_desc
	selection_tooltip = subjugate_hof_decision_tooltip
	
	decision_group_type = major

	is_shown = {
		#always = no
		faith = {
			exists = religious_head
		}
		#let's not assimilate people if the HoF doesn't have our own faith
		faith = faith.religious_head.faith
		any_religion_global = {
			any_faith = {
				NOT = {
					this = root.faith
				}
				NOT = {
					has_locked_hof = yes
				}
				NOT = {
					has_doctrine = unreformed_faith_doctrine
				}
				OR = {
					AND = {
						faith_hostility_level = {
							target = root.faith
							value <= faith_astray_level
						}
						root.faith = {
							faith_hostility_level = {
								target = prev
								value <= faith_astray_level
							}
						}
						#this decision is mostly disabled for now, since we want more control
						#but it's enabled to revert emancipations
						always = no
					}
					AND = {
						has_variable = former_foreign_hof
						var:former_foreign_hof = root.faith
					}
				}
				any_holy_site = {
					count >= holy_sites_to_create_spiritual_head_of_faith
					holder.top_liege = root
					holder.faith = root.faith
				}
				OR = {
					AND = {
						has_doctrine = doctrine_spiritual_head
						root.faith = {
							has_doctrine = doctrine_spiritual_head
						}
					}
					AND = {
						has_doctrine = doctrine_temporal_head
						root.faith = {
							has_doctrine = doctrine_temporal_head
						}
					}
					AND = {
						has_doctrine = doctrine_holy_order_head
						root.faith = {
							has_doctrine = doctrine_holy_order_head
						}
					}
					#headless faiths can't be subjugated
					#has_doctrine = doctrine_no_head
				}
				OR = {
					NOT = {
						exists = religious_head
					}
					NOT = {
						religious_head.faith = root.faith
					}
				}
				#don't assimilate dead faiths
				num_county_followers > 0
			}
		}
	}

	is_valid = {
		piety_level >= 3
		is_independent_ruler = yes
		
		faith = faith.religious_head.faith
		
		#custom_description = your_faith_holds_at_least_3_holy_sites
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		faith = {
			save_scope_as = dominant_faith
		}
		every_religion_global = {
			random_faith = {
				limit = {
					NOT = {
						this = root.faith
					}
					NOT = {
						has_doctrine = unreformed_faith_doctrine
					}
					NOT = {
						has_locked_hof = yes
					}
					OR = {
						AND = {
							faith_hostility_level = {
								target = root.faith
								value <= faith_astray_level
							}
							root.faith = {
								faith_hostility_level = {
									target = prev
									value <= faith_astray_level
								}
							}
							#this decision is mostly disabled for now, since we want more control
							#but it's enabled to revert emancipations
							always = no
						}
						AND = {
							has_variable = former_foreign_hof
							var:former_foreign_hof = root.faith
						}
					}
					any_holy_site = {
						count >= holy_sites_to_create_spiritual_head_of_faith
						holder.top_liege = root
						holder.faith = root.faith
					}
					OR = {
						AND = {
							has_doctrine = doctrine_spiritual_head
							root.faith = {
								has_doctrine = doctrine_spiritual_head
							}
						}
						AND = {
							has_doctrine = doctrine_temporal_head
							root.faith = {
								has_doctrine = doctrine_temporal_head
							}
						}
						AND = {
							has_doctrine = doctrine_holy_order_head
							root.faith = {
								has_doctrine = doctrine_holy_order_head
							}
						}
						has_doctrine = doctrine_no_head
					}
					OR = {
						NOT = {
							exists = religious_head
						}
						NOT = {
							religious_head.faith = root.faith
						}
					}
					#don't assimilate dead faith
					num_county_followers > 0
				}
				save_scope_as = subjugated_faith
			}
		}
		
		scope:subjugated_faith = {
			set_religious_head_title = root.faith.religious_head_title
		}
	}
	
	cost = {
		piety = massive_piety_value
		#TODO cost should scale with religious differences - it should be hard to join with a faith from another religion, for example
	}

	ai_check_interval = 36

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

##Sponsor theocratic see building

theocratic_see_sponsor_theocratic_see_building = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}

	desc = theocratic_see_sponsor_theocratic_see_building_desc
	selection_tooltip = theocratic_see_sponsor_theocratic_see_building_tooltip
	
	decision_group_type = major
	
	cooldown = {
		years = 10
	}

	is_shown = {
		#always = no
		NOT = {
			any_held_title = {
				is_head_of_faith = yes
			}
		}
		faith = {
			religious_head ?= {
				domicile ?= {
					is_domicile_type = theocratic_see
				}
			}
		}
	}

	is_valid = {
		gold >= estate_external_building_normal_cost_tier_4_value
		faith = {
			religious_head ?= {
				domicile ?= {
					#TODO this trigger is bugged, but it's PDX's fault
					free_external_domicile_building_slots >= 1
					#The workaround below doesn't quite work because internal buildings are also counted
					#trigger_if = {
					#	limit = {
					#		has_domicile_building = theocratic_see_main_01
					#	}
					#	num_domicile_buildings < 3 #base + 2 external
					#}
					#trigger_if = {
					#	limit = {
					#		has_domicile_building = theocratic_see_main_02
					#	}
					#	num_domicile_buildings < 4 #base + 3 external
					#}
					#trigger_if = {
					#	limit = {
					#		has_domicile_building = theocratic_see_main_03
					#	}
					#	num_domicile_buildings < 5 #base + 4 external
					#}
					#trigger_if = {
					#	limit = {
					#		has_domicile_building = theocratic_see_main_04
					#	}
					#	num_domicile_buildings < 6 #base + 2 external
					#}
					#trigger_if = {
					#	limit = {
					#		has_domicile_building = theocratic_see_main_05
					#	}
					#	num_domicile_buildings < 7 #base + 2 external
					#}
					has_ongoing_domicile_construction = no
				}
			}
		}
	}

	is_valid_showing_failures_only = {

	}

	effect = {
		
		trigger_event = ate_religious_decision.235
	}
	
	cost = {
		#gold = estate_external_building_normal_cost_tier_4_value
	}

	ai_check_interval = 36

	ai_potential = {
		OR = {
			has_trait = generous
			has_trait = zealous
		}
	}

	ai_will_do = {
		#the AI should seldom do it, this way the player can have more agency
		base = -60
		ai_value_modifier = {
			ai_zeal = 1
		}
	}
}