﻿#Interactions relating to tributary relationship management

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

become_tributary_interaction = {
	category = interaction_category_diplomacy
	common_interaction = no
	icon = become_tributary_interaction

	desc = become_tributary_interaction_desc

	is_shown = {
		scope:actor = {
			NOT = { government_has_flag = cannot_be_vassal_or_liege }
			is_independent_ruler = yes # You have to be independent - This check exists to prevent a lot of edge-cases where you can change liege
			is_tributary = no
			highest_held_title_tier >= tier_county
			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 = {
			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
			NOT = { 
				this = scope:actor
				top_suzerain = scope:actor
			}
			can_have_tributaries_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_physically_able = yes
			is_travelling = no
			NOT = { exists = involved_activity }
			is_confederation_member = no
			is_at_war = no
		}
	}

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

	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0361
		}
	}
	
	ai_potential = {
		highest_held_title_tier >= tier_county
		is_independent_ruler = yes
	}

	ai_targets = {
		ai_recipients = neighboring_rulers_including_tributary_borders
	}

	ai_targets = {
		ai_recipients = neighboring_top_overlords_connected_by_land
	}

	ai_frequency = 6 # this might appear fairly frequent but is necessary in order to ensure AI can respond to sudden threats on their borders

	force_notification = yes

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

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

		modifier = { # Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:actor = {
					has_relation_rival = scope:recipient
					NOT = { has_relation_nemesis = scope:recipient }
				}
			}
			add = -10
		}
		modifier = { # Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:actor = {
					has_relation_nemesis = scope:recipient
				}
			}
			add = -30
		}
		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_amkingtier_tt
			trigger = {
				highest_held_title_tier >= tier_kingdom
			}
			add = -20
		}

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

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	ai_accept = {
		base = -50

		modifier = {
			desc = interaction_is_nomadic
			scope:recipient = {
				government_has_flag = government_is_nomadic
			}
			add = 100
		}
		
		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 < 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 }
					}
				}
				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 = -30
		}
		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.
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1
		}

		# CONTRACT OPTIONS
		modifier = {
			add = -25
			scope:low_obligations = yes
			desc = CONTRACT_LOW_TAXES_REASON
		}
		modifier = {
			add = 25
			scope:high_obligations = yes
			desc = CONTRACT_HIGH_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: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
			
			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
			NOT = { government_has_flag = cannot_be_vassal_or_liege }
		}
		# 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:actor = {
			trigger_event = char_interaction.0363
		}
		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
		}
	}
	
	ai_maybe = yes

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

	ai_targets = {
		ai_recipients = neighboring_rulers_including_tributary_borders
		max = 5
	}

	ai_frequency = 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 >= 200000 } }
			}
			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 = { # 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 = demand_tributary_interaction_aibehavior_hightier_tt
			trigger = {
				scope:recipient = { highest_held_title_tier = tier_kingdom }
			}
			add = -100
		}

		modifier = { # They are an Emperor or greater
			desc = demand_tributary_interaction_aibehavior_hightier_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: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:recipient = { government_has_flag = government_is_nomadic }
				scope:actor.dominance_value > scope:recipient.dominance_value
			}
			add = 20
		}
		
		# Legitimacy
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			scope:actor = {
				has_legitimacy_flag = very_reduced_tributarization_acceptance
			}
			add = -25
		}
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			scope:actor = {
				has_legitimacy_flag = reduced_tributarization_acceptance
			}
			add = -10
		}
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			scope:actor = {
				has_legitimacy_flag = increased_tributarization_acceptance
			}
			add = 10
		}
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			scope:actor = {
				has_legitimacy_flag = very_increased_tributarization_acceptance
			}
			add = 25
		}

		# 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 = {
							NOT = {
								this = scope:actor
							}
						}
					}
					NOT = {
						any_realm_county = {
							is_coastal_county = yes
						}
					}
				}
			}
			add = 30
		}

		modifier = { # Cultural Acceptance
			add = -5
			desc = cultural_acceptance_interaction_reason
			trigger = {
				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 }
					}
				}
			}
		}

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

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



### Cease Paying Tribute - unilateral
### Name referenced in code! Don't change it without an adult present!
# actor = tributary
# recipient = suzerain

cease_paying_tribute_interaction = {
	category = interaction_category_diplomacy
	common_interaction = yes
	use_diplomatic_range = no
	icon = cease_paying_tributary_interaction

	desc = cease_paying_tribute_interaction_desc

	is_shown = {
		scope:actor = {
			this != scope:recipient
			suzerain = scope:recipient
			subject_can_break_tributary = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_physically_able = yes
			is_travelling = no
			NOT = { exists = involved_activity }
			trigger_if = {
				limit = {
					OR = {
						any_land_neighboring_realm_with_tributaries_owner = {
							this = scope:recipient
						}
						scope:recipient = {
							is_landed = no
						}
					}
				}
				NOT = { has_truce = scope:recipient }
			}
		}
	}

	cost = {
		prestige = {
			value = 0
			if = {
				limit = {
					scope:actor = {
						OR = {
							any_land_neighboring_realm_with_tributaries_owner = {
								this = scope:recipient
							}
							scope:recipient = {
								is_landed = no
							}
						}
					}
				}
				add = minor_prestige_value
			}
		}
	}

	auto_accept = yes
	on_accept = {
		scope:actor = {
			end_tributary = yes
		}
		scope:recipient = {
			if = {
				limit = { is_ai = yes }
				trigger_event = {
					id = char_interaction.0370
					days = 14 # we delay the response from the AI for 2 weeks to make it feel more like a "diplomacy response"
				}
			}
			else = {
				trigger_event = char_interaction.0370
			}
			add_opinion = {
				modifier = tributary_ceased_payments_opinion
				target = scope:actor
			}
		}
	}

	ai_potential = {
		is_at_war = no
		is_migrating = no
		suzerain ?= {
			is_migrating = no

			OR = {
				is_landed = no
				NOT = { # disconnected tributaries can always do this, even herders
					any_land_neighboring_realm_with_tributaries_owner = {
						this = root
					}
				}
				AND = {
					NOT = { root = { government_has_flag = government_is_herder } }
					trigger_if = { # Obedience is a hard blocker, but only if suzerain is landed
						limit = { 
							is_landed = yes
						}
						root = { is_obedient = no }
					}
				}
			}
		}
	}

	ai_targets = {
		ai_recipients = suzerain
	}

	ai_frequency = 12 # this must be 12 (1 year) in order to ensure the integrity of the UI-visualized chance the tributary will break the contract

	# visualized in the UI as the annual chance the tributary will break the contract, based on a percentage chance per year
	ai_will_do = { 
		base = -25

		modifier = {
			add = {
				add = obedience_value
				subtract = obedience_threshold
				multiply = -1
				max = obedience_threshold
				min = {
					value = obedience_threshold
					multiply = -1
				}
			}
			desc = obedience_value_reason
		}

		modifier = {
			scope:recipient = {
				has_variable = temp_tributary_protection
			}
			add = -150
			desc = temp_tributary_protection_reason
		}

		modifier = {
			dominance_value > suzerain.dominance_value
			add = 30
			desc = cease_tribute_higher_dominance_reason
		}

		modifier = {
			suzerain = { 
				any_memory = { 
					has_memory_type = nomad_showed_weakness_in_war
					memory_age_years < 5
				}
			}
			add = 30
			desc = cease_tribute_showed_weakness_in_war_reason
		}

		modifier = {
			any_memory = { 
				has_memory_type = suzerain_defended_me_in_war
				has_memory_participant = root.suzerain
				memory_age_years < 10
			}
			add = -100
			desc = cease_tribute_defended_me_in_war_reason
		}

		modifier = {
			suzerain = { 
				any_memory = { 
					has_memory_type = had_chaotic_kurultai_succession
					memory_age_years < 5
				}
			}
			add = 30
			desc = cease_tribute_had_chaotic_kurultai_succession_reason
		}

		# if the actor is sufficiently scared of the recipient they're way less likely to do this
		ai_military_threat_modifier = {  
			SENDER = scope:actor
			RECEIVER = scope:recipient
			MULTIPLIER = -2.5
		}

		modifier = {
			scope:actor = {
				is_migrating = no
			}
			scope:recipient = {
				NOT = { 
					any_land_neighboring_realm_with_tributaries_owner = {
						this = scope:actor
					}
				}
			}
			add = 1000
			desc = cease_tribute_disconnected_suzerain
		}

		modifier = {
			scope:recipient = {
				is_landed = no
				is_migrating = no
				is_at_war = no
			}
			add = 10000
			desc = cease_tribute_landless_suzerain
		}
	}
}

### Release Tributary - unilateral
# actor = suzerain
# recipient = tributary

release_tributary_interaction = {
	category = interaction_category_diplomacy
	common_interaction = no
	icon = release_tributary_interaction

	desc = release_tributary_interaction_desc

	is_shown = {
		scope:recipient = {
			this != scope:actor
			suzerain = scope:actor
			OR = { # AI should only ever consider releasing unruly subjects
				scope:actor = { is_ai = no }
				NOT = { is_obedient_to = scope:actor }
			}
		}
	}

	is_valid_showing_failures_only = {}

	cost = {
		prestige = minor_prestige_value
	}

	auto_accept = yes
	on_accept = {
		add_truce_one_way = {
			character = scope:recipient
			years = 5
			name = TRUCE_TRIBUTARY_RELEASED
		}
		scope:recipient = {
			end_tributary = yes
			save_scope_as = tributary_loc
			scope:actor = { save_scope_as = suzerain_loc }
			add_truce_both_ways = {
				character = scope:actor
				years = 5
				name = TRUCE_TRIBUTARY_STOPPED
			}
			add_opinion = {
                target = scope:actor
                modifier = tributary_released_opinion
                opinion = 25
            }
			trigger_event = char_interaction.0380
		}
		scope:actor = {
			#TODO_CD_MPO some sort of message here
		}
	}
}

### Release as Tributary - unilateral
# actor = suzerain
# recipient = tributary

release_as_tributary_interaction = {
	category = interaction_category_vassal
	common_interaction = no
	icon = release_as_tributary
	interface_priority = 4

	desc = release_as_tributary_interaction_desc

	is_shown = {
		scope:actor = {
			government_has_flag = government_is_nomadic
		}
		scope:recipient = {
			is_vassal_of = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_independent_ruler = yes
			is_at_war = no
		}
	}

	auto_accept = yes
	
	on_accept = {
		scope:actor = {
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = release_as_tributary_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					custom_tooltip = release_as_tributary_interaction_toast_desc
				}
			}
		}
		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = granted_independence_opinion
				opinion = 10
			}
			create_title_and_vassal_change = {
				type = independency
				save_scope_as = change
				add_claim_on_loss = yes
			}
			becomes_independent = {
				change = scope:change
			}

			resolve_title_and_vassal_change = scope:change
		}
		start_tributary_interaction_effect = {
			SUZERAIN = scope:actor
			TRIBUTARY = scope:recipient
		}
	}

	ai_potential = {
		government_has_flag = government_is_nomadic
		this = top_liege
		vassal_count > vassal_limit
	}

	ai_targets = {
		ai_recipients = vassals
	}

	ai_frequency = 12

	ai_will_do = {
		base = 0
		modifier = {
			scope:recipient = { # Only on your borders
				any_held_title = {
					tier = tier_county
					any_neighboring_county = {
						OR = {
							is_coastal_county = yes
							holder.top_liege != scope:recipient.top_liege
						}
					}
				}
			}
			add = 100
		}
	}
}

# Offer Courtier
offer_courtier_interaction = {
	category = interaction_category_diplomacy
	common_interaction = no
	icon = courtier_interaction
	interface_priority = 40

	desc = offer_courtier_interaction_desc

	ai_targets = {
		ai_recipients = suzerain
		ai_recipients = liege
		ai_recipients = scripted_relations
		max = 5
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 36

	greeting = positive
	notification_text = OFFER_COURTIER_NOTIFICATION

	needs_recipient_to_open = yes

	populate_actor_list = {
		scope:actor = {
			every_courtier = {
				limit = {
					is_available_healthy_ai_adult = yes
					NOR = {
						is_consort_of = scope:actor
						is_heir_of = scope:actor
						AND = {
							is_female = yes
							patrilinear_marriage = yes
						}
						AND = {
							is_male = yes
							matrilinear_marriage = yes
						}
						is_diarch = yes
						is_designated_diarch = yes
						has_character_flag = has_been_offered_as_concubine
					}
				}
				add_to_list = characters
			}
		}
	}

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient = {
			is_ruler = yes
			NOT = { government_has_flag = government_is_herder }
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = offer_courtier_valid_courtier_tt
			scope:actor = {
				any_courtier = {
					is_available_healthy_ai_adult = yes
					NOR = {
						is_consort_of = scope:actor
						is_heir_of = scope:actor
						AND = {
							is_female = yes
							patrilinear_marriage = yes
						}
						AND = {
							is_male = yes
							matrilinear_marriage = yes
						}
					}
				}
			}
		}
	}

	can_be_picked = {
		is_adult = yes
	}

	can_send = {
		custom_tooltip = {
			text = no_heirs_can_be_sent_tt
			scope:secondary_actor = {
				NOT = {
					is_heir_of = scope:actor
				}
			}
		}
		custom_tooltip = {
			text = no_spouses_can_be_sent_tt
			scope:secondary_actor = {
				NOT = {
					is_consort_of = scope:actor
				}
			}
		}
	}

	auto_accept = no

	ai_accept = {
		base = -10
		
		modifier = {
			add = 100
			scope:secondary_actor = {
				OR = {
					sum_of_all_skills_value >= sum_of_all_skills_threshold_good
					martial >= monumentally_high_skill_rating
					prowess >= extremely_high_skill_rating
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_chancellor ?= { diplomacy < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_steward ?= { stewardship < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_spymaster ?= { intrigue < monumentally_high_skill_rating }
					}
					has_relation_lover = scope:recipient # Shhh, don't tell anyone, of course you're 'skilled'!
					trigger_if = {
						limit = {
							scope:recipient = {
								government_has_flag = government_is_nomadic
							}
						}
						OR = {
							AND = {
								sum_of_all_skills_value >= sum_of_all_skills_threshold_average
								scope:recipient = {
									any_courtier = {
										count < 10
									}
								}
							}
							aptitude:master_of_hunt_court_position >= 4
							aptitude:keeper_of_the_horses_court_position >= 4
							aptitude:boyan_court_position >= 4
							aptitude:siege_engineer_court_position >= 4
							aptitude:yurtchi_court_position >= 4
							aptitude:cherbi_court_position >= 4
							aptitude:yeke_jarquchi_court_position >= 4
							aptitude:foreign_emissary_court_position >= 4
						}
					}
				}
			}
			desc = AI_INTERESTING_COURTIER_REASON
		}
		
		modifier = {
			add = 100
			scope:secondary_actor.prowess >= decent_skill_rating
			scope:recipient.number_of_knights < scope:recipient.max_number_of_knights
			desc = AI_KNIGHT_REASON
		}
		
		modifier = {
			add = 100
			exists = scope:secondary_actor.inspiration
			desc = AI_INSPIRED_REASON
		}
		
		modifier = {
			add = 100
			scope:secondary_actor = {
				is_close_or_extended_family_of = scope:recipient
			}
			desc = AI_FAMILY_REASON
		}
		
		modifier = {
			add = 100
			scope:secondary_actor = {
				is_consort_of = scope:recipient
			}
			desc = AI_SPOUSE_REASON
		}
		
		modifier = {
			add = 100
			scope:secondary_actor = {
				has_relation_friend = scope:recipient
			}
			desc = AI_FRIEND_REASON
		}
		
		modifier = {
			add = -200
			scope:secondary_actor = {
				has_relation_rival = scope:recipient
			}
			desc = AI_RIVAL_REASON
		}
		
		modifier = {
			add = 100
			scope:recipient = {
				any_courtier = {
					is_consort_of = scope:secondary_actor
				}
			}
			desc = AI_SPOUSE_OF_COURTIER_REASON
		}
		
		modifier = {
			add = 100
			scope:recipient = {
				any_courtier = {
					count < 5
				}
			}
			desc = AI_LACK_COURTIERS_REASON
		}
	}

	ai_potential = {
		OR = {
			ai_greed <= 25
			is_obedient = yes
		}
		OR = {
			is_tributary = yes
			num_of_relation_friend > 0
			num_of_relation_lover > 0
		}
	}

	ai_will_do = {
		base = 0
		
		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
				}
			}
		}
		
		modifier = {
			add = 100
			scope:recipient = {
				is_tributary_of = scope:actor
				OR = {
					ai_greed <= -50
					is_obedient_to = scope:actor
					opinion = {
						target = scope:actor
						value >= 50
					}
				}
			}
		}
		
		modifier = {
			factor = 0
			scope:secondary_actor = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
				}
			}
		}
		
		modifier = {
			factor = 0
			scope:actor = {
				NOR = {
					government_has_flag = government_is_nomadic
					government_has_flag = government_is_herder
				}
			}
			scope:secondary_actor = {
				is_close_or_extended_family_of = scope:actor
			}
		}
		
		modifier = { # The AI only offers really good characters
			factor = 0
			scope:secondary_actor = {
				NOR = {
					sum_of_all_skills_value >= sum_of_all_skills_threshold_good
					martial >= monumentally_high_skill_rating
					prowess >= extremely_high_skill_rating
					exists = inspiration
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_chancellor ?= { diplomacy < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_steward ?= { stewardship < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_spymaster ?= { intrigue < monumentally_high_skill_rating }
					}
					trigger_if = {
						limit = {
							scope:recipient = {
								government_has_flag = government_is_nomadic
							}
						}
						OR = {
							AND = {
								sum_of_all_skills_value >= sum_of_all_skills_threshold_average
								scope:recipient = {
									any_courtier = {
										count < 10
									}
								}
							}
							aptitude:master_of_hunt_court_position >= 4
							aptitude:keeper_of_the_horses_court_position >= 4
							aptitude:boyan_court_position >= 4
							aptitude:siege_engineer_court_position >= 4
							aptitude:yurtchi_court_position >= 4
							aptitude:cherbi_court_position >= 4
							aptitude:yeke_jarquchi_court_position >= 4
							aptitude:foreign_emissary_court_position >= 4
						}
					}
				}
			}
		}
	}

	on_send = {
		scope:secondary_actor = { # to block the same character from being offered twice
			add_character_flag = {
				flag = has_been_offered_as_concubine
				days = 5
			}
		}
	}
	
	on_accept = {
		scope:secondary_actor = {
			add_opinion = {
				target = scope:recipient
				modifier = piqued_opinion
				opinion = 10
			}
		}
		scope:recipient = {
			add_courtier = scope:secondary_actor
			scope:secondary_actor = {
				every_consort = {
					limit = {
						is_courtier_of = scope:actor
					}
					scope:recipient = {
						add_courtier = prev
					}
				}
				every_child = {
					limit = {
						is_adult = no
						is_courtier_of = scope:recipient
					}
					scope:actor = {
						add_courtier = prev
					}
				}
			}
			add_opinion = {
				target = scope:actor
				modifier = grateful_opinion
				opinion = 10
			}
		}
	}

	on_decline = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = msg_courtier_offer_rejected_title
				right_icon = scope:recipient
				left_icon = scope:secondary_actor
				custom_tooltip = msg_courtier_offer_rejected
			}
		}
	}
}

# Demand Courtier
demand_courtier_interaction = {
	category = interaction_category_vassal
	common_interaction = yes
	icon = request_courtier_interaction
	interface_priority = 45

	desc = demand_courtier_interaction_desc

	ai_targets = {
		ai_recipients = tributaries
		ai_recipients = vassals
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 12
	cooldown_against_recipient = { years = 3 }

	greeting = positive
	notification_text = DEMAND_COURTIER_NOTIFICATION
	
	highlighted_reason = HIGHLIGHTED_SKILLED_COURTIER
	is_highlighted = {
		scope:recipient = {
			any_courtier = {
				is_available_healthy_ai_adult = yes
				NOR = {
					is_consort_of = scope:recipient
					is_heir_of = scope:recipient
					AND = {
						is_female = yes
						patrilinear_marriage = yes
					}
					AND = {
						is_male = yes
						matrilinear_marriage = yes
					}
					is_diarch = yes
					is_designated_diarch = yes
					has_character_flag = has_been_offered_as_concubine
				}
				OR = {
					sum_of_all_skills_value >= sum_of_all_skills_threshold_good
					martial >= monumentally_high_skill_rating
					prowess >= extremely_high_skill_rating
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_chancellor ?= { diplomacy < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_steward ?= { stewardship < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_spymaster ?= { intrigue < monumentally_high_skill_rating }
					}
					trigger_if = {
						limit = {
							scope:actor = {
								government_has_flag = government_is_nomadic
							}
						}
						OR = {
							aptitude:master_of_hunt_court_position >= 4
							aptitude:keeper_of_the_horses_court_position >= 4
							aptitude:boyan_court_position >= 4
							aptitude:siege_engineer_court_position >= 4
							aptitude:yurtchi_court_position >= 4
							aptitude:cherbi_court_position >= 4
							aptitude:yeke_jarquchi_court_position >= 4
							aptitude:foreign_emissary_court_position >= 4
						}
					}
				}
			}
		}
	}

	needs_recipient_to_open = yes

	populate_actor_list = {
		scope:recipient = {
			every_courtier = {
				limit = {
					is_available_healthy_ai_adult = yes
					NOR = {
						is_consort_of = scope:recipient
						is_heir_of = scope:recipient
						AND = {
							is_female = yes
							patrilinear_marriage = yes
						}
						AND = {
							is_male = yes
							matrilinear_marriage = yes
						}
						is_diarch = yes
						is_designated_diarch = yes
						has_character_flag = has_been_offered_as_concubine
					}
				}
				add_to_list = characters
			}
		}
	}

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient = {
			OR = {
				trigger_if = {
					limit = {
						scope:actor = {
							government_has_flag = government_is_nomadic
						}
					}
					is_vassal_of = scope:actor
				}
				is_tributary_of = scope:actor
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = demand_courtier_valid_courtier_tt
			scope:recipient = {
				any_courtier = {
					is_available_healthy_ai_adult = yes
					NOR = {
						is_consort_of = scope:recipient
						is_heir_of = scope:recipient
						AND = {
							is_female = yes
							patrilinear_marriage = yes
						}
						AND = {
							is_male = yes
							matrilinear_marriage = yes
						}
					}
				}
			}
		}
	}

	can_be_picked = {
		is_adult = yes
	}

	can_send = {
	}

	auto_accept = no

	ai_accept = {
		base = 0
		
		modifier = {
			add = 1000
			scope:recipient = {
				is_obedient_to = scope:actor
			}
			desc = AI_OBEDIENT_REASON
		}
		
		modifier = {
			add = 25
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		
		modifier = {
			add = 50
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}
		
		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1.0
			desc = AI_OPINION_REASON
		}
		
		modifier = {
			add = -25
			scope:secondary_actor = {
				OR = {
					is_councillor = yes
					has_any_court_position = yes
				}
			}
			desc = AI_EMPLOYED_COURTIER_REASON
		}
		
		modifier = {
			add = -15
			scope:secondary_actor = {
				is_knight = yes
			}
			desc = AI_IS_KNIGHT_REASON
		}
		
		modifier = {
			add = -50
			exists = scope:secondary_actor.inspiration
			desc = AI_INSPIRED_REASON
		}
		
		modifier = {
			add = -25
			scope:secondary_actor = {
				is_close_or_extended_family_of = scope:recipient
			}
			desc = AI_FAMILY_REASON
		}
		
		modifier = {
			add = -50
			scope:secondary_actor = {
				has_relation_friend = scope:recipient
			}
			desc = AI_FRIEND_REASON
		}
		
		modifier = {
			add = 1000
			scope:secondary_actor = {
				has_relation_rival = scope:recipient
			}
			desc = AI_RIVAL_REASON
		}
	}

	ai_potential = {
		ai_greed >= 0
		any_tributary = { }
	}

	ai_will_do = {
		base = 0
		
		modifier = {
			add = 100
			scope:secondary_actor = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
					sum_of_all_skills_value >= sum_of_all_skills_threshold_good
					martial >= monumentally_high_skill_rating
					prowess >= extremely_high_skill_rating
					exists = inspiration
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_chancellor ?= { diplomacy < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_steward ?= { stewardship < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_spymaster ?= { intrigue < monumentally_high_skill_rating }
					}
					trigger_if = {
						limit = {
							scope:actor = {
								government_has_flag = government_is_nomadic
							}
						}
						OR = {
							AND = {
								sum_of_all_skills_value >= sum_of_all_skills_threshold_average
								scope:actor = {
									any_courtier = {
										count < 10
									}
								}
							}
							aptitude:master_of_hunt_court_position >= 4
							aptitude:keeper_of_the_horses_court_position >= 4
							aptitude:boyan_court_position >= 4
							aptitude:siege_engineer_court_position >= 4
							aptitude:yurtchi_court_position >= 4
							aptitude:cherbi_court_position >= 4
							aptitude:yeke_jarquchi_court_position >= 4
							aptitude:foreign_emissary_court_position >= 4
						}
					}
				}
			}
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
				}
			}
		}
	}

	on_send = {
		scope:secondary_actor = { # to block the same character from being offered twice
			add_character_flag = {
				flag = has_been_offered_as_concubine
				days = 5
			}
		}
	}
	
	on_accept = {
		scope:secondary_actor = {
			add_opinion = {
				target = scope:recipient
				modifier = annoyed_opinion
				opinion = -10
			}
		}
		scope:actor = {
			add_courtier = scope:secondary_actor
			scope:secondary_actor = {
				every_consort = {
					limit = {
						is_courtier_of = scope:recipient
					}
					scope:actor = {
						add_courtier = prev
					}
				}
				every_child = {
					limit = {
						is_adult = no
						is_courtier_of = scope:recipient
					}
					scope:actor = {
						add_courtier = prev
					}
				}
			}
			add_opinion = {
				target = scope:recipient
				modifier = pleased_opinion
				opinion = 20
			}
		}
		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = upset_opinion
				opinion = -15
			}
		}
	}

	on_decline = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = msg_courtier_demand_rejected_title
				right_icon = scope:recipient
				left_icon = scope:secondary_actor
				custom_tooltip = msg_courtier_demand_rejected
			}
		}
		scope:actor = {
			add_opinion = {
				target = scope:recipient
				modifier = upset_opinion
				opinion = -15
			}
		}
	}
}

# Demand Concubine
demand_concubine_interaction = {
	category = interaction_category_vassal
	common_interaction = yes
	icon = request_concubine_interaction
	interface_priority = 44

	desc = demand_concubine_interaction_desc

	ai_targets = {
		ai_recipients = tributaries
		ai_recipients = vassals
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 12
	cooldown_against_recipient = { years = 3 }

	greeting = positive
	notification_text = DEMAND_CONCUBINE_NOTIFICATION

	needs_recipient_to_open = yes

	populate_actor_list = {
		scope:recipient = {
			every_courtier = {
				limit = {
					is_physically_able_adult = yes
					is_ruler = no
					could_marry_character_trigger = { CHARACTER = scope:actor }
				}
				add_to_list = characters
			}
		}
	}

	is_shown = {
		scope:actor != scope:recipient
		scope:actor = {
			allowed_concubines = yes
		}
		scope:recipient = {
			OR = {
				trigger_if = {
					limit = {
						scope:actor = {
							government_has_flag = government_is_nomadic
						}
					}
					is_vassal_of = scope:actor
				}
				is_tributary_of = scope:actor
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			allowed_more_concubines = yes
			is_physically_able_adult = yes
		}
		custom_tooltip = {
			text = must_have_valid_concubine_tt
			scope:recipient = {
				any_courtier = {
					is_physically_able_adult = yes
					is_ruler = no
					could_marry_character_trigger = { CHARACTER = scope:actor }
				}
			}
		}
	}

	can_be_picked = {
		is_adult = yes
	}

	can_send = {
	}

	auto_accept = no

	ai_accept = {
		base = 0
		
		modifier = {
			add = 1000
			scope:recipient = {
				is_obedient_to = scope:actor
			}
			desc = AI_OBEDIENT_REASON
		}
		
		modifier = {
			add = 25
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		
		modifier = {
			add = 50
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}
		
		opinion_modifier = { # Opinion Factor
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1.0
			desc = AI_OPINION_REASON
		}
		
		modifier = {
			add = -25
			scope:secondary_actor = {
				OR = {
					is_councillor = yes
					has_any_court_position = yes
				}
			}
			desc = AI_EMPLOYED_COURTIER_REASON
		}
		
		modifier = {
			add = -15
			scope:secondary_actor = {
				is_knight = yes
			}
			desc = AI_IS_KNIGHT_REASON
		}
		
		modifier = {
			add = -50
			exists = scope:secondary_actor.inspiration
			desc = AI_INSPIRED_REASON
		}
		
		modifier = {
			add = -25
			scope:secondary_actor = {
				is_close_or_extended_family_of = scope:recipient
			}
			desc = AI_FAMILY_REASON
		}
		
		modifier = {
			add = -50
			scope:secondary_actor = {
				has_relation_friend = scope:recipient
			}
			desc = AI_FRIEND_REASON
		}
		
		modifier = {
			add = -50
			scope:secondary_actor = {
				is_consort_of = scope:recipient
			}
			desc = AI_SPOUSE_REASON
		}
		
		modifier = {
			add = -50
			scope:secondary_actor = {
				is_child_of = scope:recipient
			}
			desc = AI_CHILD_REASON
		}
		
		modifier = {
			add = 1000
			scope:secondary_actor = {
				has_relation_rival = scope:recipient
			}
			desc = AI_RIVAL_REASON
		}
	}

	ai_potential = {
		OR = {
			has_trait = lustful
			ai_honor <= 0
		}
		any_tributary = { }
	}

	ai_will_do = {
		base = 0
		
		modifier = {
			add = 100
			scope:secondary_actor = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
					sum_of_all_skills_value >= sum_of_all_skills_threshold_good
					martial >= monumentally_high_skill_rating
					prowess >= extremely_high_skill_rating
					exists = inspiration
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_chancellor ?= { diplomacy < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_steward ?= { stewardship < monumentally_high_skill_rating }
					}
					AND = {
						diplomacy >= monumentally_high_skill_rating
						scope:actor.cp:councillor_spymaster ?= { intrigue < monumentally_high_skill_rating }
					}
					has_conventionally_attractive_trigger = yes
					num_of_good_genetic_traits > 1
				}
			}
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_lover = scope:actor
				}
			}
		}
		
		modifier = {
			factor = 0
			scope:secondary_actor = {
				OR = {
					has_conventionally_ugly_trigger = yes
					age >= 30
					is_visibly_fertile = no
				}
			}
		}
	}

	on_send = {
		scope:secondary_actor = { # to block the same character from being offered twice
			add_character_flag = {
				flag = has_been_offered_as_concubine
				days = 5
			}
		}
	}
	
	on_accept = {
		scope:recipient = {
			if = {
				limit = {
					scope:secondary_actor = {
						NOR = {
							is_consort_of = scope:recipient
							is_close_or_extended_family_of = scope:recipient
						}
					}
				}
				add_opinion = {
					target = scope:actor
					modifier = upset_opinion
					opinion = -15
				}
			}
			else = {
				scope:secondary_actor = { save_scope_as = relationship_reason_involved_character }
				progress_towards_rival_effect = {
					REASON = rival_demanded_concubine
					CHARACTER = scope:actor
					OPINION = 0
				}
				add_opinion = {
					target = scope:actor
					modifier = upset_opinion
					opinion = -50
				}
				clear_saved_scope = secondary_actor
			}
		}
		demand_concubine_interaction_on_accept_effect = yes
	}

	on_decline = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = msg_concubine_demand_rejected_title
				right_icon = scope:recipient
				left_icon = scope:secondary_actor
				custom_tooltip = msg_courtier_demand_rejected
			}
		}
		scope:actor = {
			add_opinion = {
				target = scope:recipient
				modifier = upset_opinion
				opinion = -15
			}
		}
	}
}
