﻿#Events fired from rotr_inheritance_on_actions

namespace = hands

##############################################################################################
# 1000-: "Events Dealing with Inheritance of Titles in Other Realms
# by Valaddar
##############################################################################################
# 1000 - Pop Event to liege letting them know them know they are losing their lands
##############################################################################################

#Event to appoint a new heir to a vassal who is dying
hands.1000 = {
	type = character_event
	title = hands.1000.t
	desc = {
		#Trigger the correct language for family in the event description
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:sibling_exists = { exists = yes }
				}
				desc = hands.1000.a.desc
			}
			triggered_desc = {
				trigger = {
					scope:close_family_exists = { exists = yes }
				}
				desc = hands.1000.b.desc
			}
			triggered_desc = {
				trigger = {
					scope:distant_family_exists = { exists = yes }
				}
				desc = hands.1000.c.desc
			}
			triggered_desc = {
				trigger = {
					scope:dynasty_exists = { exists = yes }
				}
				desc = hands.1000.d.desc
			}
			desc = hands.1000.e.desc
		}
	}
	left_portrait = {
		character = scope:vassal_changing_heir
		animation = dead
	}
	right_portrait = {
		character = root
		animation = personality_honorable
	}
	theme = crown
	
	lower_right_portrait = {
		trigger = { exists = scope:heir_1 }
		character = scope:heir_1
	}
	lower_left_portrait = {
		trigger = { exists = scope:heir_2 }
		character = scope:heir_2
	}
	lower_center_portrait = {
		trigger = { exists = scope:heir_3 }
		character = scope:heir_3
	}

	trigger = {
		scope:primary_title_to_check.tier >= tier_county
		NOT = { scope:old_old_liege = scope:heir }	
	}

	immediate = {
		root = { save_scope_as = myself }
		every_ruler = {
			primary_heir = {
				add_to_list = list_of_game_heirs
			}
			every_spouse = {
				add_to_list = list_of_game_spouses
			}
		}
		scope:vassal_to_check = {
			save_scope_as = vassal_changing_heir
		}
		if = {
			limit = {
				scope:vassal_changing_heir = {
					any_sibling = {
						is_landed = no		
						is_alive = yes
						NOT = { has_trait = nightswatch }
						NOT = { has_trait = silent_sister }
						NOT = { has_trait = septon }
						NOT = { has_trait = maester }
						NOT = { has_trait = devoted }
						NOT = { has_trait = red_priest }
						NOT = { has_trait = order_member }
						NOT = { has_trait = kingsguard }
						NOT = { has_trait = dragon }
						NOT = { is_in_list = list_of_game_heirs }
						NOT = { is_in_list = list_of_game_spouses }	
						NOT = { is_parent_of = scope:vassal_changing_heir }
						NOT = { is_grandparent_of = scope:vassal_changing_heir }
						NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
					}
				}
			}
			scope:vassal_changing_heir = {
				every_sibling = {
					limit = {
						is_landed = no		
						is_alive = yes		
						NOT = { has_trait = nightswatch }
						NOT = { has_trait = silent_sister }
						NOT = { has_trait = septon }
						NOT = { has_trait = maester }
						NOT = { has_trait = devoted }
						NOT = { has_trait = red_priest }
						NOT = { has_trait = order_member }
						NOT = { has_trait = kingsguard }
						NOT = { has_trait = dragon }	
						NOT = { is_in_list = list_of_game_heirs }		
						NOT = { is_in_list = list_of_game_spouses }	
						NOT = { is_parent_of = scope:vassal_changing_heir }	
						NOT = { is_grandparent_of = scope:vassal_changing_heir }
						NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
					}
					add_to_list = list_of_heirs_siblings
				}
			}
			
		}		
			else_if = {
				limit = {
					scope:vassal_changing_heir = {
						any_close_family_member = {
							is_landed = no
							is_alive = yes			
							house = scope:vassal_changing_heir.house
							NOT = { has_trait = nightswatch }
							NOT = { has_trait = silent_sister }
							NOT = { has_trait = septon }
							NOT = { has_trait = maester }
							NOT = { has_trait = devoted }
							NOT = { has_trait = red_priest }
							NOT = { has_trait = order_member }
							NOT = { has_trait = kingsguard }
							NOT = { has_trait = dragon }
							NOT = { is_in_list = list_of_game_heirs }		
							NOT = { is_in_list = list_of_game_spouses }			
							NOT = { is_parent_of = scope:vassal_changing_heir }
							NOT = { is_grandparent_of = scope:vassal_changing_heir }
							NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
						}
					}
				}
				scope:vassal_changing_heir = {
					every_close_family_member = {
						limit = {
							is_landed = no
							is_alive = yes
							house = scope:vassal_changing_heir.house
							NOT = { has_trait = nightswatch }
							NOT = { has_trait = silent_sister }
							NOT = { has_trait = septon }
							NOT = { has_trait = maester }
							NOT = { has_trait = devoted }
							NOT = { has_trait = red_priest }
							NOT = { has_trait = order_member }
							NOT = { has_trait = kingsguard }
							NOT = { has_trait = dragon }
							NOT = { is_in_list = list_of_game_heirs }		
							NOT = { is_in_list = list_of_game_spouses }
							NOT = { is_parent_of = scope:vassal_changing_heir }
							NOT = { is_grandparent_of = scope:vassal_changing_heir }
							NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
						}
						add_to_list = list_of_heirs_close_family
					}
				}
			}		
				else_if = {
					limit = {
						scope:vassal_changing_heir = {
							any_close_or_extended_family_member = {
								is_landed = no
								is_alive = yes		
								house = scope:vassal_changing_heir.house
								NOT = { has_trait = nightswatch }
								NOT = { has_trait = silent_sister }
								NOT = { has_trait = septon }
								NOT = { has_trait = maester }
								NOT = { has_trait = devoted }
								NOT = { has_trait = red_priest }
								NOT = { has_trait = order_member }
								NOT = { has_trait = kingsguard }
								NOT = { has_trait = dragon }
								NOT = { is_in_list = list_of_game_heirs }		
								NOT = { is_in_list = list_of_game_spouses }				
								NOT = { is_parent_of = scope:vassal_changing_heir }
								NOT = { is_grandparent_of = scope:vassal_changing_heir }
								NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
							}
						}
					}
					scope:vassal_changing_heir = {
						every_close_or_extended_family_member = {
							limit = {
								is_landed = no
								is_alive = yes			
								house = scope:vassal_changing_heir.house
								NOT = { has_trait = nightswatch }
								NOT = { has_trait = silent_sister }
								NOT = { has_trait = septon }
								NOT = { has_trait = maester }
								NOT = { has_trait = devoted }
								NOT = { has_trait = red_priest }
								NOT = { has_trait = order_member }
								NOT = { has_trait = kingsguard }
								NOT = { has_trait = dragon }
								NOT = { is_in_list = list_of_game_heirs }		
								NOT = { is_in_list = list_of_game_spouses }			
								NOT = { is_parent_of = scope:vassal_changing_heir }
								NOT = { is_grandparent_of = scope:vassal_changing_heir }
								NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
							}
							add_to_list = list_of_heirs_distant_family
						}
					}
				}		
					else_if = {
						limit = {
							scope:vassal_changing_heir.dynasty = {
								any_dynasty_member = {
									is_landed = no
									is_alive = yes		
									dynasty = scope:vassal_changing_heir.dynasty
									NOT = { has_trait = nightswatch }
									NOT = { has_trait = silent_sister }
									NOT = { has_trait = septon }
									NOT = { has_trait = maester }
									NOT = { has_trait = devoted }
									NOT = { has_trait = red_priest }
									NOT = { has_trait = order_member }
									NOT = { has_trait = kingsguard }
									NOT = { has_trait = dragon }
									NOT = { is_in_list = list_of_game_heirs }		
									NOT = { is_in_list = list_of_game_spouses }				
									NOT = { is_parent_of = scope:vassal_changing_heir }
									NOT = { is_grandparent_of = scope:vassal_changing_heir }
									NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
								}
							}
						}
						scope:vassal_changing_heir.dynasty = {
							random_dynasty_member = {
								limit = {
									is_landed = no
									is_alive = yes		
									dynasty = scope:vassal_changing_heir.dynasty
									NOT = { has_trait = nightswatch }
									NOT = { has_trait = silent_sister }
									NOT = { has_trait = septon }
									NOT = { has_trait = maester }
									NOT = { has_trait = devoted }
									NOT = { has_trait = red_priest }
									NOT = { has_trait = order_member }
									NOT = { has_trait = kingsguard }
									NOT = { has_trait = dragon }
									NOT = { is_in_list = list_of_game_heirs }		
									NOT = { is_in_list = list_of_game_spouses }				
									NOT = { is_parent_of = scope:vassal_changing_heir }
									NOT = { is_grandparent_of = scope:vassal_changing_heir }
									NOT = { is_great_grandparent_of = scope:vassal_changing_heir }
								}
								add_to_list = list_of_heirs_dynasty
							}
						}
					}
						else = {
							root = { save_scope_as = the_final_new_heir }
						}
		
		

		
		scope:vassal_changing_heir = {
			every_held_title = {
				limit = {
					title_will_leave_sub_realm_on_succession = root					
				}
				add_to_list = titles_to_change_heir
			}
		}

		
		if ={
			limit = {
				list_size:list_of_heirs_dynasty > 0
				list_size:list_of_heirs_distant_family < 1
				list_size:list_of_heirs_close_family < 1
				list_size:list_of_heirs_siblings < 1
			}
			ordered_in_list = {
				list = list_of_heirs_dynasty
				order_by = prestige
				save_scope_as = heir_1
				save_scope_as = dynasty_exists
			}
			scope:heir_1 = { remove_from_list = list_of_heirs_dynasty }
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_dynasty
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_dynasty
					order_by = prestige
					save_scope_as = heir_2
				}
				scope:heir_2 = { remove_from_list = list_of_heirs_dynasty }
			}
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_dynasty
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_dynasty
					order_by = prestige
					save_scope_as = heir_3
				}
				scope:heir_3 = { remove_from_list = list_of_heirs_dynasty }
			}
		}

		

		if ={
			limit = {
				list_size:list_of_heirs_distant_family > 0
				list_size:list_of_heirs_close_family < 1
				list_size:list_of_heirs_siblings < 1
			}
			ordered_in_list = {
				list = list_of_heirs_distant_family
				order_by = prestige
				save_scope_as = heir_1
				save_scope_as = distant_family_exists
			}
			scope:heir_1 = { remove_from_list = list_of_heirs_distant_family }
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_distant_family
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_distant_family
					order_by = prestige
					save_scope_as = heir_2
				}
				scope:heir_2 = { remove_from_list = list_of_heirs_distant_family }
			}
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_distant_family
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_distant_family
					order_by = prestige
					save_scope_as = heir_3
				}
				scope:heir_3 = { remove_from_list = list_of_heirs_distant_family }
			}
		}

		if ={
			limit = {
				list_size:list_of_heirs_close_family > 0
				list_size:list_of_heirs_siblings < 1
			}
			ordered_in_list = {
				list = list_of_heirs_close_family
				order_by = prestige
				save_scope_as = heir_1
				save_scope_as = close_family_exists
			}
			scope:heir_1 = { remove_from_list = list_of_heirs_close_family }
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_close_family
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_close_family
					order_by = prestige
					save_scope_as = heir_2
				}
				scope:heir_2 = { remove_from_list = list_of_heirs_close_family }
			}
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_distant_family
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_close_family
					order_by = prestige
					save_scope_as = heir_3
				}
				scope:heir_3 = { remove_from_list = list_of_heirs_distant_family }
			}
		}

		


		if ={
			limit = {
				list_size:list_of_heirs_siblings > 0
			}
			ordered_in_list = {
				list = list_of_heirs_siblings
				order_by = prestige
				save_scope_as = heir_1
				save_scope_as = sibling_exists
			}
			scope:heir_1 = { remove_from_list = list_of_heirs_siblings }
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_siblings
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_siblings
					order_by = prestige
					save_scope_as = heir_2
				}
				scope:heir_2 = { remove_from_list = list_of_heirs_siblings }
			}
			if = {
				limit = {
					any_in_list = {
					list = list_of_heirs_siblings
					count >= 1
					}				
				}
				ordered_in_list = {
					list = list_of_heirs_siblings
					order_by = prestige
					save_scope_as = heir_3
				}
				scope:heir_3 = { remove_from_list = list_of_heirs_siblings }
			}
		}
		
		every_in_list = {
			list = list_of_game_heirs
			remove_from_list = prev
		}



	}

	#Pick a family person
	option = {
		name = hands.1000.heir_1.a
		trigger = {
			scope:heir_1 = { exists = yes }
		}

		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:heir_1
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:heir_1 = {
			trigger_event = hands.1001
		}

		scope:heir = {
			trigger_event = {
				id = hands.1002
				days = 2
			}
		}
	}

	option = {
		name = hands.1000.heir_2.b
		trigger = {
			scope:heir_2 = { exists = yes }
		}

		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:heir_2
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:heir_2 = {
			trigger_event = hands.1001
		}		

		scope:heir = {
			trigger_event = {
				id = hands.1002
				days = 2
			}
		}
	}

	option = {
		name = hands.1000.heir_3.c
		trigger = {
			scope:heir_3 = { exists = yes }
		}		

		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:heir_3
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:heir_3 = {
			trigger_event = hands.1001
		}

		scope:heir = {
			trigger_event = {
				id = hands.1002
				days = 2
			}
		}
	}

	#Pick liege
	option = {
		name = hands.1000.z
		trigger = {
			NOT = { scope:heir_1 = { exists = yes } }
		}		

		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:myself
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:myself = {
			trigger_event = hands.1001
		}		

		scope:heir = {
			trigger_event = {
				id = hands.1002
				days = 2
			}
		}
	}

	#Do Nothing... coward!
	option = {
		name = hands.1000.zz

		trigger = {
			OR = {
				is_ai = no
				# AND = {
				# 	is_ai = no
				# 	has_trait = craven
				# 	NOT = { has_trait = brave }
				# 	NOT = { has_trait = ambitious }
				# 	max_military_strength < scope:heir.their_hands_military_strength_value
				# }
				AND = {
					is_ai = yes
					has_trait = craven
					NOT = { has_trait = brave }
					NOT = { has_trait = ambitious }
					max_military_strength < scope:heir.their_hands_military_strength_value
				}
			}
		}

		
		every_in_list = {
			list = titles_being_lost
			save_scope_as = title
			scope:myself = {
				add_pressed_claim = scope:title
			}
		}	

		scope:heir = {
			trigger_event = hands.1003
			# trigger_event = {
			# 	id = hands.1003
			# 	days = 2
			# }
		}	
		ai_chance = {
			base = 100
		}	
	}
}

hands.1001 = {
	hidden = yes

	trigger = {
		OR = {
			scope:heir_1 = { exists = yes }
			scope:heir_2 = { exists = yes }
			scope:heir_3 = { exists = yes }
		}
	}
	immediate = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
			add_claim_on_loss = no
		}

		# Transfer vassals
		every_in_list = {
			list = vassals_to_check
			change_liege = {
				liege = root
				change = scope:change
			}
		}
		
		
		# Transfer titles
		change_liege = {
			liege = scope:myself
			change = scope:change
		}

		#Resolve the change
		resolve_title_and_vassal_change = scope:change		
	}
}

hands.1002 ={
	character_event = yes
	title = hands.1002.t
	desc = {
		#Trigger the correct language for family in the event description
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:primary_title_to_check.holder = scope:myself
				}
				desc = hands.1002.a.desc
			}
			desc = hands.1002.desc
		}
	}
	left_portrait = {
		character = scope:myself
		animation = dismissal
	}
	right_portrait = {
		character = root
		animation = anger
	}
	lower_right_portrait = {
		trigger = { exists = scope:heir_1 }
		character = scope:vassal_changing_heir
		animation = dead
	}
	theme = crown

	immediate = {
		scope:primary_title_to_check.holder = { save_scope_as = the_usurper}

		random_in_list = {
			list = titles_to_change_heir
			limit = {
				scope:primary_title_to_check = this
			}
			remove_from_list = titles_to_change_heir
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_1
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_2
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_3
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_4
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_5
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_6
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_7
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_8
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_9
				remove_from_list = titles_to_change_heir
			}
		}
		
		if ={
			limit = {
				list_size:titles_to_change_heir > 0
			}
			random_in_list = {
				list = titles_to_change_heir
				limit = {
					NOT = { scope:primary_title_to_check = this }
				}
				save_scope_as = title_10
				remove_from_list = titles_to_change_heir
			}
		}
	}

	option = {
		name = hands.1002.a
		trigger = {
			OR = {
				is_ai = no				
				AND = {
					is_ai = yes
					has_game_rule = yes_ai_hand_war
				}
			}
		}

		# every_in_list = {
		# 	list = titles_being_lost
		# 	save_scope_as = title
		# 	scope:heir = {
		# 		add_unpressed_claim = scope:title
		# 	}
		# }	

		start_war = {
			casus_belli = hands_claim_cb
			target = scope:myself
			claimant = scope:heir
			target_title = scope:primary_title_to_check
		}
	}
	option = {
		name = hands.1002.b
		trigger = {
			OR = {
				is_ai = no				
				AND = {
					is_ai = yes
					has_game_rule = yes_ai_hand_war
				}
			}
		}
		start_war = {
			casus_belli = duchy_conquest_cb
			target = scope:myself
			claimant = scope:heir
			target_title = scope:primary_title_to_check
		}
	}
	option = {
		name = hands.1002.c
		every_in_list = {
			list = titles_being_lost
			save_scope_as = title
			scope:heir = {
				add_unpressed_claim = scope:title
			}
		}	
	}
	option = {
		name = hands.1002.d
	}
}

hands.1003 = {
	character_event = yes
	title = hands.1003.t
	desc =  hands.1003.desc
	theme = crown

	immediate = {
		
	}

	left_portrait = {
		character = scope:myself
		animation = worry
	}
	right_portrait = {
		character = root
		animation = happiness
	}
	lower_right_portrait = {
		trigger = { exists = scope:heir_1 }
		character = scope:vassal_changing_heir
		animation = dead
	}
	theme = crown

	option = {
		name = hands.1003.a
	}
	option = {
		name = hands.1003.b
		trigger = {
			is_as = no
		}

		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:myself
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:myself = {
			trigger_event = hands.1103
		}
	}
}

hands.1103 = {
	hidden = yes

	immediate = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
			add_claim_on_loss = no
		}

		# Transfer vassals
		every_in_list = {
			list = vassals_to_check
			change_liege = {
				liege = scope:myself
				change = scope:change
			}
		}
		

		#Resolve the change
		resolve_title_and_vassal_change = scope:change		
	}
}


hands.5000 = {
	type = character_event
	title = hands.5000.t
	desc = hands.5000.desc
	left_portrait = {
		character = scope:heir
		animation = dismissal
	}
	right_portrait = {
		character = root
		animation = personality_honorable
	}
	
	lower_right_portrait = {
		character = scope:vassal_to_check
		animation = dead
	}
	theme = crown

	trigger = {
		NOT = { scope:old_old_liege = scope:heir }	
	}
	


	immediate = {
	}

	#Pick a family person
	option = {
		name = hands.5000.a
		custom_tooltip = hands.5000.a.tooltip

		scope:heir = {
			trigger_event = {
				id = hands.6000
				days = 2
			}
		}
		
		
		ai_chance = {
			base = 100
		}	
	}

	option = {
		name = hands.5000.b
		every_in_list = {
			list = titles_being_lost
			save_scope_as = title
			root = {
				add_pressed_claim = scope:title
			}
		}	

	}

	option = {
		name = hands.5000.c
	}
}


hands.6000 = {
	type = character_event
	title = hands.6000.t
	desc = hands.6000.desc
	left_portrait = {
		character = scope:the_old_liege
		animation = personality_bold

	}
	right_portrait = {
		character = root
		animation = personality_rational
	}
	
	# lower_right_portrait = {
	# 	character = scope:vassal_to_check
	# 	animation = dead
	# }
	theme = crown
	


	immediate = {
	}

	option = {
		name = hands.6000.a
		trigger = {
			OR = {
				is_ai = no				
				AND = {
					is_ai = yes
					has_game_rule = yes_ai_hand_war
				}
			}
		}
		
		scope:the_old_liege = {
			start_war = {
				casus_belli = duchy_conquest_cb
				target = scope:heir
				claimant = scope:the_old_liege
				target_title = scope:primary_title_to_check
			}		
		}
		
		
		ai_chance = {
			base = 50
		}	
	}

	option = {
		name = hands.6000.b

		every_in_list = {
			list = titles_being_lost
			save_scope_as = title
			root = {
				add_pressed_claim = scope:title
			}
		}	

		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:the_old_liege
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:the_old_liege = {
			trigger_event = hands.6100
		}

		
		
		ai_chance = {
			base = 100
		}	
	}

	option = {
		name = hands.6000.c
		trigger = {
			is_ai = no
		}
		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_being_lost
			change_title_holder = {
				holder = scope:the_old_liege
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:the_old_liege = {
			trigger_event = hands.6100
		}
	}
}



hands.6100 = {
	hidden = yes

	immediate = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
			add_claim_on_loss = no
		}

		# Transfer vassals
		every_in_list = {
			list = vassals_of_heirs_going_away
			change_liege = {
				liege = scope:the_old_liege
				change = scope:change
			}
		}
		

		#Resolve the change
		resolve_title_and_vassal_change = scope:change		
	}
}

hands.6500 = {
	type = character_event
	title = hands.6500.t
	desc = hands.6500.desc
	theme = crown
	left_portrait = {
		character = scope:attacker
		animation = personality_defiant
	}
	right_portrait = {
		character = root
		animation = personality_bold
	}

	immediate = {
	}

	option = {
		name = hands.6500.a
		custom_tooltip = hands.6500.a.tooltip
		trigger = {
			OR = {
				is_ai = no				
				AND = {
					is_ai = yes
					has_game_rule = yes_ai_hand_war
				}
			}
		}

		scope:attacker = {
			trigger_event = {
				id = hands.6501
				days = 2
			}
		}
		
		ai_chance = {
			base = 100
		}	
	}

	option = {
		name = hands.6500.b
		trigger = {
			is_ai = no
		}
		
		every_in_list = {
			list = titles_to_revoke
			save_scope_as = title
			scope:this_liege = {
				add_pressed_claim = scope:title
			}
		}		
		
		ai_chance = {
			base = 50
		}	
	}
	
	option = {
		name = hands.6500.b
		trigger = {
			is_ai = yes
		}
		
		every_in_list = {
			list = titles_to_revoke
			save_scope_as = title
			scope:this_liege = {
				add_pressed_claim = scope:title
			}
		}
	}

	option = {
		name = hands.6500.c

		ai_chance = {
			base = 0
		}	
	}
}

hands.6501 = {
	type = character_event
	title = hands.6501.t
	desc = hands.6501.desc
	theme = crown	
	left_portrait = {
		character = scope:this_liege
		animation = personality_bold
	}
	right_portrait = {
		character = root
		animation = personality_defiant
	}

	immediate = {
	}

	option = {
		name = hands.6501.a
		trigger = {
			OR = {
				is_ai = no				
				AND = {
					is_ai = yes
					has_game_rule = yes_ai_hand_war
				}
			}
		}

		
		
		scope:this_liege = {
			start_war = {
				casus_belli = duchy_conquest_cb
				target = scope:attacker
				claimant = scope:this_liege
				target_title = scope:the_old_title_to_check
			}		
		}
		


		ai_chance = {
			base = 100
		}	
	}

	option = {
		name = hands.6501.b
		
		
		create_title_and_vassal_change = {
			type = appointment
			save_scope_as = title_change
			add_claim_on_loss = yes
		}

		every_in_list = {
			list = titles_to_revoke
			change_title_holder = {
				holder = scope:this_liege
				change = scope:title_change
			}
		}	
		resolve_title_and_vassal_change = scope:title_change

		scope:this_liege = {
			trigger_event = hands.6502
		}	
		
		ai_chance = {
			base = 50
		}	
	}
}

hands.6502 = {
	hidden = yes

	immediate = {
		create_title_and_vassal_change = {
			type = conquest
			save_scope_as = change
			add_claim_on_loss = no
		}

		# Transfer vassals
		every_in_list = {
			list = vassals_to_revoke
			change_liege = {
				liege = scope:this_liege
				change = scope:change
			}
		}
		

		#Resolve the change
		resolve_title_and_vassal_change = scope:change		
	}
}