﻿
zz_adopt_interaction = {
	icon = icon_adopt_house_member
	category = interaction_category_friendly
	interface_priority = 60
	cooldown = { years = 2 }

	desc = adventurer_adopt_interaction_desc
	use_diplomatic_range = yes
	
	is_shown = {
		scope:actor = character:Setenon_01 
		scope:recipient = {
			is_ruler = no
			# They don't already belong to your dynasty
			NOT = { dynasty = scope:actor.dynasty }
			#AGOT ADDED
			#is_human = yes
		}
	}

	#is_valid = {}

	is_valid_showing_failures_only = {
		# Don't get imprisoned children and so on
		scope:recipient = {
			is_available = yes
			is_courtier_of = scope:actor
			opinion = {
				value >= 40 # sync with define:NDomicile|TEMPERAMENT_THRESHOLD_HIGH
				target = scope:actor
			}
		}
		scope:recipient = {
			NOT = { has_trait = devoted }
		}
		scope:recipient = {
			NOT = { has_trait = gallivanter }
		}
	}
	
	on_accept = {
		show_as_tooltip = {
			zz_adopt_to_house_effect = {
				CHILD = scope:recipient
				ADOPTER = scope:actor
			}
			scope:actor = { set_designated_heir = scope:recipient }
		}
		hidden_effect = {
			scope:actor = { trigger_event = zz_adoption.0002 }
		}
	}
	
	cost = {
		prestige = {
			value = {
				add = medium_prestige_value
				if = {
					limit = {
						scope:actor = {
							OR = {
								culture = { has_cultural_parameter = free_adoption }
								has_game_rule = adoption_always_allowed
							}
						}
					}
					multiply = 0
				}
			}
		}
	}
	
	ai_accept = {
		base = 0
		modifier = { # My parents are alive
			add = -15
			desc = parents_are_alive_tt
			OR = {
				father ?= { is_alive = yes }
				mother ?= { is_alive = yes }
			}
		}
		modifier = { # I hate my mother
			add = 10
			desc = i_hate_my_mother_tt
			exists = mother
			mother = { is_alive = yes }
			opinion = {
				value <= medium_negative_opinion
				target = mother
			}
		}
		modifier = { # I hate my father
			add = 10
			desc = i_hate_my_father_tt
			exists = father
			father = { is_alive = yes }
			opinion = {
				value <= medium_negative_opinion
				target = father
			}
		}
		modifier = { # I like my mother
			add = -10
			desc = i_like_my_mother_tt
			exists = mother
			mother = { is_alive = yes }
			opinion = {
				value >= medium_positive_opinion
				target = mother
			}
		}
		modifier = { # I like my father
			add = -10
			desc = i_like_my_father_tt
			exists = father
			father = { is_alive = yes }
			opinion = {
				value >= medium_positive_opinion
				target = father
			}
		}
		modifier = { # I like you
			add = {
				value = 5
				if = {
					limit = {
						opinion = {
							value >= high_positive_opinion
							target = scope:actor
						}
					}
					add = 10
				}
				if = {
					limit = {
						opinion = {
							value >= very_high_positive_opinion
							target = scope:actor
						}
					}
					add = 10
				}
			}
			desc = i_like_you_tt
			opinion = {
				value >= medium_positive_opinion
				target = scope:actor
			}
		}
		modifier = { # You're my friend :)
			add = 10
			desc = youre_my_friend_tt
			has_relation_friend = scope:actor
		}
		modifier = { # You're my guardian
			add = 10
			desc = youre_my_guardian_tt
			has_relation_guardian = scope:actor
		}
		modifier = { # I have no mother
			add = 5
			desc = i_want_a_mother_tt
			scope:actor = { is_female = yes }
			OR = {
				NOT = { exists = mother }
				mother = { is_alive = no }
			}
		}
		modifier = { # I have no father
			add = 5
			desc = i_want_a_father_tt
			scope:actor = { is_male = yes }
			OR = {
				NOT = { exists = father }
				father = { is_alive = no }
			}
		}
		modifier = { # I am a noble!
			add = -15
			desc = i_am_noble_tt
			has_no_particular_noble_roots_trigger = no
		}
		modifier = { # We are so alike ^^
			add = { 
				value = 5
				if = {
					limit = {
						number_of_personality_traits_in_common = {
							target = scope:actor
							value = 2
						}
					}
					multiply = 2
				}
				else_if = {
					limit = {
						number_of_personality_traits_in_common = {
							target = scope:actor
							value = 3
						}
					}
					multiply = 3
				}
				else_if = {
					limit = {
						number_of_personality_traits_in_common = {
							target = scope:actor
							value = 4
						}
					}
					multiply = 4
				}
			}
			desc = we_are_alike_tt
			number_of_personality_traits_in_common = {
				target = scope:actor
				value >= 1
			}
		}
		modifier = { # Yo, you're offering me a place in a landed house? Sick.
			add = 10
			desc = ambition_tt
			has_trait = ambitious
		}
	}
}
zz_create_cadet_branch = {

	category = interaction_category_friendly
	common_interaction = no
	icon = powerful_family_shield
	cost = {
		prestige = 1000
		influence = {
			add =  scope:actor.massive_influence_value
		}
	}
	is_shown = {
		always = no 
		scope:actor = {
			government_has_flag = government_is_freehold 
			is_ai = no
		}
		
		scope:recipient = {
			exists = house
			exists = house.house_head
			is_house_head = no
			liege = scope:actor
			#has_trait = dragonrider
		}
	}

	auto_accept = yes
	on_accept = {
		scope:recipient = {
			found_cadet_house_decision_effect = {
				CHARACTER = scope:recipient 
				PRESTIGE = major_prestige_gain
			}
			if = {
				limit = {
					government_allows = administrative
					highest_held_title_tier >= tier_duchy
					liege ?= {
						is_independent_ruler = yes
						government_allows = administrative
						NOT = {
							government_has_flag = government_is_freehold
						}
					}
				}
				create_noble_family_effect = { GOVERNMENT_GIVER = this }
				change_influence = major_influence_gain
			}
			else_if = {
				limit = { 
					government_allows = administrative
					highest_held_title_tier >= tier_duchy
					liege = {
						is_independent_ruler = yes
						government_allows = administrative
						government_has_flag = government_is_freehold
					}
				}
				create_noble_family_dragonrider_effect  = yes
				change_influence = major_influence_gain
			}
		}
	}
}




zz_establish_dragon_rider_house = {

	category = interaction_category_vassal
	common_interaction = no
	icon = powerful_family_shield

	is_shown = {
		#always = no 
		scope:actor = {
			government_has_flag = government_is_freehold 
			is_ai = no
		}
		
		scope:recipient = {
			liege = scope:actor
			is_ruler = no
			has_trait = dragonrider
		}
	}

	auto_accept = yes
	on_accept = {
		scope:recipient = {
			found_cadet_house_decision_effect = {
				CHARACTER = scope:recipient 
				PRESTIGE = major_prestige_gain
			}
			create_noble_family_effect = { GOVERNMENT_GIVER = this }
			change_influence = major_influence_gain
			create_title_and_vassal_change = {
				type = swear_fealty
				save_scope_as = change
			}
			scope:recipient = {
				change_liege = {
					liege = scope:actor
					change = scope:change
				}
				add_opinion = {
					modifier = became_vassal
					target = scope:actor
					opinion = 10
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
	}
}

demand_admin_interaction = {
	category = interaction_category_vassal
	icon = demand_admin_interaction

	ai_maybe = yes
	ai_min_reply_days = 4
	ai_max_reply_days = 9
	can_send_despite_rejection = yes
	ai_accept_negotiation = yes
	popup_on_receive = yes
	common_interaction = yes

	ai_targets = {
		ai_recipients = vassals
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 12

	desc = demand_admin_interaction_desc

	is_shown = {
		scope:actor = { government_allows = administrative }
		scope:recipient = {
			target_is_liege_or_above = scope:actor
			is_ai = yes
			is_ruler = yes
			NOT = { government_allows = administrative }
		}
		trigger_if = {
			limit = {
				scope:actor = {
					is_ai = yes
				}
			}
			scope:recipient = {
				highest_held_title_tier >= tier_county
			}
		}
		#AGOT ADDED
		scope:actor = {
			is_human = yes
			agot_can_be_ruler = yes
		}
		scope:recipient = {
			is_human = yes
			agot_can_be_ruler = yes
		}
	}

	cooldown_against_recipient = { years = 10 }

	is_valid_showing_failures_only = {
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
		scope:recipient = { is_at_war = no }
		scope:actor = { is_at_war = no }
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
		custom_tooltip = {
			text = demand_admin_tribal
			NOT = {
				scope:recipient = { government_has_flag = government_is_tribal }
			}
		}
		custom_tooltip = {
			text = head_of_faith_unable_to_change_government_desc
			NOT = {
				scope:recipient = { faith.religious_head ?= this }
			}
		}
	}

	# Offer hereditary boost
	send_option = {
		is_valid = {
			custom_tooltip = {
				text = demand_admin_hereditary_tt
				scope:recipient.house ?= {
					any_house_member = { count > 1 }
				}
			}
			custom_tooltip = {
				text = demand_admin_hereditary_exists_tt
				NOT = { exists = scope:recipient.primary_title.var:petition_house_rights }
			}
		}
		flag = hereditary
		localization = demand_admin_hereditary
	}
	#Spend influence
	send_option = {
		flag = influence
		is_valid = {
			scope:actor.influence >= massive_influence_value
		}
		localization = SPEND_INFLUENCE
	}
	#Use hook
	send_option = {
		is_valid = {
			scope:actor = { has_usable_hook = scope:recipient }
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
		}
	}

	on_send = {
		scope:recipient = {
			primary_title = { save_scope_as = demanded_administration }
			trigger_event = {
				id = ep3_interactions_events.0005
				days = 5
			}
		}
	}

	on_accept = {
		show_as_tooltip = {
			if = { 
				limit = {
					scope:actor = {
						government_has_flag = government_is_freehold 
					}
				}
				change_to_administrative_interaction_effect = yes
			}
			else = {
				change_to_administrative_interaction_effect = yes
			}
		}
	}

	on_decline = {
		scope:recipient = { custom_tooltip = demand_admin_interaction_vassal_refuses }
	}

	ai_potential = {
		government_allows = administrative
		is_adult = yes
	}

	ai_will_do = {
		base = 100
		modifier = {
			factor = 0
			scope:recipient = { highest_held_title_tier >= tier_county }
			gold >= 300
		}
		modifier = {
			factor = 0
			scope:recipient = { highest_held_title_tier >= tier_duchy }
			gold >= 600
		}
		modifier = {
			factor = 0
			scope:recipient = { highest_held_title_tier >= tier_kingdom }
			gold >= 2000
		}
	}

	ai_accept = {
		base = 0
		demand_admin_acceptance_modifier = yes
	}
}


grant_freehold_interaction = {
	icon = grant_governorship
	category = interaction_category_friendly
	common_interaction = yes

	desc = grant_governorship_interaction_desc

	special_interaction = grant_governorship_interaction
	interface = grant_titles
	target_type = title
	target_filter = actor_domain_titles
	interface_priority = 60

	# actor character giving the titles
	# recipient character receiving the titles

	is_shown = {
		always = no
		NOT = { scope:actor = scope:recipient }
		scope:recipient = {
			OR = {
				target_is_liege_or_above = scope:actor
				is_pool_guest_of = scope:actor
			}
		}
		scope:actor = {
			government_has_flag = government_is_freehold 
			government_allows = administrative
			highest_held_title_tier >= tier_county
		}
		
		trigger_if = {
			limit = {
				scope:actor = { is_ai = yes }
			}
			scope:recipient = {
				NOT = { any_parent = { is_ai = no } }
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_adult = yes
			NOT = { is_at_war_with = scope:actor }
			bp2_valid_for_standard_interactions_trigger = yes
			trigger_if = {
				limit = { is_ruler = no }
				is_imprisoned = no
			}
			# Only the preferred gender can be appointed unless they hold titles already
			trigger_if = {
				limit = {
					scope:actor = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
					}
					is_landed = no
				}
				is_female = no
			}
			trigger_if = {
				limit = {
					scope:actor = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
					}
					is_landed = no
				}
				is_female = yes
			}
			# DON'T TAKE OTHER PLAYERS' ACCLAIMED KNIGHTS
			custom_description = {
				text = grant_title_stealing_acclaimed_knight
				subject = scope:recipient
				NOR = {
					AND = {
						is_acclaimed = yes
						liege ?= {
							is_ai = no
							NOT = { this = scope:actor }
						}
					}
					AND = {
						is_acclaimed = yes
						scope:actor = { is_ai = yes }
					}
				}
			}
			trigger_if = {
				limit = { is_landed = yes }
				government_allows = administrative
			}
			is_clergy = no
			# Gallivanters won't accept additional responsibilities.
			NOT = { has_trait = gallivanter }
		}
	}

	can_send = {
		scope:recipient = {
			custom_tooltip = {
				text = promote_candidate_interaction_existing_holder_tt
				this != scope:target.holder
			}
			
			trigger_if = { # Governors can only be appointed to certain titles
				limit = {
					is_governor = yes
					scope:target = { is_noble_family_title = no } # For tooltip reasons, so we don't show more than necessary
				}
				custom_tooltip = { # Only one province of highest rank
					text = only_one_province_of_highest_rank_tt
					NAND = {
						highest_held_title_tier = scope:target.tier
						scope:target.tier >= tier_duchy
						scope:target = { # We make an exception if recipient controls at least one de jure county
							any_de_jure_county = {
								count < 1
								OR = {
									holder = scope:recipient
									holder = { is_vassal_or_below_of = scope:recipient }
								}
							}
						}
					}
				}
				custom_tooltip = {
					text = NOT_ANY_IN_DE_JURE_ALL_GLOBAL
					any_held_title = {
						OR = {
							# The target title is part of your de jure structure
							is_de_jure_liege_or_above_target = scope:target
							target_is_de_jure_liege_or_above = scope:target
							# Or is a neighboring county which de jure duchy is not part of your realm
							AND = {
								any_title_to_title_neighboring_county = { this = scope:target }
								scope:target = {
									tier = tier_county
									duchy = {
										OR = {
											NOT = { exists = holder }
											holder = {
												NOR = {
													is_vassal_or_below_of = scope:actor
													this = scope:actor
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			trigger_if = { # If recipient is landless and only have a family title, target title must be a duchy or above
				limit = {
					is_landless_ruler = yes
					any_held_title = { is_noble_family_title = yes }
				}
				scope:target = { NOT = { tier < tier_duchy } }
			}
			trigger_if = { # If recipient is a count, they can get only get counties within the same duchy
				limit = { highest_held_title_tier = tier_county }
				trigger_if = {
					limit = { scope:target.tier = tier_county }
					custom_tooltip = {
						text = NOT_ANY_IN_DE_JURE_ALL_GLOBAL
						any_held_title = { duchy = scope:target.duchy }
					}
				}
			}
		}
	}

	can_be_picked_title = {
		scope:target = {
			is_leased_out = no

			NOT = { tier = tier_barony }

			scope:recipient = {
				trigger_if = { # Governors can only be appointed to certain titles
					limit = {
						is_governor = yes
						scope:target = { is_noble_family_title = no } # For tooltip reasons, so we don't show more than necessary
					}
					custom_tooltip = { # Only one province of highest rank
						text = only_one_province_of_highest_rank_tt
						NAND = {
							highest_held_title_tier = scope:target.tier
							scope:target.tier >= tier_duchy
							scope:target = { # We make an exception if recipient controls at least one de jure county
								any_de_jure_county = {
									count < 1
									OR = {
										holder = scope:recipient
										holder = { is_vassal_or_below_of = scope:recipient }
									}
								}
							}
						}
					}
					custom_tooltip = {
						text = NOT_ANY_IN_DE_JURE_ALL_GLOBAL
						any_held_title = {
							OR = {
								# The target title is part of your de jure structure
								is_de_jure_liege_or_above_target = scope:target
								target_is_de_jure_liege_or_above = scope:target
								# Or is a neighboring county which de jure duchy is not part of your realm
								AND = {
									any_title_to_title_neighboring_county = { this = scope:target }
									scope:target = {
										tier = tier_county
										duchy = {
											OR = {
												NOT = { exists = holder }
												holder = {
													NOR = {
														is_vassal_or_below_of = scope:actor
														this = scope:actor
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				trigger_if = { # If recipient is landless and only have a family title, target title must be a duchy or above
					limit = {
						is_landless_ruler = yes
						any_held_title = { is_noble_family_title = yes }
					}
					scope:target = { NOT = { tier < tier_duchy } }
				}
				trigger_if = { # If recipient is a count, they can get only get counties within the same duchy
					limit = { highest_held_title_tier = tier_county }
					trigger_if = {
						limit = { scope:target.tier = tier_county }
						custom_tooltip = {
							text = NOT_ANY_IN_DE_JURE_ALL_GLOBAL
							any_held_title = { duchy = scope:target.duchy }
						}
					}
				}
			}

			custom_tooltip = {
				text = GRANT_TITLES_ITEM_CANT_GIVE_ADMIN_PRIMARY
				NOT = {
					this = scope:actor.primary_title.title_capital_county.duchy
				}
			}

			trigger_if = {
				limit = { is_noble_family_title = yes }
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_CANT_GIVE_NOBLE_FAMILY
					always = no
				}
			}

			trigger_if = {
				limit = {
					list_size:target_titles > 0
				}
				custom_tooltip = {
					text = GRANT_TITLES_ITEM_ADMIN_CANT_GIVE_MORE_THAN_ONE
					any_in_list = {
						list = target_titles
						scope:target ?= this
					}
				}
			}

			#AGOT Disabled
			#trigger_if = {
			#	limit = { scope:target = title:k_fashion }
			#	NOT = { scope:target = title:k_fashion }
			#}
		}

		custom_description = {
			text = grant_titles_interaction_can_only_give_diarch_de_jure_liege_to_diarch
			subject = scope:actor.diarch
			NAND = {
				# Only applies if we have an active diarchy.
				scope:actor = { has_active_diarchy = yes }
				# Now, prevent us from giving away our diarch's land to invalidate them...
				scope:target = {
					any_dejure_vassal_title_holder = { this = scope:actor.diarch }
					# ... _unless_ we're giving it _to_ the diarch.
					NOT = { scope:recipient = scope:actor.diarch }
					# Plus we only care if the title is below our tier.
					tier < scope:actor.highest_held_title_tier
				}
			}
		}

		custom_description = {
			text = grant_titles_interaction_title_being_wagered
			NOT = {
				scope:target = { has_variable = wagered_county }
			}
		}
	}

	auto_accept = yes

	on_auto_accept = {
		scope:recipient = {
			trigger_event = {
				id = zz_char_interaction.0111
				delayed = yes #this has to be delayed in case you grant it to someone that doesn't have an estate yet, for the change_government effect to work and generate the estate
			}
		}
	}

	on_accept = {
		if = {
			limit = {
				scope:recipient = {
					is_acclaimed = yes
					liege = {
						this = scope:actor
					}
				}
			}
			custom_tooltip = grant_title_landing_acclaimed_knight_warning
		}

		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_duchy
					title_capital_county = {
						NOT = { culture = scope:actor.culture }
						culture = scope:recipient.culture
					}
					NOT = {
						recent_history = {
							type = granted
							years = 10
						}
					}
				}
			}
			scope:recipient.culture = {
				change_cultural_acceptance = {
					target = scope:actor.culture
					value = grant_title_cultural_acceptance_impact
					desc = cultural_acceptance_gain_granted_title
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_county
				}
				scope:actor.culture = { has_cultural_parameter = landing_house_members_give_prestige }
				exists = scope:actor.house
				exists = scope:recipient.house
				scope:actor.house = scope:recipient.house
			}
			scope:actor = {
				add_prestige = {
					value = 0
					every_in_list = {
						list = target_titles
						limit = { tier = tier_empire }
						add = massive_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_kingdom }
						add = major_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_duchy }
						add = medium_prestige_gain
					}
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier >= tier_county
				}
				scope:actor.culture = { has_cultural_parameter = landing_house_members_gives_renown }
				exists = scope:actor.house
				exists = scope:recipient.house
				scope:actor.house = scope:recipient.house
			}
			scope:actor.dynasty = {
				add_dynasty_prestige = {
					value = 0
					every_in_list = {
						list = target_titles
						limit = { tier = tier_kingdom }
						add = major_dynasty_prestige_gain
					}
					every_in_list = {
						list = target_titles
						limit = { tier = tier_duchy }
						add = medium_dynasty_prestige_gain
					}
				}
			}
		}

		# Iterate over all given titles
		#  - Add opinion modifiers
		#  - Collect titles that discontent reduction can later be derived from
		every_in_list = {
			list = target_titles
			save_temporary_scope_as = this_title
			if = {
				limit = {
					exists = scope:landed_title
				}
				scope:recipient = {
					if = {
						limit = {
							scope:this_title.tier = tier_duchy
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_duchy
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										limit = {
											has_vassal_stance = courtly
										}
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -10	#less than usual because admin realms are more tolerant of bureaucratic "new" nobility
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}

					else_if = {
						limit = {
							scope:this_title.tier = tier_kingdom
						}

						hidden_effect = {
							add_opinion = {
								target = scope:actor
								modifier = received_title_kingdom
							}
							if = {
								limit = {
									is_lowborn = yes
								}
								scope:actor = {
									every_vassal = {
										limit = {
											has_vassal_stance = courtly
										}
										add_opinion = {
											target = scope:actor
											modifier = courtly_lowborn_grant_opinion
											opinion = -30	#less than usual because admin realms are more tolerant of bureaucratic "new" nobility
										}
									}
								}
							}
						}

						scope:this_title = { add_to_temporary_list = titles_to_grant }
					}
				}

				#Promised a vassal this title they had a claim on (vassal.2901)
				if = {
					limit = {
						scope:actor = {
							exists = var:was_promised_title
							var:was_promised_title = scope:recipient
						}
					}
					if = {
						limit = {
							scope:recipient = {
								exists = var:promised_title
							}
							scope:landed_title = scope:recipient.var:promised_title
						}
						scope:actor = {
							trigger_event = {
								id = vassal.2910
								days = { 7 14 }
							}
						}
					}
				}
			}
			if = {
				limit = {
					scope:recipient = {
						has_trait = bastard
					}
				}
				custom_tooltip = grant_title_to_bastard_dynasty_warning
			}
		} # every_in_list

		# The accumulated discontent reduction of the recipient
		scope:recipient = {
			if = {
				limit = {
					is_a_faction_member = yes
				}
				add_joined_faction_discontent = grant_title_opinion_sum_discontent_calc
			}
		}

		if = {
			limit = {
				any_in_list = {
					list = target_titles
					tier = tier_kingdom
				}
			}
			custom_tooltip = grant_title_modifier_stack_kingdoms
		}
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					tier = tier_duchy
				}
			}
			custom_tooltip = grant_title_modifier_stack_duchies
		}
		if = {
			limit = {
				trigger_if = {
					limit = { scope:actor = { is_ai = yes } }
					scope:actor = {
						any_vassal = {
							has_vassal_stance = courtly
						}
					}
				}
				scope:recipient = {
					is_lowborn = yes
				}
				any_in_list = {
					list = titles_to_grant
					tier >= tier_county
				}
			}
			custom_tooltip = grant_title_modifier_courtly_lowborn_grant_penalty
		}
		if = {
			limit = {
				scope:recipient = { is_a_faction_member = yes }
			}
			custom_tooltip = grant_title_modifier_stack_discontent
		}

		# Jealousy check
		if = {
			limit = {
				any_in_list = {
					list = titles_to_grant
					any_claimant = { grant_title_rivalry_trigger = yes }
				}
			}
			hidden_effect = {
				random = {
					chance = 25
					ordered_in_list = {
						list = titles_to_grant
						limit = {
							any_claimant = { grant_title_rivalry_trigger = yes }
						}
						order_by = tier
						save_scope_as = claim_title
						ordered_claimant = {
							limit = { grant_title_rivalry_trigger = yes }
							order_by = primary_title.tier
							save_scope_as = claim_vassal
							if = {
								limit = {
									scope:recipient = { is_lowborn = yes }
								}
								scope:recipient = { save_scope_as = lowborn_scope }
							}
							else_if = {
								limit = {
									scope:recipient = { has_claim_on = scope:claim_title }
								}
								scope:recipient = { save_scope_as = claimant_scope }
							}
							scope:actor = {
								trigger_event = {
									id = bp1_yearly.8070
									days = 5
								}
							}
						}
					}
				}
			}
		}

		scope:actor = {
			# Maintenance for runestones
			if = {
				limit = {
					# Use expanded version if we have FP1.
					has_fp1_dlc_trigger = yes
					fp1_remove_stele_new_holder_trigger = {
						TITLE = scope:target
						PREVIOUS_HOLDER = scope:actor
						NEW_HOLDER = scope:recipient
					}
				}
				# Actually removed in fp1_other_decisions.0113
				custom_tooltip = runestone_grant_title_warning
			}
			else_if = {
				limit = {
					scope:target = {
						exists = var:ancestor_to_bury
						has_county_modifier = county_raised_runestone_modifier
					}
					NOT = { scope:recipient.dynasty = var:ancestor_to_bury.dynasty } #We only have to change something if the new holder is of a different dynasty
				}
				# Actually removed in religious_decision.0312
				custom_tooltip = runestone_grant_title_warning
			}

			if = {
				limit = {
					dynasty ?= { has_dynasty_perk = ep1_culture_legacy_3 }
					scope:recipient = {
						is_playable_character = no
						NOT = { culture = scope:actor.culture }
						any_in_list = {
							list = target_titles
							OR = {
								tier = tier_county
								tier = tier_barony
							}
							culture = scope:recipient.culture
						}
					}
				}
				if = {
					limit = {
						can_add_hook = {
							target = scope:recipient
							type = favor_hook
						}
					}
					add_hook = {
						type = favor_hook
						target = scope:recipient
					}
				}
			}

			#Feedback for actor
			hidden_effect = {
				if = {
					limit = {
						NOT = { exists = scope:recipient_is_independent }
						scope:recipient = {
							any_held_title = {
								tier > tier_barony
								NOT = { is_in_list = target_titles }
							}
						}
					}
					set_variable = {
						name = lower_count
						value = {
							value = -1
							every_in_list = {
								list = target_titles
								limit = {
									NOT = { tier = scope:actor.highest_held_title_tier }
								}
								add = 1
							}
						}
					}
					save_scope_value_as = {
						name = equal_count
						value = {
							value = 0
							every_in_list = {
								list = target_titles
								limit = { tier = scope:actor.highest_held_title_tier }
								add = 1
							}
						}
					}
					ordered_in_list = {
						list = target_titles
						order_by = tier
						save_temporary_scope_as = loc_title
					}
					send_interface_toast = {
						type = event_toast_effect_neutral
						title = grant_governorship_interaction_notification
						left_icon = scope:recipient
						right_icon = scope:loc_title
						if = {
							limit = { scope:actor.var:lower_count ?= 0 }
							custom_tooltip = grant_governorship_interaction_notification_effect_2
						}
						else_if = {
							limit = {
								exists = scope:actor.var:lower_count
								scope:actor.var:lower_count > 1
							}
							custom_tooltip = grant_governorship_interaction_notification_effect_3
						}
						else_if = {
							limit = { scope:actor.var:lower_count ?= 1 }
							custom_tooltip = grant_governorship_interaction_notification_effect_4
						}
						else_if = {
							limit = {
								scope:equal_count >= 1
								scope:recipient.top_liege ?= scope:actor.top_liege
							}
							custom_tooltip = grant_titles_interaction_notification_effect_5
						}
						else = { custom_tooltip = grant_titles_interaction_notification_effect }
						if = {
							limit = {
								exists = dynasty
								#AGOT Modified
								is_diff_culture_trigger = {
									CHAR = scope:actor
									STATUS = involved
								}
								any_character_struggle = {
									involvement = involved
									#AGOT Modified, BTW struggle has faith removed
									#has_struggle_phase_parameter = struggle_grant_titles_diff_faith_culture_gives_prestige
									has_struggle_phase_parameter = struggle_grant_titles_diff_culture_gives_prestige
								}
							}
							dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
						}
						remove_variable = lower_count
					}
				}
			}
		}

		hidden_effect = {
			# Struggle Catalyst
			if = {
				limit = {
					scope:actor = {
						#AGOT Modified
						is_diff_culture_trigger = {
							CHAR = scope:recipient
							STATUS = involved
						}
						any_character_struggle = {
							involvement = involved
							activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
								#AGOT Modified, BTW struggle has faith removed
								#CATALYST = catalyst_grant_privilege_to_diff_faith_culture_vassal
								CATALYST = catalyst_grant_privilege_to_diff_culture_vassal
								CHAR = scope:recipient
							}
						}
					}
				}
				scope:actor = {
					every_character_struggle = {
						involvement = involved
						limit = {
							activate_struggle_catalyst_secondary_character_involvement_involved_trigger = {
								#AGOT Modified, BTW struggle has faith removed
								#CATALYST = catalyst_grant_privilege_to_diff_faith_culture_vassal
								CATALYST = catalyst_grant_privilege_to_diff_culture_vassal
								CHAR = scope:recipient
							}
						}
						activate_struggle_catalyst = {
							#AGOT Modified, BTW struggle has faith removed
							#catalyst = catalyst_grant_privilege_to_diff_faith_culture_vassal
							catalyst = catalyst_grant_privilege_to_diff_culture_vassal
							character = scope:actor
						}
					}
				}
			}
		}

		# Achievements.
		#AGOT Disabled
		#scope:actor = {
		#	if = {
		#		limit = {
		#			has_variable_list = candidate_a_knights_tale_achievement
		#			is_target_in_variable_list = {
		#				name = candidate_a_knights_tale_achievement
		#				target = scope:recipient
		#			}
		#		}
		#		set_global_variable = {
		#			name = finished_a_knights_tale_achievement
		#			value = yes
		#		}
		#	}
		#}
	}

	ai_will_do = {
		base = 0

		modifier = {
			scope:recipient.house ?= scope:actor.house
			add = 100
		}
		modifier = {
			scope:recipient = {
				is_close_family_of = scope:actor
			}
			add = 100
		}
	}
}
request_raid_remit_interaction = {
	icon = icon_request_raid_remit
	category = interaction_category_hostile
	filter_tags = { admin_liege }
	interface_priority = 90

	desc = request_raid_remit_interaction_desc
	use_diplomatic_range = yes

	ai_min_reply_days = 4
	ai_max_reply_days = 9

	cooldown_against_recipient = { years = 5 }

	is_shown = {
		scope:actor = {
			domicile ?= {
				OR = {
					is_domicile_type = estate
					is_domicile_type = east_asian_estate
					is_domicile_type = japanese_manor
					is_domicile_type = dragonkeep
				}
			}
			top_liege != this
		}
		scope:secondary_recipient ?= {
			domicile ?= {
				OR = {
					is_domicile_type = estate
					is_domicile_type = east_asian_estate
					is_domicile_type = japanese_manor
					is_domicile_type = dragonkeep
				}
			}
			house != scope:recipient.house
			top_liege = scope:actor.top_liege
			house != scope:actor.house
		}
		#AGOT Added
		scope:actor = {
			is_human = yes
		}
		scope:recipient = {
			is_human = yes
		}
		scope:secondary_recipient ?= {
			is_human = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_adult = yes
			custom_tooltip = {
				text = is_house_head_of_noble_family_tt
				any_held_title = { is_noble_family_title = yes }
				house.house_head ?= this
			}
			custom_tooltip = {
				text = raid_estate_already_remit_tt
				NOT = { exists = var:raid_estate_permission }
			}
			#AGOT Disabled
			# trigger_if = {
			# 	limit = {
			# 		government_has_flag = government_is_celestial
			# 		exists = var:movement_power
			# 	}
			# 	custom_tooltip = {
			# 		text = actor_not_extremely_high_movement_power
			# 		var:movement_power >= extremely_high_movement_power_value
			# 	}
			# }
			NOT = { is_at_war_with = scope:recipient }
		}
		scope:recipient.house.house_head ?= {
			custom_tooltip = {
				text = is_house_head_of_noble_family_tt
				any_held_title = { is_noble_family_title = yes }
			}
			custom_tooltip = {
				text = raid_estate_estate_tt
				domicile ?= {
					OR = {
						is_domicile_type = estate
						is_domicile_type = east_asian_estate
						is_domicile_type = japanese_manor
						is_domicile_type = dragonkeep
					}
				}
			}
		}
	}

	populate_recipient_list = {
		scope:actor.top_liege = {
			every_noble_family = {
				limit = {
					NOR = {
						holder = scope:actor
						holder = scope:actor.top_liege
					}
				}
				holder = { add_to_list = characters }
			}
		}
	}

	redirect = {
		scope:recipient.house.house_head ?= { save_scope_as = secondary_recipient }
		scope:actor.top_liege = { save_scope_as = recipient }
	}

	send_option = {
		is_valid = { scope:actor.gold >= scope:actor.minor_gold_value }
		flag = gold
		localization = GENERIC_SPEND_GOLD
	}
	send_option = {
		is_valid = {
			scope:actor = { has_usable_hook = scope:recipient }
			NOT = {
				scope:recipient = { has_hook = scope:actor }
			}
		}
		flag = hook
		localization = GENERIC_SPEND_A_HOOK
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	on_accept = {
		if = {
			limit = { scope:gold = yes }
			scope:actor = {
				pay_short_term_gold = {
					target = scope:recipient
					gold = scope:actor.minor_gold_value
				}
			}
		}
		scope:recipient = { custom_tooltip = request_raid_remit_interaction_effect_tt }
		custom_tooltip = request_raid_remit_interaction_duration_tt
		hidden_effect = {
			scope:actor = { trigger_event = ep3_interactions_events.0421 }
		}
		#AGOT Disabled
		# scope:actor = {
		# 	tgp_activate_catalyst_against_hegemon_effect = {
		# 		HEGEMON = scope:recipient
		# 		CATALYST = catalyst_hegemon_influenced_by_interaction
		# 	}
		# }
	}

	on_decline = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = request_raid_remit_effect_toast
				left_icon = scope:recipient
				right_icon = scope:actor
				scope:recipient = {
					send_interface_toast = {
						type = event_toast_effect_bad
						title = request_raid_remit_effect_toast
						left_icon = scope:recipient
						right_icon = scope:actor
						if = {
							limit = { scope:actor = { is_ai = yes } }
							reverse_add_opinion = {
								modifier = angry_opinion
								opinion = -20
								target = scope:actor
							}
						}
						if = {
							limit = { is_ai = yes }
							add_opinion = {
								modifier = respect_opinion
								opinion = -10
								target = scope:actor
							}
						}
					}
				}
			}
		}
	}

	cost = {
		prestige = {
			if = {
				limit = {
					scope:actor = { NOT = { government_has_flag = government_has_influence } }
				}
				add = scope:actor.massive_influence_value
				# Being a Powerful or Dominant Family reduces the cost significantly
				scope:actor.house = {
					if = {
						limit = { is_dominant_family = yes }
						add = {
							value = massive_influence_value
							multiply = -0.75
							desc = is_dominant_family_desc
						}
					}
					else_if = {
						limit = { is_powerful_family = yes }
						add = {
							value = massive_influence_value
							multiply = -0.5
							desc = is_powerful_family_desc
						}
					}
				}
			}
		}
		influence = {
			if = {
				limit = {
					scope:actor = { government_has_flag = government_has_influence }
				}
				add = scope:actor.massive_influence_value
				# Being a Powerful or Dominant Family reduces the cost significantly
				scope:actor.house = {
					if = {
						limit = { is_dominant_family = yes }
						add = {
							value = massive_influence_value
							multiply = -0.75
							desc = is_dominant_family_desc
						}
					}
					else_if = {
						limit = { is_powerful_family = yes }
						add = {
							value = massive_influence_value
							multiply = -0.5
							desc = is_powerful_family_desc
						}
					}
				}
			}
		}
	}

	ai_potential = {
		is_house_head = yes
		house ?= {
			any_house_member = {
				count <= 5
				is_alive = yes
			}
		}
	}

	ai_targets = {
		ai_recipients = peer_vassals
		ai_recipients = scripted_relations
		max = 10
	}

	ai_accept = {
		base = -30
		modifier = {
			scope:hook = yes
			add = 40
			desc = SCHEME_WEAK_HOOK_USED
		}
		modifier = {
			scope:gold = yes
			add = 25
			desc = SCHEME_WITH_GIFT_SIGNIFICANT
		}
		modifier = { # Target house is powerful
			add = -10
			desc = MY_HOUSE_IS_POWERFUL
			scope:secondary_recipient.house ?= { is_powerful_family = yes }
		}
		modifier = { # Target house is dominant
			add = -25
			desc = MY_HOUSE_IS_DOMINANT
			scope:secondary_recipient.house ?= { is_dominant_family = yes }
		}
		modifier = {
			scope:actor.house = { is_powerful_family = yes }
			add = 10
			desc = YOUR_FAMILY_IS_POWERFUL
		}
		modifier = {
			scope:actor.house = { is_dominant_family = yes }
			add = 25
			desc = YOUR_FAMILY_IS_DOMINANT
		}
		modifier = {
			scope:recipient.primary_spouse ?= { house ?= scope:secondary_recipient.house }
			add = -10
			desc = MY_SPOUSES_HOUSE
		}
		modifier = {
			any_child = { house = scope:secondary_recipient.house }
			add = -10
			desc = MY_CHILDS_HOUSE
		}
		modifier = {
			is_close_family_of = scope:secondary_recipient
			add = -10
			desc = TARGET_IS_MY_CLOSE_FAMILY
		}
		opinion_modifier = {
			opinion_target = scope:actor
			multiplier = 0.5
		}
		opinion_modifier = {
			opinion_target = scope:secondary_recipient
			multiplier = -0.5
		}
		modifier = {
			has_relation_rival = scope:secondary_recipient
			add = 10
			desc = THEY_ARE_MY_RIVAL
		}
		modifier = {
			add = -10
			desc = THEY_ARE_MY_FRIEND
			scope:secondary_recipient = { has_relation_friend = scope:recipient }
		}
		modifier = { # You're my friend :)
			add = 10
			desc = youre_my_friend_tt
			has_relation_friend = scope:actor
		}
		modifier = { # You're my rival >:(
			add = -10
			desc = ai_opinion.reason.relation.rival
			has_relation_rival = scope:actor
		}
		modifier = { # You're my guardian
			add = 10
			desc = youre_my_guardian_tt
			has_relation_guardian = scope:actor
		}
		ai_value_modifier = {
			ai_boldness = -0.2
			ai_honor = -0.2
		}
	}

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

	ai_will_do = {
		base = -25
		opinion_modifier = { # Opinion
			opinion_target = scope:recipient
			multiplier = -0.5
		}
		modifier = { # My rival
			add = 25
			scope:actor = { has_relation_rival = scope:recipient }
		}
		modifier = { # My friend
			add = -25
			scope:actor = { has_relation_friend = scope:recipient }
		}
		modifier = {
			scope:actor = {
				house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			}
			add = 15
		}

		# Avoid fellow movement members if possible
		#AGOT Disabled
		# modifier = {
		# 	is_in_same_movement_as = { TARGET = scope:recipient }
		# 	add = {
		# 		value = -10
		# 		if = {
		# 			limit = {
		# 				is_in_pro_hegemon_or_hegemon_movement = yes
		# 			}
		# 			multiply = 1.5
		# 		}
		# 	}
		# }
	}
}
start_raid_estate_interaction = {
	icon = icon_raid_estate
	interface_priority = 90
	category = interaction_category_hostile
	send_name = START_SCHEME 
	scheme = raid_estate
	ignores_pending_interaction_block = yes
	ai_frequency_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 24
		empire = 24
		hegemony = 24
	}

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

	filter_tags = { admin_house_head }

	cooldown = { years = 5 }

	highlighted_reason = start_raid_estate_interaction_HIGHLIGHTED

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

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

	is_shown = {
		scope:actor = {
			domicile ?= {
				OR = {
					is_domicile_type = estate
					is_domicile_type = east_asian_estate
					is_domicile_type = japanese_manor
					is_domicile_type = dragonkeep
				}
			}
		}
		scope:recipient.house.house_head ?= {
			domicile ?= {
				OR = {
					is_domicile_type = estate
					is_domicile_type = east_asian_estate
					is_domicile_type = japanese_manor
					is_domicile_type = dragonkeep
				}
			}
			is_independent_ruler = no
			top_liege = scope:actor.top_liege
			house != scope:actor.house
		}
		#AGOT Added
		scope:actor = {
			is_human = yes
		}
		scope:recipient = {
			is_human = yes
		}
	}

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

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

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

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

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

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

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


