﻿#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
				add = 15
				if = {
					limit = {
						scope:recipient = {
							is_landed = yes
						}
					}
					add = major_dynasty_prestige_value
					add = 10
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed = no
							any_heir_title = {
								exists = holder
							}
						}
					}
					add = medium_dynasty_prestige_value
					add = 10
				}
				if = {
					limit = {
						scope:recipient = {
							OR = {
								has_trait = disputed_heritage
								any_secret = {
									secret_type = secret_disputed_heritage
									is_known_by = scope:actor
								}
								has_trait = bastard
							}
						}
					}
					if = { limit = { has_game_rule = reb_disinherit_150 } multiply = 0.05 }
					else_if = { limit = { has_game_rule = reb_disinherit_200 } multiply = 0.1 }
					else = { multiply = 0 }
				}
				if = { limit = { scope.actor = { is_ai = no } }
					if = { limit = { has_game_rule = reb_disinherit_150 } multiply = 1.5 }
					else_if = { limit = { has_game_rule = reb_disinherit_200 } multiply = 2 }
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 1 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.07 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.13 } else = { multiply = 1.2 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 2 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.17 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.33 } else = { multiply = 1.5 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 3 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.3 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.16 } else = { multiply = 1.9 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 4 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.45 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.9 } else = { multiply = 2.35 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 5 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.63 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 2.25 } else = { multiply = 2.9 } }
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 6 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.96 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 2.9 } else = { multiply = 3.9 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 7 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 2.19 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 3.38 } else = { multiply = 4.6 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 8 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 2.57 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 4.17 } else = { multiply = 5.75 } } 
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 9 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 3.05 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 5.09 } else = { multiply = 7.2 } }
					if = { limit = { scope:actor.dynasty.dynasty_prestige_level = 10 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 3.64 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 6.28 } else = { multiply = 1.2 } }
					#SHARPNESS GOOD
					if = { limit = { scope:recipient = { has_trait = intellect_good_1 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.033 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.066 } else = { multiply = 1.1 } }
					if = { limit = { scope:recipient = { has_trait = intellect_good_2 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.05 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.1 } else = { multiply = 1.15 } }
					if = { limit = { scope:recipient = { has_trait = intellect_good_3 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.08 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.16 } else = { multiply = 1.25 } }
					#SHARPNESS BAD
					if = { limit = { scope:recipient = { has_trait = intellect_bad_1 } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = intellect_bad_2 } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = intellect_bad_3 } } multiply = 0.75 }     
					#MAJOR FLAW
					if = { limit = { scope:recipient = { has_trait = infertile } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = inbred } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = incapable } } multiply = 0.7 }
					#MINOR FLAW
					if = { limit = { scope:recipient = { has_trait = infirm } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = impotent } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = sickly } } multiply = 0.95 }
					#COPING FLAWS
					if = { limit = { scope:recipient = { has_trait = drunkard } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = flagellant } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = comfort_eater } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = contrite } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = improvident } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = inappetetic } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = reclusive } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = irritable } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = rakish } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = hashishiyah } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = profligate } } multiply = 0.95 }
					#FAME TRAITS
					if = { limit = { scope:recipient = { has_trait = adulterer } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = deviant } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_1 } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_2 } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_3 } } multiply = 0.8 }
					if = { limit = { scope:recipient = { has_trait = incestuous } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = sodomite } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = witch } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = cannibal } } multiply = 0.7 }
					if = { limit = { scope:recipient = { has_trait = excommunicated } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = murderer } } multiply = 0.95 }
					#OTHER TRAITS
					if = { limit = { scope:recipient = { has_trait = faith_warrior } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.07 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.14 } else = { multiply = 1.2 } }
					if = { limit = { scope:recipient = { has_trait = crusader_king } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.14 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.28 } else = { multiply = 1.4 } }
					if = { limit = { scope:recipient = { has_trait = disloyal } } multiply = 0.85 }
					if = {
						limit = {
							scope:recipient = {
								OR = {
									has_trait = reincarnation
									has_trait = august
									has_trait = reincarnation
									has_trait = saint
									has_trait = legend
									has_trait = golden_lineage
									has_trait = blood_of_prophet
								}
							}
						}
					if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.17 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.34 } else = { multiply = 1.5 }
					}
				}
			}
		}
		prestige = {
			value = {
				add = medium_prestige_value
				if = {
					limit = {
						scope:recipient = {
							is_landed = yes
						}
					}
					add = massive_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed = 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
							}
						}
					}
					if = { limit = { has_game_rule = reb_disinherit_150 } multiply = 0.05 }
					else_if = { limit = { has_game_rule = reb_disinherit_200 } multiply = 0.1 }
					else = { multiply = 0 }
				}
				if = { limit = { scope.actor = { is_ai = no } }
					if = { limit = { has_game_rule = reb_disinherit_150 } multiply = 1.5 }
					else_if = { limit = { has_game_rule = reb_disinherit_200 } multiply = 2 }
					if = { limit = { scope:actor.prestige_level = 1 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.09 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.2 } else = { multiply = 1.3 } }
					if = { limit = { scope:actor.prestige_level = 2 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.33 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.66 } else = { multiply = 2 } }
					if = { limit = { scope:actor.prestige_level = 3 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.73 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 2.45 } else = { multiply = 3.2 } }
					if = { limit = { scope:actor.prestige_level = 4 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 2.35 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 3.71 } else = { multiply = 5.1 } }
					if = { limit = { scope:actor.prestige_level = 5 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 3.64 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 6.28 } else = { multiply = 8 } }
					#SHARPNESS GOOD
					if = { limit = { scope:recipient = { has_trait = intellect_good_1 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.033 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.066 } else = { multiply = 1.1 } }
					if = { limit = { scope:recipient = { has_trait = intellect_good_2 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.05 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.1 } else = { multiply = 1.15 } }
					if = { limit = { scope:recipient = { has_trait = intellect_good_3 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.08 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.16 } else = { multiply = 1.25 } }
					#SHARPNESS BAD
					if = { limit = { scope:recipient = { has_trait = intellect_bad_1 } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = intellect_bad_2 } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = intellect_bad_3 } } multiply = 0.75 }     
					#MAJOR FLAW
					if = { limit = { scope:recipient = { has_trait = infertile } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = inbred } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = incapable } } multiply = 0.7 }
					#MINOR FLAW
					if = { limit = { scope:recipient = { has_trait = infirm } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = impotent } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = sickly } } multiply = 0.95 }
					#COPING FLAWS
					if = { limit = { scope:recipient = { has_trait = drunkard } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = flagellant } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = comfort_eater } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = contrite } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = improvident } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = inappetetic } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = reclusive } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = irritable } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = rakish } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = hashishiyah } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = profligate } } multiply = 0.95 }
					#FAME TRAITS
					if = { limit = { scope:recipient = { has_trait = adulterer } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = deviant } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_1 } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_2 } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_3 } } multiply = 0.8 }
					if = { limit = { scope:recipient = { has_trait = incestuous } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = sodomite } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = witch } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = cannibal } } multiply = 0.7 }
					if = { limit = { scope:recipient = { has_trait = excommunicated } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = murderer } } multiply = 0.95 }
					#OTHER TRAITS
					if = { limit = { scope:recipient = { has_trait = faith_warrior } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.07 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.14 } else = { multiply = 1.2 } }
					if = { limit = { scope:recipient = { has_trait = crusader_king } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.14 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.28 } else = { multiply = 1.4 } }
					if = { limit = { scope:recipient = { has_trait = disloyal } } multiply = 0.85 }
					if = {
						limit = {
							scope:recipient = {
								OR = {
									has_trait = reincarnation
									has_trait = august
									has_trait = reincarnation
									has_trait = saint
									has_trait = legend
									has_trait = golden_lineage
									has_trait = blood_of_prophet
								}
							}
						}
					if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.17 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.34 } else = { multiply = 1.5 }
					}
				}
			}
		}
	}
	
	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 = yes
						}
					}
					add = massive_prestige_value
				}
				if = {
					limit = {
						scope:recipient = {
							is_landed = 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
							}
						}
					}
					if = { limit = { has_game_rule = reb_disinherit_150 } multiply = 0.05 }
					else_if = { limit = { has_game_rule = reb_disinherit_200 } multiply = 0.1 }
					else = { multiply = 0 }
				}
				if = { limit = { scope.actor = { is_ai = no } }
					if = { limit = { has_game_rule = reb_disinherit_150 } multiply = 1.5 }
					else_if = { limit = { has_game_rule = reb_disinherit_200 } multiply = 2 }
					if = { limit = { scope:actor.prestige_level = 1 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.09 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.2 } else = { multiply = 1.3 } }
					if = { limit = { scope:actor.prestige_level = 2 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.33 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.66 } else = { multiply = 2 } }
					if = { limit = { scope:actor.prestige_level = 3 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.73 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 2.45 } else = { multiply = 3.2 } }
					if = { limit = { scope:actor.prestige_level = 4 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 2.35 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 3.71 } else = { multiply = 5.1 } }
					if = { limit = { scope:actor.prestige_level = 5 } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 3.64 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 6.28 } else = { multiply = 8 } }
					#SHARPNESS GOOD
					if = { limit = { scope:recipient = { has_trait = intellect_good_1 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.033 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.066 } else = { multiply = 1.1 } }
					if = { limit = { scope:recipient = { has_trait = intellect_good_2 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.05 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.1 } else = { multiply = 1.15 } }
					if = { limit = { scope:recipient = { has_trait = intellect_good_3 } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.08 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.16 } else = { multiply = 1.25 } }
					#SHARPNESS BAD
					if = { limit = { scope:recipient = { has_trait = intellect_bad_1 } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = intellect_bad_2 } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = intellect_bad_3 } } multiply = 0.75 }     
					#MAJOR FLAW
					if = { limit = { scope:recipient = { has_trait = infertile } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = inbred } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = incapable } } multiply = 0.7 }
					#MINOR FLAW
					if = { limit = { scope:recipient = { has_trait = infirm } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = impotent } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = sickly } } multiply = 0.95 }
					#COPING FLAWS
					if = { limit = { scope:recipient = { has_trait = drunkard } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = flagellant } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = comfort_eater } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = contrite } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = improvident } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = inappetetic } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = reclusive } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = irritable } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = rakish } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = hashishiyah } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = profligate } } multiply = 0.95 }
					#FAME TRAITS
					if = { limit = { scope:recipient = { has_trait = adulterer } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = deviant } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_1 } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_2 } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = kinslayer_3 } } multiply = 0.8 }
					if = { limit = { scope:recipient = { has_trait = incestuous } } multiply = 0.95 }
					if = { limit = { scope:recipient = { has_trait = sodomite } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = witch } } multiply = 0.85 }
					if = { limit = { scope:recipient = { has_trait = cannibal } } multiply = 0.7 }
					if = { limit = { scope:recipient = { has_trait = excommunicated } } multiply = 0.9 }
					if = { limit = { scope:recipient = { has_trait = murderer } } multiply = 0.95 }
					#OTHER TRAITS
					if = { limit = { scope:recipient = { has_trait = faith_warrior } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.07 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.14 } else = { multiply = 1.2 } }
					if = { limit = { scope:recipient = { has_trait = crusader_king } } if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.14 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.28 } else = { multiply = 1.4 } }
					if = { limit = { scope:recipient = { has_trait = disloyal } } multiply = 0.85 }
					if = {
						limit = {
							scope:recipient = {
								OR = {
									has_trait = reincarnation
									has_trait = august
									has_trait = reincarnation
									has_trait = saint
									has_trait = legend
									has_trait = golden_lineage
									has_trait = blood_of_prophet
								}
							}
						}
					if = { limit = { has_game_rule = reb_disinherit_33 } multiply = 1.17 } else_if = { limit = { has_game_rule = reb_disinherit_66 } multiply = 1.34 } else = { multiply = 1.5 }
					}
				}
			}
		}
	}

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

denounce_interaction = {
	icon = icon_dynasty
	category = interaction_category_hostile
	interface_priority = 59 #after disinherit

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

	is_valid = {
		scope:recipient = { 
			OR = {
				has_trait = kinslayer_1
				has_trait = kinslayer_2
				has_trait = kinslayer_3
				has_trait = fornicator
				has_trait = adulterer
				has_trait = incapable
				has_trait = disinherited
				has_trait = disloyal
				has_trait = lazy
				has_trait = depressed
				has_trait = lunatic
				has_trait = possessed
				has_trait = dull
				has_trait = intellect_bad_3
				has_trait = cannibal
			}
			NOR = {
				has_trait = august
				has_trait = reincarnation
				has_trait = saint
				has_trait = legend
				has_trait = golden_lineage
				has_trait = blood_of_prophet
				has_trait = crusader_king
			}
		}
	}

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