################################################
#
# Imprisoned Events
#
# ID 50000 - 54999 are reserved
#
##################################################
#
# Written by Sara Wendel-rtqvist & Henrik Fhraeus

# Escape from prison: Rope in flagon of wine # No more escaping.
# character_event = {
#	id = 50000
#	desc = EVTDESC50000
#	picture = GFX_evt_into_the_dungeon
#
#	prisoner = yes
#	min_age = 14
#	only_capable = yes
#
#	trigger = {
#		has_character_modifier = house_arrest
#
#		NOR = {
#			religion_group = muslim
#			trait = craven
#		}
#	}
#
#	mean_time_to_happen = {
#		years = 5
#
#		mult_modifier = {
#			factor = 0.5
#			trait = deceitful
#		}
#
#		mult_modifier = {
#			factor = 0.75
#			trait = ambitious
#		}
#
#		mult_modifier = {
#			factor = 0.75
#			trait = diligent
#		}
#
#		mult_modifier = {
#			factor = 2.0
#			intrigue < 3
#		}
#
#		mult_modifier = {
#			factor = 2.0
#			intrigue < 5
#		}
#
#		mult_modifier = {
#			factor = 0.75
#			intrigue >= 7
#		}
#
#		mult_modifier = {
#			factor = 0.75
#			intrigue >= 9
#		}
#
#		mult_modifier = {
#			factor = 0.75
#			intrigue >= 11
#		}
#
#		mult_modifier = {
#			factor = 2.0
#			trait = slothful
#		}
#
#		mult_modifier = {
#			factor = 2.0
#			trait = content
#		}
#	}
#
#	option = {
#		name = EVTOPTA50000
#
#		trigger = {
#			NOT = { trait = brave }
#		}
#
#		add_trait_silently_craven_effect = yes
#	}
#
#	option = {
#		name = EVTOPTB50000 # Do I risk it? Yes!
#
#		hidden_effect = {
#			random_list = {
#				30 = {
#					character_event = { id = 50001 }
#
#					host = {
#						character_event = { id = 50040 }
#					}
#				}
#
#				70 = {
#					host = {
#						character_event = { id = 50002 }
#					}
#				}
#			}
#		}
#	}
# }
#
# I'm free!
# character_event = {
#	id = 50001
#	desc = EVTDESC50001
#	picture = GFX_evt_into_the_dungeon
#
#	is_triggered_only = yes
#
#	option = {
#		name = EVTOPTA50001
#
#		prestige = 10
#		imprison = no
#
#		hidden_effect = {
#			if = {
#				limit = {
#					is_ruler = no
#
#					employer = {
#						ROOT = {
#							host = {
#								character = PREVPREV
#							}
#						}
#					}
#				}
#
#				banish = yes
#			}
#		}
#	}
# }
#
# The host is notified of the escape
# character_event = {
#	id = 50040
#	desc = EVTDESC50040
#	picture = GFX_evt_spymaster
#
#	is_triggered_only = yes
#
#	option = {
#		name = EVTOPTA50040
#
#		prestige = -10
#	}
# }
#
# A prisoner tried to escape!
# character_event = {
#	id = 50002
#	desc = EVTDESC50002
#	picture = GFX_evt_into_the_dungeon
#
#	is_triggered_only = yes
#
#	option = {
#		name = EVTOPTA50002
#
#		FROM = {
#			character_event = { id = 50003 }
#		}
#
#		ai_chance = { factor = 20 }
#	}
#
#	option = {
#		name = EVTOPTB50002
#
#		FROM = {
#			hidden_effect = {
#				remove_character_modifier = house_arrest
#				remove_character_modifier = the_oubliette
#				remove_character_modifier = the_dungeon
#			}
#
#			add_character_modifier = {
#				name = the_dungeon
#				duration = -1
#			}
#
#			character_event = { id = 50003 }
#		}
#
#		ai_chance = { factor = 20 }
#	}
#
#	option = {
#		name = EVTOPTC50002
#
#		FROM = {
#			hidden_effect = {
#				remove_character_modifier = house_arrest
#				remove_character_modifier = the_dungeon
#				remove_character_modifier = the_oubliette
#			}
#
#			add_character_modifier = {
#				name = the_oubliette
#				duration = -1
#			}
#
#			character_event = { id = 50003 }
#		}
#
#		ai_chance = {
#			factor = 20
#
#			trigger = {
#				NOT = { trait = kind }
#			}
#
#			mult_modifier = {
#				factor = 2
#				trait = envious
#			}
#
#			mult_modifier = {
#				factor = 5
#				trait = wroth
#			}
#
#			mult_modifier = {
#				factor = 5
#				trait = cruel
#			}
#		}
#	}
# }
#
# Failed to escape!
# character_event = {
#	id = 50003
#	desc = EVTDESC50003
#	picture = GFX_evt_into_the_dungeon
#
#	is_triggered_only = yes
#
#	option = {
#		name = EVTOPTA50003
#
#		trigger = { has_character_modifier = house_arrest }
#	}
#
#	option = {
#		name = EVTOPTB50003
#
#		trigger = { has_character_modifier = the_oubliette }
#
#		random = {
#			chance = 25
#			add_trait_stressed_effect = yes
#		}
#	}
#
#	option = {
#		name = EVTOPTC50003
#
#		trigger = { has_character_modifier = the_dungeon }
#
#		random = {
#			chance = 25
#			add_trait_depressed_effect = yes
#		}
#	}
# }

###############################################

# Request better accommodations - Setup
character_event = {
	id = 50004

	is_triggered_only = yes # on_become_imprisoned_any_reason
	hide_window = yes

	only_rulers = yes
	min_age = 14

	trigger = {
		NOT = { has_character_modifier = zun_judgement }
	}

	immediate = {
		clear_delayed_event = { id = 50005 }

		trigger_switch = {
			on_trigger = trait

			gregarious = {
				character_event = {
					id = 50005
					months = 6
					random = 180
				}
			}

			content = {
				character_event = {
					id = 50005
					months = 18
					random = 180
				}
			}

			fallback = {
				character_event = {
					id = 50005
					months = 6
					random = 180
				}
			}
		}
	}
}

# Request better accommodations
character_event = {
	id = 50005
	desc = EVTDESC50005
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	prisoner = yes
	only_rulers = yes
	only_capable = yes

	trigger = {
		host = {
			religion_group = ROOT
			war = no
		}

		NOR = {
			has_character_modifier = the_oubliette
			has_character_modifier = house_arrest
		}
	}

	fail_trigger_effect = {
		if = {
			limit = {
				prisoner = yes

				NOR = {
					has_character_modifier = the_oubliette
					has_character_modifier = house_arrest
				}
			}

			repeat_event = {
				id = 50005
				months = 3
			}
		}
	}

	option = {
		name = EVTOPTA50005

		host = {
			character_event = {
				id = 50006
				days = 2
			}
		}
	}

	option = {
		name = EVTOPTB50005 # I deserve this

		ai_chance = { factor = 0 }
	}
}

# Host responds to the prisoner's request
character_event = {
	id = 50006
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue

	desc = {
		text = EVTDESC50006
		trigger = { NOT = { trait = blinded } }
	}
	desc = {
		text = EVTDESC50006B
		trigger = { trait = blinded }
	}

	is_triggered_only = yes

	trigger = {
		FROM = { is_alive = yes }
	}

	option = {
		name = EVTOPTA50006 # Denied

		trigger = {
			FROM = { prisoner = yes }
		}

		FROM = {
			show_scope_change = no

			lose_weight_medium_effect = yes
			weight_trait_check_effect = yes

			opinion = {
				name = opinion_angry
				who = ROOT
				years = 1
			}
		}

		ai_chance = { factor = 45 }
	}

	option = {
		name = EVTOPTB50006 # Granted

		trigger = {
			FROM = { prisoner = yes }
		}

		FROM = {
			show_scope_change = no

			tooltip = {
				add_character_modifier = {
					name = house_arrest
					duration = -1
				}

				opinion = {
					name = opinion_grateful
					who = ROOT
					years = 1
				}
			}

			character_event = { id = 50007 }
		}

		ai_chance = {
			factor = 45

			trigger = {
				NOR = {
					trait = paranoid
					trait = wroth
				}
			}

			mult_modifier = {
				factor = 2
				trait = kind
			}

			# CK2Plus
			mult_modifier = {
				factor = 2
				trait = charitable
			}

			mult_modifier = {
				factor = 2
				trait = just
			}
		}
	}

	option = {
		name = EVTOPTC50006 # The Oubliette!

		trigger = {
			FROM = { prisoner = yes }
		}

		FROM = {
			show_scope_change = no

			lose_weight_medium_effect = yes
			weight_trait_check_effect = yes

			tooltip = {
				add_character_modifier = {
					name = the_oubliette
					duration = -1
				}

				opinion = {
					name = opinion_hate
					who = ROOT
					years = 1
				}
			}

			character_event = { id = 50008 }
		}

		if = {
			limit = { trait = kind }
			remove_trait = kind
		}

		else_if = {
			limit = {
				NOT = { trait = cruel }
			}

			random = {
				chance = 33
				add_trait_cruel_effect = yes
			}
		}

		hidden_effect = {
			change_variable = {
				which = lifestyle_martial
				value = 1
			}
		}

		ai_chance = {
			factor = 10

			trigger = {
				NOT = { trait = kind }
			}

			mult_modifier = {
				factor = 2
				trait = envious
			}

			mult_modifier = {
				factor = 2
				trait = paranoid
			}

			mult_modifier = {
				factor = 2
				trait = cruel
			}

			mult_modifier = {
				factor = 2
				trait = wroth
			}
		}
	}

	option = {
		name = EVTOPTD50006 # Already released

		trigger = {
			FROM = { prisoner = no }
		}
	}

	option = {
		name = EVTOPTE50006 # Release for favor

		trigger = {
			has_dlc = "Conclave"
			NOT = { holds_favor_on = FROM }

			FROM = { prisoner = yes }
		}

		tooltip = {
			add_favor = FROM

			FROM = {
				show_scope_change = no

				imprison = no

				opinion = {
					name = opinion_merciful
					who = ROOT
					months = 30
				}
			}
		}

		FROM = {
			character_event = { id = 50009 }
		}
	}
}

# House Arrest
character_event = {
	id = 50007
	desc = EVTDESC50007
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50007

		hidden_effect = {
			remove_character_modifier = house_arrest
			remove_character_modifier = the_dungeon
			remove_character_modifier = the_oubliette
		}

		if = {
			limit = { prisoner = yes }

			add_character_modifier = {
				name = house_arrest
				duration = -1
			}

			character_event = { id = ZE.12219 } # Loses pet rat
		}

		opinion = {
			name = opinion_grateful
			who = FROM
			years = 1
		}
	}
}

# The Oubliette
character_event = {
	id = 50008
	desc = EVTDESC50008
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50008

		hidden_effect = {
			remove_character_modifier = house_arrest
			remove_character_modifier = the_dungeon
			remove_character_modifier = the_oubliette
		}

		if = {
			limit = { prisoner = yes }

			add_character_modifier = {
				name = the_oubliette
				duration = -1
			}
		}

		opinion = {
			name = opinion_hate
			who = FROM
			years = 1
		}
	}
}

# Released for favor
character_event = {
	id = 50009
	desc = EVTDESC50009
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50009

		hidden_effect = {
			remove_character_modifier = house_arrest
			remove_character_modifier = the_dungeon
			remove_character_modifier = the_oubliette
		}

		reverse_add_favor = FROM
		imprison = no

		opinion = {
			name = opinion_released_prisoner
			who = FROM
			months = 30
		}
	}
}

###############################################

# Torture a prisoner!
character_event = {
	id = 50010
	desc = EVTDESC50010
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes # on_yearly_pulse, random_events, torturer_events

	only_playable = yes
	min_age = 14
	prisoner = no
	only_capable = yes

	trigger = {
		any_courtier = {
			prisoner = yes
			practical_age >= 14
			host = { character = ROOT }
			NOT = { has_character_modifier = house_arrest }

			trigger_if = {
				limit = { has_character_flag = tortured }

				had_character_flag = {
					flag = tortured
					years >= 2
				}
			}
		}

		OR = {
			trait = envious
			trait = wroth
			trait = arbitrary
			trait = lunatic
			trait = possessed
			trait = paranoid
			trait = impaler
			trait = cruel
		}

		NOR = {
			trait = kind
			trait = charitable
			has_character_flag = no_torture
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 4
			trait = impaler
		}

		mult_modifier = {
			factor = 2
			trait = possessed
		}

		mult_modifier = {
			factor = 2
			trait = cruel
		}

		mult_modifier = {
			factor = 1.33
			trait = paranoid
		}

		mult_modifier = {
			factor = 0.33
			trait = slothful
		}
	}

	option = {
		name = EVTOPTA50010 # Resist my foul impulse

		trigger = {
			NOR = {
				trait = possessed
				trait = lunatic
				trait = impaler
				has_character_flag = demon_child_non_pagan
			}
		}

		piety = 10
		set_character_flag = no_torture

		hidden_effect = {
			change_variable = {
				which = lifestyle_martial
				value = -1
			}
		}
	}

	option = {
		name = EVTOPTB50010 # Oil up the rack!

		if = {
			limit = { NOT = { religion = jain } }
			piety = -10
		}

		pacifists_lose_piety_effect = yes
		remove_trait_just_effect = yes

		if = {
			limit = {
				NOT = { trait = cruel }
			}

			random = {
				chance = 33

				tooltip = {
					remove_trait_silently_kind_effect = yes
					add_trait = cruel
				}

				hidden_effect = {
					remove_trait_silently_kind_effect = yes
					add_trait_cruel_effect = yes
				}
			}
		}

		random_courtier = {
			show_scope_change = no

			limit = {
				prisoner = yes
				practical_age >= 14
				host = { character = ROOT }
				NOT = { has_character_modifier = house_arrest }

				trigger_if = {
					limit = { has_character_flag = tortured }

					had_character_flag = {
						flag = tortured
						years >= 2
					}
				}
			}

			random_list = {
				30 = {
					character_event = {
						id = 50011
						tooltip = EVTTOOLTIP50011
					}
				}

				30 = {
					character_event = {
						id = 50012
						tooltip = EVTTOOLTIP50012
					}
				}

				30 = {
					character_event = {
						id = 50013
						tooltip = EVTTOOLTIP50013
					}
				}

				10 = {
					character_event = {
						id = 50014
						tooltip = EVTTOOLTIP50014
					}
				}
			}

			opinion = {
				name = opinion_hate
				who = ROOT
				years = 100
			}

			set_character_flag = tortured
		}
	}

	option = {
		name = EVTOPTC50010 # Phalaris bloodline
		tooltip_info = learning

		trigger = {
			primary_title = { title = k_sicily }
			has_dlc = "Holy Fury"
			is_alternate_start = no
			capital_scope = { de_jure_liege = d_sicily } # Must own it AND reside in it
			completely_controls = d_sicily
			culture = greek
			is_female = no
			learning >= 15

			OR = {
				trait = lunatic
				trait = possessed
				trait = impaler
				trait = cruel
			}

			NOR = {
				has_global_flag = flag_phalaris_bloodline
				has_dynasty_flag = flag_phalaris_event
			}
		}

		pacifists_lose_piety_effect = yes

		random_courtier = {
			show_scope_change = no

			limit = {
				prisoner = yes
				practical_age >= 14
				host = { character = ROOT }
				NOT = { has_character_modifier = house_arrest }
			}

			character_event = {
				id = HF.24001
				tooltip = EVTTOOLTIP50014
			}
		}
	}

	option = {
		name = EVTOPTD50010 # Phalaris bloodline. - Alt.

		trigger = {
			primary_title = { title = k_sicily }
			has_dlc = "Holy Fury"
			is_alternate_start = yes
			capital_scope = { de_jure_liege = d_sicily } # Must own it AND reside in it
			completely_controls = d_sicily
			has_character_modifier = brazen_bull
			culture = greek
			is_female = no
			independent = yes

			OR = {
				trait = lunatic
				trait = possessed
				trait = impaler
				trait = cruel
			}

			NOR = {
				has_global_flag = flag_phalaris_bloodline
				has_dynasty_flag = flag_phalaris_event
			}
		}

		pacifists_lose_piety_effect = yes

		random_courtier = {
			show_scope_change = no

			limit = {
				prisoner = yes
				practical_age >= 14
				host = { character = ROOT }
				NOT = { has_character_modifier = house_arrest }
			}

			character_event = {
				id = HF.24001
				tooltip = EVTTOOLTIP50014
			}
		}
	}
}

# Tortured
character_event = {
	id = 50011
	desc = EVTDESC5001
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50011

		lose_weight_small_effect = yes
		weight_trait_check_effect = yes

		add_character_modifier = {
			name = tortured
			months = 2
		}
	}
}

# Wounded
character_event = {
	id = 50012
	desc = EVTDESC50012
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50012

		add_trait_wounded_effect = yes
	}
}

# Maimed
character_event = {
	id = 50013
	desc = EVTDESC50013
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50013

		maim_hand_effect = yes
	}
}

# Killed
character_event = {
	id = 50014
	desc = EVTDESC50014
	picture = GFX_evt_death
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50014

		FROM = {
			character_event = { id = 50015 }
		}

		death = {
			death_reason = death_dungeon
			killer = FROM
		}
	}
}

# Host notified of death
character_event = {
	id = 50015
	desc = EVTDESC50015
	picture = GFX_evt_death
	border = GFX_event_normal_frame_intrigue

	is_triggered_only = yes

	option = {
		name = EVTOPTA50015

		prestige = -25
	}
}

###############################################

# Ruler is notified of the capture of an enemy commander
character_event = {
	id = 50020
	title = captured_in_battle
	desc = EVTDESC50020
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war
	portrait = event_target:captured_commander

	is_triggered_only = yes

	immediate = {
		event_target:captured_commander = { save_event_target_as = kinslayer_target }
	}

	# Warrior Lodge members only option...
	option = {
		name = EVTOPTC50020 # [He/She]'ll make a good sacrifice to [HighGodName]
		tooltip_info_custom = available_due_to_warrior_lodge

		trigger = {
			has_dlc = "Holy Fury"
			is_member_of_any_warrior_lodge_trigger = yes
			has_religion_matching_joined_warrior_lodge_trigger = yes
		}

		custom_tooltip = { text = EVTOPTC50020_TT }

		if = {
			limit = { event_target:captured_commander = { prisoner = yes } }

			add_kinslayer_trait_effect = yes

			if = { # If you already have three instances of this modifier...
				limit = {
					has_instances_of_character_modifier = {
						name = sacrificed_prisoner
						amount >= 3
					}
				}

				# Do some hidden removal and adding, in order to refresh the final date of the modifier...
				hidden_effect = {
					remove_character_modifier = sacrificed_prisoner # Removes all instances

					while = {
						count = 2

						add_character_modifier = {
							name = sacrificed_prisoner
							days = 1000
							stacking = yes
						}
					}
				}

				add_character_modifier = { # Add 3rd
					name = sacrificed_prisoner
					days = 1000
					stacking = yes
				}
			}

			else = { # If you don't have three instances, just add one...
				add_character_modifier = {
					name = sacrificed_prisoner
					days = 1000
					stacking = yes
				}
			}

			hidden_effect = {
				event_target:captured_commander = {
					character_event = { id = 50021 }
				}

				if = {
					limit = {
						OR = {
							has_religion_feature = religion_ritual_sacrifice
							religion_openly_aztec_or_reformed_trigger = yes
						}
					}

					if = { # A foreign religious head is also quite good
						limit = {
							event_target:captured_commander = {
								controls_religion = yes
								NOT = { religion = ROOT }
							}
						}

						change_variable = {
							which = burned_hearts_points
							value = 2
						}
					}

					if = { # A foreign emperor is also well accepted.
						limit = {
							event_target:captured_commander = {
								higher_tier_than = KING
								NOT = { religion = ROOT }
							}
						}

						change_variable = {
							which = burned_hearts_points
							value = 2
						}
					}

					bloodthirsty_tiered_traits_effect = yes
				}
			}
		}

		ai_chance = {
			factor = 1

			mult_modifier = {
				factor = 2
				is_rival = event_target:captured_commander
			}

			mult_modifier = {
				factor = 0.01
				trait = kind
			}

			mult_modifier = {
				factor = 1.5
				is_evil_trigger = yes
			}
		}
	}

	# Regular option...
	option = {
		name = {
			text = PERFECT
			trigger = {
				NOT = { is_rival = event_target:captured_commander }
			}
		}
		name = {
			text = EVTOPTB50020 # My rival, no less? Great!
			trigger = { is_rival = event_target:captured_commander }
		}

		ai_chance = { factor = 10 }
	}

}

# Prisoner receives event informing that enemy_liege has decided to sacrifice you to the gods instead of simply taking you prisoner. Shiiiit.
character_event = {
	id = 50021
	title = sacrificed_in_battle
	desc = EVTDESC50021
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	immediate = {
		save_event_target_as = sacrificed

		if = {
			limit = { multiplayer = yes } # insta-death in MP

			death = {
				death_reason = death_sacrificed
				killer = FROM
			}
		}
	}

	option = {
		name = {
			text = EVTOPTA50021 # I can't believe this is how it ends
			trigger = { NOT = { same_society_as = FROM } }
		}
		name = {
			text = EVTOPTB50021 # Noo..! For [society], why?
			trigger = { same_society_as = FROM }
		}

		tooltip = {
			FROM = {
				show_scope_change = no

				add_character_modifier = {
					name = sacrificed_prisoner
					days = 1000
					stacking = yes
				}
			}
		}

		if = {
			limit = { multiplayer = no }

			death = {
				death_reason = death_sacrificed
				killer = event_target:enemy_liege
			}
		}

		if = { # Notify liege
			limit = { independent = no }

			liege = {
				character_event = { id = 50022 }
			}
		}
	}
}

character_event = {
	id = 50022
	desc = EVTDESC50022
	picture = GFX_evt_magic_ritual

	notification = yes
	is_triggered_only = yes

	ai = no

	option = {
		name = OK # EVTOPTA50022 is missing, but not needed (notification only)
	}
}

###############################################

# Petition liege to release prisoner - Setup
character_event = {
	id = 50024

	is_triggered_only = yes # on_become_imprisoned_any_reason
	hide_window = yes

	friends = yes

	trigger = {
		host = {
			ROOT = {
				is_vassal_or_below_of = PREV

				any_friend = {
					vassal_of = PREVPREV
					is_playable = yes
					is_adult = yes
					prisoner = no
				}
			}
		}
	}

	immediate = {
		save_event_target_as = imprisoned_friend

		host = {
			save_event_target_as = captor
		}

		any_friend = {
			limit = {
				vassal_of = event_target:captor
				is_playable = yes
				is_adult = yes
				prisoner = no
			}

			score_value = {
				value = 10
				interesting_courtier_selection_score = yes
			}

			character_event = {
				id = 50025
				years = 1
				random = 1155 # 3 years 2 months
			}
		}
	}
}

# Petition liege to release prisoner
character_event = {
	id = 50025
	desc = EVTDESC50025
	picture = GFX_evt_emissary

	is_triggered_only = yes

	only_playable = yes
	friends = yes
	only_capable = yes
	prisoner = no
	war = no

	trigger = {
		is_abroad = no
		independent = no
		in_command_trigger = no

		event_target:imprisoned_friend = {
			prisoner = yes
			is_vassal_or_below_of = event_target:captor
			host = { character = event_target:captor }
			NOT = { has_character_flag = petition_release_prisoner }
		}
	}

	fail_trigger_effect = {
		if = {
			limit = {
				is_playable = yes
				vassal_of = event_target:captor

				event_target:imprisoned_friend = {
					is_friend = ROOT
					prisoner = yes
					is_vassal_or_below_of = event_target:captor
					host = { character = event_target:captor }
					NOT = { has_character_flag = petition_release_prisoner }
				}
			}

			repeat_event = {
				id = 50025
				months = 2
			}
		}
	}

	option = {
		name = EVTOPTA50025

		liege = {
			show_scope_change = no

			character_event = {
				id = 50026
				tooltip = EVTTOOLTIP50026
			}
		}

		event_target:imprisoned_friend = {
			set_character_flag = petition_release_prisoner
		}
	}

	option = {
		name = EVTOPTB50025

		reverse_opinion = {
			name = opinion_disgruntled
			who = event_target:imprisoned_friend
			years = 5
		}
	}
}

# Liege responds
character_event = {
	id = 50026
	desc = EVTDESC50026
	picture = GFX_evt_emissary

	is_triggered_only = yes

	option = {
		name = EVTOPTA50026

		prestige = -50

		event_target:imprisoned_friend = {
			show_scope_change = no

			imprison = no
		}

		# any_vassal = {
		# 	show_scope_change = no
		#
		# 	limit = { prisoner = no }
		#
		# 	opinion = {
		# 		name = opinion_released_prisoner
		# 		who = ROOT
		# 		months = 30
		# 	}
		# }
	}

	option = {
		name = EVTOPTB50026

		any_vassal = {
			show_scope_change = no

			opinion = {
				name = opinion_not_release_prisoner
				who = ROOT
				years = 10
			}
		}
	}
}