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

	desc = choose_patron_decision_desc
	selection_tooltip = choose_patron_decision_tooltip

	is_shown = {
		is_ai = yes
		patron_has_any_trait = no # check for no current patron, AI don't need to change this
	}

	effect = {
		trigger_event = religious_decision.0101
	}
	ai_potential = { always = yes }
	ai_will_do = { base = 100 }
	
	ai_goal = yes
}

### Change what kind of holy site you can build in a province
change_holy_site_type_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }

	desc = change_holy_site_type_decision_desc
	selection_tooltip = change_holy_site_type_decision_tooltip

	is_shown = {
		is_ruler = yes
		# One of the holy sites of your faith that you control has a holy site building that you can't use
		OR = { 
			AND = {
				faith = { 
					has_doctrine_parameter = faith_uses_grand_cathedral
					any_holy_site = {
						county = {
							holder = root
							title_province = { 
								OR = {
									has_building = daedric_shrine_01
									has_building = great_wyrd_tree_01
									has_building = dragon_temple_01
									has_building = holy_site_other_grand_temple_01
								}
							}	
						}	
					}
				}
			}	
			AND = {
				faith = { 
					has_doctrine_parameter = faith_uses_daedric_shrine
					any_holy_site = {
						county = {
							holder = root
							title_province = { 
								OR = {
									has_building = grand_cathedral_01
									has_building = great_wyrd_tree_01
									has_building = dragon_temple_01
									has_building = holy_site_other_grand_temple_01
								}
							}	
						}
					}
				}
			}	
			AND = {
				faith = { 
					has_doctrine_parameter = faith_uses_great_wyrd_tree
					any_holy_site = {
						county = {
							holder = root
							title_province = { 
								OR = {
									has_building = grand_cathedral_01
									has_building = daedric_shrine_01
									has_building = dragon_temple_01
									has_building = holy_site_other_grand_temple_01
								}
							}	
						}
					}
				}
			}	
			AND = {
				faith = { 
					has_doctrine_parameter = faith_uses_dragon_temple
					any_holy_site = {
						county = {
							holder = root
							title_province = { 
								OR = {
									has_building = grand_cathedral_01
									has_building = daedric_shrine_01
									has_building = great_wyrd_tree_01
									has_building = holy_site_other_grand_temple_01
								}
							}	
						}
					}
				}
			}
			AND = {
				faith = { 
					has_doctrine_parameter = faith_uses_holy_site_other_grand_temple
					any_holy_site = {
						county = {
							holder = root
							title_province = { 
								OR = {
									has_building = grand_cathedral_01
									has_building = daedric_shrine_01
									has_building = great_wyrd_tree_01
									has_building = dragon_temple_01
								}
							}	
						}	
					}
				}	
			}
		}	
	}
	
	cost = {
		gold = 1000
	}

	effect = {
		# Pay some gold to renovate the holy site building into one usable by your faith
		faith = {
			random_holy_site = {
				limit = { 
					county = {
						holder = root
						title_province = {
							OR = {
								has_building = grand_cathedral_01
								has_building = daedric_shrine_01
								has_building = great_wyrd_tree_01
								has_building = dragon_temple_01
								has_building = holy_site_other_grand_temple_01
							}
						}
					}	
				}
				# Remove the holy building
				county = {
					title_province = {
						if = {
							limit = { has_building = grand_cathedral_01 }
							remove_building = grand_cathedral_01
						}
						else_if = {
							limit = { has_building = daedric_shrine_01 }
							remove_building = daedric_shrine_01
						}
						else_if = {
							limit = { has_building = great_wyrd_tree_01 }
							remove_building = great_wyrd_tree_01
						}
						else_if = {
							limit = { has_building = dragon_temple_01 }
							remove_building = dragon_temple_01
						}
						else_if = {
							limit = { has_building = holy_site_other_grand_temple_01 }
							remove_building = holy_site_other_grand_temple_01
						}
						# then the one suitable to your faith
						if = {
							limit = { root.faith = { has_doctrine_parameter = faith_uses_grand_cathedral } }
							add_special_building = grand_cathedral_01
						}
						else_if = {
							limit = { root.faith = { has_doctrine_parameter = faith_uses_daedric_shrine } }
							add_special_building = daedric_shrine_01
						}
						else_if = {
							limit = { root.faith = { has_doctrine_parameter = faith_uses_great_wyrd_tree } }
							add_special_building = great_wyrd_tree_01
						}
						else_if = {
							limit = { root.faith = { has_doctrine_parameter = faith_uses_dragon_temple } }
							add_special_building = dragon_temple_01
						}
						else_if = {
							limit = { root.faith = { has_doctrine_parameter = faith_uses_holy_site_other_grand_temple } }
							add_special_building = holy_site_other_grand_temple_01
						}
					}
				}	
			}
		}
		add_piety = 1000
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}
}

### Vows of Squalor
take_vow_of_squalor_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }

	desc = take_vow_of_squalor_decision_desc
	selection_tooltip = take_vow_of_squalor_decision_tooltip

	is_shown = {
		is_ruler = yes
		faith = { has_doctrine_parameter = vows_of_squalor_active }
		NOT = { has_character_modifier = vow_of_squalor_modifier }
	}

	effect = {
		add_character_modifier = {
			modifier = vow_of_squalor_modifier
		}

		stress_impact = {
			greedy = major_stress_impact_gain
			cynical = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	ai_potential = {
	}

	ai_will_do = {
		base = 0
	}
}

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

	desc = renounce_vow_of_squalor_decision_desc
	selection_tooltip = renounce_vow_of_squalor_decision_tooltip

	is_shown = {
		is_ruler = yes
		faith = { has_doctrine_parameter = vows_of_squalor_active }
		has_character_modifier = vow_of_squalor_modifier
	}

	effect = {
		add_piety = medium_piety_loss
		remove_character_modifier = vow_of_squalor_modifier

		stress_impact = {
			generous = major_stress_impact_gain
			zealous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	ai_potential = {
	}

	ai_will_do = {
		base = 0
	}
}

### Rite of Passage
rite_of_passage_decision = {
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { religion = religion:aldmeri_religion }
				desc = rite_of_passage_decision_athel_vialen_name
			}
			desc = rite_of_passage_decision_fallback_name
		}
	}
	picture = { reference = "gfx/interface/illustrations/decisions/fp1_decisons_hold_bolt.dds" }
	desc = rite_of_passage_decision_desc
	selection_tooltip = rite_of_passage_decision_tooltip
	decision_group_type = major

	is_shown = {
		# Cut for the initial release, we'll see to it once we have more time
		always = no
		# faith = { has_doctrine_parameter = rite_of_passage_decision_active }
	}

	is_valid = {
		is_ai = no
	}

	effect = {
		custom_tooltip = rite_of_passage_decision_tt
		custom_tooltip = rite_of_passage_decision_religion_specific_tt
		
		### Religion & tenet specific
		if = {
			limit = { faith = { has_doctrine_parameter = cannibalism_legal } }
			custom_tooltip = rite_of_passage_decision_cannibalism_legal_tt
		}
		
		if = {
			limit = { faith = { has_doctrine_parameter = lycanthropy_accepted } }
			custom_tooltip = rite_of_passage_decision_lycanthropy_legal_tt
		}
		
		if = {
			limit = { faith = { has_doctrine = doctrine_lycanthropy_crime } }
			custom_tooltip = rite_of_passage_decision_lycanthropy_crime_tt
		}
		
		if = {
			limit = { faith = { has_doctrine_parameter = vampirism_accepted } }
			custom_tooltip = rite_of_passage_decision_vampirism_legal_tt
		}
		
		if = {
			limit = { faith = { has_doctrine = doctrine_vampirism_crime } }
			custom_tooltip = rite_of_passage_decision_vampirism_crime_tt
		}
		
		trigger_event = ek_religious_decision.0001
	}

	cost = { prestige = 50 }

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

	ai_will_do = {
		base = 100
	}
}

### Skaal sacred rituals
# Ristaag - Ritual hunt to bless & cleanse the land, and hopefully please the All-Maker
# Small event chain with how to deal with the hunt, before finding the Spirit Bear
start_ristaag_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	desc = start_ristaag_decision_desc
	selection_tooltip = start_ristaag_decision_tooltip
	
	cooldown = { years = 10 }

	is_shown = {
		is_ruler = yes
		faith = { has_doctrine_parameter = allows_ristaag_decision_active }
	}
	
	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_landed = yes
	}

	effect = {
		custom_tooltip = start_ristaag_decision_effect_tooltip
		
		trigger_event = ek_religious_decision.0101
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
		
		### EK TODO: Make it scale based on the average (if possible?) county opinion and control
	}
}

### Summon Dragons
# When at war, can spend a heavy piety cost to summon Dragons, very powerful non-regenerating troops. They bail once the war is over.
summon_dragons_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}
	
	decision_group_type = major

	desc = summon_dragons_decision_desc
	selection_tooltip = summon_dragons_decision_tooltip
	
	cooldown = { months = 12 }

	is_shown = {
		is_ruler = yes
		faith = { has_doctrine_parameter = can_use_summon_dragons_active }
	}
	
	is_valid = {
		is_at_war = yes
	}
	
	cost = {
		piety = summon_dragons_cost
	}

	effect = {
		custom_tooltip = summon_dragons_decision_effect_tooltip
		custom_tooltip = summon_dragons_decision_effect_tooltip_2
		
		trigger_event = ek_religious_decision.0301
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
	}
}

### Call for Nightmares
# Invoke your god (mostly Vaermina) to send you a nightmare. Heavy stress hit if you fail, piety gain if you win
call_for_nightmares_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	desc = call_for_nightmares_decision_desc
	selection_tooltip = call_for_nightmares_decision_tooltip
	
	# cooldown = { months = 60 }

	is_shown = {
		is_ruler = yes
		faith = { has_doctrine_parameter = intentional_nightmares_mechanics_active }
	}
	
	is_valid = {
		# Doesn't already have a nightmare modifier
		NOT = {
			has_character_modifier = ritual_nightmares_triumph_1_modifier
			has_character_modifier = ritual_nightmares_defeat_1_modifier
		}
	}
	
	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	effect = {
		custom_tooltip = call_for_nightmares_decision_effect_tooltip
		
		show_as_tooltip = {
			random_list = {
				50 = {
					show_chance = no
					desc = call_for_nightmares_decision_effect_tooltip_success
					add_piety = 250
				}
				50 = {
					show_chance = no
					desc = call_for_nightmares_decision_effect_tooltip_failure
					add_stress = medium_stress_impact_gain
				}
			}
		}
		
		trigger_event = ek_religious_decision.0601
		
		stress_impact = {
			craven = medium_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
	}
}

### Bury an ancestor in Cath Bedraud
# TODO: Holy Sites features
bury_in_cath_bedraud_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }

	desc = bury_in_cath_bedraud_decision_desc
	selection_tooltip = bury_in_cath_bedraud_decision_tooltip

	is_shown = {
		NOT = {
			has_dlc_feature = legends_of_the_dead
		}
		faith = { controls_holy_site_with_flag = is_used_for_cath_bedraud_burial }
		root.faith = {
			controls_holy_site = hs_cath_bedraud
		}

		title:b_cath_bedraud = {
			is_holy_site_of = root.faith
		}
		has_variable = ancestor_to_bury
		var:ancestor_to_bury = {
			OR = {
				NOT = { exists = var:body_has_been_disposed }
				AND = {
					exists = var:body_has_been_disposed
					var:body_has_been_disposed = no
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war = no
	}

	effect = {
		show_as_tooltip = {
			dynasty = { add_dynasty_prestige = minor_dynasty_prestige_value }
			if = {
				limit = {
					any_vassal = {
						save_temporary_scope_as = current_vassal
						
						title:b_cath_bedraud = {
							is_holy_site_of = scope:current_vassal.faith
						}
					}
				}
				every_vassal = {
					limit = {
						save_temporary_scope_as = current_vassal
						
						title:b_cath_bedraud = {
							is_holy_site_of = scope:current_vassal.faith
						}
					}
					custom = give_cath_bedraud_burial_vassals
					add_opinion = {
						modifier = pleased_opinion
						target = root
						opinion = 20
					}
				}
			}
		}
		hidden_effect = {
			var:ancestor_to_bury = {
				set_dead_character_variable = {
					name = body_has_been_disposed
					value = yes
					years = 5
				}
			}
		}
		trigger_event = ek_religious_decision.0502
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 36
		duchy = 36
		kingdom = 36
		empire = 36
		hegemony = 36
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

##### Monolatric Aspects decisions
### Aspect of Knowledge
# Improve the education
aspect_knowledge_increase_education_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 12
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}
	
	decision_group_type = major

	desc = aspect_knowledge_increase_education_decision_desc
	selection_tooltip = aspect_knowledge_increase_education_decision_tooltip
	
	cooldown = { months = 120 }

	is_shown = {
		# is_ruler = yes # Would be nice to have courtiers also improve their education
		faith = { has_doctrine_parameter = devotion_lvl_4_gives_increase_education }
		
		piety_level >= 2
		
		OR = {
			has_education_rank_1_trigger = yes
			has_education_rank_2_trigger = yes
			has_education_rank_3_trigger = yes
		}
	}
	
	is_valid = {
		piety_level >= 4
		
		trigger_if = {
			limit = { has_education_rank_1_trigger = yes }
			piety >= 250
		}
		trigger_if = {
			limit = { has_education_rank_2_trigger = yes }
			piety >= 500
		}
		trigger_if = {
			limit = { has_education_rank_3_trigger = yes }
			piety >= 750
		}
	}

	effect = {
		show_as_tooltip = {
			if = {
				limit = { has_education_rank_1_trigger = yes }
				add_piety = -250
			}
			if = {
				limit = { has_education_rank_2_trigger = yes }
				add_piety = -500
			}
			if = {
				limit = { has_education_rank_3_trigger = yes }
				add_piety = -750
			}
			custom_tooltip = aspect_knowledge_increase_education_decision_effect_tt
			rank_up_education_effect = yes
		}
		
		trigger_event = ek_religious_decision.1001
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
	}
}

# Swap the education
aspect_knowledge_swap_education_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 12
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}
	
	decision_group_type = major

	desc = aspect_knowledge_swap_education_decision_desc
	selection_tooltip = aspect_knowledge_swap_education_decision_tooltip
	
	cooldown = { months = 120 }

	is_shown = {
		is_ai = no # Not sure yet, might need to be locked to players only
		is_ruler = yes
		faith = { has_doctrine_parameter = devotion_lvl_5_gives_change_education }
		
		piety_level >= 3
	}
	
	is_valid = {
		piety_level >= 5
	}
	
	cost = {
		piety = 1000
	}

	effect = {
		custom_tooltip = aspect_knowledge_swap_education_decision_effect_tt
		trigger_event = ek_religious_decision.1002
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
	}
}

### Aspect of the Stars
# Change our Star sign
aspect_stars_change_starsign_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 12
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}
	
	decision_group_type = major

	desc = aspect_stars_change_starsign_decision_desc
	selection_tooltip = aspect_stars_change_starsign_decision_tooltip
	
	cooldown = { months = 120 }

	is_shown = {
		is_ai = no # Not sure yet, might need to be locked to players only
		is_ruler = yes
		faith = { has_doctrine_parameter = devotion_lvl_4_gives_changing_star_sign }
		
		piety_level >= 2
	}
	
	is_valid = {
		piety_level >= 4
	}
	
	cost = {
		piety = 1000
	}

	effect = {
		custom_tooltip = aspect_stars_change_starsign_decision_effect_tt
		trigger_event = ek_religious_decision.1003
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
	}
}

### Aspect of Inner Peace
# Remove a negative coping and seething trait
aspect_inner_peace_remove_bad_stress_trait_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}
	
	decision_group_type = major

	desc = aspect_inner_peace_remove_bad_stress_trait_decision_desc
	selection_tooltip = aspect_inner_peace_remove_bad_stress_trait_decision_tooltip
	
	cooldown = { months = 120 }

	is_shown = {
		is_ruler = yes
		faith = { has_doctrine_parameter = devotion_lvl_4_gives_lose_coping_trait }
		
		piety_level >= 2
		has_negative_stress_trigger = yes
	}
	
	is_valid = {
		piety_level >= 4
		has_negative_stress_trigger = yes
	}
	
	cost = {
		piety = 250
	}

	effect = {
		custom_tooltip = aspect_inner_peace_remove_bad_stress_trait_decision_effect_tt
		trigger_event = ek_religious_decision.1010
	}

	ai_potential = {
		is_landed = yes
	}

	ai_will_do = {
		base = 20
	}
}

### Hist Faiths
# Chukka-Sei
chukka_sei_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_commune_hist.dds" }
	decision_group_type = major
	ai_check_interval_by_tier = {
		barony = 0
		county = 12
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	desc = chukka_sei_decision_desc
	selection_tooltip = chukka_sei_decision_tooltip

	cooldown = { months = 12 }

	is_shown = {
		NOT = { has_character_flag = chukka-sei }
		OR = {
			has_culture = culture:hleel
			has_culture = culture:naga
			has_culture = culture:paatru
			has_culture = culture:agaceph
			has_culture = culture:sarpa
			has_culture = culture:hapsleet
		}
	}

	is_valid = {
		is_adult = yes
		custom_description = {
			text = current_month_5
			current_month = 5
		}
	}

	effect = {
		custom_tooltip = chukka_sei_decision_effect_tt
		trigger_event = ek_coming_of_age.0010
	}

	ai_potential = {
		always = yes
	}
}

# Commune with the Totem Spirit
commune_with_totem_spirit_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	desc = commune_with_totem_spirit_decision_desc
	selection_tooltip = commune_with_totem_spirit_decision_tooltip

	cooldown = { years = 10 }

	is_shown = {
		is_landed = yes
		culture = { has_cultural_pillar = heritage_orcish }
		faith = { has_doctrine = doctrine_clerical_gender_female_only }
	}

	effect = {
		custom_tooltip = commune_with_totem_spirit_decision_effect_tt
		trigger_event = {
			id = ek_religious_decision.1013
			days = { 5 30 }
		} 
	}

	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
		}		
	}
}

# Commune with the Ancestor Spirits
commune_with_ancestor_spirits_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	desc = commune_with_ancestor_spirits_decision_desc
	selection_tooltip = commune_with_ancestor_spirits_decision_tooltip

	cooldown = { years = 10 }

	is_shown = {
		is_landed = yes
		faith.religion = religion:velothi_religion
	}

	is_valid = {
		custom_description = {
			text = ancestor_requirement
			is_at_war = no
			any_ancestor = {
				even_if_dead = yes
				is_alive = no
				age >= 25
				num_virtuous_traits > 0
			}
		}
		custom_description = {
			text = available_adult
			is_available_adult = yes
		}
		is_at_war = no
		exists = cp:councillor_court_chaplain
	}

	effect = {
		custom_tooltip = commune_with_ancestor_spirits_decision_effect_tt
		trigger_event = {
			id = ek_religious_decision.1017
			days = { 5 30 }
		} 
	}

	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
		}		
	}
}

# seek sanguine to make a deal
sanguine_deal_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_misc.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	desc = sanguine_deal_decision_desc
	selection_tooltip = sanguine_deal_decision_tooltip

	cooldown = { years = 10 }

	is_shown = {
		is_landed = yes
		has_character_modifier = sanguines_wrath
	}

	cost = {
		gold = {
			value = medium_gold_value
		}
		piety = {
			value = medium_piety_value
		}
		prestige = {
			value = medium_prestige_value
		}
	}

	effect = {
		custom_tooltip = sanguine_deal_decision_effect_tt
		trigger_event = {
			id = ek_religious_decision.1014
			days = { 5 30 }
		} 
	}

	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
		}		
	}
}

### Liturgical language
# Recruit a scholar/priest knowing the language
recruit_priest_liturgical_language_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	decision_group_type = major

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

	cooldown = { years = 1 }
	
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { faith = { has_doctrine_parameter = realm_priest_must_speak_daedric } }
				desc = recruit_priest_liturgical_language_decision_daedric
			}
			triggered_desc = {
				trigger = { faith = { has_doctrine_parameter = realm_priest_must_speak_dragon } }
				desc = recruit_priest_liturgical_language_decision_dragon
			}
			triggered_desc = {
				trigger = { faith = { has_doctrine_parameter = realm_priest_must_speak_tsaesci } }
				desc = recruit_priest_liturgical_language_decision_tsaesci
			}
			triggered_desc = {
				trigger = { faith = { has_doctrine_parameter = realm_priest_must_speak_altmeris } }
				desc = recruit_priest_liturgical_language_decision_altmeris
			}
		}
	}

	is_shown = {
		faith = {
			OR = {
				has_doctrine_parameter = realm_priest_must_speak_daedric
				has_doctrine_parameter = realm_priest_must_speak_dragon
				has_doctrine_parameter = realm_priest_must_speak_tsaesci
				has_doctrine_parameter = realm_priest_must_speak_altmeris
			}
			NOT = { has_doctrine_parameter = serpent_priest }
		}
		
		# You must lack a realm priest
		primary_title.tier > tier_barony # because only tiers > baronies get councils
		is_landed_or_landless_administrative = yes
		NOT = { exists = cp:councillor_court_chaplain }
		has_free_council_slot = yes # Some special governments don't have court chaplains, so this will make sure they don't try this
	}

	effect = {
		custom_tooltip = recruit_priest_liturgical_language_decision.tt
		hidden_effect = {
			if = {
				limit = {
					exists = root.capital_province
					any_pool_character = {
						province = root.capital_province
						can_be_court_chaplain_trigger = { COURT_OWNER = root }
						learning >= medium_skill_rating
						opinion = { # Just to make sure you don't pull in rivals or similar
							value >= -30
							target = root
						}
					}
				}
				random_pool_character = {
					province = root.capital_province
					limit = {
						can_be_court_chaplain_trigger = { COURT_OWNER = root }
						learning >= medium_skill_rating
						opinion = { # Just to make sure you don't pull in rivals or similar
							value >= -30
							target = root
						}
					}
					
					save_scope_as = new_priest
				}
			}
			else = {
				create_character = {
					employer = root
					template = priest_character_template
					faith = root.faith
					culture = root.culture
					dynasty = none
					# gender_female_chance = root_faith_clergy_gender_female_chance
					
					save_scope_as = new_priest
				}
			}
			
			if = { # Error suppression
				limit = {
					exists = scope:new_priest
				}
				scope:new_priest = {
					force_character_skill_recalculation = yes
					add_character_flag = {
						flag = blocked_from_leaving
						years = 25
					}
				}
				if = {
					limit = {
						scope:new_priest = {
							NOT = {
								is_courtier_of = root
							}
						}
					}
					add_courtier = scope:new_priest
				}
				if = {
					limit = {
						exists = cp:councillor_court_chaplain
					}
					fire_councillor = cp:councillor_court_chaplain
					assign_councillor_type = {
						type = councillor_court_chaplain
						target = scope:new_priest
					}
				}
				else = {
					assign_councillor_type = {
						type = councillor_court_chaplain
						target = scope:new_priest
					}
				}
				send_interface_toast = {
					title = priest_recruited.t
					left_icon = scope:new_priest
					custom_tooltip = priest_recruited.desc
				}
			}
		}
	}

	cost = {
		gold = {
			value = minor_gold_value
		}
		piety = {
			value = medium_piety_value
		}
	}

	ai_will_do = {
		base = 100
	}
}

# Faithful perk - Try to learn your faith's Liturgical Language
learn_liturgical_language_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	decision_group_type = major

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

	cooldown = { years = 5 }
	
	desc = learn_liturgical_language_decision_desc

	is_shown = {
		faith = { faith_has_liturgical_language = yes }
		
		NOT = { knows_liturgical_language = yes }
		
		NOT = { any_scheme = { scheme_type = ek_learn_liturgical_language } }
	}

	effect = {
		custom_tooltip = starts_ek_learn_liturgical_language_scheme_now
		trigger_event = ek_learn_liturgical_language_ongoing.0001
	}

	cost = {
		piety = {
			value = minor_piety_value
		}
	}

	ai_will_do = {
		base = 100
	}
}

### The Celestial Serpent - recruit court chaplain who was 'born' under the Serpent
recruit_priest_scaled_court_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	decision_group_type = major

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

	cooldown = { years = 1 }
	
	desc = recruit_priest_scaled_court_decision_desc

	is_shown = {
		faith = { has_doctrine_parameter = serpent_priest }

		# You must lack a realm priest
		primary_title.tier > tier_barony # because only tiers > baronies get councils
		is_landed_or_landless_administrative = yes
		NOT = { exists = cp:councillor_court_chaplain }
		has_free_council_slot = yes # Some special governments don't have court chaplains, so this will make sure they don't try this
		
	}

	effect = {
		custom_tooltip = recruit_priest_scaled_court_decision.tt
		hidden_effect = {
			if = {
				limit = {
					exists = root.capital_province
					any_pool_character = {
						province = root.capital_province
						can_be_court_chaplain_trigger = { COURT_OWNER = root }
						learning >= medium_skill_rating
						opinion = { # Just to make sure you don't pull in rivals or similar
							value >= -30
							target = root
						}
					}
				}
				random_pool_character = {
					province = root.capital_province
					limit = {
						can_be_court_chaplain_trigger = { COURT_OWNER = root }
						learning >= medium_skill_rating
						opinion = { # Just to make sure you don't pull in rivals or similar
							value >= -30
							target = root
						}
					}
					
					save_scope_as = new_priest
				}
			}
			else = {
				create_character = {
					employer = root
					template = priest_character_template
					faith = root.faith
					culture = root.culture
					dynasty = none
					# gender_female_chance = root_faith_clergy_gender_female_chance
					
					save_scope_as = new_priest
				}
			}
			
			if = { # Error suppression
				limit = {
					exists = scope:new_priest
				}
				scope:new_priest = {
					force_character_skill_recalculation = yes
					add_character_flag = {
						flag = blocked_from_leaving
						years = 25
					}
				}
				if = {
					limit = {
						scope:new_priest = {
							NOT = {
								is_courtier_of = root
							}
						}
					}
					add_courtier = scope:new_priest
				}
				if = {
					limit = {
						exists = cp:councillor_court_chaplain
					}
					fire_councillor = cp:councillor_court_chaplain
					assign_councillor_type = {
						type = councillor_court_chaplain
						target = scope:new_priest
					}
				}
				else = {
					assign_councillor_type = {
						type = councillor_court_chaplain
						target = scope:new_priest
					}
				}
				send_interface_toast = {
					title = priest_recruited.t
					left_icon = scope:new_priest
					custom_tooltip = priest_recruited.desc
				}
			}
		}
	}

	cost = {
		gold = {
			value = minor_gold_value
		}
		piety = {
			value = medium_piety_value
		}
	}

	ai_will_do = {
		base = 100
	}
}

#Champion Conversion
champion_conversion_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	decision_group_type = major
	ai_check_interval_by_tier = {
		barony = 0
		county = 12
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	desc = champion_conversion_decision_desc
	selection_tooltip = champion_conversion_decision_tooltip

	is_shown = {
		OR = {
			AND = {
				has_character_flag = vaermina_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_vaermina }}
			}
			AND = {
				has_character_flag = sanguine_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_sanguine }}
			}
			AND = {
				has_character_flag = hircine_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_hircine}}
			}
			AND = {
				has_character_flag = meridia_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_meridia }}
			}
			AND = {
				has_character_flag = boethiah_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_boethiah }}
			}
			AND = {
				has_character_flag = molag_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_molag }}
			}
			AND = {
				has_character_flag = azura_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_azura }}
			}
			AND = {
				has_character_flag = clavicus_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_clavicus }}
			}
			AND = {
				has_character_flag = mehrunes_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_mehrunes }}
			}
			AND = {
				has_character_flag = hermaeus_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_hermaeus}}
			}
			AND = {
				has_character_flag = namira_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_namira }}
			}
			AND = {
				has_character_flag = sheogorath_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_sheogorath }}
			}	
			AND = {
				has_character_flag = malacath_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_malacath }}
			}	
			AND = {
				has_character_flag = nocturnal_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_nocturnal }}
			}	
			AND = {
				has_character_flag = mephala_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_mephala }}
			}	
			AND = {
				has_character_flag = peryite_conversion
				NOT = { faith = { has_doctrine = doctrine_pantheon_peryite }}				
			}	
		}
	}

	is_valid = {
		is_adult = yes
	}

	effect = {
		if = {
			limit = {
				has_character_flag = vaermina_conversion
			}
			set_character_faith_with_conversion = faith:vaermina_cult
			remove_character_flag = vaermina_conversion
		}
		if = {
			limit = {
				has_character_flag = sanguine_conversion
			}
			set_character_faith_with_conversion = faith:sanguine_cult
			remove_character_flag = sanguine_conversion
		}
		if = {
			limit = {
				has_character_flag = hircine_conversion
			}
			set_character_faith_with_conversion = faith:hircine_cult
			remove_character_flag = hircine_conversion
		}
		if = {
			limit = {
				has_character_flag = meridia_conversion
			}
			set_character_faith_with_conversion = faith:meridia_cult
			remove_character_flag = meridia_conversion
		}
		if = {
			limit = {
				has_character_flag = boethiah_conversion
			}
			set_character_faith_with_conversion = faith:boethiah_cult
			remove_character_flag = boethiah_conversion
		}
		if = {
			limit = {
				has_character_flag = molag_conversion
			}
			set_character_faith_with_conversion = faith:molag_cult
			remove_character_flag = molag_conversion
		}
		if = {
			limit = {
				has_character_flag = azura_conversion
			}
			set_character_faith_with_conversion = faith:azura_cult
			remove_character_flag = azura_conversion
		}
		if = {
			limit = {
				has_character_flag = clavicus_conversion
			}
			set_character_faith_with_conversion = faith:clavicus_cult
			remove_character_flag = clavicus_conversion
		}
		if = {
			limit = {
				has_character_flag = mehrunes_conversion
			}
			set_character_faith_with_conversion = faith:mehrunes_cult
			remove_character_flag = mehrunes_conversion
		}
		if = {
			limit = {
				has_character_flag = hermaeus_conversion
			}
			set_character_faith_with_conversion = faith:hermaeus_cult
			remove_character_flag = hermaeus_conversion
		}
		if = {
			limit = {
				has_character_flag = namira_conversion
			}
			set_character_faith_with_conversion = faith:namira_cult
			remove_character_flag = namira_conversion
		}
		if = {
			limit = {
				has_character_flag = sheogorath_conversion
			}
			set_character_faith_with_conversion = faith:sheogorath_cult
			remove_character_flag = sheogorath_conversion
		}
		if = {
			limit = {
				has_character_flag = malacath_conversion
			}
			set_character_faith_with_conversion = faith:malacath_cult
			remove_character_flag = malacath_conversion
		}
		if = {
			limit = {
				has_character_flag = mephala_conversion
			}
			set_character_faith_with_conversion = faith:mephala_cult
			remove_character_flag = mephala_conversion
		}
		if = {
			limit = {
				has_character_flag = peryite_conversion
			}
			set_character_faith_with_conversion = faith:peryite_cult
			remove_character_flag = peryite_conversion
		}
		if = {
			limit = {
				has_character_flag = nocturnal_conversion
			}
			set_character_faith_with_conversion = faith:nocturnal_cult
			remove_character_flag = nocturnal_conversion
		}
	}

	ai_potential = {
		
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = 20
			has_trait = cynical
		}
	}
}

#Form the Council of the Eight
form_cote_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }

	desc = form_cote_decision_desc
	selection_tooltip = form_cote_decision_tt

	decision_group_type = major
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 120
		hegemony = 120
	}
	
	is_shown = {
		is_landed = yes
		has_cyrodilic_empire_trigger = yes
		any_sub_realm_county = { this = title:c_imperial_city } #Temple of the one
		faith = { #Cyrodilic cult without HOF
			has_doctrine = special_doctrine_cyrodiilic_cult
			NOT = { exists = religious_head }
		}
		NOT = {
			is_target_in_global_variable_list = {
				name = talos_patron_available
				target = flag:db_emperor
			}
		}
	}
	is_valid_showing_failures_only = {
		is_imprisoned = no
		is_adult = yes
		is_at_war = no
	}
	is_valid = {
		piety_level >= 5
		faith = { #Cyrodilic cult without HOF
			has_doctrine = special_doctrine_cyrodiilic_cult
			NOT = { exists = religious_head }
		}
		custom_tooltip = { #gotta control cyrodilic cult counties
		 	text = control_cyro_cult_counties
		 	cyro_cult_counties_percent_value >= 75
		}
		# gotta be able to form a HoF title. this is one of the reqs in can_create_spiritual_head_of_faith_title_trigger, the others being level of devotion (already handled above) and some other irrelevant ones
		faith = {
			num_realm_holy_sites_faithful_holders = {
				CHARACTER = ROOT
				COUNT = holy_sites_to_create_spiritual_head_of_faith
			}
		}
    }
	cost = {
		gold = 500
        piety = 2000
	}
	effect =  {
		custom_tooltip = {
			text = form_cote_gain_spiritual_head
			every_religion_global = { #gotta check for every religion, not just Imperial, since Dawn Court may become Cyrodilic Cult too
				every_faith = {
					limit = {
						has_doctrine = special_doctrine_cyrodiilic_cult
					}		
					if = {
						limit = {
							NOT = { has_doctrine = doctrine_spiritual_head } #if the faith doesn't have the spiritual head doctrine, we gotta give it to them
						}
						#remove all other HoF doctrines to be safe
						if = {
							limit = { has_doctrine = doctrine_no_head }
							remove_doctrine = doctrine_no_head
						}
						if = {
							limit = { has_doctrine = doctrine_temporal_head }
							remove_doctrine = doctrine_temporal_head
						}
						if = {
							limit = { has_doctrine = doctrine_mystical_birthright_head }
							remove_doctrine = doctrine_mystical_birthright_head
						}
						add_doctrine = doctrine_spiritual_head #then add the relevant one	
						if = {
							limit = { has_doctrine = doctrine_clerical_succession_spiritual_appointment }
							remove_doctrine = doctrine_clerical_succession_spiritual_appointment
						}
						if = {
							limit = { has_doctrine = doctrine_clerical_succession_temporal_appointment }
							remove_doctrine = doctrine_clerical_succession_temporal_appointment
						}
						if = {
							limit = { has_doctrine = doctrine_clerical_succession_temporal_fixed_appointment }
							remove_doctrine = doctrine_clerical_succession_temporal_fixed_appointment
						}
						add_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment
					}
					set_religious_head_title = title:k_council_of_the_eight #set the HoF to the CotE (gotta do this after giving them the appropriate doctrine)

					faith_update_base_hostility_with_everyone_else = { FAITH = this } # since sharing HoF reduces hostility by 5, recalculate hostility for the affected faiths
				}
			}
		}
		custom_tooltip = {
			text = form_cote_religious_head
			trigger_event = faith_creation.0012 #spawn a priest to hold the newly formed Council of the Eight
		}
	}

	ai_will_do = {
		base = 40 #let's not have the AI do this too often
	}
}	

# Consult the Xarxeans
consult_xarxeans_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }

	desc = consult_xarxeans_decision_desc
	selection_tooltip = consult_xarxeans_decision_tt
	decision_group_type = major

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

	cooldown = { years = 10 }
	
	is_shown = {
		# Top liege of an empire tier Ceremoniarchy realm
		has_realm_law = xarxean_investiture_succession_law
	}
	
	effect =  {
		custom_tooltip = {
			text = consult_xarxeans_decision_effect
			add_character_flag = { # this flag exists for loc purposes in the event
				flag = consulted_xarxeans_flag
				days = 7
			}
			trigger_event = {
				id = ek_xarxean_investiture_event.0001
			}
		}
	}
	ai_potential = {
		has_realm_law = xarxean_investiture_succession_law
	}
	ai_will_do = {
		base = 100
	}
}

# Claim the Order of the Black Worm
claim_d_worm_kingdom = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }

	desc = claim_d_worm_kingdom_desc
	selection_tooltip = claim_d_worm_kingdom_tt
	decision_group_type = major

	ai_check_interval_by_tier = {
		barony = 0
		county = 120
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}
	
	is_shown = {
		faith = faith:worm_cult
		NOT = { exists = title:d_worm_kingdom.holder }
	}

	is_valid = {
		has_trait = necromancer
		has_perk = necromancy_master_perk
		piety_level >= max_piety_level
		is_landed_or_landless_administrative = yes
	}

	cost = {
		piety = 1000
	}

	effect =  {
		faith:worm_cult = {
			save_scope_as = worm_cult
		}
		title:d_worm_kingdom = {
			save_scope_as = worm_kingdom
		}
		custom_tooltip = {
			text = claim_d_worm_kingdom_effect_1
			trigger_event = {
				id = ek_faith_events.0005
				days = 2
			}
		}
		custom_tooltip = claim_d_worm_kingdom_effect_2
	}

	ai_will_do = {
		base = 100 #AI wanna do this
	}
}

# Inflict disease on yourself
proclaim_disease_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds" }
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	desc = proclaim_disease_decision_desc
	selection_tooltip = proclaim_disease_decision_tt

	cooldown = { years = 10 }

	is_shown = {
		faith = { has_doctrine_parameter = self_disease_active }
	}

	effect = {
		custom_tooltip = proclaim_disease_decision_effect_tt
		trigger_event = ek_religious_decision.1019
	}

	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
		}		
	}
}
