call_ally_interaction = {
	category = interaction_category_diplomacy
	desc = call_ally_interaction_desc
	interface_priority = 60
	interface = call_ally
	special_interaction = call_ally_interaction
	popup_on_receive = yes
	pause_on_receive = yes
	icon = alliance

	greeting = positive
	notification_text = CALL_ALLY_NOTIFICATION

	is_shown = {
		scope:actor = {
			#Tenno
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
			#Tenno end
			is_at_war = yes
			trigger_if = { # Avoid calling Adventurers without armies or landed rulers who have been devastated
				limit = {
					is_ai = yes
				}
				scope:recipient.current_military_strength >= 100
			}
			trigger_if = {
				limit = {
					liege = scope:recipient # The recipient is actor's liege
				}
				subject_contract_has_flag = vassal_contract_liege_forced_war_override
			}
			trigger_if = {
				limit = {
					scope:recipient = { 
						is_tributary_of = scope:actor
						NOT = { is_allied_to = scope:actor }
					}
				}
				piety >= 50
				has_realm_law_flag = can_call_tributaries_for_piety
			}
		}
		scope:recipient = {
			#Tenno
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
			#Tenno end
			OR = {
				is_allied_to = scope:actor
				AND = {
					this ?= scope:actor.diarch
					scope:actor = {
						any_character_war = { diarch_callable_in_internal_war_trigger = yes }
					}
				}
				scope:actor = {
					is_vassal_of = prev
					subject_contract_has_flag = vassal_contract_liege_forced_war_override
				}
				scope:actor = {
					is_tributary_of = prev
					subject_contract_has_flag = tributary_contract_suzerain_guarantee_override
				}
				AND = {
					is_tributary_of = scope:actor
					scope:actor = {
						piety >= 50
						has_realm_law_flag = can_call_tributaries_for_piety
					}
				}
			}
		}
		scope:actor = { #If you can call them as a House Member then do that
			NOT = {
				is_character_interaction_valid = {
					recipient = scope:recipient
					interaction = call_house_member_to_war_interaction
				}
			}
		}
	}

	has_valid_target = {
		exists = scope:target
	}

	has_valid_target_showing_failures_only = {
		scope:target = {
			is_war_leader = scope:actor
		}

		scope:actor = {
			trigger_if = {
				limit = { # if you're invoking your suzerain's defensive guarantee, it has to be for a defensive war
					NOT = { is_allied_to = scope:recipient }
					suzerain = scope:recipient
					subject_contract_has_flag = tributary_contract_suzerain_guarantee_override
				}
				scope:target = {
					primary_defender = scope:actor
				}
			}

			trigger_if = {
				limit = {
					scope:target = {
						OR = {
							using_cb = undirected_great_holy_war
							using_cb = directed_great_holy_war
						}
					}
				}

				trigger_if = {
					limit = {
						this = scope:target.casus_belli.primary_attacker
					}
					#if it's a religious war the recipient has to be of the same faith
					custom_description = {
						text = is_of_wrong_faith_for_holy_war
						subject = scope:actor
						object = scope:recipient
						faith = scope:recipient.faith
					}
				}
				trigger_else = {
					custom_description = {
						text = is_of_attacker_faith_in_holy_war
						subject = scope:actor
						object = scope:recipient
						scope:target = { primary_attacker.faith != scope:recipient.faith }
					}
				}
			}
		}

		joiner_not_already_in_another_war_with_any_target_war_participants_trigger = {
			WARRIOR = scope:actor
			JOINER = scope:recipient
		}
	}


	is_valid_showing_failures_only = {

		scope:recipient = {
			is_ruler = yes
			
			# Only rulers of a high enough rank may call a hegemon into wars
			custom_tooltip = {
				text = too_low_rank_to_call_hegemon
				trigger_if = {
					limit = { highest_held_title_tier = tier_hegemony }
					scope:actor = { highest_held_title_tier >= tier_empire }
				}
			}
		}

		scope:actor = {
			# Only War Leaders can call allies
			custom_description = {
				text = must_be_war_leader
				any_character_war = {
					is_war_leader = scope:actor
				}
			}
			
			# Cannot call the same character multiple times
			custom_description = {
				text = cannot_call_same_character_multiple_times
				subject = scope:recipient
				any_character_war = {
					ALL_FALSE = {
						was_called = scope:recipient
						is_participant = scope:recipient
					}
				}
			}
			
			# Cannot call a character of the "wrong" religion to a Great Holy War
			trigger_if = {
				limit = {
					faith != scope:recipient.faith
				}
				custom_description = {
					text = is_of_wrong_faith_for_holy_war
					subject = scope:actor
					object = scope:recipient
					any_character_war = {
						NOR = {
							using_cb = undirected_great_holy_war
							using_cb = directed_great_holy_war
						}
					}
				}
			}
		}

		can_potentially_call_ally_trigger = {
			WARRIOR = scope:actor
			JOINER = scope:recipient
		}
	}

	can_be_picked = {
		can_join_war_liege_vassal_check_trigger = { WARRIOR = scope:actor JOINER = scope:recipient }

		scope:target = {
			is_war_leader = scope:actor

			# not already in target war
			custom_description = {
				text = join_war_interaction_already_in_target_war
				NOR = {
					any_war_attacker = { this = scope:recipient }
					any_war_defender = { this = scope:recipient }
				}
			}

			# Diarchs can only be called to internal wars.
			custom_tooltip = {
				text = call_ally_interaction.tt.diarchs_called_to_internal_wars
				trigger_if = {
					limit = { scope:recipient ?= scope:actor.diarch }
					primary_defender = scope:actor
					diarch_callable_in_internal_war_trigger = yes
				}
			}
		}
		
		# You cannot call a suzerain against their own tributary
		trigger_if = {
			limit = {
				scope:target.casus_belli.primary_defender = scope:actor
				scope:target.casus_belli.primary_attacker = { is_tributary_of_suzerain_or_above = scope:recipient }
			}
			NOT = {
				scope:target.casus_belli.primary_attacker = { is_tributary_of_suzerain_or_above = scope:recipient }
			}
		}
		trigger_else_if = {
			limit = {
				scope:target.casus_belli.primary_attacker = scope:actor
				scope:target.casus_belli.primary_defender = { is_tributary_of_suzerain_or_above = scope:recipient }
			}
			NOT = {
				scope:target.casus_belli.primary_defender = { is_tributary_of_suzerain_or_above = scope:recipient }
			}
		}
		trigger_else = {}
		
		# You cannot call a tributary against their suzerain
		trigger_if = {
			limit = {
				scope:target.casus_belli.primary_defender = scope:actor
				scope:recipient = { is_tributary_of_suzerain_or_above = scope:target.casus_belli.primary_attacker }
			}
			NOT = {
				scope:recipient = { is_tributary_of_suzerain_or_above = scope:target.casus_belli.primary_attacker }
			}
		}
		trigger_else_if = {
			limit = {
				scope:target.casus_belli.primary_attacker = scope:actor
				scope:recipient = { is_tributary_of_suzerain_or_above = scope:target.casus_belli.primary_defender }
			}
			NOT = {
				scope:recipient = { is_tributary_of_suzerain_or_above = scope:target.casus_belli.primary_defender }
			}
		}
		trigger_else = {}
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = call_ally.0001
		}
		scope:target = {
			if = {
				limit = {
					is_religious_war = yes
					scope:recipient = {
						any_active_accolade = {
							accolade_parameter = acclaimed_knight_piety_from_battle
						}
					}
				}
				scope:recipient = {
					add_piety = miniscule_piety_gain
				}
			}
			if = {
				limit = {
					is_religious_war = yes
					scope:recipient = {
						any_active_accolade = {
							accolade_parameter = acclaimed_knight_piety_from_battle_high
						}
					}
				}
				scope:recipient = {
					add_piety = minor_piety_gain
				}
			}
		}
	}

	on_accept = {
		call_ally_interaction_effect = yes

		save_scope_value_as = {
			name = call_ally_interaction
			value = yes
		}

		scope:actor = {
			hidden_effect = { #To nudge friendship
				if = {
					limit = {
						NOR = {
							has_relation_friend = scope:recipient
							has_relation_potential_friend = scope:recipient
						}
					}
					set_relation_potential_friend = scope:recipient
				}
			}
			trigger_event = call_ally.0100
		}
		scope:target = {
			if = {
				limit = {
					is_religious_war = yes
					scope:recipient = {
						any_active_accolade = {
							accolade_parameter = acclaimed_knight_piety_from_battle
						}
					}
				}
				scope:recipient = {
					add_piety = minor_piety_gain
				}
			}
			if = {
				limit = {
					is_religious_war = yes
					scope:recipient = {
						any_active_accolade = {
							accolade_parameter = acclaimed_knight_piety_from_battle_high
						}
					}
				}
				scope:recipient = {
					add_piety = medium_piety_gain
				}
			}
		}
	}

	on_decline = {
		#The war could theoretically end on the day the decline is sent
		if = {
			limit = {
				exists = scope:target
			}
			scope:target = {
				if = {
					limit = {
						is_attacker = scope:actor
					}
					scope:actor = {
						add_opinion = {
							modifier = rejected_call_to_offensive_war
							target = scope:recipient
						}
					}
					scope:recipient = {
						#Why should Mandalas care about bickering tributaries in an offensive war
						if = {
							limit = { 
								NOT = { government_has_flag = government_is_mandala }
							}
							add_prestige_experience = major_prestige_loss 
						}
					}	
				}
				else = {
					scope:actor = {
						add_opinion = {
							modifier = rejected_call_to_defensive_war
							target = scope:recipient
						}
					}
					scope:recipient = {
						if = {
							limit = { government_has_flag = government_is_mandala }
							add_prestige_experience = major_prestige_loss
							add_piety_level = -1
						}
						else = { add_prestige_experience = massive_prestige_loss }
					}
				}
				if = {
					limit = {
						scope:actor = {
							has_relation_blood_brother = scope:recipient
						}
					}
					scope:recipient = {
						add_piety_experience = massive_piety_loss
						add_character_modifier = {
							modifier = broke_blood_brotherhood_modifier
							desc = broke_blood_brotherhood_modifier_acceptance_tt
							years = 25
						}
						remove_relation_blood_brother = scope:actor
					}
					scope:actor = {
						set_relation_rival = {
							target = scope:recipient
							reason = rival_blood_brother_refused_call_reason
						}
					}
				}
				# Nomad Vassals and Tributaries stop being Obedient if they have the Liege War Support / Suzerain Defensive Guarantee contract right
				if = {
					limit = {
						scope:recipient = scope:actor.obedience_target
						scope:actor = {
							OR = {
								subject_contract_has_flag = vassal_contract_liege_forced_war_override
								subject_contract_has_flag = tributary_contract_suzerain_guarantee_override
							}
						}
					}
					scope:actor = {
						set_variable = {
							name = not_obedient_declined_call
							value = scope:recipient
							years = 5
						}
					}
				}
				if = {
					limit = {
						scope:recipient = scope:actor.suzerain
						is_defender = scope:actor
						scope:actor = {
							subject_contract_has_flag = tributary_contract_suzerain_guarantee_override
						}
					}
					scope:actor = {
						end_tributary = yes
					}
				}
				hidden_effect = {
					if = {
						limit = {
							NOT = { was_called = scope:recipient }
						}
						set_called_to = scope:recipient
					}
				}
			}
			scope:actor = {
				trigger_event = call_ally.0101
			}

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

			scope:recipient = {
				if = {
					limit = {
						exists = house
						is_house_head = yes
						exists = scope:actor.house
					}
					house = {
						change_house_relation_effect = {
							HOUSE = scope:actor.house
							VALUE = house_relation_damage_medium_value
							REASON = ally_call_ignored
							CHAR = scope:recipient
							TARGET_CHAR = scope:actor
							TITLE = scope:dummy_gender
						}
					}
				}
			}
		}
	}

	auto_accept = {
		OR = {
			# Always accept a call from a Spouse
			custom_description = {
				text = "recipient_is_spouse"
				subject = scope:actor
				object = scope:recipient
				scope:recipient = {
					is_spouse_of = scope:actor
					is_ai = yes
				}
			}
			# Always accept a call from the Heir
			custom_description = {
				text = "is_recipients_player_heir"
				subject = scope:actor
				object = scope:recipient

				exists = scope:recipient.player_heir
				scope:recipient = {
					player_heir = scope:actor
					is_close_or_extended_family_of = scope:actor # Only for family
					is_ai = yes
				}
			}
			# Always accept a call from the one you are heir of
			custom_description = {
				text = "is_player_heir"
				subject = scope:recipient
				object = scope:actor

				exists = scope:actor.player_heir
				scope:actor.player_heir = scope:recipient
				scope:actor = { # Shouldn't be able to force your liege to join just because you've not got any family...
					is_close_or_extended_family_of = scope:recipient
				}
				scope:recipient = {
					is_ai = yes
				}
			}
		}
	}

	ai_accept = {
		base = -75 # 20

		modifier = {  # Conquerors do not help anyone but themselves
			add = -1000
			desc = NO_FRIVOLOUS_ACTIVITIES_REASON
			scope:recipient = { has_variable = conqueror }
		}

		modifier = {  # AI's that need to save gold will not help their lesser AI allies, unless it's a player war
			add = -1000
			desc = NO_FRIVOLOUS_ACTIVITIES_REASON
			scope:actor = {
				is_ai = yes
				primary_title.tier < scope:recipient.primary_title.tier
			}
			scope:target.casus_belli = {
				primary_attacker = { is_ai = yes }
				primary_defender = { is_ai = yes }
			}
			scope:recipient = { ai_should_focus_on_building_in_their_capital = yes }
		}

		modifier = {  # Refuse call to conflicts of little benefit
			add = -1000
			desc = WONT_FIGHT_MEANINGLESS_REASON
			trigger_if = {
				limit = { exists = scope:target }
				scope:target = { using_cb = fp2_border_raid }
				scope:recipient = { # Unless they like going on raids
					NOR = {
						has_trait = viking
						has_trait = reaver
					}
				}
			}
			trigger_else = { always = no }
		}

		modifier = {  # Refuse call against Heir
			add = -1000
			exists = scope:recipient.player_heir
			trigger_if = {
				limit = { scope:target.casus_belli.primary_defender = scope:actor }
				scope:target.casus_belli.primary_attacker = scope:recipient.player_heir
			}
			trigger_else = {
				scope:target.casus_belli.primary_defender = scope:recipient.player_heir
			}
			desc = WONT_FIGHT_HEIR_REASON
		}

		modifier = {  # Refuse call against Spouse
			add = -1000
			scope:recipient = {
				trigger_if = {
					limit = { scope:target.casus_belli.primary_defender = scope:actor }
					any_spouse = {
						this = scope:target.casus_belli.primary_attacker
					}
				}
				trigger_else = {
					any_spouse = {
						this = scope:target.casus_belli.primary_defender
					}
				}

			}
			desc = WONT_FIGHT_SPOUSE_REASON
		}
		
		modifier = {  # Refuse call against Suzerain if Obedient
			add = -1000
			trigger_if = {
				limit = {
					exists = scope:recipient.suzerain
					trigger_if = {
						limit = { scope:target.casus_belli.primary_defender = scope:actor }
						scope:recipient.suzerain = scope:target.casus_belli.primary_attacker
					}
					trigger_else = {
						scope:recipient.suzerain = scope:target.casus_belli.primary_defender
					}
					scope:recipient = {
						exists = obedience_target
						is_obedient = yes
					}
				}
			}
			trigger_else = { always = no }
			desc = WONT_FIGHT_OBEDIENT_REASON
		}

		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1.0
			desc = AI_OPINION_REASON
		}

		# Honor factor
		ai_value_modifier = {
			ai_honor = 1
			min = 0
		}

		modifier = {  # Tends to join defensive wars
			add = 50
			scope:target.casus_belli.primary_defender = scope:actor
			desc = DEFENSIVE_WAR_REASON
		}

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

		modifier = { # Shared Court Language (non-spoken)
			add = 10
			desc = foreign_realm_court_language_non_spoken_interaction_reason
			trigger = {
				scope:actor = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					NOT = { knows_court_language_of = this }
				}
				scope:actor.top_liege != scope:recipient.top_liege
				OR = {
					AND = {
						scope:recipient = {
							has_royal_court = yes
						}
						scope:actor = { # You share Court Language
							has_same_court_language = scope:recipient
						}
					}

					scope:recipient = { # The recipient doesn't have a royal court, but their liege does
						top_liege != this
						has_royal_court = no
						liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
					scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege does, while their liege doesn't have a royal court
						top_liege != this
						has_royal_court = no
						exists = liege.liege
						liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
					scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege does, while their liege doesn't have a royal court
						top_liege != this
						has_royal_court = no
						exists = liege.liege
						exists = liege.liege.liege
						liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege.liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
					scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege's liege does, while their liege doesn't have a royal court
						top_liege != this
						has_royal_court = no
						exists = liege.liege
						exists = liege.liege.liege
						exists = liege.liege.liege.liege
						liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege.liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege.liege.liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
				}
			}
		}

		modifier = { # Shared Court Language (spoken)
			add = 30
			desc = foreign_realm_court_language_spoken_interaction_reason
			trigger = {
				scope:actor = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					knows_court_language_of = this
				}
				scope:actor.top_liege != scope:recipient.top_liege
				OR = {
					AND = {
						scope:recipient = {
							has_royal_court = yes
						}
						scope:actor = { # You share Court Language
							has_same_court_language = scope:recipient
						}
					}

					scope:recipient = { # The recipient doesn't have a royal court, but their liege does
						top_liege != this
						has_royal_court = no
						liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
					scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege does, while their liege doesn't have a royal court
						top_liege != this
						has_royal_court = no
						exists = liege.liege
						liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
					scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege does, while their liege doesn't have a royal court
						top_liege != this
						has_royal_court = no
						exists = liege.liege
						exists = liege.liege.liege
						liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege.liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
					scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege's liege does, while their liege doesn't have a royal court
						top_liege != this
						has_royal_court = no
						exists = liege.liege
						exists = liege.liege.liege
						exists = liege.liege.liege.liege
						liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege.liege = {
							top_liege != this
							has_royal_court = no
						}
						liege.liege.liege.liege = {
							has_royal_court = yes
							has_same_court_language = scope:actor
						}
					}
				}
			}
		}

		modifier = {  # Serious diarchs wish to support their liege
			add = 50
			desc = ENTRENCHED_REGENT_WILL_SUPPORT_LIEGE
			trigger_if = {
				limit = { scope:recipient ?= scope:actor.diarch }
				scope:actor = { has_diarchy_parameter = diarchy_type_is_entrenched_regency }
			}
			trigger_else = { always = no }
		}

		compare_modifier = { # Likes fighting infidels
			trigger = {
				scope:recipient.faith = scope:actor.faith
				OR = {
					AND = {
						scope:target.casus_belli.primary_attacker = {
							this = scope:actor
							faith = {
								faith_hostility_level = {
									target = scope:target.casus_belli.primary_defender.faith
									value >= religious_cb_enabled_hostility_level
								}
							}
						}
					}
					AND = {
						scope:target.casus_belli.primary_defender = {
							this = scope:actor
							faith = {
								faith_hostility_level = {
									target = scope:target.casus_belli.primary_defender.faith
									value >= religious_cb_enabled_hostility_level
								}
							}
						}
					}
				}
			}
			target = scope:recipient
			value = ai_zeal
			desc = "ZEAL_AGAINST_INFIDELS"
			min = 0
			multiplier = 0.5
		}

		modifier = {  # Reluctant to attack another ally
			add = -50
			scope:target.casus_belli.primary_attacker = scope:actor
			scope:recipient = {
				is_allied_to = scope:target.casus_belli.primary_defender
			}
			desc = ATTACK_ON_ALLY_REASON
		}

		modifier = {  # Reluctant to defend against another ally
			add = -25
			scope:target.casus_belli.primary_defender = scope:actor
			scope:recipient = {
				is_allied_to = scope:target.casus_belli.primary_attacker
			}
			desc = WAR_WITH_ALLY_REASON
		}

		modifier = {  # Reluctant to join wars against religious brethren.
			add = -50
			scope:recipient.faith != scope:actor.faith
			scope:target.casus_belli.primary_attacker = scope:actor
			scope:target.casus_belli.primary_defender.faith = scope:recipient.faith
			scope:target.casus_belli.war = {
				OR = {
					using_cb = minor_religious_war
					using_cb = religious_war
					using_cb = major_religious_war
					using_cb = undirected_great_holy_war
					using_cb = directed_great_holy_war
				}
			}
			desc = WONT_ATTACK_RELIGIOUS_BRETHREN_REASON
		}

		modifier = { # Reluctant to join against Friends
			add = -50
			trigger_if = {
				limit = {
					scope:target.casus_belli.primary_defender = scope:actor
				}
				has_relation_friend = scope:target.casus_belli.primary_attacker
			}
			trigger_else = {
				has_relation_friend = scope:target.casus_belli.primary_defender
			}
			desc = WONT_FIGHT_FRIEND_REASON
		}

		modifier = { # Reluctant to join against Best Friends
			add = -100
			trigger_if = {
				limit = {
					scope:target.casus_belli.primary_defender = scope:actor
				}
				has_relation_best_friend = scope:target.casus_belli.primary_attacker
			}
			trigger_else = {
				has_relation_best_friend = scope:target.casus_belli.primary_defender
			}
			desc = WONT_FIGHT_BEST_FRIEND_REASON
		}
		modifier = { # Reluctant to join against Lovers
			add = -100
			trigger_if = {
				limit = {
					scope:target.casus_belli.primary_defender = scope:actor
				}
				has_relation_lover = scope:target.casus_belli.primary_attacker
			}
			trigger_else = {
				has_relation_lover = scope:target.casus_belli.primary_defender
			}
			desc = WONT_FIGHT_LOVER_REASON
		}
		modifier = { # Reluctant to join against Soulmate
			add = -200
			trigger_if = {
				limit = {
					scope:target.casus_belli.primary_defender = scope:actor
				}
				has_relation_soulmate = scope:target.casus_belli.primary_attacker
			}
			trigger_else = {
				has_relation_soulmate = scope:target.casus_belli.primary_defender
			}
			desc = WONT_FIGHT_SOULMATE_REASON
		}
		modifier = { # Reluctant to join tributaries
			add = -200
			scope:actor = {
				is_tributary_of = scope:recipient
				NOT = { subject_contract_has_flag = tributary_contract_suzerain_guarantee_override }
			}
			scope:recipient = {
				NOR = {
					has_relation_lover = scope:actor
					has_relation_friend = scope:actor
					is_allied_to = scope:actor
				}
			}
			desc = WONT_FIGHT_MEANINGLESS_REASON
		}
		modifier = {  # Refuse call for hostages' safety
			any_home_court_hostage = {
				warden = {
					OR = {
						is_at_war_with = scope:actor
						any_ally = { is_at_war_with = scope:actor }
					}
				}
			}
			add = {
				value = 0
				every_home_court_hostage = {
					limit = {
						warden = {
							OR = {
								is_at_war_with = scope:actor
								any_ally = { is_at_war_with = scope:actor }
							}
						}
					}
					subtract = call_to_arms_hostage_value
				}
				multiply = 0.25
			}
			desc = HOSTAGE_ENEMY_CALL_TO_ARMS_REASON
		}

		modifier = {
			scope:recipient.house.house_confederation ?= {
				trigger_if = {
					limit = { scope:actor = { is_defender_in_war = scope:target } }
					this = scope:target.casus_belli.primary_attacker.house.house_confederation
				}
				trigger_else = { this = scope:target.casus_belli.primary_defender.house.house_confederation }
			}
			add = -100
			desc = BLOC_MEMBER_CALL_TO_ARMS_REASON
		}

		modifier = {
			add = 200
			scope:actor = {
				is_tributary_of = scope:recipient
				subject_contract_has_flag = tributary_contract_suzerain_guarantee_override
			}
			desc = MANDALA_GUARANTEE_REASON
		}

		fp3_struggle_resist_allied_wars_modifier = yes
	}

	# Score above 0 means the AI will call this ally. Note that DESIRED_WAR_SIDE_STRENGTH still applies and can prevent calling the ally
	ai_will_do = {
		base = 100

		modifier = { # If the player is at war, do not bother them with offensive calls
			scope:target.casus_belli.primary_attacker = scope:actor
			scope:recipient = {
				is_ai = no
				any_character_war = {
					primary_defender = scope:recipient
				}
			}
			factor = 0
		}

		modifier = { # Do not call the player if they are in debt
			scope:recipient = {
				is_ai = no
				gold <= -1
			}
			factor = 0
		}

		modifier = { # Don't call players in against their heirs (they wouldn't accept the reverse situation... don't be a hypocrite)
			exists = scope:recipient.player_heir
			scope:recipient = {
				is_ai = no
			}
			trigger_if = {
				limit = { scope:target.casus_belli.primary_defender = scope:actor }
				scope:target.casus_belli.primary_attacker = scope:recipient.player_heir
			}
			trigger_else = {
				scope:target.casus_belli.primary_defender = scope:recipient.player_heir
			}
			factor = 0
		}

		modifier = { # Same with spouses
			scope:recipient = {
				is_ai = no
			}
			trigger_if = {
				limit = { scope:target.casus_belli.primary_defender = scope:actor }
				any_spouse = {
					this = scope:target.casus_belli.primary_attacker
				}
			}
			trigger_else = {
				any_spouse = {
					this = scope:target.casus_belli.primary_defender
				}
			}
			factor = 0
		}

		modifier = { # Don't call brand-new allies into old wars, at least until some time has elapsed.
			has_variable = delay_calling_recent_ally
			var:delay_calling_recent_ally = scope:recipient
			scope:target = {
				war_days >= 30
			}
			factor = 0

		}

		modifier = { # If the recipient is allied to both the attacker and the defender, the attacker shouldn't call
			scope:target.casus_belli.primary_attacker = scope:actor
			scope:target.casus_belli.primary_defender = {
				is_allied_to = scope:recipient
			}
			factor = 0
		}

		#You're a Mandala Suzerain; you don't get off the hook that easily
		modifier = {
			scope:actor = { subject_contract_has_flag = tributary_contract_suzerain_guarantee_override }
			scope:recipient = scope:actor.suzerain
			add = 500
		}

		modifier = { # Don't call allies into offensive wars, if the recipient doesn't have enough opinion 
			scope:target.casus_belli.primary_attacker = scope:actor
			scope:recipient = {
				is_ai = no
				opinion = {
					target = scope:actor
					value < 75
				}
			}
			factor = 0
		}

		modifier = { # Don't call allies into defensive wars, if the recipient doesn't have enough opinion 
			NOT = { scope:target.casus_belli.primary_attacker = scope:actor }
			scope:recipient = {
				is_ai = no
				opinion = {
					target = scope:actor
					value < 50
				}
			}
			factor = 0
		}
	}
}



offer_vassalization_interaction = {
	category = interaction_category_vassal
	icon = icon_vassal

	desc = offer_vassalization_interaction_desc

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

	is_shown = {
		
		scope:recipient = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:actor = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:actor = {
			is_landed = yes
		}
		scope:recipient = {
			this != scope:actor
			is_playable_character = yes
			OR = {
				AND = {
					top_liege = this
					is_tributary = no
				}
				is_tributary_of_suzerain_or_above = scope:actor
			}
			trigger_if = {
				limit = {
					scope:actor = {
						NOT = { government_has_flag = government_is_mandala }
					}
				}
				highest_held_title_tier < scope:actor.highest_held_title_tier
			}
			NOR = {
				government_has_flag = cannot_be_vassal_or_liege
				government_has_flag = government_is_herder
			}
		}
		# Temujin cannot make Jamukha his subject once he leaves him
		NOT = {
			scope:actor = {
				has_variable = had_mpo_temujin_flavor_0010
				var:had_mpo_temujin_flavor_0010 ?= scope:recipient
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			trigger_if = {
				limit = { is_confederation_member = yes }
				exists = house.house_confederation
			}
			trigger_if = {
				limit = {
					has_title = title:h_china
				}
				situation:dynastic_cycle ?= {
					NOT = {
						situation_current_phase = situation_dynastic_cycle_phase_instability
					}
					trigger_if = {
						limit = {
							situation_current_phase = situation_dynastic_cycle_phase_stability_advancement
						}
						scope:recipient = {
							custom_tooltip = {
								text = recipient_is_not_celestial_desc
								government_has_flag = government_is_celestial
							}
						}
					}
				}
			}
		}
		scope:recipient = {
			is_at_war = no
			is_confederation_member = no

			custom_description = {
				text = was_recently_granted_independence
				NOT = {
					has_opinion_modifier = {
						modifier = granted_independence_opinion
						target = scope:actor
					}
				}
			}
			trigger_if = {
				limit = { is_tributary = yes }
				custom_tooltip = {
					text = was_recently_granted_independence
					scope:recipient.suzerain = scope:actor
				}	
			}
			trigger_if = {
				limit = {
					scope:actor = { government_has_flag = government_is_mandala }
				}
				highest_held_title_tier < scope:actor.highest_held_title_tier
			}
		}
	}

	greeting = positive
	notification_text = OFFER_VASSALIZATION_INTERACTION_NOTIFICATION

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

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	ai_accept = {
		base = -50
		# MAIN
		# Heretic/Infidel modifier.
		# Tier difference modifier.
		# Dejure modifier.
		# Distant/Remote Realm modifier.
		# Military power difference modifier.

		# MINOR
		# Rivalry modifier.
		# Same Dynasty modifier.
		# Cultural/Cultural Group modifiers.
		# Ageism modifier vs kids.
		# Ruler Legitimacy modifier.
		# Claimant modifier.
		# FP3 Piety Level modifier.

		# OPINION SCALES
		# Dread
		# Compare Opinion modifier.

		#ALL these modifiers are also used in impress_intent_vassalization_acceptance_value, keep them synced

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


		# STRUGGLES - bonus gained by successful Sway scheme during the Persian Struggle
		modifier = {
			desc = fp3_persian_struggle_previously_swayed_tt
			trigger = {
				scope:recipient = {
					has_opinion_modifier = {
						modifier = scheme_sway_and_compelled_to_submit_opinion
						target = scope:actor
					}
				}
			}
			add = 20
		}

		modifier = { #Rekindler of Iran
			desc = fp3_rekindler_of_iran_modifier_reason
			trigger = {
				AND = {
					scope:actor = { dynasty ?={ has_dynasty_modifier = fp3_rekindler_of_iran_modifier } }
					scope:recipient = { culture = { has_cultural_pillar = heritage_iranian } }
				}
			}
			add = 20
		}

		# OBEDIENCE
		modifier = {
			desc = obedient_interaction_reason
			trigger = {
				is_obedient_to = scope:actor
			}
			add = 20
		}

		modifier = { # Cultural Acceptance
			add = offer_vassalage_acceptance_value
			desc = cultural_acceptance_interaction_reason
			trigger = {
				scope:actor = {
					NOR = {
						has_same_culture_as = scope:recipient
						government_has_flag = government_is_nomadic # Nomads do not care about Culture
						has_trait = nomadic_philosophy
					}
					culture = {
						cultural_acceptance = { target = scope:recipient.culture value <= 90 }
					}
				}
			}
		}

		modifier = { #Has no Available Vassal Limit
			desc = offer_vassalization_interaction_aibehavior_vassal_limit_tt
			trigger = {
				scope:actor = {
					vassal_limit_available < 1
				}
			}
			add = {
				value = -1000
			}
		}
		

		# MAIN
		modifier = { #Different faith, no pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Nomads do not care about Faith
						government_has_flag = government_is_nomadic
						has_trait = nomadic_philosophy
					}
				}
				scope:recipient = {
					NOR = { #Of two different faiths AND the potential vassal's faith is not pluralistic.
						faith = scope:actor.faith
						faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
				}
			}
			add = {
				value = -40
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -40
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -40
				}
			}
		}

		modifier = { #Different faith, pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Nomads do not care about Faith
						government_has_flag = government_is_nomadic
						has_trait = nomadic_philosophy
					}
				}
				scope:recipient = {
					faith != scope:actor.faith
					NOT = {
						scope:actor.faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
					faith = { has_doctrine = doctrine_pluralism_pluralistic }
				}
			}
			add = {
				value = -20
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -20
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -20
				}
			}
		}

		modifier = { #Different faith, both have pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Nomads do not care about Faith
						government_has_flag = government_is_nomadic
						has_trait = nomadic_philosophy
					}
				}
				scope:recipient = {
					faith != scope:actor.faith
					scope:actor.faith = { has_doctrine = doctrine_pluralism_pluralistic }
					faith = { has_doctrine = doctrine_pluralism_pluralistic }
				}
			}
			add = {
				value = -10
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -10
				}
			}
		}
		modifier = { #I am a King! Or Emperor!
			desc = offer_vassalization_interaction_aibehavior_hightier_tt
			trigger = {
				NAND = {
					scope:actor = {
						government_has_flag = government_is_celestial
						highest_held_title_tier >= tier_hegemony
					}
					scope:recipient = {
						government_has_flag = government_is_celestial
					}
				}
				scope:recipient = { highest_held_title_tier >= tier_kingdom }
			}
			add = {
				value = -50
				if = {
					limit = {
						scope:recipient = {
							OR = {
								government_has_flag = government_is_republic
								government_has_flag = government_is_theocracy
							}
						}
					}
					add = -50
				}
				if = {
					limit = {
						scope:recipient.sub_realm_size >= 10
					}
					add = -50
				}
				if = {
					limit = {
						scope:recipient.sub_realm_size >= 20
					}
					add = -100
				}
				if = {
					limit = {
						scope:recipient = { highest_held_title_tier = tier_empire }
					}
					multiply = 1.5 # We bump this up for emperors
				}
			}
		}
		modifier = { #We just fought against each other.
			desc = offer_vassalization_interaction_aibehavior_recent_war_tt
			trigger = {
				scope:recipient = {
					any_truce_holder = {
						this = scope:actor
					}
				}
				# Ensure the truce wasn't purchased and is indeed from a war
				scope:actor = {
					NOT = {
						has_purchased_truce_with_char = { TARGET = scope:recipient }
					}
				}
				scope:recipient = {
					NOT = {
						has_purchased_truce_with_char = { TARGET = 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 = { # I am Tribal and you are not
			desc = interaction_tribal_vs_nontribal
			trigger = {
				scope:recipient = {
					government_has_flag = government_is_tribal
				}
				scope:actor = {
					NOT = { government_has_flag = government_is_tribal }
				}
			}
			add = -20
		}
		modifier = { # You are Tribal and I am not
			desc = interaction_nontribal_vs_tribal
			trigger = {
				scope:actor = {
					government_has_flag = government_is_tribal
				}
				scope:recipient = {
					NOT = { government_has_flag = government_is_tribal }
				}
			}
			add = -20
		}
		modifier = { # I am Nomadic and you are Nomadic
			desc = interaction_is_nomadic
			trigger = {
				scope:recipient = {
					government_has_flag = government_is_nomadic
				}
				scope:actor = {
					government_has_flag = government_is_nomadic
				}
			}
			add = -50
		}
		modifier = { # I am Nomadic and you are not
			desc = interaction_nomadic_vs_nonnomadic
			trigger = {
				scope:recipient = {
					government_has_flag = government_is_nomadic
				}
				scope:actor = {
					NOT = { government_has_flag = government_is_nomadic }
				}
			}
			add = -75
		}
		modifier = { # You are Nomadic and I am not
			desc = interaction_nonnomadic_vs_nomadic
			trigger = {
				scope:actor = {
					government_has_flag = government_is_nomadic
				}
				scope:recipient = {
					NOT = { government_has_flag = government_is_nomadic }
				}
			}
			add = -75
		}
		modifier = { # Isolationist tradition
			desc = isolationist_reason
			trigger = {
				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 = { #Wide difference in rank
			desc = offer_vassalization_interaction_aibehavior_widetitletier_tt
			trigger = {
				scope:actor = {
					OR = {
						NOT = { government_has_flag = government_is_celestial }
						scope:recipient = {
							NOT = { government_has_flag = government_is_celestial }
						}
					}
					tier_difference = {
						target = scope:recipient
						value > 1
					}
				}
			}
			add = 10
		}
		modifier = { #Wide difference in rank (Celestial to Celestial)
			desc = offer_vassalization_interaction_aibehavior_widetitletier_tt
			trigger = {
				scope:actor = {
					government_has_flag = government_is_celestial
					tier_difference = {
						target = scope:recipient
						value > 1
					}
				}
				scope:recipient = {
					government_has_flag = government_is_celestial
				}
			}
			add = {
				value = 20
				multiply = {
					value = scope:actor.highest_held_title_tier
					subtract = scope:recipient.highest_held_title_tier
				}
			}
		}
		modifier = { # Is a Hegemon
			desc = offer_vassalization_interaction_aibehavior_hegemony_tt
			trigger = {
				scope:actor = { highest_held_title_tier = tier_hegemony }
			}
			add = 10
		}
		modifier = { # Allied
			desc = offer_vassalization_interaction_aibehavior_allied_tt
			trigger = {
				scope:recipient = {
					is_allied_to = scope:actor
				}
			}
			add = 20
		}
		modifier = { # Is the Rightful Liege of recipient
			desc = offer_vassalization_interaction_aibehavior_rightfulliegetitleholder_tt
			trigger = {
				scope:actor = { is_rightful_liege_of = scope:recipient }
			}
			add = 20
		}
		modifier = { #Is not the Rightful Liege of recipient
			desc = offer_vassalization_interaction_aibehavior_not_rightfulliegetitleholder_tt
			trigger = {
				NOT = {
					scope:actor = { is_rightful_liege_of = scope:recipient }
				}
			}
			add = -20
		}
		modifier = { # Encircled
			desc = offer_vassalization_interaction_aibehavior_encircled_tt
			trigger = {
				scope:recipient = {
					NOT = {
						any_neighboring_top_liege_realm_owner = {
							this != scope:actor
						}
					}
					NOT = {
						any_realm_county = {
							is_coastal_county = yes
						}
					}
				}
			}
			add = 20
		}
		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
						scope:actor = { 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 = {
					# landless ruler count as within realm
					trigger_if = {
						limit = { is_landed = no }
						NOT = { capital_county.holder = { target_is_same_character_or_above = scope:actor } }
					}
					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 = {
					# landless ruler count as within realm
					trigger_if = {
						limit = { is_landed = no }
						NOT = { capital_county.holder = { target_is_same_character_or_above = scope:actor } }
					}
					capital_province = { squared_distance = { target = scope:actor.capital_province value >= 200000 } }
				}
			}
			add = -500
		}
		modifier = { #Military Strength
			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 = { #Vassal opinion
			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
	  		}
		}

		# 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 = 10
		}
		modifier = { #Best Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_best_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_best_friend = scope:actor
				}
			}
			add = 20
		}
		modifier = { #Lover modifier.
			desc = interaction_lover
			trigger = {
				scope:recipient = {
					has_relation_lover = scope:actor
					NOT = { has_relation_soulmate = scope:actor }
				}
			}
			add = 10
		}
		modifier = { #Soulmate modifier.
			desc = interaction_soulmate
			trigger = {
				scope:recipient = {
					has_relation_soulmate = scope:actor
				}
			}
			add = 20
		}
		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 = 5
		}

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

		modifier = { # Iberian Struggle, less likely for outsiders to vassalize inside
			add = -35
			desc = iberian_struggle_reason_reason
			trigger = {
				scope:actor = {
					NOT = {
						any_character_struggle = { is_struggle_type = iberian_struggle }
					}
				}
				scope:recipient = {
					any_character_struggle = { is_struggle_type = iberian_struggle }
				}
			}
		}

		modifier = { #Ageism modifier vs kids.
			desc = offer_vassalization_interaction_aibehavior_child_tt
			trigger = {
				scope:actor = {
					age < 12
				}
				scope:recipient = {
					age > 16
				}
			}
			add = -5
		}
		modifier = { #Illegitimacy modifier.
			desc = offer_vassalization_interaction_aibehavior_illegitimate_tt
			trigger = {
				scope:actor = {
					OR = {
						AND = {
							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
			trigger = { scope:actor = { any_character_struggle = { has_struggle_phase_parameter = piety_level_affects_vassalage_acceptance } } }
			add = {
				value = {
					value = scope:actor.piety_level
					subtract = low_piety_level
				}
				multiply = 10
			}
		}

		# 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
		}
		opinion_modifier = { #Compare Opinion modifier - Clans care more about opinion
			trigger = {
				scope:actor = {
					government_has_flag = government_is_clan
				}
				scope:recipient = {
					government_has_flag = government_is_clan
				}
			}
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.7
		}
		opinion_modifier = { #Compare Opinion modifier.
			trigger = {
				NOT = { 
					scope:actor = { government_has_flag = government_is_mandala } #Has their own Opinion modifier
				}
				OR = {
					scope:actor = {
						NOT = { government_has_flag = government_is_clan }
					}
					scope:recipient = {
						NOT = { government_has_flag = government_is_clan }
					}
				}
			}
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.35
		}

		# DIPLOMATIC COURT GRANDEUR BONUS
		modifier = {
			trigger = {
				scope:actor = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					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 = 60
				scope:recipient = {	government_has_flag = government_is_feudal }
				scope:religious_exemption = yes
				desc = CONTRACT_RELIGIOUS_EXEMPTION_REASON
			}
			modifier = {
				add = 30
				scope:recipient = {	government_has_flag = government_is_clan }
				scope:religious_exemption_clan = yes
				desc = CONTRACT_RELIGIOUS_EXEMPTION_REASON
			}
			modifier = {
				add = 30
				scope:recipient = {	government_has_flag = government_is_feudal }
				scope:low_obligations = yes
				desc = CONTRACT_LOW_TAXES_REASON
			}
			modifier = {
				add = -40
				scope:recipient = {	government_has_flag = government_is_feudal }
				scope:high_obligations = yes
				desc = CONTRACT_HIGH_TAXES_REASON
			}

		# INSPECTION BONUSES
			modifier = {
				desc = "INSPECTION_REASON"
				add = 5
				scope:recipient = {
					has_variable_list = lesser_inspection_bonus
					is_target_in_variable_list = {
						name = lesser_inspection_bonus
						target = scope:actor
					}
				}
			}
			modifier = {
				desc = "INSPECTION_REASON"
				add = 10
				scope:recipient = {
					has_variable_list = inspection_bonus
					is_target_in_variable_list = {
						name = inspection_bonus
						target = scope:actor
					}
				}
			}
			modifier = {
				desc = "INSPECTION_REASON_REWARD"
				add = 10
				scope:recipient = {
					has_variable_list = inspection_reward
					is_target_in_variable_list = {
						name = inspection_reward
						target = scope:actor
					}
				}
			}
			modifier = {
				desc = "INSPECTION_REASON_REWARD_FOCUSED"
				add = 10
				scope:actor = { has_character_modifier = inspection_reward_focused_vassal_acceptance }
			}

		# LOW LEGITIMACY
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -25
				scope:actor = {
					has_legitimacy_flag = reduced_vassalization_acceptance
				}
			}
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -50
				scope:actor = {
					has_legitimacy_flag = very_reduced_vassalization_acceptance
				}
			}
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -75
				scope:actor = {
					has_legitimacy_flag = massively_reduced_vassalization_acceptance
				}
			}

		# HIGH LEGITIMACY
			modifier = {
				desc = "HIGH_LEGITIMACY_REASON"
				add = 25
				scope:actor = {
					has_legitimacy_flag = increased_vassalization_acceptance
				}
			}
			modifier = {
				desc = "HIGH_LEGITIMACY_REASON"
				add = 50
				scope:actor = {
					has_legitimacy_flag = very_increased_vassalization_acceptance
				}
			}
			modifier = {
				desc = "HIGH_LEGITIMACY_REASON"
				add = 75
				scope:actor = {
					has_legitimacy_flag = extra_increased_vassalization_acceptance
				}
			}

		# INFLUENCE
		modifier = {
			add = 25
			scope:influence_send_option = yes
			desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
		}

		#HISTORICALLY ADMIN PEOPLES WANT TO BE ADMIN
		modifier = {
			add = 30
			scope:actor = {
				government_has_flag = government_is_administrative
			}
			scope:recipient = {
				culture = {
					OR = {
						this = culture:greek
						any_parent_culture_or_above = {
							this = culture:greek
						}
						this = culture:han
						any_parent_culture_or_above = {
							this = culture:han
						}
					}
				}
			}

			desc = "HISTORICAL_ADMIN_REASON"
		}

		modifier = { # AI-only weights, keep the pope from vassalizing too fast
			trigger = {
				exists = faith:catholic.religious_head
				faith:catholic.religious_head = scope:actor
				scope:actor = { is_ai = yes }
			}
			add = -50
		}

		modifier = {
			scope:actor = {
				has_variable = severed_head_vassalization
				var:severed_head_vassalization = {
					this = scope:recipient
				}
			}
			add = 200
			desc = COWED_BY_SEVERED_HEAD_MODIFIER
		}

		#ALL these modifiers are also used in impress_intent_vassalization_acceptance_value, keep them synced

		#Mandala
			#Mandala Tributaries should not want to be vassals
			modifier = {
				scope:recipient = { is_tributary_of = scope:actor }
				scope:actor = { government_has_flag = government_is_mandala }
				add = -35
				desc = is_tributary_of_me_mandala
			}

			modifier = {
				scope:recipient = { government_has_flag = government_is_mandala }
				scope:actor = { government_has_flag = government_is_mandala }
				add = -25
				desc = is_mandala_government
			}

			#Your Radiance
			modifier = {
				scope:actor = { has_mandala_capital_trigger = yes }
				add = scope:actor.mandala_radiance_value
				desc = actor_positive_mandala_radiance
			}

			#Tributary Realm Size
			subject_realm_size_lose_weight_modifier = {
				DEVARAJA = scope:actor
				SUBJECT = scope:recipient
			}
			
			#Do they like you?
			opinion_modifier = { 
				trigger = {
					scope:actor = { government_has_flag = government_is_mandala }
				}
				who = scope:recipient
				opinion_target = scope:actor
				multiplier = 1
			}
	}

	# Low starting obligations
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		flag = low_obligations
		localization = low_obligations
	}

	# Medium starting obligations
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		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 = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		flag = high_obligations								# If selected then scope:flag_name will be set to yes
		localization = high_obligations					# Loc_key for option label
	}

	# Low starting obligations + religious exemption
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		is_valid = {
			scope:recipient.faith != scope:actor.faith
		}
		flag = religious_exemption
		localization = religious_exemption
	}

	# Religious exemption, for clans
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			scope:recipient.faith != scope:actor.faith
		}
		flag = religious_exemption_clan
		localization = religious_exemption
	}

	# Nothing, for clans
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			always = yes
		}
		flag = no_exemption_clan
		localization = no_exemption
	}

	send_option = { # EP3 Influence
		is_shown = {
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			scope:actor = { influence >= medium_influence_value }
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}

	send_options_exclusive = yes

	on_accept = {
		offer_vassalization_interaction_effect = yes
		scope:actor = {
			trigger_event = char_interaction.0001

			## Remove bonus, it's been used
			if = {
				limit = { has_character_modifier = event_bonus_to_vassal_accept }
				remove_character_modifier = event_bonus_to_vassal_accept
			}

			if = { # FP3
				limit = { any_character_struggle = { has_struggle_phase_parameter = offer_vassalization_removes_disloyalty } }
				scope:recipient = { remove_trait = disloyal }
			}
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0002
		}
	}

	ai_potential = {
		is_adult = yes
		top_liege = this
		highest_held_title_tier > tier_county
		vassal_limit_available > 1
	}

	ai_will_do = {
		base = 100

		# AI prefers to receive higher obligations from their vassals when possible.
		modifier = {
			factor = 3
			scope:normal_obligations = yes
		}

		modifier = {
			factor = 4
			scope:high_obligations = yes
		}

		# Cynical rulers are happy to offer religious protection to potential vassals, but only when it makes them accept a vassalization offer they would otherwise refuse.
		# Zealous rulers become increasingly reluctant to offer religious protection, as they want to enforce religious homogeneity in their realm.
		modifier = {
			add = {
				value = ai_zeal
				multiply = -2
				max = 1
			}
			scope:religious_exemption = yes
		}


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

offer_fealty_interaction = {
	category = interaction_category_vassal
	icon = icon_liege

	desc = offer_fealty_interaction_desc

	is_shown = {
		
		scope:recipient = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:actor = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:recipient = {
			this != scope:actor
			is_landed = yes
			top_liege = this # Target has to be independent
		}
		scope:actor.highest_held_title_tier < scope:recipient.highest_held_title_tier
		scope:actor = {
			is_landed = yes
			top_liege = this # You have to be independent - This check exists to prevent a lot of edge-cases where you can change liege
			NOT = { government_has_flag = cannot_be_vassal_or_liege }
			is_confederation_member = no
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_imprisoned = no
			is_at_war = no
		}
		scope:recipient = {
			custom_description = {
				text = "offer_fealty_neighboring_condition"
				subject = scope:recipient
				OR = {
					any_neighboring_and_across_water_top_liege_realm_owner = { this = scope:actor }
					any_held_title = {
						is_de_jure_liege_or_above_target = scope:actor.capital_barony
					}
				}
			}
			#making sure that if this gov types got land you won't be able to swear fealty to them
			NOR = {
				government_has_flag = government_is_landless_adventurer
				government_has_flag = government_is_holy_order
				government_has_flag = government_is_mercenary
			}
		}
	}

	greeting = positive
	notification_text = OFFER_FEALTY_INTERACTION_NOTIFICATION

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	ai_accept = {
		base = 50
		# MAIN
		# Heretic/Infidel modifier.
		# Tier difference modifier.
		# Dejure modifier.
		# Distant/Remote Realm modifier.

		# MINOR
		# Rivalry modifier.
		# Same Dynasty modifier.
		# Cultural/Cultural Group modifiers.
		# Claimant modifier.

		# OPINION SCALES
		# Personality modifier.
		# Compare Opinion modifier.

		modifier = { # Different faith, no pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Of two different faiths AND the potential vassal's faith is not pluralistic.
						faith = scope:recipient.faith
						faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
				}
			}
			add = {
				value = -25
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_evil_level
							}
						}
					}
					add = -25
				}
			}
		}

		modifier = { # I am a King!
			desc = offer_fealty_interaction_aibehavior_hightier_tt
			trigger = {
				scope:actor = {
					highest_held_title_tier >= tier_kingdom
				}
			}
			add = -10
		}
		modifier = { # Wide difference in rank
			desc = offer_vassalization_interaction_aibehavior_widetitletier_tt
			trigger = {
				scope:actor = {
					tier_difference = {
						target = scope:recipient
						value > 1
					}
				}
			}
			add = 20
		}
		modifier = { # They are my Rightful Liege
			desc = offer_vassalization_interaction_aibehavior_rightfulvassaltitleholder_tt
			trigger = {
				scope:recipient = { is_rightful_liege_of = scope:actor }
			}
			add = 25
		}
		modifier = { # Distant Realm.
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
					# landless ruler count as within realm
					trigger_if = {
						limit = { is_landed = no }
						NOT = { capital_county.holder = { target_is_same_character_or_above = scope:actor } }
					}
					capital_province = { squared_distance = { target = scope:recipient.capital_province value < 200000 } }
				}
			}
			add = -15
		}
		modifier = { # Remote Realm.
			desc = offer_vassalization_interaction_aibehavior_remoterealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
					# landless ruler count as within realm
					trigger_if = {
						limit = { is_landed = no }
						NOT = { capital_county.holder = { target_is_same_character_or_above = scope:actor } }
					}
					capital_province = { squared_distance = { target = scope:recipient.capital_province value >= 200000 } }
				}
			}
			add = -25
		}

		# MINOR
		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 = -10
		}
		modifier = { # Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -100
		}
		modifier = { # Same Dynasty modifier.
			desc = offer_vassalization_interaction_aibehavior_dynasty_tt
			trigger = {
				scope:recipient = {
					dynasty = scope:actor.dynasty
				}
			}
			add = 10
		}

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

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

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

		# PERSONALITY
		ai_value_modifier = {
			ai_greed = 0.75
			min = 0
		}

		# OPINION INFLUENCE
		opinion_modifier = { # Compare Opinion modifier.
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.5
		}

		# CONTRACT OPTIONS
		modifier = {
			add = {
				value = -10
				if = {
					limit = { scope:recipient = { has_trait = zealous } }
					add = -30
				}
				else_if = {
					limit = { scope:recipient = { has_trait = cynical } }
					add = 30
				}
			}
			scope:actor = {	government_has_flag = government_is_feudal }
			scope:religious_taxation = yes
			desc = CONTRACT_RELIGIOUS_TAXATION_REASON
		}
		modifier = {
			add = -40
			scope:actor = {	government_has_flag = government_is_feudal }
			scope:low_obligations = yes
			desc = CONTRACT_LOW_TAXES_REASON
		}
		modifier = {
			add = 40
			scope:actor = {	government_has_flag = government_is_feudal }
			scope:high_obligations = yes
			desc = CONTRACT_HIGH_TAXES_REASON
		}
		modifier = {
			add = {
				value = -10
				if = {
					limit = { scope:recipient = { has_trait = zealous } }
					add = -30
				}
				else_if = {
					limit = { scope:recipient = { has_trait = cynical } }
					add = 30
				}
			}
			scope:actor = {	government_has_flag = government_is_clan }
			scope:religious_exemption_clan = yes
			desc = CONTRACT_RELIGIOUS_EXEMPTION_REASON
		}
		# EP3
		modifier = { # cowed from an emperor's impressive visit
			add = 10
			desc = cowed_from_visit_interaction_reason
			trigger = {
				scope:actor = {
					has_character_flag = cowed_increased_vassalization_acceptance
				}
			}
		}
		#Confederation wants same-culture rulers
		modifier = {
			add = 100
			desc = CONFEDERATION_CULTURE_REASON
			scope:recipient = {
				is_confederation_member = yes
				culture = {
					this = scope:actor.culture
				}
			}
		}

		#Greatest of Khans and Mongol Emperor would prefer submission with tribute
		modifier = {
			add = -150
			desc = GOK_PREFER_SUBMISSION
			scope:recipient = {
				highest_held_title_tier >= tier_empire
				any_owned_story = {
					OR = {
						story_type = story_mongol_invasion
						story_type = story_greatest_of_khans
					}
				}
			}
		}
	}

	# Low starting obligations
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		flag = low_obligations
		localization = low_obligations
	}

	# Medium starting obligations
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		flag = normal_obligations
		localization = normal_obligations
		starts_enabled = { always = yes	}

	}

	# High starting obligations
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		flag = high_obligations
		localization = high_obligations
	}

	# Medium-high starting obligations + religious protection
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		is_valid = {
			scope:recipient.faith != scope:actor.faith
		}
		flag = religious_taxation
		localization = religious_taxation
	}

	# Religious exemption, for clans
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			scope:recipient.faith != scope:actor.faith
		}
		flag = religious_exemption_clan
		localization = religious_exemption
	}

	# Nothing, for clans
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			always = yes
		}
		flag = no_exemption_clan
		localization = no_exemption
	}

	send_options_exclusive = yes

	on_accept = {
		offer_fealty_interaction_effect = yes

		scope:actor = {
			trigger_event = char_interaction.0010
			if = {
				limit = {
					government_has_flag = government_is_administrative
					scope:recipient = { NOT = { government_has_flag = government_is_administrative } }
				}
				custom_tooltip = will_change_from_administrative_tt
				custom_tooltip = will_lose_administrative_government_type_tt
			}
			if = {
				limit = {
					scope:recipient = {
						is_confederation_member = yes
					}
				}
				if = {
					limit = {
						government_has_flag = government_is_nomadic
					}
					add_character_modifier = {
						modifier = mpo_confederation_member_modifier
						years = 5
					}
					every_vassal_or_below = {
						limit = {
							highest_held_title_tier >= tier_county
							government_has_flag = government_is_nomadic
						}
						add_character_modifier = {
							modifier = mpo_confederation_member_modifier
							years = 5
						}
					}
				}

				add_character_flag = {
					flag = new_confederate
					years = 3
				}
				every_vassal_or_below = {
					limit = {
						highest_held_title_tier >= tier_county
					}
					add_character_flag = {
						flag = new_confederate
						years = 3
					}
				}
			}

			# If you have a suzerain, they will get a lower opinion of you for not paying tribute anymore
			suzerain ?= {
				if = {
					limit = {
						this != scope:actor
						this != scope:recipient
					}
					add_opinion = {
						modifier = tributary_ceased_payments_opinion
						target = scope:actor
					}
				}
			}
		}
		scope:recipient = {
			if = {
				limit = {
					has_imprisonment_reason = scope:actor
				}
				consume_imprisonment_reasons = scope:actor
			}
			if = {
				limit = {
					has_revoke_title_reason = scope:actor
				}
				consume_revoke_title_reason = scope:actor
			}
			if = {
				limit = {
					has_banish_reason = scope:actor
				}
				consume_banish_reasons = scope:actor
			}
			if = {
				limit = {
					has_execute_reason = scope:actor
				}
				consume_execute_reasons = scope:actor
			}
		}
	}

	on_intermediary_accept = {
	}

	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0011
		}
	}
}


become_tributary_interaction = {
	category = interaction_category_vassal
	common_interaction = no
	icon = become_tributary_interaction

	desc = become_tributary_interaction_desc

	is_shown = {
		
		
		scope:recipient = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:actor = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:recipient = {
			is_independent_ruler = yes # while it's possible for tributaries to have their own tributaries, it should not be possible to create a tributary relationship with a non-independent ruler
			NOR = {
				this = scope:actor
				this = scope:actor.suzerain
				top_suzerain = scope:actor
			}
			can_have_tributaries_trigger = yes
		}
		scope:actor = {
			trigger_if = {
				limit = { is_ai = yes }
				current_military_strength < scope:recipient.one_and_a_half_times_current_military_strength
				primary_title.tier < scope:recipient.primary_title.tier
			}
		}
	}

	is_valid_showing_failures_only = {
		#These triggers need to match the Tribute Mission Decision
		trigger_if = {
			limit = {
				scope:recipient = { primary_title.tier = tier_hegemony }
			}
			custom_tooltip = {
				text = become_tributary_interaction_hegemony_not_neighbor_tt
				scope:actor = {
					OR = {
						is_tributary_or_independent_neighbor_of_hegemon_trigger = { HEGEMON = h_china }
						is_tributary_or_independent_neighbor_of_hegemon_trigger = { HEGEMON = h_roman_empire }
						is_tributary_or_independent_neighbor_of_hegemon_trigger = { HEGEMON = h_eastern_roman_empire }
						is_tributary_or_independent_neighbor_of_hegemon_trigger = { HEGEMON = h_dar_al_islam }
						is_tributary_or_independent_neighbor_of_hegemon_trigger = { HEGEMON = h_india }
					}
				}
			}
		}
		#Mandalas can into Mandalas and Tributaries
		trigger_if = {
			limit = {
				scope:recipient = { government_has_flag = government_is_mandala }
				scope:actor = {
					OR = { 
						government_has_flag = government_is_tribal
						government_has_flag = government_is_mandala
					}
				}
			}
			always = yes
		}
		#Rulers who aren't Mandala or Tribal should really only be interested if you're big enough
		trigger_else = {
			custom_tooltip = {
				text = offer_tributarization_interaction_aibehavior_not_higher_rank
				scope:recipient.highest_held_title_tier >= scope:actor.highest_held_title_tier
			}
		}
		scope:actor = {
			is_physically_able = yes
			is_travelling = no
			NOT = { exists = involved_activity }
			is_confederation_member = no
			is_at_war = no
		}
	}

	needs_confirmation = {
		scope:recipient = { highest_held_title_tier < tier_hegemony } # acknowledging a hegemon requires a tribute mission; open the decision UI instead of confirming acceptance
	}

	greeting = positive
	notification_text = BECOME_TRIBUTARY_INTERACTION_NOTIFICATION

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

	# Medium starting obligations
	send_option = {
		flag = normal_obligations
		localization = normal_tributary_obligations
		starts_enabled = { always = yes	}
	}

	# High starting obligations
	send_option = {
		flag = high_obligations
		localization = high_tributary_obligations
	}

	send_options_exclusive = yes

	on_send = {
		if = {
			limit = { scope:recipient = { highest_held_title_tier >= tier_hegemony } }
			if = {
				limit = { scope:recipient.primary_title = title:h_china }
				open_view_data = {
					view = decision_detail
					data = decision:tribute_mission_decision_china
					player = scope:actor
				}
			}
			else_if = {
				limit = { scope:recipient.primary_title = title:h_roman_empire }
				open_view_data = {
					view = decision_detail
					data = decision:tribute_mission_decision_roman_empire
					player = scope:actor
				}
			}
			else_if = {
				limit = { scope:recipient.primary_title = title:h_eastern_roman_empire }
				open_view_data = {
					view = decision_detail
					data = decision:tribute_mission_decision_eastern_roman_empire
					player = scope:actor
				}
			}
			else_if = {
				limit = { scope:recipient.primary_title = title:h_dar_al_islam }
				open_view_data = {
					view = decision_detail
					data = decision:tribute_mission_decision_dar_al_islam
					player = scope:actor
				}
			}
			else_if = {
				limit = { scope:recipient.primary_title = title:h_india }
				open_view_data = {
					view = decision_detail
					data = decision:tribute_mission_decision_india
					player = scope:actor
				}
			}
		}
	}

	on_accept = {
		if = {
			limit = { scope:recipient = { highest_held_title_tier < tier_hegemony } }
			scope:actor = {
				if = {
					limit = { is_tributary = yes }
					mandala_end_tributary_with_notification_effect = yes
				}
			}
			start_tributary_interaction_effect = {
				TRIBUTARY = scope:actor
				SUZERAIN = scope:recipient
			}
			scope:actor = {
				trigger_event = char_interaction.0360
			}
			scope:recipient = {
				if = {
					limit = { scope:high_obligations = yes }
					add_opinion = {
						modifier = tributary_volunteered_opinion
						target = scope:actor
						opinion = 20
					}
				}
				else_if = {
					limit = { scope:normal_obligations = yes }
					add_opinion = {
						modifier = tributary_volunteered_opinion
						target = scope:actor
					}
				}

				consume_all_criminal_reasons_effect = {
					LIEGE = scope:recipient
					CRIMINAL = scope:actor
				}
			}
		}
		else = {} # Do nothing if the recipient is hegemony-tier or higher; these require a tribute mission to establish
	}

	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0361
		}
	}

	is_available = {
		NOT = { government_has_flag = cannot_be_vassal_or_liege }
		top_liege = this # You have to be independent - This check exists to prevent a lot of edge-cases where you can change liege
		is_confederation_member = no
	}

	ai_targets = {
		ai_recipients = neighboring_rulers_including_tributary_borders
		max = 5
	}

	ai_targets = {
		ai_recipients = neighboring_top_overlords_connected_by_land
	}

	# this might appear fairly frequent but is necessary in order to ensure AI can respond to sudden threats on their borders
	ai_frequency_by_tier = {
		barony = 0
		county = 6
		duchy = 6
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	force_notification = yes

	ai_will_do = {
		base = -50
		#MINOR MODIFIERS
		ai_military_threat_modifier_with_cbs = {
			SENDER = scope:actor
			RECEIVER = scope:recipient
			MULTIPLIER = 1
		}
		#Obedience
		modifier = {
			is_obedient_to = scope:recipient
			add = 40
			desc = obedient_interaction_reason
		}
		# Rivalry modifier
		modifier = {
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:actor = {
					has_relation_rival = scope:recipient
					NOT = { has_relation_nemesis = scope:recipient }
				}
			}
			add = -10
		}
		# Nemesis modifier
		modifier = {
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:actor = {
					has_relation_nemesis = scope:recipient
				}
			}
			add = -100
		}
		# Different faith, no pluralism
		modifier = { 
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Of two different faiths AND the potential vassal's faith is not pluralistic.
						faith = scope:recipient.faith
						faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
				}
			}
			add = {
				value = -25
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_evil_level
							}
						}
					}
					add = -25
				}
			}
		}
		# Cultural Acceptance
		modifier = { 
			scope:actor = {
				NOT = { # cultural condition below doesn't have to apply if both actor and recipient have nomadic_philosophy
					has_trait = nomadic_philosophy
					scope:recipient = { has_trait = nomadic_philosophy }
				}
				NOT = { has_same_culture_as = scope:recipient }
				culture = {
					cultural_acceptance = { target = scope:recipient.culture value < 50 }
				}
			}
			add = {
				add = -10
				if = {
					limit = { scope:actor.culture = { has_cultural_pillar = ethos_bellicose } }
					add = -10
				}
			}
			desc = cultural_acceptance_interaction_reason
		}
		# Same language
		modifier = { 
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}

		### MANDALA ###
		#Added threshold for Mandalas who already are Tributaries
		modifier = {
			scope:recipient = { is_tributary = yes }
			NOT = { scope:recipient.suzerain = scope:actor }
			scope:recipient.suzerain = { primary_title.tier = tier_duchy }
			add = -25
			desc = already_tributary_threshold
		}
		modifier = {
			scope:recipient = { is_tributary = yes }
			NOT = { scope:recipient.suzerain = scope:actor }
			scope:recipient.suzerain = { primary_title.tier = tier_kingdom }
			add = -50
			desc = already_tributary_threshold
		}
		modifier = {
			scope:recipient = { is_tributary = yes }
			NOT = { scope:recipient.suzerain = scope:actor }
			scope:recipient.suzerain = { primary_title.tier >= tier_empire }
			add = -75
			desc = already_tributary_threshold
		}
		#A devaraja should never willingly _offer_ to become a tributary
		modifier = {
			scope:actor = {
				government_has_flag = government_is_mandala
				OR = {
					has_unruined_mandala_capital_trigger = yes
					has_mandala_aspect_trigger = yes
					has_variable = mandala_godking
				}
			}
			add = -1000
		}
		#I am a Tribal! ... and you're a Mandala
		modifier = {
			scope:actor = { government_has_flag = government_is_tribal }
			scope:recipient = { government_has_flag = government_is_mandala }
			add = 30
			desc = actor_is_a_tribal_government
		}
		#Mandala Piety Level - this is only checked if you are not a Devaraja/haven't got a capital temple complex - Otherwise we use Radiance
		mandala_devaraja_piety_level_add_weight_modifier = { DEVARAJA = scope:recipient }
		#Recipient Radiance - Radiance Value x2
		modifier = {
			scope:recipient = { has_unruined_mandala_capital_trigger = yes }
			add = {
				value = scope:recipient.mandala_radiance_value
				multiply = 2
			}
			desc = recipient_positive_mandala_radiance
		}
		#Tributary Realm Size
		subject_realm_size_lose_weight_modifier = {
			DEVARAJA = scope:actor
			SUBJECT = scope:recipient
		}
		#Devaraja Mandala Capital
		mandala_devaraja_capital_add_weight_modifier = {
			DEVARAJA = scope:actor
			TRIBUTARY = scope:recipient
		}
		#Are they independent but a neighboring Mandala more Radiant than you?
		#We reduce acceptance by the radiance difference x2
		modifier = {
			trigger_if = {
				limit = {
					scope:recipient = { has_unruined_mandala_capital_trigger = yes }
					scope:actor = {
						is_tributary = no
						OR = {
							government_has_flag = government_is_mandala
							government_has_flag = government_is_tribal
						}
					}
				}
				scope:recipient = {
					OR = {
						any_neighboring_top_liege_realm_owner = {
							has_unruined_mandala_capital_trigger = yes
							government_has_flag = government_is_mandala
							NOR = { 
								this = scope:recipient
								this = scope:actor
							}
							save_temporary_scope_as = suzerain_comparison
						}
						any_neighboring_top_suzerain_realm_owner = {
							has_unruined_mandala_capital_trigger = yes
							government_has_flag = government_is_mandala
							NOR = { 
								this = scope:recipient
								this = scope:actor
							}
							save_temporary_scope_as = suzerain_comparison
						}
					}
				}	
				always = yes
			}
			trigger_else = { always = no }
			add = {
				#Double it as we would with your own radiance impact above and reduce acceptance by that value
				value = {
					value = scope:suzerain_comparison.mandala_radiance_value
					multiply = 2
				}
				multiply = -1
			}
			desc = other_devaraja_radiance
		}
		#Prosperity Decree
		modifier = {
			desc = is_prosperity_mandala_tributary
			scope:actor = {
				is_tributary = yes
				suzerain = { has_realm_law_flag = tributaries_less_likely_to_break_free }
			}
			add = 15
		}
		#SEA legacy
		modifier = {
			desc = tgp_sea_legacy_2_modifier_desc
			scope:recipient = {
				dynasty ?= {
					has_dynasty_perk = tgp_sea_legacy_2
				}
			}
			add = tgp_sea_legacy_tributary_acceptance_value
		}
		# I am higher rank than you
		modifier = { 
			desc = tributary_interaction_aibehavior_recipient_tier_tt
			trigger = {
				scope:actor = {
					highest_held_title_tier > scope:recipient.highest_held_title_tier
				}
			}
			add = {
				value = scope:actor.highest_held_title_tier
				subtract = scope:recipient.highest_held_title_tier 
				multiply = 50
				multiply = -1
			}
		}
		# Same Faith and Actor is a god King
		modifier = { 
			desc = embrace_as_tributary_interaction_same_faith
			scope:recipient = {
				faith = scope:actor.faith
				has_unruined_mandala_capital_trigger = yes
			}
			add = {
				value = 10
			}
		}
		# Different faith, no pluralism.
		modifier = { 
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:recipient = {
					faith = {
						NOR = { # Of two different faiths AND the potential tributary's faith is not pluralistic
							this = scope:actor.faith
							has_doctrine = doctrine_pluralism_pluralistic
						}
					}
				}
			}
			add = {
				value = -25
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -25
				}
			}
		}
		# Different religion Family - We prefer god kings to be vaguely within our own world view
		modifier = { 
			desc = embrace_as_tributary_interaction_other_religion_family
			scope:actor = { 	
				NOT = { government_has_flag = government_is_wanua }
			}
			scope:recipient.faith.religion = {
				switch = {
					trigger = is_in_family
					rf_pagan = {
						scope:actor.faith.religion = { NOT = { is_in_family = rf_pagan } }
					}
					rf_sinitic = {
						scope:actor.faith.religion = { NOT = { is_in_family = rf_sinitic } }
					}
					rf_eastern = {
						scope:actor.faith.religion = { NOT = { is_in_family = rf_eastern } }
					}
					rf_abrahamic = {
						scope:actor.faith.religion = { NOT = { is_in_family = rf_abrahamic } }
					}
				}
			}
			add = -25
		}
		# They are not Mandalas nor Tribes
		modifier = {
			trigger = {
				scope:recipient = {
					NOR = {
						government_has_flag = government_is_mandala
						government_has_flag = government_is_tribal
					}
				}
			}
			add = {
				value = -50
				#Would cause a lot of issues
				if = {
					limit = {
						scope:recipient = {
							OR = {
								government_allows = administrative
								government_is_japanese_trigger = yes
								government_has_flag = government_is_nomadic
							}
						}
					}
					subtract = 950 #Some governments are especially unlikely to agree
				}
				#Not radiant enough
				if = {
					limit = {
						scope:recipient = {
							government_has_flag = government_is_mandala
							has_unruined_mandala_capital_trigger = yes
							mandala_radiance_value <= 40
						}
					}
					subtract = 100
				}
			}
		}
		#Far away
		modifier = { 
			desc = offer_vassalization_interaction_aibehavior_remoterealm_tt
			trigger = {
				scope:recipient = {
					NOT = {
						any_land_neighboring_realm_with_tributaries_owner = {
							this = scope:actor
						}
					}
				}
				trigger_if = { #Islands we can get farther away
					limit = {
						scope:actor.capital_county = { is_coastal_county = yes }
						any_sub_realm_county = { is_coastal_county = yes }
					}
					scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value >= squared_distance_huge } }
				}
				trigger_else = { #Inland is harder
					scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value >= squared_distance_major } }
				}
			}
			add = -250
		}
		#Legitimacy
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -15
				scope:recipient = {
					has_legitimacy_flag = slightly_reduced_tributarization_acceptance
				}
			}
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -25
				scope:recipient = {
					has_legitimacy_flag = reduced_tributarization_acceptance
				}
			}
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -50
				scope:recipient = {
					has_legitimacy_flag = very_reduced_tributarization_acceptance
				}
			}
			modifier = {
				desc = "LOW_LEGITIMACY_REASON"
				add = -75
				scope:recipient = {
					has_legitimacy_flag = massively_reduced_tributarization_acceptance
				}
			}
		# HIGH LEGITIMACY
			modifier = {
				desc = "HIGH_LEGITIMACY_REASON"
				add = 25
				scope:recipient = {
					has_legitimacy_flag = increased_tributarization_acceptance
				}
			}
			modifier = {
				desc = "HIGH_LEGITIMACY_REASON"
				add = 50
				scope:recipient = {
					has_legitimacy_flag = very_increased_tributarization_acceptance
				}
			}
			modifier = {
				desc = "HIGH_LEGITIMACY_REASON"
				add = 75
				scope:recipient = {
					has_legitimacy_flag = extra_increased_tributarization_acceptance
				}
			}
		# OPINION INFLUENCE
		opinion_modifier = { # Compare Opinion modifier.
			who = scope:actor
			opinion_target = scope:recipient
			multiplier = 1
		}
	}

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	auto_accept = { scope:recipient = { highest_held_title_tier >= tier_hegemony } } # Hegemons always "accepts", but this only opens the Tribute Mission UI

	ai_accept = {
		base = 50

		modifier = {
			desc = interaction_is_nomadic
			scope:recipient = {
				government_has_flag = government_is_nomadic
			}
			add = 100
		}

		modifier = {  # Can't flee the conqueror this way
			add = -1000
			desc = NO_FRIVOLOUS_ACTIVITIES_REASON
			scope:actor = { has_variable = conqueror }
		}

		modifier = { # Wide difference in rank
			desc = offer_vassalization_interaction_aibehavior_widetitletier_tt
			trigger = {
				scope:actor = {
					tier_difference = {
						target = scope:recipient
						value > 1
					}
				}
			}
			add = 20
		}
		modifier = { # Distant Realm.
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
				}
				scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value < squared_distance_major } }
			}
			add = -15
		}
		modifier = { # Remote Realm.
			desc = offer_vassalization_interaction_aibehavior_remoterealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
				}
				scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value >= squared_distance_major } }
			}
			add = -25
		}

		# MINOR
			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 = -10
			}
			modifier = { # Nemesis modifier.
				desc = offer_vassalization_interaction_aibehavior_nemesis_tt
				trigger = {
					scope:recipient = {
						has_relation_nemesis = scope:actor
					}
				}
				add = -100
			}
			modifier = { # Same Dynasty modifier.
				desc = offer_vassalization_interaction_aibehavior_dynasty_tt
				trigger = {
					scope:recipient = {
						dynasty = scope:actor.dynasty
					}
				}
				add = 10
			}

		# PERSONALITY
		ai_value_modifier = {
			ai_greed = 0.75
			min = 0
		}

		# OPINION INFLUENCE
		opinion_modifier = { # Compare Opinion modifier.
			trigger = {
				NOT = { 
					scope:recipient = { government_has_flag = government_is_mandala }
				}
			}
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1
		}

		# CONTRACT OPTIONS
		modifier = {
			add = -25
			scope:low_obligations = yes
			desc = CONTRACT_LOW_TRIBUTARY_TAXES_REASON
		}
		modifier = {
			add = 25
			scope:high_obligations = yes
			desc = CONTRACT_HIGH_TRIBUTARY_TAXES_REASON
		}
	}
}

### Demand Tributary - bilateral
# actor = offerer / potential suzerain
# recipient = receiver / potential tributary

demand_tributary_interaction = {
	category = interaction_category_diplomacy
	common_interaction = yes
	icon = demand_tributary_interaction

	desc = demand_tributary_interaction_desc

	is_shown = {
		
		
		scope:recipient = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:actor = {
			NAND = {
				has_primary_title = title:e_nmih_tenno
				has_title = title:c_nmih_gosho
				realm_size = 1
			}
		}
		scope:actor = {
			NOT = {
				this = scope:recipient
				top_suzerain = scope:recipient.top_suzerain # ensures the actor and recipient is not already in the same "suzerain bloc"
			}
			can_get_tributaries_peacefully_trigger = yes

			highest_held_title_tier < tier_hegemony # hegemonies get tributaries from exacting tribute

			#Mandala Embraces; not Demand
			trigger_if = {
				limit = { 
					scope:actor = { government_has_flag = government_is_mandala }
				}
				always = no
			}
			trigger_else = { can_get_tributaries_peacefully_trigger = yes }
			#Should be neighboring to increase growth organically
			any_land_neighboring_realm_with_tributaries_owner = {
				this = scope:recipient
			}
			trigger_if = {
				limit = {
					is_ai = yes
				}
				current_military_strength >= scope:recipient.one_and_a_half_times_current_military_strength
				primary_title.tier >= scope:recipient.primary_title.tier
			}
		}
		scope:recipient = {
			highest_held_title_tier >= tier_county
			is_independent_ruler = yes # target cannot be a vassal
			NOR = {
				government_has_flag = cannot_be_vassal_or_liege
				government_has_flag = government_is_mandala
			}
		}
		# Temujin cannot make Jamukha his subject once he leaves him
		NOT = {
			scope:actor = {
				has_variable = had_mpo_temujin_flavor_0010
				var:had_mpo_temujin_flavor_0010 ?= scope:recipient
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = { has_truce = scope:actor }
			is_physically_able = yes
			is_travelling = no
			NOT = { exists = involved_activity }
		}
		scope:recipient = {
			is_tributary = no
			is_at_war = no
			custom_tooltip = {
				text = demand_tributary_interaction_cooldown_active_tt
				NOT = {
					has_opinion_modifier = {
						modifier = tributary_demanded_opinion
						target = scope:actor
					}
				}
			}
			is_confederation_member = no
		}
		scope:actor = {
			custom_tooltip = {
				text = mpo_interaction_not_neighbouring_tt
				any_land_neighboring_realm_with_tributaries_owner = { 
					this = scope:recipient
				}
			}
		}
	}

	cost = {
		prestige = minor_prestige_value
	}

	greeting = positive
	notification_text = DEMAND_TRIBUTARY_INTERACTION_NOTIFICATION

	on_accept = {
		start_tributary_interaction_effect = {
			TRIBUTARY = scope:recipient
			SUZERAIN = scope:actor
		}
		scope:actor = {
			trigger_event = char_interaction.0362
		}
		scope:recipient = {
			add_opinion = {
				modifier = tributary_demanded_opinion # this opinion also acts as a built-in cooldown
				target = scope:actor
			}
		}
		consume_all_criminal_reasons_effect = {
			LIEGE = scope:actor
			CRIMINAL = scope:recipient
		}
	}

	on_decline = {
		scope:recipient = {
			add_opinion = {
				modifier = tributary_demanded_opinion # this opinion also acts as a built-in cooldown
				target = scope:actor
			}
			custom_tooltip = demand_tributary_interaction_cooldown_tt
		}
		scope:actor = {
			trigger_event = char_interaction.0363
			if = {
				limit = { highest_held_title_tier >= tier_hegemony }
				add_legitimacy = -50
			}
		}
	}

	ai_maybe = yes

	ai_potential = {
		highest_held_title_tier > 1 # at least a count-level ruler
		is_independent_ruler = yes

		# Hegemonic Tributary AIs never proactively demand tributaries, they wait for offers instead
		NOT = { highest_held_title_tier >= tier_hegemony }
	}

	ai_targets = {
		ai_recipients = neighboring_rulers_including_tributary_borders
		max = 5
	}
	
	ai_frequency_by_tier = {
		barony = 0
		county = 12
		duchy = 4
		kingdom = 4
		empire = 4
		hegemony = 4
	}

	force_notification = yes

	ai_will_do = {	# AI will often do this to valid targets that aren't a military threat to them, especially if they're rich
		base = 0

		modifier = {
			add = {
				add = scope:recipient.gold
				divide = 10
				max = 100
			}
			desc = accumulated_wealth_reason
		}

		ai_military_threat_modifier_with_cbs = {
			SENDER = scope:actor
			RECEIVER = scope:recipient
			MULTIPLIER = -1
		}

		modifier = {
			scope:recipient = { is_obedient_to = scope:actor }
			add = 40
			desc = obedient_interaction_reason
		}

		modifier = { # Generally don't try to tributarize those of higher rank than you
			trigger = {
				"scope:recipient.tier_difference(scope:actor)" > 1
			}
			add = -20
		}

		modifier = { # Generally don't try to tributarize those of higher dominance than you
			trigger = {
				scope:recipient.dominance_value > scope:actor.dominance_value
			}
			add = -30
		}

		modifier = { # Remote Realm.
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
				}
				scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value >= squared_distance_major } }
			}
			add = -25
		}

		modifier = {
			trigger = {
				scope:recipient = { government_has_flag = government_is_herder }
			}
			add = 1000
		}
	}

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	auto_accept = {
		custom_tooltip = {
			text = scheme_agent_aptitude.is_herder
			scope:recipient = { government_has_flag = government_is_herder }
		}
	}

	ai_accept = {
		base = -60

		modifier = { # Hegemonic Tributaries are gentler and kinder
			trigger = {
				scope:actor = { highest_held_title_tier >= tier_hegemony }
			}
			add = 100
			desc = tributary_interaction_aibehavior_actor_hegemon_tier_tt
		}

		modifier = { # Special case for Confucian-style governments towards China
			 scope:actor = {
				primary_title = title:h_china
			 }
			government_has_flag = government_is_meritocratic
			add = 25
			desc = tributary_interaction_aibehavior_recipient_confucian_government_tt
		}

		modifier = { # Perk boost
			desc = offer_vassalization_true_ruler_perk_tt
			trigger = {
				scope:actor = { has_perk = true_ruler_perk }
			}
			add = true_ruler_value
		}

		#Yurt bonuses
		modifier = {
			desc = tributary_yurt_02_domicile_building
			trigger = {
				scope:actor.domicile ?= { has_domicile_parameter = nomad_yurt_increased_tributary_acceptance_lvl_1 }
			}
			add = 5
		}

		modifier = {
			desc = tributary_yurt_02_domicile_building
			trigger = {
				scope:actor.domicile ?= { has_domicile_parameter = nomad_yurt_increased_tributary_acceptance_lvl_2 }
			}
			add = 10
		}

		modifier = {
			desc = tributary_yurt_02_domicile_building
			trigger = {
				scope:actor.domicile ?= { has_domicile_parameter = nomad_yurt_increased_tributary_acceptance_lvl_3 }
			}
			add = 15
		}

		modifier = { # the bolder they are, the less likely they will agree to this and vice versa
			NOT = { ai_boldness = 0 }
			add = {
				value = ai_boldness
				multiply = -1
				divide = 2
			}
			desc = TRIBUTARY_BOLDNESS_REASON
		}

		modifier = { # the greedier they are, the less likely they will agree to this
			ai_greed > 0
			add = {
				value = ai_greed
				multiply = -1
				divide = 4
			}
			desc = TRIBUTARY_GREED_REASON
		}

		modifier = {
			is_obedient_to = scope:actor
			add = 40
			desc = obedient_interaction_reason
		}

		modifier = {
			scope:actor = { is_gurkhan = yes }
			scope:recipient = { government_has_flag = government_is_nomadic }
			add = 20
			desc = gurkhan_interaction_reason
		}

		# Easier to make Tributaries during the Zud season
		modifier = {
			any_character_situation = {
				any_situation_sub_region = {
					has_sub_region_phase_parameter = the_great_steppe_easier_tributaries
					any_situation_sub_region_participant_group = {
						participant_group_type = nomad_rulers_capital
						participant_group_has_character = scope:actor
					}
				}
			}
			scope:recipient = { government_has_flag = government_is_nomadic }
			add = 25
			desc = zud_season_reason
		}

  		# if the actor is a major threat to the recipient they're more likely to accept
		ai_military_threat_modifier_with_cbs = {
			SENDER = scope:recipient
			RECEIVER = scope:actor
			MULTIPLIER = 1
		}

		modifier = { # They are a King
			desc = tributary_interaction_aibehavior_recipient_tier_tt
			trigger = {
				scope:recipient = { highest_held_title_tier = tier_kingdom }
			}
			add = -100
		}

		modifier = { # They are an Emperor or greater
			desc = tributary_interaction_aibehavior_recipient_tier_tt
			trigger = {
				scope:recipient = { highest_held_title_tier >= tier_empire }
			}
			add = -200
		}

		modifier = { # Recipient has higher Dominance than the actor
			desc = demand_tributary_interaction_aibehavior_dominance_tt
			trigger = {
				scope:actor = { government_has_flag = government_is_nomadic }
				scope:recipient = { government_has_flag = government_is_nomadic }
				scope:recipient.dominance_value > scope:actor.dominance_value
			}
			add = -20
		}

		modifier = { # Actor has higher Dominance than the recipient
			desc = demand_tributary_interaction_aibehavior_dominance_tt
			trigger = {
				scope:actor = { government_has_flag = government_is_nomadic }
				scope:recipient = { government_has_flag = government_is_nomadic }
				scope:actor.dominance_value > scope:recipient.dominance_value
			}
			add = 20
		}

		modifier = { # Actor is a Meritocratic Khanate trying to tributarize a Nomad
			desc = demand_tributary_interaction_steppe_admin
			trigger = {
				scope:actor = { government_has_flag = government_is_steppe_admin }
				scope:recipient = { government_has_flag = government_is_nomadic }
			}
			add = 60 # This offsets base reluctance
		}

		# Non-nomadic
		modifier = {
			desc = AI_FILTHY_HORSE_LORD_REASON
			trigger = {
				scope:actor = { government_has_flag = government_is_nomadic }
				scope:recipient = {
					NOT = { government_has_flag = government_is_nomadic }
				}
			}
			add = {
				value = -50
				if = {
					limit = {
						scope:recipient = { government_has_flag = government_is_tribal }
					}
					multiply = 0.5
				}
			}
		}

		# MINOR
		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 = -200
		}
		modifier = { # Same Dynasty modifier.
			desc = offer_vassalization_interaction_aibehavior_dynasty_tt
			trigger = {
				scope:recipient = {
					dynasty = scope:actor.dynasty
				}
			}
			add = 10
		}
		modifier = { # Different faith, no pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOT = { # faith condition below doesn't have to apply if both actor and recipient have nomadic_philosophy
						has_trait = nomadic_philosophy
						scope:recipient = { has_trait = nomadic_philosophy }
					}
					faith = {
						NOR = { # Of two different faiths AND the potential vassal's faith is not pluralistic
							this = scope:recipient.faith
							has_doctrine = doctrine_pluralism_pluralistic
						}
					}
				}
			}
			add = {
				value = -25
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_evil_level
							}
						}
					}
					add = -25
				}
			}
		}

		modifier = { # Encircled
			desc = offer_vassalization_interaction_aibehavior_encircled_tt
			trigger = {
				scope:recipient = {
					NOT = {
						any_neighboring_top_suzerain_realm_owner = {
							this != scope:actor
						}
					}
					NOT = {
						any_realm_county = { is_coastal_county = yes }
					}
				}
			}
			add = 30
		}

		modifier = { # Cultural Acceptance
			scope:actor = {
				NOT = { # cultural condition below doesn't have to apply if both actor and recipient have nomadic_philosophy
					has_trait = nomadic_philosophy
					scope:recipient = { has_trait = nomadic_philosophy }
				}
				NOT = { has_same_culture_as = scope:recipient }
				culture = {
					cultural_acceptance = { target = scope:recipient.culture value < 50 }
				}
			}
			add = {
				add = -10
				if = {
					limit = { scope:actor.culture = { has_cultural_pillar = ethos_bellicose } }
					add = -10
				}
			}
			desc = cultural_acceptance_interaction_reason
		}

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

		#Legitimacy
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -15
			scope:actor = {
				has_legitimacy_flag = slightly_reduced_tributarization_acceptance
			}
		}
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -25
			scope:actor = {
				has_legitimacy_flag = reduced_tributarization_acceptance
			}
		}
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -50
			scope:actor = {
				has_legitimacy_flag = very_reduced_tributarization_acceptance
			}
		}
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -75
			scope:actor = {
				has_legitimacy_flag = massively_reduced_tributarization_acceptance
			}
		}

		# HIGH LEGITIMACY
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			add = 25
			scope:actor = {
				has_legitimacy_flag = increased_tributarization_acceptance
			}
		}
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			add = 50
			scope:actor = {
				has_legitimacy_flag = very_increased_tributarization_acceptance
			}
		}
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			add = 75
			scope:actor = {
				has_legitimacy_flag = extra_increased_tributarization_acceptance
			}
		}

		# OPINION INFLUENCE
		opinion_modifier = { # Compare Opinion modifier.
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1
		}

		#Severed head acceptance
		modifier = {
			add = 200
			scope:actor = {
				has_variable = severed_head_vassalization
				var:severed_head_vassalization = {
					this = scope:recipient
				}
			}
		}
	}
}


