﻿#Character interactions relating to schemes

start_murder_interaction = {
	icon = icon_scheme_murder
	common_interaction = yes
	interface_priority = 90
	category = interaction_category_hostile

	ignores_pending_interaction_block = yes

	scheme = murder

	send_name = START_SCHEME

	is_shown = {
		exists = scope:puppet_or_actor
		scope:recipient != scope:puppet_or_actor

		NAND = { # Game Rules!
			has_game_rule = no_players_multiplayer_murder_schemes
			scope:actor = {
				is_ai = no
			}
			scope:recipient = {
				is_ai = no
			}
		}

		NAND = {
			has_game_rule = no_player_families_multiplayer_murder_schemes
			scope:actor = {
				is_ai = no
			}
			scope:recipient = {
				OR = {
					is_ai = no
					any_close_family_member = {
						AND = {
							is_ai = no
							this != scope:actor
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			can_start_scheme = {
				type = murder
				target_character = scope:recipient
			}
		}
		scope:recipient = { NOT = { has_strong_hook = scope:puppet_or_actor } }
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
		trigger_if = {
			limit = { scope:puppet_or_actor = { has_variable = no_scheming_allowed_var } }
			custom_tooltip = {
				text = no_scheming_allowed_var_tt
				scope:puppet_or_actor.var:no_scheming_allowed_var != scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:puppet_or_actor = {
					can_start_scheme = {
						type = murder
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_murder_approved
		}
	}

	# Scheme Starter Packages
	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	## Balanced agents.
	send_option = {
		flag = agent_focus_balance
		current_description = start_murder_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_murder_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_murder_interaction.tt.agent_focus_speed
	}
	## Focused on Secrecy.
	send_option = {
		flag = agent_focus_secrecy
		current_description = start_murder_interaction.tt.agent_focus_secrecy
	}

	on_send = {
		scope:puppet_or_actor = {
			if = {
				limit = {
					OR = {
						has_character_modifier = pam_granted_indulgences_modifier
						has_character_modifier = pam_granted_indulgences_modifier_small
					}
				}
				change_spiritual_fulfillment = major_spiritual_fulfillment_loss
			}
		}
	}
	on_accept = {
		scope:puppet_or_actor = {
			if = { # Only get stressed/SP penalties if you don't have the parameter
				limit = {
					NOT = { has_fulfillment_parameter = sp_murder_yields_no_sp_or_stress_loss }
				}
				stress_and_fulfillment_impact = {
					compassionate = major_stress_impact_gain
					honest = medium_stress_impact_gain
					just = medium_stress_impact_gain
				}
			}
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_murder_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = murder
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_assassin
						AGENT_2 = agent_assassin
						AGENT_3 = agent_thug
						# Speed.
						AGENT_4 = agent_infiltrator
						# Secrecy.
						AGENT_5 = agent_alibi
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = murder
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Speed.
						AGENT_1 = agent_infiltrator
						AGENT_2 = agent_infiltrator
						AGENT_3 = agent_footpad
						# Success.
						AGENT_4 = agent_assassin
						# Secrecy.
						AGENT_5 = agent_alibi
					}
				}
				# Secrecy.
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = murder
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Secrecy.
						AGENT_1 = agent_alibi
						AGENT_2 = agent_alibi
						AGENT_3 = agent_lookout
						# Success.
						AGENT_4 = agent_assassin
						# Speed.
						AGENT_5 = agent_infiltrator
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = murder
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_assassin
						AGENT_2 = agent_assassin
						# Speed.
						AGENT_3 = agent_infiltrator
						AGENT_4 = agent_footpad
						# Secrecy.
						AGENT_5 = agent_alibi
					}
				}
			}
			# Plus any on_start modifiers we may need.
			if = {
				limit = { var:feast_events_ewan_0001_bonus_value ?= scope:recipient }
				# Hand over the modifier.
				random_scheme = {
					type = murder
					limit = {
						scheme_target_character = scope:recipient
					}
					add_scheme_modifier = { type = feast_learnt_habits_modifier }
				}
				# Remove the variable now that we're done with it.
				remove_variable = feast_events_ewan_0001_bonus_value
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = start_murder_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
	}

	auto_accept = yes

	# AI for murders is handled in event murder_scheme_maintenance.1, fired from the five_year_playable_pulse
}

start_abduct = {
	icon = icon_scheme_abduct
	interface_priority = 70
	category = interaction_category_hostile

	send_name = START_SCHEME

	scheme = abduct
	ignores_pending_interaction_block = yes

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			is_diarch = yes
			liege ?= { has_diarchy_active_parameter = diarchy_is_co_rulership }
			ai_diarch_would_maim_execute_superior_if_got_chance_trigger = { LIEGE = liege }
		}
	}

	is_shown = {
		scope:puppet_or_actor ?= {
			OR = {
				has_perk = kidnapper_perk  # Scheme unlocked by the Kidnapper Perk
				domicile ?= { has_domicile_parameter = camp_unlocks_abduct_scheme }
#				AND = {
#					any_character_struggle = {
#						involvement = involved
#						has_struggle_phase_parameter = unlocks_abduct_for_all
#						is_secondary_character_involvement_involved_trigger = {
#							CHAR = scope:recipient
#						}
#					}
#				}
			}
		}

		NOR = {
			scope:recipient = scope:puppet_or_actor
			scope:recipient = { is_imprisoned_by = scope:puppet_or_actor }
		}
		#exists = scope:recipient.court_owner

		NAND = { # Game Rules!
			has_game_rule = no_players_multiplayer_murder_schemes
			scope:actor = {
				is_ai = no
			}
			scope:recipient = {
				is_ai = no
			}
		}

		NAND = {
			has_game_rule = no_player_families_multiplayer_murder_schemes
			scope:actor = {
				is_ai = no
			}
			scope:recipient = {
				OR = {
					is_ai = no
					any_close_family_member = {
						AND = {
							is_ai = no
							this != scope:actor
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			can_start_scheme = {
				type = abduct
				target_character = scope:recipient
			}
		}
		scope:recipient = { NOT = { has_strong_hook = scope:puppet_or_actor } }
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
		trigger_if = {
			limit = { scope:puppet_or_actor = { has_variable = no_scheming_allowed_var } }
			custom_tooltip = {
				text = no_scheming_allowed_var_tt
				scope:puppet_or_actor.var:no_scheming_allowed_var != scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:puppet_or_actor = {
					can_start_scheme = {
						type = abduct
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_abduct_approved
		}
	}

	# Scheme Starter Packages
	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	## Balanced agents.
	send_option = {
		flag = agent_focus_balance
		current_description = start_abduct.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_abduct.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_abduct.tt.agent_focus_speed
	}
	## Focused on Secrecy.
	send_option = {
		flag = agent_focus_secrecy
		current_description = start_abduct.tt.agent_focus_secrecy
	}

	on_send = {
		scope:puppet_or_actor = {
			if = {
				limit = {
					OR = {
						has_character_modifier = pam_granted_indulgences_modifier
						has_character_modifier = pam_granted_indulgences_modifier_small
					}
				}
				change_spiritual_fulfillment = medium_spiritual_fulfillment_loss
			}
		}
	}

	on_accept = {
		scope:puppet_or_actor = {  # Only get stressed/SP penalties if you don't have the parameter
			if = {
				limit = {
					NOT = { sp_hostile_schemes_except_murder_no_stress_or_fulfillment_trigger = yes }
				}
				stress_and_fulfillment_impact = {
					compassionate = medium_stress_impact_gain
					honest = minor_stress_impact_gain
					just = minor_stress_impact_gain
				}
			}
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_abduct_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = abduct
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_thug
						AGENT_2 = agent_thug
						AGENT_3 = agent_muscle
						# Speed.
						AGENT_4 = agent_footpad
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = abduct
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Speed.
						AGENT_1 = agent_footpad
						AGENT_2 = agent_footpad
						AGENT_3 = agent_infiltrator
						# Success.
						AGENT_4 = agent_thug
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
				# Secrecy.
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = abduct
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Secrecy.
						AGENT_1 = agent_lookout
						AGENT_2 = agent_lookout
						AGENT_3 = agent_decoy
						# Success.
						AGENT_4 = agent_thug
						# Speed.
						AGENT_5 = agent_footpad
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = abduct
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_thug
						AGENT_2 = agent_muscle
						# Speed.
						AGENT_3 = agent_footpad
						AGENT_4 = agent_infiltrator
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = start_abduct_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
		scope:puppet_or_actor = { save_scope_as = owner }
		scope:recipient = { save_scope_as = target}
		abduction_rivalry_progress_tooltip_forecast_effect = yes
	}

	ai_targets = { ai_recipients = liege }
	ai_frequency_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 0
		hegemony = 0
	}

	ai_will_do = {
		# They shouldn't always do this.
		base = -100

		# Obvious factor.
		opinion_modifier = {
			opinion_target = scope:recipient
			multiplier = -1
		}
		ai_value_modifier = { ai_honor = -1 }
		# Traits.
		## Disloyal.
		modifier = {
			add = 100
			has_trait = disloyal
		}
		## Ambitious.
		modifier = {
			add = 75
			has_trait = ambitious
		}
		## Arrogant.
		modifier = {
			add = 25
			has_trait = arrogant
		}
		## Fickle.
		modifier = {
			add = 25
			has_trait = fickle
		}
		## Callous.
		modifier = {
			add = 25
			has_trait = callous
		}
		## Compassionate.
		modifier = {
			add = -50
			has_trait = compassionate
		}
		## Humble.
		modifier = {
			add = -50
			has_trait = humble
		}
		## Content.
		modifier = {
			add = -100
			has_trait = content
		}
		## Loyal.
		modifier = {
			add = -300
			has_trait = loyal
		}
		# Time as a diarch — the longer they've been waiting, the more eager they are.
		modifier = {
			add = {
				value = years_as_diarch
				multiply = 2
			}
			always = yes
		}
		#Promised to abstain from sin
		modifier = {
			OR = {
				has_character_modifier = pam_granted_indulgences_modifier
				has_character_modifier = pam_granted_indulgences_modifier_small
			}
			factor = 0.1
		}
	}

	auto_accept = yes
}

end_scheme = {
	special_interaction = remove_scheme_interaction
	use_diplomatic_range = no
	hidden = yes
	on_accept = {
		scope:scheme = {
			end_scheme = yes
		}
	}

	auto_accept = yes
	ignores_pending_interaction_block = yes
}

befriend_interaction = {
	icon = icon_scheme_befriend
	category = interaction_category_friendly

	interface_priority = 90
	scheme = befriend

	send_name = START_SCHEME
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
		ai_recipients = neighboring_rulers
	}
	ai_targets = {
		ai_recipients = vassals
		ai_recipients = peer_vassals
		chance = 0.25
	}

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

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			OR = {
				has_perk = befriend_perk # Unlocked by the Befriend Perk
				culture ?= { has_cultural_parameter = automatic_befriend_access }
#				any_character_struggle = {
#					involvement = involved
#					has_struggle_phase_parameter = struggle_unlocks_befriend_schemes_for_everyone
#				}
				house ?= { has_house_aspiration_parameter = aspect_of_serenity }
				dynasty ?= {
					has_dynasty_perk = fp1_adventure_legacy_5
				}
			}
			NOR = {
				has_trait = shy
				has_trait = callous
				AND = { # No one cares about City barons
					is_lowborn = yes
					primary_title.tier <= tier_barony
				}
				any_scheme = {
					OR = {
						scheme_type = befriend
						#scheme_type = sway # We allow the AI to override Sway with Befriend
						scheme_type = seduce
						scheme_type = courting
						scheme_type = elope
						scheme_type = learn_language
						scheme_type = teach_governor
					}
				}
			}
		}
	}

	is_shown = {
		scope:puppet_or_actor ?= {
			can_use_befriend_scheme_trigger = { TARGET = scope:recipient }
		}
		scope:puppet_or_actor != scope:recipient
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			can_start_scheme = {
				type = befriend
				target_character = scope:recipient
			}
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
		trigger_if = {
			limit = { scope:is_puppet_action ?= yes }
			scope:puppet_or_actor = {
				prestige >= befriend_interaction_cost_value
			}
		}
	}

	cost = {
		prestige = {
			value = befriend_interaction_cost_value
			if = {
				limit = { scope:is_puppet_action ?= yes }
				multiply = 0
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:puppet_or_actor = {
					NOT = { is_at_war_with = scope:recipient }
					can_start_scheme = {
						type = befriend
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_befriend_approved
		}
	}

	on_accept = {
		if = {
			limit = { scope:is_puppet_action ?= yes }
			scope:puppet_or_actor = {
				if = {
					limit = { befriend_interaction_cost_value > 0 }
					add_prestige = {
						value = {
							add = befriend_interaction_cost_value
							max = prestige
							multiply = -1
						}
					}
				}
			}
		}
		scope:puppet_or_actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = befriend_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = befriend
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = befriend_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
		if = { #Stubborness effect
			limit = {
				scope:recipient = {
					has_trait = stubborn
				}
			}
			scope:puppet_or_actor = {
				random_scheme = {
					type = befriend
					limit = {
						scheme_target_character = scope:recipient
					}
					scheme_target_character = {
						random_list = {
							20 = {
								set_variable = {
									name = recipient_stubborness_scheme
									value = -5
								}
							}
							20 = {
								set_variable = {
									name = recipient_stubborness_scheme
									value = -10
								}
							}
							20 = {
								set_variable = {
									name = recipient_stubborness_scheme
									value = -15
								}
							}
							20 = {
								set_variable = {
									name = recipient_stubborness_scheme
									value = -20
								}
							}
							20 = {
								set_variable = {
									name = recipient_stubborness_scheme
									value = -25
								}
							}
						}
					}
				}
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 50

		modifier = { # Try to befriend those who you might want to vassalize
			add = 30
			scope:puppet_or_actor = {
				top_liege = this
				primary_title.tier >= tier_county
				NOT = {
					any_targeting_faction = {
						OR = {
							faction_is_type = liberty_faction
							faction_is_type = claimant_faction
							faction_is_type = independence_faction
						}
					}
				}
			}
			scope:recipient = {
				top_liege = this
				is_playable_character = yes
				primary_title.tier < scope:puppet_or_actor.primary_title.tier
				OR = {
					faith.religion = scope:puppet_or_actor.faith.religion
					AND = {
						rite = {
							rite_has_doctrine = doctrine_pluralism_pluralistic
						}
						scope:puppet_or_actor.rite = {
							rite_has_doctrine = doctrine_pluralism_pluralistic
						}
					}
				}
			}
		}

		modifier = {
			factor = 0.1
			scope:puppet_or_actor = {
				opinion = {
					target = scope:recipient
					value < -50
				}
			}
		}

		modifier = {
			factor = 0.1
			scope:recipient = {
				opinion = {
					target = scope:puppet_or_actor
					value > 50
				}
			}
		}

		modifier = {
			factor = 0.5
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:puppet_or_actor
					value < 2
				}
			}
		}

		modifier = {
			factor = 0.1
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:puppet_or_actor
					value < 1
				}
			}
		}

		# Struggle
#		modifier = {
#			scope:puppet_or_actor = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_friend_lover_with_character
#				}
#			}
#			scope:recipient = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_friend_lover_with_character
#				}
#			}
#			add = {
#				value = 0
#				if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_deescalation
#							trait_compatibility = {
#								target = scope:recipient
#								value >= low_positive_trait_compatibility
#							}
#						}
#						scope:recipient = {
#							has_character_flag = agenda_towards_deescalation
#						}
#					}
#					add = 200
#				}
#				else_if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_deescalation
#							trait_compatibility = {
#								target = scope:recipient
#								value >= low_positive_trait_compatibility
#							}
#						}
#					}
#					add = 50
#				}
#				else_if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_escalation
#						}
#					}
#					add = -200
#				}
#				else = {
#					add = 10
#				}
#			}
#		}

		modifier = {
			factor = 25
			OR = {
				has_focus = diplomacy_family_focus
				house ?= { has_house_aspiration_parameter = aspect_of_serenity }
			}	
		}

		modifier = {
			factor = 2
			scope:recipient.liege = scope:puppet_or_actor
		}

		modifier = {
			factor = 0.5
			scope:recipient.faith != scope:puppet_or_actor.faith
		}

		modifier = {
			factor = 0.25
			scope:puppet_or_actor = {
				is_ruler = yes
				tier_difference = {
					target = scope:recipient
					value > 2
				}
			}
		}
		modifier = {
			factor = 0.35
			scope:puppet_or_actor = {
				has_personality_malicious_trigger = yes
			}
		}
		modifier = {
			factor = 2
			scope:puppet_or_actor = {
				OR = {
					has_trait = gregarious
					has_trait = diplomat
					has_trait = family_first
					has_trait = august
				}
			}
		}
		modifier = {
			factor = 1.5
			scope:puppet_or_actor = {
				num_of_relation_friend < 3
			}
		}
		modifier = { #Better to Court rather than befriend.
			factor = 0.25
			scope:puppet_or_actor = {
				is_spouse_of = scope:recipient
			}
		}
		modifier = {
			factor = 0.75
			scope:recipient = {
				is_child_of = scope:puppet_or_actor
			}
		}
		modifier = {
			factor = 2
			scope:puppet_or_actor = {
				is_child_of = scope:recipient
			}
		}
		modifier = {
			factor = 2
			scope:puppet_or_actor = { #Friends of friends
				any_relation = {
					type = friend
					any_relation = {
						type = friend
						this = scope:recipient
					}
				}
			}
		}
		modifier = {
			factor = 0.25
			scope:recipient = {
				any_claim = {
					this = scope:puppet_or_actor.primary_title
				}
			}
		}
	}
}

seduce_interaction = {
	icon = icon_scheme_seduce
	category = interaction_category_friendly
	interface_priority = 45
	scheme = seduce
	common_interaction = no

	send_name = START_SCHEME
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = family
		max = 2
	}
	ai_targets = {
		ai_recipients = guests
		ai_recipients = courtiers
		max = 10
	}
	ai_targets = {
		ai_recipients = neighboring_rulers
		max = 5
	}
	ai_targets = {
		ai_recipients = vassals
		max = 5
	}
	ai_targets = {
		ai_recipients = peer_vassals
		max = 5
	}

	# We don't want this to grow ludicrously large in big realms
	ai_targets = {
		ai_recipients = realm_characters
		max = 10
	}

	ai_target_quick_trigger = {
		adult = yes
		attracted_to_owner = yes
		owner_attracted = yes
	}

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

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			is_adult = yes
			NOR = {
				has_trait = chaste
				AND = { # No one cares about City barons
					is_lowborn = yes
					primary_title.tier <= tier_barony
				}
				has_trait = celibate
				primary_title ?= {
					is_mercenary_company = yes
				}
				scheme_generic_ai_blocker_trigger = yes
				has_character_modifier = clerical_chastity_vow_modifier
			}
			might_cheat_on_every_partner_trigger = yes
		}
	}

	is_shown = {
		scope:puppet_or_actor ?= { is_adult = yes }
		scope:puppet_or_actor != scope:recipient
		scope:recipient = { is_adult = yes }

		# Avoid seducing lowborn nobodies in foreign courts
		trigger_if = {
			limit = {
				scope:actor = { is_ai = yes }
			}
			NOT = {
				scope:recipient = {
					is_lowborn = yes
					is_playable_character = no
					NOR = {
						is_courtier_of = scope:puppet_or_actor
						is_foreign_court_or_pool_guest_of = scope:puppet_or_actor
					}
				}
			}
		}
		scope:puppet_or_actor ?= { # Some early filtering for the AI to focus it towards fruitful seductions
			trigger_if = {
				limit = {
					scope:actor = { is_ai = yes }
				}
				trigger_if = { # Deviants will seduce anyone
					limit = {
						is_deviant_trigger = yes
					}
				}
				trigger_else_if = { # It's always fine to seduce your spouse
					limit = {
						scope:recipient = { is_consort_of = scope:puppet_or_actor }
					}
				}
				trigger_else_if = { # If the target is a close family member, only certain AI's will seduce much older members
					limit = {
						ai_rationality <= -50
						is_close_family_of = scope:recipient
						OR = {
							has_trait = lustful
							has_trait = rakish
							is_incestuous_trigger = yes
							has_opinion_modifier = {
								modifier = childhood_crush
								target = scope:recipient
							}
						}
					}
					scope:recipient.age <= scope:puppet_or_actor.age_plus_25
				}
				trigger_else_if = { # Lustful/seduction-focused characters have a wider range
					limit = {
						OR = {
							has_trait = lustful
							has_focus = intrigue_temptation_focus
							has_trait = rakish
						}
					}
					OR = {
						scope:recipient.age <= scope:puppet_or_actor.age_plus_10
						AND = { # Seducing your vassals/liege/realm priest is good realm management, AND drama!
							has_focus = intrigue_temptation_focus
							OR = {
								scope:recipient = {
									is_vassal_of = scope:puppet_or_actor
								}
								liege ?= scope:recipient

								scope:recipient = {
									is_theocratic_lessee = yes
									is_courtier_of = scope:puppet_or_actor
								}
							}
						}
					}
					trigger_if = { # The AI should focus on bastard-producing seductions, it's more dramatic
						limit = {
							is_male = yes
							scope:recipient = {
								is_female = yes
							}
						}
						scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
					}
				}
				trigger_else_if = { # Male characters with no children that are seducing women want to produce bastards
					limit = {
						is_male = yes
						scope:recipient = { is_female = yes }
						any_child = {
							count <= 1
						}
					}
					scope:recipient.age <= scope:puppet_or_actor.age_plus_5
					scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
				}
				trigger_else = { # Otherwise, try to not seduce with *too* large an age gap
					scope:recipient.age <= scope:puppet_or_actor.age_plus_5
					scope:recipient.age >= scope:puppet_or_actor.age_minus_10
				}
			}
			trigger_else = {
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			NOT = { is_at_war_with = scope:recipient }
			can_start_scheme = {
				type = seduce
				target_character = scope:recipient
			}
			custom_tooltip = {
				text = clerical_chastity_vow_blocks_scheme_tt
				NOT = { has_character_modifier = clerical_chastity_vow_modifier }
			}
		}
		trigger_if = {
			limit = {
				scope:recipient = { exists = primary_spouse }
			}
			scope:recipient = { primary_spouse = { NOT = { has_strong_hook = scope:puppet_or_actor } } }
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
	}

	desc = scheme_interaction_tt_seduce_approved

	on_send = {
		scope:puppet_or_actor = {
			if = {
				limit = {
					OR = {
						has_character_modifier = pam_granted_indulgences_modifier
						has_character_modifier = pam_granted_indulgences_modifier_small
					}
				}
				change_spiritual_fulfillment = medium_spiritual_fulfillment_loss
			}
		}
	}

	on_accept = {
		scope:puppet_or_actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = seduce_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = seduce
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}

				seduce_interaction_stress_effect = yes
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = seduce_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
		scope:puppet_or_actor = {
			if = {
				limit = {
					NOT = { is_attracted_to_gender_of = scope:recipient }
				}
				custom_tooltip = scheme_interaction_tt_wrong_gender_no_lover
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 5

		modifier = {
			add = -50
			scope:puppet_or_actor = {
				primary_spouse ?= { has_strong_hook = scope:puppet_or_actor }
			}
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				has_focus = intrigue_temptation_focus
			}
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				has_opinion_modifier = {
					modifier = childhood_crush
					target = scope:recipient
				}
			}
		}

		modifier = {
			add = 25
			exists = scope:puppet_or_actor.dynasty
			scope:puppet_or_actor.dynasty = {
				has_dynasty_perk = fp1_adventure_legacy_2
			}
		}

		modifier = { # Focus on befriending if that's the path you've chosen
			add = -50
			scope:puppet_or_actor = {
				has_perk = befriend_perk
			}
		}

		modifier = { # Non-lustful clergy tend to not seduce
			add = -25
			scope:puppet_or_actor = {
				is_clergy = yes
				rite = {
					NOT = { rite_has_parameter = clergy_can_marry }
				}
				NOR = {
					has_trait = lustful
					has_focus = intrigue_temptation_focus
				}
			}
		}

		modifier = { # Seducing your unmarried courtiers is good for producing bastards, which the AI will want to do if they have few heirs
			add = 10
			scope:puppet_or_actor = {
				any_child = {
					count <= 1
				}
			}
			scope:recipient = {
				is_married = no
				fertility > low_fertility
				OR = {
					is_courtier_of = scope:puppet_or_actor
					is_pool_guest_of = scope:puppet_or_actor
				}
			}
		}

		modifier = {
			add = 30
			scope:puppet_or_actor = {
				has_trait = lustful
			}
		}

		modifier = { # ( ͡° ͜ʖ ͡°)
			add = 50
			scope:puppet_or_actor = {
				is_close_or_extended_family_of = scope:recipient
				is_deviant_trigger = yes
			}
			scope:recipient = {
				OR = {
					is_deviant_trigger = yes
					has_trait = lustful
				}
			}
		}

		modifier = {
			add = 25
			scope:puppet_or_actor = {
				is_close_or_extended_family_of = scope:recipient
				is_deviant_trigger = yes
			}
			scope:recipient = {
				NOR = {
					is_deviant_trigger = yes
					has_trait = lustful
				}
			}
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				is_close_or_extended_family_of = scope:recipient
				rite = { rite_has_tenet = tenet_divine_marriage }
			}
		}

		modifier = { # Seducing the spouse of your rival is good drama...
			add = 25
			scope:recipient = {
				primary_spouse ?= {
					OR = {
						has_relation_rival = scope:puppet_or_actor
						has_relation_nemesis = scope:puppet_or_actor
					}
				}
			}
		}

		modifier = {
			add = -20
			scope:puppet_or_actor = {
				NOR = {
					has_trait = lustful
					has_trait = arbitrary
					is_deviant_trigger = yes
					rite = { rite_has_tenet = tenet_divine_marriage }
					has_perk = subtle_desire_perk
				}
			}
			scope:recipient = {
				is_close_family_of = scope:puppet_or_actor
			}
		}

		modifier = { # Seducing someone's spouse is not a clever prospect for most characters, so lowering the attractiveness a bit
			add = -20
			scope:recipient = {
				is_married = yes
				primary_spouse != scope:puppet_or_actor
			}
			scope:puppet_or_actor = {
				NOR = {
					has_trait = lustful
					has_focus = intrigue_temptation_focus
				}
			}
		}

		modifier = { # Try to avoid aggressive seduction unless you're geared for it
			add = -10
			scope:puppet_or_actor = {
				NOR = {
					has_trait = lustful
					has_focus = intrigue_temptation_focus
				}
			}
			scope:recipient = {
				is_lowborn = no
				NOT = { is_pool_guest_of = scope:puppet_or_actor }
			}
		}

		# Struggle
#		modifier = {
#			scope:recipient = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_friend_lover_with_character
#				}
#			}
#			scope:puppet_or_actor = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_friend_lover_with_character
#				}
#			}
#			add = {
#				value = 0
#				if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_deescalation
#							trait_compatibility = {
#								target = scope:recipient
#								value >= low_positive_trait_compatibility
#							}
#						}
#						scope:recipient = {
#							has_character_flag = agenda_towards_deescalation
#						}
#					}
#					add = 50
#				}
#				else_if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_escalation
#						}
#					}
#					add = -200
#				}
#				else = {
#					add = 5
#				}
#			}
#		}

		modifier = {
			factor = 1.25
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:puppet_or_actor
					value >= 1
				}
			}
		}

		modifier = {
			factor = 1.5
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:puppet_or_actor
					value >= 2
				}
			}
		}

		modifier = {
			factor = 2
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:puppet_or_actor
					value >= 3
				}
			}
		}

		modifier = {
			factor = 1.5
			scope:recipient = {
				is_playable_character = yes
			}
		}

		modifier = { # Target the player less aggressively
			factor = 0.5
			scope:recipient = {
				OR = {
					is_ai = no
					any_consort = {
						is_ai = no
					}
				}
			}
		}

		modifier = {
			factor = 1.25
			scope:recipient = {
				OR = {
					has_trait = lustful
					has_trait = beauty_good
				}
			}
		}

		modifier = { # Try to avoid 0% success chance
			factor = {
				value = 0.1
				if = {
					limit = {
						scope:recipient = {
							opinion = {
								target = scope:puppet_or_actor
								value < -15
							}
						}
					}
					value = 0
				}
			}
			scope:recipient = {
				opinion = {
					target = scope:puppet_or_actor
					value < -5
				}
			}
		}

		modifier = { # Try to avoid 0% success chance
			factor = 0.1
			scope:recipient = {
				number_of_opposing_personality_traits = {
					target = scope:puppet_or_actor
					value >= 1
				}
			}
		}

		modifier = {
			factor = 0.75
			scope:recipient = {
				is_lowborn = yes
			}
		}

		modifier = { # Barons tend to not seduce anyone landed above them
			factor = 0.1
			scope:puppet_or_actor = {
				is_playable_character = yes
				primary_title = {
					tier = tier_barony
				}
			}
			scope:recipient = {
				OR = {
					AND = {
						is_playable_character = yes
						primary_title = {
							tier > tier_barony
						}
					}
					any_spouse = {
						is_playable_character = yes
						primary_title = {
							tier > tier_barony
						}
					}
				}
			}
		}

		modifier = {
			factor = 0.2
			scope:recipient = {
				is_ai = yes
				any_targeting_scheme = {
					scheme_type = seduce
				}
			}
		}

		modifier = { #
			factor = 0.1
			scope:recipient = {
				is_ai = yes
				has_trait = chaste
			}
		}

		modifier = {
			factor = 0
			scope:recipient = {
				is_ai = yes
				any_relation = { type = soulmate }
			}
		}

		modifier = { # Family Feud
			add = 50
			scope:puppet_or_actor = {
				house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			}
		}
		#Promised to abstain from sin
		modifier = {
			OR = {
				has_character_modifier = pam_granted_indulgences_modifier
				has_character_modifier = pam_granted_indulgences_modifier_small
			}
			factor = 0.1
		}
	}
}

court_interaction = {
	icon = icon_scheme_romance
	category = interaction_category_friendly

	send_name = START_SCHEME

	interface_priority = 40
	scheme = courting
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = spouses
		ai_recipients = neighboring_rulers
	}

	ai_targets = {
		ai_recipients = vassals
		max = 5
	}

	ai_targets = {
		ai_recipients = peer_vassals
		max = 5
	}

	ai_targets = {
		ai_recipients = family
		max = 5
	}

	ai_targets = {
		ai_recipients = realm_characters
		max = 30
	}

	ai_target_quick_trigger = {
		adult = yes
		attracted_to_owner = yes
		owner_attracted = yes
	}

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

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			highest_held_title_tier > tier_barony
			trigger_if = {
				limit = {
					NOR = {
						culture ?= {
							has_cultural_parameter = ai_romance_scheme_increase
						}
#						AND = {
#							has_character_flag = agenda_towards_deescalation
#							any_character_struggle = {
#								involvement = involved
#								phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
#								is_struggle_type = iberian_struggle
#							}
#						}
					}
				}
				ai_honor >= high_positive_ai_value
				ai_compassion >= low_positive_ai_value
			}
			is_adult = yes
			NOR = {
				has_trait = chaste
				AND = { # No one cared about City barons
					is_lowborn = yes
					primary_title.tier <= tier_barony
				}
				has_trait = celibate
				scheme_generic_ai_blocker_trigger = yes
			}
		}
	}

	is_shown = {
		scope:puppet_or_actor ?= {
			this != scope:recipient
			is_adult = yes
			#Some asexuality handling
			trigger_if = {
				limit = { has_sexuality = asexual }
				trigger_if = {
					limit = { scope:actor = { is_ai = yes } }
					always = no
				}
				trigger_else = {
					scope:recipient = { is_consort_of = scope:puppet_or_actor }
				}
			}
			# Some early filtering for the AI to focus it towards fruitful romance
			trigger_if = {
				limit = { scope:actor = { is_ai = yes } }
				trigger_if = { # Deviants will romance anyone
					limit = { is_deviant_trigger = yes }
				}
				trigger_else_if = { # It's always fine to romance your spouse
					limit = {
						scope:recipient = { is_consort_of = scope:puppet_or_actor }
					}
				}
				trigger_else_if = { # If the target is a close family member, only certain AI's will romance much older members
					limit = {
						ai_rationality <= -50
						is_close_family_of = scope:recipient
						OR = {
							has_trait = lustful
							has_trait = rakish
							is_incestuous_trigger = yes
							has_opinion_modifier = {
								modifier = childhood_crush
								target = scope:recipient
							}
						}
					}
					scope:recipient.age <= scope:puppet_or_actor.age_plus_25
				}
				trigger_else_if = { # Lustful/seduction-focused characters have a wider range
					limit = {
						OR = {
							has_trait = lustful
							has_focus = intrigue_temptation_focus
							has_trait = rakish
						}
					}
					OR = {
						scope:recipient.age <= scope:puppet_or_actor.age_plus_10
						AND = { # Romancing your vassals/liege/realm priest is good realm management, AND drama!
							has_focus = intrigue_temptation_focus
							OR = {
								scope:recipient = {
									is_vassal_of = scope:puppet_or_actor
								}
								liege ?= scope:recipient

								scope:recipient = {
									is_theocratic_lessee = yes
									is_courtier_of = scope:puppet_or_actor
								}
							}
						}
					}
					trigger_if = { # The AI should focus on bastard-producing romances, it's more dramatic
						limit = {
							is_male = yes
							scope:recipient = {
								is_female = yes
							}
						}
						scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
					}
				}
				trigger_else_if = { # Male characters with no children that are romancing women want to produce children
					limit = {
						is_male = yes
						scope:recipient = { is_female = yes }
						any_child = {
							count <= 1
						}
					}
					scope:recipient.age <= scope:puppet_or_actor.age_plus_5
					scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
				}
				trigger_else = { # Otherwise, try to not seduce with *too* large an age gap
					scope:recipient.age <= scope:puppet_or_actor.age_plus_5
					scope:recipient.age >= scope:puppet_or_actor.age_minus_10
				}
			}
			trigger_else = {
			}
		}
		scope:recipient = {
			is_adult = yes
			is_attracted_to_gender_of = scope:puppet_or_actor
		}
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			NOT = { is_at_war_with = scope:recipient }
			can_start_scheme = {
				type = courting
				target_character = scope:recipient
			}
			custom_tooltip = {
				text = clerical_chastity_vow_blocks_scheme_tt
				NOT = { has_character_modifier = clerical_chastity_vow_modifier }
			}
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
	}

	desc = scheme_interaction_tt_courtship_approved

	on_send = {
		scope:puppet_or_actor = {
			if = {
				limit = {
					OR = {
						has_character_modifier = pam_granted_indulgences_modifier
						has_character_modifier = pam_granted_indulgences_modifier_small
					}
				}
				change_spiritual_fulfillment = medium_spiritual_fulfillment_loss
			}
		}
	}

	on_accept = {
		scope:puppet_or_actor = {
			# If you already have a soulmate, they get very mad
			every_relation = {
				type = soulmate
				limit = { soulmate_relation_is_exclusive_trigger = yes }

				add_opinion = {
					modifier = betrayed_our_promise
					target = scope:puppet_or_actor
				}
			}
		}
		scope:puppet_or_actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = court_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = courting
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}

				show_as_tooltip = {
					# If you already have a soulmate, they get very mad
					every_relation = {
						type = soulmate
						limit = { soulmate_relation_is_exclusive_trigger = yes }

						add_opinion = {
							modifier = betrayed_our_promise
							target = scope:puppet_or_actor
						}
					}
				}
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = court_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
		scope:recipient = {
			if = {
				limit = {
					is_ai = no
				}
				add_character_flag = {
					flag = courting_cooldown
					years = 5
				}
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0



		# Struggle
#		modifier = {
#			scope:puppet_or_actor = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
#				}
#			}
#			scope:recipient = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
#				}
#			}
#			add = {
#				value = 0
#				if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_deescalation
#						}
#						scope:recipient = {
#							has_character_flag = agenda_towards_deescalation
#						}
#					}
#					add = 25
#				}
#				else_if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_escalation
#						}
#					}
#					add = -200
#				}
#				else = {
#					add = 5
#				}
#			}
#		}

#		modifier = { # Motivate AI's to use it on catalyst providers exclusively
#			add = -50
#			scope:puppet_or_actor = {
#				any_character_struggle = {
#					involvement = involved
#					is_struggle_type = iberian_struggle
#					phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
#				}
#			}
#			scope:recipient = {
#				NOT = {
#					any_character_struggle = {
#						involvement = involved
#						is_struggle_type = iberian_struggle
#						phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
#					}
#				}
#			}
#		}

		opinion_modifier = {
			opinion_target = scope:recipient
			multiplier = 0.4
		}

		compatibility_modifier = {
			compatibility_target = scope:recipient
			multiplier = 1
			max = court_scheme_max_compatability_value
		}

		modifier = {
			factor = 25
			culture = {
				has_cultural_parameter = ai_romance_scheme_increase
			}
		}

		modifier = {
			factor = 25
			has_focus = martial_chivalry_focus
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				has_opinion_modifier = {
					modifier = childhood_crush
					target = scope:recipient
				}
			}
		}

		modifier = {
			add = -50
			scope:puppet_or_actor = {
				is_close_family_of = scope:recipient
				NOR = {
					is_deviant_trigger = yes
					has_trait = lustful
				}
			}
		}

		modifier = {
			factor = 3
			scope:recipient = {
				OR = {
					is_playable_character = yes
					any_spouse = {
						is_playable_character = yes
					}
				}
			}
		}

		modifier = {
			factor = 1.25
			scope:recipient = {
				has_trait = beauty_good
			}
		}

		modifier = { # Try to avoid 0% success chance
			factor = {
				value = 0.1
				if = {
					limit = {
						scope:recipient = {
							opinion = {
								target = scope:puppet_or_actor
								value < -20
							}
						}
					}
					value = 0
				}
			}
			scope:recipient = {
				opinion = {
					target = scope:puppet_or_actor
					value < 0
				}
			}
		}

		modifier = {
			factor = 0.2
			scope:recipient = {
				is_ai = yes
				any_targeting_scheme = {
					scheme_type = courting
				}
			}
		}

		modifier = {
			factor = 0.1
			scope:recipient = {
				any_relation = { type = soulmate }
			}
		}

		modifier = {
			factor = 0.1
			scope:recipient = {
				is_lowborn = yes
				is_married = no
			}
		}

		modifier = { # Clergy sworn to celibacy don't partake in courtly love
			factor = 0
			scope:puppet_or_actor = {
				is_clergy = yes
				rite = {
					NOT = { rite_has_parameter = clergy_can_marry }
				}
				NOT = {
					has_trait = lustful
				}
			}
		}
		#Promised to abstain from sin
		modifier = {
			OR = {
				has_character_modifier = pam_granted_indulgences_modifier
				has_character_modifier = pam_granted_indulgences_modifier_small
			}
			factor = 0.1
		}
	}
}

sway_interaction = {
	icon = icon_scheme_sway
	category = interaction_category_friendly
	common_interaction = yes

	send_name = START_SCHEME

	interface_priority = 75

	scheme = sway
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
		ai_recipients = neighboring_rulers
		max = 10
	}
	ai_targets = {
		ai_recipients = vassals
		ai_recipients = peer_vassals
		max = 10
	}
	ai_targets = {
		ai_recipients = councillors
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 120
		duchy = 24
		kingdom = 6
		empire = 6
		hegemony = 6
	}

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			NOR = {
				primary_title ?= {
					is_mercenary_company = yes
				}
				scheme_generic_ai_blocker_trigger = yes
			}
			#Don't override Befriend with Sway?
			trigger_if = {
				limit = {
					OR = {
						AND = {
							has_royal_court = yes
							court_grandeur_current_level >= 10
							has_court_type = court_diplomatic
							has_dlc_feature = royal_court
						}
						AND = {
							has_royal_court = yes
							court_grandeur_current_level >= 10
							dynasty ?= { has_dynasty_perk = glory_legacy_5 }
							has_court_type = court_diplomatic
							has_dlc_feature = royal_court
						}
					}
				}
				always = yes
			}
			trigger_else = {
				NOT = {
					any_scheme = { scheme_type = befriend }
				}
			}
		}
	}

	is_shown = {
		exists = scope:puppet_or_actor
		scope:puppet_or_actor != scope:recipient
		trigger_if = {
			limit = { scope:actor = { is_ai = yes } }
			scope:recipient = {
				trigger_if = { # The unlanded are only worth it as realm priest, spymaster, or a clan's tax collector
					limit = { is_ruler = no }
					OR = {
						is_theocratic_lessee = yes
						has_council_position = councillor_spymaster
						AND = {
							is_tax_collector = yes
							scope:puppet_or_actor = { government_has_flag = government_is_clan }
						}
					}
				}
				trigger_else = { # Only rulers have a tier or a government to judge
					trigger_if = { # Barons are only worth the effort on the council
						limit = { primary_title.tier = tier_barony }
						is_councillor = yes
					}
					trigger_if = { # Leave independent kings and above to diplomacy proper
						limit = { is_independent_ruler = yes }
						OR = {
							primary_title.tier < tier_kingdom
							is_playable_character = no
						}
					}
					NOT = { government_has_flag = government_is_herder }
				}
				trigger_if = { # Only the forgiving court a rival
					limit = { scope:puppet_or_actor = { has_relation_rival = scope:recipient } }
					scope:puppet_or_actor = { has_trait = forgiving }
				}
				opinion = { # Opinion last: it is the dearest check here
					target = scope:puppet_or_actor
					value < 100
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			can_start_scheme = {
				type = sway
				target_character = scope:recipient
			}
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
	}

	desc = scheme_interaction_tt_sway_approved

	on_accept = {
		scope:puppet_or_actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = sway_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = sway
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = sway_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 10

		modifier = { # Prefer seducing if you've got the focus for it
			add = -20
			scope:puppet_or_actor = {
				has_focus = intrigue_temptation_focus
			}
		}

		modifier = {
			add = 10
			scope:recipient = {
				is_vassal_of = scope:puppet_or_actor
			}
		}

		modifier = { # Try to sway those who you might want to vassalize
			add = 30
			scope:puppet_or_actor = {
				top_liege = this
				primary_title.tier >= tier_county
				NOT = {
					any_targeting_faction = {
						OR = {
							faction_is_type = liberty_faction
							faction_is_type = claimant_faction
							faction_is_type = independence_faction
						}
					}
				}
			}
			scope:recipient = {
				top_liege = this
				is_playable_character = yes
				primary_title.tier < scope:puppet_or_actor.primary_title.tier
				OR = {
					faith.religion = scope:puppet_or_actor.faith.religion
					AND = {
						rite = {
							rite_has_doctrine = doctrine_pluralism_pluralistic
						}
						scope:puppet_or_actor.rite = {
							rite_has_doctrine = doctrine_pluralism_pluralistic
						}
					}
				}
			}
		}

		modifier = {
			add = 10
			scope:recipient = {
				joined_faction ?= {
					faction_target = scope:puppet_or_actor
					faction_is_type = liberty_faction
					faction_is_at_war = no
				}
			}
		}

		modifier = {
			add = 20
			scope:recipient = {
				joined_faction ?= {
					faction_target = scope:puppet_or_actor
					faction_is_type = claimant_faction
					faction_is_at_war = no
				}
			}
		}

		modifier = {
			add = 30
			scope:recipient = {
				joined_faction ?= {
					faction_target = scope:puppet_or_actor
					faction_is_type = independence_faction
					faction_is_at_war = no
				}
			}
		}

		modifier = {
			factor = 2
			scope:recipient = {
				is_a_faction_leader = yes
				is_vassal_of = scope:puppet_or_actor
			}
		}

		modifier = {
			factor = 3
			scope:recipient = {
				is_vassal_of = scope:puppet_or_actor
				opinion = {
					target = scope:puppet_or_actor
					value < 0
				}
			}
		}

		modifier = {
			factor = 4
			scope:recipient = {
				is_powerful_vassal_of = scope:puppet_or_actor
				opinion = {
					target = scope:puppet_or_actor
					value < 0
				}
			}
		}

		modifier = {
			factor = 0.5
			scope:recipient.faith != scope:puppet_or_actor.faith
		}

		modifier = {
			factor = 0.25
			scope:puppet_or_actor = {
				is_ruler = yes
				tier_difference = {
					target = scope:recipient
					value > 2
				}
			}
			scope:recipient = {
				is_theocratic_lessee = no
			}
		}
		modifier = {
			factor = 0.5
			scope:puppet_or_actor = {
				has_personality_malicious_trigger = yes
			}
		}
		modifier = {
			factor = 2
			scope:puppet_or_actor = {
				OR = {
					has_trait = gregarious
					has_trait = diplomat
					has_trait = family_first
					has_trait = august
				}
			}
		}
		modifier = {
			factor = 0.75
			scope:recipient = {
				is_child_of = scope:puppet_or_actor
			}
		}
		modifier = {
			factor = 2
			scope:puppet_or_actor = {
				is_child_of = scope:recipient
			}
		}
		modifier = {
			factor = 0.25
			scope:recipient = {
				any_claim = {
					this = scope:puppet_or_actor.primary_title
				}
			}
		}
		modifier = { # Butter up the realm priest
			factor = 10
			scope:recipient = {
				is_theocratic_lessee = yes
				opinion = {
					target = scope:puppet_or_actor
					value <= 50
				}
			}
		}
		modifier = { # Try to make your tax collectors like you
			factor = 10
			scope:puppet_or_actor = {
				government_has_flag = government_is_clan
			}
			scope:recipient = {
				is_tax_collector = yes
				opinion = {
					target = scope:puppet_or_actor
					value <= 50
				}
			}
		}
	}
}

learn_language_interaction = {
	icon = icon_scheme_learn_language
	category = interaction_category_friendly
	common_interaction = yes

	send_name = START_SCHEME

	interface_priority = 42
	scheme = learn_language
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
		ai_recipients = spouses
		ai_recipients = scripted_relations
		ai_recipients = suzerain
		ai_recipients = top_suzerain
		ai_recipients = activity_host
		ai_recipients = war_allies
	}
	ai_targets = {
		ai_recipients = vassals
		ai_recipients = peer_vassals
		ai_recipients = tributaries
		max = 10
	}
	ai_targets = {
		ai_recipients = neighboring_rulers
		max = 5
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 48
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			primary_title.tier >= tier_county
			NOR = {
				has_trait = paranoid
				has_trait = lazy
				primary_title ?= {
					is_mercenary_company = yes
				}
				scheme_generic_ai_blocker_trigger = yes
			}
		}
	}

	is_shown = {
		scope:puppet_or_actor ?= {
			NOT = {
				culture = {
					has_same_culture_language = scope:recipient.culture
				}
			}
		}
		scope:puppet_or_actor != scope:recipient
	}

	is_valid_showing_failures_only = {
		scope:puppet_or_actor = {
			can_start_scheme = {
				type = learn_language
				target_character = scope:recipient
			}
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
	}

	desc = scheme_interaction_tt_learn_language_approved

	on_accept = {
		scope:puppet_or_actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = learn_language_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = learn_language
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = learn_language_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0

		# Struggle
#		modifier = {
#			scope:recipient = {
#				any_character_struggle = {
#					involvement = involved
#					phase_has_catalyst = catalyst_learned_new_language_important
#				}
#			}
#			scope:puppet_or_actor = {
#				any_character_struggle = {
#					involvement = involved
#					phase_has_catalyst = catalyst_learned_new_language_important
#				}
#			}
#			add = {
#				value = 0
#				if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_deescalation
#						}
#					}
#					add = 100
#				}
#				else_if = {
#					limit = {
#						scope:puppet_or_actor = {
#							has_character_flag = agenda_towards_escalation
#						}
#					}
#					add = -50
#				}
#			}
#		}

		modifier = { # Focus on befriending if that's the path you've chosen
			add = -50
			scope:puppet_or_actor = {
				has_perk = befriend_perk
			}
		}

		modifier = { # Prefer seducing if you've got the focus for it
			add = -20
			scope:puppet_or_actor = {
				has_focus = intrigue_temptation_focus
			}
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				has_perk = open_minded_perk
			}
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				culture = {
					has_cultural_parameter = rulers_want_to_learn_languages_of_coreligionists
				}
			}
			scope:puppet_or_actor.religion = scope:recipient.religion
		}

		modifier = {
			add = 25
			scope:puppet_or_actor = {
				has_trait = curious
			}
		}

		modifier = {
			add = 50
			scope:puppet_or_actor = {
				is_adult = no
			}
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_relation_friend = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_relation_lover = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 10
			scope:recipient = {
				has_relation_potential_friend = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 5
			scope:recipient = {
				is_close_family_of = scope:puppet_or_actor
				is_ruler = yes
			}
		}

		modifier = { # Muslims want to learn arabic
			add = 25
			scope:puppet_or_actor = {
				faith.religion = religion:islam_religion
				NOT = {
					knows_language = language_arabic
				}
			}
			scope:recipient = {
				culture = {
					has_cultural_pillar = language_arabic
				}
			}
		}

		modifier = { # Catholic clergy/pious people want to learn latin
			add = 50
			scope:puppet_or_actor = {
				religion = religion:catholic_religion
				OR = {
					has_trait = zealous
					has_trait = humble
					is_clergy = yes
				}
				NOT = {
					knows_language = language_latin
				}
			}
			scope:recipient = {
				culture = {
					has_cultural_pillar = language_latin
				}
			}
		}

		modifier = { # Catholic clergy/pious people want to learn Italian
			add = 50
			scope:puppet_or_actor = {
				religion = religion:catholic_religion
				OR = {
					has_trait = zealous
					has_trait = humble
					is_clergy = yes
				}
				NOT = {
					knows_language = language_italian
				}
			}
			scope:recipient = {
				culture = {
					has_cultural_pillar = language_italian
				}
			}
		}

		modifier = { # Clergy/pious people want to learn their HoF's language
			add = 50
			scope:puppet_or_actor = {
				exists = faith.religious_head
				OR = {
					has_trait = zealous
					is_clergy = yes
				}
				NOT = { knows_language_of_culture = scope:puppet_or_actor.faith.religious_head.culture }
			}
			scope:recipient = { knows_language_of_culture = scope:puppet_or_actor.faith.religious_head.culture }
		}

		modifier = { # Coptic/Orthodox clergy/pious people want to learn greek
			add = 50
			scope:puppet_or_actor = {
				OR = { faith.religion = religion:eastern_orthodox_religion faith.religion = religion:oriental_orthodox_religion }
				OR = {
					has_trait = zealous
					has_trait = humble
					is_clergy = yes
				}
				NOT = {
					knows_language = language_greek
				}
			}
			scope:recipient = {
				culture = {
					has_cultural_pillar = language_greek
				}
			}
		}

#		modifier = { # Nestorian clergy/pious people want to learn aramaic
#			add = 50
#			scope:puppet_or_actor = {
#				faith = faith:nestorian
#				OR = {
#					has_trait = zealous
#					has_trait = humble
#					is_clergy = yes
#				}
#				NOT = {
#					knows_language = language_aramaic
#				}
#			}
#			scope:recipient = {
#				culture = {
#					has_cultural_pillar = language_aramaic
#				}
#			}
#		}

		modifier = {
			add = 20
			scope:puppet_or_actor = {
				has_focus = diplomacy_foreign_affairs_focus
				any_neighboring_realm_same_rank_owner = {
					this = scope:recipient
				}
			}
		}

		modifier = {
			add = 20
			scope:puppet_or_actor = {
				OR = {
					has_focus = learning_scholarship_focus
					has_focus = stewardship_duty_focus
				}
			}
			scope:recipient = {
				is_vassal_of = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 10
			exists = scope:puppet_or_actor.capital_county
			scope:recipient.culture = {
				has_same_culture_language = scope:puppet_or_actor.capital_county.culture
			}
		}

		modifier = {
			add = 100
			scope:puppet_or_actor.culture = {
				has_cultural_tradition = tradition_loyal_soldiers
			}
			top_liege != this
			scope:puppet_or_actor = {
				liege = scope:recipient
			}
		}

		modifier = {
			factor = 2
			scope:recipient = {
				is_powerful_vassal_of = scope:puppet_or_actor
			}
		}

		modifier = {
			factor = 2
			scope:puppet_or_actor = {
				learning >= 12
			}
		}

		modifier = {
			factor = 0.5
			scope:puppet_or_actor = {
				learning <= 6
			}
		}

		modifier = {
			factor = 0

			scope:puppet_or_actor.num_of_known_languages >= 5
			scope:puppet_or_actor = {
				NOR = {
					has_perk = pedagogy_perk
					has_trait = intellect_good_2
					has_trait = intellect_good_3
					age < 25
				}
			}
		}

		modifier = {
			factor = 0

			scope:puppet_or_actor.num_of_known_languages >= language_soft_cap
		}
	}
}

study_faith_interaction = {
	icon = icon_scheme_study_faith
	category = interaction_category_friendly
	common_interaction = yes

	send_name = START_SCHEME

	interface_priority = 42
	scheme = study_faith

	ai_targets = {
		ai_recipients = liege
		ai_recipients = spouses
		ai_recipients = scripted_relations
		ai_recipients = suzerain
		ai_recipients = top_suzerain
		ai_recipients = activity_host
		ai_recipients = war_allies
	}
	ai_targets = {
		ai_recipients = vassals
		ai_recipients = peer_vassals
		ai_recipients = tributaries
		max = 10
	}
	ai_targets = {
		ai_recipients = neighboring_rulers
		max = 5
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 144
		duchy = 60
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	is_available = {
		trigger_if = {
			limit = { is_ai = yes }
			NOR = {
				has_trait = paranoid
				has_trait = lazy
				primary_title ?= {
					is_mercenary_company = yes
				}
				scheme_generic_ai_blocker_trigger = yes
			}
		}
	}

	is_shown = {
		scope:puppet_or_actor ?= { faith != scope:recipient.faith }
		scope:puppet_or_actor != scope:recipient
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor = scope:recipient
			}
			custom_tooltip = {
				text = study_faith_nothing_left_to_learn_tt_puppet_self
				scope:puppet_or_actor = {
					study_faith_has_anything_to_learn_trigger = { RITE = scope:recipient.rite }
				}
			}
		}
		trigger_else = {
			custom_tooltip = {
				text = study_faith_nothing_left_to_learn_tt
				scope:puppet_or_actor = {
					study_faith_has_anything_to_learn_trigger = { RITE = scope:recipient.rite }
				}
			}
		}
		scope:puppet_or_actor = {
			can_start_scheme = {
				type = study_faith
				target_character = scope:recipient
			}
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:puppet_or_actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:puppet_or_actor
			}
		}
		trigger_if = {
			limit = { scope:is_puppet_action ?= yes }
			scope:puppet_or_actor = {
				piety >= medium_piety_value
			}
		}
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:is_puppet_action ?= yes
					scope:actor = scope:recipient
				}
				desc = scheme_interaction_tt_study_faith_approved_puppet_self
			}
			desc = scheme_interaction_tt_study_faith_approved
		}
	}
	notification_text = study_faith_interaction_notification_int

	cost = {
		piety = {
			value = medium_piety_value
			if = {
				limit = { scope:is_puppet_action ?= yes }
				multiply = 0
			}
		}
	}

	send_option = {
		flag = study_faith_ask_directly
		current_description = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:is_puppet_action ?= yes
						scope:actor = scope:recipient
					}
					desc = study_faith_interaction.tt.ask_directly_puppet_self
				}
				desc = study_faith_interaction.tt.ask_directly
			}
		}
	}
	send_option = {
		flag = study_faith_ask_for_emissary
		current_description = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:is_puppet_action ?= yes
						scope:actor = scope:recipient
					}
					desc = study_faith_interaction.tt.ask_for_emissary_puppet_self
				}
				desc = study_faith_interaction.tt.ask_for_emissary
			}
		}
	}
	send_option = {
		flag = study_faith_study_from_afar
		is_valid = {
			custom_tooltip = {
				text = can_only_be_learned_in_person_tt
				scope:recipient.faith = {
					NOT = { has_doctrine_parameter = can_only_be_learned_in_person }
				}
			}
		}
		current_description = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:is_puppet_action ?= yes
						scope:actor = scope:recipient
					}
					desc = study_faith_interaction.tt.study_from_afar_puppet_self
				}
				desc = study_faith_interaction.tt.study_from_afar
			}
		}
	}

	auto_accept = { scope:study_faith_study_from_afar = yes }

	on_accept = {
		if = {
			limit = { scope:is_puppet_action ?= yes }
			scope:puppet_or_actor = {
				add_piety = { value = { add = medium_piety_value max = piety multiply = -1 } }
			}
		}
		scope:puppet_or_actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = study_faith_interaction_notification

				left_icon = scope:puppet_or_actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = study_faith
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
				scope:new_scheme ?= {
					if = {
						limit = { scope:study_faith_ask_directly = yes }
						add_scheme_modifier = {
							type = study_faith_ask_directly_modifier
						}
					}
					else_if = {
						limit = { scope:study_faith_ask_for_emissary = yes }
						add_scheme_modifier = {
							type = study_faith_ask_for_emissary_modifier
						}
					}
					else_if = {
						limit = { scope:study_faith_study_from_afar = yes }
						add_scheme_modifier = {
							type = study_faith_study_from_afar_modifier
						}
					}
				}
			}
		}
		if = {
			limit = {
				scope:is_puppet_action ?= yes
				scope:actor != scope:recipient
			}
			scope:actor = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = study_faith_interaction_notification_puppeteer
					left_icon = scope:puppet_or_actor
					right_icon = scope:recipient
				}
			}
		}
		if = {
			limit = {
				scope:study_faith_ask_directly = yes
				scope:is_puppet_action ?= yes
				scope:actor = scope:recipient
			}
			custom_label = study_faith_interaction.accept.study_faith_ask_directly_puppet_self
		}
		else_if = {
			limit = { scope:study_faith_ask_directly = yes }
			custom_label = study_faith_interaction.accept.study_faith_ask_directly
		}
		else_if = {
			limit = {
				scope:study_faith_ask_for_emissary = yes
				scope:is_puppet_action ?= yes
				scope:actor = scope:recipient
			}
			custom_label = study_faith_interaction.accept.study_faith_ask_for_emissary_puppet_self
		}
		else_if = {
			limit = { scope:study_faith_ask_for_emissary = yes }
			custom_label = study_faith_interaction.accept.study_faith_ask_for_emissary
		}
		else_if = {
			limit = {
				scope:study_faith_study_from_afar = yes
				scope:is_puppet_action ?= yes
				scope:actor = scope:recipient
			}
			custom_label = study_faith_interaction.accept.study_faith_study_from_afar_puppet_self
		}
		else_if = {
			limit = { scope:study_faith_study_from_afar = yes }
			custom_label = study_faith_interaction.accept.study_faith_study_from_afar
		}
	}

	ai_accept = {
		base = 0

		modifier = {
			add = 25
			scope:puppet_or_actor = {
				has_perk = theologian_perk
			}
			desc = study_faith_interaction.ai_accept.theologian_perk
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_trait = curious
			}
			desc = study_faith_interaction.ai_accept.curious
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_relation_friend = scope:puppet_or_actor
			}
			desc = WE_ARE_FRIENDS
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_relation_lover = scope:puppet_or_actor
			}
			desc = WE_ARE_LOVERS
		}

		modifier = {
			add = 25
			scope:recipient = {
				is_close_family_of = scope:puppet_or_actor
				is_ruler = yes
			}
			desc = study_faith_interaction.ai_accept.close_family_ruler
		}

		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:puppet_or_actor
			multiplier = 0.5
			desc = AI_OPINION_REASON
		}

		modifier = {
			add = -30
			scope:recipient.faith = {
				faith_hostility_level = {
					target = scope:puppet_or_actor.faith
					value = faith_evil_level
				}
			}
			desc = study_faith_interaction.ai_accept.evil_faith
		}
		modifier = {
			add = -15
			scope:recipient.faith = {
				faith_hostility_level = {
					target = scope:puppet_or_actor.faith
					value = faith_hostile_level
				}
			}
			desc = study_faith_interaction.ai_accept.hostile_faith
		}
		modifier = {
			add = 5
			scope:recipient.faith = {
				faith_hostility_level = {
					target = scope:puppet_or_actor.faith
					value = faith_astray_level
				}
			}
			desc = study_faith_interaction.ai_accept.astray_faith
		}
		modifier = {
			add = 25
			scope:recipient.faith = {
				faith_hostility_level = {
					target = scope:puppet_or_actor.faith
					value = faith_fully_accepted_level
				}
			}
			desc = study_faith_interaction.ai_accept.accepted_faith
		}

		modifier = {
			add = 60
			scope:study_faith_ask_for_emissary = yes
			desc = study_faith_interaction.ai_accept.ask_for_emissary
		}
	}

	ai_will_do = {
		base = 0

		modifier = { # Focus on befriending if that's the path you've chosen
			add = -50
			scope:puppet_or_actor = {
				has_perk = befriend_perk
			}
		}

		modifier = { # Prefer seducing if you've got the focus for it
			add = -20
			scope:puppet_or_actor = {
				has_focus = intrigue_temptation_focus
			}
		}

		modifier = {
			add = 35
			scope:puppet_or_actor = {
				has_focus = learning_theology_focus
			}
		}

		modifier = {
			add = 35
			scope:puppet_or_actor = {
				has_perk = theologian_perk
			}
		}

		modifier = {
			add = 25
			scope:puppet_or_actor = {
				has_perk = open_minded_perk
			}
		}

		modifier = {
			add = 25
			scope:puppet_or_actor = {
				has_trait = curious
			}
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_relation_friend = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 25
			scope:recipient = {
				has_relation_lover = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 10
			scope:recipient = {
				has_relation_potential_friend = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 25
			scope:recipient = {
				is_close_family_of = scope:puppet_or_actor
				is_ruler = yes
			}
		}

		modifier = {
			add = 20
			scope:puppet_or_actor = {
				has_focus = diplomacy_foreign_affairs_focus
				any_neighboring_realm_same_rank_owner = {
					this = scope:recipient
				}
			}
		}

		modifier = {
			add = 20
			scope:puppet_or_actor = {
				has_focus = stewardship_duty_focus
			}
			scope:recipient = {
				is_vassal_of = scope:puppet_or_actor
			}
		}

		modifier = {
			add = 10
			exists = scope:puppet_or_actor.capital_county
			scope:recipient.faith = scope:puppet_or_actor.capital_county.faith
		}

		modifier = {
			factor = 2
			scope:recipient = {
				is_powerful_vassal_of = scope:puppet_or_actor
			}
		}

		modifier = {
			factor = 2
			scope:puppet_or_actor = {
				learning >= 12
			}
		}

		modifier = {
			factor = 0.5
			scope:puppet_or_actor = {
				learning <= 6
			}
		}
	}
}

