﻿
namespace = dungeon_ongoing

#0000 - 0999: Ongoing events
#9000 - 9999: Long term imprisonment events

##############################
# Regular Ongoing Events
#	0001-0999
##############################

#Crazy neighbors bother you
#by Linnéa Thimrén
dungeon_ongoing.0001 = {
	type = character_event
	title = dungeon_ongoing.0001.t
	desc = dungeon_ongoing.0001.desc

	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = stress
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		NOT = { has_character_flag = had_dungeon_ongoing_0001_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.7
			time_in_prison_type = {
				days > 730
			}
		}
		compare_modifier = {
			value = stress
			multiplier = -0.01
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_dungeon_ongoing_0001_event
			days = 730
		}
	}

	option = { #Make it stop!
		name = dungeon_ongoing.0001.a
		stress_impact = {
			base = medium_stress_gain
		}
	}
	
	option = { #Talk to the rambling prisoner
		name = dungeon_ongoing.0001.b
		trigger = {
			OR = {
				has_trait = lunatic
				has_trait = gregarious
				has_diplomacy_lifestyle_trait_trigger = yes
			}
		}
		exclusive = yes
		trait = lunatic_1
		trait = gregarious
		trait = family_first
		trait = august
		stress_impact = {
			base = medium_stress_loss
		}
	}
}


#Able to wait patiently
#by Linnéa Thimrén
dungeon_ongoing.0002 = {
	type = character_event
	title = dungeon_ongoing.0002.t
	desc = dungeon_ongoing.0002.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = boredom
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		NOT = { has_character_flag = had_event_dungeon_ongoing_0002 }
	}

	weight_multiplier = {
		base = 0.2
		modifier = {
			add = 0.8
			has_trait = patient
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0002
			days = 1825
		}
	}

	option = { #I have to get out
		name = dungeon_ongoing.0002.a
		stress_impact = {
			base = minor_stress_gain
		}
	}

	option = { #I can wait
		name = dungeon_ongoing.0002.b
		trigger = {
			has_trait = patient
		}
		exclusive = yes
		trait = patient
		stress_impact = {
			base = medium_stress_loss
		}
	}
}


#Guards threaten to give you a beating
#by Linnéa Thimrén
dungeon_ongoing.0003 = {
	type = character_event
	title = dungeon_ongoing.0003.t
	desc = dungeon_ongoing.0003.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = beg
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		NOT = { has_character_flag = had_event_dungeon_ongoing_0003 }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.8
			has_trait_rank = {
				trait = wounded
				rank = 2
			}
		}
		modifier = {
			add = -0.5
			NOT = { has_trait = stubborn }
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0003
			days = 1825
		}
	}

	option = { #Fine, I'll back off
		name = dungeon_ongoing.0003.a
		trigger = {
			NOT = { has_trait = stubborn }
		}
		stress_impact = {
			base = minor_stress_gain
		}
	}

	option = { #I won't keep quiet
		name = dungeon_ongoing.0003.b
		trait = stubborn
		increase_wounds_effect = { REASON = dungeon }
	}
}


#A wound goes infected
#by Linnéa Thimrén
dungeon_ongoing.0004 = {
	type = character_event
	title = dungeon_ongoing.0004.t
	desc = dungeon_ongoing.0004.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = pain
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		has_trait = wounded
		NOT = { has_character_modifier = infected_wound_modifier }
		NOT = { has_character_flag = recently_recovered_from_infection }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			has_trait_rank = {
				trait = wounded
				rank > 1
			}
		}
		modifier = {
			add = 1
			has_trait_rank = {
				trait = wounded
				rank > 2
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_illness"
		imprisoner = { save_scope_as = bg_override_char }
	}

	option = {
		name = dungeon_ongoing.0004.a
		flavor = dungeon_no_response_tooltip
		add_character_modifier = {
			modifier = infected_wound_modifier
		}
	}
}


#Infection passes in prison
#by Linnéa Thimrén
dungeon_ongoing.0005 = {
	type = character_event
	title = dungeon_ongoing.0005.t
	desc = dungeon_ongoing.0005.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = shame
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		has_character_modifier = infected_wound_modifier
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_illness"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = recently_recovered_from_infection
			days = 730
		}
		remove_character_modifier = infected_wound_modifier
		add_character_flag = will_get_scar
	}

	option = {
		name = dungeon_ongoing.0005.a
	}
}



#You are content, so prison isn't sooo bad
#by Linnéa Thimrén
dungeon_ongoing.0006 = {
	type = character_event
	title = dungeon_ongoing.0006.t
	desc = dungeon_ongoing.0006.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = boredom
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		NOT = { has_character_flag = had_event_dungeon_ongoing_0006 }
		has_trait = content
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0006
			days = 1825
		}
	}

	option = { #I have to get out
		name = dungeon_ongoing.0006.a
		stress_impact = {
			base = minor_stress_gain
		}
	}

	option = { #I can wait
		name = dungeon_ongoing.0006.b
		trigger = {
			has_trait = content
		}
		exclusive = yes
		trait = content
		stress_impact = {
			base = medium_stress_loss
		}
	}
}


#The dungeon is torture for ambitious people
#by Linnéa Thimrén
dungeon_ongoing.0007 = {
	type = character_event
	title = dungeon_ongoing.0007.t
	desc = dungeon_ongoing.0007.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = boredom
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		has_trait = ambitious
		NOT = { has_character_flag = had_event_dungeon_ongoing_0007 }
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0007
			days = 1825
		}
	}

	option = { #Hold on to hope!
		name = dungeon_ongoing.0007.a
		trigger = { has_trait = ambitious }
		trait = ambitious
		stress_impact = {
			base = medium_stress_gain
		}
		ai_chance = {
		 	base = 100
		}
	}

	option = { #Focus on survival
		name = dungeon_ongoing.0007.b
		trigger = {
			number_of_personality_traits > 2
		}
		remove_trait = ambitious
		stress_impact = {
			base = major_stress_loss
		}
		ai_chance = {
			base = 1
		}
	}
}


#The dungeon is torture for impatient people
#by Linnéa Thimrén
dungeon_ongoing.0008 = {
	type = character_event
	title = dungeon_ongoing.0008.t
	desc = dungeon_ongoing.0008.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = delirium
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		has_trait = impatient
		NOT = { has_character_flag = had_event_dungeon_ongoing_0008 }
	}

	weight_multiplier = {
		base = 1
		modifier = { #Three times as likely to fire in your first year
			add = 2
			time_in_prison_type = {
				days < 365
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0008
			days = 1825
		}
	}

	option = {
		name = dungeon_ongoing.0008.a
		trait = impatient
		stress_impact = {
			base = medium_stress_gain
		}
	}
}


#You prison pet is there to comfort you
#by Linnéa Thimrén
dungeon_ongoing.0009 = {
	type = character_event
	title = dungeon_ongoing.0009.t
	desc = dungeon_ongoing.0009.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = happiness
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		exists = var:prison_pet_variable
		NOT = { has_character_flag = had_event_dungeon_ongoing_0009 }
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0009
			days = 1825
		}
	}

	option = {
		name = dungeon_ongoing.0009.a
		stress_impact = {
			base = medium_stress_loss
		}
	}
}

# You contemplate smuggling a letter out to your family, beseeching them for help
# Clans only
dungeon_ongoing.0010 = {
	type = character_event
	title = dungeon_ongoing.0010.t
	desc = dungeon_ongoing.0010.desc

	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = stress
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
 
	trigger = {
		age >= 12
		government_has_flag = government_is_clan
		exists = top_liege
		exists = house
		# You belong to the same government as your imprisoner
		imprisoner = {
			top_liege ?= root.top_liege
		}
		NOT = { has_character_flag = had_event_dungeon_ongoing_0010 }
		house = {
			any_house_member = {
				NOR = {
					this = root
					this = root.imprisoner
				}
				is_available_adult = yes
				# Belongs to the same government as the imprisoner
				# This is so that the imprisoner actually cares about their opinion
				top_liege ?= root.imprisoner.top_liege
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		add_character_flag = {
			flag = had_event_dungeon_ongoing_0010
			days = 365
		}
		imprisoner = {
			save_scope_as = imprisoner
			save_scope_as = bg_override_char
		}
		save_scope_as = prisoner
		# Grab the most likely person to write to
		# This will be the person we're closest to and has the most military power
		house = {
			random_house_member = {
				limit = {
					NOR = {
						this = scope:prisoner
						this = scope:imprisoner
					}
					is_available_adult = yes
				}
				weight = {
					base = 1
					opinion_modifier = {
						who = this
						opinion_target = scope:prisoner
						multiplier = 2
					}
					modifier = {
						add = {
							value = max_military_strength
							subtract = scope:imprisoner.max_military_strength
							divide = 50
							min = 50 # Weights landed over unlanded
						}
					}
				}
				save_scope_as = letter_recipient
			}
		}		
		# Save the difference between our diplomacy/intrigue skills and our imprisoners'
		# This will be important to determine which of the smuggle letter options to show
		save_scope_value_as = {
			name = diplomacy_skill_difference
			value = {
				value = diplomacy
				subtract = scope:imprisoner.diplomacy
			}
		}
		save_scope_value_as = {
			name = intrigue_skill_difference
			value = {
				value = intrigue
				subtract = scope:imprisoner.intrigue
			}
		}
	}

	option = { # Risk writing them: Diplomacy
		name = dungeon_ongoing.0010.a
		custom_tooltip = dungeon_ongoing.0010.a.tt
		# The difference between our diplomacy skill and the imprisoner's diplomacy skill is higher than
		# The difference between our intrigue skill and theirs
		# I.e. this option has a higher chance of success than option b
		trigger = {
			scope:diplomacy_skill_difference >= scope:intrigue_skill_difference
		}
		duel = {
			skill = diplomacy
			value = scope:imprisoner.diplomacy
			7 = { # Success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -6.67
				}
				desc = dungeon_ongoing.0010.a.success.t
				send_interface_toast = {
					title = dungeon_ongoing.0010.a.success.t
					custom_tooltip = dungeon_ongoing.0010.a.success.desc
					left_icon = scope:letter_recipient
				}
				scope:letter_recipient = {
					trigger_event = {
						id = dungeon_ongoing.0011
						days = { 7 14 }
					}
				}
			}
			3 = { # Failure, get beaten
				desc = dungeon_ongoing.0010.a.failure.t
				send_interface_toast = {
					type = event_toast_effect_bad
					title = dungeon_ongoing.0010.a.failure.t
					left_icon = scope:imprisoner
					increase_wounds_effect = { REASON = dungeon }
				}
			}
		}
		stress_impact = {
			craven = minor_stress_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = {
					value = scope:diplomacy_skill_difference
					multiply = 4
				}
			}
		}
	}

	option = { # Risk writing them: Intrigue
		name = dungeon_ongoing.0010.b
		custom_tooltip = dungeon_ongoing.0010.b.tt
		trigger = {
			scope:diplomacy_skill_difference < scope:intrigue_skill_difference
		}
		duel = {
			skill = intrigue
			value = scope:imprisoner.intrigue
			7 = { # Success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
					min = -6.67
				}
				desc = dungeon_ongoing.0010.a.success.t
				send_interface_toast = {
					title = dungeon_ongoing.0010.a.success.t
					custom_tooltip = dungeon_ongoing.0010.a.success.desc
					left_icon = scope:letter_recipient
				}
				scope:letter_recipient = {
					trigger_event = {
						id = dungeon_ongoing.0011
						days = { 7 14 }
					}
				}
			}
			3 = { # Failure, get beaten
				desc = dungeon_ongoing.0010.b.failure.t
				send_interface_toast = {
					type = event_toast_effect_bad
					title = dungeon_ongoing.0010.b.failure.t
					left_icon = root
					increase_wounds_effect = { REASON = dungeon }
				}
			}
		}
		stress_impact = {
			craven = minor_stress_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = {
					value = scope:intrigue_skill_difference
					multiply = 4
				}
			}
		}
	}

	option = { # Don't risk writing them
		name = dungeon_ongoing.0010.c
		if = {
			limit = {
				OR = {
					has_trait = patient
					has_trait = craven
					has_trait = content
				}
			}
			# No stress impact
		}
		else_if = {
			limit = {
				OR = {
					has_trait = impatient
					has_trait = brave
					has_trait = ambitious
				}
			}
			add_stress = medium_stress_impact_gain
		}
		else = {
			add_stress = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			opinion_modifier = {
				who = scope:prisoner
				opinion_target = scope:letter_recipient
				multiplier = 4
			}
		}
	}

}

# A family member beseeches you to rescue them from prison
dungeon_ongoing.0011 = {
	type = character_event
	title = dungeon_ongoing.0011.t
	desc = dungeon_ongoing.0011.desc

	theme = family
	override_background = {
		reference = dungeon
	}
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = scope:prisoner
		animation = beg
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		# Making sure our prisoner is still imprisoned by the same person...
		scope:prisoner = {
			is_alive = yes
			is_imprisoned_by = scope:imprisoner
		}
	}

	option = { # Try to guilt-trip the imprisoner
		name = dungeon_ongoing.0011.a
		# If the imprisoner is an AI, then duel with diplomacy
		if = {
			limit = {
				scope:imprisoner = { is_ai = yes}
			}
			duel = {
				skill = diplomacy
				value = scope:imprisoner.diplomacy
				6 = { # Successful convincing imprisoner
					desc = dungeon_ongoing.0011.a.success.t
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.25
					}
					# More likely if imprisoner likes you
					opinion_modifier = {
						who = scope:imprisoner
						opinion_target = scope:letter_recipient
						multiplier = 0.1
					}
					# More likely if imprisoner fears your military might
					modifier = {
						add = {
							value = max_military_strength
							subtract = scope:imprisoner.max_military_strength
							divide = 500
							min = -2
						}
					}
					send_interface_toast = {
						type = event_toast_effect_good
						title = dungeon_ongoing.0011.a.success.t
						left_icon = scope:imprisoner
						right_icon = scope:prisoner
						scope:prisoner = {
							release_from_prison = yes
						}
						add_clan_unity_interaction_effect = {
							CHARACTER = scope:letter_recipient
							TARGET = scope:imprisoner
							VALUE = minor_unity_gain
							DESC = clan_unity_release_from_prison.desc
							REVERSE_NON_HOUSE_TARGET = no
						}
					}
					reverse_add_opinion = {
						target = scope:prisoner
						modifier = released_from_prison
					}
				}
				4 = { # Did not convince imprisoner
					desc = dungeon_ongoing.0011.a.failure.t
					send_interface_toast = {
						type = event_toast_effect_bad
						title = dungeon_ongoing.0010.a.failure.t
						left_icon = scope:imprisoner
						reverse_add_opinion = {
							target = scope:imprisoner
							modifier = overreaction_opinion
							opinion = -15
						}
						add_clan_unity_interaction_effect = {
							CHARACTER = scope:letter_recipient
							TARGET = scope:imprisoner
							VALUE = minor_unity_loss
							DESC = clan_unity_unrelease_from_prison.desc
							REVERSE_NON_HOUSE_TARGET = no
						}
					}
					scope:prisoner = {
						trigger_event = dungeon_ongoing.0014
					}
					hidden_effect = {
						reverse_add_opinion = {
							target = scope:imprisoner
							modifier = disappointed_opinion
							opinion = -15
						}
					}
				}
			}
		}
		# Otherwise trigger dungeon_ongoing.0013 for the imprisoner where they will decide for themselves
		else = {
			custom_tooltip = dungeon_ongoing.0011.a_not_ai
			scope:imprisoner = {
				trigger_event = {
					id = dungeon_ongoing.0013
					days = { 3 7 }
				}
			}
		}
		ai_chance = {
			base = 50
			# More likely if the letter recipient likes the prisoner
			opinion_modifier = {
				who = scope:letter_recipient
				opinion_target = scope:prisoner
				multiplier = 2
			}
		}
	}

	option = { # Let them rot!
		name = dungeon_ongoing.0011.b
		scope:prisoner = {
			add_opinion = {
				target = scope:letter_recipient
				modifier = abandoned_me_opinion
			}
			trigger_event = dungeon_ongoing.0012
		}
		# Lose piety, unless religion condones callousness
		if = {
			limit = {
				faith = {
					NOR = {
						trait_is_virtue = callous
						trait_is_virtue = sadistic
						trait_is_sin = compassionate
					}
				}
			}
			add_piety = minor_piety_loss
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_compassion = -0.5
			}
			# More likely if the letter recipient hates the prisoner
			opinion_modifier = {
				who = scope:letter_recipient
				opinion_target = scope:prisoner
				multiplier = -1
			}
		}
	}
}

# Letter to family member goes ignored
dungeon_ongoing.0012 = {
	type = character_event
	title = dungeon_ongoing.0012.t
	desc = dungeon_ongoing.0012.desc

	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			animation = boredom
		}
		triggered_animation = {
			trigger = {
				NOR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			animation = stress
		}
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		is_imprisoned_by = scope:imprisoner
	}

	option = { # Be sad, unless you're callous
		name = dungeon_ongoing.0012.a
		stress_impact = {
			base = medium_stress_gain
		}
	}

	option = { # Bah, who needs family?
		name = dungeon_ongoing.0012.b
		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
			}
		}
		trait = callous
		trait = sadistic
		exclusive = yes
	}
}

# Release a clan member from your prison or not?
dungeon_ongoing.0013 = {
	type = character_event
	title = dungeon_ongoing.0013.t
	desc = {
		desc = dungeon_ongoing.0013.desc_intro
		first_valid = {
			# In this desc, the advocate is imploring you to release the prisoner on the basis of compassion + house unity
			# So don't trigger it if that advocate also has another house member imprisoned and would be a hypocrite
			triggered_desc = {
				trigger = {
					is_in_same_clan_as_trigger = { CHARACTER = scope:letter_recipient }
					scope:letter_recipient = {
						NOR = {
							ai_compassion < low_positive_ai_value
							any_prisoner = {
								house = scope:letter_recipient.house
							}
						}
					}
				}
				desc = dungeon_ongoing.0013.desc_reasoning_compassionate
			}
			desc = dungeon_ongoing.0013.desc_reasoning_other
		}
	}

	theme = family
	override_background = {
		reference = throne_room
	}
	left_portrait = {
		character = scope:letter_recipient
		animation = disapproval
	}
	right_portrait = {
		character = scope:imprisoner
		animation = personality_rational
	}
	lower_left_portrait = scope:prisoner

	trigger = {
		scope:prisoner = {
			is_alive = yes
			is_imprisoned_by = scope:imprisoner
		}
		scope:letter_recipient = {
			is_available_adult = yes
			top_liege = scope:imprisoner.top_liege
		}
	}

	immediate = {
		top_liege.primary_title = { save_scope_as = realm_title }
	}

	option = { # Release the prisoner
		name = dungeon_ongoing.0013.a
		scope:prisoner = {
			release_from_prison = yes
		}
		scope:prisoner = {
			add_opinion = {
				target = scope:letter_recipient
				modifier = released_from_prison
			}
		}
		reverse_add_opinion = {
			target = scope:letter_recipient
			modifier = grateful_opinion
			opinion = 20
		}
		# Add house unity if either the petitioner or the prisoner are part of your house
		if = {
			limit = {
				OR = {
					is_in_same_clan_as_trigger = { CHARACTER = scope:letter_recipient }
					is_in_same_clan_as_trigger = { CHARACTER = scope:prisoner }
				}
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = scope:imprisoner
				TARGET = scope:letter_recipient
				VALUE = minor_unity_gain
				DESC = clan_unity_grant_prisoner_release.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			# More likely to release if they like the concerned family member
			opinion_modifier = {
				opinion_target = scope:letter_recipient
				multiplier = 0.25
			}
		}
	}

	option = { # Don't release the prisoner
		name = dungeon_ongoing.0013.b
		reverse_add_opinion = {
			target = scope:letter_recipient
			modifier = disappointed_opinion
			opinion = -20
		}
		# Remove house unity if either the petitioner or the prisoner are part of your house
		if = {
			limit = {
				OR = {
					is_in_same_clan_as_trigger = { CHARACTER = scope:letter_recipient }
					is_in_same_clan_as_trigger = { CHARACTER = scope:prisoner }
				}
			}
			add_clan_unity_interaction_effect = {
				CHARACTER = scope:imprisoner
				TARGET = scope:letter_recipient
				VALUE = minor_unity_loss
				DESC = clan_unity_refused_release_request.desc
				REVERSE_NON_HOUSE_TARGET = no
			}
		}
		scope:prisoner = {
			trigger_event = dungeon_ongoing.0014
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = 0.25
				ai_compassion = 0.2
			}
		}
	}
}

# Your family member's request was ignored
dungeon_ongoing.0014 = {
	type = character_event
	title = dungeon_ongoing.0014.t
	desc = dungeon_ongoing.0014.desc

	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = stress
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	trigger = {
		is_alive = yes
		is_imprisoned_by = scope:imprisoner
	}

	option = { # At least they tried
		name = dungeon_ongoing.0014.a
		stress_impact = {
			base = minor_stress_loss
		}
	}

	option = { # But I want to leave NOW!
		name = dungeon_ongoing.0014.b
		trigger = {
			OR = {
				has_trait = impatient
				has_trait = ambitious
			}
		}
		trait = impatient
		trait = ambitious
		exclusive = yes
		stress_impact = {
			base = minor_stress_gain
		}
	}
}

#########################
# Long-term Imprisonment Events
#	9000-9999
#########################

#Become Ill
dungeon_ongoing.9001 = {
	type = character_event
	title = dungeon_ongoing.9001.t
	desc = dungeon_ongoing.9001.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = sick
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		NOT = { has_trait = ill }
		NOT = { has_character_flag = had_long_term_dungeon_stay_event }
		time_in_prison_type = {
			years > 5
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait = pneumonic
		}
	}

	immediate = {
		play_music_cue = "mx_cue_illness"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_long_term_dungeon_stay_event
			days = 365
		}
		contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
	}

	option = {
		name = dungeon_ongoing.9001.a
	}
}

#Become Pneumonic
dungeon_ongoing.9002 = {
	type = character_event
	title = dungeon_ongoing.9002.t
	desc = dungeon_ongoing.9002.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = cough
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		NOT = { has_trait = pneumonic }
		NOT = { has_character_flag = had_long_term_dungeon_stay_event }
		time_in_prison_type = {
			years > 5
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait = ill
		}
	}

	immediate = {
		play_music_cue = "mx_cue_illness"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_long_term_dungeon_stay_event
			days = 365
		}
		contract_disease_effect = { DISEASE = pneumonic TREATMENT_EVENT = yes }
	}

	option = {
		name = dungeon_ongoing.9002.a
	}
}


#Add Stress
dungeon_ongoing.9003 = {
	type = character_event
	title = dungeon_ongoing.9003.t
	desc = dungeon_ongoing.9003.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = sadness
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		NOT = { has_character_flag = had_long_term_dungeon_stay_event }
		time_in_prison_type = {
			years > 5
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait = patient
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_long_term_dungeon_stay_event
			days = 365
		}
	}

	option = {
		name = dungeon_ongoing.9003.a
		stress_impact = {
			base = massive_stress_gain
		}
	}
}



#Add Stress
dungeon_ongoing.9004 = {
	type = character_event
	title = dungeon_ongoing.9004.t
	desc = dungeon_ongoing.9004.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = stress
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}
	
	trigger = {
		NOT = { has_character_flag = had_long_term_dungeon_stay_event }
		time_in_prison_type = {
			years > 5
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait = patient
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		add_character_flag = {
			flag = had_long_term_dungeon_stay_event
			days = 365
		}
	}

	option = {
		name = dungeon_ongoing.9004.a
		stress_impact = {
			base = massive_stress_gain
		}
	}
}


#Prison pet dies
#by Linnéa Thimrén
dungeon_ongoing.9005 = {
	type = character_event
	title = dungeon_ongoing.9005.t
	desc = dungeon_ongoing.9005.desc
	
	theme = prison
	soundeffect = in_the_dungeon_event
	left_portrait = {
		character = root
		animation = grief
		override_imprisonment_visuals = yes
		outfit_tags = { beggar_rags }
	}

	
	trigger = {
		exists = var:prison_pet_variable
		NOT = { has_character_flag = had_long_term_dungeon_stay_event }
		time_in_prison_type = {
			years > 5
		}
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		imprisoner = { save_scope_as = bg_override_char }
		random_dummy_gender_effect = yes
		add_character_flag = {
			flag = had_long_term_dungeon_stay_event
			days = 365
		}
	}

	option = {
		name = dungeon_ongoing.9005.a
		stress_impact = {
			base = medium_stress_gain
		}
		if = {
			limit = {
				var:prison_pet_variable = flag:rat
			}
			remove_character_modifier = prison_pet_rat_modifier
		}
		else_if = {
			limit = {
				var:prison_pet_variable = flag:stone
			}
			remove_character_modifier = prison_pet_stone_modifier
		}
		else_if = {
			limit = {
				var:prison_pet_variable = flag:spoon
			}
			remove_character_modifier = prison_pet_spoon_modifier
		}
		else_if = {
			limit = {
				var:prison_pet_variable = flag:cockroach
			}
			remove_character_modifier = prison_pet_cockroach_modifier
		}
	}
	after = {
		remove_variable = prison_pet_variable
	}
}
