﻿namespace = religious_decision

#########################
# Seek Aid of Spirits	#
# by Sean Hughes		#
# 0001-0009				#
#########################


religious_decision.0001 = {
	type = character_event
	title = religious_decision.0001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_government = landless_adventurer_government }
				desc = religious_decision.0001.desc_landless
			}
			desc = religious_decision.0001.desc
		}
	}
	theme = faith
	override_background = { reference = fp3_cave }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:realm_priest }
			}
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = {
				NOT = { has_trait = cynical }
			}
			animation = disbelief
		}
		animation = personality_coward
	}
	right_portrait = {
		trigger = { exists = scope:realm_priest }
		character = scope:realm_priest
		animation = personality_zealous
	}
	trigger = {
		NOT = { has_character_flag = flag_sought_aid_of_spirits }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		if = {
			limit = { exists = cp:councillor_court_chaplain }
			cp:councillor_court_chaplain = {
				save_scope_as = realm_priest
			}
		}
	}

	option = {
		trigger = {
			OR = {
				is_ai = no
				short_term_gold > major_gold_value
			}
		}
		name = religious_decision.0001.a
		remove_short_term_gold = major_gold_value
		custom_tooltip = religious_decision.0001.a.tt.1
		custom_tooltip = religious_decision.0001.a.tt.2
		save_scope_value_as = {
			name = offering
			value = flag:expensive
		}
		stress_impact = {
			greedy = medium_stress_gain
			cynical = medium_stress_gain
		}
		trigger_event = {
			id = religious_decision.0002
			days = { 2 3 }
		}
		ai_chance = {
			base = 0

			ai_value_modifier = {
				ai_zeal = 10
				ai_greed = -10
			}
		}
	}

	option = {
		trigger = {
			OR = {
				is_ai = no
				short_term_gold > minor_gold_value
			}
		}
		name = religious_decision.0001.b
		remove_short_term_gold = minor_gold_value
		custom_tooltip = religious_decision.0001.b.tt
		save_scope_value_as = {
			name = offering
			value = flag:traditional
		}
		trigger_event = {
			id = religious_decision.0002
			days = { 2 3 }
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = religious_decision.0001.c
		custom_tooltip = religious_decision.0001.c.tt
		save_scope_value_as = {
			name = offering
			value = flag:none
		}
		stress_impact = {
			generous = medium_stress_gain
			humble = medium_stress_gain
		}
		trigger_event = {
			id = religious_decision.0002
			days = { 2 3 }
		}

		ai_chance = {
			base = 0

			ai_value_modifier = {
				ai_boldness = 5
				ai_greed = 5
				ai_zeal = -10
			}

			modifier = {
				add = 980
				has_trait = arrogant
			}
		}
	}

	option = {
		name = religious_decision.0001.d
		flavor = religious_decision.0001.d.flavor
		remove_character_flag = flag_sought_aid_of_spirits
		ai_chance = {
			base = 0
		}
	}
}

religious_decision.0002 = {
	type = character_event
	title = religious_decision.0002.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:realm_priest
					scope:offering = flag:none
				}
				desc = religious_decision.0002.desc.start_no_offering
			}
			triggered_desc = {
				trigger = { scope:offering = flag:none }
				desc = religious_decision.0002.desc.start_no_offering_alone
			}
			triggered_desc = {
				trigger = { exists = scope:realm_priest }
				desc = religious_decision.0002.desc.start_offering
			}
			desc = religious_decision.0002.desc.start_offering_alone
		}
		first_valid = {
			triggered_desc = { 
				trigger = { exists = scope:realm_priest }
				desc = religious_decision.0002.desc
			}
			desc = religious_decision.0002.desc_alone
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:outcome = flag:no_effect
				}
				desc = religious_decision.0002.desc.end_no_change
			}
			desc = religious_decision.0002.desc.end_changed
		}
	}
	theme = faith
	override_background = { reference = fp3_cave }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:outcome = flag:shrewd }
			animation = personality_rational
		}
		triggered_animation = {
			trigger = { 
				OR = {
					scope:outcome = flag:strong
					scope:outcome = flag:wind_spirit
					scope:outcome = flag:water_spirit
					scope:outcome = flag:tree_spirit
					scope:outcome = flag:bush_spirit
					scope:outcome = flag:rock_spirit
				}
			}
			animation = ecstasy
		}
		triggered_animation = {
			trigger = { 
				OR = {
					scope:outcome = flag:possessed 
					scope:outcome = flag:impotent
				}
			}
			animation = paranoia
		}
		triggered_animation = {
			trigger = { scope:outcome = flag:ill }
			animation = sick
		}
		triggered_animation = {
			trigger = { scope:outcome = flag:infirm }
			animation = personality_irrational
		}
		animation = disbelief
	}
	right_portrait = {
		trigger = { exists = scope:realm_priest }
		character = scope:realm_priest
		animation = personality_zealous
	}

	trigger = {
		trigger_if = {
			limit = { exists = scope:realm_priest }
			scope:realm_priest = { is_available_adult = yes }
		}
	}
	# Refund the player's money if the ritual fails for some reason.
	on_trigger_fail = {
		if = {
			limit = {
				scope:offering = flag:expensive
			}
			add_gold = major_gold_value
		}
		else_if = {
			limit = {
				scope:offering = flag:traditional
			}
			add_gold = minor_gold_value
		}
	}
	immediate = {
		# Character cannot take this decision again for 5 years.
		add_character_flag = {
			flag = flag_sought_aid_of_spirits
			years = 5
		}
		# Determine what the impact of the ritual will be.
		if = {
			#Realm Priest, don't fail me now
			limit = { exists = scope:realm_priest }
			random_list = {
				# Positive Effect
				35 = { # Maximum ~85% chance of a good effect (Expensive offering nullifies no outcome; 60 weight good vs. 10 weight bad)
					compare_modifier = {
						value = {
							value = scope:realm_priest.learning
							subtract = 10
						}
					}
					modifier = {
						add = 10
						scope:realm_priest = { has_trait = lifestyle_mystic }
					}
					random_list = {
						# Permanent Skill Boost
						25 = {
							# Minimum chance of ~0%. Maximum chance of ~40% (Miracle Worker RP with 20 Learning and an Expensive Offering)
							compare_modifier = {
								value = {
									value = scope:realm_priest.learning
									subtract = 20
								}
							}
							modifier = {
								add = 10
								scope:realm_priest = { has_trait = lifestyle_mystic }
							}
							modifier = {
								add = 10
								scope:realm_priest = {
									has_trait = lifestyle_mystic
									has_trait_xp = {
										trait = lifestyle_mystic
										value >= 50
									}
								}
							}
							modifier = {
								add = 10
								scope:realm_priest = {
									has_trait = lifestyle_mystic
									has_trait_xp = {
										trait = lifestyle_mystic
										value >= 100
									}
								}
							}
							modifier = {
								add = 20
								scope:offering = flag:expensive
							}
							trigger = {
								NAND = {
									has_trait = shrewd
									has_trait_rank = {
										trait = intellect_bad
										rank > 0
									}
									has_trait = strong
									has_trait_rank = {
										trait = physique_bad
										rank > 0
									}
								}
							}
							random_list = {
								50 = {
									trigger = {
										NOR = {
											has_trait = shrewd
											has_trait_rank = {
												trait = intellect_bad
												rank > 0
											}
										}
									}
									save_scope_value_as = {
										name = outcome
										value = flag:shrewd
									}
								}
								50 = {
									trigger = {
										NOR = {
											has_trait = strong
											has_trait_rank = {
												trait = physique_bad
												rank > 0
											}
										}
									}
									save_scope_value_as = {
										name = outcome
										value = flag:strong
									}
								}
							}
						}
						# Temporary Skill Boost
						75 = {
							random_list = {
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:wind_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:water_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:bush_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:rock_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:tree_spirit
									}
								}
							}
						}
					}
				}
				# No Effect
				40 = {
					# Offering modifiers only effect the 'None' chance.
					modifier = { # 0% chance with expensive offering.
						add = -40
						scope:offering = flag:expensive
					}
					modifier = { # 40% chance with standard offering.
						add = 0
						scope:offering = flag:traditional
					}
					modifier = { # 66% chance with no offering.
						add = 80
						scope:offering = flag:none
						NOT = { has_trait = arrogant }
					}

					# Since the effects of the ritual could be explained through belief alone (placebo effect), a character's skepticism influences if they receive a bonus or not.
					modifier = { # Cynical characters less likely to believe in the ritual.
						add = 40
						has_trait = cynical
					}
					modifier = { # Zealous characters more likely to believe in the ritual.
						add = -20
						has_trait = zealous
					}
					save_scope_value_as = {
						name = outcome
						value = flag:no_effect
					}
				}
				# Negative Effect
				20 = {
					modifier = {
						add = 20
						scope:offering = flag:none
					}
					compare_modifier = {
						value = {
							value = 10
							subtract = scope:realm_priest.learning
							min = -10
						}
					}
					random_list = {
						25 = {
							trigger = { NOT = { has_trait = possessed } }
							modifier = {
								add = 100
								scope:offering = flag:expensive
							}
							save_scope_value_as = {
								name = outcome
								value = flag:possessed
							}
						}
						25 = {
							trigger = { NOT = { has_trait = impotent } }
							save_scope_value_as = {
								name = outcome
								value = flag:impotent
							}
						}
						25 = {
							trigger = { can_contract_disease_trigger = { DISEASE = ill } }
							save_scope_value_as = {
								name = outcome
								value = flag:ill
							}
						}
						25 = {
							trigger = { NOT = { has_trait = infirm } }
							save_scope_value_as = {
								name = outcome
								value = flag:infirm
							}
						}
					}
				}
			}
		}
		#... we're on our own
		else = {
			random_list = {
				# Positive Effect
				40 = { # Maximum ~85% chance of a good effect (Expensive offering nullifies no outcome; 60 weight good vs. 10 weight bad)
					compare_modifier = {
						value = {
							value = learning
							subtract = 10
						}
					}
					modifier = {
						add = 10
						has_trait = lifestyle_mystic
					}
					random_list = {
						# Permanent Skill Boost
						10 = {
							# Minimum chance of ~0%. Maximum chance of ~40% (Miracle Worker RP with 20 Learning and an Expensive Offering)
							compare_modifier = {
								value = {
									value = learning
									subtract = 10
								}
							}
							modifier = {
								add = 10
								has_trait = lifestyle_mystic
							}
							modifier = {
								add = 10
								has_perk = numina_via_geniorum_3_perk
							}
							modifier = {
								add = 10
								has_perk = numina_via_geniorum_4_perk
							}
							modifier = {
								add = 10
								has_perk = numina_via_geniorum_5_perk
							}
							trigger = {
								NAND = {
									AND = {
										has_trait = shrewd
										has_trait_rank = {
											trait = intellect_bad
											rank > 0
										}
									}
									AND = {
										has_trait = strong
										has_trait_rank = {
											trait = physique_bad
											rank > 0
										}
									}
								}
							}
							random_list = {
								50 = {
									trigger = {
										NOR = {
											has_trait = shrewd
											has_trait_rank = {
												trait = intellect_bad
												rank > 0
											}
										}
									}
									save_scope_value_as = {
										name = outcome
										value = flag:shrewd
									}
								}
								50 = {
									trigger = {
										NOR = {
											has_trait = strong
											has_trait_rank = {
												trait = physique_bad
												rank > 0
											}
										}
									}
									save_scope_value_as = {
										name = outcome
										value = flag:strong
									}
								}
							}
						}
						# Temporary Skill Boost
						99 = {
							random_list = {
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:wind_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:water_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:bush_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:rock_spirit
									}
								}
								20 = {
									save_scope_value_as = {
										name = outcome
										value = flag:tree_spirit
									}
								}
							}
						}
					}
				}
				# No Effect
				80 = {
					# Offering modifiers only effect the 'None' chance.
					modifier = { # 0% chance with expensive offering.
						add = -20
						scope:offering = flag:expensive
					}
					modifier = { # 40% chance with standard offering.
						add = 0
						scope:offering = flag:traditional
					}
					modifier = { # 66% chance with no offering.
						add = 80
						scope:offering = flag:none
						NOT = { has_trait = arrogant }
					}

					# Since the effects of the ritual could be explained through belief alone (placebo effect), a character's skepticism influences if they receive a bonus or not.
					modifier = { # Cynical characters less likely to believe in the ritual.
						add = 40
						has_trait = cynical
					}
					modifier = { # Zealous characters more likely to believe in the ritual.
						add = -20
						has_trait = zealous
					}
					modifier = {
						add = -10
						has_perk = numina_via_geniorum_2_perk
					}
					modifier = {
						add = -10
						has_perk = numina_via_geniorum_3_perk
					}
					modifier = {
						add = -10
						has_perk = numina_via_geniorum_4_perk
					}
					modifier = {
						add = -10
						has_perk = numina_via_geniorum_5_perk
					}
					save_scope_value_as = {
						name = outcome
						value = flag:no_effect
					}
				}
				# Negative Effect
				20 = {
					modifier = {
						add = 20
						scope:offering = flag:none
					}
					modifier = {
						add = -5
						has_perk = numina_via_geniorum_2_perk
					}
					modifier = {
						add = -5
						has_perk = numina_via_geniorum_3_perk
					}
					modifier = {
						add = -5
						has_perk = numina_via_geniorum_4_perk
					}
					modifier = {
						add = -5
						has_perk = numina_via_geniorum_5_perk
					}
					compare_modifier = {
						value = {
							value = 10
							subtract = learning
							min = -10
						}
					}
					random_list = {
						#Avoid immortal AI always ending up possessed
						1000 = {
							trigger = { 
								is_immortal = yes						
								is_ai = yes 
								}
							save_scope_value_as = {
								name = outcome
								value = flag:no_effect
							}
						}				
						25 = {
							trigger = { 
								NOT = { has_trait = possessed } 
								POD_can_be_possessed_trigger = yes
							}
							modifier = {
								add = 100
								scope:offering = flag:expensive
							}
							save_scope_value_as = {
								name = outcome
								value = flag:possessed
							}
						}
						25 = {
							trigger = { 
							NOT = { has_trait = impotent }
							is_immortal = no	
							}
							save_scope_value_as = {
								name = outcome
								value = flag:impotent
							}
						}
						25 = {
							trigger = { can_contract_disease_trigger = { DISEASE = ill } }
							save_scope_value_as = {
								name = outcome
								value = flag:ill
							}
						}
						25 = {
							trigger = { 
							NOT = { has_trait = infirm }
							is_immortal = no			
							}
							save_scope_value_as = {
								name = outcome
								value = flag:infirm
							}
						}
					}
				}
			}
		}

		# If we failed to set the outcome flag, set it now.
		if = {
			limit = {
				NOT = { exists = scope:outcome }
			}
			save_scope_value_as = {
				name = outcome
				value = flag:no_effect
			}
		}
	}

	option = {
		# Custom name text based on ritual outcome.
		name = {
			trigger = { scope:outcome = flag:shrewd }
			text = religious_decision.0002.shrewd
		}
		name = {
			trigger = { scope:outcome = flag:strong }
			text = religious_decision.0002.strong
		}
		name = {
			trigger = {
				OR = {
					scope:outcome = flag:wind_spirit
					scope:outcome = flag:water_spirit
					scope:outcome = flag:rock_spirit
					scope:outcome = flag:bush_spirit
					scope:outcome = flag:tree_spirit
				}
			}
			text = religious_decision.0002.good
		}
		name = {
			trigger = {
				OR = {
					scope:outcome = flag:ill
					scope:outcome = flag:impotent
					scope:outcome = flag:infirm
				}
			}
			text = religious_decision.0002.bad
		}
		name = {
			trigger = { scope:outcome = flag:possessed }
			text = religious_decision.0002.possessed
		}
		name = {
			trigger = {
				scope:outcome = flag:no_effect
				has_trait = zealous
			}
			text = religious_decision.0002.no_change.zealous
		}
		name = {
			trigger = {
				scope:outcome = flag:no_effect
				NOT = { has_trait = zealous }
			}
			text = religious_decision.0002.no_change
		}

		# Apply the actual outcome effects:
		# Good Outcomes
		if = {
			limit = { scope:outcome = flag:shrewd }
			if = {
				limit = { has_trait = dull }
				remove_trait = dull
			}
			else = {
				add_trait = shrewd
			}
		}
		else_if = {
			limit = { scope:outcome = flag:strong }
			if = {
				limit = { has_trait = weak }
				remove_trait = weak
			}
			else = {
				add_trait = strong
			}
		}
		else_if = {
			limit = { scope:outcome = flag:wind_spirit }
			add_character_modifier = {
				modifier = wind_spirit_blessing
				years = 20
			}
		}
		else_if = {
			limit = { scope:outcome = flag:water_spirit }
			add_character_modifier = {
				modifier = water_spirit_blessing
				years = 20
			}
		}
		else_if = {
			limit = { scope:outcome = flag:tree_spirit }
			add_character_modifier = {
				modifier = tree_spirit_blessing
				years = 20
			}
		}
		else_if = {
			limit = { scope:outcome = flag:bush_spirit }
			add_character_modifier = {
				modifier = bush_spirit_blessing
				years = 20
			}
		}
		else_if = {
			limit = { scope:outcome = flag:rock_spirit }
			add_character_modifier = {
				modifier = rock_spirit_blessing
				years = 20
			}
		}
		# Bad Outcomes
		else_if = {
			limit = { scope:outcome = flag:possessed }
			add_trait = possessed_1
		}
		else_if = {
			limit = { scope:outcome = flag:impotent }
			add_trait = impotent
		}
		else_if = {
			limit = { scope:outcome = flag:ill }
			contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
		}
		else_if = {
			limit = { scope:outcome = flag:infirm }
			add_trait = infirm
		}
	}
}

#########################
# Select Personal God	#
# by Sean Hughes		#
# 0101-0120				#
#########################

religious_decision.0101 = {
	type = character_event
	title = religious_decision.0101.t
	desc = {
		desc = religious_decision.0101.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
					}
				}
				desc = religious_decision.0101.desc.vaishnavism
			}
			triggered_desc = {
				trigger = {
					faith = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
					}
				}
				desc = religious_decision.0101.desc.shaivism
			}
			triggered_desc = {
				trigger = {
					faith = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
					}
				}
				desc = religious_decision.0101.desc.smartism
			}
			desc = religious_decision.0101.desc.generic
		}
		desc = religious_decision.0101.desc.end
	}
	theme = faith
	left_portrait = {
		character = root
		animation = personality_rational
	}

	# 'Generic' Hinduism
	option = {
		name = religious_decision.0101.ganga
		trigger = {
			NOR = {
				# vaishnavism includes this one
				faith = {
					OR = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
					}
				}
				has_character_modifier = bhakti_hinduism_ganga
			}
		}
		set_bhakti_effect = { BHAKTI = bhakti_hinduism_ganga }
	}

	option = {
		name = religious_decision.0101.saraswati
		trigger = {
			NOR = {
				faith = {
					OR = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
					}
				}
				has_character_modifier = bhakti_hinduism_saraswati
			}
		}
		set_bhakti_effect = { BHAKTI = bhakti_hinduism_saraswati }
	}

	option = {
		name = religious_decision.0101.kali
		trigger = {
			NOR = {
				faith = {
					OR = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
					}
				}
				has_character_modifier = bhakti_hinduism_kali
			}
		}
		set_bhakti_effect = { BHAKTI = bhakti_hinduism_kali }
	}

	option = {
		name = religious_decision.0101.kubera
		trigger = {
			NOR = {
				faith = {
					OR = {
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
						portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
					}
				}
				# smartism includes this one
				has_character_modifier = bhakti_hinduism_kubera
			}
		}
		set_bhakti_effect = { BHAKTI = bhakti_hinduism_kubera }
	}

	# Vaishnavism
	option = {
		name = religious_decision.0101.lakishmi
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
			}
			NOT = { has_character_modifier = bhakti_vaishnavism_lakishmi }
		}
		set_bhakti_effect = { BHAKTI = bhakti_vaishnavism_lakishmi }
	}

	option = {
		name = religious_decision.0101.jagganath
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
			}
			NOT = { has_character_modifier = bhakti_vaishnavism_jagganath }
		}
		set_bhakti_effect = { BHAKTI = bhakti_vaishnavism_jagganath }
	}

	option = {
		name = religious_decision.0101.hayagriva
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:vaishnavism }
			}
			NOT = { has_character_modifier = bhakti_vaishnavism_hayagriva }
		}
		set_bhakti_effect = { BHAKTI = bhakti_vaishnavism_hayagriva }
	}

	# Shaivism
	option = {
		name = religious_decision.0101.parvati
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
			}
			NOT = { has_character_modifier = bhakti_shaivism_parvati }
		}
		set_bhakti_effect = { BHAKTI = bhakti_shaivism_parvati }
	}

	option = {
		name = religious_decision.0101.virabhadra
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
			}
			NOT = { has_character_modifier = bhakti_shaivism_virabhadra }
		}
		set_bhakti_effect = { BHAKTI = bhakti_shaivism_virabhadra }
	}

	option = {
		name = religious_decision.0101.munishwarar
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
			}
			NOT = { has_character_modifier = bhakti_shaivism_munishwarar }
		}
		set_bhakti_effect = { BHAKTI = bhakti_shaivism_munishwarar }
	}

	option = {
		name = religious_decision.0101.dakshinamoorthy
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:shaivism }
			}
			NOT = { has_character_modifier = bhakti_shaivism_dakshinamoorthy }
		}
		set_bhakti_effect = { BHAKTI = bhakti_shaivism_dakshinamoorthy }
	}

	# Smartism
	option = {
		name = religious_decision.0101.ganesha
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
			}
			NOT = { has_character_modifier = bhakti_smartism_ganesha }
		}
		set_bhakti_effect = { BHAKTI = bhakti_smartism_ganesha }
	}

	option = {
		name = religious_decision.0101.vishnu
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
			}
			NOT = { has_character_modifier = bhakti_smartism_vishnu }
		}
		set_bhakti_effect = { BHAKTI = bhakti_smartism_vishnu }
	}

	option = {
		name = religious_decision.0101.shiva
		trigger = {
			faith = {
				portrait_religious_faith_or_foundational_trigger = { FAITH = faith:smartism }
			}
			NOT = { has_character_modifier = bhakti_smartism_shiva }
		}
		set_bhakti_effect = { BHAKTI = bhakti_smartism_shiva }
	}

	# Opt-Out
	option = {
		name = religious_decision.0101.optout
		flavor = religious_decision.0101.flavor

		ai_chance = {
			base = 0
		}
	}
}

religious_decision.0102 = {
	type = character_event
	title = religious_decision.0102.t
	desc = religious_decision.0102.desc
	theme = faith
	left_portrait = {
		character = root
		animation = personality_rational
	}

	# Odin
	option = {
		name = religious_decision.0102.odin
		trigger = {
			NOT = { has_character_modifier = bhakti_germanic_generic_odin }
		}
		set_bhakti_effect = { BHAKTI = bhakti_germanic_generic_odin }
	}

	# Ullr
	option = {
		name = religious_decision.0102.ullr
		trigger = {
			is_vaguely_danish_bhakti_trigger = no
			NOT = { has_character_modifier = bhakti_germanic_not_danish_ullr }
		}
		set_bhakti_effect = { BHAKTI = bhakti_germanic_not_danish_ullr }
	}

	# Tyr
	option = {
		name = religious_decision.0102.tyr
		trigger = {
			is_vaguely_danish_bhakti_trigger = yes
			NOT = { has_character_modifier = bhakti_germanic_danish_tyr }
		}
		set_bhakti_effect = { BHAKTI = bhakti_germanic_danish_tyr }
	}

	# Thor
	option = {
		name = religious_decision.0102.thor
		trigger = {
			NOT = { has_character_modifier = bhakti_germanic_generic_thor }
		}
		set_bhakti_effect = { BHAKTI = bhakti_germanic_generic_thor }
	}

	# Freyr
	option = {
		name = religious_decision.0102.freyr
		trigger = {
			NOT = { has_character_modifier = bhakti_germanic_generic_freyr }
		}
		set_bhakti_effect = { BHAKTI = bhakti_germanic_generic_freyr }
	}

	# Opt-Out
	option = {
		name = religious_decision.0102.optout
		flavor = religious_decision.0102.flavor

		ai_chance = {
			base = 0
		}
	}
}

#########################
# Meditate in Seclusion	#
# by Sean Hughes		#
# 0201-0299				#
#########################

# If the player exits the travel planning UI, this event fires reseting the decision cooldown and removing variables
religious_decision.0200 = {
	hidden = yes
	trigger = {
		OR = {
			exists = var:meditation_location
			has_character_flag = meditation_character_flag
		}
	}
	immediate = {
		current_travel_plan ?= { 
			if = {
				limit = { can_cancel = yes }
				cancel_travel_plan = yes
			}
		}
		remove_decision_cooldown = meditate_in_seclusion_decision
		remove_variable = meditation_location
		remove_character_flag = meditation_character_flag
	}
}

scripted_trigger religious_decision_0201_can_meditate_in_terrain_trigger = {
	religious_decision_0201_has_two_meditation_options_trigger = no
	any_sub_realm_barony = {
		this != root.capital_barony
		title_province = {
			terrain = $TERRAIN$
		}
	}
}

scripted_trigger religious_decision_0201_has_two_meditation_options_trigger = {
	# Stops after we've found 2 good places for meditation (don't want to overload the player).
	calc_true_if = {
		amount >= 2
		has_character_flag = meditation_option_basilica
		has_character_flag = meditation_option_plains
		has_character_flag = meditation_option_hills
		has_character_flag = meditation_option_steppe
		has_character_flag = meditation_option_forest
		has_character_flag = meditation_option_drylands
		has_character_flag = meditation_option_mountains
		has_character_flag = meditation_option_wetlands
		has_character_flag = meditation_option_jungle
		has_character_flag = meditation_option_desert
	}
}

scripted_effect save_meditation_option_effect = {
	add_character_flag = meditation_option_$TERRAIN$
	random_sub_realm_barony = {
		limit = {
			this != root.capital_barony
			title_province = {
				terrain = $TERRAIN$
			}
		}
		title_province = { save_scope_as = $TERRAIN$_location }
	}
}

scripted_effect meditate_at_location_effect = {
	set_variable = {
		name = meditation_location
		value = scope:$TERRAIN$_location
	}
	scope:$TERRAIN$_location = { #to show the location name in the difficulty custom tooltip
		save_scope_as = tooltip_loc
	}
	start_travel_plan = {
		destination = var:meditation_location
		on_travel_planner_cancel_event = religious_decision.0200
		on_arrival_event = religious_decision.0210
		on_arrival_destinations = all_but_last
	}
	add_character_modifier = {
		modifier = meditating_in_seclusion_modifier
		days = meditation_duration
	}
	add_character_flag = meditation_character_flag
}

religious_decision.0201 = {
	type = character_event
	title = religious_decision.0201.t
	desc = religious_decision.0201.desc
	theme = faith

	override_background = {
		reference = throne_room
	}

	left_portrait = {
		character = root
		animation = personality_rational
	}

	immediate = {
		# Stop characters from planning multiple activities at once.
		add_character_flag = {
			flag = planning_an_activity
			days = 30
		}
		
		# POD: Meditate in San Michele's basilica
		if = {
			limit = {
				any_directly_owned_province = {
					has_building_with_flag = san_michele_basilica
				}
			}
			random_directly_owned_province = {
				limit = {
					has_building_with_flag = san_michele_basilica
				}
				save_scope_as = basilica_location
			}
			add_character_flag = meditation_option_basilica
		}

		# Save the character's capital scope for meditation
		capital_barony.title_province = {
			save_scope_as = capital_location
		}

		# Generate options for meditation based on terrain in character's realm.
		if = {
			limit = {
				religious_decision_0201_has_two_meditation_options_trigger = no
				any_sub_realm_barony = {
					this != root.capital_barony
					title_province = {
						OR = {
							terrain = mountains
							terrain = desert_mountains
						}
					}
				}
			}
			add_character_flag = meditation_option_mountains
			random_sub_realm_barony = {
				limit = {
					this != root.capital_barony
					title_province = {
						OR = {
							terrain = mountains
							terrain = desert_mountains
						}
					}
				}
				title_province = { save_scope_as = mountains_location }
			}
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = steppe}}
			save_meditation_option_effect = { TERRAIN = steppe }
		}
		if = {
			limit = {
				religious_decision_0201_has_two_meditation_options_trigger = no
				any_sub_realm_barony = {
					this != root.capital_barony
					title_province = {
						OR = {
							terrain = forest
							terrain = taiga
						}
					}
				}
			}
			add_character_flag = meditation_option_forest
			random_sub_realm_barony = {
				limit = {
					this != root.capital_barony
					title_province = {
						OR = {
							terrain = forest
							terrain = taiga
						}
					}
				}
				title_province = { save_scope_as = forest_location }
			}
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = desert}}
			save_meditation_option_effect = { TERRAIN = desert }
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = hills}}
			save_meditation_option_effect = { TERRAIN = hills }
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = drylands}}
			save_meditation_option_effect = { TERRAIN = drylands }
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = plains}}
			save_meditation_option_effect = { TERRAIN = plains }
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = jungle}}
			save_meditation_option_effect = { TERRAIN = jungle }
		}
		if = {
			limit = { religious_decision_0201_can_meditate_in_terrain_trigger = {TERRAIN = wetlands}}
			save_meditation_option_effect = { TERRAIN = wetlands }
		}
	}
	
	# POD option: Meditate in San Michele's Basilica, Rome is capital province
	option = {
		trigger = {
			AND = {
				has_character_flag = meditation_option_basilica
				scope:basilica_location ?= scope:capital_location
			}
		}
		name = religious_decision.0201.basilica
		set_variable = {
			name = meditation_location
			value = scope:basilica_location
		}
		add_character_flag = meditation_character_flag
		add_character_modifier = {
			modifier = meditating_in_seclusion_modifier
			days = meditation_duration
		}
		custom_tooltip = religious_decision.0201.difficulty.easy
		custom_tooltip = religious_decision.0201.learning
		custom_tooltip = religious_decision.0201.trait
		trigger_event = {
			id = religious_decision.0211
			days = meditation_duration
		}
	}
	
	# POD option: Meditate in San Michele's Basilica, Rome is NOT capital province
	option = {
		trigger = {
			AND = {
				has_character_flag = meditation_option_basilica
				NOT = { scope:basilica_location ?= scope:capital_location }
			}
		}
		name = religious_decision.0201.basilica
		meditate_at_location_effect = { TERRAIN = basilica }
		custom_tooltip = religious_decision.0201.difficulty.easy
		custom_tooltip = religious_decision.0201.learning
		custom_tooltip = religious_decision.0201.trait
	}

	# Option 1: Meditate at home. Lowest risk, lowest reward.
	option = {
		trigger = {
			NAND = {
				has_character_flag = meditation_option_basilica
				scope:basilica_location ?= scope:capital_location
			}
		}
		name = religious_decision.0201.home
		set_variable = {
			name = meditation_location
			value = scope:capital_location
		}
		add_character_flag = meditation_character_flag
		add_character_modifier = {
			modifier = meditating_in_seclusion_modifier
			days = meditation_duration
		}
		scope:capital_location = { #to show the location name in the difficulty custom tooltip
			save_scope_as = tooltip_loc			
		}
		custom_tooltip = religious_decision.0201.difficulty.easy
		trigger_event = {
			id = religious_decision.0211
			days = meditation_duration
		}
	}

	# Option 2-A: Meditate in the plains. Low risk, low reward.
	option = {
		trigger = { has_character_flag = meditation_option_plains }
		name = religious_decision.0201.plains
		meditate_at_location_effect = { TERRAIN = plains }
		custom_tooltip = religious_decision.0201.difficulty.easy
		custom_tooltip = religious_decision.0201.stress
	}

	# Option 2-B: Meditate in the hills. Low risk, low reward.
	option = {
		trigger = { has_character_flag = meditation_option_hills }
		name = religious_decision.0201.hills
		meditate_at_location_effect = { TERRAIN = hills }
		custom_tooltip = religious_decision.0201.difficulty.easy
		custom_tooltip = religious_decision.0201.learning
	}

	# Option 2-C: Meditate in the steppe. Low risk, medium reward.
	option = {
		trigger = { has_character_flag = meditation_option_steppe }
		name = religious_decision.0201.steppe
		meditate_at_location_effect = { TERRAIN = steppe }
		custom_tooltip = religious_decision.0201.difficulty.easy
		custom_tooltip = religious_decision.0201.trait
	}

	# Option 2-D: Meditate in the forest. Medium risk, medium reward.
	option = {
		trigger = { has_character_flag = meditation_option_forest }
		name = religious_decision.0201.forest
		meditate_at_location_effect = { TERRAIN = forest }
		custom_tooltip = religious_decision.0201.difficulty.medium
		custom_tooltip = religious_decision.0201.stress
	}

	# Option 2-E: Meditate in the drylands. Medium risk, medium reward.
	option = {
		trigger = { has_character_flag = meditation_option_drylands }
		name = religious_decision.0201.drylands
		meditate_at_location_effect = { TERRAIN = drylands }
		custom_tooltip = religious_decision.0201.difficulty.medium
		custom_tooltip = religious_decision.0201.learning
	}

	# Option 2-F: Meditate in the mountains. High risk, high reward.
	option = {
		trigger = { has_character_flag = meditation_option_mountains }
		name = religious_decision.0201.mountains
		meditate_at_location_effect = { TERRAIN = mountains }
		custom_tooltip = religious_decision.0201.difficulty.hard
		custom_tooltip = religious_decision.0201.stress
		custom_tooltip = religious_decision.0201.trait
	}

	# Option 2-G: Meditate in the desert. High risik, high reward.
	option = {
		trigger = { has_character_flag = meditation_option_desert }
		name = religious_decision.0201.desert
		meditate_at_location_effect = { TERRAIN = desert }
		custom_tooltip = religious_decision.0201.difficulty.hard
		custom_tooltip = religious_decision.0201.learning
	}

	# Option 2-H: Meditate in the swamp. High risk, low reward.
	option = {
		trigger = { has_character_flag = meditation_option_wetlands }
		name = religious_decision.0201.wetlands
		meditate_at_location_effect = { TERRAIN = wetlands }
		custom_tooltip = religious_decision.0201.difficulty.hard
	}

	# Option 2-I: Meditate in the jugnle. High risk, low reward.
	option = {
		trigger = { has_character_flag = meditation_option_jungle }
		name = religious_decision.0201.jungle
		meditate_at_location_effect = { TERRAIN = jungle }
		custom_tooltip = religious_decision.0201.difficulty.hard
	}

	# Option 3: Opt-out
	option = {
		name = religious_decision.0201.optout
		flavor = religious_decision.0201.optout.flavor

		ai_chance = {
			base = 0
		}

		remove_decision_cooldown = meditate_in_seclusion_decision
	}

	after = {
		remove_character_flag = meditation_option_basilica
		remove_character_flag = meditation_option_plains
		remove_character_flag = meditation_option_hills
		remove_character_flag = meditation_option_steppe
		remove_character_flag = meditation_option_forest
		remove_character_flag = meditation_option_drylands
		remove_character_flag = meditation_option_mountains
		remove_character_flag = meditation_option_wetlands
		remove_character_flag = meditation_option_jungle
		remove_character_flag = meditation_option_desert
		remove_character_flag = planning_an_activity
	}
}

scripted_effect improve_meditation_skill = {
	if = {
		limit = {
			has_variable = meditation_experience
		}
		change_variable = {
			name = meditation_experience
			add = 1
		}
	}
	else = {
		set_variable = {
			name = meditation_experience
			value = 1
		}
	}
	custom_tooltip = religious_decision.0211.experience
}

religious_decision.0210 = {
	hidden = yes
	immediate = {
		send_interface_toast = {
			title = religious_decision.0210.toast
			left_icon = root
			current_travel_plan = {
				delay_travel_plan = { days = meditation_duration }
			}
		}
		trigger_event = {
			id = religious_decision.0211
			days = meditation_duration
		}
	}
}

religious_decision.0211 = {
	type = character_event
	title = religious_decision.0211.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:in_basilica = yes }
				desc = religious_decision.0211.desc.beginning.basilica
			}
			triggered_desc = {
				trigger = { scope:at_home = yes }
				desc = religious_decision.0211.desc.beginning.home
			}
			triggered_desc = {
				trigger = {
					var:meditation_location = {
						OR = {
							terrain = mountains
							terrain = desert_mountains
						}
					}
				}
				desc = religious_decision.0211.desc.beginning.mountains
			}
			triggered_desc = {
				trigger = {
					var:meditation_location = {
						OR = {
							terrain = forest
							terrain = taiga
						}
				}
				}
				desc = religious_decision.0211.desc.beginning.forest
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = plains }}
				desc = religious_decision.0211.desc.beginning.plains
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = hills }}
				desc = religious_decision.0211.desc.beginning.hills
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = steppe }}
				desc = religious_decision.0211.desc.beginning.steppe
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = drylands }}
				desc = religious_decision.0211.desc.beginning.drylands
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = wetlands }}
				desc = religious_decision.0211.desc.beginning.wetlands
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = jungle }}
				desc = religious_decision.0211.desc.beginning.jungle
			}
			triggered_desc = {
				trigger = {var:meditation_location = { terrain = desert }}
				desc = religious_decision.0211.desc.beginning.desert
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = meditation_minor_stress_loss }
				desc = religious_decision.0211.desc.result.minor_stress
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_medium_stress_loss }
				desc = religious_decision.0211.desc.result.medium_stress
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_major_stress_loss }
				desc = religious_decision.0211.desc.result.major_stress
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_reflection }
				desc = religious_decision.0211.desc.result.reflection
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_fugue }
				desc = religious_decision.0211.desc.result.fugue
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_epiphany }
				desc = religious_decision.0211.desc.result.epiphany
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_impatient }
				desc = religious_decision.0211.desc.result.impatient
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_secret }
				desc = religious_decision.0211.desc.result.secret
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_hungry }
				desc = religious_decision.0211.desc.result.hungry
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_thirsty }
				desc = religious_decision.0211.desc.result.thirsty
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_headache }
				desc = religious_decision.0211.desc.result.headache
			}
			triggered_desc = {
				trigger = { has_character_flag = meditation_distraction }
				desc = religious_decision.0211.desc.result.distraction
			}
		}
	}
	theme = faith
	override_background = {
		trigger = {
			scope:in_basilica = yes
		}
		reference = temple_church
	}
	override_background = {
		trigger = {
			scope:at_home = yes
			scope:in_basilica = no
		}
		reference = sitting_room
	}
	override_background = {
		trigger = {
			scope:at_home = no
			scope:in_basilica = no
		}
		reference = wilderness_scope
	}
	override_background = {
		trigger = {	has_character_flag = meditation_thirsty }
		reference = bp1_crossroads_inn
	}
	left_portrait = root

	immediate = {
		if = {
			limit = {
				NOT = {
					exists = var:meditation_location
				}
			}
			set_variable = {
				name = meditation_location
				value = root.location
			}
		}
		var:meditation_location = {
			save_scope_as = meditation_location
			save_scope_as = background_wilderness_scope
		}

		# Check if we are meditating in our capital (will be checked frequently when determining outcomes).
		# POD change: Check if we're in the basilica first
		if = {
			limit = {
				scope:meditation_location = {
					has_building_with_flag = san_michele_basilica
				}
			}
			save_scope_value_as = {
				name = in_basilica
				value = yes
			}
			save_scope_value_as = {
				name = at_home
				value = no
			}
		}
		else = {
			save_scope_value_as = {
				name = in_basilica
				value = no
			}
			if = {
				limit = {
					exists = capital_province
					scope:meditation_location = root.capital_province
				}
				save_scope_value_as = {
					name = at_home
					value = yes
				}
			}
			else = {
				save_scope_value_as = {
					name = at_home
					value = no
				}
			}
		}

		# Determine what the outcome of the meditation journey will be.
		random_list = {
			# Positive Outcomes
			50 = {
				# Double positive chance for meditating at home (though the benefits will be small).
				modifier = {
					add = 80
					trigger = {
						OR = {
							scope:at_home = yes
							scope:in_basilica = yes
						}
					}
				}
				# POD
				modifier = {
					add = 80
					trigger = {
						has_perk = pillar_of_osiris_perk
					}
				}

				random_list = {
					# Stress Reduction
					99 = {
						modifier = {
							add = 40
							scope:meditation_location = {
								OR = {
									terrain = mountains
									terrain = desert_mountains
									terrain = forest
									terrain = taiga
								}
							}
						}

						random_list = {
							# Lower stress loss when meditating at home.
							100 = {
								trigger = { scope:at_home = yes }
								add_character_flag = meditation_minor_stress_loss
							}

							# Higher stress loss when meditating in the wilderness
							66 = {
								trigger = { scope:at_home = no }
								add_character_flag = meditation_medium_stress_loss
							}
							33 = {
								trigger = { scope:at_home = no }
								modifier = {
									add = 121
									OR = {
										scope:in_basilica = yes
										scope:meditation_location = {
											OR = {
												terrain = desert_mountains
												terrain = mountains
											}
										}
									}
								}
								add_character_flag = meditation_major_stress_loss
							}
						}
					}
					# Replace Negative Trait
					20 = {
						trigger = {
							scope:at_home = no
							# Must have a negative trait to replace.
							OR = {
								has_trait = greedy
								has_trait = lustful
								has_trait = gluttonous
								has_trait = deceitful
								has_trait = ambitious
								has_trait = impatient
								has_trait = sadistic
								has_trait = wrathful
							}
						}

						# Greater chance when meditating in one of these terrains.
						modifier = {
							add = 5
							scope:meditation_location = {
								terrain = steppe
							}
						}
						modifier = {
							add = 10
							scope:meditation_location = {
								OR = {
									terrain = mountains
									terrain = desert_mountains
								}
							}
						}
						modifier = {
							add = 150 # vanilla ck3 levels in basilica
							scope:in_basilica = yes
						}
						add_character_flag = meditation_reflection
					}
					# Gain Learning
					20 = {
						trigger = {
							scope:at_home = no
						}
						modifier = {
							add = 5
							scope:meditation_location = {
								terrain = hills
							}
						}
						modifier = {
							add = 50 # vanilla ck3 levels in basilica
							scope:in_basilica = yes
						}
						add_character_flag = meditation_epiphany
					}
					# Gain extra Learning
					10 = {
						trigger = {
							scope:at_home = no
							# Only in hot regions.
							scope:meditation_location = {
								OR = {
									terrain = desert
									terrain = drylands
								}
							}
						}
						modifier = {
							add = 2
							scope:meditation_location = {
								terrain = desert
							}
						}
						modifier = {
							add = 100 # vanilla ck3 levels in basilica
							scope:in_basilica = yes
						}
						add_character_flag = meditation_fugue
					}
				}
			}
			# Negative Outcomes
			30 = {
				# Location modifiers.
				modifier = { # Failure increases from 20% to 25%. Still relatively easy.
					add = 7 # Total 27
					scope:at_home = no
					scope:in_basilica = no
				}
				modifier = { # Failure increases from 25% to 40%. Moderate difficulty.
					add = 26 # Total 53
					scope:at_home = no
					scope:in_basilica = no
					scope:meditation_location = {
						OR = {
							terrain = forest
							terrain = taiga
							terrain = drylands
						}
					}
				}
				modifier = { # Failure increases from 25% to 60%. Hard difficulty.
					add = 93 # Total 120
					scope:at_home = no
					scope:in_basilica = no
					scope:meditation_location = {
						OR = {
							terrain = desert
							terrain = desert_mountains
							terrain = mountains
							terrain = wetlands
							terrain = jungle
						}
					}
				}

				# Positive Personality Modifiers.
				modifier = {
					factor = 0.86
					has_trait = patient
				}
				modifier = {
					factor = 0.90
					has_trait = calm
				}
				modifier = {
					factor = 0.92
					has_trait = temperate
				}

				# Negative Personality Modifiers.
				modifier = {
					factor = 1.13
					has_trait = impatient
				}
				modifier = {
					factor = 1.10
					has_trait = gluttonous
				}
				modifier = {
					factor = 1.08
					has_trait = wrathful
				}

				# Reduces failure chance by 10 points per previous successful meditation.
				modifier = {
					add = {
						subtract = var:meditation_experience
						multiply = 10
					}
					has_variable = meditation_experience
				}

				random_list = {
					25 = {
						trigger = { NOT = { has_trait = patient } }
						modifier = {
							add = 50
							var:meditation_location = {
								terrain = wetlands
							}
						}
						modifier = {
							add = 75
							has_trait = impatient
						}
						add_character_flag = meditation_impatient
					}
					25 = {
						trigger = {
							any_secret = { }
						}
						modifier = {
							add = 75
							any_secret = {
								is_criminal_for = root
							}
						}
						add_character_flag = meditation_secret
					}
					75 = {
						trigger = {
							scope:in_basilica = no
							scope:meditation_location = {
								terrain = jungle
							}
						}
						add_character_flag = meditation_distraction
					}
					25 = {
						trigger = {
							scope:in_basilica = no
						}
						modifier = {
							add = -20
							has_trait = temperate
						}
						modifier = {
							add = 75
							has_trait = gluttonous
						}
						add_character_flag = meditation_hungry
					}
					100 = {
						trigger = {
							scope:in_basilica = no
							scope:meditation_location = {
								OR = {
									terrain = desert
									terrain = drylands
								}
							}
						}
						add_character_flag = meditation_thirsty
					}
					100 = {
						trigger = {
							scope:in_basilica = no
							scope:meditation_location = {
								OR = {
									terrain = mountains
									terrain = desert_mountains
								}
							}
						}
						add_character_flag = meditation_headache
					}
				}
			}
		}
	}

	option = {
		name = {
			trigger = {
				OR = {
					has_character_flag = meditation_epiphany
					has_character_flag = meditation_fugue
					has_character_flag = meditation_major_stress_loss
				}
			}
			text = religious_decision.0211.a.critical_success
		}
		name = {
			trigger = {
				OR = {
					has_character_flag = meditation_reflection
					has_character_flag = meditation_medium_stress_loss
					has_character_flag = meditation_minor_stress_loss
				}
			}
			text = religious_decision.0211.a.success
		}
		name = {
			trigger = {
				OR = {
					has_character_flag = meditation_secret
					has_character_flag = meditation_impatient
					has_character_flag = meditation_hungry
					has_character_flag = meditation_thirsty
					has_character_flag = meditation_distraction
					has_character_flag = meditation_headache
				}
			}
			text = religious_decision.0211.a.failure
		}
		if = {
			limit = { has_character_flag = meditation_minor_stress_loss }
			add_stress = minor_stress_loss
			improve_meditation_skill = yes
		}
		else_if = {
			limit = { has_character_flag = meditation_medium_stress_loss }
			add_stress = medium_stress_loss
			improve_meditation_skill = yes
		}
		else_if = {
			limit = { has_character_flag = meditation_major_stress_loss }
			add_stress = major_stress_loss
			improve_meditation_skill = yes
		}
		else_if = {
			limit = { has_character_flag = meditation_reflection }
			random_list = {
				1 = {
					trigger = {	has_trait = gluttonous }
					remove_trait = gluttonous
					add_trait_force_tooltip = temperate
				}
				1 = {
					trigger = {	has_trait = greedy }
					remove_trait = greedy
					add_trait_force_tooltip = generous
				}
				1 = {
					trigger = {	has_trait = ambitious }
					remove_trait = ambitious
					add_trait_force_tooltip = content
				}
				1 = {
					trigger = {	has_trait = lustful }
					remove_trait = lustful
					add_trait_force_tooltip = chaste
				}
				1 = {
					trigger = {	has_trait = deceitful }
					remove_trait = deceitful
					add_trait_force_tooltip = honest
				}
				1 = {
					trigger = {	has_trait = sadistic }
					remove_trait = sadistic
					add_trait_force_tooltip = compassionate
				}
				1 = {
					trigger = {	has_trait = impatient }
					remove_trait = impatient
					add_trait_force_tooltip = patient
				}
				1 = {
					trigger = {	has_trait = wrathful }
					remove_trait = wrathful
					add_trait_force_tooltip = calm
				}
			}
			improve_meditation_skill = yes
		}
		else_if = {
			limit = { has_character_flag = meditation_fugue }
			add_learning_skill = 2
			improve_meditation_skill = yes
		}
		else_if = {
			limit = { has_character_flag = meditation_epiphany }
			add_learning_skill = 1
			improve_meditation_skill = yes
		}
		else_if = {
			limit = { has_character_flag = meditation_impatient }
			add_stress = minor_stress_gain
		}
		else_if = {
			limit = { has_character_flag = meditation_secret }
			add_stress = minor_stress_gain
		}
		else_if = {
			limit = { has_character_flag = meditation_hungry }
			add_stress = minor_stress_gain
		}
		else_if = {
			limit = { has_character_flag = meditation_thirsty }
			add_stress = minor_stress_gain
		}
		else_if = {
			limit = { has_character_flag = meditation_headache }
			add_stress = minor_stress_gain
		}
		else_if = {
			limit = { has_character_flag = meditation_distraction }
			add_stress = minor_stress_gain
		}
	}

	after = {
		# Remove character
		remove_character_flag = meditation_secret
		remove_character_flag = meditation_impatient
		remove_character_flag = meditation_epiphany
		remove_character_flag = meditation_fugue
		remove_character_flag = meditation_reflection
		remove_character_flag = meditation_major_stress_loss
		remove_character_flag = meditation_medium_stress_loss
		remove_character_flag = meditation_minor_stress_loss

		# Run the clean-up event.
		trigger_event = {
			id = religious_decision.0291
			days = 30
		}
	}
}

religious_decision.0291 = {
	hidden = yes
	immediate = {
		send_interface_toast = {
			title = religious_decision.0291.toast
			left_icon = root
			current_travel_plan ?= {
				if = {
					limit = { is_paused = yes }
					resume_travel_plan = yes
				}
			}
		}
		remove_variable = meditation_location
		remove_character_flag = meditation_character_flag
		if = {
			limit = {
				OR = {
					POD_gains_thousandwhispers_dharma_xp = yes
					POD_gains_inwardway_dharma_xp = yes
					POD_gains_livingearth_dharma_xp = yes
				}
			}
			POD_give_dharma_xp_effect = { VALUE = POD_kueijin_dharma_xp_value_huge }
		}
	}
}

#########################
# Sky Burials 			#
# by Sean Hughes		#
# 0301-0302				#
#########################

religious_decision.0301 = {
	hidden = yes

	# Faiths with Sky Burial need to have this character saved as a variable on their successor.
	trigger = {
		exists = player_heir
		faith = {
			has_doctrine_parameter = sky_burials_active
		}
	}

	immediate = {
		player_heir = {
			if = {
				limit = {
					faith = root.faith
					OR = {
						is_child_of = root
						is_grandchild_of = root
						is_great_grandchild_of = root
					}
				}
				set_variable = {
					name = ancestor_to_bury
					value = root
					years = 5
				}
			}
		}
	}
}

religious_decision.0302 = {
	type = character_event
	title = religious_decision.0302.t
	desc = {
		triggered_desc = {
			trigger = {
				NOR = {
					religion = religion:zoroastrianism_religion
					religion = religion:zunism_religion
				}
			}
			desc = religious_decision.0302.desc.wilderness
		}
		triggered_desc = {
			trigger = {
				OR = {
					religion = religion:zoroastrianism_religion
					religion = religion:zunism_religion
				}
			}
			desc = religious_decision.0302.desc.zoroastrian
		}
	}
	theme = faith
	override_background = {
		trigger = {
			NOR = {
				religion = religion:zoroastrianism_religion
				religion = religion:zunism_religion
			}
		}
		reference = wilderness
	}
	override_background = {
		trigger = {
			OR = {
				religion = religion:zoroastrianism_religion
				religion = religion:zunism_religion
			}
		}
		reference = temple
	}

	left_portrait = {
		character = var:ancestor_to_bury
	}

	immediate = {
		add_piety = major_piety_value
		if = {
			limit = {
				any_vassal = {
					faith = {
						has_doctrine_parameter = sky_burials_active
					}
				}
			}
			every_vassal = {
				limit = {
					faith = {
						has_doctrine_parameter = sky_burials_active
					}
				}
				custom = give_sky_burial_vassals
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 20
				}
			}
		}
	}

	option = {
		name = religious_decision.0302.a
	}

	after = {
		remove_variable = ancestor_to_bury
	}
}

#################################
# Raise Runestone Maintenance	#
# by Linnéa Thimrén				#
# 0311							#
#################################

religious_decision.0311 = {
	hidden = yes

	# Faiths that can raise a runestone need to have this character saved as a variable on their successor.
	trigger = {
		player_heir ?= {
			is_close_family_of = root
			is_alive = yes
		}
		dynasty = player_heir.dynasty
		# Has access to a valid method of raising runestones.
		fp1_can_raise_stele_trigger = yes
	}

	immediate = {
		player_heir = {
			set_variable = {
				name = ancestor_to_bury
				value = root
				years = 5
			}
		}
	}
}

#New holder of the county with a runestone
religious_decision.0312 = {
	hidden = yes
	orphan = yes

	trigger = {
		scope:title = {
			exists = var:ancestor_to_bury
		}
		dynasty != scope:previous_holder.dynasty #We only have to change something if the new holder is of a different dynasty
		# Use expanded version if we have FP1.
		has_fp1_dlc_trigger = no
	}

	immediate = {
		if = {
			limit = {
				scope:title = {
					NOT = { var:ancestor_to_bury.dynasty = root.dynasty }
				}
			}
			scope:title = {
				remove_county_modifier = county_raised_runestone_modifier
				remove_variable = ancestor_to_bury
			}
		}
	}
}


#########################
# Divine the Stars		#
# by Sean Hughes		#
# 0401					#
#########################

religious_decision.0401 = {
	type = character_event
	title = religious_decision.0401.t
	desc = {
		desc = religious_decision.0401.desc.beginning
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:divination_outcome = flag:great_battle
				}
				desc = religious_decision.0401.desc.great_battle
			}
			triggered_desc = {
				trigger = {
					scope:divination_outcome = flag:new_friends
				}
				desc = religious_decision.0401.desc.new_friends
			}
			triggered_desc = {
				trigger = {
					scope:divination_outcome = flag:hard_work
				}
				desc = religious_decision.0401.desc.hard_work
			}
			triggered_desc = {
				trigger = {
					scope:divination_outcome = flag:betrayal
				}
				desc = religious_decision.0401.desc.betrayal
			}
			triggered_desc = {
				trigger = {
					scope:divination_outcome = flag:new_beginnings
				}
				desc = religious_decision.0401.desc.new_beginnings
			}
		}
	}
	theme = faith
	override_background = {
		trigger = { is_landless_adventurer = no }
		reference = corridor_night
	}
	override_background = {
		trigger = { has_government = landless_adventurer_government }
		reference = bp1_bonfire
	}
	left_portrait = root

	immediate = {
		random_list = {
			20 = {
				save_scope_value_as = {
					name = divination_outcome
					value = flag:great_battle
				}
			}
			20 = {
				save_scope_value_as = {
					name = divination_outcome
					value = flag:new_friends
				}
			}
			20 = {
				save_scope_value_as = {
					name = divination_outcome
					value = flag:hard_work
				}
			}
			20 = {
				save_scope_value_as = {
					name = divination_outcome
					value = flag:betrayal
				}
			}
			20 = {
				save_scope_value_as = {
					name = divination_outcome
					value = flag:new_beginnings
				}
			}
		}
	}

	option = {
		name = religious_decision.0401.a

		if = {
			limit = {
				scope:divination_outcome = flag:great_battle
			}
			add_character_modifier = {
				modifier = astrology_great_battle
				years = 10
			}
		}
		else_if = {
			limit = {
				scope:divination_outcome = flag:new_friends
			}
			add_character_modifier = {
				modifier = astrology_new_friends
				years = 10
			}
		}
		else_if = {
			limit = {
				scope:divination_outcome = flag:hard_work
			}
			add_character_modifier = {
				modifier = astrology_hard_work
				years = 10
			}
		}
		else_if = {
			limit = {
				scope:divination_outcome = flag:betrayal
			}
			add_character_modifier = {
				modifier = astrology_betrayal
				years = 10
			}
		}
		else_if = {
			limit = {
				scope:divination_outcome = flag:new_beginnings
			}
			add_character_modifier = {
				modifier = astrology_new_beginnings
				years = 10
			}
		}

		# Remove the blocking flag.
		remove_character_flag = divining_the_stars
	}
}


#########################
# Reforming Kabarism	#
# by James Beaumont		#
# 0501-0502				#
#########################

religious_decision.0501 = {
	type = character_event
	title = religious_decision.0501.t
	desc = {
		desc = religious_decision.0501.desc
	}
	theme = faith
	override_background = {
		reference = temple_generic
	}
	left_portrait = root
	right_portrait = root.faith.religious_head
	
	immediate = {
		save_scope_as = khazar_khan
	}

	option = {
		name = religious_decision.0501.a
		trigger = {
			OR = {
				NOT = { exists = scope:bwow_chosen_people }
				scope:bwow_chosen_people = no
			}
			OR = {
				NOT = { exists = scope:bwow_esotericism }
				scope:bwow_esotericism = no
			}
			OR = {
				NOT = { exists = scope:bwow_fundementalist }
				scope:bwow_fundementalist = no
			}
		}
		root.faith = { remove_doctrine = unreformed_faith_doctrine }
		custom_description_no_bullet = {
			text = can_never_reform_kuzarism_tt
			subject = root
		}
		root.faith.religious_head = {
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -40
			}
		}
		every_vassal = {
			custom = religious_decision.0501.jewish.tt
			limit = {
				has_religion = religion:judaism_religion
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		every_vassal = {
			custom = religious_decision.0501.nonjewish.tt
			limit = {
				NOT = { has_religion = religion:judaism_religion }
			}
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}
		stress_impact = {
			zealous = major_stress_impact_gain
			cynical = minor_stress_impact_loss
		}
	}

	option = {
		name = religious_decision.0501.d
		trigger = {
			scope:bwow_chosen_people ?= yes
		}
		root.faith = { break_with_old_ways_become_chosen_people = yes }
		every_vassal = {
			custom = religious_decision.0501.diff_culture.tt
			limit = {
				culture != root.culture
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		hidden_effect = {
			every_ruler = {
				limit = {
					this != root
					OR = {
						is_vassal_of = root
						has_faith = faith:kabarism
					}
				}
				trigger_event = religious_decision.0502
			}
		}
		ai_chance = {
			base = 100
		}
		stress_impact = {
			zealous = minor_stress_impact_loss
		}
	}

	option = {
		name = religious_decision.0501.b
		trigger = {
			scope:bwow_esotericism ?= yes
		}
		root.faith = { break_with_old_ways_become_righteous = yes }
		every_vassal = {
			custom = religious_decision.0501.nonjewish.tt
			limit = {
				NOT = { has_religion = religion:judaism_religion }
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		hidden_effect = {
			every_ruler = {
				limit = {
					this != root
					OR = {
						is_vassal_of = root
						has_faith = faith:kabarism
					}
				}
				trigger_event = religious_decision.0502
			}
		}
		ai_chance = {
			base = 100
		}
		stress_impact = {
			zealous = minor_stress_impact_loss
		}
	}

	option = {
		name = religious_decision.0501.c
		trigger = {
			scope:bwow_fundementalist ?= yes
		}
		root.faith = { break_with_old_ways_become_fundamentalist = yes }
		every_vassal = {
			custom = religious_decision.0501.nonjewish.tt
			limit = {
				NOT = { has_religion = religion:judaism_religion }
			}
			add_opinion = {
				target = root
				modifier = scared_opinion
				opinion = -25
			}
		}
		every_vassal = {
			limit = {
				has_religion = religion:judaism_religion
			}
			custom = religious_decision.0501.jewish.tt
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 20
			}
		}
		hidden_effect = {
			every_ruler = {
				limit = {
					this != root
					OR = {
						is_vassal_of = root
						has_faith = faith:kabarism
					}
				}
				trigger_event = religious_decision.0502
			}
		}
		stress_impact = {
			zealous = major_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
	}
}

#Event notifying vassals and Kabarites of the changes
religious_decision.0502 = {
	type = character_event
	title = religious_decision.0502.t
	desc = {
		desc = religious_decision.0502.desc.intro
		desc = religious_decision.0502.desc.body
		triggered_desc = {
			trigger = {
				scope:khazar_khan.faith = {
					NOT = {
						has_doctrine = doctrine_pluralism_fundamentalist
					}
				}
			}
			desc = religious_decision.0502.desc.righteous
		}
		triggered_desc = {
			trigger = {
				scope:khazar_khan.faith = {
					has_doctrine = doctrine_pluralism_fundamentalist
				}
			}
			desc = religious_decision.0502.desc.fundamentalist
		}
	}
	theme = faith
	override_background = {
		reference = temple_generic
	}
	left_portrait = scope:khazar_khan
	right_portrait = root

	option = {
		name = religious_decision.0502.a
		trigger = {
			NOT = { has_faith = faith:kabarism }
			scope:khazar_khan.faith = {
				NOT = {
					has_doctrine = doctrine_pluralism_fundamentalist
				}
			}
		}
		ai_chance = {
			base = 10
		}
		show_as_tooltip = {
			scope:khazar_khan.faith = {
				break_with_old_ways_become_righteous = yes
			}
		}
	}

	option = {
		name = religious_decision.0502.a
		trigger = {
			NOT = { has_faith = faith:kabarism }
			scope:khazar_khan.faith = { has_doctrine = doctrine_pluralism_fundamentalist }
		}
		show_as_tooltip = {
			scope:khazar_khan.faith = {
				break_with_old_ways_become_fundamentalist = yes
			}
		}
	}

	option = {
		name = religious_decision.0502.b
		trigger = {
			has_faith = faith:kabarism
			scope:khazar_khan.faith = {
				NOT = {
					has_doctrine = doctrine_pluralism_fundamentalist
				}
			}
		}
		ai_chance = {
			base = 10
		}
		show_as_tooltip = {
			scope:khazar_khan.faith = {
				break_with_old_ways_become_righteous = yes
			}
		}
	}

	option = {
		name = religious_decision.0502.b
		trigger = {
			has_faith = faith:kabarism
			scope:khazar_khan.faith = { has_doctrine = doctrine_pluralism_fundamentalist }
		}
		show_as_tooltip = {
			scope:khazar_khan.faith = {
				break_with_old_ways_become_fundamentalist = yes
			}
		}
	}
}

#########################
# Adopt Hebrew Language	#
# by James Beaumont		#
# 0503					#
#########################

#Event notifying vassals and Kabarites of the changes
religious_decision.0503 = {
	type = character_event
	title = religious_decision.0503.t
	desc = religious_decision.0503.desc
	theme = faith
	override_background = {
		reference = temple_generic
	}
	left_portrait = scope:hebrew_language_adopter_scope

	option = { # Ah heck yeah
		name = {
			trigger = { root.faith.religion = religion:judaism_religion }
			text = religious_decision.0503.a.jewish
		}
		name = religious_decision.0503.a.non_jewish
		custom_tooltip = switch_to_israelite_language_tt
	}

	option = { # Ah heck no
		trigger = {
			NOT = { root.faith.religion = religion:judaism_religion }
			this != scope:hebrew_language_adopter_scope
			exists = scope:target_other_culture
		}
		name = religious_decision.0503.b
		create_divergent_culture = yes
		custom_tooltip = {
			text = switch_to_original_language_tt
			root.culture = {
				set_language_from = scope:target_other_culture
			}
		}
	}
}

#############################
# Schisming the Caliphate	#
# by Ewan Cowhig Croft		#
# 0601 - 0610				#
#############################

scripted_effect religious_decision_0601_count_converts_effect = {
	if = {
		limit = { exists = var:schismed_caliphate_major_ruler_converted_count }
		custom_tooltip = religious_decision.0601.tt.some_rulers_converted_away
	}
	else = { custom_tooltip = religious_decision.0601.tt.all_rulers_stayed }
}

#	Scope:founder's POV - you're the new caliph!
religious_decision.0601 = {
	orphan = yes
	type = character_event
	title = religious_decision.0601.t
	desc = religious_decision.0601.desc
	theme = faith
	left_portrait = {
		character = scope:founder
		animation = personality_bold
	}
	right_portrait = {
		character = scope:old_caliph
		animation = fear
	}

	immediate = {
		play_music_cue = "mx_cue_faith_conversion"
		# Execute the actual effects.
		appoint_a_righteous_caliph_scripted_effect = yes
	}

	# This is a heavy burden I now bear...
	option = {
		name = religious_decision.0601.a

		# Inform scope:founder how many, if any, folks rejected their coup.
		religious_decision_0601_count_converts_effect = yes

		# No stress impact, choice is narrative.
		ai_chance = {
			# AI chance is irrelevant, as the options are cosmetic.
			base = 100
		}
	}

	# Hah, take *that* scope:old_caliph!
	option = {
		name = religious_decision.0601.b

		# Inform scope:founder how many, if any, folks rejected their coup.
		religious_decision_0601_count_converts_effect = yes

		# No stress impact, choice is narrative.
		ai_chance = {
			# AI chance is irrelevant, as the options are cosmetic.
			base = 100
		}
	}

	after = {
		# Clean up the variable count, if required.
		if = {
			limit = { exists = var:schismed_caliphate_major_ruler_converted_count }
			remove_variable = schismed_caliphate_major_ruler_converted_count
		}
	}
}

#	Co-faithist POV - uhhh, there's a new HoF in town?
religious_decision.0602 = {
	orphan = yes
	type = character_event
	title = religious_decision.0602.t
	desc = religious_decision.0602.desc
	theme = faith
	left_portrait = {
		character = scope:founder
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:old_caliph
		animation = rage
	}

	immediate = {
		play_music_cue = "mx_cue_faith_conversion"
		# Plus grab the current faith for loc.
		faith = { save_scope_as = current_faith }
		# Show the effects of the schism.
		show_as_tooltip = {
			scope:founder = { appoint_a_righteous_caliph_scripted_effect = yes }
		}
	}

	# Scope:founder shall lead us to PositiveAfterLife!
	option = {
		name = religious_decision.0602.a

		custom_tooltip = religious_decision.0602.a.tt

		# No stress impact, as zealous and cynical could come down on either side here.
		ai_chance = {
			base = 0
			opinion_modifier = {
				opinion_target = scope:founder
				multiplier = 5
			}
			# Distant caliphs are less respected.
			modifier = {
				add = 100
				NOT = { in_diplomatic_range = scope:old_caliph }
			}
		}
	}

	# Never: my loyalty to scope:old_caliph outweighs my loyalty to scope:current_faith!
	option = {
		name = religious_decision.0602.b
		# We're not fussed about much, but very young kids don't really get a choice in this.
		trigger = { age >= 8 }

		# Convert to scope:old_caliph's faith.
		set_character_faith_with_conversion = scope:old_caliph.faith
		# Make a note that a major character chose to convert rather than toe the line.
		scope:founder = {
			if = {
				limit = {
					NOT = { exists = var:schismed_caliphate_major_ruler_converted_count }
				}
				set_variable = {
					name = schismed_caliphate_major_ruler_converted_count
					value = 1
				}
			}
			else = {
				change_variable = {
					name = schismed_caliphate_major_ruler_converted_count
					add = 1
				}
			}
		}

		# No stress impact, as zealous and cynical could come down on either side here.
		ai_chance = {
			base = 0
			opinion_modifier = {
				opinion_target = scope:old_caliph
				multiplier = 5
			}
			# Caliphs within writing distance are more respected.
			modifier = {
				add = 100
				in_diplomatic_range = scope:old_caliph
			}
			# Heirs to scope:founder won't voluntarily disinherit themselves unless they're zealous.
			modifier = {
				factor = 0
				NOT = { has_trait = zealous }
				any_heir_title = { holder = scope:founder }
			}
		}
	}

	# People seem desperate for a true leader...
	option = {
		name = religious_decision.0602.c
		trigger = { is_ai = no }

		# It becomes cheaper to make your own faith for a while.
		add_character_modifier = {
			modifier = fp2_opportunistic_schismatic_modifier
			years = 25
		}

		# No stress impact, as zealous and cynical could come down on either side here.
		ai_chance = {
			# AI chance irrelevant, since the AI doesn't use the relevant feature.
			base = 100
		}
	}
}

#	Other POV - bit dramatic, mate.
religious_decision.0603 = {
	orphan = yes
	type = character_event
	title = religious_decision.0603.t
	desc = religious_decision.0603.desc
	theme = faith
	left_portrait = {
		character = scope:founder
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:old_caliph
		animation = rage
	}

	immediate = {
		play_music_cue = "mx_cue_faith_conversion"
		# Show the effects of the schism.
		show_as_tooltip = {
			scope:founder = { appoint_a_righteous_caliph_scripted_effect = yes }
		}
	}

	# Scope:old_caliph's POV - Fiend! Cur! Blasphemer!
	option = {
		name = religious_decision.0603.a
		trigger = { this = scope:old_caliph }

		# No stress impact, choice is narrative.
		ai_chance = {
			# AI chance is irrelevant, since the choice is narrative.
			base = 100
		}
	}

	# Other co-religionist's POV - Scope:old_caliph cannot keep HerHis house in order...
	option = {
		name = religious_decision.0603.b
		trigger = {
			this != scope:old_caliph
			religion = religion:islam_religion
		}

		# No stress impact, choice is narrative.
		ai_chance = {
			# AI chance is irrelevant, since the choice is narrative.
			base = 100
		}
	}

	# Neighbouring Ruler POV: Ha! What high drama!
	option = {
		name = religious_decision.0603.c
		trigger = {
			NOT = { religion = religion:islam_religion }
		}

		# No stress impact, choice is narrative.
		ai_chance = {
			# AI chance is irrelevant, since the choice is narrative.
			base = 100
		}
	}
}
