#Interactions relating to the head of the dynasty

disinherit_interaction = {
	icon = icon_dynasty
	category = interaction_category_hostile
	interface_priority = 60

	desc = disinherit_interaction_desc
	use_diplomatic_range = no
	
	is_shown = {
		NOT = { 
			scope:recipient = scope:actor 

			AND = { # Explicit AND to ensure no funny business
				scope:recipient = { is_child_of = scope:actor }
				scope:actor.dynasty = {
					this = scope:recipient.dynasty
					has_dynasty_perk = fp2_coterie_legacy_5
				}
			}
		}

		scope:actor = {
			is_dynast = yes
			dynasty = scope:recipient.dynasty

		}
		scope:recipient = {
			NOT = {
				has_trait = disinherited
			}
		}
	}

	is_valid = {
		custom_description = {
			scope:actor.culture = {
				NOT = { has_cultural_parameter = cannot_disherit }
			} 
			text = "mystical_ancestors_disinherit"
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				NOT = { # in such cases, it will be free so no need to check for Renown
					scope:recipient = {
						OR = {
							has_trait = disputed_heritage
							any_secret = {
								secret_type = secret_disputed_heritage
								is_known_by = scope:actor
							}
							has_trait = bastard
						}
					}
				}
			}
			scope:actor.dynasty = {
				dynasty_prestige >= medium_dynasty_prestige_value
			}
		}

		scope:recipient = { is_busy_in_events_localised = yes }
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
		trigger_if = {
			limit = {
				scope:recipient = {
					NOR = {
						is_child_of = scope:actor
						is_grandchild_of = scope:actor
						is_great_grandchild_of = scope:actor
					}
				}
			}
			custom_description = {
				scope:recipient.top_liege = scope:actor.top_liege
				text = "same_realm_as"
			}
		}
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0020
		}
	}
	
	on_accept = {
		scope:actor = {
			stress_impact = {
				forgiving = minor_stress_impact_gain
				compassionate = minor_stress_impact_gain
			}
			
			#Legitimacy loss
			if = {
				limit = { has_legitimacy = yes }
				if = {
					limit = { scope:recipient = { is_primary_heir_of = scope:actor } }
					add_legitimacy = {
						value = medium_legitimacy_loss
						multiply = scope:actor.primary_title.tier
					}
				}
				else_if = {
					limit = { scope:recipient = { is_child_of = scope:actor } }
					add_legitimacy = {
						value = minor_legitimacy_loss
						multiply = scope:actor.primary_title.tier
					}
				}
				else = {
					add_legitimacy = {
						value = miniscule_legitimacy_loss
						multiply = scope:actor.primary_title.tier
					}
				}
			}
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = disinherit_interaction_notification

					left_icon = scope:actor					
					right_icon = scope:recipient

					scope:recipient = {
						show_as_tooltip = {
							disinherit_effect = { DISINHERITOR = scope:actor }
						}
					}
				}
			}
		}

		scope:recipient = {
			disinherit_effect = { DISINHERITOR = scope:actor }
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_loss
			DESC = clan_unity_disinheritance.desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		if = {
			limit = {
				scope:recipient = {
					any_secret = {
						secret_type = secret_disputed_heritage
						is_known_by = scope:actor
						save_temporary_scope_as = secret_to_reveal
					}
				}
			}

			scope:secret_to_reveal = {
				expose_secret = scope:recipient.mother
			}

			scope:recipient = {
				add_trait = disputed_heritage
			}
		}
	}
	
	cost = {
		renown = {
			value = {
				add = medium_dynasty_prestige_value
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = yes
						}
					}
					add = major_dynasty_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = no
							any_heir_title = {
								exists = holder
							}
						}
					}
					add = medium_dynasty_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							OR = {
								has_trait = disputed_heritage
								any_secret = {
									secret_type = secret_disputed_heritage
									is_known_by = scope:actor
								}
								has_trait = bastard
							}
						}
					}
					multiply = 0
				}
			}
		}
		prestige = {
			value = {
				add = medium_prestige_value
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = yes
						}
					}
					add = massive_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = no
							any_heir_title = {
								exists = holder
							}
						}
					}
					add = medium_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							OR = {
								has_trait = disputed_heritage
								any_secret = {
									secret_type = secret_disputed_heritage
									is_known_by = scope:actor
								}
								has_trait = bastard
							}
						}
					}
					multiply = 0
				}
			}
		}
	}
	
	auto_accept = yes

	ai_potential = {
		is_at_war = no
		NOT = {
			has_trait = forgiving
		}
	}
	
	ai_targets = {
		ai_recipients = dynasty
		max = 20
	}
	
	ai_frequency = 96
	
	ai_will_do = {
		base = 0
		
		modifier = {
			add = -100
			scope:actor = {
				OR = {
					legitimacy_level = 0
					legitimacy_level = 1
				}
			}
			scope:recipient = { is_primary_heir_of = scope:actor }
		}
		
		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
				}
			}
		}
		
		modifier = {
			add = 100
			scope:recipient = {
				is_primary_heir_of = scope:actor
				OR = {
					has_trait = inbred
					has_trait = intellect_bad_3
					has_trait = incapable
				}
			}
		}
		
		modifier = {
			add = 5
			ai_vengefulness >= medium_positive_ai_value
			scope:recipient = {
				is_heir_of = scope:actor
			}
			OR = {
				AND = {
					scope:recipient = {
						has_trait = incestuous
					}
					NOT = { is_incestuous_trigger = yes }
					trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = kinslayer
					}
					NOT = { has_trait = kinslayer }
				}
				AND = {
					scope:recipient = {
						has_trait = adulterer
					}
					NOR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = fornicator
					}
					NOR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = deviant
					}
					NOT = {
						is_deviant_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = witch
					}
					NOT = {
						is_witch_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = sodomite
					}
					NOR = {
						has_trait = sodomite
						any_secret = {
							secret_type = secret_homosexual
						}
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = cannibal
					}
					NOT = {
						is_cannibal_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
			}
		}

		# Unity modifiers
		evaluate_action_decreasing_house_unity = {
			VALUE = 100
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_best_friend = scope:actor
				}
			}
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				is_ai = no
			}
		}
	}
}

disinherit_children_interaction = {
	icon = icon_dynasty
	category = interaction_category_hostile
	interface_priority = 60

	desc = disinherit_children_interaction_desc
	use_diplomatic_range = no

	is_shown = {
		# DLC checking
		has_fp2_dlc_trigger = yes
		# Standard check
		NOT = { scope:recipient = scope:actor }

		scope:actor.dynasty = {
			this = scope:recipient.dynasty
			has_dynasty_perk = fp2_coterie_legacy_5
		}
		scope:recipient = {
			NOT = {
				has_trait = disinherited
			}
		}
	}

	is_valid = {
		scope:actor = { is_parent_of = scope:recipient }


		custom_description = {
			scope:actor.culture = {
				NOT = { has_cultural_parameter = cannot_disherit }
			}
			text = "mystical_ancestors_disinherit"
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			prestige >= major_prestige_value
		}
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
		trigger_if = {
			limit = {
				scope:recipient = {
					NOR = {
						is_child_of = scope:actor
						is_grandchild_of = scope:actor
						is_great_grandchild_of = scope:actor
					}
				}
			}
			custom_description = {
				scope:recipient.top_liege = scope:actor.top_liege
				text = "same_realm_as"
			}
		}
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0020
		}
	}

	on_accept = {
		scope:actor = {
			stress_impact = {
				forgiving = minor_stress_impact_gain
				compassionate = minor_stress_impact_gain
			}
			add_tyranny = massive_tyranny_value
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = disinherit_interaction_notification

					left_icon = scope:actor
					right_icon = scope:recipient

					scope:recipient = {
						show_as_tooltip = {
							disinherit_effect = { DISINHERITOR = scope:actor }
						}
					}
				}
			}
		}

		scope:recipient = {
			disinherit_effect = { DISINHERITOR = scope:actor }
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_disinheritance.desc
			REVERSE_NON_HOUSE_TARGET = no
		}		
	}

	cost = {
		prestige = {
			value = {
				add = medium_prestige_value
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = yes
						}
					}
					add = massive_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = no
							any_heir_title = {
								exists = holder
							}
						}
					}
					add = medium_prestige_value
				}
			}
		}
	}

	auto_accept = yes

	ai_potential = {
		is_at_war = no
		NOT = {
			has_trait = forgiving
		}
	}

	ai_targets = {
		ai_recipients = dynasty
		max = 20
	}

	ai_frequency = 96

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
				}
			}
		}

		modifier = {
			add = 100
			scope:recipient = {
				is_primary_heir_of = scope:actor
				OR = {
					has_trait = inbred
					has_trait = intellect_bad_3
					has_trait = incapable
				}
			}
		}

		modifier = {
			add = 5
			ai_vengefulness >= medium_positive_ai_value
			scope:recipient = {
				is_heir_of = scope:actor
			}
			OR = {
				AND = {
					scope:recipient = {
						has_trait = incestuous
					}
					NOT = { is_incestuous_trigger = yes }
					trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = kinslayer
					}
					NOT = { has_trait = kinslayer }
				}
				AND = {
					scope:recipient = {
						has_trait = adulterer
					}
					NOR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = fornicator
					}
					NOR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = deviant
					}
					NOT = {
						is_deviant_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = witch
					}
					NOT = {
						is_witch_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = sodomite
					}
					NOR = {
						has_trait = sodomite
						any_secret = {
							secret_type = secret_homosexual
						}
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = cannibal
					}
					NOT = {
						is_cannibal_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
			}
		}

		# Unity modifiers
		evaluate_action_decreasing_house_unity = {
			VALUE = 100
		}

		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_best_friend = scope:actor
				}
			}
		}

		modifier = {
			factor = 0
			scope:recipient = {
				is_ai = no
			}
		}
	}
}

restore_inheritance_interaction = {
	icon = icon_dynasty
	category = interaction_category_friendly
	desc = restore_inheritance_interaction_desc

	interface_priority = 60

	is_shown = {
		scope:actor = {
			is_dynast = yes
			dynasty = scope:recipient.dynasty

		}
		scope:recipient = {
			has_trait = disinherited
		}
	}

	is_valid_showing_failures_only = {
		scope:actor.dynasty ={
			dynasty_prestige >= miniscule_dynasty_prestige_value
		}
		scope:recipient = { is_busy_in_events_localised = yes }
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0030
		}
	}
	
	on_accept = {
		scope:actor = {
			stress_impact = {
				vengeful = minor_stress_impact_gain
				stubborn = minor_stress_impact_gain
			}
			hidden_effect = {
				send_interface_message = {
					type = event_dynasty_neutral
					title = restore_inheritance_interaction_notification
					right_icon = scope:recipient
					show_as_tooltip = {
						scope:recipient = {
							restore_inheritance_effect = yes
						}
					}
				}
			}
		}

		scope:recipient = {
			restore_inheritance_effect = yes
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_gain
			DESC = clan_unity_re_inheritance.desc
			REVERSE_NON_HOUSE_TARGET = no
		}		
	}

	cost = {
		renown = {
			value = medium_dynasty_prestige_value
		}
	}
	
	auto_accept = yes

	ai_potential = {
		is_at_war = no
	}
	
	ai_targets = {
		ai_recipients = dynasty
		max = 20
	}
	
	ai_frequency = 120
	
	ai_will_do = {
		base = 0
		
		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_best_friend = scope:actor
				}
			}
		}
		
		modifier = {
			add = 5
			ai_vengefulness <= medium_negative_ai_value
		}
		
		modifier = {
			add = 100
			scope:recipient = scope:actor
		}

		# Unity modifiers
		evaluate_action_increasing_house_unity = {
			VALUE = 100
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
				}
			}
		}
	}
}

denounce_interaction = {
	icon = icon_dynasty
	category = interaction_category_hostile
	interface_priority = 60

	desc = denounce_interaction_desc
	
	is_shown = {
		NOT = { scope:recipient = scope:actor }

		scope:actor = {
			is_dynast = yes
			dynasty = scope:recipient.dynasty
		}
		scope:recipient = {
			NOT = {
				has_trait = denounced
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor.dynasty = {
			dynasty_prestige >= minor_dynasty_prestige_value
		}
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
		custom_tooltip = {
			text = cannot_take_overt_hostile_actions_against_diarch.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0040
		}
	}
	
	on_accept = {
		scope:actor = {
			stress_impact = {
				forgiving = minor_stress_impact_gain
				compassionate = minor_stress_impact_gain
			}

			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = denounce_interaction_notification

					left_icon = scope:actor					
					right_icon = scope:recipient

					scope:recipient = {
						show_as_tooltip = {
							denounce_effect = { ACTOR = scope:actor RECIPIENT = scope:recipient }
						}
					}
				}
			}
		}

		scope:recipient = {
			denounce_effect = { ACTOR = scope:actor RECIPIENT = scope:recipient }
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_denouncement.desc
			REVERSE_NON_HOUSE_TARGET = no
		}		
	}

	cost = {
		renown = {
			value = {
				add = minor_dynasty_prestige_value
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = yes
						}
					}
					add = medium_dynasty_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = no
							any_heir_title = {
								exists = holder
							}
						}
					}
					add = minor_dynasty_prestige_value
				}
			}
		}
		prestige = {
			value = {
				add = medium_prestige_value
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = yes
						}
					}
					add = major_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed_or_landless_administrative = no
							any_heir_title = {
								exists = holder
							}
						}
					}
					add = medium_prestige_value
				}
			}
		}
	}
	
	auto_accept = yes

	ai_potential = {
		is_adult = yes
		NOT = {
			has_trait = forgiving
		}
	}
	
	ai_targets = {
		ai_recipients = dynasty
		max = 20
	}
	
	ai_frequency = 96
	
	ai_will_do = {
		base = 0
		
		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
				}
			}
		}
		
		modifier = {
			add = 5
			ai_vengefulness >= medium_positive_ai_value
			OR = {
				AND = {
					scope:recipient = {
						has_trait = incestuous
					}
					NOT = { is_incestuous_trigger = yes }
					trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = kinslayer
					}
					NOT = { has_trait = kinslayer }
				}
				AND = {
					scope:recipient = {
						has_trait = adulterer
					}
					NOR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = fornicator
					}
					NOR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = deviant
					}
					NOT = {
						is_deviant_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = witch
					}
					NOT = {
						is_witch_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = sodomite
					}
					NOR = {
						has_trait = sodomite
						any_secret = {
							secret_type = secret_homosexual
						}
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
				AND = {
					scope:recipient = {
						has_trait = cannibal
					}
					NOT = {
						is_cannibal_trigger = yes
					}
					trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient }
				}
			}
		}

		# Unity modifiers
		evaluate_action_decreasing_house_unity = {
			VALUE = 100
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_best_friend = scope:actor
				}
			}
		}
	}
}

forgive_interaction = {
	icon = icon_dynasty
	category = interaction_category_friendly
	interface_priority = 60

	desc = forgive_interaction_desc
	
	is_shown = {
		NOT = { scope:recipient = scope:actor }

		scope:actor = {
			is_dynast = yes
			dynasty = scope:recipient.dynasty
		}
		scope:recipient = {
			has_trait = denounced
		}
	}

	is_valid_showing_failures_only = {
		scope:actor.dynasty = {
			dynasty_prestige >= miniscule_dynasty_prestige_value
		}
		scope:recipient = { is_busy_in_events_localised = yes }
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0050
		}
	}

	on_accept = {
		scope:actor = {
			stress_impact = {
				vengeful = minor_stress_impact_gain
				stubborn = minor_stress_impact_gain
			}
			hidden_effect = {
				send_interface_message = {
					type = event_generic_neutral
					title = forgive_interaction_notification
					right_icon = scope:recipient
					show_as_tooltip = {
						scope:recipient = {
							forgive_effect = yes
						}
					}
				}
			}
		}

		scope:recipient = {
			forgive_effect = yes
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_gain
			DESC = clan_unity_forgiveness.desc
			REVERSE_NON_HOUSE_TARGET = no
		}		
	}

	cost = {
		renown = {
			value = miniscule_dynasty_prestige_value
		}
	}
	
	auto_accept = yes

	ai_potential = {
		is_at_war = no
	}
	
	ai_targets = {
		ai_recipients = dynasty
		max = 20
	}
	
	ai_frequency = 120
	
	ai_will_do = {
		base = 0
		
		modifier = {
			add = 100
			scope:recipient = {
				OR = {
					has_relation_friend = scope:actor
					has_relation_best_friend = scope:actor
				}
			}
		}
		
		modifier = {
			add = 5
			ai_vengefulness <= medium_negative_ai_value
		}
		
		modifier = {
			add = 100
			scope:recipient = scope:actor
		}

		# Unity modifiers
		evaluate_action_increasing_house_unity = {
			VALUE = 100
		}
		
		modifier = {
			factor = 0
			scope:recipient = {
				OR = {
					has_relation_rival = scope:actor
					has_relation_nemesis = scope:actor
				}
			}
		}
	}
}

call_dynasty_member_to_war_interaction = {
	icon = icon_dynasty
	category = interaction_category_diplomacy
	interface_priority = 60

	desc = call_dynasty_member_to_war_interaction_desc
	
	interface = call_ally
	special_interaction = call_ally_interaction
	popup_on_receive = yes
	pause_on_receive = yes
	
	greeting = positive
	notification_text = CALL_DYNASTY_MEMBER_NOTIFICATION
	
	is_shown = {
		NOT = { scope:recipient = scope:actor }

		scope:actor = {
			is_dynast = yes
			religion = scope:recipient.religion
			dynasty = scope:recipient.dynasty
			NOT = { house = scope:recipient.house } # Use the House Head version instead
			any_character_war = {
				is_war_leader = scope:actor
			}
		}
		scope:recipient = {
			is_ruler = yes
		}

		scope:recipient = {
			NOT = {
				target_is_liege_or_above = scope:actor
			}
		}
	}
	
	has_valid_target = {
		exists = scope:target
	}

	has_valid_target_showing_failures_only = {
		scope:target = {
			is_war_leader = scope:actor
		}
		joiner_not_already_in_another_war_with_any_target_war_participants_trigger = {
			WARRIOR = scope:actor
			JOINER = scope:recipient
		}
	}

	is_valid_showing_failures_only = {
		scope:actor.dynasty = { dynasty_prestige >= medium_dynasty_prestige_value }
		scope:recipient = {
			NOT = { government_has_flag = government_is_mercenary }
			NOT = { government_has_flag = government_is_holy_order }
		}
		custom_description = {
			text = "is_already_in_all_wars"
			scope:actor = {
				any_character_war = {
					NOR = {
						is_participant = scope:recipient
						was_called = scope:recipient
					}
					OR = {
						primary_attacker = scope:actor
						primary_defender = scope:actor
					}
				}
			}
		}
	}

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

	on_auto_accept = {
		scope:recipient = {
			trigger_event = call_ally.0001
		}
	}
		
	on_accept = {
		call_dynasty_member_to_war_interaction_effect = yes

		save_scope_value_as = {
			name = call_dynasty_member_to_war_interaction
			value = yes
		}

		if = {
			limit = {
				exists = scope:target
			}
			scope:actor = {
				trigger_event = call_ally.0100
			}
		}
	}
	
	on_decline = {
		#The war could theoretically end on the day the decline is sent
		if = {
			limit = {
				exists = scope:target
			}
			scope:target = {
				if = {
					limit = {
						is_attacker = scope:actor
					}
					scope:actor = {
						add_opinion = {
							modifier = rejected_call_to_offensive_war
							target = scope:recipient
						}
					}
				}
				else = {
					scope:actor = {
						add_opinion = {
							modifier = rejected_call_to_defensive_war
							target = scope:recipient
						}
					}
				}
				hidden_effect = {
					if = {
						limit = {
							NOT = { was_called = scope:recipient }
						}
						set_called_to = scope:recipient
					}
				}
			}
			scope:actor.dynasty = {
				add_dynasty_prestige = medium_dynasty_prestige_loss
			}
		}

		if = {
			limit = {
				exists = scope:target
			}
			scope:actor = {
				trigger_event = call_ally.0101
			}
		}
	}
	
	ai_accept = {
		base = 20

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

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

		modifier = {  # Refuse call against Spouse
			add = -1000
			scope:recipient = {
				trigger_if = {
					limit = { scope:target.casus_belli.primary_defender = scope:actor }
					any_spouse = {
						this = scope:target.casus_belli.primary_attacker
					}
				}
				trigger_else = {
					any_spouse = {
						this = scope:target.casus_belli.primary_defender
					}
				}
				
			}
			desc = WONT_FIGHT_SPOUSE_REASON
		}
		
		modifier = {  # Reluctant when already at war
			add = -50
			scope:recipient = {
				is_at_war = yes
			}
			desc = ALREADY_AT_WAR
		}

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

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

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

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

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

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

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

		fp3_struggle_resist_allied_wars_modifier = yes
	}

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

	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
}

dynast_claim_title_interaction = {
	icon = icon_dynasty
	category = interaction_category_diplomacy
	desc = dynast_claim_title_interaction_desc
	target_type = title
	target_filter = recipient_domain_titles
	ignores_pending_interaction_block = yes
	cost = { renown = major_dynasty_prestige_value }
	is_shown = {
		NOT = { scope:recipient = scope:actor }

		scope:actor = {
			is_dynast = yes
			religion = scope:recipient.religion
			dynasty = scope:recipient.dynasty
		}

		scope:recipient = {
			is_playable_character = yes
		}
	}
	
	can_be_picked = {
		custom_description = {
			scope:target = { NOT = { any_claimant = { this = scope:actor } } }
			text = "already_have_a_claim_on_this_title"
		}
	}

	is_valid_showing_failures_only = {
		custom_description = {
			scope:recipient = {
				any_held_title = {
					tier >= tier_county
					NOT = { any_claimant = { this = scope:actor } }
				} 
			}

			object = scope:recipient
			text = "already_have_claims_on_all_titles"
		}
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0060
		}
	}
	
	on_accept = {
		dynast_claim_title_effect = yes
		scope:actor = {
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = dynast_claim_title_interaction_notification

					left_icon = scope:actor					
					right_icon = scope:recipient

					show_as_tooltip = {
						dynast_claim_title_effect = yes
					}
				}
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_loss
			DESC = clan_unity_title_claim.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	auto_accept = yes
}

dynast_end_dynasty_wars_interaction = {
	icon = icon_dynasty
	category = interaction_category_diplomacy
	desc = dynast_end_dynasty_wars_interaction_desc

	is_shown = {
		NOT = { scope:actor = scope:recipient }
		
		scope:actor = {
			is_dynast = yes
			religion = scope:recipient.religion
			dynasty = scope:recipient.dynasty
		}

		scope:recipient = {
			is_playable_character = yes
			any_character_war = {
				NOT = { primary_defender = scope:actor }
				primary_attacker = scope:recipient
				primary_defender.dynasty = scope:recipient.dynasty
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor.dynasty = {
			dynasty_prestige >= medium_dynasty_prestige_value
		}
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:actor = {
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
	}

	on_auto_accept = {
		scope:recipient = {
			trigger_event = char_interaction.0070
		}
	}

	on_accept = {

		scope:actor = {
			hidden_effect = {
				send_interface_message = {
					type = event_dynasty_neutral
					title = dynast_end_dynasty_wars_interaction_notification
					right_icon = scope:recipient
					show_as_tooltip = {
						dynast_end_dynasty_wars_effect = yes
					}
				}
			}
		}
		dynast_end_dynasty_wars_effect = yes
	}

	auto_accept = yes
}

dynast_legitimize_bastard_interaction = {
	icon = icon_dynasty
	category = interaction_category_diplomacy
	desc = dynast_legitimize_bastard_interaction_desc

	is_shown = {
		scope:actor = scope:recipient.dynasty.dynast
		scope:actor = {
			religion = scope:recipient.religion
			NOT = { house = scope:recipient.house }
			faith = { has_doctrine_parameter = bastards_legitimize }
		}
		scope:recipient = {
			has_trait = bastard
			faith = { has_doctrine_parameter = bastards_legitimize }
		}
	}

	is_valid = {
		scope:actor.dynasty = {
			dynasty_prestige >= medium_dynasty_prestige_value
		}
		scope:recipient = { is_busy_in_events_localised = yes }
	}

	auto_accept = yes

	cost = {
		renown = medium_dynasty_prestige_value
	}
	
	on_accept = {
		scope:actor = {
			stress_impact = {
				arrogant = minor_stress_impact_gain
			}
			send_interface_message = {
				type = event_dynasty_neutral
				title = dynast_legitimize_bastard_interaction_notification
				right_icon = scope:recipient
				show_as_tooltip = {
					scope:recipient = {
						add_trait_force_tooltip = legitimized_bastard
						add_opinion = {
							target = scope:actor
							modifier = legitimized_me_opinion
						}
					}
				}
			}
		}
		
		hidden_effect = {
			scope:recipient = {
				trigger_event = bastard_interaction.0009
				every_parent = {
					limit = {
						is_playable_character = yes
						NOT = { this = scope:actor }
					}
					hidden_effect = { #Nudge towards friendship
						if = {
							limit = {
								NOR = {
									has_relation_friend = scope:actor
									has_relation_potential_friend = scope:actor
								}
							}
							set_relation_potential_friend = scope:actor
						}
					}
					trigger_event = bastard_interaction.0010
				}
				every_sibling = {
					limit = {
						is_playable_character = yes
						NOT = { this = scope:actor }
					}
					trigger_event = bastard_interaction.0010
				}
			}
		}
	}
}

send_to_varangian_guard_interaction = {
	category = interaction_category_friendly
	interface_priority = 60
	icon = send_to_varangian_guard_interaction

	desc = send_to_varangian_guard_interaction_desc
	use_diplomatic_range = no
	common_interaction = yes
	
	is_shown = {
		NOT = { scope:recipient = scope:actor }

		scope:actor = {
			is_dynast = yes
			dynasty = scope:recipient.dynasty
			
			dynasty = {
				has_dynasty_perk = fp1_adventure_legacy_1
			}
			
			exists = title:e_byzantium.holder
			NOR = {
				faith = {
					has_doctrine_parameter = pacifist_opinion_active
				}
				this = title:e_byzantium.holder
				has_truce = title:e_byzantium.holder
				is_at_war_with = title:e_byzantium.holder
			}
		}
	}
	
	cooldown = { years = 2 }

	is_valid_showing_failures_only = {
		scope:actor = {
			is_at_war = no
			NOT = {
				has_relation_rival = title:e_byzantium.holder
			}
		}
		scope:recipient = {
			is_busy_in_events_localised = yes
			is_ruler = no
			is_adult = yes
			is_married = no
			NOT = {
				has_trait = varangian
			}
		}
		trigger_if = {
			limit = {
				scope:recipient = {
					is_adult = yes
					NOT = {
						can_be_knight_trigger = {
							ARMY_OWNER = title:e_byzantium.holder
						}
					}
				}
			}
			custom_description = {
				scope:recipient = {
					can_be_knight_trigger = {
						ARMY_OWNER = title:e_byzantium.holder
					}
				}
				text = "not_allowed_in_varangian_guard"
			}
		}
		trigger_if = {
			limit = {
				scope:recipient = {
					NOR = {
						is_child_of = scope:actor
						is_grandchild_of = scope:actor
						is_great_grandchild_of = scope:actor
					}
				}
			}
			custom_description = {
				scope:recipient.top_liege = scope:actor.top_liege
				text = "same_realm_as"
			}
		}
	}
	
	on_accept = {
		title:e_byzantium.holder = {
			save_scope_as = emperor
			if = {
				limit = { capital_county = title:c_byzantion }
				set_local_variable = {
					name = to_miklagard
					value = yes
				}
			}
		}
		
		scope:actor = {
			stress_impact = {
				paranoid = minor_stress_impact_gain
			}
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = send_to_varangian_guard_interaction_toast

					left_icon = scope:recipient					
					right_icon = scope:emperor
					
					custom_tooltip = send_to_varangian_guard_interaction_toast_desc
				}
			}
		}

		scope:recipient = {
			save_scope_as = varangian_candidate
			
		}
		
		show_as_tooltip = {
			scope:varangian_candidate = {
				visit_court_of = scope:emperor
				add_trait = varangian
				custom_description_no_bullet = {
					text = send_to_varangian_guard_interaction_effect
				}
			}
		}
		hidden_effect = {
			scope:emperor = {
				trigger_event = varangian.0003
			}
		}
		
		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = miniscule_unity_loss
			DESC = clan_unity_vaering.desc
			REVERSE_NON_HOUSE_TARGET = no
		}		
	}
	
	cost = {
		prestige = {
			value = 350
		}
	}
	
	auto_accept = yes

	ai_potential = {
		is_at_war = no
		is_dynast = yes
		
		dynasty = {
			has_dynasty_perk = fp1_adventure_legacy_1
		}
		
		exists = title:e_byzantium.holder
		NOR = {
			faith = {
				has_doctrine_parameter = pacifist_opinion_active
			}
			this = title:e_byzantium.holder
			has_truce = title:e_byzantium.holder
			is_at_war_with = title:e_byzantium.holder
		}
	}
	
	ai_targets = {
		ai_recipients = children
		max = 10
	}
	
	ai_frequency = 120
	
	ai_will_do = {
		base = 100
	}
}
