﻿demand_imperial_subjugation_interaction = {
	category = interaction_category_vassal
	icon = icon_scheme_claim_throne

	common_interaction = yes
	interface_priority = 10
	ai_maybe = yes
	ai_min_reply_days = 5
	ai_max_reply_days = 10
	can_send_despite_rejection = yes
	popup_on_receive = yes
	pause_on_receive = yes
	
	desc = demand_imperial_subjugation_interaction_desc
	
	greeting = positive
	notification_text = DEMAND_IMPERIAL_SUBJUGATION_NOTIFICATION
	pre_answer_maybe_key = ANSWER_MIGHT_SUCCEED
	pre_answer_no_key = ANSWER_CANT_SUCCEED
	pre_answer_yes_key = ANSWER_WILL_SUCCEED
	pre_answer_maybe_breakdown_key = ANSWER_SUM_CHANCE
	
	ai_potential = {
		is_adult = yes
		top_liege = this
		highest_held_title_tier > tier_duchy
	}
	
	is_shown = {
		scope:actor = {
			is_hre_candidate_ruler = yes
			# we are more than half-way to reaching HRE realm size
			sub_realm_size > 70
		}
		scope:recipient = {
			top_liege = this
			is_landed = yes
			# their primary title lies within Carolingian borders
			primary_title = {
				is_titular = no
				tier = tier_kingdom
				title_capital_county.title_province = {
					OR = {
						geographical_region = world_europe_west_germania
						geographical_region = custom_northern_italy
						geographical_region = custom_burgundy
					}
				}
			}
			# their realm is smaller
			sub_realm_size < scope:actor.sub_realm_size
			# they are catholic and feudal
			faith = faith:catholic
			government_has_flag = government_is_feudal
			NOR = {
				government_has_flag = can_not_be_vassal_or_liege
				this = scope:actor.faith.religious_head
				# they don't hold more than one kingdom title
				any_held_title = {
					title_tier = kingdom
					count > 1
				}
				has_opinion_modifier = {
					modifier = demanded_my_title_hre_opinion
					target = scope:actor
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_at_war = no
			is_adult = yes
			is_available = yes
			NOT = { has_truce = scope:recipient }
		}
		scope:recipient = {
			OR = {
				is_imprisoned = no
				is_imprisoned_by = scope:actor
			}
			NOR = {
				has_strong_hook = scope:actor
				is_at_war = yes
			}
			custom_description = {
				text = was_recently_granted_independence
				NOT = {
					has_opinion_modifier = {
						modifier = granted_independence_opinion
						target = scope:actor
					}
				}
			}
		}
	}
	
	can_send = {
		scope:actor = {
			custom_description = {
				text = "character_interactions_hostile_actions_disabled_delay"
				NOT = { has_character_flag = flag_hostile_actions_disabled_delay }
			}
		}
	}

	is_highlighted = {
		always = yes
	}

	on_send = {
		scope:actor = {
			add_character_flag = {
				flag = flag_hostile_actions_disabled_delay
				days = 10
			}
		}
	}	

	# Low starting obligations
	send_option = {
		flag = low_obligations
		localization = low_obligations
	}

	# Medium starting obligations
	send_option = {
		flag = normal_obligations								# If selected then scope:flag_name will be set to yes
		localization = normal_obligations				# Loc_key for option label
		starts_enabled = { always = yes	}				# Trigger for whether this should be on when the window opens. If not defined, defaults to off

	}

	# High starting obligations
	send_option = {
		flag = high_obligations								# If selected then scope:flag_name will be set to yes
		localization = high_obligations					# Loc_key for option label
	}

	send_options_exclusive = yes

	auto_accept = no
	
	on_decline = {
		scope:actor = {
			if = {
				limit = {
					NOT = { has_claim_on = scope:recipient.primary_title }
				}
				add_unpressed_claim = scope:recipient.primary_title
			}
			if = {
				limit = { is_allied_to = scope:recipient }
				break_alliance = scope:recipient
			}
			progress_towards_rival_effect = {
				CHARACTER = scope:recipient
				REASON = rival_demanded_title
				OPINION = -50
			}
			reverse_add_opinion = {
				target = scope:recipient
				modifier = demanded_my_title_hre_opinion
			}
		}
	}
	
	on_accept = {
		custom_tooltip = imperial_subjugation_accept_tt
		takes_same_tier_titles_then_vassalizes = { SUBJUGATOR = scope:actor TARGET = scope:recipient }
	}
	
	ai_accept = {
		base = 50
		
		# PERKS
		modifier = { # Perk boost
			desc = offer_vassalization_true_ruler_perk_tt
			trigger = {
				scope:actor = { has_perk = true_ruler_perk }
			}
			add = true_ruler_value
		}
		modifier = { # Education 5 boost
			desc = offer_vassalization_education_diplomacy_5_tt
			trigger = {
				scope:actor = { has_trait_with_flag = offer_vassalisation_25 }
			}
			add = 25
		}

		# EVENTS - temporary bonuses gained by events
		modifier = {
			desc = event_bonus_to_vassal_accept_tt
			trigger = {
				scope:actor = { has_character_modifier = event_bonus_to_vassal_accept }
			}
			add = 20
		}

		modifier = { # Cultural Acceptance
			add = offer_vassalage_acceptance_value
			desc = cultural_acceptance_interaction_reason
			trigger = {
				scope:actor = {
					NOT = { has_same_culture_as = scope:recipient }
					culture = {
						cultural_acceptance = { target = scope:recipient.culture value <= 90 }
					}
				}
			}
		}

		# MAIN
		modifier = { #We just fought against each other.
			desc = offer_vassalization_interaction_aibehavior_recent_war_tt
			trigger = {
				scope:recipient = {
					any_truce_holder = {
						this = scope:actor
					}
				}
			}
			add = -50
		}
		modifier = { #I fought an independence war against you.
			desc = offer_vassalization_interaction_aibehavior_independence_war_tt
			trigger = {
				scope:recipient = {
					exists = var:independence_war_former_liege
					var:independence_war_former_liege = scope:actor
				}
			}
			add = -200
		}
		modifier = { # Isolationist tradition
			desc = isolationist_reason
			trigger = {
				NOT = {
					scope:actor.culture = scope:recipient.culture
				}
				scope:recipient.culture = {
					has_cultural_tradition = tradition_isolationist
				}
			}
			add = -20
		}
		modifier = { #Bankrupt
			desc = bankrupt_reason
			trigger = {
				scope:actor.gold <= -1
			}
			add = -100
		}
		modifier = { # Allied
			desc = offer_vassalization_interaction_aibehavior_allied_tt
			trigger = {
				scope:recipient = {
					is_allied_to = scope:actor
				}
			}
			add = 25
		}
		modifier = { # Encircled
			desc = offer_vassalization_interaction_aibehavior_encircled_tt
			trigger = {
				scope:recipient = {
					NOT = {
						any_neighboring_top_liege_realm_owner = {
							NOT = {
								this = scope:actor
							}
						}
					}
					NOT = {
						any_realm_county = {
							is_coastal_county = yes
						}
					}
				}
			}
			add = 25
		}
		modifier = { #Distant Realm — Overseas Connection
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					character_is_realm_neighbor = scope:recipient
					NOT = { #Ibiza should want to be a vassal of Mallorca, etc.
						character_is_land_realm_neighbor = scope:recipient
						is_rightful_liege_of = scope:recipient
					}
				}
			}
			add = -100
		}
		modifier = { #Distant Realm — No Connection
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						character_is_realm_neighbor = scope:recipient
					}
				}
				scope:recipient.capital_province = { squared_distance = { target = scope:actor.capital_province value < 200000 } }
			}
			add = -250
		}
		modifier = { #Remote Realm.
			desc = offer_vassalization_interaction_aibehavior_remoterealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						character_is_realm_neighbor = scope:recipient
					}
				}
				scope:recipient.capital_province = { squared_distance = { target = scope:actor.capital_province value >= 200000 } }
			}
			add = -500
		}
		modifier = { #Military Power
			desc = offer_vassalization_interaction_aibehavior_power_tt
	  	  	add = {
				value = 1
				subtract = {
					value = scope:recipient.max_military_strength # Intended for recipient to use max, to avoid having vassalizations become too easy for weakened realms
					divide = { value = scope:actor.current_military_strength min = 1 }
				}
				multiply = 20
				ceiling = yes
	  		}
		}
		modifier = { #Military Power
			desc = offer_vassalization_interaction_aibehavior_vassal_opinion_tt
			trigger = {
				scope:actor = {
				number_of_powerful_vassals >= 1
				}
			}

	  	  	add = {
				value = 0
				scope:actor = {
					every_powerful_vassal = {
						if = {
							limit = {
								save_temporary_opinion_value_as = {
									name = vassal_opinion
									target = scope:actor
								}
							}
							add = scope:vassal_opinion
						}
					}

					if = {
						limit = {
							number_of_powerful_vassals > 0
						}
						divide = number_of_powerful_vassals
					}
					else = {
						divide = 5
					}
				}

				divide = 5
	  		}
		}
		modifier = { #Realm Size
			desc = offer_vassalization_interaction_aibehavior_realmsize_tt
			trigger = {
				scope:actor.sub_realm_size < scope:recipient.sub_realm_size_plus_10
			}
			add = -100
		}
		modifier = { #Realm Size
			desc = offer_vassalization_interaction_aibehavior_realmsize_tt
			trigger = {
				scope:actor.sub_realm_size > scope:recipient.sub_realm_size_plus_20
			}
			add = {
				value = scope:actor.sub_realm_size
				subtract = scope:recipient.sub_realm_size_plus_20
				max = 20
			}
		}

		# MINOR
		modifier = { #Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_friend = scope:actor
					NOT = { has_relation_best_friend = scope:actor }
				}
			}
			add = 20
		}
		modifier = { #Best Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_best_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_best_friend = scope:actor
				}
			}
			add = 50
		}
		modifier = { #Lover modifier.
			desc = interaction_lover
			trigger = {
				scope:recipient = {
					has_relation_lover = scope:actor
					NOT = { has_relation_soulmate = scope:actor }
				}
			}
			add = 20
		}
		modifier = { #Soulmate modifier.
			desc = interaction_soulmate
			trigger = {
				scope:recipient = {
					has_relation_soulmate = scope:actor
				}
			}
			add = 50
		}
		modifier = { #Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -100
		}
		modifier = { #Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -1000
		}
		modifier = { #Same Dynasty modifier.
			desc = offer_vassalization_interaction_aibehavior_dynasty_tt
			trigger = {
				scope:recipient = {
					dynasty = scope:actor.dynasty
				}
			}
			add = 25
		}

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

		modifier = { # Is a child
			desc = offer_vassalization_interaction_aibehavior_recipient_child_tt
			trigger = {
				scope:recipient = {
					is_adult = no
				}
			}
			add = 5
		}
		modifier = { #Illegitimacy modifier.
			desc = offer_vassalization_interaction_aibehavior_illegitimate_tt
			trigger = {
				OR = {
					AND = {
						scope:actor = {
							has_trait = bastard
						}
						scope:recipient = {
							faith = { NOT = { has_doctrine = doctrine_bastardry_none } }
						}
					}
					has_trait = denounced
					has_trait = disinherited
				}
			}
			add = -10
		}

		modifier = { #Claimant modifier.
			desc = offer_vassalization_interaction_aibehavior_claimant_tt
			trigger = {
				scope:actor.primary_title = {
					scope:recipient = {
						has_claim_on = prev
					}
				}
			}
			add = -20
		}

		modifier = { # Ambitious
			desc = TAKE_THE_VOWS_AMBITIOUS
			trigger = {
				scope:recipient = {
					has_trait = ambitious
				}
			}
			add = -20
		}

		modifier = { # Paranoid
			desc = INTERACTION_PARANOID
			trigger = {
				scope:recipient = {
					has_trait = paranoid
				}
			}
			add = -20
		}

		modifier = { # Arrogant
			desc = INTERACTION_ARROGANT
			trigger = {
				scope:recipient = {
					has_trait = arrogant
				}
			}
			add = -20
		}

		modifier = { # Fickle
			desc = INTERACTION_FICKLE
			trigger = {
				scope:recipient = {
					has_trait = fickle
				}
			}
			add = -10
		}

		modifier = { # Stubborn
			desc = INTERACTION_STUBBORN
			trigger = {
				scope:recipient = {
					has_trait = stubborn
				}
			}
			add = -10
		}

		modifier = { # Trusting
			desc = TAKE_THE_VOWS_TRUSTING
			trigger = {
				scope:recipient = {
					has_trait = trusting
				}
			}
			add = 5
		}

		modifier = { # Content
			desc = INTERACTION_CONTENT
			trigger = {
				scope:recipient = {
					has_trait = content
				}
			}
			add = 5
		}

		modifier = { # FP3 modifier.
			desc = GENERIC_YOUR_PIETY_LEVEL_MODIFIER
			add = {
				value = {
					value = scope:actor.piety_level
					subtract = low_piety_level
				}
				multiply = 5
			}
		}

		# OPINION INFLUENCE
		modifier = {
			add = intimidated_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		modifier = {
			add = cowed_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}

		# DIPLOMATIC COURT GRANDEUR BONUS
		modifier = {
			trigger = {
				scope:actor = {
					has_royal_court = yes
					has_court_type = court_diplomatic
					court_grandeur_current_level >= 1
				}
			}
			add = {
				value = scope:actor.court_grandeur_current
				if = {
					limit = { # Reduce the bonus if you are below your expected level
						scope:actor = {
							court_grandeur_current_level < court_grandeur_minimum_expected_level
						}
					}
					multiply = 0.15
				}
				else = {
					multiply = 0.3
				}
			}
			desc = DIPLOMATIC_COURT_ACCEPTANCE_INCREASE_REASON
		}

		# CONTRACT OPTIONS
		modifier = {
			add = 30
			scope:low_obligations = yes
			desc = CONTRACT_LOW_TAXES_REASON
		}
		modifier = {
			add = -40
			scope:high_obligations = yes
			desc = CONTRACT_HIGH_TAXES_REASON
		}
	}

	# AI
	ai_targets = {
		ai_recipients = neighboring_rulers
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 0
		hegemony = 0
	}
	
	ai_will_do = {
		base = 100

		# AI prefers to receive higher obligations from their vassals when possible.
		modifier = {
			add = 2
			scope:low_obligations = yes
		}

		modifier = {
			add = 3
			scope:normal_obligations = yes
		}

		modifier = {
			add = 4
			scope:high_obligations = yes
		}
		
		modifier = {
			factor = 0
			scope:actor.sub_realm_size < scope:recipient.sub_realm_size_plus_10
		}
		
		modifier = {
			factor = 0
			scope:actor.sub_realm_size >= 140
			NOT = {
				scope:recipient = { primary_title = title:k_italy }
			}
		}
		
		modifier = {
			factor = 0
			scope:recipient = { save_temporary_scope_as = target }
			scope:actor.strength_with_relevant_allies_vs_target_value <= scope:recipient.one_and_a_half_times_current_strength_with_relevant_allies_vs_root
		}
		
		modifier = {
			factor = 0
			scope:actor = {
				has_claim_on = scope:recipient.primary_title
				NOR = {
					is_allied_to = scope:recipient
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
				}
			}
		}


		modifier = { # If the recipient is a player, do not bother sending
			factor = 0
			scope:recipient = {
				is_ai = no
			}
		}
	}
}

demand_rurikid_subjugation_interaction = {
	category = interaction_category_vassal
	icon = change_allegiance

	common_interaction = yes
	interface_priority = 10
	ai_maybe = yes
	ai_min_reply_days = 5
	ai_max_reply_days = 10
	can_send_despite_rejection = yes
	popup_on_receive = yes
	pause_on_receive = yes
	
	desc = demand_rurikid_subjugation_interaction_desc
	
	greeting = positive
	notification_text = DEMAND_RURIKID_SUBJUGATION_NOTIFICATION
	pre_answer_maybe_key = ANSWER_MIGHT_SUCCEED
	pre_answer_no_key = ANSWER_CANT_SUCCEED
	pre_answer_yes_key = ANSWER_WILL_SUCCEED
	pre_answer_maybe_breakdown_key = ANSWER_SUM_CHANCE
	
	ai_potential = {
		is_adult = yes
		top_liege = this
		OR = {
			highest_held_title_tier = tier_duchy
			highest_held_title_tier = tier_kingdom
		}
	}
	
	is_shown = {
		has_game_rule = yes_full_stronger_rurikid
		scope:actor = {
			is_rurikid_candidate_ruler = yes
		}
		scope:recipient = {
			is_rurikid_subjugation_target = { SUBJUGATOR = scope:actor }
		}
	}
	
	is_valid_showing_failures_only = {
		scope:actor = {
			is_at_war = no
			is_adult = yes
			is_available = yes
			NOT = { has_truce = scope:recipient }
		}
		scope:recipient = {
			OR = {
				is_imprisoned = no
				is_imprisoned_by = scope:actor
			}
			NOR = {
				has_strong_hook = scope:actor
				is_at_war = yes
			}
			custom_description = {
				text = was_recently_granted_independence
				NOT = {
					has_opinion_modifier = {
						modifier = granted_independence_opinion
						target = scope:actor
					}
				}
			}
		}
	}
	
	can_send = {
		scope:actor = {
			custom_description = {
				text = "character_interactions_hostile_actions_disabled_delay"
				NOT = { has_character_flag = flag_hostile_actions_disabled_delay }
			}
		}
	}
	
	is_highlighted = {
		always = yes
	}
	
	on_send = {
		scope:actor = {
			add_character_flag = {
				flag = flag_hostile_actions_disabled_delay
				days = 10
			}
		}
	}
	
	auto_accept = no
	
	on_decline = {
		scope:actor = {
			if = {
				limit = {
					NOT = { has_claim_on = scope:recipient.primary_title }
				}
				add_unpressed_claim = scope:recipient.primary_title
			}
			if = {
				limit = { is_allied_to = scope:recipient }
				break_alliance = scope:recipient
			}
			progress_towards_rival_effect = {
				CHARACTER = scope:recipient
				REASON = rival_demanded_title
				OPINION = -50
			}
			reverse_add_opinion = {
				target = scope:recipient
				modifier = demanded_my_subjugation_opinion
			}
		}
	}
	
	on_accept = {
		custom_tooltip = imperial_subjugation_accept_tt
		if = {
			limit = { scope:recipient.highest_held_title_tier = scope:actor.highest_held_title_tier }
			takes_same_tier_titles_then_vassalizes = { SUBJUGATOR = scope:actor TARGET = scope:recipient }
		}
		else = {
			subjugates_then_vassalizes_effect = { SUBJUGATOR = scope:actor TARGET = scope:recipient }
		}
	}
	
	ai_accept = {
		base = 50
		# Vs Conqueror
		modifier = {
			desc = ACTOR_IS_CONQUEROR
			trigger = {
				scope:actor = { has_trait = conqueror }
			}
			add = 25
		}
		# PERKS
		modifier = { # Perk boost
			desc = offer_vassalization_true_ruler_perk_tt
			trigger = {
				scope:actor = { has_perk = true_ruler_perk }
			}
			add = true_ruler_value
		}
		modifier = { # Education 5 boost
			desc = offer_vassalization_education_diplomacy_5_tt
			trigger = {
				scope:actor = { has_trait_with_flag = offer_vassalisation_25 }
			}
			add = 25
		}

		# EVENTS - temporary bonuses gained by events
		modifier = {
			desc = event_bonus_to_vassal_accept_tt
			trigger = {
				scope:actor = { has_character_modifier = event_bonus_to_vassal_accept }
			}
			add = 20
		}
		modifier = {
			desc = SUBJUGATION_SAME_CULTURE_TT
			trigger = {
				scope:actor = { has_same_culture_as = scope:recipient }
			}
			add = 10
		}
		modifier = { # Cultural Acceptance
			add = offer_vassalage_acceptance_value
			desc = cultural_acceptance_interaction_reason
			trigger = {
				scope:actor = {
					NOT = { has_same_culture_as = scope:recipient }
					culture = {
						cultural_acceptance = { target = scope:recipient.culture value <= 90 }
					}
				}
			}
		}

		# MAIN
		modifier = { #We just fought against each other.
			desc = offer_vassalization_interaction_aibehavior_recent_war_tt
			trigger = {
				scope:recipient = {
					any_truce_holder = {
						this = scope:actor
					}
				}
			}
			add = -50
		}
		modifier = { #I fought an independence war against you.
			desc = offer_vassalization_interaction_aibehavior_independence_war_tt
			trigger = {
				scope:recipient = {
					exists = var:independence_war_former_liege
					var:independence_war_former_liege = scope:actor
				}
			}
			add = -200
		}
		modifier = { # Isolationist tradition
			desc = isolationist_reason
			trigger = {
				NOT = {
					scope:actor.culture = scope:recipient.culture
				}
				scope:recipient.culture = {
					has_cultural_tradition = tradition_isolationist
				}
			}
			add = -20
		}
		modifier = { #Bankrupt
			desc = bankrupt_reason
			trigger = {
				scope:actor.gold <= -1
			}
			add = -100
		}
		modifier = { # Allied
			desc = offer_vassalization_interaction_aibehavior_allied_tt
			trigger = {
				scope:recipient = {
					is_allied_to = scope:actor
				}
			}
			add = 25
		}
		modifier = { # Encircled
			desc = offer_vassalization_interaction_aibehavior_encircled_tt
			trigger = {
				scope:recipient = {
					NOT = {
						any_neighboring_top_liege_realm_owner = {
							NOT = {
								this = scope:actor
							}
						}
					}
					NOT = {
						any_realm_county = {
							is_coastal_county = yes
						}
					}
				}
			}
			add = 25
		}
		modifier = { #Military Power
			desc = offer_vassalization_interaction_aibehavior_power_tt
	  	  	add = {
				value = 1
				subtract = {
					value = scope:recipient.max_military_strength # Intended for recipient to use max, to avoid having vassalizations become too easy for weakened realms
					divide = { value = scope:actor.current_military_strength min = 1 }
				}
				multiply = 25
				ceiling = yes
	  		}
		}
		modifier = { #Military Power
			desc = offer_vassalization_interaction_aibehavior_vassal_opinion_tt
			trigger = {
				scope:actor = {
				number_of_powerful_vassals >= 1
				}
			}

	  	  	add = {
				value = 0
				scope:actor = {
					every_powerful_vassal = {
						if = {
							limit = {
								save_temporary_opinion_value_as = {
									name = vassal_opinion
									target = scope:actor
								}
							}
							add = scope:vassal_opinion
						}
					}

					if = {
						limit = {
							number_of_powerful_vassals > 0
						}
						divide = number_of_powerful_vassals
					}
					else = {
						divide = 5
					}
				}

				divide = 5
	  		}
		}
		modifier = { #Realm Size
			desc = offer_vassalization_interaction_aibehavior_realmsize_tt
			trigger = {
				scope:actor.sub_realm_size < scope:recipient.sub_realm_size_plus_10
			}
			add = -100
		}
		modifier = { #Realm Size
			desc = offer_vassalization_interaction_aibehavior_realmsize_tt
			trigger = {
				scope:actor.sub_realm_size > scope:recipient.sub_realm_size_plus_20
			}
			add = {
				value = scope:actor.sub_realm_size
				subtract = scope:recipient.sub_realm_size_plus_20
				max = 20
			}
		}

		# MINOR
		modifier = { #Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_friend = scope:actor
					NOT = { has_relation_best_friend = scope:actor }
				}
			}
			add = 25
		}
		modifier = { #Best Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_best_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_best_friend = scope:actor
				}
			}
			add = 50
		}
		modifier = { #Lover modifier.
			desc = interaction_lover
			trigger = {
				scope:recipient = {
					has_relation_lover = scope:actor
					NOT = { has_relation_soulmate = scope:actor }
				}
			}
			add = 20
		}
		modifier = { #Soulmate modifier.
			desc = interaction_soulmate
			trigger = {
				scope:recipient = {
					has_relation_soulmate = scope:actor
				}
			}
			add = 50
		}
		modifier = { #Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -100
		}
		modifier = { #Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -1000
		}
		modifier = { #Same Dynasty modifier.
			desc = offer_vassalization_interaction_aibehavior_dynasty_tt
			trigger = {
				scope:recipient = {
					dynasty = scope:actor.dynasty
				}
			}
			add = 25
		}

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

		modifier = { # Is a child
			desc = offer_vassalization_interaction_aibehavior_recipient_child_tt
			trigger = {
				scope:recipient = {
					is_adult = no
				}
			}
			add = 10
		}

		modifier = { #Claimant modifier.
			desc = offer_vassalization_interaction_aibehavior_claimant_tt
			trigger = {
				scope:actor.primary_title = {
					scope:recipient = {
						has_claim_on = prev
					}
				}
			}
			add = -20
		}

		modifier = { # Ambitious
			desc = TAKE_THE_VOWS_AMBITIOUS
			trigger = {
				scope:recipient = {
					has_trait = ambitious
				}
			}
			add = -20
		}

		modifier = { # Paranoid
			desc = INTERACTION_PARANOID
			trigger = {
				scope:recipient = {
					has_trait = paranoid
				}
			}
			add = -20
		}

		modifier = { # Arrogant
			desc = INTERACTION_ARROGANT
			trigger = {
				scope:recipient = {
					has_trait = arrogant
				}
			}
			add = -20
		}

		modifier = { # Fickle
			desc = INTERACTION_FICKLE
			trigger = {
				scope:recipient = {
					has_trait = fickle
				}
			}
			add = -10
		}

		modifier = { # Stubborn
			desc = INTERACTION_STUBBORN
			trigger = {
				scope:recipient = {
					has_trait = stubborn
				}
			}
			add = -10
		}

		modifier = { # Trusting
			desc = TAKE_THE_VOWS_TRUSTING
			trigger = {
				scope:recipient = {
					has_trait = trusting
				}
			}
			add = 5
		}

		modifier = { # Content
			desc = INTERACTION_CONTENT
			trigger = {
				scope:recipient = {
					has_trait = content
				}
			}
			add = 5
		}

		# OPINION INFLUENCE
		modifier = {
			add = intimidated_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		modifier = {
			add = cowed_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}

		# DIPLOMATIC COURT GRANDEUR BONUS
		modifier = {
			trigger = {
				scope:actor = {
					has_royal_court = yes
					has_court_type = court_diplomatic
					court_grandeur_current_level >= 1
				}
			}
			add = {
				value = scope:actor.court_grandeur_current
				if = {
					limit = { # Reduce the bonus if you are below your expected level
						scope:actor = {
							court_grandeur_current_level < court_grandeur_minimum_expected_level
						}
					}
					multiply = 0.15
				}
				else = {
					multiply = 0.3
				}
			}
			desc = DIPLOMATIC_COURT_ACCEPTANCE_INCREASE_REASON
		}
	
		# HAS LAND OUTSIDE RUSSIA
		modifier = {
			desc = SUBJUGATION_LAND_OUTSIDE_RUSSIA_TT
			trigger = {
				scope:recipient = {
					any_realm_county = {
						NOT = { empire = title:e_russia }
					}
				}
			}
			add = -50
		}
	}
	
	# AI
	ai_targets = {
		ai_recipients = neighboring_rulers
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 0
		duchy = 24
		kingdom = 9
		empire = 0
		hegemony = 0
	}
	
	ai_will_do = {
		base = 100
		
		modifier = {
			factor = 0
			scope:actor.sub_realm_size < scope:recipient.sub_realm_size_plus_10
		}
		
		modifier = {
			factor = 0
			scope:recipient = { save_temporary_scope_as = target }
			scope:actor.strength_with_relevant_allies_vs_target_value <= scope:recipient.one_and_a_half_times_current_strength_with_relevant_allies_vs_root
		}
	}
}

