﻿



# Set one of your children as heir
#This interaction is referenced in code! If it's renamed you have to ping a coder
designate_heir_interaction = {
	icon = heir

	category = interaction_category_diplomacy

	desc = designate_heir_interaction_desc

	is_shown = {
		trigger_if = {
			limit = { # Admin always has access to this - Recipient just need to be their child
				scope:actor = {
					government_allows = administrative
					any_held_title = {
						is_noble_family_title = yes
					}
				}
			}
			scope:recipient = {
				is_child_of = scope:actor
			}
		}
		trigger_else = { # Everyone else also needs to gain access to this interaction
			scope:recipient = {
				is_child_of = scope:actor
			}
			scope:actor = {
				can_designate_heir_trigger = yes
			}
		}
		NOR = {
			scope:recipient = scope:actor.designated_heir
			scope:recipient = scope:actor
		}
		trigger_if = {
			limit = {
				scope:actor = { NOT = { primary_title = title:e_byzantium } }
			}
			custom_description = {
				text = "dynasty_member_leads_election"
				scope:actor = {
					NAND = {
						primary_title = {
							has_title_law_flag = elective_succession_law
						}
						dynasty = primary_heir.dynasty
					}
				}
			}
		}
	}

	cost = {
		prestige = {
			value = {
				add = {
					if = {
						limit = {
							scope:actor = {
								government_allows = administrative
								any_held_title = {
									is_noble_family_title = yes
								}
							}
						}
						value = designate_heir_admin_prestige_cost
					}
					else = {
						value = designate_heir_cost
					}
					desc = BASE
				}
				if = {
					limit = {
						scope:actor = {
							government_has_flag = government_is_landless_adventurer
						}
					}
					multiply = {
						value = 0
						desc = "[adventurer|E]"
					}
				}
			}
		}
		influence = {
			value = {
				add = 0
				if = {
					limit = {
						scope:actor = {
							government_allows = administrative
							any_held_title = {
								is_noble_family_title = yes
							}
						}
					}
					add = {
						value = designate_heir_admin_influence_cost
						desc = "[administrative_government|E]"
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = { exists = scope:recipient }
			scope:recipient = {
				is_busy_in_events_localised = yes
				is_eunuch_trigger = no
				NOR = {
					has_trait = disinherited
					has_trait = devoted
					has_trait = order_member
					has_trait = bastard
				}
			}
		}
		scope:actor = {
			trigger_if = {
				limit = {
					government_allows = administrative
					any_held_title = {
						is_noble_family_title = yes
					}
				}
				prestige >= designate_heir_admin_prestige_cost
				influence >= designate_heir_admin_influence_cost
				
				custom_tooltip = {
					text = valid_co_emperor_candidate_liege_trigger
					scope:recipient.top_liege = scope:actor.top_liege
				}
			}
			trigger_else_if = {
				limit = {
					NOT = { government_has_flag = government_is_landless_adventurer }
				}
				prestige >= designate_heir_cost
			}
			trigger_else = {}
		}
		trigger_if = {
			limit = {
				scope:actor = {
					government_has_flag = government_is_landless_adventurer
				}
				exists = scope:recipient
			}
			scope:recipient = {
				is_adult = yes
			}
		}
		custom_tooltip = {
			text = designate_heir_interaction.tt.currently_coruling
			scope:actor = {
				NOT = { has_diarchy_active_parameter = diarchy_is_co_rulership }
			}
		}
	}

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

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = designate_heir_interaction_notification

				left_icon = scope:actor					
				right_icon = scope:recipient

				set_designated_heir = scope:recipient
			}
		}
	}

	auto_accept = yes
}
