﻿# 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 = ask_for_conversion_interaction_desc

	hidden = yes
	
	is_shown = {
		NOT = { scope:actor.faith = scope:recipient.faith }
		scope:recipient.liege = scope:actor
		
		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}

	is_valid_showing_failures_only = {
		valid_demand_conversion_conditions_trigger = yes
	} 
	
	ai_accept = {
		base = 0
		religion_demand_conversion_default_modifier = yes
	}
	
	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

		scope:actor = {
			hidden_effect = {
				if = {
					limit = { 
						AND = {
							exists = scope:actor.var:RE_court_stew_2_var
							scope:actor.var:RE_court_stew_2_var <= 97
						}
					}
					scope:actor = {
						change_variable = {
							name = RE_court_stew_2_var
							add = 3
						}
						RE_axis_recount_stew = yes
					}
				}
				else_if = {
					limit = { 
						exists = scope:actor.var:RE_court_stew_2_var
					}
					scope:actor = {
						set_variable = {
							name = RE_court_stew_2_var
							value = 100
						}
					}
				}
				else = {}
			}
			#AGOT Disabled
		# 	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 = {
		send_interface_message = {
			type = event_generic_neutral
			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
	}

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

#AGOT Disabled
# 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 = 12
	
# 	is_shown = {
# 		NOT = { scope:actor.faith = scope:recipient.faith }
# 		scope:recipient = { is_courtier_of = scope:actor }
# 		scope:recipient = { is_ruler = no }
# 		scope:recipient = { is_imprisoned = no }
# 	}

# 	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 }
# 		}
# 	}
	
# 	ai_min_reply_days = 1
# 	ai_max_reply_days = 5
	
# 	on_accept = {
# 		demand_conversion_interaction_effect = yes
# 		hidden_effect = {
# 			scope:actor = {
# 				send_interface_message = {	
# 					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

# 		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 = {
# 				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
# 	}

# 	# 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_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
# 				faith = {
# 					faith_hostility_level = {
# 						target = scope:recipient.faith
# 						value <= faith_fully_accepted_level
# 					}
# 				}
# 			}
# 			NOT = {
# 				scope:recipient = {
# 					is_close_family_of = scope:actor
# 				}
# 			}
# 		}

# 		modifier = { # Astray faiths require specific circumstances to demand conversion of
# 			factor = 0
# 			scope:actor = {
# 				has_tolerant_faith_or_culture_trigger = yes
# 				ai_zeal < 50
# 				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 < 0
# 				faith = {
# 					faith_hostility_level = {
# 						target = scope:recipient.faith
# 						value <= faith_astray_level
# 					}
# 				}
# 			}
# 			NOT = {
# 				scope:recipient = {
# 					is_close_family_of = scope:actor
# 				}
# 			}
# 		}
# 	}
# }

#AGOT Disabled
# 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 = {
# 		NOT = { scope:recipient = scope:actor }
# 		scope:actor = {
# 			is_house_head = yes
# 			NOT = { faith = scope:recipient.faith }
# 			house = scope:recipient.house
# 		}
# 		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
# 		}
# 	}

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

# 	on_decline = {
# 		scope:recipient = {
# 			execute_decision = create_cadet_branch_decision
# 			show_as_tooltip = { create_cadet_branch = yes }
# 		}
# 		#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
# 	}

# 	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_options_exclusive = no
# }

#AGOT Disabled
# demand_conversion_vassal_ruler_interaction = {
# 	category = interaction_category_religion
# 	icon = religious

# 	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 = 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 = {
# 			target_is_liege_or_above = scope:actor
# 			NOT = { faith = scope:actor.faith }
# 			is_ai = yes
# 			is_ruler = yes
# 		}
# 	}

# 	cooldown_against_recipient = { years = 15 }

# 	is_valid_showing_failures_only = {
# 		valid_demand_conversion_conditions_trigger = yes
# 	}

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

# 	on_send = {
# 	}


# 	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

# 		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 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_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
# 				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
# 							}
# 						}
# 					}
# 				}
# 			}
# 			NOT = {
# 				scope:recipient = {
# 					is_close_family_of = scope:actor
# 				}
# 			}
# 		}

# 		modifier = { # Astray faiths require specific circumstances to demand conversion of
# 			factor = 0
# 			scope:actor = {
# 				has_tolerant_faith_or_culture_trigger = yes
# 				ai_zeal < 50
# 				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 < 0
# 				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
# 							}
# 						}
# 					}
# 				}
# 			}
# 		}
# 	}
# 	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
# 		}
# 	}
# }

#AGOT Disabled
# 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 = 120

# 	is_shown = {
# 		scope:recipient = {
# 			is_ai = no
# 			target_is_liege_or_above = scope:actor
# 			NOT = { faith = scope:actor.faith }
# 		}
# 	}

# 	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

# 		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
# 	}
	
# 	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
# 				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
# 							}
# 						}
# 					}
# 				}
# 			}
# 			NOT = {
# 				scope:recipient = {
# 					is_close_family_of = scope:actor
# 				}
# 			}
# 		}

# 		modifier = { # Astray faiths require specific circumstances to demand conversion of
# 			factor = 0
# 			scope:actor = {
# 				has_tolerant_faith_or_culture_trigger = yes
# 				ai_zeal < 50
# 				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 < 0
# 				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
# 				}
# 			}
# 		}
# 	}
# }

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 = {
		NOT = { scope:actor.faith = scope:recipient.faith }
		scope:actor = {
			# They're either your liege or your spouse
			OR = {
				target_is_liege_or_above = scope:recipient
				any_consort = {
					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
				}
			}
		}
		# AGOT Added - human check
		scope:recipient = {
			is_human = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = { is_busy_in_events_localised = yes }
	}

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

	ai_accept = {
		base = 0
	}

	ai_will_do = {
		base = 0
	}
}

#AGOT Disabled
# 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 = {
# 		NOT = {
# 			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 = {
# 		scope:recipient = { is_busy_in_events_localised = yes }
# 	}

	
# 	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 = 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 = {
		NOT = {
			scope:recipient = scope:actor
		}
		scope:actor.faith = {
			religious_head = scope:recipient
			#AGOT Modified
			#has_doctrine = tenet_communion
			OR = {
				has_doctrine = tenet_communion
				has_doctrine = tenet_the_most_devout
			}
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
		scope:secondary_recipient = { is_human = yes }
	}

	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 = 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 = kinslayer_2 GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = witch
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = witch GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = deviant
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = deviant GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = sodomite
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith 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 = kinslayer_1 GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = fornicator
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = fornicator GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = adulterer
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith 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
			}
		}
		scope:recipient = { is_busy_in_events_localised = yes }
	}
	
	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 = 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 = {
		NOT = {
			scope:recipient = scope:actor
		}
		scope:actor = {
			has_trait = excommunicated
			faith = {
				religious_head = scope:recipient
				#AGOT Modified
				#has_doctrine = tenet_communion
				OR = {
					has_doctrine = tenet_communion
					has_doctrine = tenet_the_most_devout
				}
			}
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = {
				has_character_modifier = recent_excommunication
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
		scope:recipient = { is_busy_in_events_localised = yes }
	}
	
	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
				}
			}
		}

		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 = 72

	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
			#AGOT Modified
			#has_doctrine = tenet_communion
			OR = {
				has_doctrine = tenet_communion
				has_doctrine = tenet_the_most_devout
			}
			has_doctrine = doctrine_spiritual_head
		}

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

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

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}

	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 = {	
					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 = 36

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

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:recipient = { is_busy_in_events_localised = yes }
		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 = 72

	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

	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
			#AGOT Modified
			#has_doctrine = tenet_communion
			OR = {
				has_doctrine = tenet_communion
				has_doctrine = tenet_the_most_devout
			}
			has_doctrine = doctrine_spiritual_head
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}

	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:recipient = { is_busy_in_events_localised = yes }
		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 = 36

	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 = {
			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.faith = {
			any_faith_holy_order = { #Your faith must have a Holy Order
				always = yes
			}
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}
	
	is_valid_showing_failures_only = {

		scope:recipient = {
			#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
			}
			
			hidden_effect = {
				if = {
					limit = { 
						AND = {
							exists = scope:actor.var:RE_court_intr_2_var
							scope:actor.var:RE_court_intr_2_var >= 5
						}
					}
					scope:actor = {
						change_variable = {
							name = RE_court_intr_2_var
							add = -5
						}
						RE_axis_recount_intr = yes
					}
				}
				else_if = {
					limit = { 
						exists = scope:actor.var:RE_court_intr_2_var
					}
					scope:actor = {
						set_variable = {
							name = RE_court_intr_2_var
							value = 0
						}
					}
				}
				else = {}
			}
			
			# 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 = {
						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
				}
			}
			desc = TAKE_THE_VOWS_HEIR
		}
		
		modifier = {
			add = -100
			scope:recipient = {
				NOT = { is_heir_of = scope:actor }
				any_heir_title = {
					exists = holder
					NOT = {
						holder = scope:actor
					}
					place_in_line_of_succession = {
						target = scope:recipient
						value < 2
					}
				}
				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_heir_title = {
					exists = holder
					NOT = {
						holder = scope:actor
					}
					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 = 72

	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 = {
					count >= 1
				}
			}
			scope:recipient = {
				NOT = {
					is_child_of = scope:actor
				}
				any_claim = {
					exists = holder
					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
#AGOT Disabled
# take_vows_interaction = {
# 	category = interaction_category_friendly
# 	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 = {
# 			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 = {
# 			has_doctrine_parameter = take_vows_active # Faith has Monastery order that recipient can be sent to
# 		}
# 	}
	
# 	is_valid_showing_failures_only = {

# 		scope:recipient = {
# 			age >= 10
# 			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 }
# 				}
# 				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
# 					scope:recipient = {
# 						is_close_family_of = scope:actor
# 					}
# 				}
# 				faith.religious_head = {
# 					add_opinion = {
# 						target = scope:actor
# 						modifier = pious_opinion
# 						opinion = 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 = {
# 						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
# 				}
# 			}
# 			desc = TAKE_THE_VOWS_HEIR
# 		}
		
# 		modifier = {
# 			add = -100
# 			scope:recipient = {
# 				NOT = { is_heir_of = scope:actor }
# 				any_heir_title = {
# 					exists = holder
# 					NOT = {
# 						holder = scope:actor
# 					}
# 					place_in_line_of_succession = {
# 						target = scope:recipient
# 						value < 2
# 					}
# 				}
# 				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_heir_title = {
# 					exists = holder
# 					NOT = {
# 						holder = scope:actor
# 					}
# 					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 = 72

# 	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 = {
# 					count >= 1
# 				}
# 			}
# 			scope:recipient = {
# 				NOT = {
# 					is_child_of = scope:actor
# 				}
# 				any_claim = {
# 					exists = holder
# 					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 = temporal_condemnation_interaction_desc
	icon = religious

	is_shown = {
		NOT = { scope:actor = scope:recipient }
		scope:actor.faith = {
			has_doctrine_parameter = temporal_condemnation_enabled
		}
		scope:recipient = {
			liege = scope:actor
		}
		scope:recipient = {
			is_landed = yes
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = 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 faith = 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 } }
		scope:recipient = { is_busy_in_events_localised = yes }
	}

	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 = {	
					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 = 60

	cooldown = { years = 1 }

	is_shown = {
		NOT = {
			scope:recipient = scope:actor
		}
		scope:actor = {
			is_landed = yes
			is_adult = yes
			faith = {
				has_doctrine_parameter = host_honored_guests_active
			}
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}

	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 = {	
					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 = 24
	
	cooldown_against_recipient = { years = 3 }

	is_shown = {
		NOT = {
			scope:recipient = scope:actor
		}
		scope:actor.faith = {
			religious_head = scope:recipient
			has_doctrine = doctrine_spiritual_head
		}
		scope:actor = {
			is_landed = 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 }
				}
			}
		}
		scope:recipient = { is_busy_in_events_localised = yes }
	}
	
	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 = 1
		}
		
		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 a Kinslayer
			add = -15
			desc = I_AM_A_KINSLAYER
			scope:actor = {
				has_trait_rank = {
					trait = kinslayer
					rank >= 1
				}
			}
		}
		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 = 10
				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
		}
	}
	
	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
		}
	}
	
	send_option = {
		is_shown = {
			NOT = { 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_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_landed = yes
		piety >= major_piety_value
		NOT = { has_trait = excommunicated }
		highest_held_title_tier > tier_barony
		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 
			is_independent_ruler = no
			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
		}
	}
}

hof_ask_for_claim_interaction = {
	category = interaction_category_diplomacy
	icon = religious_claim

	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_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 = yes
			primary_title = { tier >= tier_county }
			NOT = { government_has_flag = government_is_holy_order }

			#AGOT Added, must be criminal to get claim
			OR = {
				scope:secondary_recipient = {
					has_trait = murderer
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = incestuous
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = kinslayer
					}
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = adulterer
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = deviant
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = witch
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = sodomite
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:secondary_recipient = {
						has_trait = cannibal
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
			}

			#AGOT Added, no ruin claims
			NOT = { has_government = ruins_government }

			#AGOT Added, no NW claims
			NOT = { has_government = nights_watch_government }

			NOT = { any_liege_or_above = { has_government = nights_watch_government } }

			#AGOT Added, no Silent Sister claims
			NOT = { has_government = silent_sisterhood_government }
			NOT = { any_liege_or_above = { has_government = silent_sisterhood_government } }
		}
		#AGOT Added, no NW claims
		NOT = {
			scope:actor = { has_government = nights_watch_government }
			scope:actor = {
				any_liege_or_above = { has_government = nights_watch_government }
			}
		}
	}
	
	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	
			}	
		}
		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:recipient = { is_busy_in_events_localised = yes }
		scope:secondary_recipient = { NOT = { has_strong_hook = scope:actor } }
		
		# AGOT Added, only buy claims on titles a tier higher one than you
		custom_description = {
			text = hof_ask_for_claim_must_higher_one_tier
			scope:actor = {
				tier_difference = {
					target = scope:secondary_recipient
					value >= -1
				}
			}
		}
	}
	
	ai_targets = {
		ai_recipients = neighboring_rulers
		ai_recipients = peer_vassals
		ai_recipients = liege
	}
	ai_frequency = 36
	
	ai_potential = {
		is_landed = yes
		OR = {
			ai_greed >= 50
			ai_has_warlike_personality = yes
		}
		piety >= major_piety_value
		NOT = { has_trait = excommunicated }
		exists = faith.religious_head
		highest_held_title_tier > tier_barony
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = scope:actor.ai_greed
		}

		modifier = {
			add = scope:target.tier
		}

		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 = -50
			desc = BASE_RELUCTANCE
		}
		
		modifier = { # Practically impossible to claim Kingdoms/Empires when already King/Emperor
			add = -1000
			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 = -200
			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
			add = {
				if = {
					limit = {
						NOT = { 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 a Kinslayer
			add = -15
			desc = I_AM_A_KINSLAYER
			scope:actor = {
				has_trait_rank = {
					trait = kinslayer
					rank >= 1
				}
			}
		}
		
		modifier = { # They are a Kinslayer
			add = 15
			desc = THEY_ARE_A_KINSLAYER
			scope:secondary_recipient = {
				has_trait_rank = {
					trait = kinslayer
					rank >= 1
				}
			}
		}
		
		modifier = { # They are of the same dynasty as the Head of Faith
			add = -5
			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 = 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 = { # They are of the same house as the Head of Faith
			add = -10
			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 = 10
				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 = -10
				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
			}
		}
	}

	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 = {
		is_shown = {
			NOT = { 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
	
#AGOT Disabled
# 	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 = { is_independent_ruler = yes }
# 		NOT = { exists = scope:actor.faith.great_holy_war.ghw_war }
# 		NOT = { 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
# 		NOT = { 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.
# 		scope:recipient = { is_busy_in_events_localised = yes }
# 	}
	
# 	has_valid_target_showing_failures_only = {
# 		exists = scope:target
# 		scope:target.tier = tier_kingdom
# 		NOT = { 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 = {
# 					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_landed = 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

	#AGOT Added
	hidden = yes

	#AGOT Disabled
	# populate_recipient_list = {
	# 	scope:recipient = {
	# 		#Any member of your own house.
	# 		house = {
	# 			every_house_member = {
	# 				limit = {
	# 					# Cannot select them self as beneficiary
	# 					NOT = { 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
	# 				NOT = { 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
	# 			}
	# 		}
	# 	}
	# }
	
	# 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
	# 	}
	# 	NOT = { 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
	# 				}
	# 			}
	# 		}
	# 	}
	# }

	# has_valid_target_showing_failures_only = {
	# 	scope:secondary_recipient = {
	# 		NOR = {
	# 			has_trait = excommunicated
	# 			has_trait = incapable
	# 			has_trait = devoted
	# 			has_serious_disease_trigger = yes
	# 			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
	# 		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
	# 				}
	# 			}
	# 		}
	# 	}
	# 	scope:recipient = { is_busy_in_events_localised = yes }
	# }
	
	# on_accept = {
	# 	scope:actor = {
	# 		send_interface_toast = {
	# 			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
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = 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 = {
		NOT = { scope:actor = scope:recipient }
		scope:actor.faith = {
			has_doctrine_parameter = literalist_debate_enabled
		}
		scope:recipient = {
			is_landed = 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.
			}
		}

		#AGOT Added, no non-human interactions
		scope:actor = { is_human = yes }
		scope:recipient = { is_human = yes }
	}
	is_valid_showing_failures_only = {
		scope:actor = {
			is_adult = yes
		}
		scope:recipient = {
			faith = scope:actor.faith
		}
		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 }
			}
		}
		scope:recipient = {
			is_adult = yes
		}
		scope:recipient = {
			NOT = { has_strong_hook = scope:actor }
		}
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:actor = {
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
	}

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