﻿
namespace = vassal_interaction

###########################
# Ask vassal attacker to stop war
# by Petter Vilberg
###########################

#Vassal selects response
vassal_interaction.0001 = {
	type = letter_event
	sender = scope:actor
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0001.desc
	
	immediate = {
		scope:target = {
			primary_defender = {
				save_scope_as = defender
			}
		}
		random = { #Roll to see whether they accept at all
			chance = stop_war_attacker_likelihood_calculation
			random_list = { #Roll to see if they make demands
				5 = {
					modifier = {
						add = 10
						has_trait = loyal
					}
					modifier = {
						add = 10
						has_trait = craven
					}
					modifier = {
						add = 5
						has_trait = humble
					}
					modifier = {
						add = 5
						has_trait = content
					}
					modifier = {
						# Admin governors are more likely to accept without demands by default. Increases with Bureaucracy level.
						factor = {
							value = 2
							if = {
								limit = {
									top_liege = { has_realm_law = imperial_bureaucracy_3 }
								}
								add = 3
							}
							else_if = {
								limit = {
									top_liege = { has_realm_law = imperial_bureaucracy_2 }
								}
								add = 2
							}
							else_if = {
								limit = {
									top_liege = { has_realm_law = imperial_bureaucracy_1 }
								}
								add = 1
							}
						}
						is_governor = yes
					}
					modifier = {
						# Stubborn characters will always ask for something UNLESS they are intimidated.
						factor = 0
						has_trait = stubborn
						NOT = {
							has_dread_level_towards = {
								target = scope:actor
								level = 1
							}
						}
						is_governor = no # Governors will never refuse simply because they are stubborn
					}
					modifier = {
						# Intimidated characters more likely to accept without asking for anything.
						factor = 2
						has_dread_level_towards = {
							target = scope:actor
							level = 1
						}
					}
					save_scope_value_as = {
						name = response
						value = flag:accept
					}
				}
				5 = {
					modifier = {
						add = 10
						has_trait = ambitious
					}
					modifier = {
						# Cowed characters never ask for anything.
						factor = 0
						has_dread_level_towards = {
							target = scope:actor
							level = 2
						}
					}
					save_scope_value_as = {
						name = response
						value = flag:favor
					}
				}
				5 = {
					modifier = {
						add = 10
						has_trait = greedy
					}
					modifier = {
						# Cowed characters never ask for anything.
						factor = 0
						has_dread_level_towards = {
							target = scope:actor
							level = 2
						}
					}
					save_scope_value_as = {
						name = response
						value = flag:gold
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:response }
			}
			save_scope_value_as = {
				name = response
				value = flag:refuse
			}
		}
	}

	option = { #Accept
		name = vassal_interaction.0001.a
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
			scope:actor = {
				add_opinion = {
					target = root
					modifier = pleased_opinion
					opinion = low_positive_opinion
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0002
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:accept
			}
		}
	}

	option = { #Request a favor
		name = vassal_interaction.0001.b
		trigger = {
			can_add_hook = {
				target = scope:actor
				type = favor_hook
			}
		}
		custom_tooltip = vassal_interaction.0001.request_favor_tt
		show_as_tooltip = {
			random_list = {
				1 = {
					desc = vassal_interaction.0001.accept
					show_chance = no
					scope:target = {
						end_war = white_peace
					}
					add_hook = {
						target = scope:actor
						type = favor_hook
					}
				}
				1 = {
					desc = vassal_interaction.0001.decline
					show_chance = no
					add_prestige = medium_prestige_loss
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0003
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:favor
			}
		}
	}
	
	option = { #Request gold
		name = vassal_interaction.0001.c
		custom_tooltip = vassal_interaction.0001.request_gold_tt
		show_as_tooltip = {
			random_list = {
				1 = {
					desc = vassal_interaction.0001.accept
					show_chance = no
					scope:target = {
						end_war = white_peace
					}
					scope:actor = {
						pay_short_term_gold = {
							target = root
							gold = scope:recipient.stop_war_attacker_bribe_size
						}
					}
				}
				1 = {
					desc = vassal_interaction.0001.decline
					show_chance = no
					add_prestige = medium_prestige_loss
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0004
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:gold
			}
		}
	}
	
	option = { #Refuse
		name = vassal_interaction.0001.d
		trigger = {
			NOT = { has_usable_hook = scope:actor }
		}
		show_as_tooltip = {
			scope:actor = {
				add_opinion = {
					target = root
					modifier = refusal_opinion
					opinion = low_negative_opinion
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0005
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:refuse
			}
		}
	}

	option = { #Refuse - you have a hook!
		name = vassal_interaction.0001.e
		trigger = {
			has_usable_hook = scope:actor
		}
		show_as_tooltip = {
			use_hook = scope:actor
		}
		save_scope_value_as = {
			name = vassal_used_hook
			value = yes
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0005
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:refuse
			}
		}
	}
}


#Liege: Vassal accepts
vassal_interaction.0002 = {
	type = letter_event
	sender = scope:recipient
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0002.desc
	
	immediate = {
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
		}
		hidden_effect = {
			save_scope_as = war_ender
			send_interface_toast = {
				title = vassal_interaction.war_ender_gives_up
				scope:target = {
					end_war = white_peace
				}
			}
			add_opinion = {
				target = scope:recipient
				modifier = pleased_opinion
				opinion = low_positive_opinion
			}
		}
	}

	option = {
		name = vassal_interaction.0002.a
		scope:defender = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		
		# If we're a clan this event affects unity
		stop_attacker_vassal_war_add_clan_unity_effect = yes
	}
}


#Liege: Vassal asks for a favor
vassal_interaction.0003 = {
	type = letter_event
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0003.desc
	sender = {
		character = scope:recipient
		animation = personality_greedy
	}

	option = { #Very well
		name = vassal_interaction.0003.a
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
			scope:recipient = {
				add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		save_scope_value_as = {
			name = reward_type
			value = flag:favor
		}
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0006
				days = 1
			}
		}
		scope:defender = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		
		# If we're a clan this event affects unity
		stop_attacker_vassal_war_add_clan_unity_effect = yes
		
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = generous
			}
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_honor = 0.5
			}
		}
	}

	option = { #Never!
		name = vassal_interaction.0003.b
		custom_tooltip = vassal_interaction.0003.b.tt
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0007
				days = 1
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = stubborn
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_greed = 1
			}
		}
	}

	option = {
		name = vassal_interaction.you_owe_me
		trigger = {
			scope:recipient = { is_ai = yes }
			has_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		scope:target = {
			end_war = white_peace
		}
		scope:defender = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		
		# If we're a clan this event affects unity
		stop_attacker_vassal_war_add_clan_unity_effect = yes
	}
}

#Liege: Vassal asks for gold
vassal_interaction.0004 = {
	type = letter_event
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0004.desc
	sender = {
		character = scope:recipient
		animation = personality_greedy
	}

	option = { #Very well
		name = vassal_interaction.0004.a
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
			pay_short_term_gold = {
				target = scope:recipient
				gold = scope:recipient.stop_war_attacker_bribe_size
			}
		}
		save_scope_value_as = {
			name = reward_type
			value = flag:gold
		}
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0006
				days = 1
			}
		}
		scope:defender = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		
		# If we're a clan this event affects unity
		stop_attacker_vassal_war_add_clan_unity_effect = yes
		
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = generous
			}
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_honor = 0.5
			}
			modifier = {
				factor = 0.1
				short_term_gold < scope:recipient.stop_war_attacker_bribe_size
			}
		}
	}

	option = { #Never!
		name = vassal_interaction.0004.b
		custom_tooltip = vassal_interaction.0003.b.tt
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0007
				days = 1
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = stubborn
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_greed = 1
			}
		}
	}

	option = {
		name = vassal_interaction.you_owe_me
		trigger = {
			scope:recipient = { is_ai = yes }
			has_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		scope:target = {
			end_war = white_peace
		}
		scope:defender = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		
		# If we're a clan this event affects unity
		stop_attacker_vassal_war_add_clan_unity_effect = yes
	}
}


#Liege: Vassal refuses
vassal_interaction.0005 = {
	type = letter_event
	sender = scope:recipient
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0005.desc

	option = {
		name = vassal_interaction.0005.a
		trigger = {
			NOT = { exists = scope:vassal_used_hook }
		}
		add_prestige = minor_prestige_loss
		hidden_effect = {
			add_opinion = {
				target = scope:recipient
				modifier = refusal_opinion
				opinion = low_negative_opinion
			}
		}
	}

	option = {
		name = vassal_interaction.you_owe_me
		trigger = {
			scope:recipient = { is_ai = yes }
			has_usable_hook = scope:recipient
			NOT = { exists = scope:vassal_used_hook }
		}
		use_hook = scope:recipient
		scope:target = {
			end_war = white_peace
		}
	}

	option = {
		name = vassal_interaction.0005.b
		trigger = {
			exists = scope:vassal_used_hook
		}
		scope:recipient = {
			use_hook = scope:actor
		}
	}
}

#Vassal: Liege accepts
vassal_interaction.0006 = {
	type = letter_event
	sender = scope:actor
	opening = vassal_interaction.0001.opening
	desc = {
		desc = vassal_interaction.0006.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:reward_type = flag:favor }
				desc = vassal_interaction.0006.favor
			}
			desc = vassal_interaction.0006.gold
		}
	}

	immediate = {
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
		}
		hidden_effect = {
			save_scope_as = war_ender
			send_interface_toast = {
				title = vassal_interaction.war_ender_gives_up
				scope:target = {
					end_war = white_peace
				}
			}
		}
	}

	option = {
		name = vassal_interaction.0006.a
		trigger = {
			scope:reward_type = flag:favor
		}
		add_hook = {
			target = scope:actor
			type = favor_hook
		}
	}

	option = {
		name = vassal_interaction.0006.b
		trigger = {
			scope:reward_type = flag:gold
		}
		scope:actor = {
			pay_short_term_gold = {
				target = scope:recipient
				gold = scope:recipient.stop_war_attacker_bribe_size
			}
		}
	}
}

#Vassal: Liege refuses
vassal_interaction.0007 = {
	type = letter_event
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0007.desc
	sender = {
		character = scope:recipient
		animation = anger
	}

	option = {
		name = vassal_interaction.0007.a
		add_prestige = medium_prestige_loss
	}
}

###########################
# Ask vassal defender to stop surrender
# by Petter Vilberg
###########################

#Vassal selects response
vassal_interaction.0011 = {
	type = letter_event
	sender = scope:actor
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0011.desc
	
	immediate = {
		scope:target = {
			primary_attacker = {
				save_scope_as = attacker
			}
		}
		random = { #Roll to see whether they accept at all
			chance = stop_war_defender_likelihood_calculation
			random_list = { #Roll to see if they make demands
				5 = {
					modifier = {
						add = 10
						has_trait = loyal
					}
					modifier = {
						add = 10
						has_trait = craven
					}
					modifier = {
						add = 5
						has_trait = humble
					}
					modifier = {
						add = 5
						has_trait = content
					}
					modifier = {
						# Admin governors are more likely to accept without demands by default. Increases with Bureaucracy level.
						factor = {
							value = 2
							if = {
								limit = {
									top_liege = { has_realm_law = imperial_bureaucracy_3 }
								}
								add = 3
							}
							else_if = {
								limit = {
									top_liege = { has_realm_law = imperial_bureaucracy_2 }
								}
								add = 2
							}
							else_if = {
								limit = {
									top_liege = { has_realm_law = imperial_bureaucracy_1 }
								}
								add = 1
							}
						}
						is_governor = yes
					}
					modifier = {
						# Stubborn characters will always ask for something UNLESS they are intimidated.
						factor = 0
						has_trait = stubborn
						NOT = {
							has_dread_level_towards = {
								target = scope:actor
								level = 1
							}
						}
						is_governor = no # Governors will never refuse simply because they are stubborn
					}
					modifier = {
						# Intimidated characters more likely to accept without asking for anything.
						factor = 2
						has_dread_level_towards = {
							target = scope:actor
							level = 1
						}
					}
					save_scope_value_as = {
						name = response
						value = flag:accept
					}
				}
				5 = {
					modifier = {
						add = 10
						has_trait = ambitious
					}
					modifier = {
						# Cowed characters never ask for anything.
						factor = 0
						has_dread_level_towards = {
							target = scope:actor
							level = 2
						}
					}
					save_scope_value_as = {
						name = response
						value = flag:favor
					}
				}
				5 = {
					modifier = {
						add = 10
						has_trait = greedy
					}
					modifier = {
						# Cowed characters never ask for anything.
						factor = 0
						has_dread_level_towards = {
							target = scope:actor
							level = 2
						}
					}
					save_scope_value_as = {
						name = response
						value = flag:gold
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:response }
			}
			save_scope_value_as = {
				name = response
				value = flag:refuse
			}
		}
	}

	option = { #Accept
		name = vassal_interaction.0011.a
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
			scope:actor = {
				add_opinion = {
					target = root
					modifier = pleased_opinion
					opinion = low_positive_opinion
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0012
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:accept
			}
		}
	}

	option = { #Request a favor
		name = vassal_interaction.0011.b
		trigger = {
			can_add_hook = {
				target = scope:actor
				type = favor_hook
			}
		}
		custom_tooltip = vassal_interaction.0001.request_favor_tt
		show_as_tooltip = {
			random_list = {
				1 = {
					desc = vassal_interaction.0001.accept
					show_chance = no
					scope:target = {
						end_war = white_peace
					}
					add_hook = {
						target = scope:actor
						type = favor_hook
					}
				}
				1 = {
					desc = vassal_interaction.0001.decline
					show_chance = no
					add_prestige = medium_prestige_loss
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0013
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:favor
			}
		}
	}
	
	option = { #Request gold
		name = vassal_interaction.0011.c
		custom_tooltip = vassal_interaction.0001.request_gold_tt
		show_as_tooltip = {
			random_list = {
				1 = {
					desc = vassal_interaction.0001.accept
					show_chance = no
					scope:target = {
						end_war = white_peace
					}
					scope:actor = {
						pay_short_term_gold = {
							target = root
							gold = stop_war_defender_bribe_size
						}
					}
				}
				1 = {
					desc = vassal_interaction.0001.decline
					show_chance = no
					add_prestige = medium_prestige_loss
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0014
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:gold
			}
		}
	}
	
	option = { #Refuse
		name = vassal_interaction.0011.d
		trigger = {
			NOT = { has_usable_hook = scope:actor }
		}
		show_as_tooltip = {
			scope:actor = {
				add_opinion = {
					target = root
					modifier = refusal_opinion
					opinion = low_negative_opinion
				}
			}
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0015
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:refuse
			}
		}
	}

	option = { #Refuse - you have a hook!
		name = vassal_interaction.0011.d
		trigger = {
			has_usable_hook = scope:actor
		}
		show_as_tooltip = {
			use_hook = scope:actor
		}
		save_scope_value_as = {
			name = vassal_used_hook
			value = yes
		}
		scope:actor = {
			trigger_event = {
				id = vassal_interaction.0015
				days = { 3 6 }
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				scope:response = flag:refuse
			}
		}
	}
}


#Liege: Vassal accepts
vassal_interaction.0012 = {
	type = letter_event
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0012.desc
	sender = {
		character = scope:recipient
		animation = personality_coward
	}
	
	immediate = {
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
		}
		hidden_effect = {
			save_scope_as = war_ender
			send_interface_toast = {
				title = vassal_interaction.war_ender_gives_up
				scope:target = {
					end_war = white_peace
				}
			}
		}
	}

	option = {
		name = vassal_interaction.0012.a
		add_opinion = {
			target = scope:recipient
			modifier = pleased_opinion
			opinion = low_positive_opinion
		}
		
		# If we're a clan this event affects unity
		stop_defender_vassal_war_add_clan_unity_effect = yes
	}
}


#Liege: Vassal asks for a favor
vassal_interaction.0013 = {
	type = letter_event
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0013.desc
	sender = {
		character = scope:recipient
		animation = personality_greedy
	}

	option = { #Very well
		name = vassal_interaction.0003.a
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
			scope:recipient = {
				add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		save_scope_value_as = {
			name = reward_type
			value = flag:favor
		}
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0016
				days = 1
			}
		}
		
		# If we're a clan this event affects unity
		stop_defender_vassal_war_add_clan_unity_effect = yes
		
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = generous
			}
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_honor = 0.5
			}
		}
	}

	option = { #Never!
		name = vassal_interaction.0003.b
		custom_tooltip = vassal_interaction.0003.b.tt
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0017
				days = 1
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = stubborn
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_greed = 1
			}
		}
	}

	option = {
		name = vassal_interaction.you_owe_me
		trigger = {
			scope:recipient = { is_ai = yes }
			has_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		scope:target = {
			end_war = white_peace
		}
		
		# If we're a clan this event affects unity
		stop_defender_vassal_war_add_clan_unity_effect = yes
	}
}

#Liege: Vassal asks for gold
vassal_interaction.0014 = {
	type = letter_event
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0014.desc
	sender = {
		character = scope:recipient
		animation = personality_greedy
	}

	option = { #Very well
		name = vassal_interaction.0004.a
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
			pay_short_term_gold = {
				target = scope:recipient
				gold = scope:recipient.stop_war_defender_bribe_size
			}
		}
		save_scope_value_as = {
			name = reward_type
			value = flag:gold
		}
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0006
				days = 1
			}
		}
		
		# If we're a clan this event affects unity
		stop_defender_vassal_war_add_clan_unity_effect = yes
		
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = generous
			}
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_honor = 0.5
			}
			modifier = {
				factor = 0.1
				short_term_gold < scope:recipient.stop_war_defender_bribe_size
			}
		}
	}

	option = { #Never!
		name = vassal_interaction.0004.b
		custom_tooltip = vassal_interaction.0003.b.tt
		scope:recipient = {
			trigger_event = {
				id = vassal_interaction.0007
				days = 1
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 100
				has_trait = stubborn
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_greed = 1
			}
		}
	}

	option = {
		name = vassal_interaction.you_owe_me
		trigger = {
			scope:recipient = { is_ai = yes }
			has_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		scope:target = {
			end_war = white_peace
		}
		
		# If we're a clan this event affects unity
		stop_defender_vassal_war_add_clan_unity_effect = yes
	}
}


#Liege: Vassal refuses
vassal_interaction.0015 = {
	type = letter_event
	sender = scope:recipient
	opening = vassal_interaction.0002.opening
	desc = vassal_interaction.0015.desc

	option = {
		name = vassal_interaction.0005.a
		add_prestige = minor_prestige_loss
		add_opinion = {
			target = scope:recipient
			modifier = refusal_opinion
			opinion = low_negative_opinion
		}
	}

	option = {
		name = vassal_interaction.you_owe_me
		trigger = {
			scope:recipient = { is_ai = yes }
			has_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		scope:target = {
			end_war = white_peace
		}
	}

	option = {
		name = vassal_interaction.0005.b
		trigger = {
			exists = scope:vassal_used_hook
		}
		scope:recipient = {
			use_hook = scope:actor
		}
	}
}

#Vassal: Liege accepts
vassal_interaction.0016 = {
	type = letter_event
	sender = scope:actor
	opening = vassal_interaction.0001.opening
	desc = {
		desc = vassal_interaction.0006.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:reward_type = flag:favor }
				desc = vassal_interaction.0006.favor
			}
			desc = vassal_interaction.0016.gold
		}
	}

	immediate = {
		show_as_tooltip = {
			scope:target = {
				end_war = white_peace
			}
		}
		hidden_effect = {
			save_scope_as = war_ender
			send_interface_toast = {
				title = vassal_interaction.war_ender_gives_up
				scope:target = {
					end_war = white_peace
				}
			}
		}
	}

	option = {
		name = vassal_interaction.0016.a
		trigger = {
			scope:reward_type = flag:favor
		}
		add_hook = {
			target = scope:actor
			type = favor_hook
		}
	}

	option = {
		name = vassal_interaction.0016.b
		trigger = {
			scope:reward_type = flag:gold
		}
		scope:actor = {
			pay_short_term_gold = {
				target = scope:recipient
				gold = scope:recipient.stop_war_defender_bribe_size
			}
		}
	}
}

#Vassal: Liege refuses
vassal_interaction.0017 = {
	type = letter_event
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0007.desc
	sender = {
		character = scope:actor
		animation = anger
	}

	option = {
		name = vassal_interaction.0007.a
		add_prestige = medium_prestige_loss
	}
}


###########################
# Grant vassal independence
# by Linnéa Thimrén
###########################


#Notify other vassals (if players)
vassal_interaction.0022 = {
	type = letter_event
	sender = scope:actor
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0022.desc

	immediate = {
		show_as_tooltip = {
			add_opinion = {
				target = scope:actor
				modifier = granted_independence_opinion
			}

			add_truce_both_ways = {
				character = scope:actor
				days = 3650
				name = TRUCE_GRANT_INDEPENDENCE
			}
		}
	}

	option = {
		name = vassal_interaction.0022.a
	}
}

#Notify the liege's liege (if player)
vassal_interaction.0023 = {
	type = letter_event
	sender = scope:actor
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0023.desc

	immediate = {
		show_as_tooltip = {
			add_opinion = {
				target = scope:actor
				modifier = granted_independence_opinion
			}

			add_truce_both_ways = {
				character = scope:actor
				days = 3650
				name = TRUCE_GRANT_INDEPENDENCE
			}
		}
	}

	option = {
		name = vassal_interaction.0023.a
	}
}

##################################################
# Pardon Requested
# by Ewan Cowhig Croft
##################################################

#	You have received a pardon.
vassal_interaction.0030 = {
	type = letter_event
	opening = vassal_interaction.0001.opening
	desc = vassal_interaction.0030.desc
	sender = {
		character = scope:recipient
		animation = personality_forgiving
	}

	immediate = {
		play_music_cue = "mx_cue_positive_effect"
		show_as_tooltip = { ask_for_pardon_interaction_effect = yes }
	}

	option = {
		name = vassal_interaction.0030.a
	}
}

#####################
# A Vassal has claimed one of my titles
# by Alexander Oltner
#####################
vassal_interaction.0040 = {
	type = letter_event
	opening = {
		desc = char_interaction.0020.opening
	}
	desc = vassal_interaction.0040.desc
		
	sender = scope:actor

	option = {
		name = vassal_interaction.0040.a
		show_as_tooltip = {
			scope:actor = {
				add_unpressed_claim = scope:target
			}
		}
	}
}
