# Interaction used to convert people when you reform or create a faith
ask_for_conversion_interaction = {
	category = interaction_category_religion
	special_interaction = request_conversion_interaction
	popup_on_receive = yes

	desc = compel_conversion_interaction_desc

	hidden = yes

	is_shown = {
		scope:actor.faith != scope:recipient.faith
		scope:recipient.liege = scope:actor
		NOT = { scope:recipient = { government_has_flag = government_is_landless_minority } }
		NOT = { scope:recipient = { culture = { has_cultural_tradition = tradition_diasporic } } }
	}

	is_valid_showing_failures_only = {
		valid_ask_for_conversion_conditions_trigger = yes
	}

	ai_accept = {
		base = 0
		religion_demand_conversion_default_modifier = yes

		# We add a few extra modifiers if you have a state faith, to make the initial conversion rate more immersive and plausible
		modifier = {
			scope:actor = {
				government_allows = state_faith

				# If you fulfill a minimum amount of the below triggers, we consider that you hold enough sway within the realm to make it easier for others to abandon the state faith
				calc_true_if = {
					amount >= 4

					diplomacy >= excellent_skill_level
					learning >= excellent_skill_level
					has_trait = august # You finished the August lifestyle tree
					has_trait = theologian # You finished the Theologian lifestyle tree
					AND = {
						top_liege = this
						legitimacy_level >= 4
					}
					influence_level >= 3
					house = {
						OR = {
							is_dominant_family = yes
							is_powerful_family = yes
						}
					}
				}
			}
			add = {
				value = 50
				if = {
					limit = {
						scope:actor.influence_level = 5
					}
					add = 50
				}
				else_if = {
					limit = {
						scope:actor.influence_level >= 4
					}
					add = 25
				}
				if = {
					limit = {
						scope:actor = {
							top_liege = this
							legitimacy_level >= 5
						}
					}
					add = 50
				}
			}
			desc = STATE_FAITH_CREATE_FAITH_REASON
		}
		modifier = { # If you have the prophet perk, let's increase acceptance equal to half your diplomacy and learning
			scope:actor = {
				government_allows = state_faith
				has_perk = prophet_perk
			}
			add = { value = scope:actor.learning add = scope:actor.diplomacy multiply = 0.5 }
			desc = HAS_PERK_PROPHET_REASON
		}
	}

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		new_faith_created_conversion_effect = yes

		# If we're a clan this interaction affects unity
		accept_faith_conversion_add_clan_unity_effect = yes

		# If character is converting to the state faith, we add influence
		state_faith_conversion_add_piety_effect = yes

#		scope:actor = {
#			if = {
#				limit = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = piety_from_converting_involved_rulers
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
#				add_piety = medium_piety_gain
#			}
#		}
	}

	on_decline = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = ask_for_conversion_decline_notification
				right_icon = scope:recipient
			}
		}

		# If we're a clan this interaction affects unity
		refuse_faith_conversion_add_clan_unity_effect = yes

		state_faith_refuse_conversion_add_piety_effect = yes
	}

	#Use hook
	send_option = {
		is_valid = {
			always = no # Only here to ensure that religion_demand_conversion_default_modifier doesn't error
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	send_options_exclusive = no
}

ask_for_conversion_courtier_interaction = {
	category = interaction_category_religion
	icon = religious

	special_interaction = request_conversion_interaction
	ai_maybe = yes
	can_send_despite_rejection = yes

	desc = {
		desc = ask_for_conversion_interaction_desc
		triggered_desc = {
			trigger = {
				scope:actor = {
					refusing_conversion_is_crime_trigger = {
						CHARACTER = scope:recipient
					}
				}
				scope:recipient = {
					target_is_liege_or_above = scope:actor
				}
			}
			desc = demand_conversion_vassal_ruler_is_crime
		}
	}

	ai_targets = {
		ai_recipients = courtiers
		chance = 0.25
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 36
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		scope:actor.faith != scope:recipient.faith
		scope:recipient = { is_courtier_of = scope:actor }
		scope:recipient = { is_ruler = no }
		scope:recipient = { is_imprisoned = no }
		NOT = { scope:recipient = { government_has_flag = government_is_landless_minority } }
	}

	cooldown_against_recipient = { years = 15 }

	is_valid_showing_failures_only = {
		valid_demand_conversion_conditions_trigger = yes
	}

	ai_accept = {
		base = 0
		# Increase base chance
		modifier = {
			add = 50
			desc = EDUCATE_CHILD_ACTOR_IS_MY_LIEGE
		}
		religion_demand_conversion_default_modifier = yes
	}

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
			NOT = { scope:recipient = { has_character_flag = ai_will_not_convert } }
		}
	}

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		demand_conversion_interaction_effect = yes
		hidden_effect = {
			scope:actor = {
				send_interface_message = {
					type = event_religious_good
					title = ask_for_conversion_courtier_interaction.tt
					left_icon = scope:recipient
					scope:recipient = {
						show_as_tooltip = { demand_conversion_interaction_effect = yes }
					}
				}
			}
		}
		if = {
			limit = { scope:hook = yes }
			scope:actor = {
				if = {
					limit = {
						has_usable_hook = scope:recipient
					}
					use_hook = scope:recipient
				}
			}
			scope:recipient = {
				# trigger_event = char_interaction.0180
				trigger_event = false_conversion.0900
				save_scope_value_as = {
					name = forcibly_converted
					value = yes
				}
			}
		}
		if = {
			limit = { scope:recipient = { is_imprisoned_by = scope:actor } }
			scope:recipient = { release_from_prison = yes }
			scope:recipient = {
				# trigger_event = char_interaction.0180
				trigger_event = false_conversion.0900
				save_scope_value_as = {
					name = forcibly_converted
					value = yes
				}
			}
		}

		# If we're a clan this interaction affects unity
		accept_faith_conversion_add_clan_unity_effect = yes

		# If character is converting to the state faith, we add influence
		state_faith_conversion_add_piety_effect = yes

#		scope:actor = {
#			if = {
#				limit = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = piety_from_converting_involved_rulers
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
#				add_piety = medium_piety_gain
#			}
#		}
	}

	on_decline = {
		#Negative opinions
		scope:recipient = {
			if = {
				limit = {
					scope:actor = {
						refusing_conversion_is_crime_trigger = {
							CHARACTER = scope:recipient
						}
					}
					scope:recipient = {
						target_is_liege_or_above = scope:actor
					}
				}
				reverse_add_opinion = {
					target = scope:actor
					modifier = illegal_resisted_conversion_opinion
					years = 10
				}
			}
			else = {
				add_opinion = {
					modifier = demanded_my_conversion_opinion
					target = scope:actor
					opinion = -10
				}
			}
		}
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = ask_for_conversion_decline_notification
				left_icon = scope:recipient
			}
		}

		# If we're a clan this interaction affects unity
		refuse_faith_conversion_add_clan_unity_effect = yes

		state_faith_refuse_conversion_add_piety_effect = yes
	}

	cost = {
		influence = {
			value = 0
			if = {
				limit = { scope:influence_send_option = yes }
				add = scope:actor.medium_influence_value
				desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
			}
		}
	}

	# Use hook
	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
			NOT = {
				scope:recipient = { is_imprisoned_by = scope:actor }
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_option = { # EP3 Influence
		is_shown = { # Actor must have a government that uses influence
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			# Actor has enough influence
			scope:actor = { influence >= medium_influence_value }
			# Both characters are within the same top realm
			custom_tooltip = {
				text = not_same_realm_tt
				scope:recipient.top_liege = scope:actor.top_liege
			}
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}
	send_options_exclusive = no


	ai_potential = {
		is_adult = yes
	}

	ai_will_do = {
		base = 100

		modifier = { # The AI will only use a Hook if they couldn't otherwise do this
			scope:hook = yes
			add = -1
		}

		modifier = { # The AI doesn't really want to convert Diasporic culture courtiers
			scope:recipient = {
				faith.religion = religion:judaism_religion
				culture = {
					has_cultural_tradition = tradition_diasporic
				}
			}
			factor = 0
		}

		modifier = { # Do not convert Righteous faith subjects, unless disturbingly zealous
			factor = 0
			scope:actor = {
				ai_zeal < 100
				ai_rationality > -50
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_fully_accepted_level
					}
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				has_tolerant_faith_or_culture_trigger = yes
				ai_zeal < 100
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				faith = { has_doctrine = doctrine_pluralism_fundamentalist }
				ai_zeal < -10
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				NOR = {
					faith = { has_doctrine = doctrine_pluralism_fundamentalist }
					has_tolerant_faith_or_culture_trigger = yes
				}
				ai_zeal < 25
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Rulers with State Faith won't try to convert people with faiths that are astray or better
			factor = 0
			scope:actor = {
				government_allows = state_faith
				primary_title.state_faith ?= {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
		}
	}
}

# House head demand conversion
demand_conversion_interaction = {
	icon = religious
	category = interaction_category_religion
	popup_on_receive = yes
	pause_on_receive = yes
	can_send_despite_rejection = yes
	ai_maybe = yes

	notification_text = HOUSE_HEAD_DEMAND_CONVERSION

	is_shown = {
		scope:recipient != scope:actor
		scope:actor = {
			is_house_head = yes
			faith != scope:recipient.faith
			OR = {
				house = scope:recipient.house
				AND = { # House Bloc
					house.house_confederation ?= {
						scope:recipient.house.house_confederation ?= this 
						has_cohesion_level_parameter = bloc_members_join_leaders_faith
					}
				}
			}
		}
		NOT = {
			scope:recipient = { # Use the vassal-liege interaction instead.
				is_ruler = yes
				target_is_liege_or_above = scope:actor
			}
		}
		scope:recipient = { # To avoid you converting someone's entire family, and then asking them. Restricting it to landed rulers at least gives them a chance to create their own cadet house.
			is_ruler = yes
		}
		NOT = { scope:recipient = { government_has_flag = government_is_landless_minority } }
		
		NOT = { scope:recipient = { culture = { has_cultural_tradition = tradition_diasporic } } }
	}

	cooldown_against_recipient = { years = 15 }

	desc = {
		desc = demand_conversion_interaction_desc
		triggered_desc = {
			trigger = {
				scope:actor = {
					refusing_conversion_is_crime_trigger = {
						CHARACTER = scope:recipient
					}
				}
				scope:recipient = {
					target_is_liege_or_above = scope:actor
				}
			}
			desc = demand_conversion_vassal_ruler_is_crime
		}
	}

	is_valid_showing_failures_only = {
		valid_demand_conversion_conditions_trigger = yes
	}

	cost = {
		influence = {
			value = 0
			if = {
				limit = { scope:influence_send_option = yes }
				add = scope:actor.medium_influence_value
				desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
			}
		}
	}

	on_accept = {
		demand_conversion_interaction_effect = yes
		if = {
			limit = { scope:hook = yes }
			scope:actor = {
				use_hook = scope:recipient
			}
			scope:recipient = {
				# trigger_event = char_interaction.0180
				trigger_event = false_conversion.0900
				save_scope_value_as = {
					name = forcibly_converted
					value = yes
				}
			}
		}
		if = {
			limit = { scope:recipient = { is_imprisoned_by = scope:actor } }
			scope:recipient = { release_from_prison = yes }
			scope:recipient = {
				# trigger_event = char_interaction.0180
				trigger_event = false_conversion.0900
				save_scope_value_as = {
					name = forcibly_converted
					value = yes
				}
			}
		}
		else = {
			scope:actor = {
				trigger_event = char_interaction.0181
			}
		}

#		scope:actor = {
#			if = {
#				limit = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = piety_from_converting_involved_rulers
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
#				add_piety = medium_piety_gain
#			}
#		}

		# If we're a clan this interaction affects unity
		accept_faith_conversion_add_clan_unity_effect = yes

		# If character is converting to the state faith, we add influence
		state_faith_conversion_add_piety_effect = yes
	}

	on_decline = {
		scope:recipient = {
			execute_decision = create_cadet_branch_decision
			show_as_tooltip = { create_cadet_branch = {} }
		}
		#Negative opinions
		scope:recipient = {
			if = {
				limit = {
					scope:actor = {
						refusing_conversion_is_crime_trigger = {
							CHARACTER = scope:recipient
						}
					}
					scope:recipient = {
						target_is_liege_or_above = scope:actor
					}
				}
				add_opinion = {
					target = scope:recipient
					modifier = illegal_resisted_conversion_opinion
					years = 10
				}
			}
			else = {
				add_opinion = {
					modifier = demanded_my_conversion_opinion
					target = scope:actor
					opinion = -10
				}
			}
		}
		scope:actor = {
			trigger_event = char_interaction.0182
		}

		# If we're a clan this interaction affects unity
		refuse_faith_conversion_add_clan_unity_effect = yes

		state_faith_refuse_conversion_add_piety_effect = yes
	}

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	#For loc
	on_auto_accept = {
		scope:recipient = {
			save_scope_value_as = {
				name = forcibly_converted
				value = yes
			}
		}
	}

	ai_accept = {
		base = 0
		# Increase base chance
		modifier = {
			add = 50
			desc = EDUCATE_CHILD_ACTOR_IS_MY_LIEGE
		}
		modifier = {
			add = 100
			NOT = {
				scope:recipient = {
					can_execute_decision = create_cadet_branch_decision
				}
			}
			desc = ASK_FOR_CONVERSION_CAN_NOT_CREATE_CADET_BRANCH
		}
		modifier = {
			add = -10
			scope:recipient = {
				can_execute_decision = create_cadet_branch_decision
			}
			desc = ASK_FOR_CONVERSION_CAN_CREATE_CADET_BRANCH
		}
		religion_demand_conversion_default_modifier = yes
	}

	can_send_despite_rejection = yes
	force_notification = yes

	#Use hook
	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
			NOT = {
				scope:recipient = { is_imprisoned_by = scope:actor }
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_option = { # EP3 Influence
		is_shown = { # Actor must have a government that uses influence
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			# Actor has enough influence
			scope:actor = { influence >= medium_influence_value }
			# Both characters are within the same top realm
			custom_tooltip = {
				text = not_same_realm_tt
				scope:recipient.top_liege = scope:actor.top_liege
			}
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}
	send_options_exclusive = no
}

demand_conversion_vassal_ruler_interaction = {
	category = interaction_category_religion
	icon = religious
	notification_text = LIEGE_DEMAND_CONVERSION

	ai_maybe = yes
	ai_min_reply_days = 4
	ai_max_reply_days = 9
	can_send_despite_rejection = yes
	ai_accept_negotiation = yes
	popup_on_receive = yes

	ai_targets = {
		ai_recipients = vassals
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 120
		duchy = 24
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	desc = {
		desc = ask_for_conversion_interaction_desc
		desc = line_break
		triggered_desc = {
			trigger = {
				NOT = { scope:recipient = { is_imprisoned_by = scope:actor } }
			}
			desc = might_ask_for_something_in_return_warning
		}
		triggered_desc = {
			trigger = {
				scope:actor = {
					refusing_conversion_is_crime_trigger = {
						CHARACTER = scope:recipient
					}
				}
			}
			desc = demand_conversion_vassal_ruler_is_crime
		}
	}

	on_decline_summary = stop_attacker_vassal_war_decline_summary

	is_shown = {
		scope:recipient = {
			OR = {
				target_is_liege_or_above = scope:actor
				is_tributary_of = scope:actor
			}
			faith != scope:actor.faith
			is_ai = yes
			is_ruler = yes
		}
		NOT = { scope:recipient = { government_has_flag = government_is_landless_minority } }
		NOT = { scope:recipient = { culture = { has_cultural_tradition = tradition_diasporic } } }
	}

	cooldown_against_recipient = { years = 15 }

	is_valid_showing_failures_only = {
		valid_demand_conversion_conditions_trigger = yes
		trigger_if = {
			limit = {
				scope:actor.domicile ?= {
					domicile_uses_culture_and_faith = yes
				}
				scope:recipient = {
					is_ruler = yes
					OR = {
						government_has_flag = government_is_nomadic
						government_has_flag = government_is_true_herder
					}
				}
			}
			custom_tooltip = {
				text = nomads_must_inspire_tt
				NOT = {
					scope:recipient = {
						OR = {
							government_has_flag = government_is_nomadic
							government_has_flag = government_is_true_herder
						}
					}
				}
			}
		}
	}

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
			NOT = { scope:recipient = { has_character_flag = ai_will_not_convert } }
		}
	}

	on_send = {
	}

	cost = {
		influence = {
			value = 0
			if = {
				limit = { scope:influence_send_option = yes }
				add = scope:actor.medium_influence_value
				desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
			}
		}
	}

	on_accept = {
		scope:actor = {
			trigger_event = religious_interaction.2002
		}
		demand_conversion_vassal_ruler_interaction_effect = yes

		# If we're a clan this interaction affects unity
		accept_faith_conversion_add_clan_unity_effect = yes

		# If character is converting to the state faith, we add influence
		state_faith_conversion_add_piety_effect = yes
#
#		scope:actor = {
#			if = {
#				limit = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = piety_from_converting_involved_rulers
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
#				add_piety = medium_piety_gain
#			}
#		}
	}

	on_decline = {
		scope:recipient = {
			hidden_effect = {
				random_list = {
					80 = { # Conditional acceptance
						modifier = {
							factor = 0 # Heresiarchs never agree to convert
							scope:recipient = {
								has_trait = heresiarch
							}
						}
						ai_value_modifier = {
							ai_greed = 0.5
						}
						random_list = {
							50 = { #They ask for gold
								modifier = {
									add = 50 # More likely to ask for gold if they're poor
									scope:recipient.short_term_gold < medium_gold_value
								}
								modifier = {
									add = { # Much more likely to ask for gold involved in one of their own wars (they want to win).
										value = 50
										if = {
											# Especially true if they're in debt!
											limit = { gold < 0 }
											add = 150
										}
									}
									is_at_war = yes
									any_character_war = {
										is_war_leader = scope:recipient
									}
								}
								scope:actor = {
									trigger_event = {
										id = religious_interaction.2011
									}
								}
							}
							500 = { #They ask for a favor
								trigger = {
									exists = scope:recipient.capital_county
									NOT = { has_hook = scope:actor }
								}
								# Direct feudal vassals appreciate favors more (they can improve their contract).
								modifier = {
									add = {
										value = 50
										# This goes double for your Powerful Vassals. A better contract is likely to be much more important than a short-term payout.
										if = {
											limit = { is_powerful_vassal_of = scope:actor }
											add = 100
										}
									}
									this.liege = scope:actor
									government_has_flag = government_is_feudal
								}
								scope:actor = {
									trigger_event = {
										id = religious_interaction.2012
									}
								}
							}
						}

					}
					20 = { # Full refuse
						modifier = {
							add = 20
							scope:recipient.demand_conversion_likelihood_calculation < 40
						}
						modifier = {
							add = 20
							scope:recipient.demand_conversion_likelihood_calculation < 20
						}
						modifier = {
							add = 50
							scope:recipient.demand_conversion_likelihood_calculation < 0
						}
						scope:actor = {
							trigger_event = {
								id = religious_interaction.2003
							}
						}
					}
				}
			}
			custom_tooltip = demand_conversion_vassal_ruler_does_not_convert
			show_as_tooltip = {
				#Negative opinions
				add_opinion = {
					modifier = demanded_my_conversion_opinion
					target = scope:actor
					opinion = -10
				}
				scope:actor = {
					if = {
						limit = {
							refusing_conversion_is_crime_trigger = {
								CHARACTER = scope:recipient
							}
						}
						custom_tooltip = action_can_lawfully_imprison_label
					}
				}
				# If appropriate, give 'em piety.
				give_piety_for_clinging_to_state_faith_effect = yes
			}
		}

		# If we're a clan this interaction affects unity
		refuse_faith_conversion_add_clan_unity_effect = yes
	}

	ai_potential = {
		is_adult = yes
	}

	# Use hook
	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
			NOT = {
				scope:recipient = { is_imprisoned_by = scope:actor }
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_option = { # EP3 Influence
		is_shown = { # Actor must have a government that uses influence
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			# Actor has enough influence
			scope:actor = { influence >= medium_influence_value }
			# Both characters are within the same top realm
			custom_tooltip = {
				text = not_same_realm_tt
				scope:recipient.top_liege = scope:actor.top_liege
			}
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}
	send_options_exclusive = no

	ai_will_do = {
		base = 100

		modifier = { # Make sure the AI uses hooks for this as it's % based
			scope:hook = yes
			add = 1
		}

		modifier = {
			factor = 0
			scope:recipient.demand_conversion_likelihood_calculation < 10
			NOT = {
				scope:actor = {
					refusing_conversion_is_crime_trigger = {
						CHARACTER = scope:recipient
					}
				}
			}
		}

		modifier = {
			factor = 0
			scope:recipient.demand_conversion_likelihood_calculation < 70
			scope:actor = {
				gold < demand_conversion_bribe_size
			}
		}

		modifier = {
			factor = 0
			scope:recipient.demand_conversion_likelihood_calculation < 90
			scope:actor = {
				culture = {
					has_cultural_parameter = less_likely_to_force_conversion
				}
			}
		}

		modifier = { # Do not convert Righteous faith subjects, unless disturbingly zealous
			factor = 0
			scope:actor = {
				ai_zeal < 100
				ai_rationality > -50
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_fully_accepted_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				has_tolerant_faith_or_culture_trigger = yes
				ai_zeal < 100
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				faith = { has_doctrine = doctrine_pluralism_fundamentalist }
				ai_zeal < -10
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				NOR = {
					faith = { has_doctrine = doctrine_pluralism_fundamentalist }
					has_tolerant_faith_or_culture_trigger = yes
				}
				ai_zeal < 25
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
		}

		modifier = { # Rulers with state faith won't try to convert people with faiths that are astray or better
			factor = 0
			scope:actor = {
				government_allows = state_faith
				primary_title.state_faith ?= {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
		}
	}
	ai_accept = {
		base = 0
		# Increase base chance
		modifier = {
			add = 50
			desc = EDUCATE_CHILD_ACTOR_IS_MY_LIEGE
		}
		religion_demand_conversion_default_modifier = yes

		modifier = {
			desc = might_ask_for_something_in_return_warning_line_break
			add = 0
		}
	}
}

demand_conversion_player_ruler_interaction = {
	category = interaction_category_religion
	desc = ask_for_conversion_interaction_desc
	notification_text = LIEGE_DEMAND_CONVERSION
	popup_on_receive = yes
	pause_on_receive = yes
	icon = religious

	ai_targets = {
		ai_recipients = vassals
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	is_shown = {
		scope:recipient = {
			is_ai = no
			target_is_liege_or_above = scope:actor
			faith != scope:actor.faith
		}
		NOT = { scope:recipient = { government_has_flag = government_is_landless_minority } }
		NOT = { scope:recipient = { culture = { has_cultural_tradition = tradition_diasporic } } }
	}

	cooldown_against_recipient = { years = 15 }

	is_valid_showing_failures_only = {
		valid_demand_conversion_conditions_trigger = yes
	}

	send_option = {
		is_valid = {
			scope:actor = {
				has_strong_usable_hook = scope:recipient
			}
		}
		flag = demand_conversion_hook
		localization = GENERIC_SPEND_A_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_strong_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"


	send_options_exclusive = no

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:demand_conversion_hook = yes
		}
	}

	on_auto_accept = {
		demand_conversion_player_ruler_interaction_effect = yes

		scope:actor = {
			trigger_event = char_interaction.0190
		}

		scope:recipient = {
			save_scope_value_as = {
				name = forcibly_converted
				value = yes
			}
			trigger_event = religious_interaction.2021
		}
	}

	on_accept = {
		# Do conversion
		demand_conversion_player_ruler_interaction_effect = yes
		scope:actor = {
			trigger_event = char_interaction.0190
		}

		# If we're a clan this interaction affects unity
		accept_faith_conversion_add_clan_unity_effect = yes

		# If character is converting to the state faith, we add influence
		state_faith_conversion_add_piety_effect = yes

#		scope:actor = {
#			if = {
#				limit = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = piety_from_converting_involved_rulers
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
#				add_piety = medium_piety_gain
#			}
#		}
	}

	on_decline = {
		scope:actor = {
			#Crime if relevant
			if = {
				limit = {
					refusing_conversion_is_crime_trigger = {
						CHARACTER = scope:recipient
					}
				}
				add_opinion = {
					target = scope:recipient
					modifier = illegal_resisted_conversion_opinion
					years = 15
				}
			}
			else = {
				add_opinion = {
					target = scope:recipient
					modifier = resisted_conversion_opinion
					years = 15
				}
			}
			trigger_event = char_interaction.0191
		}

		# If we're a clan this interaction affects unity
		refuse_faith_conversion_add_clan_unity_effect = yes

		state_faith_refuse_conversion_add_piety_effect = yes
	}

	ai_potential = {
		is_adult = yes
	}

	ai_will_do = {
		base = 100

		modifier = {
			scope:hook = yes
			add = 1
		}

		modifier = {
			factor = 0
			scope:recipient.demand_conversion_likelihood_calculation < 10
		}

		modifier = { # Do not convert Righteous faith subjects, unless disturbingly zealous
			factor = 0
			scope:actor = {
				ai_zeal < 100
				ai_rationality > -50
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_fully_accepted_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				has_tolerant_faith_or_culture_trigger = yes
				ai_zeal < 100
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				faith = { has_doctrine = doctrine_pluralism_fundamentalist }
				ai_zeal < -10
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Astray faiths require specific circumstances to demand conversion of
			factor = 0
			scope:actor = {
				NOR = {
					faith = { has_doctrine = doctrine_pluralism_fundamentalist }
					has_tolerant_faith_or_culture_trigger = yes
				}
				ai_zeal < 25
				faith = {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
			NOT = { # If the subject has one of your holy sites, always try to convert
				scope:recipient = {
					any_sub_realm_county = {
						any_county_province = {
							barony = {
								is_holy_site_of = scope:actor.faith
							}
						}
					}
				}
			}
			NOT = {
				scope:recipient = {
					is_close_family_of = scope:actor
				}
			}
		}

		modifier = { # Rulers with state faith won't try to convert people with faiths that are astray or better
			factor = 0
			scope:actor = {
				government_allows = state_faith
				primary_title.state_faith ?= {
					faith_hostility_level = {
						target = scope:recipient.faith
						value <= faith_astray_level
					}
				}
			}
		}
	}
}

# Compel Conversion
demand_conversion_minister_rites_interaction = {
	category = interaction_category_religion
	icon = religious
	notification_text = CONVERT_TO_RELIGION

	ai_maybe = yes
	ai_min_reply_days = 4
	ai_max_reply_days = 9
	can_send_despite_rejection = no
	popup_on_receive = yes

	desc = {
		desc = ask_for_conversion_interaction_desc
		desc = line_break
		desc = demand_conversion_vassal_ruler_is_crime
	}

	on_decline_summary = stop_attacker_vassal_war_decline_summary

	is_shown = {
		scope:actor = {
			is_ai = no
			has_title = title:e_minister_of_rites
		}
		scope:recipient = {
			top_liege = scope:actor.top_liege
			this != top_liege
			faith = {
				OR = {
					faith_hostility_level = {
						target = scope:actor.faith
						value >= faith_hostile_level
					}
					faith_hostility_level = {
						target = scope:actor.top_liege.faith
						value >= faith_hostile_level
					}
				}
			}
			is_ai = yes
			is_ruler = yes
		}
		NOT = { scope:recipient = { government_has_flag = government_is_landless_minority } }
	}

	cooldown_against_recipient = { years = 15 }

	is_valid_showing_failures_only = {
		valid_demand_conversion_conditions_trigger = yes
	}

	on_send = {
	}

	cost = {
		treasury = {
			value = 0
			add = scope:actor.minor_treasury_value
			multiply = {
				value = scope:recipient.primary_title.tier
			}
		}
	}

	on_accept = {
		switch = {
			trigger = yes
			scope:convert_to_minister_faith = {
				scope:actor.faith = {
					save_scope_as = conversion_faith
				}
			}
			scope:convert_to_top_liege_faith = {
				scope:actor.top_liege.faith = {
					save_scope_as = conversion_faith
				}
			}
			scope:convert_to_realm_capital_faith = {
				scope:actor.top_liege.capital_county.faith = {
					save_scope_as = conversion_faith
				}
			}
		}
		scope:actor = {
			trigger_event = religious_interaction.2002
		}
		demand_conversion_vassal_ruler_interaction_effect = yes

		# If we're a clan this interaction affects unity
		accept_faith_conversion_add_clan_unity_effect = yes

		show_as_tooltip = {
			scope:actor = {
				change_influence = {
					value = minor_influence_gain
					multiply = scope:recipient.primary_title.tier
				}
				add_piety = {
					value = minor_piety_gain
					multiply = scope:recipient.primary_title.tier
				}
			}
		}
	}

	on_decline = {
		switch = {
			trigger = yes
			scope:convert_to_minister_faith = {
				scope:actor.faith = {
					save_scope_as = conversion_faith
				}
			}
			scope:convert_to_top_liege_faith = {
				scope:actor.top_liege.faith = {
					save_scope_as = conversion_faith
				}
			}
			scope:convert_to_realm_capital_faith = {
				scope:actor.top_liege.capital_county.faith = {
					save_scope_as = conversion_faith
				}
			}
		}
		scope:recipient = {
			hidden_effect = {
				random_list = {
					80 = { # Conditional acceptance
						modifier = {
							factor = 0 # Heresiarchs never agree to convert
							scope:recipient = {
								has_trait = heresiarch
							}
						}
						ai_value_modifier = {
							ai_greed = 0.5
						}
						random_list = {
							50 = { #They ask for gold
								modifier = {
									add = 50 # More likely to ask for gold if they're poor
									scope:recipient.short_term_gold < medium_gold_value
								}
								modifier = {
									add = { # Much more likely to ask for gold involved in one of their own wars (they want to win).
										value = 50
										if = {
											# Especially true if they're in debt!
											limit = { gold < 0 }
											add = 150
										}
									}
									is_at_war = yes
									any_character_war = {
										is_war_leader = scope:recipient
									}
								}
								scope:actor = {
									trigger_event = {
										id = religious_interaction.2011
									}
								}
							}
							500 = { #They ask for a favor
								trigger = {
									exists = scope:recipient.capital_county
									NOT = { has_hook = scope:actor }
								}
								# Direct feudal vassals appreciate favors more (they can improve their contract).
								modifier = {
									add = {
										value = 50
										# This goes double for your Powerful Vassals. A better contract is likely to be much more important than a short-term payout.
										if = {
											limit = { is_powerful_vassal_of = scope:actor }
											add = 100
										}
									}
									this.liege = scope:actor
									government_has_flag = government_is_feudal
								}
								scope:actor = {
									trigger_event = {
										id = religious_interaction.2012
									}
								}
							}
						}

					}
					20 = { # Full refuse
						modifier = {
							add = 20
							scope:recipient.demand_conversion_likelihood_calculation < 40
						}
						modifier = {
							add = 20
							scope:recipient.demand_conversion_likelihood_calculation < 20
						}
						modifier = {
							add = 50
							scope:recipient.demand_conversion_likelihood_calculation < 0
						}
						scope:actor = {
							trigger_event = {
								id = religious_interaction.2003
							}
						}
					}
				}
			}
			custom_tooltip = demand_conversion_vassal_ruler_does_not_convert
			show_as_tooltip = {
				#Negative opinions
				add_opinion = {
					modifier = compelled_me_to_convert_opinion
					target = scope:actor
					opinion = -10
				}
				scope:actor = {
					if = {
						limit = {
							refusing_conversion_is_crime_trigger = {
								CHARACTER = scope:recipient
							}
						}
						custom_tooltip = action_can_lawfully_imprison_label
					}
				}
				# If appropriate, give 'em piety.
				give_piety_for_clinging_to_state_faith_effect = yes
			}
		}
	}

	# Use hook
	send_option = {
		flag = convert_to_minister_faith
		localization = MINISTER_FAITH
	}

	send_option = {
		is_shown = {
			scope:actor.top_liege.faith != scope:actor.faith
		}
		flag = convert_to_top_liege_faith
		localization = TOP_LIEGE_FAITH
	}

	send_option = {
		is_shown = {
			scope:actor.top_liege.capital_county.faith = {
				NOR = {
					this = scope:actor.top_liege.faith
					this = scope:actor.faith
				}
			}
		}
		flag = convert_to_realm_capital_faith
		localization = CAPITAL_FAITH
	}

	ai_accept = {
		base = 0
		# Increase base chance
		modifier = {
			add = 50
			desc = ACTOR_IS_MINISTER_OF_RITES
		}
		modifier = {
			add = 25
			trigger = {
				scope:actor.top_liege = {
					OR = {
						has_realm_law = celestial_bureaucracy_0
						has_realm_law = celestial_bureaucracy_1
					}
				}
			}
			desc = IMPRESSED_BY_AUTHORITY
		}
		modifier = {
			add = 50
			trigger = {
				scope:actor.top_liege = {
					has_realm_law = celestial_bureaucracy_2
				}
			}
			desc = OVERWHELMED_BY_AUTHORITY
		}
		modifier = {
			add = 75
			trigger = {
				scope:actor.top_liege = {
					has_realm_law = celestial_bureaucracy_3
				}
			}
			desc = OVERWHELMED_BY_AUTHORITY
		}
		modifier = {
			add = 25
			trigger = {
				scope:actor = {
					has_hook = scope:recipient
				}
			}
			desc = HAS_A_HOOK
		}
		religion_demand_conversion_default_modifier = yes
		modifier = {
			desc = might_ask_for_something_in_return_warning_line_break
			add = 0
		}
	}
}

convert_to_religion_interaction = {
	category = interaction_category_religion
	icon = religious


	desc = convert_to_religion_interaction_desc

	notification_text = CONVERT_TO_RELIGION
	ignores_pending_interaction_block = yes

	is_shown = {
		scope:actor.faith != scope:recipient.faith
		scope:actor = {
			is_landless_ruler = no
			# They're either your liege, your spouse or your tributary
			OR = {
				target_is_liege_or_above = scope:recipient
				any_consort = {
					this = scope:recipient
				}
				is_tributary_of = scope:recipient
			}
			# And you've never HumSac'd a tolerated HoF.
			NAND = {
				has_variable_list = humsacd_hofs
				is_target_in_variable_list = {
					name = humsacd_hofs
					target = scope:recipient.faith
				}
			}
		}
		NOT = { scope:actor = { government_has_flag = government_is_landless_minority } }
		OR = {
			is_ai = no
			NOT = { scope:actor = { culture = { has_cultural_tradition = tradition_diasporic } } }
		}
	}

	is_valid_showing_failures_only = {
	}

	auto_accept = yes

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_send = {
		# Show conversion preview - this can be canceled, but it's fine since the conversion is voluntary
		## If we have a valid state faith, we go there.
		if = {
			limit = {
				scope:actor = {
					government_allows = state_faith
				}
				scope:actor.top_liege.primary_title.state_faith ?= scope:recipient.faith
			}
			decision:adopt_state_faith = {
				open_view_data = {
					view = decision_detail
					player = scope:actor
				}
			}
		}
		## Otherwise, go to the usual place.
		else = {
			scope:recipient.faith = {
				open_view_data = {
					view = faith_conversion
					player = scope:actor # interaction effects are executed for all clients, make sure to open the window only for the actor
				}
			}
		}
	}

	on_accept = {
		custom_tooltip = {
			text = open_faith_conversion_view_tt
		}
	}

	ai_accept = {
		base = 0
	}

	ai_will_do = {
		base = 0
	}
}

convert_to_religion_adventurer_interaction = {
	category = interaction_category_religion
	icon = religious


	desc = convert_to_religion_interaction_desc

	notification_text = CONVERT_TO_RELIGION
	ignores_pending_interaction_block = yes

	is_shown = {
		scope:actor.faith != scope:recipient.faith
		scope:actor = {
			has_government = landless_adventurer_government
			# They're either your friend or your spouse
			OR = {
				target_is_liege_or_above = scope:recipient
				any_consort = {
					this = scope:recipient
				}
				any_relation = {
					type = friend
					this = scope:recipient
				}
			}
			# And you've never HumSac'd a tolerated HoF.
			NAND = {
				has_variable_list = humsacd_hofs
				is_target_in_variable_list = {
					name = humsacd_hofs
					target = scope:recipient.faith
				}
			}
		}
		NOT = { scope:actor = { government_has_flag = government_is_landless_minority } }
		OR = {
			is_ai = no
			NOT = { scope:actor = { culture = { has_cultural_tradition = tradition_diasporic } } }
		}
	}

	is_valid_showing_failures_only = {
	}	

	auto_accept = yes

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		scope:actor = {
			hidden_effect = { faith = { save_scope_as = old_faith } }
			set_character_faith = scope:recipient.faith
			trigger_event = {
				on_action = on_faith_conversion
			}
		}
	}

	ai_accept = {
		base = 0
	}

	ai_will_do = {
		base = 0
	}
}

convert_at_war_interaction = {
	category = interaction_category_religion
	icon = religious


	desc = convert_at_war_interaction_desc

	notification_text = CONVERT_AT_WAR_INTERACTION_NOTIFICATION

	is_shown = {
		scope:actor.faith != scope:recipient.faith
		scope:actor = {
			any_character_war = {
				primary_defender = scope:actor
				primary_attacker = scope:recipient
				using_non_ghw_holy_war_cb_trigger = yes
			}
			NOR = {
				#They're neither your liege nor your spouse (so this isn't shown with convert_to_religion_interaction)
				target_is_liege_or_above = scope:recipient
				any_spouse = {
					this = scope:recipient
				}
				#They can convert
				scope:actor = scope:actor.faith.religious_head
				government_has_flag = government_is_holy_order
				# And you've never HumSac'd a tolerated HoF.
				AND = {
					has_variable_list = humsacd_hofs
					is_target_in_variable_list = {
						name = humsacd_hofs
						target = scope:recipient.faith
					}
				}
			}
		}
	}


	is_valid_showing_failures_only = {
	}


	ai_accept = {
		base = 100 #Ai always says yes
	}

	ai_min_reply_days = 1
	ai_max_reply_days = 3

	cooldown_against_recipient = { years = 10 }

	on_accept = {
		scope:actor = {
			trigger_event = religious_interaction.2500
			convert_at_war_interaction_effect = yes
		}
	}

	on_decline = {
		scope:actor = {
			show_as_tooltip = {
				add_piety_level = -1
				stress_impact = { zealous = major_stress_impact_gain }
			}
			trigger_event = religious_interaction.2501
		}
	}

	ai_potential = {
		ai_zeal < 100
		faith = {
			OR = {
				has_doctrine_parameter = unreformed
				fervor <= 25
				has_doctrine_parameter = unattractive_for_character_conversions
			}
		}
	}

	ai_targets = {
		ai_recipients = primary_war_enemies
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 36
		duchy = 24
		kingdom = 24
		empire = 24
		hegemony = 24
	}

	ai_will_do = {
		base = 0

		ai_value_modifier = {
			who = scope:actor
			ai_zeal = -1
			ai_boldness = -0.5
			max = 40
		}
		modifier = {
			scope:actor = {
				any_character_war = {
					primary_attacker = scope:recipient
					primary_defender = scope:actor
					attacker_war_score >= 30
				}
			}
			add = 5
		}
		modifier = {
			scope:actor = {
				any_character_war = {
					primary_attacker = scope:recipient
					primary_defender = scope:actor
					attacker_war_score >= 50
				}
			}
			add = 10
		}
		modifier = {
			scope:actor = {
				any_character_war = {
					primary_attacker = scope:recipient
					primary_defender = scope:actor
					attacker_war_score >= 80
				}
			}
			add = 15
		}
		modifier = {
			scope:actor.faith = {
				fervor < 50
			}
			scope:recipient.faith = {
				fervor >= 50
			}
			add = 5
		}
		modifier = {
			scope:actor.faith = {
				fervor <= 25
			}
			scope:recipient.faith = {
				fervor >= 50
			}
			add = 5
		}
		modifier = {
			scope:actor.faith = {
				fervor <= 25
			}
			scope:recipient.faith = {
				fervor >= 75
			}
			add = 5
		}
		modifier = {
			scope:actor.faith = {
				fervor >= 75
			}
			add = -10
		}
		modifier = {
			scope:actor.faith = {
				fervor >= 50
			}
			add = -5
		}
		modifier = {
			scope:recipient.faith = {
				fervor <= 25
			}
			add = -10
		}
		modifier = {
			scope:recipient.faith = {
				fervor <= 15
			}
			add = -20
		}
		modifier = {
			scope:recipient.faith = {
				fervor <= 10
			}
			add = -30
		}
		modifier = {
			scope:recipient.faith.fervor < scope:actor.faith.fervor
			factor = 0
		}
		modifier = { # Big rulers shouldn't convert arbitrarily
			scope:actor = {
				highest_held_title_tier >= tier_kingdom
				sub_realm_size >= 10
				NOT = {
					has_trait = lunatic
				}
			}
			factor = 0
		}
	}
}


####################
# Communion tenets #
# by Sean Hughes	#
####################

seek_indulgences_interaction = {
	icon = religious
	category = interaction_category_religion

	desc = seek_indulgences_interaction_desc

	notification_text = RELIGIOUS_HEAD_SEEK_INDULGENCES

	is_shown = {
		scope:recipient != scope:actor
		scope:actor.faith = {
			religious_head = scope:recipient
			has_doctrine = tenet_communion
		}
	}

	cooldown = { years = 5 }

	is_valid_showing_failures_only = {
		scope:actor = {
			trigger_if = {
				limit = {
					has_trait = kinslayer_3
					trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_3 GENDER_CHARACTER = scope:actor }
				}
				gold >= seek_indulgences_major_criminal_trait_value
			}
			trigger_else_if = {
				limit = {
					OR = {
						AND = {
							has_trait = kinslayer_2
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_2 GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = witch
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:witch GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = deviant
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:deviant GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = sodomite
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:sodomite GENDER_CHARACTER = scope:actor }
						}
					}
				}
				gold >= seek_indulgences_medium_criminal_trait_value
			}
			trigger_else_if = {
				limit = {
					OR = {
						AND = {
							has_trait = kinslayer_1
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_1 GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = fornicator
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:fornicator GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = adulterer
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:adulterer GENDER_CHARACTER = scope:actor }
						}
					}
				}
				gold >= seek_indulgences_minor_criminal_trait_value
			}
			trigger_else = {
				gold >= seek_indulgences_buy_piety_value
			}
			custom_description = {
				text = "seek_indulgences_excommunicated"
				NOT = { has_trait = excommunicated }
			}
		}
		scope:actor = {
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
	}

	ai_accept = {
		base = 50

		opinion_modifier = {
			opinion_target = scope:actor
			who = scope:recipient
			multiplier = 1
		}

		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}

		evaluate_action_increasing_house_unity = {
			VALUE = 50
		}

		evaluate_action_decreasing_house_unity = {
			VALUE = -100
		}
	}

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		seek_indulgences_interaction_effect = yes
		scope:actor = {
			trigger_event = religious_interaction.1010
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_gain
			DESC = clan_unity_indulgences_accepted.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = religious_interaction.1011
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_indulgences_declined.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	# AI will do

	ai_potential = {
		short_term_gold >= head_of_faith_gold_value
		NOT = {
			has_trait = cynical
		}
	}

	ai_targets = {
		ai_recipients = head_of_faith
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 36
		duchy = 36
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	ai_will_do = {
		base = -25

		ai_value_modifier = { # +50 to -50
			who = scope:actor
			ai_zeal = 0.5
		}

		modifier = {
			add = 50
			scope:actor = {
				piety < 0
			}
		}

		modifier = {
			add = 75
			scope:actor = {
				piety_level < 0
			}
		}

		modifier = {
			add = 50
			scope:actor = {
				piety < major_piety_value
				short_term_gold >= head_of_faith_gold_value
				short_term_gold >= monumental_gold_value
			}
		}

		modifier = {
			add = -25
			scope:actor = {
				piety > major_piety_value
				piety_level > 0
			}
		}

		evaluate_action_increasing_house_unity = {
			VALUE = 50
		}
	}
}

declaration_of_repentance_interaction = {
	icon = religious
	category = interaction_category_religion

	desc = {
		desc = declaration_of_repentance_interaction_desc
		triggered_desc = {
			trigger = { scope:actor = { has_hook = scope:recipient } }
			desc = declaration_of_repentance_interaction_desc_hook
		}
	}

	notification_text = RELIGIOUS_HEAD_DECLARATION_OF_REPENTANCE

	is_shown = {
		scope:recipient != scope:actor
		scope:actor = {
			has_trait = excommunicated
			faith = {
				religious_head = scope:recipient
				has_doctrine = tenet_communion
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = {
				has_character_modifier = recent_excommunication
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
	}

	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = declaration_hook
		localization = DECLARATION_OF_REPENTANCE_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:declaration_hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	ai_accept = {
		base = 25

		modifier = {
			scope:declaration_hook = yes
			add = 20
			desc = SCHEME_WEAK_HOOK_USED
		}
		opinion_modifier = {
			opinion_target = scope:actor
			who = scope:recipient
			multiplier = 1
		}
		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}
		modifier = {
			add = {
				add = 10
				multiply = scope:actor.num_virtuous_traits
			}
			scope:actor.num_virtuous_traits > 0
			desc = DECLARATION_OF_REPENTANCE_VIRTUES
		}
		modifier = {
			add = {
				add = -10
				multiply = scope:actor.num_sinful_traits
			}
			scope:actor.num_sinful_traits > 0
			desc = DECLARATION_OF_REPENTANCE_SINS
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_PARAGON
			add = 15
			scope:actor = {
				has_trait = paragon
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_CONSECRATED_BLOOD
			add = 5
			scope:actor = {
				has_trait = consecrated_blood
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_UNPLEDGED_GHW
			add = -25
			scope:recipient = {
				has_opinion_modifier = {
					target = scope:actor
					modifier = unpledged_from_ghw_opinion
				}
			}
		}
		modifier = {
			add = 20
			scope:recipient = {
				is_landed = no
			}
			OR = {
				scope:recipient.liege ?= scope:actor
				scope:recipient.top_liege ?= scope:actor
			}
			desc = I_AM_LIEGE_TOP_LIEGE
		}
		modifier = {
			add = 10
			scope:recipient = {
				is_landed = yes
			}
			OR = {
				scope:recipient.liege ?= scope:actor
				scope:recipient.top_liege ?= scope:actor
			}
			desc = I_AM_LIEGE_TOP_LIEGE
		}

		evaluate_action_increasing_house_unity = {
			VALUE = 50
		}

		evaluate_action_decreasing_house_unity = {
			VALUE = -100
		}
	}

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		declaration_of_repentance_interaction_effect = yes

		scope:actor = {
			#Letter event to inform character that their excommunication has been lifted.
			trigger_event = {
				id = religious_interaction.1024
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_gain
			DESC = clan_unity_repentance.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	on_decline = {
		scope:actor = {

			#Letter event to inform character the pope refused to lift the excommunication.
			trigger_event = {
				id = religious_interaction.1025
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC =  clan_unity_repentance_declined.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	# AI will do

	ai_potential = {
		has_trait = excommunicated
	}

	ai_targets = {
		ai_recipients = head_of_faith
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 72
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	ai_will_do = {
		base = 100
	}
}

excommunicate_interaction = {
	category = interaction_category_hostile
	common_interaction = yes #suppress error
	icon = excommunication

	desc = excommunicate_interaction_desc

	is_shown = {
		scope:actor = scope:actor.faith.religious_head
		scope:actor.faith = {
			this = scope:recipient.faith
			has_doctrine = tenet_communion
			has_doctrine = doctrine_spiritual_head
		}

		NOT = {
			scope:recipient = {
				has_trait = excommunicated
			}
		}

		NOT = { #Don't do this to yourself
			scope:recipient = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		NOR = {
			scope:recipient = {
				has_character_modifier = excommunication_recently_lifted
			}
			AND = {
				exists = scope:actor.faith.great_holy_war
				scope:actor.faith.great_holy_war = {
					has_pledged_attacker = scope:recipient
				}
			}
		}
		scope:recipient = {
			age >= 12
		}
		scope:actor = {
			piety >= major_piety_value
		}
		scope:actor = {
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
		}
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	auto_accept = yes
	force_notification = yes
	notification_text = religious_interaction.1021
	#answer_accept_key = religious_interaction.1000.strong_negative

	on_accept = {
		scope:actor = {
			add_piety = major_piety_loss
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = excommunicate_interaction_desc.tt
					left_icon = scope:recipient
					scope:recipient = {
						show_as_tooltip = { add_trait = excommunicated }
					}
				}
			}
		}
		excommunicate_character = {
			REQUESTING_CHARACTER = scope:actor
			TARGET_CHARACTER = scope:recipient
		}

		scope:recipient = {
			hidden_effect = { #Nudge towards rivalry
				if = {
					limit = {
						NOR = {
							has_relation_rival = scope:actor
							has_relation_potential_rival = scope:actor
						}
					}
					set_relation_potential_rival = scope:actor
				}
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_loss
			DESC = clan_unity_excommunication.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	# AI will do

	ai_potential = {
		is_adult = yes
		piety >= major_piety_value
	}

	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = scripted_relations
		ai_recipients = primary_war_enemies
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 36
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_will_do = {
		base = 50

		ai_value_modifier = { # +50 to -50
			who = scope:actor
			ai_vengefulness = 0.5
		}

		modifier = {
			factor = 0
			scope:recipient = {
				NOR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
					is_at_war_with = scope:actor
				}
			}
		}

		modifier = {
			factor = 0
			scope:recipient = {
				involved_activity ?= {
					has_activity_type = activity_coronation
					activity_host = prev
				}
			}
		}
	}
}

lift_excommunication_interaction = {
	category = interaction_category_religion
	icon = excommunication

	common_interaction = yes

	desc = lift_excommunication_interaction_desc

	is_shown = {
		scope:actor = scope:actor.faith.religious_head
		scope:actor.faith = scope:recipient.faith
		scope:recipient = {
			has_trait = excommunicated
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
	}

	auto_accept = yes
	force_notification = yes
	notification_text = religious_interaction.1024
	#answer_accept_key = religious_interaction.1024.positive

	on_accept = {
		lift_character_excommunication_effect = {
			TARGET_CHARACTER = scope:recipient
			REQUESTING_CHARACTER = scope:actor
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_gain
			DESC = clan_unity_excommunication_lifted
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	# AI will do

	ai_potential = {
		is_adult = yes
		piety >= major_piety_value
	}

	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = scripted_relations
		ai_recipients = war_allies
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 96
		duchy = 72
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_will_do = {
		base = 10

		ai_value_modifier = { # +50 to -50
			who = scope:actor
			ai_compassion = 0.5
		}

		modifier = {
			factor = 0
			scope:recipient = {
				NOR = {
					has_relation_friend = scope:actor
					has_relation_best_friend = scope:actor
					is_allied_to = scope:actor
				}
			}
		}
	}
}

request_excommunication_interaction = {
	category = interaction_category_hostile
	icon = excommunication
	interface_priority = 30

	desc = request_excommunication_interaction_desc
	redirect = {
		if = {
			limit = {
				exists = scope:actor.faith.religious_head
			}
			scope:recipient = {
				save_scope_as = secondary_recipient
			}
			scope:actor.faith.religious_head = {
				save_scope_as = recipient
			}
		}
		scope:actor.faith = {
			if = {
				limit = { exists = religious_head }
				religious_head = {
					save_scope_as = recipient
				}
			}
		}
	}

	notification_text = RELIGIOUS_HEAD_REQUEST_EXCOMMUNICATION

	is_shown = {
		exists = scope:actor.faith.religious_head
		NOR = {
			scope:actor = scope:secondary_recipient
			scope:actor.faith.religious_head = scope:actor
			scope:actor.faith.religious_head = scope:secondary_recipient
		}
		scope:actor.faith = {
			exists = religious_head
			this = scope:secondary_recipient.faith
			has_doctrine = tenet_communion
			has_doctrine = doctrine_spiritual_head
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			piety >= massive_piety_value
		}
		scope:secondary_recipient = { #Excommunication target
			NOT = { has_trait = excommunicated }
			age >= 12
		}
		scope:actor = {
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
		scope:secondary_recipient = { NOT = { has_strong_hook = scope:actor } }
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = excommunication_hook
		localization = EXCOMMUNICATION_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:excommunication_hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	ai_accept = {
		base = -50

		modifier = {
			scope:excommunication_hook = yes
			add = 50
			desc = SCHEME_WEAK_HOOK_USED
		}
		opinion_modifier = {
			who = scope:actor.faith.religious_head
			opinion_target = scope:actor
			multiplier = 1
		}
		opinion_modifier = {
			who = scope:actor.faith.religious_head
			opinion_target = scope:secondary_recipient #Excommunication target
			multiplier = -1
			min = 0
		}
		modifier = {
			add = -100
			scope:actor.faith.religious_head = {
				opinion = {
					value > 0
					target = scope:secondary_recipient #Excommunication target
				}
			}
			desc = EXCOMMUNICATION_OPINION
		}
		modifier = {
			add = {
				add = -10
				multiply = scope:secondary_recipient.num_virtuous_traits
			}
			scope:secondary_recipient.num_virtuous_traits > 0
			desc = EXCOMMUNICATION_VIRTUES
		}
		modifier = {
			add = {
				add = 10
				multiply = scope:secondary_recipient.num_sinful_traits
			}
			scope:secondary_recipient.num_sinful_traits > 0
			desc = EXCOMMUNICATION_SINS
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_PARAGON
			add = 15
			scope:actor = {
				has_trait = paragon
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_CONSECRATED_BLOOD
			add = 5
			scope:actor = {
				has_trait = consecrated_blood
			}
		}
	}

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		if = {
			limit = {
				scope:secondary_recipient = { is_alive = yes }
			}
			if = {
				limit = { scope:excommunication_hook = yes }
				scope:actor = {
					use_hook = scope:recipient
				}
			}

			scope:actor = {
				#Spend piety for the excommunication.
				add_piety = massive_piety_loss

				#Letter event to inform character the pope agreed to their request.
				trigger_event = {
					id = religious_interaction.1022
				}
			}
			excommunicate_character = {
				TARGET_CHARACTER = scope:secondary_recipient
				REQUESTING_CHARACTER = scope:actor
			}
			scope:secondary_recipient = {
				#Letter event to inform character that they have been excommunicated.
				trigger_event = {
					id = religious_interaction.1020
				}
				hidden_effect = { #Nudge towards rivalry
					if = {
						limit = {
							NOR = {
								has_relation_rival = scope:actor
								has_relation_potential_rival = scope:actor
							}
							scope:actor = { is_alive = yes }
						}
						set_relation_potential_rival = scope:actor
					}
				}
			}
			# If we're a clan this interaction affects unity
			add_clan_unity_interaction_effect = {
				CHARACTER = scope:actor
				TARGET = scope:recipient
				VALUE = medium_unity_loss
				DESC = clan_unity_request_excommunication.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
	}

	on_decline = {
		scope:actor = {
			#Letter event to inform character the pope refused their request.
			trigger_event = {
				id = religious_interaction.1023
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = miniscule_unity_gain
			DESC = clan_unity_excommunication_request_denied.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	# AI will do

	ai_potential = {
		is_adult = yes
		piety >= major_piety_value
	}

	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = scripted_relations
		ai_recipients = primary_war_enemies
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 48
		duchy = 36
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_will_do = {
		base = 25

		ai_value_modifier = { # +50 to -50
			who = scope:actor
			ai_vengefulness = 0.5
		}

		modifier = {
			factor = 0
			scope:secondary_recipient = {
				NOR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
					is_at_war_with = scope:actor
				}
			}
		}
	}
}

### End Communion tenets ###

#Ask to take the vows to join Holy order
#by Linnéa Thimrén & Bianca Savazzi
send_to_holy_order_interaction = {
	category = interaction_category_friendly
	icon = holy_order

	ai_maybe = yes
	ai_min_reply_days = 4
	ai_max_reply_days = 9
	#can_send_despite_rejection = yes
	popup_on_receive = yes
	pause_on_receive = yes

	common_interaction = yes
	cooldown_against_recipient = { years = 10 }

	desc = send_to_holy_order_interaction_desc

	on_decline_summary = take_vows_decline_summary

	greeting = negative
	notification_text = REQUEST_VOWS_NOTIFICATION_TEXT

	is_shown = {
		scope:recipient = {
			OR = {
				is_courtier_of = scope:actor
				is_child_of = scope:actor
			}
			NOR = {
				has_trait = devoted
				has_trait = order_member
			}
		}
		NOT = { #Not your bishop
			scope:actor = {
				any_learning_councillor = { this = scope:recipient }
			}
		}
		scope:actor.faith = {
			any_faith_holy_order = { #Your faith must have a Holy Order
				always = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_courtier_of = scope:actor
			#Triggers that applies to both Monastery or Holy Order requirements
			can_take_religious_vows_trigger = yes

			can_be_warrior_trigger = { ARMY_OWNER = scope:recipient }
			custom_description = {
				text = TAKE_VOWS_INTERACTION_MARTIAL_EDUCATION
				object = scope:recipient
				has_education_martial_trigger = yes
			}
			custom_description = { #At least one Holy Order whose leader you're not a rival of
				text = not_rival_leader_check
				object = scope:recipient
				scope:actor.faith = {
					any_faith_holy_order = {
						leader = {
							NOT = { has_relation_rival = scope:recipient }
						}
					}
				}
			}
		}
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	#Use hook
	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}

	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	cost = {
		piety = scope:recipient.ask_to_take_vows_piety_cost
	}

	on_send = {
		scope:recipient = {
			set_variable = {
				name = vows_piety_spent
				value = ask_to_take_vows_piety_cost
				days = 10
			}
		}
	}

	on_accept = {
		scope:actor = {
			if = {
				limit = { scope:hook = yes }
				use_hook = scope:recipient
			}

			# Legitimacy loss if you're doing this to your children
			if = {
				limit = {
					scope:recipient = { is_primary_heir_of = scope:actor }
				}
				add_legitimacy = {
					value = minor_legitimacy_loss
					multiply = scope:actor.primary_title.tier
				}
			}
			else_if = {
				limit = {
					scope:recipient = { is_child_of = scope:actor }
				}
				add_legitimacy = {
					value = miniscule_legitimacy_loss
					multiply = scope:actor.primary_title.tier
				}
			}

			trigger_event = holy_order.0001
			show_as_tooltip = {
				send_child_to_holy_order_tooltip_effect = yes
				scope:recipient = { kick_from_court_interaction_warning_tooltip_effect = yes }
			}
		}
		hidden_effect = {
			scope:recipient = {
				remove_variable = vows_piety_spent
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_gain
			DESC = clan_unity_send_to_holy_order.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	on_decline = {
		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = asked_me_to_take_vows_opinion
				years = 10
			}
		}
		#Letter event informing the character about the rejection.
		scope:actor = {
			trigger_event = {
				id = religious_interaction.1031
			}
		}

		# Refund piety cost
		show_as_tooltip = {
			scope:actor = {
				add_piety_no_experience = {
					value = scope:recipient.ask_to_take_vows_piety_cost
				}
			}
		}
		hidden_effect = {
			if = {
				limit = {
					scope:recipient = {
						has_variable = vows_piety_spent
 					}
				}
				scope:actor = {
					add_piety_no_experience = {
						value = scope:recipient.var:vows_piety_spent
 					}
 				}
				scope:recipient = {
					remove_variable = vows_piety_spent
				}
 			}
 		}

 		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_join_holy_order_refusal.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
 	}

	auto_accept = no

	ai_accept = {
		base = 0 # Try to make it 0 for most interactions

		modifier = {
			scope:hook = yes
			add = 50
			desc = SCHEME_WEAK_HOOK_USED
		}
		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.25
			desc = AI_SIMPLE_OPINION_REASON
		}
		modifier = {
			add = ai_zeal
			ai_zeal < 0
			desc = TAKE_THE_VOWS_SKEPTIC
		}
		modifier = {
			add = {
				value = ai_zeal
				divide = 2
			}
			ai_zeal > 0
			desc = TAKE_THE_VOWS_ZEALOUS
		}
		modifier = {
			add = {
				value = ai_zeal
				multiply = ai_boldness
				divide = 100
				min = 10
			}
			ai_zeal > 0
			ai_boldness > 0
			desc = TAKE_THE_VOWS_FIGHT_FOR_FAITH
		}
		modifier = {
			add = {
				value = ai_boldness
			}
			ai_boldness < 0
			desc = TAKE_THE_VOWS_AFRAID_TO_DIE
		}
		modifier = {
			add = {
				value = ai_greed
				multiply = -1
			}
			ai_greed > 0
			desc = TAKE_THE_VOWS_GREED
		}
		modifier = {
			add = 50
			exists = scope:actor.cp:councillor_court_chaplain
			scope:recipient = {
				OR = {
					has_relation_lover = scope:actor.cp:councillor_court_chaplain
					has_relation_friend = scope:actor.cp:councillor_court_chaplain
					has_secret_relation_lover = scope:actor.cp:councillor_court_chaplain
					has_relation_soulmate = scope:actor.cp:councillor_court_chaplain
					has_relation_best_friend = scope:actor.cp:councillor_court_chaplain
					opinion = {
						target = scope:actor.cp:councillor_court_chaplain
						value >= very_high_positive_opinion
					}
				}
			}
			desc = TAKE_THE_VOWS_INSPIRING_COURT_CHAPLAIN
		}
		modifier = {
			add = 50
			scope:recipient = {
				OR = {
					any_relation = {
						type = friend
						is_clergy = yes
					}
					any_relation = {
						type = best_friend
						is_clergy = yes
					}
					any_relation = {
						type = lover
						is_clergy = yes
					}
					any_relation = {
						type = soulmate
						is_clergy = yes
					}
					any_secret = {
						type = secret_lover
						secret_target = {
							is_clergy = yes
						}
					}
				}
			}
			desc = TAKE_THE_VOWS_INSPIRING_CLERGY
		}

		modifier = {
			add = {
				add = 20
				multiply = scope:recipient.num_virtuous_traits
			}
			scope:recipient.num_virtuous_traits > 0
			desc = TAKE_THE_VOWS_VIRTUOUS
		}

		modifier = {
			add = {
				add = -20
				multiply = scope:recipient.num_sinful_traits
			}
			scope:recipient.num_sinful_traits > 0
			desc = TAKE_THE_VOWS_SINFUL
		}
		modifier = { # Has fought for the faith before
			add = 20
			scope:recipient = {
				has_trait = holy_warrior
			}
			desc = TAKE_THE_VOWS_HOLY_WARRIOR
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_trait = temperate
			}
			desc = TAKE_THE_VOWS_TEMPERATE
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_trait = content
			}
			desc = TAKE_THE_VOWS_CONTENT
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_trait = humble
			}
			desc = TAKE_THE_VOWS_HUMBLE
		}

		#Negative Personality Modifiers
		modifier = {
			add = -500
			scope:recipient = {
				has_trait = pregnant
			}
			desc = TAKE_THE_VOWS_PREGNANT
		}
		modifier = {
			add = -500
			scope:recipient = {
				has_trait = ambitious
			}
			desc = TAKE_THE_VOWS_AMBITIOUS
		}

		modifier = {
			add = -50
			scope:recipient = {
				OR = {
					is_married = yes
					exists = betrothed
				}
			}
			desc = TAKE_THE_VOWS_MARRIED_OR_BETROTHED
		}

		modifier = {
			add = -150
			scope:recipient = {
				is_primary_heir_of = scope:actor
			}
			desc = TAKE_THE_VOWS_PRIMARY_HEIR
		}

		modifier = {
			add = -75
			scope:recipient = {
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			scope:actor.primary_title = {
				place_in_line_of_succession = {
					target = prev
					value = 2
				}
			}
			desc = TAKE_THE_VOWS_SECOND_HEIR
		}

		modifier = {
			add = -50
			scope:recipient = {
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			scope:actor.primary_title = {
				place_in_line_of_succession = {
					target = prev
					value = 3
				}
			}
			desc = TAKE_THE_VOWS_THIRD_HEIR
		}

		modifier = {
			add = -25
			scope:recipient = {
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			scope:actor.primary_title = {
				place_in_line_of_succession = {
					target = prev
					value >= 4
					value <= 10
				}
			}
			desc = TAKE_THE_VOWS_HEIR
		}

		modifier = {
			add = -100
			scope:recipient = {
				NOT = { is_heir_of = scope:actor }
				any_heir_title = {
					exists = holder
					holder != scope:actor
				}
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			desc = TAKE_THE_VOWS_HEIR_TO_OTHER_TITLE
		}

		modifier = {
			add = -50
			scope:recipient = {
				NOT = { is_heir_of = scope:actor }
				any_parent = {
					any_held_title = {
						place_in_line_of_succession = {
							target = scope:recipient
							value < 5
						}
						NOT = {
							place_in_line_of_succession = {
								target = scope:recipient
								value < 2
							}
						}
					}
				}
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			desc = TAKE_THE_VOWS_IN_LINE_TO_OTHER_TITLE
		}

		modifier = { #Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -50
		}
		modifier = { #Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -100
		}

		#Dread modifiers
		modifier = {
			add = intimidated_halved_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		modifier = {
			add = cowed_halved_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}
	}

	# AI will do

	ai_potential = {
		is_adult = yes
		piety >= major_piety_value
	}

	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = courtiers
		max = 5
	}

	ai_targets = {
		ai_recipients = family
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 144
		duchy = 72
		kingdom = 24
		empire = 24
		hegemony = 24
	}

	ai_will_do = {
		base = 0

		modifier = { # The AI will always use a Hook
			scope:hook = yes
			add = 1
		}

		modifier = { # Try to send rivals
			add = 100
			scope:actor = {
				OR = {
					has_relation_rival = scope:recipient
					has_relation_nemesis = scope:recipient
				}
			}
		}

		modifier = { # Try to send people who would make poor heirs
			add = 50
			scope:recipient = {
				OR = {
					has_trait = murderer
					has_trait = incestuous
					has_trait = sodomite
					has_trait = cannibal
					has_trait = deviant
					has_trait = kinslayer
					has_trait = adulterer
					has_trait = fornicator
					has_trait = maimed
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = flagellant
					has_trait = reclusive
					num_of_bad_genetic_traits >= 1
					num_sinful_traits >= 2
				}
				scope:actor.primary_title = {
					place_in_line_of_succession = {
						target = prev
						value <= 7
					}
				}
			}
		}

		modifier = { # Try to send people who would make poor heirs
			add = 25
			scope:recipient = {
				is_adult = yes
				calc_true_if = {
					amount >= 3

					diplomacy < 8
					stewardship < 8
					martial < 8
					intrigue < 8
					learning < 8
				}
				scope:actor.primary_title = {
					place_in_line_of_succession = {
						target = prev
						value <= 7
					}
				}
			}
		}

		modifier = { # Sending one of your heirs is almost customary
			add = 100
			scope:actor = {
				any_child = {
					count >= 3
				}
				NOT = {
					any_child = {
						OR = {
							has_trait = devoted
							has_trait = order_member
						}
					}
				}
			}
			scope:recipient = {
				is_child_of = scope:actor
				has_education_martial_trigger = yes
			}
		}

		modifier = { # Zealous characters generally want to send characters to the Holy Order
			add = 50
			scope:actor = {
				ai_zeal >= high_positive_ai_value
			}
			scope:recipient = {
				has_education_martial_trigger = yes
			}
		}

		modifier = { # Greedy characters want to rid their court of potential threats
			add = 50
			scope:actor = {
				ai_greed >= medium_positive_ai_value
				any_child = { }
			}
			scope:recipient = {
				NOT = {
					is_child_of = scope:actor
				}
				any_claim = {
					holder ?= scope:actor
				}
			}
		}

		modifier = { # The AI doesn't ask married/betrothed people
			factor = 0
			scope:recipient = {
				OR = {
					exists = betrothed
					is_married = yes
				}
			}
		}

		modifier = { # Never ask Primary Heir
			factor = 0
			scope:recipient = {
				is_primary_heir_of = scope:actor
			}
		}

		modifier = { # Only care about family
			factor = 0
			scope:recipient = {
				NOT = {
					is_close_or_extended_family_of = scope:actor
				}
			}
		}
	}
}


#Ask to take the vows for a monastery
#by Linnéa Thimrén & Bianca Savazzi
take_vows_interaction = {
	category = interaction_category_vassal
	icon = religious

	ai_maybe = yes
	ai_min_reply_days = 4
	ai_max_reply_days = 9
	#can_send_despite_rejection = yes
	popup_on_receive = yes
	pause_on_receive = yes

	common_interaction = yes
	cooldown_against_recipient = { years = 10 }

	desc = take_vows_interaction_desc

	on_decline_summary = take_vows_decline_summary

	greeting = negative
	notification_text = REQUEST_VOWS_NOTIFICATION_TEXT

	is_shown = {
		scope:recipient = {
			is_courtier_of = scope:actor
			NOR = {
				has_trait = devoted
				has_trait = order_member
			}
		}
		NOT = { #Not your bishop
			scope:actor = {
				any_learning_councillor = { this = scope:recipient }
			}
		}
		scope:actor = {
			take_vows_available_trigger = yes # Faith has Monastery order that recipient can be sent to
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			age >= 10
			is_courtier_of = scope:actor
			can_take_religious_vows_trigger = yes #Triggers that applies to both Monastery or Holy Order requirements
		}
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	#Use hook
	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	cost = {
		piety = scope:recipient.ask_to_take_vows_piety_cost
	}

	on_send = {
		scope:recipient = {
			set_variable = {
				name = vows_piety_spent
				value = ask_to_take_vows_piety_cost
				days = 10
 			}
 		}
 	}

	on_accept = {
		scope:actor = {
			if = {
				limit = { scope:hook = yes }
				use_hook = scope:recipient
			}

			# Legitimacy loss if you're doing this to your children
			if = {
				limit = {
					scope:recipient = { is_primary_heir_of = scope:actor }
				}
				add_legitimacy = {
					value = minor_legitimacy_loss
					multiply = scope:actor.primary_title.tier
				}
			}
			else_if = {
				limit = {
					scope:recipient = { is_child_of = scope:actor }
					has_legitimacy = yes
				}
				add_legitimacy = {
					value = miniscule_legitimacy_loss
					multiply = scope:actor.primary_title.tier
				}
			}

			show_as_tooltip = {
				send_child_to_clergy_effect = yes
			}
			scope:recipient = {
				if = {
					limit = {
						scope:actor.top_liege = {
							any_vassal_or_below = {
								government_has_flag = government_is_theocracy
								primary_title.tier > tier_barony
								faith = scope:actor.faith
							}
						}
					}
					scope:actor.top_liege = {
						random_vassal_or_below = {
							limit = {
								government_has_flag = government_is_theocracy
								primary_title.tier > tier_barony
								faith = scope:actor.faith
							}
							save_scope_as = theocratic_travel_target
						}
					}
					visit_court_of = scope:theocratic_travel_target
				}
				else_if = {
					limit = {
						exists = scope:actor.capital_province
					}
					move_to_pool_at = scope:actor.capital_province
				}
				kick_from_court_interaction_warning_tooltip_effect = yes
			}
			trigger_event = holy_order.0002
			if = {
				limit = {
					exists = cp:councillor_court_chaplain
					scope:recipient = {
						is_close_family_of = scope:actor
					}
				}
				cp:councillor_court_chaplain = {
					add_opinion = {
						target = scope:actor
						modifier = pious_opinion
						opinion = 25
					}
				}
			}
			if = {
				limit = {
					exists = faith.religious_head
					faith.religious_head != scope:actor
					scope:recipient = {
						is_close_family_of = scope:actor
					}
				}
				faith.religious_head = {
					add_opinion = {
						target = scope:actor
						modifier = pious_opinion
						opinion = 10
					}
				}
			}
			if = {
				limit = {
					house = {
						has_house_aspiration_parameter = humility_take_the_vows_bonus
					}
				}
				add_piety_experience = 100
				add_character_modifier = {
					modifier = tgp_humility_take_the_vows_bonus_modifier
					years = 10
				}
			}
		}

		hidden_effect = {
			scope:recipient = {
				remove_variable = vows_piety_spent
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_gain
			DESC = clan_unity_take_vows.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	on_decline = {
		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = asked_me_to_take_vows_opinion
				years = 10
			}
		}
		#Letter event informing the character about the rejection.
		scope:actor = {
			trigger_event = {
				id = religious_interaction.1031
			}
		}

		# Refund piety cost
		show_as_tooltip = {
			scope:actor = {
				add_piety_no_experience = {
					value = scope:recipient.ask_to_take_vows_piety_cost
				}
			}
		}
		# Refund piety cost
		hidden_effect = {
			if = {
				limit = {
					scope:recipient = {
						has_variable = vows_piety_spent
 					}
 				}
				scope:actor = {
					add_piety_no_experience = {
						value = scope:recipient.var:vows_piety_spent
 					}
				}
				scope:recipient = {
					remove_variable = vows_piety_spent
 				}
 			}
 		}

 		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_refused_to_take_vows.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
 	}

	auto_accept = no

	ai_accept = {
		base = 0 # Try to make it 0 for most interactions

		modifier = {
			scope:hook = yes
			add = 50
			desc = SCHEME_WEAK_HOOK_USED
		}
		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.25
			desc = AI_SIMPLE_OPINION_REASON
		}
		modifier = {
			add = ai_zeal
			ai_zeal < 0
			desc = TAKE_THE_VOWS_SKEPTIC
		}
		modifier = {
			add = {
				value = ai_zeal
				divide = 2
			}
			ai_zeal > 0
			desc = TAKE_THE_VOWS_ZEALOUS
		}
		modifier = {
			add = {
				value = ai_greed
				multiply = -1
			}
			ai_greed > 0
			desc = TAKE_THE_VOWS_GREED
		}
		modifier = {
			add = 50
			scope:recipient = {
				age >= 45
				is_visibly_fertile = no
				NOT = {
					any_heir_title = {
						exists = holder
					}
				}
			}
			desc = TAKE_THE_VOWS_RETIRE_IN_CHURCH
		}
		modifier = {
			add = 50
			exists = scope:actor.cp:councillor_court_chaplain
			scope:recipient = {
				OR = {
					has_relation_lover = scope:actor.cp:councillor_court_chaplain
					has_relation_friend = scope:actor.cp:councillor_court_chaplain
					has_secret_relation_lover = scope:actor.cp:councillor_court_chaplain
					has_relation_soulmate = scope:actor.cp:councillor_court_chaplain
					has_relation_best_friend = scope:actor.cp:councillor_court_chaplain
					opinion = {
						target = scope:actor.cp:councillor_court_chaplain
						value >= very_high_positive_opinion
					}
				}
			}
			desc = TAKE_THE_VOWS_INSPIRING_COURT_CHAPLAIN
		}
		modifier = {
			add = 50
			scope:recipient = {
				OR = {
					any_relation = {
						type = friend
						is_clergy = yes
					}
					any_relation = {
						type = best_friend
						is_clergy = yes
					}
					any_relation = {
						type = lover
						is_clergy = yes
					}
					any_relation = {
						type = soulmate
						is_clergy = yes
					}
					any_relation = {
						type = crush
						is_clergy = yes
					}
					any_secret = {
						type = secret_lover
						secret_target = {	
							is_clergy = yes
						}
					}
				}
			}
			desc = TAKE_THE_VOWS_INSPIRING_CLERGY
		}
		modifier = {
			add = 50
			scope:recipient = {
				has_education_learning_trigger = yes
			}
			desc = TAKE_THE_VOWS_LEARNING_EDUCATION
		}

		modifier = {
			add = {
				add = 20
				multiply = scope:recipient.num_virtuous_traits
			}
			scope:recipient.num_virtuous_traits > 0
			desc = TAKE_THE_VOWS_VIRTUOUS
		}

		modifier = {
			add = {
				add = -20
				multiply = scope:recipient.num_sinful_traits
			}
			scope:recipient.num_sinful_traits > 0
			desc = TAKE_THE_VOWS_SINFUL
		}

		#Positive Personality Modifiers
		modifier = { # Wants to help people
			add = {
				value = ai_compassion
				divide = 2
			}
			scope:recipient = {
				ai_compassion > 0
				has_trait = lifestyle_physician
			}
			desc = TAKE_THE_VOWS_PHYSICIAN_WANTS_TO_HELP
		}
		modifier = {
			add = 1200
			scope:recipient = {
				has_trait = reclusive
			}
			desc = TAKE_THE_VOWS_RECLUSIVE
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_trait = curious
			}
			desc = TAKE_THE_VOWS_CURIOUS
		}
		modifier = {
			add = 50
			scope:recipient = {
				has_trait = pensive
			}
			desc = TAKE_THE_VOWS_PENSIVE
		}
		modifier = { # Loves books & knowledge!
			add = 20
			scope:recipient = {
				has_trait = lifestyle_mystic
			}
			desc = TAKE_THE_VOWS_MYSTIC
		}
		modifier = { # Loves books & knowledge!
			add = 20
			scope:recipient = {
				has_trait = scholar
			}
			desc = TAKE_THE_VOWS_SCHOLAR
		}
		modifier = { # Loves books & knowledge!
			add = 20
			scope:recipient = {
				has_trait = theologian
			}
			desc = TAKE_THE_VOWS_THEOLOGIAN
		}
		modifier = { # Plants!
			add = 20
			scope:recipient = {
				has_trait = lifestyle_herbalist
			}
			desc = TAKE_THE_VOWS_HERBALIST
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_trait = temperate
			}
			desc = TAKE_THE_VOWS_TEMPERATE
		}
		modifier = {
			add = 50
			scope:recipient = {
				has_trait = celibate
			}
			desc = TAKE_THE_VOWS_CELIBATE
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_trait = chaste
			}
			desc = TAKE_THE_VOWS_CHASTE
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_trait = content
			}
			desc = TAKE_THE_VOWS_CONTENT
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_trait = humble
			}
			desc = TAKE_THE_VOWS_HUMBLE
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_trait = drunkard
			}
			desc = TAKE_THE_VOWS_DRUNKARD
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_trait = hashishiyah
			}
			desc = TAKE_THE_VOWS_HASHISHIYAH
		}
		modifier = {
			add = 50
			scope:recipient = {
				has_trait = trusting
			}
			desc = TAKE_THE_VOWS_TRUSTING
		}

		#Negative Personality Modifiers
		modifier = {
			add = -50
			scope:recipient = {
				has_trait = rowdy
			}
			desc = TAKE_THE_VOWS_ROWDY
		}
		modifier = {
			add = -25
			scope:recipient = {
				has_trait = bossy
			}
			desc = TAKE_THE_VOWS_BOSSY
		}
		modifier = {
			add = -20
			scope:recipient = {
				has_trait = gluttonous
			}
			desc = TAKE_THE_VOWS_GLUTTONOUS
		}
		modifier = {
			add = -20
			scope:recipient = {
				has_trait = lustful
			}
			desc = TAKE_THE_VOWS_LUSTFUL
		}
		modifier = {
			add = -500
			scope:recipient = {
				has_trait = pregnant
			}
			desc = TAKE_THE_VOWS_PREGNANT
		}
		modifier = {
			add = -500
			scope:recipient = {
				has_trait = ambitious
			}
			desc = TAKE_THE_VOWS_AMBITIOUS
		}

		modifier = {
			add = -50
			scope:recipient = {
				OR = {
					is_married = yes
					exists = betrothed
				}
			}
			desc = TAKE_THE_VOWS_MARRIED_OR_BETROTHED
		}

		modifier = {
			add = -150
			scope:recipient = {
				is_primary_heir_of = scope:actor
			}
			desc = TAKE_THE_VOWS_PRIMARY_HEIR
		}

		modifier = {
			add = -75
			scope:recipient = {
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			scope:actor.primary_title = {
				place_in_line_of_succession = {
					target = prev
					value = 2
				}
			}
			desc = TAKE_THE_VOWS_SECOND_HEIR
		}

		modifier = {
			add = -50
			scope:recipient = {
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			scope:actor.primary_title = {
				place_in_line_of_succession = {
					target = prev
					value = 3
				}
			}
			desc = TAKE_THE_VOWS_THIRD_HEIR
		}

		modifier = {
			add = -25
			scope:recipient = {
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			scope:actor.primary_title = {
				place_in_line_of_succession = {
					target = prev
					value >= 4
					value <= 10
				}
			}
			desc = TAKE_THE_VOWS_HEIR
		}

		modifier = {
			add = -100
			scope:recipient = {
				NOT = { is_heir_of = scope:actor }
				any_heir_title = {
					exists = holder
					holder != scope:actor
				}
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			desc = TAKE_THE_VOWS_HEIR_TO_OTHER_TITLE
		}

		modifier = {
			add = -50
			scope:recipient = {
				NOT = { is_heir_of = scope:actor }
				any_parent = {
					any_held_title = {
						place_in_line_of_succession = {
							target = scope:recipient
							value < 5
						}
						NOT = {
							place_in_line_of_succession = {
								target = scope:recipient
								value < 2
							}
						}
					}
				}
				NOT = {
					is_primary_heir_of = scope:actor
				}
			}
			desc = TAKE_THE_VOWS_IN_LINE_TO_OTHER_TITLE
		}

		modifier = { #Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -50
		}
		modifier = { #Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -100
		}

		#Dread modifiers
		modifier = {
			add = 25
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		modifier = {
			add = 50
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}

		# Culture Tradition modifiers

		modifier = {
			add = {
				value = 25
				if = {
					limit = {
						scope:recipient = {
							is_adult = no
							is_child_of = scope:actor
						}
					}
					add = 100
				}
			}
			scope:actor.culture = { has_cultural_parameter = monastic_expectations }
			desc = MONASTIC_EXPECTATIONS_REASON
		}
	}

	# AI will do

	ai_potential = {
		is_adult = yes
		piety >= major_piety_value
	}

	ai_target_quick_trigger = {
		adult = yes
	}

	ai_targets = {
		ai_recipients = courtiers
		max = 5
	}

	ai_targets = {
		ai_recipients = children
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 144
		duchy = 72
		kingdom = 24
		empire = 24
		hegemony = 24
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = -50
			scope:actor = {
				OR = {
					legitimacy_level = 0
					legitimacy_level = 1
				}
			}
			scope:recipient = { is_primary_heir_of = scope:actor }
		}

		modifier = { # The AI will always use a Hook
			scope:hook = yes
			add = 1
		}

		modifier = { # Try to send rivals
			add = 100
			scope:actor = {
				OR = {
					has_relation_rival = scope:recipient
					has_relation_nemesis = scope:recipient
				}
			}
		}

		modifier = { # Try to send people who would make poor heirs
			add = 50
			scope:recipient = {
				OR = {
					has_trait = murderer
					has_trait = incestuous
					has_trait = sodomite
					has_trait = cannibal
					has_trait = deviant
					has_trait = kinslayer
					has_trait = adulterer
					has_trait = fornicator
					has_trait = maimed
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = flagellant
					has_trait = reclusive
					num_of_bad_genetic_traits >= 1
					num_sinful_traits >= 2
				}
				scope:actor.primary_title = {
					place_in_line_of_succession = {
						target = prev
						value <= 7
					}
				}
			}
		}

		modifier = { # Try to send people who would make poor heirs
			add = 25
			scope:recipient = {
				is_adult = yes
				calc_true_if = {
					amount >= 3

					diplomacy < 8
					stewardship < 8
					martial < 8
					intrigue < 8
					learning < 8
				}
				scope:actor.primary_title = {
					place_in_line_of_succession = {
						target = prev
						value <= 7
					}
				}
			}
		}

		modifier = { # Sending one of your heirs is almost customary
			add = 100
			scope:actor = {
				any_child = {
					count >= 3
				}
				NOT = {
					any_child = {
						OR = {
							has_trait = devoted
							has_trait = order_member
						}
					}
				}
			}
			scope:recipient = {
				is_child_of = scope:actor
				has_education_learning_trigger = yes
			}
		}

		modifier = { # Zealous characters generally want to send characters to the clergy
			add = 50
			scope:actor = {
				ai_zeal >= high_positive_ai_value
			}
			scope:recipient = {
				has_education_learning_trigger = yes
			}
		}

		modifier = { # Greedy characters want to rid their court of potential threats
			add = 50
			scope:actor = {
				ai_greed >= medium_positive_ai_value
				any_child = { }
			}
			scope:recipient = {
				NOT = {
					is_child_of = scope:actor
				}
				any_claim = {
					holder ?= scope:actor
				}
			}
		}

		modifier = { # The AI doesn't ask married/betrothed people
			factor = 0
			scope:recipient = {
				OR = {
					exists = betrothed
					is_married = yes
				}
			}
		}

		modifier = { # Never ask Primary Heir
			factor = 0
			scope:recipient = {
				is_primary_heir_of = scope:actor
			}
		}

		modifier = { # Only care about family
			factor = 0
			scope:recipient = {
				NOT = {
					is_close_or_extended_family_of = scope:actor
				}
			}
		}

		modifier = {
			factor = 0
			scope:recipient.liege ?= { is_ai = no }
		}
	}
}

### End Monasticism tenets ###

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

temporal_condemnation_interaction = {
	category = interaction_category_religion
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:actor.faith = faith:quranist }
				desc = temporal_condemnation_interaction_desc_fasiq
			}
			desc = temporal_condemnation_interaction_desc
		}
	}
	icon = religious

	is_shown = {
		scope:actor != scope:recipient
		scope:actor.faith = {
			has_doctrine_parameter = temporal_condemnation_enabled
		}
		scope:recipient = {
			liege = scope:actor
		}
		scope:recipient = {
			is_playable_character = yes
		}
	}

	cooldown = { years = 5 }

	is_valid = {
		scope:actor = {
			piety >= medium_piety_value
		}
		custom_description = {
			text = temporal_condemnation_learning_requirement
			subject = scope:actor
			object = scope:recipient
			value = religious_legal_pronouncement_learning_requirement
			religious_legal_pronouncement_requirements >= 0
			scope:actor = { learning >= 1 }
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient.religion = scope:actor.religion
		custom_description = {
			text = temporal_condemnation_is_not_sinful
			object = scope:recipient
			scope:recipient = {
				num_sinful_traits = { value > 0 target = scope:actor.faith }
			}
		}
		trigger_if = {
			limit = {
				scope:recipient.num_sinful_traits > 0
				scope:actor.num_sinful_traits > 0
			}
			custom_description = {
				text = temporal_condemnation_less_sinful_than_me
				object = scope:recipient
				scope:actor.num_sinful_traits < scope:recipient.num_sinful_traits
			}
		}
		custom_description = {
			text = temporal_condemnation_has_been_condemned
			object = scope:recipient
			scope:recipient = {
				NOT = {
					has_character_modifier = temporal_condemnation_modifier
				}
			}
		}
		NAND = {
			exists = scope:actor.faith.great_holy_war
			scope:actor.faith.great_holy_war = {
				has_pledged_attacker = scope:recipient
			}
		}
		scope:recipient = {
			is_adult = yes
		}
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
	}

	auto_accept = yes
	force_notification = yes
	notification_text = temporal_condemnation_interaction.notification

	on_accept = {
		scope:actor = {
			add_piety = medium_piety_loss
			add_opinion = {
				target = scope:recipient
				modifier = temporal_condemnation_opinion
				years = 10
			}
			custom_tooltip = temporal_condemnation_revoke_reason
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_good
					title = temporal_condemnation_interaction.tt
					left_icon = scope:recipient
					show_as_tooltip = { custom_tooltip = temporal_condemnation_got_revoke_reason }
				}
			}
			stress_impact = {
				cynical = minor_stress_impact_gain
			}
		}
		scope:recipient = {
			add_character_modifier = {
				modifier = temporal_condemnation_modifier
				years = 15
			}
			add_opinion = {
				target = scope:actor
				modifier = temporal_condemnation_condemned_me_opinion
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_gain
			DESC = clan_unity_condemn_sins.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}
}

#########################
# Host Honored Guest
# by Sean Hughes
#########################

host_honored_guest_interaction = {
	icon = religious
	category = interaction_category_friendly

	desc = host_honored_guest_interaction_desc

	ai_targets = {
		ai_recipients = vassals
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 0
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	cooldown = { years = 1 }

	is_shown = {
		scope:recipient != scope:actor
		scope:actor = {
			is_playable_character = yes
			is_adult = yes
			faith = {
				has_doctrine_parameter = host_honored_guests_active
			}
		}
	}

	is_valid_showing_failures_only = {
		# Target faith is Hostile.
		custom_description = {
			text = host_honored_guest_is_hostile
			object = scope:recipient
			NOT = {
				scope:recipient = {
					faith = {
						faith_hostility_level = {
							target = scope:actor.faith
							value = faith_hostile_level
						}
					}
				}
			}
		}
		# Target faith is Evil.
		custom_description = {
			text = host_honored_guest_is_evil
			object = scope:recipient
			NOT = {
				scope:recipient = {
					faith = {
						faith_hostility_level = {
							target = scope:actor.faith
							value = faith_evil_level
						}
					}
				}
			}
		}
		# Target is sick
		custom_description = {
			text = host_honored_guest_is_unwell
			object = scope:recipient
			scope:recipient = {
				is_healthy = yes
			}
		}
		# Target is commanding an army
		custom_description = {
			text = host_honored_guest_is_commanding
			object = scope:recipient
			scope:recipient = {
				is_commanding_army = no
			}
		}
		# Target is imprisoned
		custom_description = {
			text = host_honored_guest_is_imprisoned
			object = scope:recipient
			scope:recipient = {
				is_imprisoned = no
			}
		}
		# At war with target
		custom_description = {
			text = host_honored_guest_is_at_war
			object = scope:recipient
			scope:recipient = {
				NOT = { is_at_war_with = scope:actor }
			}
		}
		# Is my courtier
		custom_description = {
			text = host_honored_guest_is_my_courtier
			object = scope:recipient
			scope:recipient = {
				NOT = { is_courtier_of = scope:actor }
			}
		}
	}

	auto_accept = yes
	force_notification = yes
	notification_text = host_honored_guest_interaction.notification
	#answer_accept_key = host_honored_guest_interaction.response

	on_accept = {
		scope:actor = {
			stress_impact = {
				cynical = minor_stress_impact_gain
				shy = minor_stress_impact_gain
			}
		}
		scope:recipient = {
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_good
					title = host_honored_guest_interaction_recipient.notification
					left_icon = scope:actor
				}
			}
			# Spend piety based on recipient's tier.
			if = {
				limit = {
					highest_held_title_tier <= tier_county
				}
				scope:actor = {
					add_piety = minor_piety_loss
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier = tier_duchy
				}
				scope:actor = {
					add_piety = medium_piety_loss
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier = tier_kingdom
				}
				scope:actor = {
					add_piety = major_piety_loss
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier = tier_empire
				}
				scope:actor = {
					add_piety = massive_piety_loss
				}
			}

			# Increase opinion of recipient.
			add_opinion = {
				modifier = pleased_opinion
				target = scope:actor
				opinion = {
					value = 20

					# Zealous characters more likely to appreciate the religious ceremony (if of your faith)
					if = {
						limit = {
							has_trait = zealous
							faith = scope:actor.faith
						}
						add = 10
					}
					# Cynical characters, or characters who do not believe in the hospitality ritual, are less likely to be appreciative.
					else_if = {
						limit = {
							OR = {
								has_trait = cynical
								NOT = {
									faith = {
										has_doctrine_parameter = host_honored_guests_active
									}
								}
							}
						}
						subtract = 10
					}

					# But arrogant characters like it more regardless.
					if = {
						limit = {
							has_trait = arrogant
						}
						add = 10
					}
				}
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = miniscule_unity_gain
			DESC = clan_unity_honored_guest.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	ai_potential = {
		piety >= major_piety_value
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					is_powerful_vassal_of = scope:actor
					liege = root
				}
				opinion = {
					target = scope:actor
					value = {-15 0 }
				}
			}
		}

		modifier = {
			add = 75
			scope:recipient = {
				OR = {
					is_powerful_vassal_of = scope:actor
					liege = root
				}
				opinion = {
					target = scope:actor
					value = { 0 20 }
				}
			}
		}

		modifier = {
			add = 40
			scope:recipient = {
				OR = {
					is_powerful_vassal_of = scope:actor
					liege = root
				}
				opinion = {
					target = scope:actor
					value = { 20 60 }
				}
			}
		}

		modifier = {
			add = 10
			scope:recipient = {
				OR = {
					is_powerful_vassal_of = scope:actor
					liege = root
				}
				opinion = {
					target = scope:actor
					value = { 60 100 }
				}
			}
		}
	}
}

# Spiritual Head of Faith Actions

hof_ask_for_gold_interaction = {
	icon = icon_gold
	category = interaction_category_religion

	desc = hof_ask_for_gold_interaction_desc

	ai_targets = {
		ai_recipients = head_of_faith
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 36
		duchy = 24
		kingdom = 6
		empire = 6
		hegemony = 6
	}

	cooldown_against_recipient = { years = 3 }

	is_shown = {
		scope:recipient != scope:actor
		scope:actor.faith = {
			religious_head = scope:recipient
			has_doctrine = doctrine_spiritual_head
		}
		scope:actor = {
			is_playable_character = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			gold >= scope:actor.head_of_faith_gold_value
		}
		scope:actor = {
			piety >= major_piety_value
			custom_description = {
				text = "hof_ask_for_gold_excommunicated"
				NOT = { has_trait = excommunicated }
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
		scope:actor = {
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
		}
	}

	cost = {
		influence = {
			value = 0
			if = {
				limit = { scope:influence_send_option = yes }
				add = scope:actor.medium_influence_value
				desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
			}
		}
	}

	ai_accept = {
		base = -40

		compare_modifier = {
			value = scope:recipient.gold
			trigger = {
				scope:recipient.gold > 2500
			}
			offset = -2500
			multiplier = 0.1
			max = 50
			desc = ASK_FOR_GOLD_OVERFLOWING_COFFERS
		}

		opinion_modifier = {
			opinion_target = scope:actor
			who = scope:recipient
			multiplier = 0.5
		}

		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}

		modifier = { # Attacking a co-religionist
			add = -50
			desc = I_AM_ATTACKING_A_CORELIGIONIST
			scope:actor = {
				is_at_war = yes
				any_character_war = {
					primary_attacker = scope:actor
					primary_defender.faith = scope:actor.faith
					primary_defender = {
						NOT = {
							has_trait = excommunicated
						}
					}
				}
			}
		}

		modifier = { # Offensive holy war/excommunication war
			add = 30
			desc = I_AM_WAGING_AN_OFFENSIVE_HOLY_OR_EXCOMMUNICATION_WAR
			scope:actor = {
				is_at_war = yes
				any_character_war = {
					is_attacker = scope:actor
					OR = {
						using_non_ghw_holy_war_cb_trigger = yes
						using_cb = excommunication_war
					}
				}
			}
		}

		modifier = { # Defensive Holy War
			add = 50
			desc = I_AM_DEFENDING_AGAINST_A_HOLY_WAR
			scope:actor = {
				is_at_war = yes
				any_character_war = {
					is_defender = scope:actor
					using_non_ghw_holy_war_cb_trigger = yes
				}
			}
		}

		modifier = { # HoF wants the money for themselves!
			add = -20
			desc = THEY_ARE_GREEDY
			scope:recipient = {
				ai_greed >= high_positive_greed
			}
		}

		modifier = { # I am rich already
			add = -25
			desc = I_AM_RICH
			scope:actor = {
				gold >= scope:actor.medium_treasury_value
				NOT = {
					gold >= scope:actor.major_treasury_value
				}
			}
		}

		modifier = { # I am rich already
			add = -50
			desc = I_AM_RICH
			scope:actor = {
				gold >= scope:actor.major_treasury_value
				NOT = {
					gold >= scope:actor.massive_treasury_value
				}
			}
		}

		modifier = { # I am very rich already
			add = -75
			desc = I_AM_RICH
			scope:actor = {
				gold >= scope:actor.massive_treasury_value
			}
		}

		modifier = { # I am Adulterer/Fornicator
			add = -25
			desc = I_AM_ADULTERER
			scope:actor = {
				OR = {
					AND = {
						has_trait = fornicator
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:fornicator GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = adulterer
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:adulterer GENDER_CHARACTER = scope:actor }
					}
				}
			}
		}

		modifier = { # I am a Murderer
			add = -50
			desc = I_AM_MURDERER
			scope:actor = {
				has_trait = murderer
			}
		}

		modifier = { # I am Incestous
			add = -50
			desc = I_AM_INCESTOUS
			scope:actor = {
				NOT = { scope:recipient = { faith = { has_doctrine = doctrine_consanguinity_unrestricted } } }
				has_trait = incestuous
			}
		}

		modifier = { # I am a Kinslayer
			add = -50
			desc = I_AM_A_KINSLAYER
			scope:actor = {
				OR = {
					AND = {
						has_trait = kinslayer_1
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_1 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_2
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_2 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_3
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_3 GENDER_CHARACTER = scope:actor }
					}
				}
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_SAVIOR
			add = 15
			scope:actor = {
				has_trait = savior
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_DIVINE_BLOOD
			add = 5
			scope:actor = {
				has_trait = divine_blood
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_PARAGON
			add = 15
			scope:actor = {
				has_trait = paragon
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_CONSECRATED_BLOOD
			add = 5
			scope:actor = {
				has_trait = consecrated_blood
			}
		}

		modifier = { # You are of the same dynasty as the Head of Faith
			add = 5
			desc = YOU_ARE_MY_DYNASTY_MEMBER
			scope:recipient = {
				is_lowborn = no
				dynasty = scope:actor.dynasty
				NOR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.dynasty = scope:secondary_recipient.dynasty
				}
			}
		}

		modifier = { # You are of the same house as the Head of Faith
			add = 10
			desc = YOU_ARE_MY_HOUSE_MEMBER
			scope:recipient = {
				is_lowborn = no
				house = scope:actor.house
				NOR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.house = scope:secondary_recipient.house
				}
			}
		}

		modifier = { # Related to the Head of Faith
			add = 10
			desc = YOU_ARE_MY_RELATIVE
			scope:recipient = {
				OR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
				}
				NOT = { is_child_of = scope:actor }
			}
		}

		modifier = { # Parent of the Head of Faith
			add = 25
			desc = YOU_ARE_MY_PARENT
			scope:recipient = {
				is_child_of = scope:actor
			}
		}

		modifier = { # Friend of the Head of Faith
			add = 25
			desc = WE_ARE_FRIENDS
			scope:recipient = {
				has_relation_friend = scope:actor
			}
		}

		modifier = { # Best Friend of the Head of Faith
			add = 50
			desc = WE_ARE_BEST_FRIENDS
			scope:recipient = {
				has_relation_best_friend = scope:actor
			}
		}

		modifier = { # Lover of the Head of Faith
			add = 10
			desc = WE_ARE_LOVERS
			scope:recipient = {
				has_relation_lover = scope:actor
			}
		}

		modifier = { # Rival of the Head of Faith
			add = -100
			desc = WE_ARE_RIVALS
			scope:recipient = {
				has_relation_rival = scope:actor
			}
		}

		modifier = { # Nemesis of the Head of Faith
			add = -500
			desc = WE_ARE_NEMESES
			scope:recipient = {
				has_relation_nemesis = scope:actor
			}
		}

		modifier = {
			add = {
				add = 10
				multiply = scope:actor.num_virtuous_traits
			}
			scope:actor.num_virtuous_traits > 0
			desc = I_AM_VIRTUOUS
		}

		modifier = {
			add = {
				add = 5
				multiply = scope:actor.piety_level
			}
			scope:actor.piety_level > 1
			desc = I_AM_PIOUS
		}

		modifier = {
			add = {
				add = 5
				multiply = scope:actor.piety_level
			}
			scope:actor.piety_level > 2
			scope:actor.gold < 0
			desc = I_AM_PIOUS_AND_BROKE
		}

		modifier = {
			add = {
				add = -10
				multiply = scope:actor.num_sinful_traits
			}
			scope:actor.num_sinful_traits > 0
			desc = I_AM_SINFUL
		}

		modifier = {
			add = 25
			scope:influence_send_option = yes
			desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
		}
		
		modifier = {
			add = -25
			desc = BASE_RELUCTANCE
			trigger = {
				has_game_rule = hard_difficulty
				scope:actor = {
					is_ai = no
				}
			}
		}
		
		modifier = {
			add = -75
			desc = BASE_RELUCTANCE
			trigger = {
				has_game_rule = very_hard_difficulty
				scope:actor = {
					is_ai = no
				}
			}
		}
	}

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
		}
	}

	send_option = {
		is_shown = {
			scope:actor != scope:recipient
		}
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = hook
		localization = GENERIC_SPEND_A_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_option = { # EP3 Influence
		is_shown = { # Actor must have a government that uses influence
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			# Actor has enough influence
			scope:actor = { influence >= medium_influence_value }
			# Both characters are within the same top realm
			custom_tooltip = {
				text = not_same_realm_tt
				scope:recipient.top_liege = scope:actor.top_liege
			}
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}

	send_options_exclusive = no

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		hof_ask_for_gold_interaction_effect = yes

		scope:actor = {
			trigger_event = religious_interaction.3
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = religious_interaction.32
		}
	}

	ai_potential = {
		is_playable_character = yes
		piety >= major_piety_value
		NOT = { has_trait = excommunicated }
		exists = faith.religious_head
	}

	ai_will_do = {
		base = 0

		modifier = { # The AI will only use a Hook if they couldn't otherwise do this
			scope:hook = yes
			add = -1
		}

		modifier = { # Counts get a bad 'exchange rate' due to their low income.
			highest_held_title_tier < tier_county
			scope:recipient.gold < 3000
			add = -50
		}
		modifier = { # Dukes are also somewhat reluctant to request gold if not independent.
			highest_held_title_tier = tier_duchy 
			top_liege != this
			scope:recipient.gold < 3000
			add = -25
		}

		modifier = { # I am low on money while at war
			add = 300
			scope:actor = {
				is_at_war = yes
				gold < medium_gold_value
			}
		}
		modifier = { # I am in debt
			add = 300
			scope:actor = {
				gold < 0
			}
		}

		modifier = { # Piety to burn, and no reason to keep it.
			add = 25
			scope:actor = {
				piety > massive_piety_value
				NOR = {
					has_character_modifier = vow_of_poverty_modifier
					has_trait = generous
				}
			}
		}
		modifier = { # Or when greedy
			add = scope:actor.ai_greed
			scope:actor = {
				ai_greed > 0
			}
		}

		modifier = { # If the Pope has overflowing coffers, it'd be rather impious to NOT ask him to give some to a fellow, poor and struggling christian!
			add = 50
			scope:actor = {
				piety > major_piety_value
			}
			scope:recipient.gold >= 3000
		}

		modifier = {
			add = 100
			scope:actor = {
				ai_has_economical_boom_personality = yes
			}
			scope:recipient.gold >= 1000
		}

		modifier = {
			add = 100
			scope:actor = {
				ai_has_warlike_personality = yes
				war_chest_gold < war_chest_gold_maximum
			}
			scope:recipient.gold >= 1000
		}

		modifier = { #That's _my_ piety
			add = -100
			scope:actor = { ai_has_builder_or_pious_builder_personality = yes }
		}

		modifier = { #Go on! Git!
			add = -100
			scope:actor = { government_has_flag = government_is_mandala }
		}
	}
}

hof_ask_for_claim_interaction = {
	category = interaction_category_diplomacy
	icon = religious_claim
	interface_priority = 35

	desc = hof_ask_for_claim_interaction_desc
	target_type = title
	target_filter = secondary_recipient_domain_titles
	redirect = {
		if = {
			limit = {
				exists = scope:actor.faith.religious_head
			}
			scope:recipient = {
				save_scope_as = secondary_recipient
			}
			scope:actor.faith.religious_head = {
				save_scope_as = recipient
			}
		}
	}

	has_valid_target_showing_failures_only = {
		scope:target = {
			tier >= tier_county
			is_noble_family_title = no
		}
		trigger_if = { # Admin can't request claim on other admin titles, only the top liege's primary title is up for grabs
			limit = {
				scope:secondary_recipient = {
					government_allows = administrative
					top_liege = this
				}
				scope:actor = {
					government_allows = administrative
				}
			}
			scope:target = {
				this = scope:secondary_recipient.primary_title
			}
		}
	}

	is_shown = {
		exists = scope:actor.faith.religious_head
		scope:actor.faith = scope:secondary_recipient.faith
		NOR = {
			scope:actor = scope:secondary_recipient
			scope:secondary_recipient = scope:recipient
		}
		exists = scope:actor.faith.religious_head
		scope:actor.faith = {
			has_doctrine = doctrine_spiritual_head
		}
		scope:secondary_recipient = {
			is_landed_or_landless_administrative = yes
			primary_title = { tier >= tier_county }
			NOT = { government_has_flag = government_is_holy_order }
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = { # Can't request on titles you already have a pressed claim on
			limit = {
				exists = scope:target
				scope:actor = {
					has_strong_claim_on = scope:target
				}
			}
			custom_description = {
				text = "hof_ask_for_claim_has_pressed_claim_already"
				always = no
			}
		}
		trigger_if = { # Can't request claims on baronies
			limit = {
				OR = {
					scope:recipient.highest_held_title_tier = tier_barony
					AND = {
						exists = scope:target
						scope:target = {
							tier = tier_barony
						}
					}
				}
			}
			custom_description = {
				text = "hof_ask_for_claim_no_baronies"
				always = no
			}
		}
		trigger_if = { # Can't request claims on theocratic lessees or theocracies (= Prince-Bishops)
			limit = {
				scope:secondary_recipient = {
					government_has_flag = government_is_theocracy
				}
			}
			custom_description = {
				text = "hof_ask_for_claim_theocratic_lessee"
				always = no
			}
		}
		trigger_if = { # Admin can't request claims on other admin titles
			limit = {
				scope:secondary_recipient = {
					government_allows = administrative
					NOT = { top_liege = this }
				}
				scope:actor = {
					government_allows = administrative
				}
			}
			custom_description = {
				text = "hof_ask_for_claim_on_admin_titles"
				always = no
			}
		}
		scope:actor = { # Variable piety cost depending on tier
			trigger_if = {
				limit = {
					exists = scope:target
				}
				piety >= claim_piety_value
			}
			custom_description = {
				text = "hof_ask_for_claim_excommunicated"
				NOT = { has_trait = excommunicated }
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
		scope:actor = {
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
		}
		scope:secondary_recipient = { NOT = { has_strong_hook = scope:actor } }
		# Ceremonial Monarchs cannot do this
		scope:actor = { tgp_is_ceremonial_liege_trigger = no }
	}

	cost = {
		influence = {
			value = 0
			if = {
				limit = { scope:influence_send_option = yes }
				add = scope:actor.medium_influence_value
				desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
			}
		}
	}

	ai_targets = {
		ai_recipients = neighboring_rulers
		ai_recipients = peer_vassals
		ai_recipients = liege
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 108
		duchy = 36
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_potential = {
		is_playable_character = yes
		OR = {
			ai_greed >= 50
			ai_has_warlike_personality = yes
		}
		piety >= major_piety_value
		NOT = { has_trait = excommunicated }
		exists = faith.religious_head
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = scope:actor.ai_greed
		}

		modifier = {
			add = scope:target.tier
		}

		modifier = {
			add = 500
			has_variable = conqueror
			NOR = {
				has_relation_friend = scope:secondary_recipient
				has_relation_lover = scope:secondary_recipient
			}
		}

		modifier = {
			add = -100
			scope:actor = {
				OR = {
					has_relation_friend = scope:secondary_recipient
					has_relation_lover = scope:secondary_recipient
					opinion = {
						target = scope:secondary_recipient
						value >= high_positive_opinion
					}
				}
			}
		}

		modifier = {
			factor = 0
			NOT = {
				scope:target = {
					is_neighbor_to_realm = scope:actor
				}
			}
		}
	}

	ai_accept = {
		base = 0 # Should be 0 for all interactions

		modifier = {
			scope:claim_hook ?= yes
			add = 100
			desc = SCHEME_WEAK_HOOK_USED
		}

		modifier = {
			add = -100
			desc = BASE_RELUCTANCE
		}

		modifier = { # Very difficult to claim Kingdoms/Empires when already King/Emperor
			add = -100
			desc = I_AM_ALREADY_HIGH_TIER
			scope:actor.primary_title ?= {
				tier >= tier_kingdom
			}
			scope:target = {
				tier >= tier_kingdom
			}
		}

		modifier = { # Characters with a pressed claim on a kingdom or empire already has a reduced chance of getting a claim on a kingdom or empire
			add = -50
			desc = I_ALREADY_HAVE_A_KINGDOM_OR_EMPIRE_CLAIM
			scope:actor = {
				any_claim = {
					pressed = yes
					tier >= tier_kingdom
				}
			}
			scope:target = {
				tier >= tier_kingdom
			}
		}

		opinion_modifier = { # More likely if Recipient likes Actor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.5
			desc = AI_OPINION_REASON
		}

		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}
		modifier = { # Unlikely if recipient likes Secondary Recipient
			desc = AI_OPINION_RECIPIENT_REASON
			add = {
				if = {
					limit = {
						scope:recipient != scope:secondary_recipient
					}
					subtract = "scope:recipient.opinion(scope:secondary_recipient)"
				}
			}
		}

		modifier = { # Less likely the lower their tier is compared to you
			add = {
				add = -10
				if = {
					limit = {
						scope:actor = {
							tier_difference = {
								target = scope:secondary_recipient
								value >= 2
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:actor = {
							tier_difference = {
								target = scope:secondary_recipient
								value >= 3
							}
						}
					}
					add = -10
				}
			}
			desc = THEY_ARE_LOWER_TIER
			scope:actor = {
				tier_difference = {
					target = scope:secondary_recipient
					value >= 1
				}
			}
		}

		modifier = { # Penalty for asking claims on your own vassals
			add = -50
			desc = THEY_ARE_YOUR_VASSAL
			scope:actor = {
				any_vassal_or_below = {
					this = scope:secondary_recipient
				}
			}
		}

		modifier = { # Bonus for adults to ask on children
			add = 25
			desc = THEY_ARE_A_CHILD
			scope:secondary_recipient = {
				is_adult = no
			}
			scope:actor = {
				is_adult = yes
			}
		}

		modifier = { # Penalty for children to ask on adults
			add = -25
			desc = I_AM_A_CHILD
			scope:secondary_recipient = {
				is_adult = yes
			}
			scope:actor = {
				is_adult = no
			}
		}

		modifier = { # Bonus for men if a woman under male preference
			add = 15
			desc = THEY_ARE_FEMALE_WHEN_MALE_IS_PREFERRED
			scope:secondary_recipient = {
				is_adult = yes
				is_female = yes
			}
			scope:actor = {
				is_adult = yes
				is_female = no
				faith = {
					has_doctrine = doctrine_gender_male_dominated
				}
			}
		}

		modifier = { # Bonus for women if a man under female preference
			add = 15
			desc = THEY_ARE_MALE_WHEN_FEMALE_IS_PREFERRED
			scope:secondary_recipient = {
				is_adult = yes
				is_female = no
			}
			scope:actor = {
				is_adult = yes
				is_female = yes
				faith = {
					has_doctrine = doctrine_gender_female_dominated
				}
			}
		}

		modifier = { # Penalty for women to ask claims on men under male preference
			add = -15
			desc = I_AM_FEMALE_WHEN_MALE_IS_PREFERRED
			scope:actor = {
				is_adult = yes
				is_female = yes
				faith = {
					has_doctrine = doctrine_gender_male_dominated
				}
			}
			scope:secondary_recipient = {
				is_adult = yes
				is_female = no
			}
		}

		modifier = { # Penalty for men to ask claims on women under female preference
			add = -15
			desc = I_AM_MALE_WHEN_FEMALE_IS_PREFERRED
			scope:actor = {
				is_adult = yes
				is_female = no
				faith = {
					has_doctrine = doctrine_gender_female_dominated
				}
			}
			scope:secondary_recipient = {
				is_adult = yes
				is_female = yes
			}
		}

		modifier = { # They are Excommunicated
			add = 25
			desc = THEY_ARE_EXCOMMUNICATED
			scope:secondary_recipient = {
				has_trait = excommunicated
			}
		}

		modifier = { # I am Adulterer/Fornicator
			add = -25
			desc = I_AM_ADULTERER
			scope:actor = {
				OR = {
					AND = {
						has_trait = fornicator
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:fornicator GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = adulterer
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:adulterer GENDER_CHARACTER = scope:actor }
					}
				}
			}
		}

		modifier = { # They are Adulterer/Fornicator
			add = 15
			desc = THEY_ARE_ADULTERER
			scope:secondary_recipient = {
				OR = {
					AND = {
						has_trait = fornicator
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:fornicator GENDER_CHARACTER = scope:secondary_recipient }
					}
					AND = {
						has_trait = adulterer
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:adulterer GENDER_CHARACTER = scope:secondary_recipient }
					}
				}
			}
		}

		modifier = { # I am Incestous
			add = -50
			desc = I_AM_INCESTOUS
			scope:actor = {
				NOT = { scope:recipient = { faith = { has_doctrine = doctrine_consanguinity_unrestricted } } }
				has_trait = incestuous
			}
		}

		modifier = { # I am a Murderer
			add = -50
			desc = I_AM_MURDERER
			scope:actor = {
				has_trait = murderer
			}
		}

		modifier = { # They are a Murderer
			add = 15
			desc = THEY_ARE_MURDERER
			scope:secondary_recipient = {
				has_trait = murderer
			}
		}

		modifier = { # They are Incestous
			add = 15
			desc = THEY_ARE_INCESTOUS
			scope:secondary_recipient = {
				NOT = { scope:recipient = { faith = { has_doctrine = doctrine_consanguinity_unrestricted } } }
				has_trait = incestuous
			}
		}

		modifier = { # I am a Kinslayer
			add = -50
			desc = I_AM_A_KINSLAYER
			scope:actor = {
				OR = {
					AND = {
						has_trait = kinslayer_1
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_1 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_2
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_2 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_3
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_3 GENDER_CHARACTER = scope:actor }
					}
				}
			}
		}

		modifier = { # They are a Kinslayer
			add = 15
			desc = THEY_ARE_A_KINSLAYER
			scope:secondary_recipient = {
				OR = {
					AND = {
						has_trait = kinslayer_1
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_1 GENDER_CHARACTER = scope:secondary_recipient }
					}
					AND = {
						has_trait = kinslayer_2
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_2 GENDER_CHARACTER = scope:secondary_recipient }
					}
					AND = {
						has_trait = kinslayer_3
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = trait:kinslayer_3 GENDER_CHARACTER = scope:secondary_recipient }
					}
				}
			}
		}

		modifier = { # They are of the same dynasty as the Head of Faith
			add = -50
			desc = THEY_ARE_MY_DYNASTY_MEMBER
			scope:recipient = {
				is_lowborn = no
				dynasty = scope:secondary_recipient.dynasty
				NOR = {
					house = scope:secondary_recipient.house
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.dynasty = scope:actor.dynasty
				}
			}
		}

		modifier = { # You are of the same dynasty as the Head of Faith
			add = 10
			desc = YOU_ARE_MY_DYNASTY_MEMBER
			scope:recipient = {
				is_lowborn = no
				dynasty = scope:actor.dynasty
				NOR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.dynasty = scope:secondary_recipient.dynasty
				}
			}
		}

		modifier = { # They are of the same house as the Head of Faith
			add = -50
			desc = THEY_ARE_MY_HOUSE_MEMBER
			scope:recipient = {
				is_lowborn = no
				house = scope:secondary_recipient.house
				NOR = {
					house = scope:actor.house
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.house = scope:actor.house
				}
			}
		}

		modifier = { # You are of the same house as the Head of Faith
			add = 10
			desc = YOU_ARE_MY_HOUSE_MEMBER
			scope:recipient = {
				is_lowborn = no
				house = scope:actor.house
				NOR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.house = scope:secondary_recipient.house
				}
			}
		}

		modifier = { # Related to the Head of Faith
			add = 25
			desc = YOU_ARE_MY_RELATIVE
			scope:recipient = {
				OR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
				}
				NOT = { is_child_of = scope:actor }
			}
		}

		modifier = { # Parent of the Head of Faith
			add = 50
			desc = YOU_ARE_MY_PARENT
			scope:recipient = {
				is_child_of = scope:actor
			}
		}

		modifier = { # Friend of the Head of Faith
			add = 15
			desc = WE_ARE_FRIENDS
			scope:recipient = {
				has_relation_friend = scope:actor
			}
		}

		modifier = { # Best Friend of the Head of Faith
			add = 20
			desc = WE_ARE_BEST_FRIENDS
			scope:recipient = {
				has_relation_best_friend = scope:actor
			}
		}

		modifier = { # Lover of the Head of Faith
			add = 10
			desc = WE_ARE_LOVERS
			scope:recipient = {
				has_relation_lover = scope:actor
			}
		}

		modifier = { # Rival of the Head of Faith
			add = -100
			desc = WE_ARE_RIVALS
			scope:recipient = {
				has_relation_rival = scope:actor
			}
		}

		modifier = { # Nemesis of the Head of Faith
			add = -500
			desc = WE_ARE_NEMESES
			scope:recipient = {
				has_relation_nemesis = scope:actor
			}
		}

		modifier = {
			add = {
				add = 5
				multiply = scope:actor.num_virtuous_traits
			}
			scope:actor.num_virtuous_traits > 0
			desc = I_AM_VIRTUOUS
		}

		modifier = {
			add = {
				add = -10
				multiply = scope:secondary_recipient.num_virtuous_traits
			}
			scope:secondary_recipient.num_virtuous_traits > 0
			desc = THEY_ARE_VIRTUOUS
		}

		modifier = {
			add = {
				add = -20
				multiply = scope:actor.num_sinful_traits
			}
			scope:actor.num_sinful_traits > 0
			desc = I_AM_SINFUL
		}

		modifier = {
			add = {
				add = 10
				multiply = scope:secondary_recipient.num_sinful_traits
			}
			scope:secondary_recipient.num_sinful_traits > 0
			desc = THEY_ARE_SINFUL
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_SAVIOR
			add = 15
			scope:actor = {
				has_trait = savior
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_DIVINE_BLOOD
			add = 5
			scope:actor = {
				has_trait = divine_blood
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_PARAGON
			add = 15
			scope:actor = {
				has_trait = paragon
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_CONSECRATED_BLOOD
			add = 5
			scope:actor = {
				has_trait = consecrated_blood
			}
		}
		modifier = {
			add = 25
			scope:influence_send_option = yes
			desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
		}
	}

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:claim_hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	send_option = { # EP3 Influence
		is_shown = { # Actor must have a government that uses influence
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			# Actor has enough influence
			scope:actor = { influence >= medium_influence_value }
			# Both characters are within the same top realm
			custom_tooltip = {
				text = not_same_realm_tt
				scope:recipient.top_liege = scope:actor.top_liege
			}
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}
	send_option = {
		is_shown = {
			scope:actor != scope:recipient
		}
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = claim_hook
		localization = GENERIC_SPEND_A_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		hof_ask_for_claim_interaction_effect = yes
		scope:secondary_recipient = {
			trigger_event = religious_interaction.5
		}
		scope:actor = {
			trigger_event = religious_interaction.4
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:secondary_recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_granted_claim.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = religious_interaction.42
		}
	}
}

#This interaction is referenced in code! If it's renamed you have to ping a coder
hof_redirect_great_holy_war_interaction = {
	hidden = yes

	target_type = title
	target_filter = secondary_recipient_de_jure_titles
	redirect = {
		scope:recipient = {
			save_scope_as = secondary_recipient
		}
		scope:actor.faith.religious_head = {
			save_scope_as = recipient
		}
	}

	auto_accept = yes

	is_shown = {
		#exists = scope:actor.faith.religious_head #Called by Autonomous Faiths too.
		exists = scope:actor.faith.great_holy_war
		scope:actor.faith = { is_hostile_enough_for_holy_war_trigger = { FAITH = scope:secondary_recipient.faith } }
		scope:secondary_recipient = { top_liege = this }
		NOT = { exists = scope:actor.faith.great_holy_war.ghw_war }
		scope:target != scope:actor.faith.great_holy_war.ghw_target_title #Do not show the title already targeted in the list.
	}

	can_be_picked_title = {
		scope:target.tier = tier_kingdom
		scope:target != scope:actor.faith.great_holy_war.ghw_target_title #Do not show the title already targeted in the list.
	}

	is_valid_showing_failures_only = {
		scope:actor = { piety >= faith.great_holy_war.var:redirect_cost }
		scope:actor.faith.great_holy_war = { days_until_ghw_launch >= 100 } #No last minute changes.
	}

	has_valid_target_showing_failures_only = {
		exists = scope:target
		scope:target.tier = tier_kingdom
		scope:target != scope:actor.faith.great_holy_war.ghw_target_title #Do not show the title already targeted in the list.
	}

	cost = {
		piety = scope:actor.faith.great_holy_war.var:redirect_cost
	}

	on_accept = {
		scope:actor.faith.great_holy_war = {
			#Toast for attackers
			every_pledged_attacker = {
				limit = {
					is_ai = no
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = hof_redirected_ghw.0001.desc
					left_icon = scope:actor
					right_icon = scope:secondary_recipient
				}
			}
			#Event for former defenders.
			every_pledged_defender = {
				limit = {
					is_ai = no
				}
				add_to_temporary_list = former_defenders
			}
		}
		scope:actor = {
			faith.great_holy_war = {
				save_scope_as = the_ghw
				set_great_holy_war_target = { target_character = scope:secondary_recipient target_title = scope:target }
				#Old defenders that are no longer in the area are notified.
				every_in_list = {
					list = former_defenders
					limit = {
						is_ai = no
						NOT = {
							scope:actor.faith.great_holy_war = { has_pledged_defender = prev }
						}
					}
					trigger_event = great_holy_war.0081
				}
				#New defenders are notified.
				every_pledged_defender = {
					limit = {
						is_ai = no
					}
					trigger_event = { id = great_holy_war.0082 }
				}
				change_variable = {
					name = redirect_cost
					multiply = 2
				}
				set_variable = {
					name = last_redirector
					value = scope:actor
				}
			}
			hidden_effect = {
				scope:actor.faith = { save_scope_as = the_faith }
				scope:target = { save_scope_as = target_kingdom }
				scope:secondary_recipient = {
					save_scope_as = target_character
					faith = { save_scope_as = target_faith }
				}
				every_ruler = { #Defenders Pledge to the Crusade again. (AI only)
					limit = {
						faith = scope:target_character.faith
						is_ai = yes
						is_playable_character = yes
						highest_held_title_tier >= tier_county
						NOT = {
							scope:actor.faith.great_holy_war = { has_pledged_defender = prev }
						}
					}
					trigger_event = { id = great_holy_war.0021 days = { 25 150 } } #AI counterpledging. Unlike attackers, defenders should be selected much faster during the preparation phase and then stop.
				}
				scope:target_character = {
					faith = {
						every_faith_holy_order = {
							trigger_event = { id = great_holy_war.0091 days = { 25 60 } } #Holy order counterpledging
						}
					}
				}
				scope:actor.faith.great_holy_war = { #Recalculate Recipient.
					faith = { save_scope_as = the_faith }
					ghw_target_title = { save_scope_as = target_kingdom }
					if = { #If Pope died in the meantime.
						limit = {
							OR = {
								NOT = {
									exists = scope:the_faith.great_holy_war.ghw_war_declarer
								}
								NOT = {
									scope:the_faith.great_holy_war.ghw_war_declarer = { is_alive = yes }
								}
							}
						}
						scope:the_faith = { ghw_set_new_war_declarer_effect = yes }
					}
					scope:the_faith.great_holy_war.ghw_war_declarer = { save_scope_as = ghw_sponsor }
					#Check and set sponsor if needed.
					undirected_ghw_recipient_selection_effect = yes
				}
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

select_ghw_beneficiary_interaction = {
	category = interaction_category_religion
	icon = religious


	populate_recipient_list = {
		scope:recipient = {
			#Any member of your own house.
			house = {
				every_house_member = {
					limit = {
						# Cannot select them self as beneficiary
						this != scope:recipient
					}
					add_to_list = characters
				}
			}
			#Any nearby family member who is of your dynasty, even if they're a separate house.
			every_close_or_extended_family_member = {
				limit = {
					dynasty = scope:recipient.dynasty
					house != scope:recipient.house
				}
				add_to_list = characters
			}
			#And then any landless heads of minor houses in your dynasty.
			dynasty = {
				every_dynasty_member = {
					limit = {
						this = this.house.house_head
						NOR = {
							this.house = scope:recipient.house
							any_close_or_extended_family_member = { this = scope:recipient }
						}
						is_ruler = no
					}
					add_to_list = characters
				}
			}
			# If you're a laamp, add you too.
			if = {
				limit = { OR = { government_has_flag = government_is_landless_adventurer government_has_flag = government_is_landless_minority } }
				add_to_list = characters
			}
		}
	}

	auto_accept = yes

	is_shown = {
		exists = scope:actor.faith.great_holy_war
		scope:actor = {
			exists = faith.great_holy_war
			this = scope:recipient
			is_pledged_ghw_attacker = yes
		}
		scope:actor != scope:recipient.faith.great_holy_war.ghw_war_declarer #Not for the Caliph himself.
	}

	can_be_picked = {
		is_adult = yes
		is_ruler = no
		faith = scope:actor.faith
		custom_tooltip = {
			text = ghw_heir_to_a_title
			NOT = {
				any_heir_title = {} # Not heir to anything
			}
		}
		custom_tooltip = {
			text = ghw_married_to_a_ruler
			OR = { #Either not married, or not married to a ruler.
				is_married = no
				NOT = {
					any_spouse = {
						is_ruler = yes
					}
				}
			}
		}
		custom_tooltip = {
			text = ghw_devoted_to_their_faith
			NOR = { # not dedicated to a religious career
				has_trait = devoted
				has_trait = order_member
			}
		}
	}

	has_valid_target_showing_failures_only = {
		scope:secondary_recipient = {
			NOR = {
				has_trait = excommunicated
				has_trait = incapable
				has_trait = devoted
				has_trait_with_flag = debilitating_illness
				custom_description = {
					text = "ghw_recipient_must_not_be_realm_priest"
					faith = {
						has_doctrine = doctrine_theocracy_temporal
					}
					has_council_position = councillor_court_chaplain
				}
			}
			faith = scope:actor.faith
			is_adult = yes
			trigger_if = {
				limit = {
					NOT = { OR = { government_has_flag = government_is_landless_adventurer government_has_flag = government_is_landless_minority } }
				}
				is_ruler = no
			}
			NOT = {
				any_heir_title = {} # Not heir to anything
			}
			OR = { #Either not married, or not married to a ruler.
				is_married = no
				NOT = {
					any_spouse = {
						is_ruler = yes
					}
				}
			}
		}
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = select_ghw_beneficiary_interaction_notification

				right_icon = scope:secondary_recipient

				set_beneficiary = scope:secondary_recipient
			}
		}
	}
	ai_will_do = {
		base = 0 #Assigned directly by event for the AI.
	}
}

sun_trial_interaction = {
	interface_priority = 30
	icon = religious

	category = interaction_category_prison

	is_shown = {
		scope:actor = { faith = { has_doctrine_parameter = trial_by_sun_active } }
		scope:recipient = {
			is_imprisoned_by = scope:actor
			is_adult = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			has_imprisonment_reason = scope:recipient
		}
	}


	on_accept = {
		scope:actor = {
			save_scope_as = imprisoner

			sun_trial_interaction_piety_effect = yes
		}

		scope:recipient = {
			save_scope_as = prisoner
			show_as_tooltip = {
				#Prisoner has a random outcome (toast sent through prisoner's events)
				random_list = {
					desc = outcome_in_a_few_days
					50 = { #they die without consequences! (must match event religious_interaction.2100)
						sun_trial_death_modifier = yes
						desc = sun_trial_interaction.success.tt
						sun_trial_death_effect = yes
					}
					50 = { #they are freed and super cool! (must match event religious_interaction.2100)
						sun_trial_survival_modifier = yes
						desc = sun_trial_interaction.failure.tt
						sun_trial_survival_effect = yes
					}
				}
			}
			hidden_effect = { #Nudge towards rivalry
				if = {
					limit = {
						NOR = {
							has_relation_rival = scope:actor
							has_relation_potential_rival = scope:actor
						}
					}
					set_relation_potential_rival = scope:actor
				}
			}
			#Event for outcome
			trigger_event = {
				id = religious_interaction.2100
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = major_unity_loss
			DESC = clan_unity_sun_trial.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	auto_accept = yes
}

#########################
# Literalism tenets
# by Ewan Cowhig Croft
#########################

#Engage in literalist debate.
#by Ewan Cowhig Croft
literalist_debate_interaction = {
	icon = religious
	category = interaction_category_religion
	desc = literalist_debate_interaction_desc

	is_shown = {
		scope:actor != scope:recipient
		scope:actor.faith = {
			has_doctrine_parameter = literalist_debate_enabled
		}
		scope:recipient = {
			is_playable_character = yes
			OR = {
				liege = scope:actor	#You may debate direct vassals.
				liege = scope:actor.liege	#You may debate vassals with whom you share a liege.
				scope:actor.liege = scope:recipient	#You may debate your direct liege.
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_available_adult = yes
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
		scope:recipient = {
			faith = scope:actor.faith
			is_available_adult = yes
			NOT = { has_strong_hook = scope:actor }
		}
		custom_description = {
			text = literalist_debate_interaction_has_been_debated
			object = scope:recipient
			scope:recipient = {
				NOT = { has_character_modifier = used_literalist_debate_modifier } #To prevent back and forth & back-to-back challenges
				NOT = { has_character_modifier = literally_debated_modifier }
			}
		}
		custom_description = {
			text = literalist_debate_timing
			scope:actor = {
				NOT = { has_character_modifier = used_literalist_debate_modifier }
			}
		}
	}

	auto_accept = yes

	on_accept = {
		hidden_effect = {
			scope:actor = {
				add_character_modifier = {
					modifier = used_literalist_debate_modifier
					years = 2
				}
			}
			scope:recipient = {
				trigger_event = { id = religious_interaction.2400 }
				add_character_modifier = {
					modifier = literally_debated_modifier
					years = 10
				}
			}
		}
		custom_tooltip = literalist_debate_interaction.tt_modifiers
		scope:actor = {
			stress_impact = {
				cynical = minor_stress_impact_gain
			}
			custom_tooltip = literalist_debate_interaction.tt_winnings_actor
		}
		scope:recipient = {
			custom_tooltip = literalist_debate_interaction.tt_winnings_recipient
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_loss
			DESC = clan_unity_literalist_debate.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}
}

attempt_conversion_of_local_ruler_interaction = {
	category = interaction_category_laamp
	icon = religious

	ai_maybe = yes
	ai_min_reply_days = 1
	ai_max_reply_days = 3
	popup_on_receive = yes
	common_interaction = yes

	desc = attempt_conversion_of_local_ruler_interaction_desc

	is_shown = {
		scope:actor = {
			has_government = landless_adventurer_government
			has_perk = prophet_perk
		}
		scope:recipient = {
			faith != scope:actor.faith
			is_ai = yes
			is_ruler = yes
			is_landed = yes
		}
		OR = {
			is_ai = no
			NOT = { scope:actor = { government_has_flag = government_is_landless_minority } }
		}
		OR = {
			is_ai = no
			NOT = { scope:actor = { culture = { has_cultural_tradition = tradition_diasporic } } }
		}
	}

	is_highlighted = {
		scope:actor = {
			is_character_interaction_potentially_accepted = {
				recipient = scope:recipient
				interaction = attempt_conversion_of_local_ruler_interaction
			}
		}
	}

	cooldown_against_recipient = { years = 15 }

	can_send = {
		custom_tooltip = {
			text = must_be_in_domain_tt
			scope:recipient = {
				OR = {
					capital_province ?= scope:actor.domicile.domicile_location
					any_held_title = {
						title_tier = county
						any_county_province = {
							this = scope:actor.domicile.domicile_location
						}
					}
				}
			}
		}
	}

	# Use Stress
	send_option = {
		flag = piety
		localization = USE_PIETY
	}
	send_option = {
		flag = stress
		localization = USE_STRESS
	}
	send_option = {
		is_valid = {
			scope:actor.intrigue >= scope:recipient.intrigue
		}
		flag = lie
		localization = USE_INTRIGUE
	}
	send_option = {
		is_valid = {
			scope:actor.domicile ?= {
				provisions >= {
					value = 300
					multiply = scope:recipient.highest_held_title_tier
				}
			}
			NOR = {
				scope:recipient = { has_trait = arbitrary }
				scope:recipient = { has_trait = sadistic }
				scope:recipient = { has_trait = callous }
			}
		}
		flag = provisions
		localization = USE_PROVISIONS
	}
	send_option = {
		is_valid = {
			scope:actor = {
				gold >= scope:recipient.medium_gold_value
			}
			NOR = {
				scope:recipient = { has_trait = generous }
				scope:recipient = { has_trait = humble }
			}
		}
		flag = gold
		localization = USE_GOLD
	}
	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
			NOT = {
				scope:recipient = { is_imprisoned_by = scope:actor }
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	send_options_exclusive = no
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_available = yes
		}
		valid_demand_conversion_conditions_trigger = yes
	}

	on_send = {
	}

	cost = {
		piety = {
			value = {
				add = medium_piety_value
				multiply = scope:recipient.highest_held_title_tier
				if = {
					limit = {
						scope:piety = yes
					}
					multiply = 2
				}
			}
		}
	}

	on_accept = {
		scope:actor = {
			trigger_event = religious_interaction.2002
			show_as_tooltip = {
				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
						}
					}
				}
			}
			if = {
				limit = {
					scope:stress = yes
				}
				add_stress = medium_stress_impact_gain
			}
			if = {
				limit = {
					scope:lie = yes
				}
				stress_impact = {
					honest = medium_stress_impact_gain
					forgiving = medium_stress_impact_gain
					compassionate = minor_stress_impact_gain
					just = minor_stress_impact_gain
				}
			}
			if = {
				limit = {
					scope:gold = yes
				}
				pay_short_term_gold = {
					target = scope:recipient
					gold = scope:recipient.medium_gold_value
				}
			}
			if = {
				limit = {
					scope:provisions = yes
				}
				domicile ?= {
					change_provisions = {
						value = 300
						multiply = scope:recipient.highest_held_title_tier
						multiply = -1
					}
				}
			}
		}
		demand_conversion_interaction_effect = yes
		scope:recipient = {
			if = {
				limit = {
					scope:lie = yes
				}
				stress_impact = {
					base = minor_stress_impact_gain
					paranoid = medium_stress_impact_gain
					trusting = medium_stress_impact_gain
				}
			}
			custom_tooltip = {
				text = will_not_convert_away_tt
				add_character_flag = ai_will_not_convert
			}
			add_opinion = {
				modifier = showed_me_the_light_opinion
				target = scope:actor
				opinion = 40
			}
			if = {
				limit = {
					top_liege != this
					liege ?= {
						faith != scope:actor.faith
					}
				}
				liege = {
					add_opinion = {
						modifier = annoyed_opinion
						target = scope:actor
						opinion = -20
					}
				}
			}
		}

#		scope:actor = {
#			if = {
#				limit = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = piety_from_converting_involved_rulers
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
#				add_piety = medium_piety_gain
#			}
#		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = {
				id = religious_interaction.2003
			}
			if = {
				limit = {
					scope:stress = yes
				}
				add_stress = medium_stress_impact_gain
			}
			if = {
				limit = {
					scope:lie = yes
				}
				stress_impact = {
					honest = medium_stress_impact_gain
					forgiving = medium_stress_impact_gain
					compassionate = minor_stress_impact_gain
					just = minor_stress_impact_gain
				}
			}
			if = {
				limit = {
					scope:gold = yes
				}
				pay_short_term_gold = {
					target = scope:recipient
					gold = scope:recipient.medium_gold_value
				}
			}
			if = {
				limit = {
					scope:provisions = yes
				}
				domicile ?= {
					change_provisions = {
						value = 300
						multiply = scope:recipient.highest_held_title_tier
						multiply = -1
					}
				}
			}
		}
		scope:recipient = {
			if = {
				limit = {
					scope:lie = yes
				}
				stress_impact = {
					base = minor_stress_impact_gain
					paranoid = medium_stress_impact_gain
					trusting = medium_stress_impact_gain
				}
			}
			show_as_tooltip = {
				#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
						}
					}
				}
			}
		}
	}

	ai_accept = {
		base = 0
		modifier = {
			desc = SCHEME_WEAK_HOOK_USED
			add = 20
			scope:hook = yes
		}
		modifier = {
			desc = ASK_FOR_CONVERSION_RECIPIENT_INTRIGUE
			scope:lie = yes
			add = {
				value = scope:actor.intrigue
				subtract = scope:recipient.intrigue
				min = 1
			}
		}
		modifier = {
			add = 20
			scope:piety = yes
			desc = USING_PIETY
		}
		modifier = {
			add = 20
			scope:stress = yes
			desc = USING_STRESS
		}
		modifier = {
			add = 20
			scope:gold = yes
			desc = USING_GOLD
		}
		modifier = {
			add = 20
			scope:provisions = yes
			desc = USING_PROVISIONS
		}
 		modifier = {
			scope:recipient = {
				has_trait = trusting
			}
 			add = 20
 			desc = DEMAND_SUBMISSION_RECIPIENT_IS_TRUSTING
 		}
 		modifier = {
			scope:recipient = {
				has_relation_lover = scope:actor
			}
 			add = 25
 			desc = AI_YOUR_LOVER
 		}
 		modifier = {
			scope:recipient = {
				has_relation_friend = scope:actor
			}
 			add = 25
 			desc = AI_YOUR_FRIEND
 		}
 		modifier = {
			scope:recipient = {
				is_child_of = scope:actor
			}
 			add = 50
 			desc = AI_YOUR_CHILD
 		}
		modifier = {
			add = {
				value = scope:actor.piety_level
				multiply = 10
			}
			scope:actor = {
				piety_level > 1
			}
			desc = ASK_FOR_CONVERSION_ACTOR_IS_PIOUS
		}
		modifier = {
			add = {
				value = scope:recipient.highest_held_title_tier
				subtract = 2
				multiply = -25
				if = {
					limit = {
						scope:recipient.highest_held_title_tier >= tier_duchy
					}
					multiply = 2
				}
			}
			scope:recipient.highest_held_title_tier >= tier_duchy
			desc = ASK_FOR_CONVERSION_RECIPIENT_TIER
		}
		modifier = {
			add = -25
			scope:recipient = {
				top_liege != this
				faith = liege.faith
				faith = {
					faith_hostility_level = {
						target = scope:actor.faith
						value >= faith_hostile_level
					}
				}
			}
			desc = ASK_FOR_CONVERSION_RECIPIENT_CRIME
		}
		modifier = {
			add = -50
			scope:recipient = {
				faith = {
					faith_hostility_level = {
						target = scope:actor.faith
						value >= faith_astray_level
					}
					faith_hostility_level = {
						target = scope:actor.faith
						value < faith_hostile_level
					}
				}
			}
			desc = ASK_FOR_CONVERSION_RECIPIENT_ASTRAY
		}
		modifier = {
			add = -75
			scope:recipient = {
				faith = {
					faith_hostility_level = {
						target = scope:actor.faith
						value >= faith_hostile_level
					}
					faith_hostility_level = {
						target = scope:actor.faith
						value < faith_evil_level
					}
				}
			}
			desc = ASK_FOR_CONVERSION_RECIPIENT_HOSTILE
		}
		modifier = {
			add = -100
			scope:recipient = {
				faith = {
					faith_hostility_level = {
						target = scope:actor.faith
						value >= faith_evil_level
					}
				}
			}
			desc = ASK_FOR_CONVERSION_RECIPIENT_EVIL
		}
		religion_demand_conversion_default_modifier = yes
	}
}

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

revel_in_pain_interaction = {
	icon = religious
	category = interaction_category_religion
	desc = revel_in_pain_interaction_desc

	use_diplomatic_range = yes

	greeting = positive
	notification_text = REVEL_IN_PAIN_INTERACTION_NOTIFICATION

	is_shown = {
		NOT = { scope:actor = scope:recipient }
		scope:actor = {
			faith = { has_doctrine_parameter = self_mutilation_active }
			OR = {
				has_relation_friend = scope:recipient
				has_relation_lover = scope:recipient
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_adult = yes
			is_available = yes
			custom_tooltip = {
				text = actor_is_severely_injured_tt
				NOT = { has_trait = wounded_2 }
			}
		}
		scope:recipient = {
			custom_tooltip = {
				text = recipient_involved_in_revel_in_pain_recently_tt
				NOT = { has_character_flag = involved_in_revel_in_pain_recently }
			}
			is_adult = yes
			NOT = { has_trait = craven }
			faith = { has_doctrine_parameter = self_mutilation_active }
			NOT = { is_at_war_with = scope:actor }
			custom_tooltip = {
				text = recipient_is_severely_injured_tt
				NOT = { has_trait = wounded_2 }
			}
			custom_tooltip = {
				text = recipient_not_in_the_same_location_tt
				location = scope:actor.location
			}
			is_available = yes
		}
	}

	auto_accept = {
		scope:recipient = { is_ai = yes }
	}

	on_accept = {
		scope:actor = {
			trigger_event = religious_interaction.2600
			show_as_tooltip = { revel_in_pain_effect = yes }
		}
		scope:recipient = {
			if = {
				limit = { is_ai = no }
				trigger_event = religious_interaction.2600
				show_as_tooltip = { 
					revel_in_pain_effect = yes
					revel_in_pain_opinion_effect = yes
				}
			}
			else = {
				revel_in_pain_effect = yes
				revel_in_pain_opinion_effect = yes
			}
		}
	}

	on_decline = {
		scope:actor = { 
			trigger_event = religious_interaction.2610
		}
	}

	ai_targets = {
		ai_recipients = family
		ai_recipients = scripted_relations
		ai_recipients = vassals
		ai_recipients = courtiers
		max = 5
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 36
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	ai_potential = {
		faith = { has_doctrine_parameter = self_mutilation_active }
		is_at_war = no
		OR = {
			has_trait = zealous
			has_trait = sadistic
		}
		NOR = { 
			has_trait = craven
			has_trait = wounded_1
			has_trait = wounded_2
		}
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = ai_boldness
		}
		modifier = {
			has_trait = flagellant
			add = 25
		}		
	}
}
