namespace = religious_interaction

religious_interaction.1 = { # Faith head divorce event (divorce_character_rel_head interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = {
		desc = religious_interaction.1.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:secondary_recipient = { exposed_cheating_on_spouse_trigger = { SPOUSE = scope:actor } }
						scope:secondary_recipient = {
							any_relation = {
								type = lover
								NOR = {
									this = scope:actor
									this = scope:recipient
								}
								NOT = { has_secret_relation_lover = scope:secondary_recipient }
								relation_with_character_is_incestuous_in_my_faith_trigger = { CHARACTER = scope:secondary_recipient	}
							}
						}
					}
				}
				desc = religious_interaction.1.adultery
			}
			triggered_desc = {
				trigger = {
					scope:actor = {
						OR = {
							is_close_or_extended_family_of = scope:secondary_recipient
							is_cousin_of = scope:secondary_recipient
							dynasty = scope:secondary_recipient.dynasty
						}
					}
				}
				desc = religious_interaction.1.consanguinity
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = { is_eunuch_trigger = yes }
				}
				desc = religious_interaction.1.eunuch
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient.faith != scope:actor.faith
				}
				desc = religious_interaction.1.different_faith
			}
			desc = religious_interaction.1.fallback
		}
	}
	sender = scope:recipient

	option = {
		name = religious_interaction.1.a
		scope:actor = {
			divorce_effect = {
				DIVORCER = scope:actor
				DIVORCEE = scope:secondary_recipient
			}
		}
		
		hidden_effect = { # Notify the one being divorced
			scope:secondary_recipient = {
				send_interface_toast = {
					title = X_DIVORCED_ME
					left_icon = scope:recipient
					right_icon = scope:actor
					#custom_tooltip = X_DIVORCED_ME_DESC
				}
			}
		}
	}
}

religious_interaction.2 = { # House Head divorce event (divorce_character_house_head interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = {
		desc = religious_interaction.2.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = { exposed_cheating_on_spouse_trigger = { SPOUSE = scope:actor } }
				}
				desc = religious_interaction.2.adultery
			}
			triggered_desc = {
				trigger = {
					scope:actor = {
						fertility > 0.1
					}
					scope:secondary_recipient = {
						fertility < 0.1
						is_eunuch_trigger = no
						NOR = {
							any_child = {
								is_child_of = scope:actor
							}
						}
					}
				}
				desc = religious_interaction.2.infertility
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = { is_eunuch_trigger = yes }
				}
				desc = religious_interaction.1.eunuch
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient.faith != scope:actor.faith
				}
				desc = religious_interaction.1.different_faith
			}
			desc = religious_interaction.1.fallback
		}
	}
	sender = scope:recipient

	immediate = {
		show_as_tooltip = {
			if = {
				limit = { always = scope:divorce_hook }
				scope:actor = {
					use_hook = scope:recipient
				}
			}
			scope:actor = {
				add_piety = { subtract = divorce_cost }
			}
		}
		scope:actor = {
			divorce_effect = {
				DIVORCER = scope:actor
				DIVORCEE = scope:secondary_recipient
			}
		}
		
		hidden_effect = { # Notify the one being divorced
			scope:secondary_recipient = {
				send_interface_toast = {
					title = X_DIVORCED_ME
					left_icon = scope:recipient
					right_icon = scope:actor
					#custom_tooltip = X_DIVORCED_ME_DESC
				}
			}
		}
	}

	option = {
		name = religious_interaction.1.a
	}
}

religious_interaction.3 = { # Ask for Gold accepted letter event (hof_ask_for_gold interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = {
		desc = religious_interaction.3.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:actor = {
						is_at_war = yes
						any_character_war = {
							is_defender = scope:actor
							using_holy_war_cb_trigger = yes
						}
					}
				}
				desc = religious_interaction.3.defensive_war
			}
			triggered_desc = {
				trigger = {
					scope:actor = {
						is_at_war = yes
						any_character_war = {
							is_attacker = scope:actor
							OR = {
								using_holy_war_cb_trigger = yes
								using_cb = excommunication_war
							}
						}
					}
				}
				desc = religious_interaction.2.offensive_war
			}
			desc = religious_interaction.3.fallback
		}
	}
	sender = scope:recipient

	immediate = {
		scope:actor = {
			if = {
				limit = {
					scope:actor = {
						is_at_war = yes
						any_character_war = {
							is_defender = scope:actor
							using_holy_war_cb_trigger = yes
						}
					}
				}
				random_character_war = {
					limit = {
						is_defender = scope:actor
						using_holy_war_cb_trigger = yes
					}
					primary_attacker = {
						save_scope_as = war_target
					}
				}
			}
			else_if = {
				limit = {
					scope:actor = {
						is_at_war = yes
						any_character_war = {
							is_attacker = scope:actor
							OR = {
								using_holy_war_cb_trigger = yes
								using_cb = excommunication_war
							}
						}
					}
				}
				random_character_war = {
					limit = {
						is_attacker = scope:actor
						OR = {
							using_holy_war_cb_trigger = yes
							using_cb = excommunication_war
						}
					}
					primary_defender = {
						save_scope_as = war_target
					}
				}
			}
		}
		show_as_tooltip = { hof_ask_for_gold_interaction_effect = yes }
	}

	option = {
		name = {
			trigger = {
				scope:actor = {
					NOT = { has_trait = generous }
				}
			}
			text = religious_interaction.3.a
		}
		name = {
			trigger = {
				scope:actor = {
					is_at_war = yes
				}
			}
			text = religious_interaction.3.b
		}
		name = religious_interaction.3.c
		name = {
			trigger = {
				scope:actor = {
					has_trait = greedy
				}
			}
			text = religious_interaction.3.d
		}
	}
}

religious_interaction.32 = { # Ask for Gold rejection letter event (hof_ask_for_gold interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.32.desc
	sender = scope:recipient

	option = {
		name = religious_interaction.32.a
	}
}

religious_interaction.4 = { # Ask for Claim accepted letter event (hof_ask_for_claim interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = {
		desc = religious_interaction.4.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = {
						is_adult = no
					}
					scope:actor = {
						is_adult = yes
					}
				}
				desc = religious_interaction.4.child
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = {
						is_adult = yes
						is_female = yes
					}
					scope:actor = {
						is_adult = yes
						is_female = no
						faith = {
							has_doctrine = doctrine_gender_male_dominated
						}
					}
				}
				desc = religious_interaction.4.they_are_female
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = {
						is_adult = yes
						is_female = no
					}
					scope:actor = {
						is_adult = yes
						is_female = yes
						faith = {
							has_doctrine = doctrine_gender_female_dominated
						}
					}
				}
				desc = religious_interaction.4.they_are_male
			}
			desc = religious_interaction.4.fallback
		}
	}
	sender = scope:recipient

	immediate = {
		show_as_tooltip = { hof_ask_for_claim_interaction_effect = yes }
	}

	option = {
		name = religious_interaction.4.a
	}
}

religious_interaction.42 = { # Ask for Claim rejection letter event (hof_ask_for_claim interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.42.desc
	sender = scope:recipient

	option = {
		name = religious_interaction.42.a
	}
}

religious_interaction.5 = {
	type = letter_event
	opening = religious_interaction.1.opening
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = {
						is_adult = no
					}
					scope:actor = {
						is_adult = yes
					}
				}
				desc = religious_interaction.5.child
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = {
						is_adult = yes
						is_female = yes
					}
					scope:actor = {
						is_adult = yes
						is_female = no
						faith = {
							has_doctrine = doctrine_gender_male_dominated
						}
					}
				}
				desc = religious_interaction.5.they_are_female
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = {
						is_adult = yes
						is_female = no
					}
					scope:actor = {
						is_adult = yes
						is_female = yes
						faith = {
							has_doctrine = doctrine_gender_female_dominated
						}
					}
				}
				desc = religious_interaction.5.they_are_male
			}
			desc = religious_interaction.5.fallback
		}
		desc = religious_interaction.5.outro
	}
	sender = {
		character = scope:recipient
		animation = personality_vengeful
	}

	option = {
		name = religious_interaction.5.a
		show_as_tooltip = {
			scope:actor = { add_pressed_claim = scope:target }
		}
	}
}


religious_interaction.6 = { # Faith head divorce event via Dynast (divorce_character_rel_head interaction)
	type = letter_event
	opening = {
		desc = religious_interaction.6.opening
	}
	desc = {
		desc = religious_interaction.6.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:secondary_recipient = { exposed_cheating_on_spouse_trigger = { SPOUSE = scope:secondary_actor } }
						scope:secondary_recipient = {
							any_relation = {
								type = lover
								NOR = {
									this = scope:secondary_actor
									this = scope:recipient
								}
								NOT = { has_secret_relation_lover = scope:secondary_recipient }
								relation_with_character_is_incestuous_in_my_faith_trigger = { CHARACTER = scope:secondary_recipient	}
							}
						}
					}
				}
				desc = religious_interaction.6.adultery
			}
			triggered_desc = {
				trigger = {
					scope:secondary_actor = {
						OR = {
							is_close_or_extended_family_of = scope:secondary_recipient
							is_cousin_of = scope:secondary_recipient
							dynasty = scope:secondary_recipient.dynasty
						}
					}
				}
				desc = religious_interaction.6.consanguinity
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient = { is_eunuch_trigger = yes }
				}
				desc = religious_interaction.6.eunuch
			}
			triggered_desc = {
				trigger = {
					scope:secondary_recipient.faith != scope:secondary_actor.faith
				}
				desc = religious_interaction.6.different_faith
			}
			desc = religious_interaction.6.fallback
		}
	}
	sender = scope:recipient

	option = {
		name = religious_interaction.6.a
		scope:secondary_actor = {
			divorce_effect = {
				DIVORCER = scope:secondary_actor
				DIVORCEE = scope:secondary_recipient
			}
		}
		
		hidden_effect = { # Notify the one being divorced
			scope:secondary_recipient = {
				send_interface_toast = {
					title = X_DIVORCED_ME
					left_icon = scope:recipient
					right_icon = scope:secondary_actor
					#custom_tooltip = X_DIVORCED_ME_DESC
				}
			}
		}
	}
}

#########################
# Temporal Condemnation #
# by Petter Vilberg		#
# 1001					#
#########################

#Religious Legal Pronouncements
religious_interaction.1001 = {
	type = character_event
	orphan = yes
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = {
						religion_tag = islam_religion
					}
				}
				desc = religious_interaction.1001.t.fatwa
			}
			triggered_desc = {
				trigger = { }
				desc = religious_interaction.1001.t
			}
		}
	}
	desc = religious_interaction.1001.desc
	theme = faith
	left_portrait = {
		character = scope:actor
		animation = dismissal
	}

	immediate = {
		reverse_add_opinion = {
			target = scope:actor
			modifier = temporal_condemnation_opinion
			years = 10
		}
		add_character_modifier = {
			modifier = temporal_condemnation_modifier
			years = 15
		}
	}

	option = {
		name = religious_interaction.1001.a
		add_opinion = {
			target = scope:actor
			modifier = temporal_condemnation_condemned_me_opinion
		}
		custom_tooltip = religious_interaction.1001.a.revoke_tt
	}
}

#####################
# Seek Indulgences 	#
# by Sean Hughes	#
# 1010-1011			#
#####################

#Seek Indulgences Accepted
religious_interaction.1010 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1010
	sender = {
		character = scope:recipient
		animation = happiness
	}

	immediate = {
		show_as_tooltip = {
			seek_indulgences_interaction_effect = yes
		}
	}

	option = {
		name = religious_interaction.1000.positive
	}
}

#Seek Indulgences Rejected
religious_interaction.1011 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1011
	sender = scope:recipient

	option = {
		name = religious_interaction.1000.negative
	}
}

#####################
# Excommunucation 	#
# by Sean Hughes	#
# 1020-1025			#
#####################

#Excommunicated (Requested by another Ruler)
religious_interaction.1020 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = {
		desc = religious_interaction.1020
		desc = religious_interaction.1021
	}
	sender = {
		character = scope:recipient
		animation = schadenfreude
	}

	immediate = { add_excommunication_tooltip_only_effect = yes }

	option = {
		name = religious_interaction.1000.strong_negative
	}
}

#Excommunicated (Pope's own initiative)
religious_interaction.1021 = {
	type = letter_event
	orphan = yes
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1021
	sender = {
		character = scope:recipient
		animation = anger
	}

	immediate = { add_excommunication_tooltip_only_effect = yes }

	option = {
		name = religious_interaction.1000.strong_negative
	}
}

#Excommunication Requester informed the Pope accepted their request.
religious_interaction.1022 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1022
	sender = scope:recipient
	
	immediate = {
		scope:secondary_recipient = { add_excommunication_tooltip_only_effect = yes }
	}
	option = {
		name = religious_interaction.1000.positive
	}
}


#Excommuniation Requester informed the Pope denied their request.
religious_interaction.1023 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1023
	sender = {
		character = scope:recipient
		animation = dismissal
	}

	option = {
		name = religious_interaction.1000.negative
	}
}

#Pope lifts Excommunication.
religious_interaction.1024 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1024
	sender = {
		character = scope:recipient
		animation = personality_zealous
	}
	
	immediate = {
		show_as_tooltip = {
			declaration_of_repentance_interaction_effect = yes
		}
	}

	option = {
		name = religious_interaction.1024.positive
	}
}

#Pope refuses to lift Excommunication.
religious_interaction.1025 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1025
	sender = {
		character = scope:recipient
		animation = dismissal
	}

	option = {
		name = religious_interaction.1000.strong_negative
	}
}

#####################
# Take The Vows 	#
# by Sean Hughes	#
# 1030-1031			#
#####################

#Take Vows Rejected
religious_interaction.1031 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.1031
	sender = {
		character = scope:recipient
		animation = dismissal
	}

	immediate = {
		show_as_tooltip = {
			scope:recipient = {
				add_opinion = {
					target = scope:actor
					modifier = asked_me_to_take_vows_opinion
					years = 5
				}
			}
		}
	}

	option = {
		name = religious_interaction.1000.strong_negative
	}
}



#####################
# Demand Conversion	#
# 					#
# 					#
#####################

#Accepts conversion
religious_interaction.2002 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.2002.desc
	sender = scope:recipient

	immediate = {
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			show_as_tooltip = { demand_conversion_interaction_effect = yes }
		}
		else = {
			show_as_tooltip = { demand_conversion_vassal_ruler_interaction_effect = yes }
		}
	}
	
	option = {
		name = religious_interaction.2002.a
		if = {
			limit = {
				has_government = landless_adventurer_government
				scope:recipient.highest_held_title_tier >= tier_barony
			}
			faith = {
				change_fervor = {
					value = {
						add = 1
						multiply = scope:recipient.highest_held_title_tier
					}
					desc = imperial_capital_sacked_fervor_gain
				}
			}
			add_prestige = {
				value = 200
				multiply = scope:recipient.highest_held_title_tier
				if = {
					limit = {
						scope:recipient.highest_held_title_tier >= tier_kingdom
					}
					multiply = 2
				}
			}
		}
	}
}


#Refuses conversion
religious_interaction.2003 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = {
		desc = religious_interaction.2003.desc
		triggered_desc = {
			trigger = { exists = scope:hooking_out_of_conversion }
			desc = religious_interaction.2003.hooking_out
		}
	}
	sender = {
		character = scope:recipient
		animation = dismissal
	}

	immediate = {
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			scope:recipient = {
				#Negative opinions
				add_opinion = {
					modifier = unwanted_religious_conversion_opinion
					target = scope:actor
				}
				if = {
					limit = {
						top_liege != this
						liege ?= {
							faith != scope:actor.faith
						}
					}
					liege = {
						add_opinion = {
							modifier = religious_rebel_opinion
							target = scope:actor
						}
					}
				}
			}
		}
		else = {
			hidden_effect = {
				if = {
					limit = {
						exists = scope:recipient.capital_county
						scope:recipient.capital_county.faith = scope:recipient.faith
					}
					save_scope_value_as = {
						name = convert_capital
						value = yes
					}
				}
			}
			scope:recipient = {
				add_opinion = {
					modifier = demanded_my_conversion_opinion
					target = root
					opinion = -10
				}
			}
			if = {
				limit = {
					refusing_conversion_is_crime_trigger = {
						CHARACTER = scope:recipient
					}
					scope:recipient = {
						has_strong_usable_hook = root
					}
				}
				save_scope_value_as = {
					name = hooking_out_of_conversion
					value = yes
				}
			}
		}
		# If appropriate, give 'em piety.
		scope:recipient = { give_piety_for_clinging_to_state_faith_effect = yes }
	}
	
	#It's not illegal
	option = {
		name = religious_interaction.2003.a
		trigger = {
			NOT = { exists = scope:hooking_out_of_conversion }
			NOT = {
				refusing_conversion_is_crime_trigger = {
					CHARACTER = scope:recipient
				}
			}
		}
		if = {
			limit = {
				is_landless_adventurer = no
			}
			hidden_effect = {
				add_opinion = {
					target = scope:recipient
					modifier = resisted_conversion_opinion
					years = 15
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_zeal = -0.5
			}
		}
	}

	#It's a Crime
	option = {
		name = religious_interaction.2003.b
		trigger = {
			NOT = { exists = scope:hooking_out_of_conversion }
			refusing_conversion_is_crime_trigger = {
				CHARACTER = scope:recipient
			}
		}
		if = {
			limit = {
				is_landless_adventurer = no
			}
			add_opinion = {
				target = scope:recipient
				modifier = illegal_resisted_conversion_opinion
				years = 10
			}
		}
		ai_chance = {
			base = 100
		}
	}

	#It's a Crime, but the target has a Hook on you
	option = {
		name = religious_interaction.2003.c
		trigger = {
			exists = scope:hooking_out_of_conversion
		}
		exclusive = yes
		scope:recipient = {
			use_hook = root
		}
		hidden_effect = {
			add_opinion = {
				target = scope:recipient
				modifier = resisted_conversion_opinion
				years = 20
			}
		}
		ai_chance = {
			base = 100
		}
	}

	#Use a Hook to force it through
	option = {
		name = religious_interaction.2003.d
		trigger = {
			NOT = { exists = scope:hooking_out_of_conversion }
			NOT = { has_government = landless_adventurer_government }
			has_usable_hook = scope:recipient
		}
		use_hook = scope:recipient

		demand_conversion_interaction_effect = yes
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}
}



#They ask for Gold
religious_interaction.2011 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.2011.desc
	sender = scope:recipient

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					exists = scope:recipient.capital_county
					scope:recipient.capital_county.faith = scope:recipient.faith
				}
				save_scope_value_as = {
					name = convert_capital
					value = yes
				}
			}
		}
		scope:recipient = {
			add_opinion = {
				modifier = demanded_my_conversion_opinion
				target = root
				opinion = -10
			}
		}
	}

	#Accept
	option = {
		name = religious_interaction.2011.a
		pay_short_term_gold = {
			target = scope:recipient
			gold = demand_conversion_bribe_size
		}
		
		demand_conversion_interaction_effect = yes
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_zeal = 0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					short_term_gold <= major_gold_value
					has_variable = conqueror
					ai_should_focus_on_building_in_their_capital = yes
				}
			}
		}
	}

	#Refuse
	option = {
		name = religious_interaction.2011.b
		if = {
			# show player opinion change if it gives imprisonment reason
			limit = {
				refusing_conversion_is_crime_trigger = {
					CHARACTER = scope:recipient
				}
			}
			add_opinion = {
				target = scope:recipient
				modifier = illegal_resisted_conversion_opinion
				years = 15
			}
		}
		else = {
			hidden_effect = {
				add_opinion = {
					target = scope:recipient
					modifier = resisted_conversion_opinion
					years = 15
				}
			}
		}
		
		ai_chance = {
			base = 10
			modifier = {
				add = 100
				gold < demand_conversion_bribe_size
			}
		}
	}

	#Use a Hook to force it through
	option = {
		name = religious_interaction.2011.c
		trigger = {
			has_strong_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		
		demand_conversion_interaction_effect = yes
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}
}


#They ask for a Favor
religious_interaction.2012 = {
	type = letter_event
	opening = {
		desc = religious_interaction.1.opening
	}
	desc = religious_interaction.2012.desc
	sender = scope:recipient

	immediate = {
		hidden_effect = {
			if = {
				limit = {
					exists = scope:recipient.capital_county
					scope:recipient.capital_county.faith = scope:recipient.faith
				}
				save_scope_value_as = {
					name = convert_capital
					value = yes
				}
			}
		}
		scope:recipient = {
			add_opinion = {
				modifier = demanded_my_conversion_opinion
				target = root
				opinion = -10
			}
		}
	}

	#Accept
	option = {
		name = religious_interaction.2012.a
		scope:recipient = {
			if = { # Check that they don't already have a hook on root
				limit = {
					NOT = {
						has_hook_of_type = {
							target = root
							type = favor_hook
						}
					}
				}
				add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		demand_conversion_interaction_effect = yes

		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}

	#Refuse
	option = {
		name = religious_interaction.2012.b
		if = {
			# show player opinion change if it gives imprisonment reason
			limit = {
				refusing_conversion_is_crime_trigger = {
					CHARACTER = scope:recipient
				}
			}
			add_opinion = {
				target = scope:recipient
				modifier = illegal_resisted_conversion_opinion
				years = 15
			}
		}
		else = {
			hidden_effect = {
				add_opinion = {
					target = scope:recipient
					modifier = resisted_conversion_opinion
					years = 15
				}
			}
		}

		ai_chance = {
			base = 10
		}
	}

	#Use a Hook to force it through
	option = {
		name = religious_interaction.2012.c
		trigger = {
			has_strong_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		demand_conversion_interaction_effect = yes
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
		}
	}
}

#demand_conversion_player_ruler_interaction auto accept
religious_interaction.2021 = {
	type = letter_event
	opening = {
		desc = religious_interaction.2021.opening
	}
	desc = religious_interaction.2021.desc
	sender = scope:actor
	
	immediate = {
		show_as_tooltip = {
			scope:actor = {
				use_hook = scope:recipient
			}
		}
		if = {
			limit = {
				faith = capital_county.faith
			}
			save_scope_value_as = {
				name = convert_capital
				value = yes
			}
		}
		show_as_tooltip = { demand_conversion_interaction_effect = yes }
	}

	option = {
		name = religious_interaction.2021.a
	}
}




#############################################################
# SUN TRIAL 												#
#															#
# originally by 											#
# Mathilda Bjarnehed										#
#															#
# reworked and made approximately 80% more ridiculous by 	#
# Nick Meredith												#
#############################################################

#I have been left in the sun to die!
religious_interaction.2100 = {
	type = character_event
	title = religious_interaction.2100.t
	desc = {
		desc = religious_interaction.2100.desc
		first_valid = {
			triggered_desc = { #Hostile
				trigger = {
					scope:capital = {
						OR = {
							terrain = desert
							terrain = desert_mountains
							terrain = drylands
							terrain = mountains
							terrain = steppe
						}
					}
				}
				desc = religious_interaction.2100.deschostile
			}
			triggered_desc = { #Waterlogged
				trigger = {
					scope:capital = {
						OR = {
							terrain = floodplains
							terrain = wetlands
						}
					}
				}
				desc = religious_interaction.2100.descwaterlogged
			}
			triggered_desc = { #Forest
				trigger = {
					scope:capital = {
						OR = {
							terrain = forest
							terrain = jungle
							terrain = taiga
						}
					}
				}
				desc = religious_interaction.2100.descforest
			}
			triggered_desc = { #Pleasant
				trigger = {
					scope:capital = {
						OR = {
							terrain = farmlands
							terrain = hills
							terrain = plains
						}
					}
				}
				desc = religious_interaction.2100.descpleasant
			}
			triggered_desc = { #Oasis
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2100.descoasis
			}
		}
		first_valid = {
			triggered_desc = { #default
				trigger = {
					scope:capital = {
						NOT = {
							terrain = oasis
						}
					}
				}
				desc = religious_interaction.2100.middledefault
			}
			triggered_desc = { #Oasis
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2100.middleoasis
			}
		}
		first_valid = {
			triggered_desc = { #Waterlogged
				trigger = {
					scope:capital = {
						OR = {
							terrain = floodplains
							terrain = wetlands
						}
					}
				}
				desc = religious_interaction.2100.endwaterlogged
			}
			triggered_desc = { #Pleasant
				trigger = {
					scope:capital = {
						OR = {
							terrain = farmlands
							terrain = hills
							terrain = plains
						}
					}
				}
				desc = religious_interaction.2100.endpleasant
			}
			triggered_desc = { #Forest
				trigger = {
					scope:capital = {
						OR = {
							terrain = forest
							terrain = taiga
							terrain = jungle
						}
					}
				}
				desc = religious_interaction.2100.endforest
			}
			triggered_desc = { #Oasis
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2100.endoasis
			}
		}
	}
	theme = death
	override_background = {
		trigger = {
			scope:capital = {
				terrain = desert_mountains
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = plains
			}
		}
		reference = plains
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = hills
			}
		}
		reference = hills
	}
	override_background = {
		trigger = {
			scope:capital = {
				OR = {
					terrain = wetlands
					terrain = floodplains
				}
			}
		}
		reference = wilderness_wetlands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = drylands
			}
		}
		reference = drylands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = oasis
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = farmlands
			}
		}
		reference = farmland
	}
	override_background = {
		trigger = {
			scope:capital = {
				NOR = {
					terrain = desert_mountains
					terrain = farmlands
					terrain = oasis
					terrain = drylands
					terrain = wetlands
					terrain = floodplains
					terrain = plains
				}
			}
		}
		reference = wilderness_scope
	}
	left_portrait = {
		character = root
		animation = prisondungeon
		override_imprisonment_visuals = yes
	}
	right_portrait = {
		character = scope:imprisoner
		animation = personality_zealous
	}

	immediate = {
		scope:imprisoner = {
			capital_province = {
				save_scope_as = capital
			}
		}
	}

	#What will happen...?
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:capital = {
								OR = {
									terrain = farmlands
									terrain = hills
									terrain = plains
									terrain = floodplains
									terrain = wetlands
									terrain = oasis
									terrain = forest
									terrain = jungle
									terrain = taiga
								}
							}
						}
						desc = religious_interaction.2100.a.confused
					}
					triggered_desc = {
						trigger = {
							faith = {
								has_doctrine = tenet_sun_worship
							}
						}
						desc = religious_interaction.2100.a.believer
					}
					triggered_desc = {
						trigger = {
							NOT = {
								faith = {
									has_doctrine = tenet_sun_worship
								}
							}
						}
						desc = religious_interaction.2100.a.unbeliever
					}
				}
			}
		}
	
	  	random_list = {
			desc = outcome_in_a_few_days
			50 = { #they are freed and super cool!

				sun_trial_survival_modifier = yes

				desc = religious_interaction.2100.a.success
				show_as_tooltip = { sun_trial_survival_effect = yes }
				trigger_event = {
					id = religious_interaction.2101
					days = 3
				}
				scope:imprisoner = {
					trigger_event = {
						id = religious_interaction.2102
						days = 3
					}				
				}
			}
			50 = { #they die without consequences!

				sun_trial_death_modifier = yes

				desc = religious_interaction.2100.a.failure
				show_as_tooltip = { sun_trial_death_effect = yes }
				trigger_event = {
					id = religious_interaction.2103
					days = 3
				}
				scope:imprisoner = {
					trigger_event = {
						id = religious_interaction.2104
						days = 3
					}				
				}
			}
		}
	}
}

#I have survived!
religious_interaction.2101 = {
	type = character_event
	title = religious_interaction.2101.t
	desc = {
		first_valid = {
			triggered_desc = { #Pleasant
				trigger = {
					scope:capital = {
						OR = {
							terrain = farmlands
							terrain = hills
							terrain = plains
							terrain = floodplains
							terrain = wetlands
							terrain = forest
							terrain = jungle
							terrain = taiga
						}
					}
				}
				desc = religious_interaction.2101.desc.pleasant
			}
			triggered_desc = { #Oasis
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2101.desc.oasis
			}
			triggered_desc = { #Regular
				trigger = {
					scope:capital = {
						NOR = {
							terrain = oasis
							terrain = farmlands
							terrain = hills
							terrain = plains
							terrain = floodplains
							terrain = wetlands
							terrain = forest
							terrain = jungle
							terrain = taiga
						}
					}
				}
				desc = religious_interaction.2101.start.desc
				desc = religious_interaction.2101.end.desc
			}
		}
	}
	theme = dungeon
	left_portrait = {
		character = root
		animation = happiness
		override_imprisonment_visuals = yes
	}
	right_portrait = {
		character = scope:imprisoner
		animation = anger
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = desert_mountains
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = plains
			}
		}
		reference = plains
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = hills
			}
		}
		reference = hills
	}
	override_background = {
		trigger = {
			scope:capital = {
				OR = {
					terrain = wetlands
					terrain = floodplains
				}
			}
		}
		reference = wilderness_wetlands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = drylands
			}
		}
		reference = drylands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = oasis
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = farmlands
			}
		}
		reference = farmland
	}
	override_background = {
		trigger = {
			scope:capital = {
				NOR = {
					terrain = desert_mountains
					terrain = farmlands
					terrain = oasis
					terrain = drylands
					terrain = wetlands
					terrain = floodplains
					terrain = plains
				}
			}
		}
		reference = wilderness_scope
	}
	immediate = {
		scope:imprisoner = {
			capital_province = {
				save_scope_as = capital
			}
		}
	}

	option = {
		name = religious_interaction.2101.a
		sun_trial_survival_effect = yes
	}
}

#They survived...
religious_interaction.2102 = {
	type = character_event
	title = religious_interaction.2100.t
	desc = {
		first_valid = {
			triggered_desc = { #Pleasant
				trigger = {
					scope:capital = {
						OR = {
							terrain = farmlands
							terrain = hills
							terrain = plains
							terrain = floodplains
							terrain = wetlands
							terrain = forest
							terrain = jungle
							terrain = taiga
						}
					}
				}
				desc = religious_interaction.2101.desc.pleasant
			}
			triggered_desc = { #Oasis
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2101.desc.oasis
			}
			triggered_desc = { #Noasis
				trigger = {
					scope:capital = {
						NOT = {
							terrain = oasis
						}
					}
				}
				desc = religious_interaction.2102.desc
			}
		}
	}
	theme = dungeon
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:prisoner
		animation = happiness
		override_imprisonment_visuals = yes
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = desert_mountains
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = plains
			}
		}
		reference = plains
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = hills
			}
		}
		reference = hills
	}
	override_background = {
		trigger = {
			scope:capital = {
				OR = {
					terrain = wetlands
					terrain = floodplains
				}
			}
		}
		reference = wilderness_wetlands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = drylands
			}
		}
		reference = drylands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = oasis
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = farmlands
			}
		}
		reference = farmland
	}
	override_background = {
		trigger = {
			scope:capital = {
				NOR = {
					terrain = desert_mountains
					terrain = farmlands
					terrain = oasis
					terrain = drylands
					terrain = wetlands
					terrain = floodplains
					terrain = plains
				}
			}
		}
		reference = wilderness_scope
	}
	immediate = {
		show_as_tooltip = {
			sun_trial_interaction_piety_effect = yes
		}
		capital_province = {
			save_scope_as = capital
		}
	}

	#Okay then
	option = {
		name = religious_interaction.2102.a

		sun_trial_survival_effect = yes
 		ai_chance = {
 			base = 100
 		}
	}

	#They look dead to me?
	option = {
		trigger = { scope:prisoner = { is_ai = yes } }
		name = religious_interaction.2102.b
		flavor = religious_interaction.2102.b.tt

		duel = {
			skill = intrigue
			value = average_skill_rating
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3
				}
				desc = religious_interaction.2102.b.success
				unknown_murder_effect = {
					VICTIM = scope:prisoner
					MURDERER = scope:imprisoner
					REASON = death_sun_trial
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2
				}
				desc = religious_interaction.2102.b.failure
				known_murder_effect = {
					VICTIM = scope:prisoner
					MURDERER = scope:imprisoner
					EXPOSER = scope:imprisoner
				}
			}
		}

		ai_chance = {
			base = 10
			ai_honor_target_modifier = { VALUE = -100 }
			ai_boldness_target_modifier = { VALUE = 30 }
			ai_vengefulness_target_modifier = { VALUE = 50 }
			ai_zeal_target_modifier = { VALUE = -100 }
		}
	}
}

#I have died...
religious_interaction.2103 = {
	type = character_event
	title = religious_interaction.2100.t
	desc = {
		first_valid = {
			triggered_desc = { #Pleasant
				trigger = {
					scope:capital = {
						OR = {
							terrain = farmlands
							terrain = hills
							terrain = plains
							terrain = forest
							terrain = jungle
							terrain = taiga
						}
					}
				}
				desc = religious_interaction.2103.desc.pleasant
			}
			triggered_desc = { #Wetlands
				trigger = {
					scope:capital = {
						OR = {
							terrain = floodplains
							terrain = wetlands
						}
					}
				}
				desc = religious_interaction.2103.desc.waterlogged
			}
			triggered_desc = { #Oasis
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2103.desc.oasis
			}
			triggered_desc = { #Regular
				trigger = {
					scope:capital = {
						NOR = {
							terrain = oasis
							terrain = farmlands
							terrain = hills
							terrain = plains
							terrain = floodplains
							terrain = wetlands
							terrain = forest
							terrain = jungle
							terrain = taiga
						}
					}
				}
				desc = {
					desc = religious_interaction.2101.start.desc
					desc = religious_interaction.2103.end.desc
				}
			}
		}
	}
	theme = dungeon
	left_portrait = {
		character = root
		animation = prisondungeon
		override_imprisonment_visuals = yes
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = desert_mountains
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = plains
			}
		}
		reference = plains
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = hills
			}
		}
		reference = hills
	}
	override_background = {
		trigger = {
			scope:capital = {
				OR = {
					terrain = wetlands
					terrain = floodplains
				}
			}
		}
		reference = wilderness_wetlands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = drylands
			}
		}
		reference = drylands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = oasis
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = farmlands
			}
		}
		reference = farmland
	}
	override_background = {
		trigger = {
			scope:capital = {
				NOR = {
					terrain = desert_mountains
					terrain = farmlands
					terrain = oasis
					terrain = drylands
					terrain = wetlands
					terrain = floodplains
					terrain = plains
				}
			}
		}
		reference = wilderness_scope
	}

	immediate = {
		scope:imprisoner = {
			capital_province = {
				save_scope_as = capital
			}
		}
	}

	option = { #Die of exposure
		name = religious_interaction.2103.a

		trigger = {
			scope:capital = {
				NOR = {
					terrain = floodplains
					terrain = wetlands
					terrain = oasis
				}
			}
		}
		sun_trial_death_effect = yes
	}

	option = { #Drown
		name = religious_interaction.2103.b

		trigger = {
			scope:capital = {
				OR = {
					terrain = floodplains
					terrain = wetlands
					terrain = oasis
				}
			}
		}
		sun_trial_death_effect = yes
	}
}

#They died!
religious_interaction.2104 = {
	type = character_event
	title = religious_interaction.2100.t
	desc = {
		first_valid = {
			triggered_desc = { #Drowned
				trigger = {
					scope:capital = {
						OR = {
							terrain = floodplains
							terrain = wetlands
						}
					}
				}
				desc = religious_interaction.2104.desc.drowned
			}
			triggered_desc = { #Drowned
				trigger = {
					scope:capital = {
						terrain = oasis
					}
				}
				desc = religious_interaction.2104.desc.oasisdrowned
			}
			triggered_desc = { #Regular death
				trigger = {
					scope:capital = {
						NOR = {
							terrain = floodplains
							terrain = wetlands
							terrain = oasis
						}
					}
				}
				desc = religious_interaction.2104.desc
			}
		}
	}
	theme = dungeon
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:prisoner
		animation = prisondungeon
		override_imprisonment_visuals = yes
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = desert_mountains
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = plains
			}
		}
		reference = plains
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = hills
			}
		}
		reference = hills
	}
	override_background = {
		trigger = {
			scope:capital = {
				OR = {
					terrain = wetlands
					terrain = floodplains
				}
			}
		}
		reference = wilderness_wetlands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = drylands
			}
		}
		reference = drylands
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = oasis
			}
		}
		reference = wilderness_desert
	}
	override_background = {
		trigger = {
			scope:capital = {
				terrain = farmlands
			}
		}
		reference = farmland
	}
	override_background = {
		trigger = {
			scope:capital = {
				NOR = {
					terrain = desert_mountains
					terrain = farmlands
					terrain = oasis
					terrain = drylands
					terrain = wetlands
					terrain = floodplains
					terrain = plains
				}
			}
		}
		reference = wilderness_scope
	}
	immediate = {
		sun_trial_interaction_piety_effect = yes
		sun_trial_death_effect = yes
		capital_province = {
			save_scope_as = capital
		}
	}

	#Okay then
	option = {
		name = religious_interaction.2102.a

		trigger = {
			scope:capital = {
				NOR = {
					terrain = floodplains
					terrain = wetlands
					terrain = oasis
				}
			}
		}
	}

	#Uhh, sure?
	option = {
		name = religious_interaction.2104.b.drowned

		trigger = {
			scope:capital = {
				OR = {
					terrain = floodplains
					terrain = wetlands
					terrain = oasis
				}
			}
		}

		add_character_modifier = {
			modifier = sun_trial_suspicious_modifier
			years = 25
		}
	}
}


#########################
# Literalist Debate		#
# by Ewan Cowhig Croft	#
# 2400					#
#########################

#	The challenge to debate is issued!
#		by Ewan Cowhig Croft
religious_interaction.2400 = {
	type = character_event
	title = religious_interaction.2400.t
	desc = religious_interaction.2400.desc
	theme = faith
	override_background = {
		reference = council_chamber
	}
	left_portrait =	scope:actor

	immediate = {
		capital_province = {		#For loc.
			barony = { save_scope_as = debate_locale }
		}
	}

	#I accept the challenge.
	option = {
		name = religious_interaction.2400.a
		duel = {
			skill = learning
			target = scope:actor
			50 = {	#Defender wins the toss.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = {
						value = scope:recipient.num_virtuous_traits
						multiply = 5
					}
				}
				modifier = {
					add = {
						value = scope:recipient.num_sinful_traits
						multiply = -5
					}
				}
				modifier = {
					add = {
						value = scope:actor.num_virtuous_traits
						multiply = -5
					}
				}
				modifier = {
					add = {
						value = scope:actor.num_sinful_traits
						multiply = 5
					}
				}
				desc = religious_interaction.2400.a.tt_success
				hidden_effect = {
					random_list = {
						1490 = {
							scope:actor = {
								add_character_flag = {
									flag = debate_lost
									years = 1
								}
								trigger_event = {
									id = religious_interaction.2401
									days = 7
								}
							}
							scope:recipient = {
								add_character_flag = {
									flag = debate_won
									years = 1
								}
								trigger_event = {
									id = religious_interaction.2402
									days = 7
								}
							}
						}
						10 = {
							trigger = {
								scope:actor = {
									is_ai = yes
									age >= 35
								}
							}
							compare_modifier = {
								target = scope:recipient
								value = learning
							}
							compare_modifier = {
								target = scope:actor
								value = learning
								multiplier = -1
							}
							compare_modifier = {
								target = scope:actor
								value = age
								offset = -40
								multiplier = 0.5
							}
							compare_modifier = {
								target = scope:actor
								value = stress
								multiplier = 0.2
							}
							scope:actor = {
								save_scope_as = victim
							}
							scope:recipient = {
								trigger_event = {
									id = religious_interaction.2403
									days = 7
								}
							}
						}
					}
				}
			}
			50 = {	#Attacker wins the toss.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = {
						value = scope:recipient.num_virtuous_traits
						multiply = -5
					}
				}
				modifier = {
					add = {
						value = scope:recipient.num_sinful_traits
						multiply = 5
					}
				}
				modifier = {
					add = {
						value = scope:actor.num_virtuous_traits
						multiply = 5
					}
				}
				modifier = {
					add = {
						value = scope:actor.num_sinful_traits
						multiply = -5
					}
				}
				desc = religious_interaction.2400.a.tt_fail
				hidden_effect = {
					random_list = {
						1490 = {
							scope:actor = {
								add_character_flag = {
									flag = debate_won
									years = 1
								}
								trigger_event = {
									id = religious_interaction.2401
									days = 7
								}
							}
							scope:recipient = {
								add_character_flag = {
									flag = debate_lost
									years = 1
								}
								trigger_event = {
									id = religious_interaction.2402
									days = 7
								}
							}
						}
						10 = {
							trigger = {
								scope:recipient = {
									is_ai = yes
									age >= 35
								}
							}
							compare_modifier = {
								target = scope:actor
								value = learning
							}
							compare_modifier = {
								target = scope:recipient
								value = learning
								multiplier = -1
							}
							compare_modifier = {
								target = scope:recipient
								value = age
								offset = -40
								multiplier = 0.5
							}
							compare_modifier = {
								target = scope:recipient
								value = stress
								multiplier = 0.2
							}
							scope:recipient = {
								save_scope_as = victim
							}
							scope:actor = {
								trigger_event = {
									id = religious_interaction.2403
									days = 7
								}
							}
						}
					}
				}
			}
		}
		#No stress, as AI is forced to pick this.
		ai_chance = {	#The AI always pick this.
			base = 100
		}
	}
	
	#I have better things to do.
	option = {
		name = religious_interaction.2400.b
		trigger = { is_ai = no }	#Only players may opt out.
		add_piety = medium_piety_loss
		custom_tooltip = religious_interaction.2400.b.tt
		hidden_effect = {
			scope:actor = {
				send_interface_toast = {
					title = religious_interaction.2400.b_turned_down
					left_icon = scope:recipient
				}
				add_piety = medium_piety_gain
				remove_character_modifier = used_literalist_debate_modifier
			}
		}
		stress_impact = { zealous = minor_stress_impact_gain }
		ai_chance = {	#Unavailable to the AI.
			base = 0
		}
	}
}

#	#Debate results: aggressor / actor
#		by Ewan Cowhig Croft
religious_interaction.2401 = {
	type = character_event
	title = religious_interaction.2400.t
	desc = {
		desc = religious_interaction.2401.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = debate_won }
				desc = religious_interaction.2401.desc_won
			}
			desc = religious_interaction.2401.desc_lost
		}
	}
	theme = faith
	override_background = {
		reference = council_chamber
	}
	left_portrait =	scope:recipient

	#The result.
	option = {
		name = {
			trigger = { has_character_flag = debate_won }
			text = religious_interaction.2401.a_won
		}
		name = {
			trigger = { has_character_flag = debate_lost }
			text = religious_interaction.2401.a_lost
		}
		if = {
			limit = { has_character_flag = debate_won }
			add_piety = major_piety_gain
			reverse_add_opinion = {
				target = scope:recipient
				modifier = literalist_debate_loser_opinion
			}
		}
		else_if = {
			limit = { has_character_flag = debate_lost }
			add_piety = major_piety_loss
			reverse_add_opinion = {
				target = scope:recipient
				modifier = literalist_debate_victor_opinion
			}
		}
		stress_impact = { cynical = medium_stress_impact_gain }
		ai_chance = {	#No other options available.
			base = 100
		}
	}
}

#	#Debate results: defender / recipient
#		by Ewan Cowhig Croft
religious_interaction.2402 = {
	type = character_event
	title = religious_interaction.2400.t
	desc = {
		desc = religious_interaction.2401.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = debate_won}
				desc = religious_interaction.2402.desc_won
			}
			desc = religious_interaction.2402.desc_lost
		}
	}
	theme = faith
	override_background = {
		reference = council_chamber
	}
	left_portrait =	scope:actor

	#The result.
	option = {
		name = {
			trigger = { has_character_flag = debate_won }
			text = religious_interaction.2401.a_won
		}
		name = {
			trigger = { has_character_flag = debate_lost }
			text = religious_interaction.2401.a_lost
		}
		if = {
			limit = { has_character_flag = debate_won}
			add_piety = major_piety_gain
			reverse_add_opinion = {
				target = scope:actor
				modifier = literalist_debate_loser_opinion
			}
		}
		else_if = {
			limit = { has_character_flag = debate_lost }
			add_piety = major_piety_loss
			reverse_add_opinion = {
				target = scope:actor
				modifier = literalist_debate_victor_opinion
			}
		}
		#No stress, as the AI is forced to get here.
		ai_chance = {	#No other options available.
			base = 100
		}
	}
}

################################
# Things go really bad for the defender
# by Petter Vilberg
################################
religious_interaction.2403 = {
	type = character_event
	title = religious_interaction.2400.t
	desc = {
		desc = religious_interaction.2401.desc_intro
		desc = religious_interaction.2403.desc
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = { scope:victim = { is_male = yes } }
					desc = religious_interaction.2403.conclusion_man
				}
				triggered_desc = {
					trigger = { scope:victim = { is_male = no } }
					desc = religious_interaction.2403.conclusion_woman
				}
				triggered_desc = {
					desc = religious_interaction.2403.conclusion_either
				}
			}
		}
	}
	theme = faith
	override_background = {
		reference = council_chamber
	}
	left_portrait = {
		character = root
		animation = anger
	}
	right_portrait = {
		character = scope:victim
		animation = pain
	}
	
	option = {
		name = religious_interaction.2403.a
		name = {
			trigger = { ai_compassion <= medium_negative_ai_value }
			text = religious_interaction.2403.a.low_compassion
		}
		name = {
			trigger = { has_trait = stubborn }
			text = religious_interaction.2403.a.stubborn
		}
		name = {
			trigger = { has_trait = zealous }
			text = religious_interaction.2403.a.zealous
		}
		trait = zealous
		custom_tooltip = religious_interaction.2403.a.tt
		hidden_effect = {
			scope:victim = {
				death = {
					killer = root
					death_reason = death_literalist_debate
				}
			}
		}
	}
}

religious_interaction.2500 = {
	type = letter_event
	opening = char_interaction.0001.opening
	desc = religious_interaction.2500.desc
	sender = scope:recipient

	immediate = {
		show_as_tooltip = { convert_at_war_interaction_effect = yes }
	}

	option = {
		name = religious_interaction.2500.a
	}
}

religious_interaction.2501 = {
	type = letter_event
	opening = char_interaction.0001.opening
	desc = religious_interaction.2501.desc
	sender = scope:recipient

	option = {
		name = religious_interaction.1000.negative
		add_piety_level = -1
		stress_impact = { zealous = major_stress_impact_gain }
	}
}

#########################
# Exaltation of Pain tenet
#########################

religious_interaction.2600 = {
	type = character_event
	title = religious_interaction.2600.t
	desc = {
		first_valid = {
			#Are we the recipient?
			triggered_desc = {
				trigger = { root = scope:recipient }
				desc = religious_interaction.2600.desc.recipient
			}
			#Else we're the actor
			desc = religious_interaction.2600.desc.actor
		}
	}
	theme = faith
	override_background = { reference = temple }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:other_character = scope:actor }
			animation = interested
		}
		animation = flirtation
	}
	right_portrait = {
		character = scope:other_character
		triggered_animation = {
			trigger = { scope:other_character = scope:recipient }
			animation = interested_left
		}
		animation = flirtation_left
	}
	immediate = {
		if = {
			limit = { root = scope:recipient }
			scope:actor = { save_scope_as = other_character }
		}
		else = {
			scope:recipient = { save_scope_as = other_character }
		}
		scope:recipient = { 
			add_character_flag = {
				flag = involved_in_revel_in_pain_recently
				years = 3
			} 
		}
	}
	#This is happening, I guess
	option = {
		name = religious_interaction.2600.a
		revel_in_pain_effect = yes
		revel_in_pain_opinion_effect = yes
	}
}

religious_interaction.2610 = {
	type = letter_event
	opening = char_interaction.0001.opening
	desc = religious_interaction.2610.desc
	sender = scope:recipient

	immediate = {
		scope:recipient = { 
			add_character_flag = {
				flag = involved_in_revel_in_pain_recently
				years = 3
			} 
		}
	}

	option = {
		name = religious_interaction.2610.a
	}
}
