﻿abdicate_interaction = {
	category = interaction_category_friendly
	common_interaction = yes
	desc = abdicate_interaction.desc
	interface_priority = 90
	auto_accept = yes
	ai_frequency = 0
	
	
	send_option = {
		flag = domain
		localization = take_domain_interaction
	}
	send_option = {
		flag = realm
		localization = take_realm_interaction
	}
	
	
	
	is_shown = {
		scope:actor = {
			is_ai = no
			is_ruler = yes
		}
		scope:recipient = {
			is_ai = yes
		}
	}
	
	can_send = {
		scope:actor = { 
		is_ai = no 
		is_ruler = yes
		}
		scope:recipient = { is_ruler = no OR = { is_courtier_of = scope:actor is_foreign_court_or_pool_guest_of = scope:actor} }
	}
	
	
	on_accept = {
     	if = {
			limit = { scope:realm = yes }
				create_title_and_vassal_change = {
				add_claim_on_loss = no
				type = granted
				save_scope_as = change
			}
			scope:actor = {
				every_sub_realm_title = {
					limit = { tier > tier_barony }
					change_title_holder_include_vassals = {
						holder = scope:recipient
						change = scope:change
					}
				}
				add_character_flag = main_rtr
			}
			resolve_title_and_vassal_change = scope:change
		}
		else_if = {
			limit = { scope:domain = yes }
			create_title_and_vassal_change = {
				type = granted
				save_scope_as = change
				add_claim_on_loss = no
			}
			scope:actor = {
				every_held_title = {
				    limit = { tier > tier_barony }
					change_title_holder_include_vassals = {
						holder = scope:recipient
						change = scope:change
					}
				}
				add_character_flag = main_rtr
			}
			resolve_title_and_vassal_change = scope:change
		}
		scope:actor = { trigger_event = rtr.0013 }
	}
}