﻿### EP3 Scheme Interactions

# Slander
start_slander_interaction = {
	icon = icon_scheme_slander
	interface_priority = 95
	common_interaction = no
	category = interaction_category_succession
	filter_tags = { admin_house_head dynastic_cycle ceremonial_liege }

	send_name = START_SCHEME

	scheme = slander
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = peer_vassals
		max = 10
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 92
		duchy = 48
		kingdom = 24
		empire = 12
		hegemony = 0
	}
	
	is_shown = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			government_allows = administrative
		}
		scope:recipient = {
			this != scope:actor
			government_allows = administrative
			top_liege = scope:actor.top_liege

			# don't show on the huangdi
			OR = {
				NOT = { government_allows = merit }
				is_independent_ruler = no
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = slander
				target_character = scope:recipient
			}
		}
		scope:recipient = {
			NOT = { has_strong_hook = scope:actor }
			top_liege != this
		}
		trigger_if = {
			limit = { scope:actor = { has_variable = no_scheming_allowed_var } }
			custom_tooltip = {
				text = no_scheming_allowed_var_tt
				scope:actor.var:no_scheming_allowed_var != scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:actor = {
					can_start_scheme = {
						type = slander
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_slander_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_slander_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_slander_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_slander_interaction.tt.agent_focus_speed
	}
	## Focused on Secrecy.
	send_option = {
		flag = agent_focus_secrecy
		current_description = start_slander_interaction.tt.agent_focus_secrecy
	}

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

				left_icon = scope:actor					
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = slander
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_intermediary
						AGENT_2 = agent_sycophant
						AGENT_3 = agent_sycophant
						# Speed.
						AGENT_4 = agent_political_socialite
						# Secrecy.
						AGENT_5 = agent_courtesan
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = slander
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Speed.
						AGENT_1 = agent_political_socialite
						AGENT_2 = agent_political_socialite
						AGENT_3 = agent_bureaucrat
						# Success.
						AGENT_4 = agent_sycophant
						# Secrecy.
						AGENT_5 = agent_courtesan
					}
				}
				# Secrecy.
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = slander
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Secrecy.
						AGENT_1 = agent_courtesan
						AGENT_2 = agent_amanuensis
						AGENT_3 = agent_eunuch
						# Success.
						AGENT_4 = agent_sycophant
						# Speed.
						AGENT_5 = agent_political_socialite
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = slander
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_sycophant
						AGENT_2 = agent_intermediary
						# Speed.
						AGENT_3 = agent_political_socialite
						AGENT_4 = agent_bureaucrat
						# Secrecy.
						AGENT_5 = agent_courtesan
					}
				}
			}
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
			# Trigger a catalyst if target has a lot of power
			show_as_tooltip = {
				if = {
					limit = {
						exists = scope:recipient.var:movement_power
						scope:recipient.var:movement_power >= medium_movement_power_value
					}
					tgp_activate_catalyst_against_hegemon_effect = {
						HEGEMON = scope:recipient.top_liege
						CATALYST = catalyst_governor_slander
					}
				}
			}
			stress_impact = {
				compassionate = minor_stress_impact_gain
				honest = minor_stress_impact_gain
				just = minor_stress_impact_gain
			}
		}
		scope:recipient = { custom_tooltip = slander_modifier_tt }
	}

	ai_potential = {
		ai_honor <= 20
		OR = {
			primary_title.tier >= tier_duchy
			AND = {
				this = house.house_head
				is_landless_administrative = yes
			}
		}
		NOR = {
			has_trait = honest
			any_scheme = {
				is_scheme_category = hostile
			}
		}
		OR = { # So that the cycle doesn't get nuked by having too many landless families
			NOT = { government_allows = merit }
			is_landed = yes
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0

		#Competing candidate
		modifier = {
			NOT = { government_allows = merit }
			scope:recipient = { is_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = 30
		}
		modifier = {
			NOT = { government_allows = merit }
			scope:recipient = { is_winning_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = 50
		}
		modifier = {
			government_allows = merit
			NOT = {
				is_in_same_movement_as = { TARGET = scope:recipient }
			}
			add = 30
		}

		# House & Family
		modifier = {
			is_close_family_of = scope:recipient
			add = -20
		}
		modifier = {
			house = scope:recipient.house
			add = -50
		}
		modifier = {
			house.house_head = scope:recipient
			add = -50
		}

		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			add = 150
		}

		# Relationships
		modifier = {
			add = 25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 150
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 1000
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -25
			has_any_mild_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		
		#Personality
		modifier = {
			has_trait = compassionate
			add = -75
		}
		modifier = {
			has_trait = content
			add = -75
		}
		modifier = {
			has_trait = ambitious
			factor = 2
		}
		modifier = {
			has_trait = deceitful
			factor = 2
		}
		
		modifier = {
			factor = 0
			OR = {
				has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
				has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
			}
		}

		# More likely against powerful or dominant families
		modifier = {
			scope:recipient.house ?= {
				OR = {
					is_powerful_family = yes
					is_dominant_family = yes
				}
			}
			factor = 2
		}
		
		# Avoid fellow movement members if possible
		modifier = {
			factor = {
				value = 0.25
				if = {
					limit = {
						is_in_pro_hegemon_or_hegemon_movement = yes
					}
					multiply = 0.5
				}
			}
			is_in_same_movement_as = { TARGET = scope:recipient }
		}

		ttd_minor_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Promote
start_promote_interaction = {
	icon = icon_scheme_promote
	interface_priority = 230
	common_interaction = no
	category = interaction_category_succession

	send_name = START_SCHEME

	filter_tags = { admin_house_head dynastic_cycle ceremonial_liege }

	scheme = promote
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = self
 	}
	ai_targets = {
		ai_recipients = spouses
	}
	ai_targets = {
		ai_recipients = children
		max = 10
	}
	ai_targets = {
		ai_recipients = family
		max = 10
	}
	ai_targets = {
		ai_recipients = dynasty
		max = 10
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 180
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}
	
	is_shown = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			government_allows = administrative
		}
		scope:recipient = {
			government_allows = administrative
			top_liege = scope:actor.top_liege

			# don't show on the huangdi
			OR = {
				NOT = { government_allows = merit }
				is_independent_ruler = no
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = promote
				target_character = scope:recipient
			}
		}
		scope:recipient = {
			is_adult = yes
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:actor = {
					can_start_scheme = {
						type = promote
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_promote_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_promote_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_promote_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_promote_interaction.tt.agent_focus_speed
	}

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

				left_icon = scope:actor					
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = promote
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_intermediary
						AGENT_2 = agent_proponent
						AGENT_3 = agent_proponent
						AGENT_4 = agent_sycophant
						# Speed.
						AGENT_5 = agent_political_socialite
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = promote
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Speed.
						AGENT_1 = agent_political_socialite
						AGENT_2 = agent_political_socialite
						AGENT_3 = agent_bureaucrat
						AGENT_4 = agent_bureaucrat
						# Success.
						AGENT_5 = agent_proponent
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = promote
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						AGENT_3 = agent_sycophant
						# Speed.
						AGENT_4 = agent_political_socialite
						AGENT_5 = agent_bureaucrat
					}
				}
			}
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
		}
		scope:recipient = {
			if = {
				limit = {
					this != scope:actor
				}
				custom_tooltip = promote_scheme_success_tt
			}
			else = {
				custom_tooltip = promote_scheme_success_self_tt
			}
		}
	}

	ai_potential = {
		OR = {
			primary_title.tier >= tier_duchy
			AND = {
				this = house.house_head
				is_landless_administrative = yes
			}
		}
		NOT = {
			any_scheme = {
				is_scheme_category = hostile
			}
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0

		#Competing candidate
		modifier = {
			scope:recipient = { is_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = -50
		}

		modifier = {
			scope:recipient = { is_winning_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = -75
		}

		#Personality
		modifier = {
			has_trait = gregarious
			add = 15
		}

		modifier = {
			has_trait = honest
			add = -10
		}

		modifier = {
			has_trait = shy
			add = -10
		}

		modifier = {
			has_trait = ambitious
			add = 20
		}

		# House & Family
		modifier = {
			is_close_family_of = scope:recipient
			add = 30
		}

		modifier = {
			is_parent_of = scope:recipient
			add = 50
		}

		modifier = {
			house = scope:recipient.house
			add = 50
		}

		modifier = {
			house.house_head = scope:recipient
			add = 50
		}

		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			add = -100
		}

		# Relationships
		modifier = {
			add = -25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -50
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -100
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 25
			has_any_mild_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 50
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 100
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		ttd_minor_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Challenge Status
start_challenge_status_interaction = {
	icon = icon_scheme_challenge_status
	interface_priority = 80
	category = interaction_category_hostile
	filter_tags = { admin_house_head }
	common_interaction = no
	send_name = START_SCHEME

	scheme = challenge_status
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = peer_vassals
		max = 5
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 92
		duchy = 48
		kingdom = 24
		empire = 12
		hegemony = 0
	}
	
	is_shown = {
		scope:actor = {
			government_allows = administrative
		}
		scope:recipient != scope:actor
		scope:recipient = {
			government_allows = administrative
			top_liege = scope:actor.top_liege
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_lowborn = no
		}
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			can_start_scheme = {
				type = challenge_status
				target_character = scope:recipient
			}
		}
		tgp_blocked_action_against_tenno_trigger = {
			ACTOR = scope:actor
			TARGET = scope:recipient
		}
		trigger_if = {
			limit = { scope:actor = { has_variable = no_scheming_allowed_var } }
			custom_tooltip = {
				text = no_scheming_allowed_var_tt
				scope:actor.var:no_scheming_allowed_var != scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:actor = {
					can_start_scheme = {
						type = challenge_status
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_challenge_status_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_challenge_status_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_challenge_status_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_challenge_status_interaction.tt.agent_focus_speed
	}

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

				left_icon = scope:actor
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = challenge_status
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						AGENT_3 = agent_sycophant
						# Speed.
						AGENT_4 = agent_political_socialite
						AGENT_5 = agent_bureaucrat
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = challenge_status
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						# Speed.
						AGENT_3 = agent_political_socialite
						AGENT_4 = agent_bureaucrat
						AGENT_5 = agent_bureaucrat
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = challenge_status
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_proponent
						AGENT_2 = agent_intermediary
						# Speed.
						AGENT_3 = agent_political_socialite
						AGENT_4 = agent_bureaucrat
						# Secrecy.
						AGENT_5 = agent_amanuensis
					}
				}
			}
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
			show_as_tooltip = {
				tgp_activate_catalyst_against_hegemon_effect = {
					HEGEMON = scope:recipient.top_liege
					CATALYST = catalyst_governor_challenged_status
				}
			}
			custom_tooltip = challenge_status_success_actor_tt
		}
		scope:recipient = {
			save_scope_as = target
			custom_tooltip = challenge_status_success_recipient_tt
		}
	}

	ai_potential = {
		ai_honor <= 20
		NOR = {
			has_trait = honest
			any_scheme = {
				is_scheme_category = political
			}
		}
		government_allows = administrative
		OR = { # So that the cycle doesn't get nuked by having too many landless families
			NOT = { government_allows = merit }
			is_landed = yes
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0

		#Competing candidate
		modifier = {
			NOT = { government_allows = merit }
			scope:recipient = { is_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = 30
		}
		modifier = {
			NOT = { government_allows = merit }
			scope:recipient = { is_winning_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = 50
		}
		modifier = {
			government_allows = merit
			NOT = {
				is_in_same_movement_as = { TARGET = scope:recipient }
			}
			add = 30
		}

		# House & Family
		modifier = {
			is_close_family_of = scope:recipient
			add = -20
		}
		modifier = {
			house = scope:recipient.house
			add = -50
		}
		modifier = {
			house.house_head = scope:recipient
			add = -50
		}

		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			add = 150
		}

		# Relationships
		modifier = {
			add = 25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 150
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 1000
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -25
			has_any_mild_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			factor = 0
			OR = {
				has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
				has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
			}
		}
		
		#Personality
		modifier = {
			has_trait = vengeful
			add = 15
		}
		modifier = {
			has_trait = deceitful
			add = 15
		}
		modifier = {
			has_trait = compassionate
			add = -75
		}
		modifier = {
			has_trait = content
			add = -75
		}
		modifier = {
			has_trait = ambitious
			factor = 2
		}
		modifier = {
			has_trait = vengeful
			factor = 2
		}

		# More likely against powerful or dominant families
		modifier = {
			scope:recipient.house ?= {
				OR = {
					is_powerful_family = yes
					is_dominant_family = yes
				}
			}
			factor = 2
		}
		
		# Avoid fellow movement members if possible
		modifier = {
			factor = {
				value = 0.25
				if = {
					limit = {
						is_in_pro_hegemon_or_hegemon_movement = yes
					}
					multiply = 0.5
				}
			}
			is_in_same_movement_as = { TARGET = scope:recipient }
		}

		ttd_minor_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Expand Power Base
start_expand_power_base_interaction = {
	icon = icon_scheme_expand_power_base
	common_interaction = yes
	interface_priority = 70
	category = interaction_category_succession

	send_name = START_SCHEME

	scheme = expand_power_base
	ignores_pending_interaction_block = yes

	cooldown = { years = 10 }

	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 48
		kingdom = 36
		empire = 36
		hegemony = 36
	}
	ai_targets = {
		ai_recipients = self
	}
	
	is_shown = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			government_allows = administrative
			this = scope:recipient
			exists = house.house_head
			house.house_head = {
				any_held_title = {
					is_noble_family_title = yes
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = expand_power_base
				target_character = scope:actor
			}
		}
	}

	desc = scheme_interaction_tt_expand_power_base_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_expand_power_base_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_expand_power_base_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_expand_power_base_interaction.tt.agent_focus_speed
	}

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

				left_icon = scope:actor

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = expand_power_base
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:actor
						# Success.
						AGENT_1 = agent_intermediary
						AGENT_2 = agent_proponent
						AGENT_3 = agent_proponent
						AGENT_4 = agent_sycophant
						# Speed.
						AGENT_5 = agent_bureaucrat
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = expand_power_base
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:actor
						# Speed.
						AGENT_1 = agent_political_socialite
						AGENT_2 = agent_political_socialite
						AGENT_3 = agent_bureaucrat
						AGENT_4 = agent_bureaucrat
						# Success.
						AGENT_5 = agent_intermediary
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = expand_power_base
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:actor
						# Success.
						AGENT_1 = agent_intermediary
						AGENT_2 = agent_proponent
						AGENT_3 = agent_sycophant
						# Speed.
						AGENT_4 = agent_political_socialite
						AGENT_5 = agent_bureaucrat
					}
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = stewardship }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes

			custom_tooltip = expand_power_base_effect_tt
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0
		# The more I'm investing, the more I want my cap to increase
		modifier = {
			add = {
				value = 0
				every_succession_appointment_invested_candidate = {
					add = 5
				}
			}
		}

		#Not a governor
		modifier = {
			is_governor = no
			add = 30
		}

		#Personality
		modifier = {
			has_trait = ambitious
			add = 20
		}

		ttd_minor_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient.top_liege }
	}
}

# Depose Scheme
start_depose_interaction = {
	icon = icon_scheme_depose
	interface_priority = 16
	category = interaction_category_vassal

	filter_tags = { admin_liege }

	send_name = START_SCHEME

	scheme = depose
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
		max = 1
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 120
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 0
	}
	
	is_shown = {
		scope:actor = { government_allows = administrative }
		scope:recipient = {
			government_allows = administrative
			primary_title.tier >= tier_empire # Target has to be the emperor
			this = top_liege
			this != scope:actor
			top_liege.primary_title = scope:actor.top_liege.primary_title # This hides the tooltip
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			custom_tooltip = {
				text = house_head_powerful_dominant_family_trigger
				house = {
					# Must be a powerful or dominant family
					OR = {
						is_powerful_family = yes
						is_dominant_family = yes
					}
				}
				# Must be the house head
				house.house_head = scope:actor
			}
			# Must not be from the same House as the Emperor 
			house != scope:actor.top_liege.house
			# If you are a part of the Dynastic Cycle, we had additional requirements
			trigger_if = {
				limit = {
					government_has_flag = government_is_celestial
					any_character_situation = {
						situation_type = dynastic_cycle
					}
				}
				situation:dynastic_cycle ?= {
					situation_current_phase = situation_dynastic_cycle_phase_instability
				}
				merit_level >= 6
				scope:recipient = {
					legitimacy_level < 3
				}
			}
			can_start_scheme = {
				type = depose
				target_character = scope:recipient
			}
		}
		scope:recipient = {
			NOT = { has_strong_hook = scope:actor }
		}
	}

	desc = scheme_interaction_tt_depose_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_depose_interaction.tt.agent_focus_balance
	}
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_depose_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_depose_interaction.tt.agent_focus_speed
	}
	## Focused on Secrecy.
	send_option = {
		flag = agent_focus_secrecy
		current_description = start_depose_interaction.tt.agent_focus_secrecy
	}

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

				left_icon = scope:actor					
				right_icon = scope:recipient

				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = depose
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_intermediary
						AGENT_2 = agent_proponent
						AGENT_3 = agent_sycophant
						# Speed.
						AGENT_4 = agent_political_socialite
						# Secrecy.
						AGENT_5 = agent_courtesan
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = depose
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Speed.
						AGENT_1 = agent_political_socialite
						AGENT_2 = agent_political_socialite
						AGENT_3 = agent_bureaucrat
						# Success.
						AGENT_4 = agent_proponent
						# Secrecy.
						AGENT_5 = agent_courtesan
					}
				}
				# Secrecy.
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = depose
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Secrecy.
						AGENT_1 = agent_courtesan
						AGENT_2 = agent_amanuensis
						AGENT_3 = agent_eunuch_speed
						# Success.
						AGENT_4 = agent_proponent
						# Speed.
						AGENT_5 = agent_political_socialite
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = depose
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_intermediary
						AGENT_2 = agent_proponent
						# Speed.
						AGENT_3 = agent_political_socialite
						AGENT_4 = agent_bureaucrat
						# Secrecy.
						AGENT_5 = agent_courtesan
					}
				}
			}
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes

			stress_impact = {
				compassionate = minor_stress_impact_gain
				honest = minor_stress_impact_gain
				just = minor_stress_impact_gain
				loyal = major_stress_impact_gain
			}
		}
	}

	ai_potential = {
		OR = {
			primary_title.tier >= tier_duchy
			AND = {
				this = house.house_head
				is_landless_administrative = yes
			}
		}
		NOT = {
			any_scheme = {
				is_scheme_category = hostile
			}
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0

		# Dominant Family
		modifier = {
			house = { is_dominant_family = yes }
			add = 50
		}

		#Personality
		modifier = {
			has_trait = ambitious
			add = 15
		}
		modifier = {
			has_trait = deceitful
			add = 15
		}
		modifier = {
			has_trait = honest
			add = -15
		}
		modifier = {
			has_trait = compassionate
			add = -15
		}
		modifier = {
			has_trait = just
			add = -10
		}

		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			add = 50
		}

		# Relationships
		modifier = {
			add = 25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 50
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 100
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -25
			has_any_mild_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -50
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			factor = 0
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		# House & Family
		modifier = { # Family and house members never want to depose each other
			OR = {
				is_close_family_of = scope:recipient
				AND = {
					exists = house
					NOT = { scope:recipient.house ?= house }
				}
			}
			NOR = { # Unless they are...
				has_trait = ambitious
				has_trait = greedy
				has_trait = deceitful
			}
			factor = 0
		}
		
		# Only depose if you dislike the target
		modifier = {
			opinion = { target = scope:recipient value > -30 }
			factor = 0
		}

		# EP3 Dynasty Legacy Perk Malus
		modifier = {
			add = -70
			scope:target.dynasty ?= { has_dynasty_perk = ep3_administrative_legacy_5 }
		}

		ttd_medium_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Foster Legitimacy
start_foster_legitimacy_interaction = {
	icon = icon_scheme_foster_legitimacy
	interface_priority = 10
	common_interaction = no
	category = interaction_category_vassal

	filter_tags = { admin_liege }

	send_name = START_SCHEME

	scheme = foster_legitimacy_scheme
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 120
		duchy = 60
		kingdom = 60
		empire = 0
		hegemony = 0
	}
	
	is_shown = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			government_allows = administrative
		}

		scope:recipient != scope:actor

		scope:recipient = {
			this = scope:actor.liege
			has_legitimacy = yes
			is_adult = yes
			# Admin type governments have this available - Except for celestial
			government_allows = administrative
			NOT = { government_has_flag = government_is_celestial }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = foster_legitimacy_scheme
				target_character = scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:actor = {
					can_start_scheme = {
						type = foster_legitimacy_scheme
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_foster_legitimacy_approved
		}
	}

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

				left_icon = scope:actor					
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = foster_legitimacy_scheme
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = diplomacy }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes

			custom_tooltip = foster_legitimacy_positive_outcome_actor_tt
			custom_tooltip = foster_legitimacy_negative_outcome_tt
		}
		scope:recipient = {
			custom_tooltip = foster_legitimacy_positive_outcome_recipient_tt
		}
	}

	ai_potential = {
		is_governor = yes
		trigger_if = {
			limit = { exists = scope:recipient }
			opinion = {
				target = scope:recipient
				value > 0
			}
		}
		# Only try to foster legitimacy if they don't meet your expectations
		scope:recipient ?= {
			NOT = { meets_legitimacy_expectation_of = scope:actor }
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0 # So the AI doesn't mess with your Legitimacy too often

		# Legitimacy Levels
		modifier = {
			scope:recipient.legitimacy_level >= 4
			add = -50
		}

		#Personality
		modifier = {
			has_lifestyle = diplomacy_lifestyle
			add = 15
		}
		
		modifier = {
			has_trait = loyal
			add = 15
		}
		
		modifier = {
			has_trait = disloyal
			add = -25
		}

		modifier = {
			has_trait = deceitful
			add = -15
		}

		# House & Family, but you need to get along
		modifier = {
			is_close_family_of = scope:recipient
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
			add = 25
		}
		
		modifier = {
			house = scope:recipient.house
			has_any_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
			add = 15
		}

		# Relationships
		modifier = {
			add = -25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -50
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -100
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		ttd_medium_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Damage Legitimacy
start_damage_legitimacy_interaction = {
	icon = icon_scheme_damage_legitimacy
	interface_priority = 9 # listed after start_foster_legitimacy_interaction
	common_interaction = no
	category = interaction_category_vassal

	filter_tags = { admin_liege }

	send_name = START_SCHEME

	scheme = damage_legitimacy_scheme
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = liege
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 120
		duchy = 60
		kingdom = 60
		empire = 0
		hegemony = 0
	}
	
	is_shown = {
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			government_allows = administrative
		}

		scope:recipient != scope:actor

		scope:recipient = {
			this = scope:actor.liege
			has_legitimacy = yes
			is_adult = yes
			# Admin type governments have this available - Except for celestial
			government_allows = administrative
			NOT = { government_has_flag = government_is_celestial }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = damage_legitimacy_scheme
				target_character = scope:recipient
			}
		}
	}

	desc = {
		triggered_desc = {
			trigger = {
				scope:actor = {
					can_start_scheme = {
						type = damage_legitimacy_scheme
						target_character = scope:recipient
					}
				}
			}
			desc = scheme_interaction_tt_damage_legitimacy_approved
		}
	}

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

				left_icon = scope:actor					
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = damage_legitimacy_scheme
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = intrigue }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes

			custom_tooltip = damage_legitimacy_negative_outcome_tt

			stress_impact = {
				loyal = major_stress_impact_gain
				honest = medium_stress_impact_gain
			}
		}
		scope:recipient = {
			custom_tooltip = damage_legitimacy_positive_outcome_tt
		}
	}

	ai_potential = {
		is_governor = yes
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0 # So the AI doesn't mess with your Legitimacy too often

		#Personality
		modifier = {
			has_lifestyle = intrigue_lifestyle
			add = 15
		}
		
		modifier = {
			has_trait = disloyal
			add = 15
		}
		
		modifier = {
			has_trait = deceitful
			add = 15
		}
		
		modifier = {
			has_trait = loyal
			add = -25
		}

		modifier = {
			has_trait = honest
			add = -15
		}
		
		# Relationships
		modifier = {
			add = -25
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		
		modifier = {
			add = -50
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		
		modifier = {
			add = 25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 50
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 75
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		ttd_medium_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Dispute Border - AKA Boundary Dispute
start_dispute_border_interaction = {
	icon = icon_dispute_border
	interface_priority = 75
	category = interaction_category_vassal 
	send_name = START_SCHEME 
	scheme = dispute_border
	ignores_pending_interaction_block = yes 
	ai_targets = { ai_recipients = peer_vassals }
	ai_frequency_by_tier = {
		barony = 0
		county = 120
		duchy = 60
		kingdom = 0
		empire = 0
		hegemony = 0
	}
	common_interaction = yes

	filter_tags = { admin_governor }

	cooldown_against_recipient = { years = 5 }

	target_type = title
	target_filter = recipient_realm_titles

	can_be_picked_title = {
		scope:target = {
			ep3_boundary_dispute_county_trigger = {
				OWNER = scope:actor
				TARGET = scope:recipient
			}
		}
	}

	is_shown = {
		scope:actor = {
			is_governor = yes
			NOR = {
				government_has_flag = government_is_celestial # Celestial governors do not have access to this
				government_has_flag = government_is_japan_administrative # Celestial governors do not have access to this
				main_administrative_tier = tier_county
			}
		}
		scope:recipient = {
			this != scope:actor
			is_alive = yes
			top_liege = scope:actor.top_liege
			is_governor_or_admin_count = yes
			in_diplomatic_range = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_available_adult = yes
			trigger_if = {
				limit = { exists = scope:target }
				can_start_scheme = {
					type = dispute_border
					target_title = scope:target
				}
			}
			trigger_if = {
				limit = {
					scope:recipient = {
						sub_realm_size > 1
					}
				}
				custom_tooltip = {
					text = dispute_border_county_neighbour_tt
					character_is_realm_neighbor = scope:recipient
				}
			}
			trigger_else = {
				custom_tooltip = {
					text = dispute_border_county_neighbour_tt
					scope:recipient.capital_county = {
						holder = scope:recipient
						any_neighboring_county = {
							OR = {
								holder = scope:actor
								holder.liege ?= scope:actor
							}
						}
					}
				}
			}
			is_in_civil_war = no
			custom_tooltip = {
				text = admin_vassal_border_limit_desc
				top_liege ?= {
					NOT = { has_realm_law_flag = admin_vassal_border_limit }
				}
			}
			trigger_if = {
				limit = {
					top_liege ?= {
						NOT = { has_realm_law_flag = admin_vassal_border_limit }
						has_realm_law_flag = admin_vassal_border_restricted
					}
				}
				custom_tooltip = {
					text = interaction_must_be_powerful_or_dominant_family_tt
					house = {
						OR = {
							is_powerful_family = yes
							is_dominant_family = yes
						}
					}
				}
			}
		}
		scope:recipient = {
			is_in_civil_war = no
		}
	}

	desc = start_dispute_border_interaction_desc

	cost = {
		influence = {
			add = scope:actor.massive_influence_gain
		}
	}

	# Scheme Starter Packages
	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_dispute_border_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_dispute_border_interaction.tt.agent_focus_speed
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_dispute_border_notification
				left_icon = scope:recipient					
				right_icon = scope:target
				scope:recipient = {
					send_interface_toast = {
						type = event_toast_effect_bad
						title = start_dispute_border_notification
						left_icon = scope:actor					
						right_icon = scope:target
						scope:actor = {
							# Success.
							if = {
								limit = { scope:agent_focus_success ?= yes }
								begin_scheme_with_agents_effect = {
									SCHEME_TYPE = dispute_border
									TARGET_TYPE = target_title
									TARGET_SCOPE = scope:target
									# Success.
									AGENT_1 = agent_intermediary
									AGENT_2 = agent_proponent
									AGENT_3 = agent_sycophant
									# Speed.
									AGENT_4 = agent_political_socialite
									AGENT_5 = agent_bureaucrat
								}
							}
							# Speed.
							else = {
								begin_scheme_with_agents_effect = {
									SCHEME_TYPE = dispute_border
									TARGET_TYPE = target_title
									TARGET_SCOPE = scope:target
									# Success.
									AGENT_1 = agent_intermediary
									AGENT_2 = agent_proponent
									# Speed.
									AGENT_3 = agent_political_socialite
									AGENT_4 = agent_bureaucrat
									AGENT_5 = agent_bureaucrat
								}
							}
						}
					}
				}
			}
			random_scheme = {
				type = dispute_border
				limit = {
					scheme_target_title = scope:target
				}
				set_variable = {
					name = target_character
					value = scope:recipient
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = diplomacy }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
			if = {
				limit = {
					scope:recipient = {
						highest_held_title_tier >= tier_duchy
					}
				}
				custom_tooltip = boundary_dispute_outcome_tt
			}
			else = {
				custom_tooltip = boundary_dispute_outcome_vassal_tt
			}

			stress_impact = {
				content = medium_stress_impact_gain
			}
		}
		scope:recipient = {
			if = {
				limit = {
					is_ai = yes
					highest_held_title_tier >= tier_duchy
				}
				add_opinion = {
					target = scope:actor
					modifier = attempted_dispute_border_opinion
				}
			}
			else_if = {
				limit = {
					is_ai = yes
				}
				add_opinion = {
					target = scope:actor
					modifier = attempted_dispute_border_opinion
					opinion = -40
				}
			}
		}
	}

	ai_potential = {
		NOT = {
			any_scheme = { is_scheme_category = political }
		}
		is_governor = yes
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0
		#Personality
		modifier = {
			has_trait = ambitious
			add = 15
		}
		modifier = {
			has_trait = content
			add = -15
		}
		# Land
		modifier = {
			scope:recipient = {
				any_sub_realm_county = {
					OR = {
						duchy.holder = scope:actor
						kingdom.holder = scope:actor
					}
				}
			}
			add = 50
		}
		# Relationships
		modifier = {
			add = -25
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -50
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 15
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 25
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 50
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		# House
		modifier = {
			add = -50
			scope:recipient.house ?= scope:actor.house
		}

		ttd_title_distance_ai_will_do_modifier = { CHARACTER = scope:actor TITLE = scope:target }
	}
}

# Subsume Province
start_subsume_province_interaction = {
	icon = icon_subsume_province
	common_interaction = yes
	interface_priority = 50
	category = interaction_category_vassal
	send_name = START_SCHEME 
	scheme = subsume_province
	ignores_pending_interaction_block = yes 
	ai_targets = { ai_recipients = peer_vassals }
	ai_frequency_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 0
		hegemony = 0
	}

	filter_tags = { admin_governor }


	cooldown = { years = 5 }

	target_type = title
	target_filter = recipient_de_jure_titles

	can_be_picked_title = {
		scope:actor = {
			can_start_scheme = {
				type = subsume_province
				target_title = scope:target
			}
		}
	}

	has_valid_target_showing_failures_only = {
		scope:target ?= {
			tier = tier_duchy
			holder ?= scope:recipient
		}
	}

	desc = start_subsume_province_interaction_desc

	is_shown = {
		scope:actor = { is_governor = yes }
		scope:recipient = {
			is_alive = yes
			top_liege = scope:actor.top_liege
			is_governor = yes
			NOR = { 
				this = scope:actor 
				scope:actor.house = scope:recipient.house
				government_has_flag = government_is_celestial # Celestial governors do not have access to this
				government_has_flag = government_is_meritocratic
				government_has_flag = government_is_japan_administrative
			}
			in_diplomatic_range = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_available_adult = yes
			trigger_if = {
				limit = { exists = scope:target }
				can_start_scheme = {
					type = subsume_province
					target_title = scope:target
				}
			}
			trigger_if = {
				limit = {
					top_liege ?= {
						NOT = { has_realm_law_flag = admin_vassal_border_limit }
					}
				}
				custom_tooltip = {
					text = interaction_must_be_powerful_or_dominant_family_tt
					house = {
						OR = {
							is_powerful_family = yes
							is_dominant_family = yes
						}
					}
				}
			}
			is_in_civil_war = no
			custom_tooltip = {
				text = admin_vassal_border_limit_desc
				top_liege ?= {
					NOT = { has_realm_law_flag = admin_vassal_border_limit }
				}
			}
		}
		scope:recipient = {
			custom_tooltip = {
				text = subsume_province_neighboring_duchy_tt
				any_sub_realm_county = {
					any_neighboring_county = {
						county_held_or_vassal_to_target_trigger = { TARGET = scope:actor }
					}
				}
			}
			custom_tooltip = {
				text = subsume_province_recipient_scheming_against_you_tt
				NOT = {
					is_scheming_against = {
						type = subsume_province
						target = scope:actor
					}
				}
			}
			custom_tooltip = {
				text = subsume_province_recipient_house_power_or_gov_efficiency_tt
				OR = {
					governor_efficiency_presented <= -25
					AND = {
						trigger_if = {
							limit = { house = { is_powerful_family = yes } }
							scope:actor.house = { is_dominant_family = yes }
						}
						house = { is_dominant_family = no }
					}
				}
			}
			is_in_civil_war = no
			NOT = { is_diarch_of_target = liege }
		}
	}

	cost = {
		influence = {
			add = {
				value = scope:actor.massive_influence_gain
				multiply = 4
			}
		}
	}

	# Scheme Starter Packages
	options_heading = schemes.t.agent_packages
	send_options_exclusive = yes
	## Focused on Success Chance.
	send_option = {
		flag = agent_focus_success
		current_description = start_subsume_province_interaction.tt.agent_focus_success
	}
	## Focused on Speed.
	send_option = {
		flag = agent_focus_speed
		current_description = start_subsume_province_interaction.tt.agent_focus_speed
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_subsume_province_notification
				left_icon = scope:recipient					
				right_icon = scope:target
				scope:recipient = {
					send_interface_toast = {
						type = event_toast_effect_bad
						title = start_subsume_province_notification
						left_icon = scope:actor					
						right_icon = scope:target
						scope:actor = {
							# Success.
							if = {
								limit = { scope:agent_focus_success ?= yes }
								begin_scheme_with_agents_effect = {
									SCHEME_TYPE = subsume_province
									TARGET_TYPE = target_title
									TARGET_SCOPE = scope:target
									# Success.
									AGENT_1 = agent_intermediary
									AGENT_2 = agent_proponent
									AGENT_3 = agent_proponent
									# Speed.
									AGENT_4 = agent_political_socialite
									AGENT_5 = agent_political_socialite
								}
							}
							# Speed.
							else = {
								begin_scheme_with_agents_effect = {
									SCHEME_TYPE = subsume_province
									TARGET_TYPE = target_title
									TARGET_SCOPE = scope:target
									# Success.
									AGENT_1 = agent_intermediary
									AGENT_2 = agent_proponent
									# Speed.
									AGENT_3 = agent_political_socialite
									AGENT_4 = agent_political_socialite
									AGENT_5 = agent_political_socialite
								}
							}
						}
					}
				}
			}
			random_scheme = {
				type = subsume_province
				limit = {
					scheme_target_title = scope:target
				}
				set_variable = {
					name = target_character
					value = scope:recipient
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = diplomacy }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
			custom_tooltip = subsume_province_scheme_success_outcome_tt
			stress_impact = {
				content = medium_stress_impact_gain
			}
		}
		scope:recipient = {
			if = {
				limit = { is_ai = yes }
				add_opinion = {
					target = scope:actor
					modifier = attempted_subsume_province_opinion
				}
			}
		}
	}

	ai_potential = {
		NOT = {
			any_scheme = { is_scheme_category = political }
		}
		is_governor = yes
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 0

		#Personality
		modifier = {
			has_trait = ambitious
			add = 15
		}
		modifier = {
			has_trait = content
			add = -15
		}
		# Land
		modifier = {
			scope:recipient = {
				any_sub_realm_county = {
					OR = {
						duchy.holder = scope:actor
						kingdom.holder = scope:actor
					}
				}
			}
			add = 50
		}
		# Relationships
		modifier = {
			add = -25
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -50
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 15
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 25
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 50
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		# House
		modifier = {
			add = -50
			scope:recipient.house ?= scope:actor.house
		}

		ttd_title_distance_ai_will_do_modifier = { CHARACTER = scope:actor TITLE = scope:target }
	}
}

# Raid Estate
start_raid_estate_interaction = {
	icon = icon_raid_estate
	interface_priority = 90
	category = interaction_category_hostile
	send_name = START_SCHEME 
	scheme = raid_estate
	ignores_pending_interaction_block = yes
	ai_frequency_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 24
		empire = 24
		hegemony = 24
	}

	ai_targets = { ai_recipients = liege }
	ai_targets = {
		ai_recipients = peer_vassals
		max = 20
	}
	ai_targets = {
		ai_recipients = vassals
		max = 20
	}

	filter_tags = { admin_house_head }

	cooldown = { years = 5 }

	highlighted_reason = start_raid_estate_interaction_HIGHLIGHTED

	is_highlighted = { scope:actor.var:raid_estate_permission ?= scope:recipient.house }

	redirect = {
		scope:recipient = {
			if = {
				limit = {
					is_house_head = no
					exists = house.house_head
				}
				house.house_head = { save_scope_as = recipient }
			}
		}
	}

	is_shown = {
		scope:actor = {
			domicile ?= {
				OR = {
					is_domicile_type = estate
					is_domicile_type = east_asian_estate
					is_domicile_type = japanese_manor
				}
			}
		}
		scope:recipient.house.house_head ?= {
			domicile ?= {
				OR = {
					is_domicile_type = estate
					is_domicile_type = east_asian_estate
					is_domicile_type = japanese_manor
				}
			}
			is_independent_ruler = no
			top_liege = scope:actor.top_liege
			house != scope:actor.house
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_available_adult = yes
			shared_raid_estate_participant_valid_trigger = yes
			trigger_if = {
				limit = {
					government_has_flag = government_is_celestial
					exists = var:movement_power
				}
				custom_tooltip = {
					text = actor_not_extremely_high_movement_power
					var:movement_power >= extremely_high_movement_power_value
				}
			}
		}
		scope:recipient.house.house_head ?= {
			shared_raid_estate_participant_valid_trigger = yes
			domicile ?= {
				trigger_if = {
					limit = { is_domicile_type = japanese_manor }
					custom_tooltip = {
						text = raid_estate_japanese_manor_tt
						is_domicile_type = japanese_manor
					}
				}
				trigger_else_if = {
					limit = { is_domicile_type = east_asian_estate }
					custom_tooltip = {
						text = raid_estate_estate_tt
						is_domicile_type = east_asian_estate
					}
				}
				trigger_else = {
					custom_tooltip = {
						text = raid_estate_estate_tt
						is_domicile_type = estate
					}
				}
			}
		}
		trigger_if = {
			limit = { scope:actor = { has_variable = no_scheming_allowed_var } }
			custom_tooltip = {
				text = no_scheming_allowed_var_tt
				scope:actor.var:no_scheming_allowed_var != scope:recipient
			}
		}
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient.domicile ?= { is_domicile_type = japanese_manor }
				}
				desc = start_raid_estate_interaction_desc_japan
			}
			desc = start_raid_estate_interaction_desc
		}
	}

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

	on_accept = {
		scope:recipient = { 
			custom_tooltip = raid_estate_kill_maim_imprison_house_members_tt
			custom_tooltip = raid_estate_destroy_buildings_tt
			if = {
				limit = {
					domicile ?= { is_domicile_type = japanese_manor }
				}
				custom_tooltip = raid_estate_house_modifier_tt_japan
			}
			else = { custom_tooltip = raid_estate_house_modifier_tt }
			random_held_title = {
				limit = { is_noble_family_title = yes }
				save_scope_as = target_title
			}
		}
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_raid_estate_notification
				left_icon = scope:recipient					
				right_icon = scope:target_title
				# Success.
				if = {
					limit = { scope:agent_focus_success ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = raid_estate
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_scout
						AGENT_2 = agent_scout
						AGENT_3 = agent_muscle
						# Speed.
						AGENT_4 = agent_infiltrator
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
				# Speed.
				else_if = {
					limit = { scope:agent_focus_speed ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = raid_estate
						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_scout
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
				# Secrecy.
				else_if = {
					limit = { scope:agent_focus_secrecy ?= yes }
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = raid_estate
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Secrecy.
						AGENT_1 = agent_lookout
						AGENT_2 = agent_lookout
						AGENT_3 = agent_alibi
						# Success.
						AGENT_4 = agent_scout
						# Speed.
						AGENT_5 = agent_infiltrator
					}
				}
				# Balanced.
				else = {
					begin_scheme_with_agents_effect = {
						SCHEME_TYPE = raid_estate
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:recipient
						# Success.
						AGENT_1 = agent_scout
						AGENT_2 = agent_muscle
						# Speed.
						AGENT_3 = agent_infiltrator
						AGENT_4 = agent_footpad
						# Secrecy.
						AGENT_5 = agent_lookout
					}
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = intrigue }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes

			custom_tooltip = raid_estate_gain_coin_tt
			# Relations
			if = {
				limit = { has_relation_rival = scope:recipient }
				custom_tooltip = raid_estate_nemesis_relation_tt
			}
			else = { custom_tooltip = raid_estate_rival_relation_tt }
			# Catalysts
			if = {
				limit = {
					NOT = { var:raid_estate_permission ?= scope:recipient.house }
				}
				show_as_tooltip = {
					tgp_activate_catalyst_against_hegemon_effect = {
						HEGEMON = scope:recipient.top_liege
						CATALYST = catalyst_governor_raided_estate
					}
				}
			}
			# Stress
			stress_impact = {
				content = medium_stress_impact_gain
			}
			if = {
				limit = { has_relation_nemesis = scope:recipient }
				stress_impact = { base = major_stress_impact_loss }
			}
			else_if = {
				limit = { has_relation_rival = scope:recipient }
				stress_impact = { base = medium_stress_impact_loss }
			}
		}
	}

	ai_potential = {
		NOT = {
			any_scheme = { is_hostile = yes }
		}
		any_held_title = { is_noble_family_title = yes }
	}
	
	auto_accept = yes

	ai_will_do = {
		base = -20
		#Personality
		modifier = {
			has_trait = vengeful
			add = 15
		}
		modifier = {
			has_trait = forgiving
			add = -15
		}
		modifier = {
			has_trait = brave
			add = 15
		}
		modifier = {
			has_trait = craven
			add = -15
		}
		# Relationships
		modifier = {
			add = -25
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -50
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 15
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 25
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 50
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			scope:recipient.house = scope:actor.top_liege.house
			add = -25
		}
		opinion_modifier = {
			who = scope:actor
			opinion_target = scope:recipient
			multiplier = -0.25
		}
		
		# Avoid fellow movement members if possible (assuming they aren't rivals)
		modifier = {
			factor = {
				value = 0.25
				if = {
					limit = {
						is_in_pro_hegemon_or_hegemon_movement = yes
					}
					multiply = 0.5
				}
			}
			is_in_same_movement_as = { TARGET = scope:recipient }
			NOT = { has_relation_rival = scope:recipient }
		}

		ttd_domicile_distance_ai_will_do_modifier = { CHARACTER = scope:actor DOMICILE = scope:recipient.domicile }
	}
}

# Teach Governor - AKA Mentor in Governance/mentor_in_governance
start_teach_governor_interaction = {
	icon = icon_teach_governor
	interface_priority = 20
	category = interaction_category_vassal
	filter_tags = { admin_governor }
	send_name = START_SCHEME 
	scheme = teach_governor
	ai_targets = {
		ai_recipients = peer_vassals
		max = 20
	}
	ai_targets = {
		ai_recipients = vassals
		max = 10
	}

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

	notification_text = TEACH_GOVERNOR_NOTIFICATION
	ai_min_reply_days = 4
	ai_max_reply_days = 9

	cooldown_against_recipient = { years = 15 }

	is_shown = {
		scope:actor = { government_allows = administrative }
		scope:recipient != scope:actor
		scope:recipient = {
			is_alive = yes
			top_liege = scope:actor.top_liege
			in_diplomatic_range = scope:actor
		}

		scope:actor = {
			exists = domicile
			domicile = { has_domicile_parameter = estate_unlock_teach_governor_interaction }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = teach_governor
				target_character = scope:recipient
			}
			custom_tooltip = {
				text = teach_governor_maximum_xp_tt
				scope:recipient = { has_trait_xp = { trait = governor value < 95 } }
			}
			custom_tooltip = {
				text = teach_governor_minimum_xp_tt
				scope:recipient = {
					trigger_if = {
						limit = { has_trait_xp = { trait = governor value >= 100 } }
						scope:actor = { has_trait_xp = { trait = governor value >= 75 } }
					}
					trigger_else_if = {
						limit = { has_trait_xp = { trait = governor value >= 75 } }
						scope:actor = { has_trait_xp = { trait = governor value >= 50 } }
					}
					trigger_else_if = {
						limit = { has_trait_xp = { trait = governor value >= 50 } }
						scope:actor = { has_trait_xp = { trait = governor value >= 25 } }
					}
					trigger_else = { always = yes }
				}
			}
		}
	}

	desc = start_teach_governor_interaction_desc

	cost = {
		influence = { add = scope:actor.minor_influence_gain }
	}

	on_accept = {
		scope:actor = {
			custom_tooltip = teach_governor_actor_reward_tt
			stress_impact = {
				humble = minor_stress_impact_gain
				lazy = medium_stress_impact_gain
			}
			trigger_event = scheme_critical_moments.8045
		}
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_teach_governor_notification
				left_icon = scope:recipient					
				right_icon = scope:recipient.primary_title
				scope:recipient = {
					send_interface_toast = {
						type = event_toast_effect_bad
						title = start_teach_governor_notification
						left_icon = scope:actor					
						right_icon = scope:actor.primary_title
						scope:actor = {
							begin_scheme_basic_effect = {
								SCHEME_TYPE = teach_governor
								TARGET_TYPE = target_character
								TARGET_SCOPE = scope:recipient
							}
						}
					}
				}
			}
			# Scheme progress bonus from education
			education_5_scheme_progress_effect = { SKILL = stewardship }
			# Scheme bonuses from being the emperor/dominant family/powerful family
			ep3_actor_scheme_modifier_effect = yes
		}
		scope:recipient = {
			if = {
				limit = { is_ai = yes }
				add_opinion = {
					target = scope:actor
					modifier = mentoring_governor_opinion
				}
			}
			custom_tooltip = teach_governor_recipient_reward_tt
		}
	}

	on_decline = {
		scope:actor = {
			if = {
				limit = { is_ai = yes }
				add_opinion = {
					target = scope:recipient
					modifier = insulted_opinion
					opinion = -10
				}
			}
			else = { trigger_event = scheme_critical_moments.8046 }
		}
	}

	ai_potential = {
		NOR = {
			has_trait = lazy
			scheme_generic_ai_blocker_trigger = yes
		}
		is_governor = yes
	}

	ai_accept = {
		base = 0
		opinion_modifier = {
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.25
		}
		# Experience
		modifier = {
			desc = RELATIVE_GOVERNOR_EFFICIENCY
			add = {
				value = ep3_actor_recipient_governor_trait_level_diff_value
				subtract = 1
				multiply = 15
			}
		}
		modifier = { # If you are from a powerful family, and they are not, they are more likely to accept
			scope:actor.house ?= { is_powerful_family = yes }
			house ?= {
				is_powerful_family = no
				is_dominant_family = no
			}
			add = 15
			desc = your_house_is_powerful_reason
		}
		modifier = { # If you are from a dominant family, and they are not, they are more likely to accept
			scope:actor.house ?= { is_dominant_family = yes }
			house ?= { is_dominant_family = no }
			add = 25
			desc = your_house_is_dominant_reason
		}
		modifier = { # If they are from a powerful family, and you are not, they are more likely to refuse
			house ?= { is_powerful_family = yes }
			scope:actor.house ?= {
				is_powerful_family = no
				is_dominant_family = no
			}
			add = -15
			desc = their_house_is_powerful_reason
		}
		modifier = { # If they are from a dominant family, and you are not, they are more likely to refuse
			house ?= { is_dominant_family = yes }
			scope:actor.house ?= { is_dominant_family = no }
			add = -25
			desc = their_house_is_dominant_reason
		}
		modifier = { # Difference in influence level
			influence_level != scope:actor.influence_level
			add = {
				add = {
					add = 10
					multiply = scope:recipient.influence_level
				}
				subtract = {
					add = 10
					multiply = scope:actor.influence_level
				}
			}
			desc = difference_in_influence_level_reason
		}
		modifier = {
			exists = scope:actor.house
			exists = scope:recipient.house
			house.house_head.top_liege ?= scope:actor.house.house_head.top_liege
			add = {
				value = scope:actor.house.house_power_score
				subtract = scope:recipient.house.house_power_score
				divide = 4
				floor = yes
			}
			desc = RELATIVE_FAMILY_RATING
		}
		# Relations
		modifier = { # Friend
			desc = offer_vassalization_interaction_aibehavior_friend_tt
			has_relation_friend = scope:actor
			NOT = { has_relation_best_friend = scope:actor }
			add = 15
		}
		modifier = { # Best Friend
			desc = offer_vassalization_interaction_aibehavior_best_friend_tt
			has_relation_best_friend = scope:actor
			add = 30
		}
		modifier = { # Rival 
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			has_relation_rival = scope:actor
			NOT = { has_relation_nemesis = scope:actor }
			add = -25
		}
		modifier = { # Nemesis
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			has_relation_nemesis = scope:actor
			add = -50
		}
		modifier = {
			is_close_family_of = scope:actor
			add = 50
			desc = CLOSE_FAMILY_REASON
		}
		modifier = {
			is_extended_family_of = scope:actor
			add = 25
			desc = EXTENDED_FAMILY_REASON
		}
		modifier = {
			NOR = {
				is_close_family_of = scope:actor
				is_extended_family_of = scope:actor
			}
			house ?= scope:actor.house
			add = 5
			desc = YOU_ARE_MY_HOUSE_MEMBER
		}
		#Age
		modifier = {
			desc = AGE_DIFFERENCE
			add = {
				value = scope:actor.age
				add = {
					value = scope:recipient.age
					multiply = -1
				}
			}
		}
		# Traits
		modifier = {
			has_trait = ambitious
			add = 10
			desc = INTERACTION_AMBITIOUS
		}
		modifier = {
			has_trait = diligent
			add = 10
			desc = INTERACTION_DILIGENT
		}
		modifier = {
			has_trait = humble
			add = 10
			desc = INTERACTION_HUMBLE
		}
		modifier = {
			has_trait = content
			add = -10
			desc = INTERACTION_CONTENT
		}
		modifier = {
			has_trait = lazy
			add = -10
			desc = INTERACTION_LAZY
		}
		modifier = {
			has_trait = arrogant
			add = -10
			desc = INTERACTION_ARROGANT
		}
		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:actor }
			add = -50
		}
		modifier = {
			add = 10
			scope:recipient = {
				has_relation_elder = scope:actor
			}
			desc = AI_YOUR_DISCIPLE
		}
	}

	ai_will_do = {
		base = -25
		#Personality
		modifier = {
			has_trait = diligent
			add = 15
		}
		modifier = {
			has_trait = generous
			add = 15
		}
		modifier = {
			has_trait = lazy
			add = -15
		}
		modifier = {
			has_trait = greedy
			add = -15
		}
		# Relationships
		modifier = {
			add = 25
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = 50
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -15
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -25
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		modifier = {
			add = -50
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		# House
		modifier = {
			add = 5
			scope:recipient.house ?= scope:actor.house
		}
		# Family
		modifier = {
			add = 10
			scope:actor = { is_parent_of = scope:recipient }
		}
		modifier = {
			add = 5
			scope:actor = { is_close_family_of = scope:recipient }
		}
		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:recipient }

			add = -50
		}
		
		modifier = {
			add = 10
			scope:actor = {
				has_relation_disciple = scope:recipient
			}
		}
		# Prefer to help your fellow movement members
		modifier = {
			factor = {
				value = 1.2
				if = {
					limit = {
						is_in_pro_hegemon_or_hegemon_movement = yes
					}
					multiply = 1.5
				}
			}
			is_in_same_movement_as = { TARGET = scope:recipient }
		}

		ttd_medium_distance_ai_will_do_modifier = { CHARACTER_1 = scope:actor CHARACTER_2 = scope:recipient }
	}
}

# Ingratiate Family
start_ingratiate_family_interaction = {
	icon = icon_ingratiate_family
	interface_priority = 50
	category = interaction_category_friendly
	filter_tags = { admin_house_head }
	send_name = START_SCHEME
	scheme = ingratiate_family
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = peer_vassals
		max = 20
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 36
		kingdom = 12
		empire = 0
		hegemony = 0
	}
	
	is_shown = {
		scope:actor = {
			can_start_scheme = {
				type = ingratiate_family
				target_character = scope:recipient
			}
		}
		scope:actor = {
			is_adult = yes
			is_imprisoned = no
			is_incapable = no
			any_held_title = { is_noble_family_title = yes }
			house.house_head ?= this
		}
		scope:recipient = {
			is_adult = yes
			is_imprisoned = no
			is_incapable = no
			any_held_title = { is_noble_family_title = yes }
			house.house_head ?= this
			house != scope:actor.house
			top_liege = scope:actor.top_liege
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			can_start_scheme = {
				type = ingratiate_family
				target_character = scope:recipient
			}
		}
	}
 	
 	desc = start_ingratiate_family_interaction_desc

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = start_ingratiate_family_notification
				left_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = ingratiate_family
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}
				scope:recipient = {
					if = {
						limit = { is_ai = yes }
						add_opinion = {
							modifier = ingratiating_family_opinion
							target = scope:actor
						}
					}
				}
				show_as_tooltip = {
					stress_impact = {
						arrogant = minor_stress_impact_gain
						shy = minor_stress_impact_gain
					}
				}
			}
			
			if = { # I am the emperor
				limit = { scope:actor.highest_held_title_tier >= tier_empire }
				custom_tooltip = {
					text = admin_emperor_scheme_modifier_tt
					random_scheme = {
						type = ingratiate_family
						limit = {
							scheme_target_character	= scope:recipient
						}
						add_scheme_modifier = { type = admin_emperor_scheme_modifier }
					}
				}
			}
			else_if = { # I am a dominant family
				limit = {
					scope:actor.house ?= { is_dominant_family = yes }
				}
				custom_tooltip = {
					text = admin_dominant_family_scheme_modifier_tt
					random_scheme = {
						type = ingratiate_family
						limit = {
							scheme_target_character	= scope:recipient
						}
						add_scheme_modifier = { type = admin_dominant_family_scheme_modifier }
					}
				}
				if = {
					limit = { scope:recipient.highest_held_title_tier >= tier_empire }
					custom_tooltip = {
						text = admin_target_emperor_scheme_modifier_tt
						random_scheme = {
							type = ingratiate_family
							limit = {
								scheme_target_character	= scope:recipient
							}
							add_scheme_modifier = { type = admin_target_emperor_scheme_modifier }
						}
					}
				}
			}
			else_if = { # I am a powerful family
				limit = {
					scope:actor.house ?= { is_powerful_family = yes }
				}
				custom_tooltip = {
					text = admin_powerful_family_scheme_modifier_tt
					random_scheme = {
						type = ingratiate_family
						limit = {
							scheme_target_character	= scope:recipient
						}
						add_scheme_modifier = { type = admin_powerful_family_scheme_modifier }
					}
				}
				if = {
					limit = { scope:recipient.highest_held_title_tier >= tier_empire }
					custom_tooltip = {
						text = admin_target_emperor_scheme_modifier_tt
						random_scheme = {
							type = ingratiate_family
							limit = {
								scheme_target_character	= scope:recipient
							}
							add_scheme_modifier = { type = admin_target_emperor_scheme_modifier }
						}
					}
				}
				else_if = {
					limit = { scope:recipient.house ?= { is_dominant_family = yes } }
					custom_tooltip = {
						text = admin_target_dominant_family_scheme_modifier_tt
						random_scheme = {
							type = ingratiate_family
							limit = {
								scheme_target_character	= scope:recipient
							}
							add_scheme_modifier = { type = admin_target_dominant_family_scheme_modifier }
						}
					}
				}
			}
			else = { # I am NOT a powerful or dominant family or the emperor
				if = {
					limit = { scope:recipient.highest_held_title_tier >= tier_empire }
					custom_tooltip = {
						text = admin_target_emperor_scheme_modifier_tt
						random_scheme = {
							type = ingratiate_family
							limit = {
								scheme_target_character	= scope:recipient
							}
							add_scheme_modifier = { type = admin_target_emperor_scheme_modifier }
						}
					}
				}
				else_if = {
					limit = { scope:recipient.house ?= { is_dominant_family = yes } }
					custom_tooltip = {
						text = admin_target_dominant_family_scheme_modifier_tt
						random_scheme = {
							type = ingratiate_family
							limit = {
								scheme_target_character	= scope:recipient
							}
							add_scheme_modifier = { type = admin_target_dominant_family_scheme_modifier }
						}
					}
				}
				else_if = {
					limit = { scope:recipient.house ?= { is_powerful_family = yes } }
					custom_tooltip = {
						text = admin_target_powerful_family_scheme_modifier_tt
						random_scheme = {
							type = ingratiate_family
							limit = {
								scheme_target_character	= scope:recipient
							}
							add_scheme_modifier = { type = admin_target_powerful_family_scheme_modifier }
						}	
					}
				}
			}

			custom_tooltip = ingratiate_family_success_actor_tt
			stress_impact = {
				arrogant = minor_stress_impact_gain
				shy = minor_stress_impact_gain
			}
		}
		scope:recipient = {
			custom_tooltip = ingratiate_family_success_recipient_tt
		}
	}

	ai_potential = {
		NOT = {
			any_scheme = {
				is_scheme_category = hostile
			}
		}
	}
	
	auto_accept = yes

	ai_will_do = {
		base = 5

		#Competing candidate
		modifier = {
			scope:recipient = { is_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = -50
		}

		modifier = {
			scope:recipient = { is_winning_competing_for_same_title_as = { CHARACTER = scope:actor } }
			add = -75
		}

		#Personality
		modifier = {
			has_trait = ambitious
			add = 15
		}

		modifier = {
			has_trait = deceitful
			add = 15
		}

		modifier = {
			has_trait = honest
			add = -15
		}

		# Culture
		modifier = {
			culture != scope:actor.culture
			"culture.cultural_acceptance(scope:recipient.culture)" < 50
			add = {
				value = 50
				subtract = "culture.cultural_acceptance(scope:recipient.culture)"
				multiply = -0.25
				round = yes
			}
			desc = CULTURAL_ACCEPTANCE
		}

		# Faith
		modifier = {
			faith = {
				faith_hostility_level = {
					target = scope:recipient.faith
					value >= faith_astray_level
				}
			}
			add = {
				value = "faith.faith_hostility_level(scope:recipient.faith)"
				multiply = -10
			}
			desc = FAITH_HOSTILITY_LEVEL
		}

		# House & Family
		modifier = {
			is_close_family_of = scope:recipient
			add = -20
		}

		#Feuds
		modifier = {
			house_has_feud_relation_with_trigger = { TARGET = scope:recipient }

			add = -50
		}

		# Relationships
		modifier = {
			add = -25
			has_any_mild_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = -50
			has_any_moderate_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			factor = 0
			has_any_worst_bad_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 25
			has_any_mild_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 50
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}

		modifier = {
			add = 100
			has_any_best_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
		}
		
		# Prefer to get closer to your fellow movement members
		modifier = {
			factor = {
				value = 1.3
				if = {
					limit = {
						is_in_pro_hegemon_or_hegemon_movement = yes
					}
					multiply = 1.5
				}
			}
			is_in_same_movement_as = { TARGET = scope:recipient }
		}

		ttd_domicile_distance_ai_will_do_modifier = { CHARACTER = scope:actor DOMICILE = scope:recipient.domicile }
	}
}
