﻿### EK NOTE: Removed references to vanilla religions
### EK TODO: Add our own pet names

namespace = pet_animal

###########################################
# CAT (0001-0999), by Linnéa Thimrén
#	pet_animal.0001 - Name your cat!
#
# Other events for your cat, by Linnéa Thimrén
#	pet_animal.0101 - Random encounter, get some gold
#	pet_animal.0103 - Your cat charms a vassal
#	pet_animal.0104 - Chill with your cat and lose stress
#	pet_animal.0105 - Your cat exposes a courtier's/vassal's secret
#	pet_animal.0106 - Your spouse is allergic!
#	pet_animal.0109 - Your cat kills rodents
#	pet_animal.0110 - Your cat insults a vassal
#	pet_animal.0197 - Your cat has disappeared
#	pet_animal.0199 - Cat dies
#
# Additional events for your cat, by Nick Meredith
#   pet_animal.0200 - Your cat falls off a desk
#   pet_animal.0201 - Your cat knocks something off a shelf
#   pet_animal.0202 - Your cat interrupts some coitus
#   pet_animal.0203 - Your cat loves a random courtier
#   pet_animal.0204 - Your cat makes you feel better when you're sick
#   pet_animal.0205 - Your cat keeps interrupting you
#
# DOG (1001-1999), by Linnéa Thimrén
#	pet_animal.1001 - Name your dog!
#
# Other events for your dog, by Linnéa Thimrén
#	pet_animal.1101 - Go out and walk your dog, get health modifier
#	pet_animal.1102 - Dog runs away!
#	pet_animal.1107 - Your dog charms a vassal
#	pet_animal.1108 - Your dog exposes a scheme targeting you
#	pet_animal.1109 - Meet another dog!
#	pet_animal.1113 - Bring your dog to a council meeting?
#	pet_animal.1118 - Your dog insults a vassal
#	pet_animal.1199 - Dog dies
#
#
# CAT AND DOG (2001-2999), by Linnéa Thimrén
#	pet_animal.2001 - You have both a dog AND a cat
#	pet_animal.2002 - You have both a dog AND a cat. Things don't really work out
#
#
# OTHER PEOPLE HAVE PETS (5001-5999), by Linnéa Thimrén
#	pet_animal.5001 - Your rival has a cat...
#	pet_animal.5002 - Your rival has a dog...
#
# DOG DECISION EVENTS
#	pet_animal.6001 - You pet your dog
#	pet_animal.6002 - You pet your dog v.2
#	pet_animal.6003 - Your dog finds a claim :O
#	pet_animal.6004 - Your dog lashes out D:
#
# CAT DECISION EVENTS
#	pet_animal.6051 - You pet your cat
#	pet_animal.6052 - You pet your cat v.2
#	pet_animal.6055 - Decide if your spouse can be allergic
#
# EAGLE (3001-3999), by Ariana Tranumn
#	pet_animal.3001 - Name your eagle!
#   pet_animal.3010 - Your eagle goes missing
#	pet_animal.3020 - Your decide to let your eagle go (as per tradition)
#   pet_animal.3030 - Your eagle is injured randomly
#   pet_animal.3040 - You train your eagle
# 	pet_animal.3050 - Your rival has an eagle...
#   pet_animal.3060 - Teach your kid how to hunt with an eagle, wholesome chill moment
# 	pet_animal.3070 - Your eagle helps you with rizz
#  	pet_animal.3080 - Your eagle brings you a gift
#   pet_animal.3199 - Eagle dies

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


###########################################
# Name your cat
#	0001-0999
###########################################

#Name your cat
#by Linnéa Thimrén
pet_animal.0001 = {
	type = character_event
	title = pet_animal.0001.t
	desc = pet_animal.0001.desc
	theme = pet
	left_portrait = {
		character = root
		animation = personality_cynical
	}

	immediate = {
		if = {
			limit = {
				NOT = {
					has_character_flag = city_cat
				}
			}
			#To give some options to show
			assign_name_options_cat_story_cycle_effect = yes
			assign_name_options_cat_story_cycle_effect = yes
			assign_name_options_cat_story_cycle_effect = yes
			play_music_cue = "mx_cue_low_key_positive"

			if = {
				limit = { is_ai = yes }
				random_list = {
					1 = {
						trigger = { has_character_flag = name_mite }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_mite
						}
					}
					1 = {
						trigger = { has_character_flag = name_paws }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_paws
						}
					}
					1 = {
						trigger = { has_character_flag = name_mittens }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_mittens
						}
					}
					1 = {
						trigger = { has_character_flag = name_gray }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_gray
						}
					}
					1 = {
						trigger = { has_character_flag = name_flame }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_flame
						}
					}
					1 = {
						trigger = { has_character_flag = name_snow }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_snow
						}
					}
					1 = {
						trigger = { has_character_flag = name_shadow }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_shadow
						}
					}
					### EK EDIT: Disabled since they're tied to cultures
					# 1 = {
						# trigger = { has_character_flag = name_gyb }
						# set_variable = {
							# name = story_cycle_cat_name
							# value = flag:cat_name_gyb
						# }
					# }
					# 1 = {
						# trigger = { has_character_flag = name_meone }
						# set_variable = {
							# name = story_cycle_cat_name
							# value = flag:cat_name_meone
						# }
					# }
					# 1 = {
						# trigger = { has_character_flag = name_cruibne }
						# set_variable = {
							# name = story_cycle_cat_name
							# value = flag:cat_name_cruibne
						# }
					# }
					1 = {
						trigger = { has_character_flag = name_spooky }
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_spooky
						}
					}
					### EK EDIT: Dev pet names
					1 = {
						trigger = { has_character_flag = name_alduin } # Singe's cat
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_alduin
						}
					}
					1 = {
						trigger = { has_character_flag = name_mana } # Noodle's cat
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_mana
						}
					}
					1 = {
						trigger = { has_character_flag = name_sir_sabre_cat } # random eso cat
						set_variable = {
							name = story_cycle_cat_name
							value = flag:cat_name_sir_sabre_cat
						}
					}
					#EK EDIT END
				}
			}
		}
		else = {
			location = {
				save_scope_as = location
			}
			set_variable = {
				name = cat_city
				value = scope:location
			}
			add_character_flag = name_lil_city
			add_character_flag = name_pride_of_city
			#EK EDIT
			#if = {
			#	limit = {
			#		title:b_constantinople ?= scope:location
			#	}
			#	add_character_flag = name_tigon
			#}
			#else = {
			#	add_character_flag = name_tail_of_city
			#}
			add_character_flag = name_tail_of_city
			if = {
				limit = { is_ai = yes }
				random_list = {
					1 = {
						set_variable = {
							name = story_cycle_cat_name
							value = flag:name_lil_city
						}
					}
					1 = {
						set_variable = {
							name = story_cycle_cat_name
							value = flag:name_pride_of_city
						}
					}
					1 = {
						set_variable = {
							name = story_cycle_cat_name
							value = flag:name_tail_of_city
						}
					}
				}
			}
		}
	}

	widget = {
		gui = "event_window_widget_enter_text"
		container = "dynamic_birth_name"
		controller = {
			type = text
			data = {
				key = story_cycle_cat_name
				default = {
					localization_key = name_lil_city
					trigger = {
						has_character_flag = name_lil_city
					}
				}
				default = {
					localization_key = name_pride_of_city
					trigger = {
						has_character_flag = name_pride_of_city
					}
				}
				default = {
					localization_key = name_tail_of_city
					trigger = {
						has_character_flag = name_tail_of_city
					}
				}
				#EK DISABLED
				#default = {
				#	localization_key = name_tigon
				#	trigger = {
				#		has_character_flag = name_tigon
				#	}
				#}
				default = {
					localization_key = cat_name_mite
					trigger = {
						has_character_flag = name_mite
					}
				}
				default = {
					localization_key = cat_name_paws
					trigger = {
						has_character_flag = name_paws
					}
				}
				default = {
					localization_key = cat_name_mittens
					trigger = {
						has_character_flag = name_mittens
					}
				}
				default = {
					localization_key = cat_name_gray
					trigger = {
						has_character_flag = name_gray
					}
				}
				default = {
					localization_key = cat_name_flame
					trigger = {
						has_character_flag = name_flame
					}
				}
				default = {
					localization_key = cat_name_snow
					trigger = {
						has_character_flag = name_snow
					}
				}
				default = {
					localization_key = cat_name_shadow
					trigger = {
						has_character_flag = name_shadow
					}
				}
				default = {
					localization_key = cat_name_gyb
					trigger = {
						has_character_flag = name_gyb
					}
				}
				default = {
					localization_key = cat_name_meone
					trigger = {
						has_character_flag = name_meone
					}
				}
				default = {
					localization_key = cat_name_cruibne
					trigger = {
						has_character_flag = name_cruibne
					}
				}
				###EK EDIT: Dev pet names
				default = {
					localization_key = cat_name_alduin
					trigger = {
						has_character_flag = name_alduin
					}
				}
				default = {
					localization_key = cat_name_mana
					trigger = {
						has_character_flag = name_mana
					}
				}
				default = {
					localization_key = cat_name_merlin
					trigger = {
						has_character_flag = name_merlin
					}
				}
				default = {
					localization_key = cat_name_sir_sabre_cat
					trigger = {
						has_character_flag = name_sir_sabre_cat
					}
				}
				#EK EDIT END
			}
		}
		setup_scope = {
			root = { save_scope_as = text_target }
		}
	}

	option = { 
		name = pet_animal.0001.a
	}

	after = {
		remove_character_flag = is_naming_cat
		remove_character_flag = name_gyb
		remove_character_flag = name_mite
		remove_character_flag = name_paws
		remove_character_flag = name_mittens
		remove_character_flag = name_gray
		remove_character_flag = name_flame
		remove_character_flag = name_snow
		remove_character_flag = name_shadow
		remove_character_flag = name_meone
		remove_character_flag = name_cruibne
		remove_character_flag = name_spooky
		remove_character_flag = name_lil_city
		remove_character_flag = name_pride_of_city
		remove_character_flag = name_tail_of_city
		###EK EDIT: Dev pet names
		remove_character_flag = name_alduin
		remove_character_flag = name_merlin
		remove_character_flag = name_mana
		remove_character_flag = name_sir_sabre_cat
		
		if = {
			# We entered custom text into the pop up
			limit = { NOT = { has_variable = story_cycle_cat_name } }
			set_variable = {
				name = story_cycle_cat_name
				value = flag:custom
			}
		}
	}
}

###########################################
# Other events for your cat
#	0100-0199
###########################################

#Random encounter, get some gold
#by Linnéa Thimrén
pet_animal.0101 = {
	type = character_event
	title = pet_animal.0101.t
	desc = {
		desc = pet_animal.0101.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:story = {
						var:cat_age_variable > 10
					}
				}
				desc = pet_animal.0101.desc_old
			}
			triggered_desc = {
				trigger = {
					scope:story = {
						var:cat_age_variable < 10
					}
				}
				desc = pet_animal.0101.desc_young
			}
			desc = pet_animal.0101.desc_middle
		}
		desc = pet_animal.0101.desc_ending
	}
	theme = pet
	override_background = {
		reference = corridor_day
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_0101_event }
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_0101_event
			years = 10
		}
	}

	option = { #thank you!
		name = {
			trigger = { scope:story = { var:cat_gender = flag:female } }
			text = pet_animal.0101.a_female
		}
		name = {
			trigger = { scope:story = { var:cat_gender = flag:male } }
			text = pet_animal.0101.a_male
		}
		add_gold = 2
	}
}


#Your cat charms a vassal
#by Linnéa Thimrén
pet_animal.0103 = {
	type = character_event
	title = pet_animal.0103.t
	desc = pet_animal.0103.desc
	theme = pet
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = scope:vassal
		animation = happiness
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_0103_event }
		any_vassal = {
			is_available_ai = yes
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				is_available_ai = yes
			}
			weight = {
				base = 50
				ai_value_modifier = {
					ai_compassion = 1
				}
			}
			save_scope_as = vassal
		}
		add_character_flag = {
			flag = had_pet_animal_0103_event
			years = 10
		}
	}

	option = {
		name = pet_animal.0103.a
		scope:vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 20
			}
		}
	}
}


#Chill with your cat and lose stress
#by Linnéa Thimrén
pet_animal.0104 = {
	type = character_event
	title = pet_animal.0104.t
	desc = pet_animal.0104.desc
	theme = pet
	left_portrait = {
		character = root
		animation = personality_content
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_0104_event }
		stress > normal_baseline_stress
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_0104_event
			years = 10
		}
		play_music_cue = "mx_cue_ck3_vocal_maintheme"
	}

	option = {
		name = pet_animal.0104.a
		add_stress = medium_stress_loss
	}
}


#Your cat exposes a courtier's/vassal's secret
#by Linnéa Thimrén
pet_animal.0105 = {
	type = character_event
	title = pet_animal.0105.t
	desc = {
		desc = pet_animal.0105.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_murder
					}
				}
				desc = pet_animal.0105.desc_murder
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_lover
					}
				}
				desc = pet_animal.0105.desc_lover
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_homosexual
					}
				}
				desc = pet_animal.0105.desc_homosexual
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_deviant
					}
				}
				desc = pet_animal.0105.desc_deviant
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_cannibal
					}
				}
				desc = pet_animal.0105.desc_cannibal
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_murder_attempt
					}
				}
				desc = pet_animal.0105.desc_murder_attempt
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_non_believer
					}
				}
				desc = pet_animal.0105.desc_non_believer
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_incest
					}
				}
				desc = pet_animal.0105.desc_incest
			}
			triggered_desc = {
				trigger = {
					scope:secret = {
						secret_type = secret_witch
					}
				}
				desc = pet_animal.0105.desc_witch
			}
			desc = pet_animal.0105.desc_fallback
		}
	}
	theme = pet
	left_portrait = scope:person

	trigger = {
		NOT = { has_character_flag = had_pet_animal_0105_event }
		OR = {
			any_courtier = {
				any_secret = {
					NOT = { is_known_by = root }
				}
			}
			any_vassal = {
				any_secret = {
					NOT = { is_known_by = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_0105_event
			years = 10
		}
		hidden_effect = { #As likely to get a vassal or a courtier
			random_list = {
				50 = {
					trigger = {
						any_courtier = {
								any_secret = {
									NOT = { is_known_by = root }
								}
							}
					}
					random_courtier = {
							limit = {
								any_secret = {
									NOT = { is_known_by = root }
								}
							}
							save_scope_as = person
							random_secret = {
								limit = {
									NOT = { is_known_by = root }
								}
								save_scope_as = secret
							}
						}
				}
				50 = {
					trigger = {
						any_vassal = {
								any_secret = {
									NOT = { is_known_by = root }
								}
							}
					}
					random_vassal = {
							limit = {
								any_secret = {
									NOT = { is_known_by = root }
								}
							}
							save_scope_as = person
							random_secret = {
								limit = {
									NOT = { is_known_by = root }
								}
								save_scope_as = secret
							}
						}
				}
			}
		}
		scope:secret = {
			reveal_to_without_events_effect = {
				CHARACTER = root
			}
		}
	}

	option = { #Keep it secret, keep it safe
		name = pet_animal.0105.a
	}

	option = { #Expose!
		name = pet_animal.0105.b
		scope:secret = {
			expose_secret = root
		}
	}
}

#Your spouse is allergic!
#by Linnéa Thimrén
pet_animal.0106 = {
	type = character_event
	title = pet_animal.0106.t
	desc = pet_animal.0106.desc
	theme = pet
	left_portrait = {
		character = scope:spouse
		animation = sick
	}
	lower_left_portrait = scope:receiver_1
	lower_center_portrait = scope:receiver_2
	lower_right_portrait = scope:receiver_3

	# Trigger removed as it is handled by pet_animal.6055
	immediate = {
		save_scope_as = giver
		add_character_flag = {
			flag = had_pet_animal_0106_event
			years = 10
		}
		random_spouse = {
			limit = {
				is_available_ai = yes
				NOR = {
					has_character_modifier = cat_story_allergy_modifier
					has_character_flag = forbidden_from_pet_allergies
				}
			}
			save_scope_as = spouse
		}

		#Who can you give it away to?
		if = {
			limit = {
				any_relation = {
					type = friend
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { this = scope:spouse }
				}
			}
			every_relation = {
				type = friend
				limit = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { this = scope:spouse }
				}
				add_to_list = can_get_cat
			}
		}
		if = {
			limit = {
				any_relation = {
					type = lover
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
			}
			every_relation = {
				type = lover
				limit = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
				add_to_list = can_get_cat
			}
		}
		if = {
			limit = {
				any_vassal = {
					NOT = { has_relation_rival = root }
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
			}
			every_vassal = {
				limit = {
					NOT = { has_relation_rival = root }
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
				add_to_list = can_get_cat
			}
		}
		if = { #Ehehehe, give it to another consort!
			limit = {
				any_consort = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
			}
			every_consort = {
				limit = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
				add_to_list = can_get_cat
			}
		}
		random_in_list = {
			list = can_get_cat
			save_scope_as = receiver_1
		}
		random_in_list = {
			list = can_get_cat
			limit = { NOT = { this = scope:receiver_1 } }
			save_scope_as = receiver_2
		}
		random_in_list = {
			list = can_get_cat
			limit = {
				NOR = {	
					this = scope:receiver_1
					this = scope:receiver_2
				}

			}
			save_scope_as = receiver_3
		}
	}

	option = { #Ok, I'll give it away to receiver_1
		name = pet_animal.0106.a
		trigger = {
			exists = scope:receiver_1
		}
		transfer_cat_story_cycle_to_effect = { CHARACTER = scope:receiver_1 STORY = scope:story }
		scope:receiver_1 = {
			trigger_event = pet_animal.0107
		}
	}

	option = { #Ok, I'll give it away to receiver_2
		name = pet_animal.0106.b
		trigger = {
			exists = scope:receiver_2
		}
		transfer_cat_story_cycle_to_effect = { CHARACTER = scope:receiver_2 STORY = scope:story }
		scope:receiver_2 = {
			trigger_event = pet_animal.0107
		}
	}

	option = { #Ok, I'll give it away to receiver_3
		name = pet_animal.0106.c
		trigger = {
			exists = scope:receiver_3
		}
		transfer_cat_story_cycle_to_effect = { CHARACTER = scope:receiver_3 STORY = scope:story }
		scope:receiver_3 = {
			trigger_event = pet_animal.0107
		}
	}

	option = { #No!
		name = pet_animal.0106.d
		scope:spouse = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -15
			}
			add_character_modifier = {
				modifier = cat_story_allergy_modifier
				years = 5
			}
		}
	}

	option = { #I'll... I'll get rid of it...
		name = pet_animal.0106.e
		trigger = {
			NOT = { exists = scope:receiver_1 }
		}
		show_as_tooltip = {
			remove_cat_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}


#You got a cat!
#by Linnéa Thimrén
pet_animal.0107 = {
	type = character_event
	title = pet_animal.0107.t
	desc = pet_animal.0107.desc
	theme = pet
	left_portrait = {
		character = scope:giver
		animation = sadness
	}

	immediate = {
		save_scope_as = receiver
	}

	option = { #Nice!
		name = pet_animal.0107.a
		show_as_tooltip = { start_cat_story_cycle_effect = yes }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
			}
		}
	}

	option = { #I don't want it...
		name = pet_animal.0107.b
		add_gold = 10
		show_as_tooltip = {
			remove_cat_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:giver
				multiplier = -1
			}
		}
	}

	after = {
		scope:giver = { #Check-up event for owner
			trigger_event = {
				id = pet_animal.0108
				days = { 365 380 }
			}
		}
	}
}

#How's the cat doing with its new owner?
#by Linnéa Thimrén
pet_animal.0108 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:alive }
				desc = pet_animal.0108.t
			}
			desc = pet_animal.0108.t_dead
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:alive }
				desc = {
					desc = pet_animal.0108.desc_opening
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:receiver = { is_landed = yes }
							}
							desc = pet_animal.0108.desc_alive_landed
						}
						desc = pet_animal.0108.desc_alive
					}
					random_valid = {
						desc = pet_animal.0108.desc_alive_1
						desc = pet_animal.0108.desc_alive_2
					}
				}
			}
			desc = {
				desc = pet_animal.0108.desc_dead_opening
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:receiver = { is_landed = yes }
						}
						desc = pet_animal.0108.desc_dead_landed
					}
					desc = pet_animal.0108.desc_dead
				}
				desc = pet_animal.0108.desc_dead_ending
			}
		}
	}
	theme = pet
	left_portrait = {
		character = scope:receiver
		triggered_animation = {
			trigger = { NOT = { exists = scope:alive } }
			animation = paranoia
		}
		triggered_animation = {
			trigger = { exists = scope:alive }
			animation = happiness
		}
	}

	immediate = {
		if = {
			limit = {
				scope:receiver= {
					any_owned_story = {
						story_type = story_cycle_pet_cat
					}
				}
			}
			save_scope_value_as = {
				name = alive
				value = yes
			}
		}
	}

	option = { #It's alive and happy!
		name = pet_animal.0108.a
		trigger = { exists = scope:alive }
		add_stress = minor_stress_loss
	}

	option = { #Where is the cat?!
		name = pet_animal.0108.b
		trigger = { NOT = { exists = scope:alive } }
		add_stress = minor_stress_gain
	}
}


#Your cat kills rodents
#by Linnéa Thimrén
pet_animal.0109 = {
	type = character_event
	title = pet_animal.0109.t
	desc = pet_animal.0109.desc
	theme = pet
	left_portrait = {
		character = root
		animation = happiness
	}

	trigger = {
		NOT = { has_character_flag = had_pet_animal_0109_event }
		# Requires a capital county.
		is_landed = yes
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_0109_event
			years = 10
		}
	}

	option = { #
		name = pet_animal.0109.a
		capital_province = {
			add_province_modifier = {
				modifier = cat_killing_rodents_modifier
				years = 5
			}
		}
	}
}

#Your cat insults a vassal
#by Linnéa Thimrén
pet_animal.0110 = {
	type = character_event
	title = pet_animal.0110.t
	desc = pet_animal.0110.desc
	theme = pet
	left_portrait = {
		character = scope:vassal
		animation = anger
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_0110_event }
		any_vassal = {
			is_available_ai = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_0110_event
			years = 10
		}
		random_vassal = {
			limit = {
				is_available_ai = yes
			}
			weight = {
				base = 50
				modifier = {
					add = 40
					is_powerful_vassal_of = root
				}
			}
			save_scope_as = vassal
		}
	}

	option = { #I'll pay for it!
		name = pet_animal.0110.a
		trigger = {
			short_term_gold >= medium_gold_value
		}
		show_as_unavailable = {
			short_term_gold < medium_gold_value
		}
		remove_short_term_gold = medium_gold_value
	}

	option = { #Bah!
		name = pet_animal.0110.b
		scope:vassal = {
			add_opinion = {
				modifier = insult_opinion
				target = root
				opinion = -20
			}
		}
	}
}

#Your cat has disappeared, probably due to your negligence
#by Linnéa Thimrén
pet_animal.0197 = {
	type = character_event
	title = pet_animal.0197.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = had_event_court_5020
				}
				desc = pet_animal.0197.desc_court_5020
			}
			desc = pet_animal.0197.desc
		}
	}
	theme = pet
	left_portrait = {
		character = root
		animation = sadness
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
	}

	option = {
		name = pet_animal.0197.a
		show_as_tooltip = {
			remove_cat_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
	
	after = {
		remove_character_flag = cat_is_dying
	}
}

#Cat dies
#by Linnéa Thimrén
pet_animal.0199 = {
	type = character_event
	title = pet_animal.0199.t
	desc = pet_animal.0199.desc
	theme = pet
	left_portrait = {
		character = root
		animation = sadness
	}
	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		create_artifact_animal_hide_effect = {
			OWNER = root
			HUNTER = root
			LEGENDARY = no
			ANIMAL = flag:cat
		}
	}

	option = {
		name = pet_animal.0199.a
		if = {
			limit = { exists = scope:newly_created_artifact }
			hidden_effect = { destroy_artifact = scope:newly_created_artifact }
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = {
		name = pet_animal.0199.b
		remove_short_term_gold = { 10 20 }
		show_as_tooltip = {
			scope:newly_created_artifact = { set_owner = root }
		}
		ai_chance = {
			base = 10
		}
	}

	after = {
		show_as_tooltip = {
			remove_cat_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
		remove_character_flag = cat_is_dying
	}
}

#Extra cat events

#Your cat falls off a desk
#by Nick Meredith
pet_animal.0200 = {
	type = character_event
	title = pet_animal.0200.t
	desc = pet_animal.0200.desc
	theme = pet
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = laugh
	}

	trigger = {
		is_available_healthy_adult = yes
		is_landed = yes
	}

	cooldown = { years = 15 }

	option = { # Add dopey cat modifier
		name = pet_animal.0200.a
		add_character_modifier = {
			modifier = cat_dopey_modifier
			years = 10
		}

		ai_chance = {
			base = 100
		}
	}
}

#Your cat knocks something off a shelf
#by Nick Meredith
pet_animal.0201 = {
	type = character_event
	title = pet_animal.0201.t
	desc = pet_animal.0201.desc
	theme = pet
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = shock
	}
	cooldown = { years = 15 }

	trigger = {
		is_available_healthy_adult = yes
		OR = {
			any_character_artifact = {
				artifact_slot_type = primary_armament
			}
			any_character_artifact = {
				artifact_slot_type = book
			}
			any_character_artifact = {
				artifact_slot_type = helmet
			}
			any_character_artifact = {
				artifact_slot_type = regalia
			}
			any_character_artifact = {
				artifact_slot_type = miscellaneous
			}
		}
		is_landed = yes
	}

	immediate = {
		random_character_artifact = {
			limit = {
				OR = {
					artifact_slot_type = primary_armament
					artifact_slot_type = book
					artifact_slot_type = helmet
					artifact_slot_type = regalia
					artifact_slot_type = miscellaneous
				}
			}
			save_scope_as = cat_artifact
		}
	}

	option = { # Try to catch it
		name = pet_animal.0201.a

		flavor = pet_animal.0201.a.tt

		duel = {
			skill = prowess
			value = high_skill_rating
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = pet_animal.0201.a.success
				send_interface_toast = {
					title = pet_animal.0201.a.success
					left_icon = root

					add_stress = minor_stress_loss
				}
			}
			# Failure!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = pet_animal.0201.a.failure
				send_interface_toast = {
					title = pet_animal.0201.a.failure
					left_icon = root

					add_stress = minor_stress_gain

					scope:cat_artifact = {
						add_durability = -5
					}
				}
			}
		}

		stress_impact = {
			brave = miniscule_stress_impact_gain
			craven = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = brave
			}
		}
	}

	option = { # Try to grab the cat
		name = pet_animal.0201.b

		flavor = pet_animal.0201.b.tt

		duel = {
			skills = { prowess martial }
			value = high_skill_rating
			# Success!
			70 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = pet_animal.0201.b.success
				send_interface_toast = {
					title = pet_animal.0201.b.success
					left_icon = root

					add_character_modifier = {
						modifier = cat_wrangler_modifier
						years = 10
					}

					add_stress = minor_stress_loss 
				}
			}
			# Failure!
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = pet_animal.0201.b.failure
				send_interface_toast = {
					title = pet_animal.0201.b.failure
					left_icon = root

					increase_wounds_no_death_effect = { REASON = wounds }

					add_stress = minor_stress_gain
				}
			}
		}
		stress_impact = {
			craven = miniscule_stress_impact_gain
			brave = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = craven
			}
		}
	}
}

#Your cat interrupts some coitus
#by Nick Meredith
pet_animal.0202 = {
	type = character_event
	title = pet_animal.0202.t
	desc = pet_animal.0202.desc
	theme = pet
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:cat_lover
		animation = anger
	}

	trigger = {
		NOT = {
			has_trait = celibate
		}
		any_relation = {
			type = lover
			is_available_healthy_ai_adult = yes
			location = root.location
		}
	}

	cooldown = { years = 15 }

	immediate = {
		random_relation = {
			type = lover
			limit = {
				is_available_healthy_ai_adult = yes
				location = root.location
			}
			save_scope_as = cat_lover
		}
		add_character_flag = is_naked
		scope:cat_lover = {
			add_character_flag = is_naked
		}
	}

	option = { # Shoo!
		name = pet_animal.0202.a

		duel = {
			skill = diplomacy
			value = medium_skill_rating
			# Success!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = pet_animal.0202.a.success
				send_interface_toast = {
					title = pet_animal.0202.a.success
					left_icon = root
					right_icon = scope:cat_lover

					reverse_add_opinion = {
						modifier = love_opinion
						target = scope:cat_lover
						opinion = 30
					}
				}
			}
			# Failure!
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = pet_animal.0202.a.failure
				send_interface_toast = {
					title = pet_animal.0202.a.failure
					left_icon = root
					right_icon = scope:cat_lover

					add_character_modifier = {
						modifier = cat_coitus_interrupted_modifier
						years = 10
					}
				}
			}
		}

		stress_impact = {
			chaste = miniscule_stress_impact_gain
			lustful = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = chaste
			}
		}
	}

	option = { # Leave the cat to it
		name = pet_animal.0202.b

		reverse_add_opinion = {
			modifier = disappointed_opinion
			target = scope:cat_lover
			opinion = -20
		}

		stress_impact = {
			chaste = miniscule_stress_impact_loss
			lustful = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = lustful
			}
		}   
	}
	after = {
		remove_character_flag = is_naked
		scope:cat_lover = {
			remove_character_flag = is_naked
		}
	}
}

#Your cat loves a random courtier
#by Nick Meredith
pet_animal.0203 = {
	type = character_event
	title = pet_animal.0203.t
	desc = pet_animal.0203.desc
	theme = pet
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:random_courtier
		animation = ecstasy
	}

	trigger = {
		is_available_healthy_adult = yes
		any_courtier_or_guest = {
			is_available_healthy_ai_adult = yes
			location = root.location
		}
		is_landed = yes
	}

	cooldown = { years = 15 }

	immediate = {
		random_courtier_or_guest = {
			limit = {
				is_available_healthy_ai_adult = yes
			}
			save_scope_as = random_courtier
		}
	}

	option = { # Gimme my cat back!
		name = pet_animal.0203.a

		reverse_add_opinion = {
			modifier = disappointed_opinion
			target = scope:random_courtier
			opinion = -10
		}

		stress_impact = {
			arrogant = minor_stress_impact_loss
			humble = minor_stress_impact_gain
			compassionate = miniscule_stress_impact_gain
			callous = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -1
			}
		}
	}

	option = { # Aww... OK then :(
		name = pet_animal.0203.b

		add_character_modifier = {
			modifier = cat_rejection_modifier
			years = 5
		}

		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:random_courtier
			opinion = 15
		}

		stress_impact = {
			compassionate = miniscule_stress_impact_loss
			callous = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}
}

#Your cat makes you feel better when you're sick
pet_animal.0204 = {
	type = character_event
	title = pet_animal.0204.t
	desc = pet_animal.0204.desc
	theme = pet
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = sick
		outfit_tags = { nightgown }
	}

	trigger = {
		is_available_adult = yes
		is_healthy = no
	}

	cooldown = { years = 15 }

	option = { # Aww :)
		name = pet_animal.0204.a

		add_character_modifier = {
			modifier = cat_ill_modifier
			years = 5
		}

		stress_impact = {
			base = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}
}

#Your cat keeps interrupting you
pet_animal.0205 = {
	type = character_event
	title = pet_animal.0205.t
	desc = pet_animal.0205.desc
	theme = pet
	override_background = { reference = council_chamber }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:cat_disapprover
		animation = dismissal
	}

	trigger = {
		is_available_adult = yes
		any_councillor = {
			is_available_adult = yes
			location = root.location
		}
		is_landed = yes
	}

	immediate = {
		random_councillor = {
			limit = {
				is_available_adult = yes
				location = root.location
			}
			save_scope_as = cat_disapprover #booooo, hissss
		}
	}

	cooldown = { years = 15 }

	option = { # If anyone says another word about my precious kitten...
		name = pet_animal.0205.a

		trigger = {
			OR = {
				has_trait = wrathful
				has_trait = stubborn
			}
		}

		add_character_modifier = {
			modifier = cat_lover_modifier
			years = 10
		}

		add_dread = minor_dread_gain

		stress_impact = {
			base = minor_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -1
				ai_vengefulness = 1
			}
		}
	}

	option = { # For god's sakes, someone get this cat out of here!
		name = pet_animal.0205.b

		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:cat_disapprover
			opinion = 10
		}

		stress_impact = {
			base = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_rationality = 1
			}
		}
	}

	option = { # C'mere, you lil fuzzball
		name = pet_animal.0205.c

		flavor = pet_animal.0205.c.tt

		reverse_add_opinion = {
			modifier = annoyed_opinion
			target = scope:cat_disapprover
			opinion = -15
		}

		stress_impact = {
			base = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_sociability = 1
			}
		}
	}
}

##############
##############
## DOG
##############
##############

###########################################
# Name your dog
#	1001-0999
###########################################

#Name your dog
#by Linnéa Thimrén
pet_animal.1001 = {
	type = character_event
	title = pet_animal.1001.t
	desc = pet_animal.1001.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = personality_cynical
	}

	immediate = {
		assign_name_options_dog_story_cycle_effect = yes
		assign_name_options_dog_story_cycle_effect = yes
		assign_name_options_dog_story_cycle_effect = yes
		play_music_cue = "mx_cue_low_key_positive"

		if = {
			limit = { is_ai = yes }
			random_list = {
				1 = {
					trigger = { has_character_flag = name_amiable }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_amiable
					}
				}
				1 = {
					trigger = { has_character_flag = name_nosewise }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_nosewise
					}
				}
				1 = {
					trigger = { has_character_flag = name_holdfast }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_holdfast
					}
				}
				1 = {
					trigger = { has_character_flag = name_gray }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_gray
					}
				}
				1 = {
					trigger = { has_character_flag = name_choplicker }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_choplicker
					}
				}
				1 = {
					trigger = { has_character_flag = name_shadow }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_shadow
					}
				}
				1 = {
					trigger = { has_character_flag = name_snow }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_snow
					}
				}
				###EK EDIT: Dev pet names
				1 = {
					trigger = { has_character_flag = name_bandit }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_bandit
					}
				}
				1 = {
					trigger = { has_character_flag = name_pumpkin }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_pumpkin
					}
				}
				1 = {
					trigger = { has_character_flag = name_chunk }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_chunk
					}
				}
				1 = {
					trigger = { has_character_flag = name_nightbiter }
					set_variable = {
						name = story_cycle_dog_name
						value = flag:dog_name_nightbiter
					}
				}
				#EK EDIT END
			}
		}
	}

	widget = {
		gui = "event_window_widget_enter_text"
		container = "dynamic_birth_name"
		controller = {
			type = text
			data = {
				key = story_cycle_dog_name
				default = {
					localization_key = dog_name_amiable
					trigger = {
						has_character_flag = name_amiable
					}
				}
				default = {
					localization_key = dog_name_nosewise
					trigger = {
						has_character_flag = name_nosewise
					}
				}
				default = {
					localization_key = dog_name_holdfast
					trigger = {
						has_character_flag = name_holdfast
					}
				}
				default = {
					localization_key = dog_name_gray
					trigger = {
						has_character_flag = name_gray
					}
				}
				default = {
					localization_key = dog_name_shadow
					trigger = {
						has_character_flag = name_shadow
					}
				}
				default = {
					localization_key = dog_name_snow
					trigger = {
						has_character_flag = name_snow
					}
				}
				###EK EDIT: Dev pet names
				default = {
					localization_key = dog_name_bandit
					trigger = {
						has_character_flag = name_bandit
					}
				}
				default = {
					localization_key = dog_name_pumpkin
					trigger = {
						has_character_flag = name_pumpkin
					}
				}
				#EK EDIT END
			}
		}
		setup_scope = {
			root = { save_scope_as = text_target }
		}
	}

	option = {
		name = pet_animal.0001.a
	}

	after = {
		remove_character_flag = is_naming_dog
		remove_character_flag = name_amiable
		remove_character_flag = name_nosewise
		remove_character_flag = name_holdfast
		remove_character_flag = name_gray
		remove_character_flag = name_choplicker
		remove_character_flag = name_shadow
		remove_character_flag = name_snow
		###EK EDIT: Dev pet names
		remove_character_flag = name_bandit
		remove_character_flag = name_pumpkin
		remove_character_flag = name_chunk
		remove_character_flag = name_nightbiter

		if = {
			# We entered custom text into the pop up
			limit = { NOT = { has_variable = story_cycle_dog_name } }
			set_variable = {
				name = story_cycle_dog_name
				value = flag:custom
			}
		}
	}
}



###########################################
# Other events for your dog
#	1100-1199
###########################################

#Go out and walk your dog, get health modifier
#by Linnéa Thimrén
pet_animal.1101 = {
	type = character_event
	title = pet_animal.1101.t
	desc = pet_animal.1101.desc
	theme = pet
	#EK DISABLED
	#override_background = {
		#trigger = {
			#culture = { has_cultural_pillar = heritage_north_germanic }
			#religion = religion:germanic_religion
		#}
		#reference = fp1_runestone
	#}
	override_background = {
		#trigger = {
			#NAND = {
				#culture = { has_cultural_pillar = heritage_north_germanic }
				#religion = religion:germanic_religion
			#}
		#}
		reference = farmland
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1101_event }
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_1101_event
			years = 10
		}
	}

	option = { #walk on!
		name = pet_animal.1101.a
		add_character_modifier = {
			modifier = dog_story_walking_modifier
			days = 3650
		}
	}
}

#Dog runs away!
#by Linnéa Thimrén
pet_animal.1102 = {
	type = character_event
	title = pet_animal.1102.t
	desc = pet_animal.1102.desc
	theme = pet
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = root
		animation = worry
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1102_event }
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_1102_event
			years = 10
		}
	}

	option = { #Run after
		name = pet_animal.1102.a
		flavor = pet_animal.1102.a.tt
		save_scope_value_as = {
			name = followed
			value = yes
		}
	}

	option = { #You wait
		name = pet_animal.1102.b
		flavor = pet_animal.1102.b.tt
	}

	after = {
		hidden_effect = {
			random_list = {
				20 = {
					modifier = {
						add = 20
						exists = scope:followed
					}
					trigger_event = {
						id = pet_animal.1103
						days = { 7 14 }
					}
				}
				10 = {
					trigger_event = {
						id = pet_animal.1104
						days = { 7 14 }
					}
				}
				50 = { #Rival kills dog :(
					trigger = {
						any_relation = {
							type = rival
							is_alive = yes
							is_imprisoned = no
						}
					}
					trigger_event = {
						id = pet_animal.1105
						days = { 7 14 }
					}
				}
				50 = { #Friend returns dog!
					trigger = {
						any_relation = {
							type = friend
							is_alive = yes
							is_imprisoned = no
						}
					}
					trigger_event = {
						id = pet_animal.1106
						days = { 7 14 }
					}
				}
			}
		}
	}
}

#Found dog!
#by Linnéa Thimrén
pet_animal.1103 = {
	type = character_event
	title = pet_animal.1102.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:followed
				}
				desc = pet_animal.1103.desc_followed
			}
			desc = pet_animal.1103.desc
		}
		desc = pet_animal.1103.desc_ending
	}
	theme = pet
	override_background = {
		reference = terrain
	}
	left_portrait = root

	trigger = {
		exists = scope:story
	}

	option = {
		name = pet_animal.1103.a
		add_gold = 2
	}
}

#Dog is gone :(
#by Linnéa Thimrén
pet_animal.1104 = {
	type = character_event
	title = pet_animal.1102.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:followed
				}
				desc = pet_animal.1104.desc_followed
			}
			desc = pet_animal.1104.desc
		}
		desc = pet_animal.1104.desc_ending
	}
	theme = pet
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = root
		animation = sadness
	}

	trigger = {
		exists = scope:story
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
	}

	option = { #
		name = pet_animal.1104.a
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}

#Rival killed dog :(
#by Linnéa Thimrén
pet_animal.1105 = {
	type = character_event
	title = pet_animal.1102.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:followed
				}
				desc = pet_animal.1104.desc_followed
			}
			desc = pet_animal.1104.desc
		}
		desc = pet_animal.1105.desc_ending
	}
	theme = pet
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = scope:rival
		animation = schadenfreude
	}

	trigger = {
		any_relation = {
			type = rival
			is_alive = yes
			is_imprisoned = no
		}
		exists = scope:story
	}

	immediate = {
		random_relation = {
			type = rival
			limit = {
				has_relation_nemesis = root
				is_imprisoned = no
			}
			alternative_limit = {
				is_alive = yes
				is_imprisoned = no
			}
			save_scope_as = rival
		}
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_gender }
	}

	option = { #what did you do to them?!
		name = pet_animal.1105.a
		scope:story = {
			hidden_effect = { end_story = yes }
		}
		hidden_effect = {
			scope:rival = {
				add_character_modifier = {
					modifier = dog_story_fur_carpet_modifier
					years = 10
				}
			}
		}
	}
}

#Friend return dog!
#by Linnéa Thimrén
pet_animal.1106 = {
	type = character_event
	title = pet_animal.1102.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:followed
				}
				desc = pet_animal.1104.desc_followed
			}
			desc = pet_animal.1104.desc
		}
		desc = pet_animal.1106.desc_ending
	}
	theme = pet
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = scope:friend
		animation = happiness
	}

	trigger = {
		any_relation = {
			type = friend
			is_alive = yes
			is_imprisoned = no
			age >= 12
		}
		exists = scope:story
	}

	immediate = {
		random_relation = {
			type = friend
			limit = {
				has_relation_best_friend = root
				age >= 12
			}
			alternative_limit = {
				is_alive = yes
				is_imprisoned = no
				age >= 12
			}
			save_scope_as = friend
		}
	}

	option = { #Thank you!
		name = pet_animal.1106.a
		scope:friend = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 15
			}
		}
	}
}


#Your dog charms a vassal
#by Linnéa Thimrén
pet_animal.1107 = {
	type = character_event
	title = pet_animal.1107.t
	desc = pet_animal.1107.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = scope:vassal
		animation = happiness
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1107_event }
		any_vassal = {
			is_available_ai = yes
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				is_available_ai = yes
			}
			weight = {
				base = 50
				ai_value_modifier = {
					ai_compassion = 1
				}
			}
			save_scope_as = vassal
		}
		add_character_flag = {
			flag = had_pet_animal_1107_event
			years = 10
		}
	}

	option = {
		name = {
			trigger = { scope:story = { var:dog_gender = flag:female } }
			text = pet_animal.1107.a_female
		}
		name = {
			trigger = { scope:story = { var:dog_gender = flag:male } }
			text = pet_animal.1107.a_male
		}
		scope:vassal = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 20
			}
		}
	}
}


#Your dog exposes a scheme targeting you
#by Linnéa Thimrén
pet_animal.1108 = {
	type = character_event
	title = pet_animal.1108.t
	desc = pet_animal.1108.desc
	theme = pet
	override_background = {
		reference = sitting_room
	}
	left_portrait = scope:agent
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1108_event }
		any_targeting_scheme = {
			is_scheme_exposed = no
			save_temporary_scope_as = scheme_check
			any_scheme_agent_character = {
				NOT = { is_agent_exposed_in_scheme = scope:scheme_check }
				is_in_the_same_court_as = root
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_1108_event
			years = 10
		}
		random_targeting_scheme = {
			limit = {
				is_scheme_exposed = no
			}
			save_scope_as = scheme
			random_scheme_agent_character = {
				limit = {
					NOT = { is_agent_exposed_in_scheme = scope:scheme }
					is_in_the_same_court_as = root
				}
				save_scope_as = agent
			}
		}
	}

	option = {
		name = pet_animal.1108.a
		scope:scheme = {
			expose_scheme = yes
		}
	}
}


#Meet another dog!
#by Linnéa Thimrén
pet_animal.1109 = {
	type = character_event
	title = pet_animal.1109.t
	desc = pet_animal.1109.desc
	theme = pet
	#override_background = {
		#trigger = {
			#culture = { has_cultural_pillar = heritage_north_germanic }
			#religion = religion:germanic_religion
		#}
		#reference = fp1_runestone
	#}
	left_portrait = scope:other_owner
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1109_event }
		OR = {
			any_vassal = {
				is_available_ai = yes
				any_owned_story = {
					story_type = story_cycle_pet_dog
					exists = story_owner.var:story_cycle_dog_name
				}
			}
			any_courtier = {
				is_available_ai = yes
				any_owned_story = {
					story_type = story_cycle_pet_dog
					exists = story_owner.var:story_cycle_dog_name
				}
			}
			any_neighboring_top_liege_realm_owner = {
				is_available_ai = yes
				any_owned_story = {
					story_type = story_cycle_pet_dog
					exists = story_owner.var:story_cycle_dog_name
				}
			}
			AND = {
				exists = liege
				liege = {
					is_available_ai = yes
					NOT = { this = root }
					any_owned_story = {
						story_type = story_cycle_pet_dog
						exists = story_owner.var:story_cycle_dog_name
					}
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_1109_event
			years = 10
		}
		hidden_effect = {
			random_list = {
				10 = {
					trigger = {
						any_vassal = {
							is_available_ai = yes
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
					}
					random_vassal = {
						limit = {
							is_available_ai = yes
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
							save_scope_as = other_story
						}
					}
				}
				10 = {
					trigger = {
						any_courtier = {
							is_available_ai = yes
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
					}
					random_courtier = {
						limit = {
							is_available_ai = yes
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
							save_scope_as = other_story
						}
					}
				}
				10 = {
					trigger = {
						any_neighboring_top_liege_realm_owner = {
							is_available_ai = yes
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
					}
					random_neighboring_top_liege_realm_owner = {
						limit = {
							is_available_ai = yes
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
							save_scope_as = other_story
						}
					}
				}
				10 = {
					trigger = {
						liege = {
							is_available_ai = yes
							NOT = { this = root }
							any_owned_story = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
						}
					}
					liege = {
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = story_cycle_pet_dog
								exists = story_owner.var:story_cycle_dog_name
							}
							save_scope_as = other_story
						}
					}
				}
			}
		}
	}

	option = { #I'm sure they'll be fine
		name = pet_animal.1109.a
		flavor = pet_animal.1109.a.tt
		hidden_effect = {
			random_list = {
				10 = { #Breed
					trigger = {
						OR = {
							AND = {
								scope:story = { var:dog_gender = flag:female }
								scope:other_story = { var:dog_gender = flag:male }
							}
							AND = {
								scope:story = { var:dog_gender = flag:male }
								scope:other_story = { var:dog_gender = flag:female }
							}
						}
					}
					trigger_event = {
						id = pet_animal.1110
						days = { 7 14 }
					}
				}
				20 = { #Play
					trigger_event = {
						id = pet_animal.1111
						days = { 7 14 }
					}
				}
				10 = { #Fight
					trigger_event = {
						id = pet_animal.1112
						days = { 7 14 }
					}
				}
			}
		}
	}
}


#The dogs bred!
#by Linnéa Thimrén
pet_animal.1110 = {
	type = character_event
	title = pet_animal.1109.t
	desc = {
		desc = pet_animal.1110.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:your_dog
				}
				desc = pet_animal.1110.desc_your_dog
			}
			desc = pet_animal.1110.desc_their_dog
		}
	}
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = scope:other_owner

	trigger = {
		exists = scope:story
		scope:other_owner = { is_alive = yes }
	}

	immediate = {
		if = { #We only care if it was your dog
			limit = {
				scope:story = { var:dog_gender = flag:female }
			}
			dog_got_pregnant_effect = yes
			save_scope_value_as = {
				name = your_dog
				value = yes
			}
		}
	}

	option = { #Ups
		name = pet_animal.1110.a
		if = {
			limit = {
				NOT = { exists = scope:your_dog }
			}
			scope:other_owner = {
				add_opinion = {
					target = root
					modifier = hate_opinion
					opinion = -10
				}
			}
		}
	}
}

#The dogs play
#by Linnéa Thimrén
pet_animal.1111 = {
	type = character_event
	title = pet_animal.1109.t
	desc = pet_animal.1111.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = scope:other_owner
		animation = happiness
	}

	trigger = {
		exists = scope:story
		scope:other_owner = { is_alive = yes }
	}

	option = { #Cute!
		name = pet_animal.1111.a
		scope:other_owner = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 15
			}
		}
	}
}

#The dogs fight
#by Linnéa Thimrén
pet_animal.1112 = {
	type = character_event
	title = pet_animal.1109.t
	desc = {
		desc = pet_animal.1112.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:dead
				}
				desc = pet_animal.1112.desc_dead
			}
			desc = pet_animal.1112.desc_alive
		}
	}
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = scope:other_owner
		animation = anger
	}

	trigger = {
		exists = scope:story
		scope:other_owner = { is_alive = yes }
	}

	immediate = {
		hidden_effect = {
			random = {
				chance = 25
				save_scope_value_as = {
					name = dead
					value = yes
				}
			}
		}
		if = {
			limit = {
				exists = scope:dead
			}
			scope:other_owner = {
				add_opinion = {
					target = root
					modifier = hate_opinion
					opinion = -20
				}
				show_as_tooltip = {
					remove_dog_story_modifiers_effect = yes
				}
				if = {
					limit = {
						exists = scope:other_story
					}
					scope:other_story = {
						hidden_effect = { end_story = yes }
					}
				}
			}
		}
		else = {
			scope:other_owner = {
				add_opinion = {
					target = root
					modifier = hate_opinion
					opinion = -10
				}
			}
		}
	}

	option = { #Ups
		name = pet_animal.1112.a
	}
}


#Bring your dog to a council meeting?
#by Linnéa Thimrén
pet_animal.1113 = {
	type = character_event
	title = pet_animal.1113.t
	desc = pet_animal.1113.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = root
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1113_event }
		is_landed = yes
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_1113_event
			years = 10
		}
		
	}

	option = { #Bring them
		name = pet_animal.1113.a

		every_councillor = {
			custom = every_councillor
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -5
			}
		}
		
		random_list = {
			75 = { #They make you seem cool!
				desc = pet_animal.1113.a_success
				show_chance = no
				custom_tooltip = pet_animal.1113.a_success.tt
				trigger_event = {
					id = pet_animal.1114
					days = { 7 10 }
				}
			}
			25 = { #They poop
				desc = pet_animal.1113.a_failure
				show_chance = no
				custom_tooltip = pet_animal.1113.a_failure.tt
				trigger_event = {
					id = pet_animal.1115
					days = { 7 10 }
				}
			}
		}
	}

	option = { #Don't bring them
		name = pet_animal.1113.b
		custom_tooltip = pet_animal.1113.b.tt

		random_list = {
			50 = { #They befriends a courtier
				desc = pet_animal.1113.b_success
				show_chance = no
				custom_tooltip = pet_animal.1113.a_success.tt
				trigger = {
					any_courtier = { NOT = { has_relation_rival = root } }
				}
				trigger_event = {
					id = pet_animal.1116
					days = { 7 10 }
				}
			}
			50 = { #They trash a courtier's room
				desc = pet_animal.1113.b_failure
				show_chance = no
				custom_tooltip = pet_animal.1113.a_failure.tt
				trigger_event = {
					id = pet_animal.1117
					days = { 7 10 }
				}
			}
		}
	}
}

#You bring them and it works out
#by Linnéa Thimrén
pet_animal.1114 = {
	type = character_event
	title = pet_animal.1113.t
	desc = pet_animal.1114.desc
	theme = pet
	override_background = {
		reference = council_chamber
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:councillor
		animation = fear
	}

	immediate = {
		random_councillor = {
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = -5
				}
			}
			save_scope_as = councillor
		}
	}

	option = { #
		name = {
			trigger = { scope:story = { var:dog_gender = flag:female } }
			text = pet_animal.1014.a_girl
		}
		name = {
			trigger = { scope:story = { var:dog_gender = flag:male } }
			text = pet_animal.1014.a_boy
		}
		add_prestige = minor_prestige_gain
	}
}


#You bring them and they poop
#by Linnéa Thimrén
pet_animal.1115 = {
	type = character_event
	title = pet_animal.1113.t
	desc = pet_animal.1115.desc
	theme = pet
	override_background = {
		reference = council_chamber
	}
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:councillor
		animation = fear
	}

	immediate = {
		random_councillor = {
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = -5
				}
			}
			save_scope_as = councillor
		}
	}

	option = { #
		name = pet_animal.1115.a
		add_prestige = minor_prestige_loss
		
	}
}

#You don't bring them and they befriend a courtier
#by Linnéa Thimrén
pet_animal.1116 = {
	type = character_event
	title = pet_animal.1113.t
	desc = {
		desc = pet_animal.1116.desc_opening
		desc = pet_animal.1116.desc
	}
	theme = pet
	override_background = {
		reference = corridor_day
	}
	left_portrait = {
		character = scope:courtier
		animation = happiness
	}

	trigger = {
		any_courtier = { NOT = { has_relation_rival = root } }
	}

	immediate = {
		random_courtier = {
			limit = {
				NOT = { has_relation_rival = root }
			}
			save_scope_as = courtier
		}
	}

	option = { #
		name = pet_animal.1116.a
		scope:courtier = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 15
			}
		}
	}
}

#You don't bring them and they trash a courtier's room
#by Linnéa Thimrén
pet_animal.1117 = {
	type = character_event
	title = pet_animal.1113.t
	desc = {
		desc = pet_animal.1116.desc_opening
		desc = pet_animal.1117.desc
	}
	theme = pet
	override_background = {
		reference = corridor_day
	}
	left_portrait = {
		character = scope:courtier
		animation = anger
	}
	
	trigger = {
		any_courtier = {
			is_alive = yes
		}
	}

	immediate = {
		random_courtier = {
			limit = {
				has_relation_rival = root
			}
			alternative_limit = {
				has_relation_potential_rival = root
			}
			alternative_limit = {
				is_alive = yes
			}
			save_scope_as = courtier
		}
	}

	option = { #
		name = pet_animal.1117.a
		scope:courtier = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -15
			}
		}
	}
}


#Your dog insults a vassal
#by Linnéa Thimrén
pet_animal.1118 = {
	type = character_event
	title = pet_animal.1118.t
	desc = pet_animal.1118.desc
	theme = pet
	# override_background = {
		# trigger = {
			# culture = { has_cultural_pillar = heritage_north_germanic }
			# religion = religion:germanic_religion
		# }
		# reference = fp1_runestone
	# }
	left_portrait = {
		character = scope:vassal
		animation = anger
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_1118_event }
		any_vassal = {
			is_available_ai = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_1118_event
			years = 10
		}
		random_vassal = {
			limit = {
				is_available_ai = yes
			}
			weight = {
				base = 50
				modifier = {
					add = 40
					is_powerful_vassal_of = root
				}
			}
			save_scope_as = vassal
		}
	}

	option = { #I'll pay for it!
		name = pet_animal.1118.a
		trigger = {
			short_term_gold >= medium_gold_value
		}
		show_as_unavailable = {
			short_term_gold < medium_gold_value
		}
		remove_short_term_gold = medium_gold_value
	}

	option = { #Bah!
		name = pet_animal.1118.b
		scope:vassal = {
			add_opinion = {
				modifier = insult_opinion
				target = root
				opinion = -20
			}
		}
	}
}

#Puppies!
#by Linnéa Thimrén
pet_animal.1190 = {
	type = character_event
	title = pet_animal.1190.t
	desc = pet_animal.1190.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = root
	lower_left_portrait = scope:receiver_1
	lower_center_portrait = scope:receiver_2
	lower_right_portrait = scope:receiver_3

	immediate = {
		save_scope_as = giver
		#Who can get a puppy?
		if = {
			limit = {
				any_relation = {
					type = friend
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
				}
			}
			every_relation = {
				type = friend
				limit = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
				}
				add_to_list = can_get_dog
			}
		}
		if = {
			limit = {
				any_relation = {
					type = lover
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_dog }
				}
			}
			every_relation = {
				type = lover
				limit = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_dog }
				}
				add_to_list = can_get_dog
			}
		}
		if = {
			limit = {
				any_vassal = {
					NOT = { has_relation_rival = root }
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_dog }
				}
			}
			every_vassal = {
				limit = {
					NOT = { has_relation_rival = root }
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_dog }
				}
				add_to_list = can_get_dog
			}
		}
		if = {
			limit = {
				any_consort = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_dog }
				}
			}
			every_consort = {
				limit = {
					NOT = {
						any_owned_story = {
								story_type = story_cycle_pet_cat
							}
					}
					NOT = { is_in_list = can_get_dog }
				}
				add_to_list = can_get_dog
			}
		}
		random_in_list = {
			list = can_get_dog
			save_scope_as = receiver_1
		}
		random_in_list = {
			list = can_get_dog
			limit = { NOT = { this = scope:receiver_1 } }
			save_scope_as = receiver_2
		}
		random_in_list = {
			list = can_get_dog
			limit = {
				NOR = {	
					this = scope:receiver_1
					this = scope:receiver_2
				}

			}
			save_scope_as = receiver_3
		}
	}

	option = { #Ok, I'll give it away to receiver_1
		name = pet_animal.1190.a
		trigger = {
			exists = scope:receiver_1
		}
		scope:receiver_1 = {
			show_as_tooltip = { start_dog_story_cycle_effect = yes }
			trigger_event = pet_animal.1191
		}
	}

	option = { #Ok, I'll give it away to receiver_2
		name = pet_animal.1190.b
		trigger = {
			exists = scope:receiver_2
		}
		scope:receiver_2 = {
			show_as_tooltip = { start_dog_story_cycle_effect = yes }
			trigger_event = pet_animal.1191
		}
	}

	option = { #Ok, I'll give it away to receiver_3
		name = pet_animal.1190.c
		trigger = {
			exists = scope:receiver_3
		}
		scope:receiver_3 = {
			show_as_tooltip = { start_dog_story_cycle_effect = yes }
			trigger_event = pet_animal.1191
		}
	}

	option = { #No one to give it to :(
		name = pet_animal.1190.d
		trigger = {
			NOT = { exists = scope:receiver_1 }
		}
		add_gold = 10
	}
}

#You got a puppy!
#by Linnéa Thimrén
pet_animal.1191 = {
	type = character_event
	title = pet_animal.1191.t
	desc = pet_animal.1191.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = scope:giver

	immediate = {
		save_scope_as = receiver
	}

	option = { #Nice!
		name = pet_animal.1191.a
		start_dog_story_cycle_effect = yes
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
			}
		}
	}

	option = { #I don't want it...
		name = pet_animal.1191.b
		add_gold = 10
		
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:giver
				multiplier = -1
			}
		}
	}

	after = {
		scope:giver = { #Checkup event for giver
			trigger_event = {
				id = pet_animal.1192
				days = { 365 380 }
			}
		}
	}
}


#How's the dog doing with its new owner?
#by Linnéa Thimrén
pet_animal.1192 = {
	type = character_event
	title = pet_animal.1192.t
	desc = {
		desc = pet_animal.1192.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:alive
				}
				desc = {
					desc = {
						first_valid = {
							triggered_desc = {
								trigger = {
									scope:receiver = { is_landed = yes }
								}
								desc = pet_animal.1192.desc_alive_landed
							}
							desc = pet_animal.1192.desc_alive
						}
					}
					random_valid = {
						desc = pet_animal.1192.desc_alive_1
						desc = pet_animal.1192.desc_alive_2
					}
				}
			}
			desc = pet_animal.1192.desc
		}
	}
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = scope:receiver
		triggered_animation = {
			trigger = { NOT = { exists = scope:alive } }
			animation = paranoia
		}
		triggered_animation = {
			trigger = { exists = scope:alive }
			animation = happiness
		}
	}

	trigger = {
		scope:receiver = {
			is_alive = yes
		}
	}

	immediate = {
		if = {
			limit = {
				scope:receiver= {
					any_owned_story = {
							story_type = story_cycle_pet_dog
						}
				}
			}
			save_scope_value_as = {
				name = alive
				value = yes
			}
		}
	}

	option = { #It's alive and happy!
		name = pet_animal.1192.a
		trigger = { exists = scope:alive }
		add_stress = minor_stress_loss
	}

	option = { #Where is the dog?!
		name = pet_animal.1192.b
		trigger = { NOT = { exists = scope:alive } }
		add_stress = minor_stress_gain
	}
}


#Dog dies
#by Linnéa Thimrén
pet_animal.1199 = {
	type = character_event
	title = pet_animal.1199.t
	desc = pet_animal.1199.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = sadness
	}
	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		create_artifact_animal_hide_effect = {
			OWNER = root
			HUNTER = root
			LEGENDARY = no
			ANIMAL = flag:dog
		}
	}

	option = {
		name = pet_animal.1199.a
		if = {
			limit = { exists = scope:newly_created_artifact }
			hidden_effect = { destroy_artifact = scope:newly_created_artifact }
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = {
		name = pet_animal.0199.b
		remove_short_term_gold = { 10 20 }
		show_as_tooltip = {
			scope:newly_created_artifact = { set_owner = root }
		}
		ai_chance = {
			base = 10
		}
	}

	after = {
		show_as_tooltip = {
			remove_dog_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
		remove_character_flag = dog_is_dying
	}
}




##############
##############
## CAT AND DOG
##############
##############

#You have both a dog AND a cat (you lucky person, you!)
#by Linnéa Thimrén
pet_animal.2001 = {
	type = character_event
	title = pet_animal.2001.t
	desc = pet_animal.2001.desc
	theme = pet
	override_background = {
		reference = sitting_room
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_2001_event }
		any_owned_story = {
			story_type = story_cycle_pet_cat
			exists = story_owner.var:story_cycle_cat_name
		}
		any_owned_story = {
			story_type = story_cycle_pet_dog
			exists = story_owner.var:story_cycle_dog_name
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_2001_event
			years = 10
		}
	}

	option = {
		name = pet_animal.2001.a
		add_stress = medium_stress_loss
	}
}

#You have both a dog AND a cat. Things don't really work out
#by Linnéa Thimrén
pet_animal.2002 = {
	type = character_event
	title = pet_animal.2002.t
	desc = pet_animal.2002.desc
	theme = pet
	override_background = {
		reference = courtyard
	}
	left_portrait = root
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_2002_event }
		NOT = { has_character_flag = had_pet_animal_2001_event } #They haven't already cozied it up
		any_owned_story = {
			story_type = story_cycle_pet_cat
			exists = story_owner.var:story_cycle_cat_name
		}
		any_owned_story = {
			story_type = story_cycle_pet_dog
			exists = story_owner.var:story_cycle_dog_name
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_2002_event
			years = 10
		}
		random_owned_story = {
				limit = {
					story_type = story_cycle_pet_cat
				}
				save_scope_as = cat_story
			}
			random_owned_story = {
				limit = {
					story_type = story_cycle_pet_dog
				}
				save_scope_as = dog_story
			}
	}

	option = {
		name = pet_animal.2002.a
		custom_tooltip = pet_animal.2002.a.tt
		save_scope_value_as = {
			name = sided_with_cat
			value = yes
		}
	}

	option = {
		name = pet_animal.2002.b
		custom_tooltip = pet_animal.2002.b.tt
		save_scope_value_as = {
			name = sided_with_dog
			value = yes
		}
	}

	option = {
		name = pet_animal.2002.c
		flavor = pet_animal.2002.c.tt
	}

	after = {
		hidden_effect = {
			random_list = {
				10 = { #Dog dies
					modifier = {
						add = 10
						exists = scope:sided_with_cat
					}
					add_character_flag = dog_is_dying
					trigger_event = {
						id = pet_animal.2003
						days = { 7 14 }
					}
				}
				15 = { #Cat dies
					modifier = {
						add = 10
						exists = scope:sided_with_dog
					}
					add_character_flag = cat_is_dying
					trigger_event = {
						id = pet_animal.2004
						days = { 7 14 }
					}
				}
				5 = { #Both die
					add_character_flag = dog_is_dying
					add_character_flag = cat_is_dying
					trigger_event = {
						id = pet_animal.2005
						days = { 7 14 }
					}
				}
				2 = { #They work it out
					modifier = { #You at least tried to do something
						add = 5
						OR = {
							exists = scope:sided_with_cat
							exists = scope:sided_with_dog
						}
					}
					trigger_event = {
						id = pet_animal.2006
						days = { 7 14 }
					}
				}
			}
		}
	}
}

#Dog dies
#by Linnéa Thimrén
pet_animal.2003 = {
	type = character_event
	title = pet_animal.2002.t
	desc = pet_animal.2003.desc
	theme = pet
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = grief
	}

	immediate = {
		play_music_cue = "mx_cue_stress"
	}

	option = {
		name = pet_animal.2003.a
		show_as_tooltip = {
			remove_dog_story_modifiers_effect = yes
		}
		scope:dog_story = {
			hidden_effect = { end_story = yes }
		}
	}

	after = {
		remove_character_flag = dog_is_dying
	}
}

#Cat dies
#by Linnéa Thimrén
pet_animal.2004 = {
	type = character_event
	title = pet_animal.2002.t
	desc = {
		desc = pet_animal.2004.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:dog_story = { var:dog_gender = flag:female }
				}
				desc = pet_animal.2004.desc_female
			}
			desc = pet_animal.2004.desc_male
		}
		desc = pet_animal.2004.desc
	}
	theme = pet
	left_portrait = {
		character = root
		animation = grief
	}

	immediate = {
		play_music_cue = "mx_cue_murder"
	}

	option = {
		name = pet_animal.2004.a
		show_as_tooltip = {
			remove_cat_story_modifiers_effect = yes
		}
		scope:cat_story = {
			hidden_effect = { end_story = yes }
		}
	}

	after = {
		remove_character_flag = cat_is_dying
	}
}

#Both die
#by Linnéa Thimrén
pet_animal.2005 = {
	type = character_event
	title = pet_animal.2002.t
	desc = {
		desc = pet_animal.2005.desc_opening
		desc = pet_animal.2005.desc
	}
	theme = pet
	left_portrait = {
		character = root
		animation = grief
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
	}

	option = {
		name = pet_animal.2005.a
		show_as_tooltip = {
			remove_cat_story_modifiers_effect = yes
			remove_dog_story_modifiers_effect = yes
		}
		scope:cat_story = {
			hidden_effect = { end_story = yes }
		}
		scope:dog_story = {
			hidden_effect = { end_story = yes }
		}
	}

	after = {
		remove_character_flag = cat_is_dying
		remove_character_flag = dog_is_dying
	}
}

#They work it out
#by Linnéa Thimrén
pet_animal.2006 = {
	type = character_event
	title = pet_animal.2002.t
	desc = {
		desc = pet_animal.2005.desc_opening
		desc = pet_animal.2006.desc
	}
	theme = pet
	left_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = pet_animal.2006.a
		add_stress = minor_stress_loss
	}
}



#########################
#########################
## OTHER PEOPLE HAVE PETS
#########################
#########################

#A rival has a cat...
#by Linnéa Thimrén
pet_animal.5001 = {
	type = character_event
	title = pet_animal.5001.t
	desc = pet_animal.5001.desc
	theme = pet
	override_background = {
		reference = farmland
	}
	left_portrait = scope:rival
	
	trigger = {
		NOR = {
			has_character_flag = had_pet_animal_5001_event
			has_character_flag = had_pet_animal_5002_event
			has_character_flag = had_pet_animal_3050_event
		}
		any_relation = {
			type = rival
			is_ai = yes
			any_owned_story = {
				story_type = story_cycle_pet_cat
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_5001_event
			years = 40
		}
		random_relation = {
			type = rival
			limit = {
				is_ai = yes
				any_owned_story = {
					story_type = story_cycle_pet_cat
				}
			}
			save_scope_as = rival

			random_owned_story = {
				limit = {
					story_type = story_cycle_pet_cat
				}
				save_scope_as = rival_cat_story
			}

			capital_province = {
				save_scope_as = rival_home
			}
		}
	}

	option = { #Kill it
		name = pet_animal.5001.a
		flavor = pet_animal.5001.a.tt
		show_as_tooltip = {
			scope:rival = { remove_cat_story_modifiers_effect = yes }
		}
		scope:rival_cat_story = {
			hidden_effect = { end_story = yes }
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			sadistic = medium_stress_impact_loss
		}
	}

	option = { #Pet it!
		name = pet_animal.5001.b
		add_stress = medium_stress_loss
	}
}

#A rival has a dog...
#by Linnéa Thimrén
pet_animal.5002 = {
	type = character_event
	title = pet_animal.5002.t
	desc = pet_animal.5002.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = scope:rival
	
	trigger = {
		NOR = {
			has_character_flag = had_pet_animal_5001_event
			has_character_flag = had_pet_animal_5002_event
			has_character_flag = had_pet_animal_3050_event
		}
		any_relation = {
			type = rival
			is_ai = yes
			any_owned_story = {
				story_type = story_cycle_pet_dog
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_5002_event
			years = 40
		}
		random_relation = {
			type = rival
			limit = {
				is_ai = yes
				any_owned_story = {
					story_type = story_cycle_pet_dog
				}
			}
			save_scope_as = rival

			random_owned_story = {
				limit = {
					story_type = story_cycle_pet_dog
				}
				save_scope_as = rival_dog_story
			}

			capital_province = {
				save_scope_as = rival_home
			}
		}
	}

	option = { #Kill it
		name = pet_animal.5002.a
		flavor = pet_animal.5001.a.tt
		show_as_tooltip = {
			scope:rival = { remove_dog_story_modifiers_effect = yes }
		}
		scope:rival_dog_story = {
			hidden_effect = { end_story = yes }
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			sadistic = medium_stress_impact_loss
		}
	}

	option = { #Pet it!
		name = pet_animal.5002.b
		add_stress = medium_stress_loss
	}
}


#########################
#########################
## DOG DECISION EVENTS
#########################
#########################
#Events triggered from decisions about your animals

#You pet your dog
#by Linnéa Thimrén
pet_animal.6001 = {
	type = character_event
	title = pet_animal.6001.t
	desc = pet_animal.6001.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = pet_animal.6001.a
		add_stress = minor_stress_loss
	}
}

#You pet your dog v.2
#by Linnéa Thimrén
pet_animal.6002 = {
	type = character_event
	title = pet_animal.6001.t
	desc = pet_animal.6002.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = pet_animal.6001.a
		add_stress = minor_stress_loss
	}
}

scripted_trigger pet_animal_6003_new_claim_trigger = {
	save_temporary_scope_as = target_county
	root = {
		NOT = {
			has_claim_on = scope:target_county
		}
		any_character_to_title_neighboring_county = {
			this = scope:target_county
		}
	}
}

scripted_trigger pet_animal_6003_neighboring_ruler_trigger = {
	save_temporary_scope_as = neighboring_ruler
	any_sub_realm_county = {
		pet_animal_6003_new_claim_trigger = yes
	}
}

#Your dog finds a claim!
#by Alexander Oltner
pet_animal.6003 = {
	type = character_event
	title = pet_animal.6001.t
	desc = pet_animal.6003.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:neighboring_ruler
		animation = personality_rational
	}
	
	trigger = {
		highest_held_title_tier >= tier_county
		any_neighboring_realm_same_rank_owner = {
			pet_animal_6003_neighboring_ruler_trigger = yes
		}
		NOT = { has_character_flag = had_pet_animal_6003_event } #Complete blockage since the event is so powerful
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_6003_event
			years = 10
		}
		random_neighboring_realm_same_rank_owner = {
			limit = {
				pet_animal_6003_neighboring_ruler_trigger = yes
			}
			save_scope_as = neighboring_ruler
			random_sub_realm_county = {
				limit = {
					pet_animal_6003_new_claim_trigger = yes
				}
				save_scope_as = target_county
			}
		}
	}

	option = {
		name = pet_animal.6003.a
		add_unpressed_claim = scope:target_county
		stress_impact = {
			content = medium_stress_impact_gain
			honest = medium_stress_impact_gain
			just = medium_stress_impact_gain
			arrogant = minor_stress_loss
			ambitious = minor_stress_loss
			greedy = minor_stress_loss
		}
	}

	option = {
		name = pet_animal.6003.b
		scope:neighboring_ruler = {
			add_opinion = {
				modifier = trust_opinion
				target = root
				opinion = 20
			}
		}
		progress_towards_friend_effect = { CHARACTER = scope:neighboring_ruler REASON = friend_returned_lost_scroll OPINION = 0 }
		stress_impact = {
			content = minor_stress_loss
			honest = medium_stress_loss
			just = minor_stress_loss
			greedy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			ambitious = major_stress_impact_gain
		}
	}
}


#Your dog lashes out D:
#by Linnéa Thimrén
pet_animal.6004 = {
	type = character_event
	title = pet_animal.6001.t
	desc = pet_animal.6004.desc
	theme = pet
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = shock
	}
	
	trigger = {
		NOT = { has_character_flag = had_pet_animal_6004_event } #Complete blockage since the event is severe
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_6004_event
			years = 10
		}
		random_owned_story = {
			limit = {
				story_type = story_cycle_pet_dog
			}
			save_scope_as = story
		}
		increase_wounds_effect = { REASON = dog_attack }
	}

	option = {
		name = pet_animal.6004.a
	}

	option = {
		name = pet_animal.6004.b
		show_as_tooltip = {
			remove_dog_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}


#########################
#########################
## CAT DECISION EVENTS
#########################
#########################

#You pet your cat
#by Linnéa Thimrén
pet_animal.6051 = {
	type = character_event
	title = pet_animal.6051.t
	desc = pet_animal.6051.desc
	theme = pet
	override_background = {
		reference = sitting_room
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	
	weight_multiplier = {
		base = 1
		modifier = { #No blockage, so the decision is available, but very unlikely with repetition
			add = -0.9
			has_character_flag = had_pet_animal_6051_event
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_6051_event
			years = 10
		}
	}

	option = {
		name = pet_animal.6001.a
		add_stress = minor_stress_loss
	}
}

#You pet your cat v.2
#by Linnéa Thimrén
pet_animal.6052 = {
	type = character_event
	title = pet_animal.6051.t
	desc = pet_animal.6052.desc
	theme = pet
	left_portrait = {
		character = root
		animation = happiness
	}
	
	weight_multiplier = {
		base = 1
		modifier = { #No blockage, so the decision is available, but very unlikely with repetition
			add = -0.9
			has_character_flag = had_pet_animal_6052_event
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_pet_animal_6052_event
			years = 10
		}
	}

	option = {
		name = pet_animal.6001.a
		add_stress = minor_stress_loss
	}
}

pet_animal.6055 = { # Decide if your spouse can be allergic by Hugo Cortell
	hidden = yes
	# As suggested by Oltner, this event acts as a gateway to pet_animal.0106
	# Culls down the number of allergic people by flagging some as resistant to allergies

	trigger = {
		NOT = { has_character_flag = had_pet_animal_0106_event }
		any_spouse = {
			is_available_ai = yes
			NOR = {
				has_character_modifier = cat_story_allergy_modifier
				has_character_flag = forbidden_from_pet_allergies
			}
		}
	}

	immediate = {
		random_list = {
			10 = { trigger_event = pet_animal.0106 } # Allow spouse to be allergic
			90 = { # No allergens for you, mwahahaha!
				random_spouse = {
					limit = { NOT = { has_character_flag = forbidden_from_pet_allergies } } # If there are multiple spouses, this ensures it is assigned to a valid one
					add_character_flag = forbidden_from_pet_allergies
				}
			}
		}
	}
}

###########################################
# Name your Eagle
#	3001-3999
###########################################
pet_animal.3001 = {
	type = character_event
	title = pet_animal.3001.t
	desc = pet_animal.3001.desc
	theme = pet

	left_portrait = {
		character = root
		animation = personality_cynical
	}
	
	trigger = {
		NOT = { has_variable = naming_eagle_var }
	}

	immediate = {
		set_variable = naming_eagle_var
		#To give some options to show
		hidden_effect = {
			while = {
				count = 3
				assign_name_options_eagle_story_cycle_effect = yes
			}
		}
		play_music_cue = "mx_cue_low_key_positive"
		if = {
			limit = { is_ai = yes }
			random_in_list = {
				variable = story_cycle_eagle_names
				save_scope_as = eagle_name
				root = {
					set_variable = {
						name = story_cycle_eagle_name
						value = scope:eagle_name
					}
				}
			}
		}
	}

	widget = {
		gui = "event_window_widget_enter_text"
		container = "dynamic_birth_name"
		controller = {
			type = text
			data = {
				key = story_cycle_eagle_name
				default = {
					localization_key = eagle_name_lyra
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:lyra }
					}
				}
				default = {
					localization_key = eagle_name_astana
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:astana }
					}
				}
				default = {
					localization_key = eagle_name_anda
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:anda }
					}
				}
				default = {
					localization_key = eagle_name_khongor
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:khongor }
					}
				}
				default = {
					localization_key = eagle_name_chania
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:chania }
					}
				}
				default = {
					localization_key = eagle_name_timur
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:timur }
					}
				}
				default = {
					localization_key = eagle_name_qyliinshaq
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:qyliinshaq }
					}
				}
				default = {
					localization_key = eagle_name_janym
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:janym }
					}
				}
				default = {
					localization_key = eagle_name_syr
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:syr }
					}
				}
				default = {
					localization_key = eagle_name_torebek
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:torebek }
					}
				}
				default = {
					localization_key = eagle_name_elmek
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:elmek }
					}
				}
				default = {
					localization_key = eagle_name_jargal
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:jargal }
					}
				}
				default = {
					localization_key = eagle_name_khair
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:khair }
					}
				}
				default = {
					localization_key = eagle_name_halik
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:halik }
					}
				}
				default = {
					localization_key = eagle_name_zephyr
					trigger = {
						any_in_list = { variable = story_cycle_eagle_names this = flag:zephyr }
					}
				}
			}
		}
		setup_scope = {
			root = { save_scope_as = text_target }
		}
	}

	option = { 
		name = pet_animal.0001.a
	}

	after = {
		remove_variable = naming_eagle_var
		clear_variable_list = story_cycle_eagle_names
		if = {
			# We entered custom text into the pop up
			limit = { NOT = { has_variable = story_cycle_eagle_name } }
			set_variable = {
				name = story_cycle_eagle_name
				value = flag:custom
			}
		}
	}
}
scripted_trigger would_steal_eagle_trigger = {
	OR = {
		has_trait = deceitful
		has_trait = greedy
		has_trait = callous
		has_trait = sadistic
		has_trait = gallowsbait
	}
	NOR = { 
		has_trait = honest 
		has_trait = loyal
	}
}

pet_animal.3010 = { # Eagle is missing
	type = character_event
	title = pet_animal.3010.t
	desc = {
		desc = pet_animal.3010.desc
		triggered_desc = {
			trigger = {
				has_character_flag = eagle_was_stolen
			}
			desc = pet_animal.3010.desc_thief
		}
	}
	theme = pet

	cooldown = { years = 15 }

	left_portrait = {
		character = root
		animation = sadness
	}

	right_portrait = {
		character = scope:eagle_informer
		animation = worry
	}

	trigger = {
		is_available_adult = yes
		any_courtier_or_guest = { count > 0 }
	}

	immediate = {
		add_character_flag = eagle_is_missing
		random_courtier_or_guest = {
			limit = {
				is_available_ai_adult = yes
			}
			save_scope_as = eagle_informer
		}
		# Someone stole it 
		if = {
			random_list = {
				50 = { 
					trigger = {
						any_courtier_or_guest = { would_steal_eagle_trigger = yes } 
					}
					modifier = { # A curious eagle might have flown away
						add = 10
						has_character_modifier = curious_eagle_story_modifier
					}
					modifier = { # No one there to steal it lol
						add = 1000
						any_courtier_or_guest = { count = 1 }
					}
				}
				50 = { 
					modifier = { # A loyal eagle would never leave you, willingly
						add = 1000
						has_character_modifier = loyal_eagle_story_modifier
					}
					add_character_flag = eagle_was_stolen
				}
			}
		}

		if = {
			limit = {
				NOT = { exists = scope:story }
			}
			every_owned_story = {
				limit = { story_type = story_cycle_pet_eagle }
				save_scope_as = story
			}
		}
	}

	option = { # Organize a search party
		name = pet_animal.3010.a
		custom_tooltip = pet_animal.3010.a_tt
		trigger = {
			NOT = { has_character_flag = eagle_was_stolen }
		}
		remove_short_term_gold = minor_gold_value
		save_scope_value_as = {
			name = eagle_return_variable
			value = flag:found
		}
		hidden_effect = {
			random_list = {
				90 = { # Found / Returns
					trigger_event = {
						id = pet_animal.3011
						days = { 30 400 }
					}
				}
				10 = {
					trigger_event = {
						id = pet_animal.3012
						days = 400
					}
				}
			}
		}

		ai_chance = {
			base = 25
		}
	}

	option = { # Investigate a courtier
		name = pet_animal.3010.b
		trigger = {
			has_character_flag = eagle_was_stolen
		}
		custom_tooltip = pet_animal.3010.b_tt

		trigger_event = {
			id = pet_animal.3013
		}

		ai_chance = {
			base = 35
		}
	}

	option = { # Wait and hope 
		name = pet_animal.3010.c
		add_stress = minor_stress_gain
		custom_tooltip = pet_animal.3010.c_tt
		save_scope_value_as = {
			name = eagle_return_variable
			value = flag:freedom
		}
		hidden_effect = {
			random_list = {
				50 = { # Found / Returns
					modifier = {
						has_character_flag = eagle_was_stolen
						add = -30
					}
					trigger_event = {
						id = pet_animal.3011
						days = { 120 800 }
					}
				}
				50 = {
					trigger_event = {
						id = pet_animal.3012
						days = 800
					}
				}
			}
		}

		ai_chance = {
			base = 15
			modifier = {
				has_trait = lazy
				add = 15
			}
		}
	}

	option = { # Abandon him/her
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							has_trait = callous
						}
						desc = pet_animal.3010.d_mean
					}
					triggered_desc = {
						trigger = {
							var:eagle_age_variable > 15
						}
						desc = pet_animal.3010.d_old
					}
					desc = pet_animal.3010.d
				}
			}
		}
		custom_tooltip = pet_animal.3010.d_tt
		add_stress = minor_stress_loss
		add_prestige = minor_prestige_loss
		remove_character_flag = eagle_is_missing
		show_as_tooltip = {
			remove_eagle_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.25
			}
			modifier = {
				add = 20
				var:eagle_age_variable > 15
			}
		}
	}
}

pet_animal.3011 = { # Eagle is found / returns
	type = character_event
	title = pet_animal.3011.t
	desc = {
		desc = pet_animal.3011.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:eagle_return_variable
					scope:eagle_return_variable = flag:freedom
				}
				desc = pet_animal.3011.desc_freedom
			}
			triggered_desc = {
				trigger = {
					exists = scope:eagle_return_variable
					scope:eagle_return_variable = flag:found
				}
				desc = pet_animal.3011.desc_found
			}
			triggered_desc = {
				trigger = {
					exists = scope:eagle_thief
				}
				desc = pet_animal.3011.desc_stolen
			}
		}
		triggered_desc = {
			trigger = {
				NOT = { has_character_flag = eagle_returned_no_change }
			}
			desc = pet_animal.3011.desc_change
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait_2 ?= flag:observant
				}
				desc = pet_animal.3011.desc_observant
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait_2 ?= flag:protective
				}
				desc = pet_animal.3011.desc_protective
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait_2 ?= flag:aggressive
				}
				desc = pet_animal.3011.desc_aggressive
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait = flag:brave
				}
				desc = pet_animal.3011.desc_brave
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait = flag:curious
				}
				desc = pet_animal.3011.desc_curious
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait = flag:loyal
				}
				desc = pet_animal.3011.desc_loyal
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait = flag:calm
				}
				desc = pet_animal.3011.desc_calm
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait = flag:wise
				}
				desc = pet_animal.3011.desc_wise
			}
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = eagle_returned_no_change }
					var:eagle_personality_trait = flag:cunning
				}
				desc = pet_animal.3011.desc_cunning
			}
		}
	}
	theme = pet

	left_portrait = {
		character = root
	 	animation = hunting_falcon #TODO_MPO - Change to eagle
	}

	lower_right_portrait = {
		trigger = {
			exists = scope:eagle_thief
		}
		character = scope:eagle_thief
	}

	immediate = {
		remove_character_flag = eagle_is_missing
		# If they don't have a personality trait, give them one
		hidden_effect = {
			if = {
				limit = {
					has_eagle_personality_trait_trigger = no
				}
				set_random_eagle_personality_trait_effect = { ADD_MODIFIER = yes }
				add_eagle_personality_modifier_effect = yes
			}
			# If they have one, give a secondary
			else_if = {
				limit = {
					has_secondary_eagle_personality_trait_trigger = no
				}
				set_random_secondary_eagle_personality_trait_effect = yes
			}
			# No change
			else = {
				add_character_flag = {
					flag = eagle_returned_no_change
					days = 2
				}
			}
		}
		if = {
			limit = {
				exists = scope:eagle_thief
			}
			progress_towards_rival_effect = {
				REASON = rival_stole_from_me_eagle
				CHARACTER = scope:eagle_thief
				OPINION = -30
			}
		}
		add_stress = medium_stress_loss
	}

	option = { # Welcome back!
		name = pet_animal.3011.a
		add_prestige = minor_prestige_gain

		ai_chance = {
			base = 50
		}
	}

	option = { # Le thief
		name = pet_animal.3011.b
		trigger = { exists = scope:eagle_thief }
		
		add_dread = minor_dread_gain

		rightfully_imprison_character_less_verbose_effect = {
			TARGET = scope:eagle_thief
			IMPRISONER = root
		}

		stress_impact = {
			compassionate = minor_stress_impact_gain
			vengeful = medium_stress_impact_loss
			just = minor_stress_impact_loss
		}

		ai_chance = {
			base = 35
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = 0.25
			}
		}
	}
}

pet_animal.3012 = { # Eagle is not returning :(
	type = character_event
	title = pet_animal.3013.t
	desc = pet_animal.3012.desc

	theme = pet

	left_portrait = {
		character = root
		animation = sadness
	}

	right_portrait = {
		character = scope:eagle_informer
		animation = worry
	}

	immediate = {
		if = { # Get new informer if needed
			limit = {
				OR = {
					NOT = { exists = scope:eagle_informer }
					scope:eagle_informer = { is_alive = no }
					scope:eagle_informer = { is_available_adult = no }
				}
			}
			random_courtier_or_guest = {
				limit = {
					is_ai = yes
					is_available_adult = yes
				}
				save_scope_as = eagle_informer
			}
		}
	}


	option = { # bye
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							has_trait = callous
						}
						desc = pet_animal.3010.d_mean
					}
					triggered_desc = {
						trigger = {
							scope:story = {
								var:eagle_age_variable > 15
							}
						}
						desc = pet_animal.3010.d_old
					}
					desc = pet_animal.3012.a
				}
			}
		}
		add_stress = minor_stress_gain
		remove_character_flag = eagle_is_missing
		show_as_tooltip = {
			remove_eagle_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}

scripted_effect find_potential_eagle_thief_effect = {
	random_courtier_or_guest = {
		limit = {
			is_ai = yes
			is_available_adult = yes
			NOT = { has_eagle_trigger = yes }
			NOR = { # prevent duplicate
				scope:accused_thief_1 ?= this
				scope:accused_thief_2 ?= this
			}
		}
		weight = {
			base = 1
			opinion_modifier = {
				opinion_target = root
				multiplier = 0.5 
			}
			modifier = {
				add = 50
				would_steal_eagle_trigger = yes
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:$SCOPE_NAME$ }
			}
			save_scope_as = $SCOPE_NAME$
		}
	}
}

scripted_effect find_eagle_thief_effect = {
	$THIEF$ = { save_scope_as = accused_thief }
	custom_tooltip = pet_animal.3013.tt
	if = {
		limit = {
			scope:accused_thief = scope:eagle_thief
		}
		trigger_event = {
			id = pet_animal.3011
		}
	}
	else = {
		hidden_effect = {
			send_interface_toast = {
				title = pet_animal.3013.wrong
				type = event_toast_effect_bad
				left_icon = root
				right_icon = scope:accused_thief
				add_stress = minor_stress_gain
				
				scope:accused_thief = {
					add_opinion = {
						modifier = falsely_accused
						target = root
					}
				}
			}
			# Still has a small chance to come back though
			random_list = {
				20 = { 
					trigger_event = {
						id = pet_animal.3011
						days = { 120 240 }
					}
				}
				80 = {
					trigger_event = {
						id = pet_animal.3012
						days = { 120 240 }
					}
				}
			}
		}		
	}
}

pet_animal.3013 = { # Finding a thief
	type = character_event
	title = pet_animal.3013.t
	desc = {
		desc = pet_animal.3013.desc
		first_valid = {
			triggered_desc = {
				trigger = {	
					exists = scope:accused_thief_2
				}
				desc = pet_animal.3013.desc_thief_2
			}
			triggered_desc = {
				trigger = {
					exists = scope:accused_thief_1
				}
				desc = pet_animal.3013.desc_thief_1
			}
			desc = pet_animal.3013.desc_thief_none
		}
	}
	theme = pet

	left_portrait = {
		character = root
		animation = thinking
	}

	lower_left_portrait = {
		trigger = {
			exists = scope:accused_thief_1
		}
		character = scope:accused_thief_1
	}

	lower_right_portrait = {
		trigger = {
			exists = scope:accused_thief_2
		}
		character = scope:accused_thief_2
	}

	immediate = {
		remove_character_flag = eagle_was_stolen
		# Get potential thiefs
		find_potential_eagle_thief_effect = { SCOPE_NAME = accused_thief_1 }
		if = {
			limit = {
				exists = scope:accused_thief_1
			}
			find_potential_eagle_thief_effect = { SCOPE_NAME = accused_thief_2 }
		}
		# Set the thief
		random_list = {
			1 = { trigger = { exists = scope:accused_thief_1 } scope:accused_thief_1 = { save_scope_as = eagle_thief } }
			1 = { trigger = { exists = scope:accused_thief_2 } scope:accused_thief_2 = { save_scope_as = eagle_thief } }
		}
	}


	option = { # Surely, it's option 1
		name = pet_animal.3013.a
		trigger = { exists = scope:accused_thief_1 }
		find_eagle_thief_effect = { THIEF = scope:accused_thief_1 }
		
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				scope:accused_thief_1 = { has_trait = deceitful }
			}
			opinion_modifier = {
				who = root
				opinion_target = scope:accused_thief_1
				multiplier = -0.5
			}
		}
	}

	option = { # No, it's option 2
		name = pet_animal.3013.b
		trigger = {
			exists = scope:accused_thief_2
		}
		find_eagle_thief_effect = { THIEF = scope:accused_thief_2 }
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				scope:accused_thief_2 = { has_trait = deceitful }
			}
			opinion_modifier = {
				who = root
				opinion_target = scope:accused_thief_2
				multiplier = -0.5
			}
		}
	}


	option = { # None of the above
		name = pet_animal.3013.d
		custom_tooltip = pet_animal.3013.unknown
		hidden_effect = {
			random_list = { # Small chance to return still 
				30 = { 
					trigger_event = {
						id = pet_animal.3011
						days = { 120 240 }
					}
				}
				70 = {
					trigger_event = {
						id = pet_animal.3012
						days = { 120 240 }
					}
				}
			}
		}

		stress_impact = {
			base = miniscule_stress_impact_gain
			vengeful = minor_stress_impact_gain
			just = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
			}
		}
	}
}

pet_animal.3020 = { # Time to let go :(
	type = character_event
	title = pet_animal.3020.t
	desc = {
		desc = pet_animal.3020.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_capture_method_standard
				}
				desc = pet_animal.3020.desc_intro_standard
			}
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_capture_method_lure
				}
				desc = pet_animal.3020.desc_intro_lure
			}
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_capture_method_gift
				}
				desc = pet_animal.3020.desc_intro_gift
			}
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_capture_method_market
				}
				desc = pet_animal.3020.desc_intro_market
			}
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_capture_method_stolen
				}
				desc = pet_animal.3020.desc_intro_stolen
			}
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_capture_method_none
				}
				desc = pet_animal.3020.desc_intro_none
			}
		}
		desc = pet_animal.3020.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_let_go
				}
				desc = pet_animal.3020.desc_let_go
			}
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_let_go_2
				}
				desc = pet_animal.3020.desc_let_go_2
			}
			desc = pet_animal.3020.desc_normal
		}
	}
	theme = pet

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_character_flag = eagle_let_go_2 }
			animation = sadness
		}
		triggered_animation = {
			trigger = { always = yes }
			animation = hunting_falcon #TODO_MPO - Change to eagle
		}
	}

	trigger = {
		NOR = {
			has_character_flag = eagle_is_missing
			has_character_flag = eagle_is_dying
		}
		is_alive = yes
		exists = var:story_cycle_eagle_name
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		if = {
			limit = {
				NOT = { exists = scope:story }
			}
			every_owned_story = {
				limit = { story_type = story_cycle_pet_eagle }
				save_scope_as = story
			}
		}
		create_artifact_bird_feather_effect = {
			OWNER = root
			HUNTER = root
			ANIMAL = flag:eagle
		}
	}

	option = { # Ok, bye
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							has_character_flag = eagle_let_go
						}
						desc = pet_animal.3020.a_second
					}
					desc = pet_animal.3199.a
				}
			}
		}
		custom_tooltip = pet_animal.3020.a_tt
		if = {
			limit = { # First time getting the event
				NOR = {
					has_character_flag = eagle_let_go
					has_character_flag = eagle_let_go_2
				}
			}
			scope:newly_created_artifact = { set_owner = root }
		}
		add_prestige = medium_prestige_gain
		show_as_tooltip = {
			remove_eagle_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}

		if = {
			limit = {
				has_character_flag = eagle_let_go
			}
			remove_character_flag = eagle_let_go
		}
		else_if = {
			limit = {
				has_character_flag = eagle_let_go_2
			}
			remove_character_flag = eagle_let_go_2
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}

	option = { # Not letting go yet
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							has_character_flag = eagle_let_go
						}
						desc = pet_animal.3020.b_second
					}
					desc = pet_animal.3020.b
				}
			}
		}
		trigger = {
			NOT = { has_character_flag = eagle_let_go_2 }
		}
		custom_tooltip = pet_animal.3020.b_tt
		add_prestige = minor_prestige_gain
		if = {
			limit = {
				has_character_flag = eagle_let_go
			}
			remove_character_flag = eagle_let_go
			add_character_flag = eagle_let_go_2
			trigger_event = { # OK, try again in about 3/4 years
				id = pet_animal.3020
				days = { 1095 1460 }
			}
		}
		else = {
			add_character_flag = eagle_let_go
			trigger_event = { # OK, try again in about 5/6 years
				id = pet_animal.3020
				days = { 1825 2190 }
			}
		}
		custom_tooltip = pet_animal.3020.warning_less
		if = {
			limit = { exists = scope:newly_created_artifact }
			hidden_effect = { destroy_artifact = scope:newly_created_artifact }
		}

		hidden_effect = {
			random_list = {
				20 = { # Eagle becomes a bit weak
					modifier = {
						add = 10
						has_character_flag = eagle_let_go
					}
					modifier = {
						add = 20
						has_character_flag = eagle_let_go_2
					}
					modifier = {
						add = -10
						var:eagle_personality_trait_2 ?= flag:protective
					}
					weaken_eagle_effect = yes
				}
				50 = { } # Nothing happens
			}
		}

		ai_chance = {
			base = 40
			ai_value_modifier = {
				ai_compassion = 0.25
			}
			modifier = {
				add = 20
				has_trait = stubborn
			}
		}
	}

	option = {
		name = pet_animal.3020.c
		trigger = {
			NOT = { has_character_flag = eagle_let_go_2 }
		}
		custom_tooltip = pet_animal.3020.c_tt
		add_stress = medium_stress_loss
		custom_tooltip = pet_animal.3020.warning
		if = {
			limit = {
				has_character_flag = eagle_let_go
			}
			remove_character_flag = eagle_let_go
		}
		else_if = {
			limit = {
				has_character_flag = eagle_let_go_2
			}
			remove_character_flag = eagle_let_go_2
		}

		if = {
			limit = { exists = scope:newly_created_artifact }
			hidden_effect = { destroy_artifact = scope:newly_created_artifact }
		}

		hidden_effect = {
			random_list = {
				40 = { # Eagle becomes a bit weak
					modifier = {
						add = 10
						has_character_flag = eagle_let_go
					}
					modifier = {
						add = 20
						has_character_flag = eagle_let_go_2
					}
					modifier = {
						add = -10
						var:eagle_personality_trait_2 ?= flag:protective
					}
					weaken_eagle_effect = yes
				}
				50 = { } # Nothing happens
			}
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.1
			}
			modifier = {
				add = 50
				has_trait = stubborn
			}
		}
	}
}

pet_animal.3030 = { # Eagle is injured
	type = character_event
	title = {
		desc = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:eagle_injury_variable = flag:eye
					}
					desc = pet_animal.3030.t_eye
				}
				triggered_desc = {
					trigger = {
						scope:eagle_injury_variable = flag:wing
					}
					desc = pet_animal.3030.t_wing
				}
				triggered_desc = {
					trigger = {
						scope:eagle_injury_variable = flag:claw
					}
					desc = pet_animal.3030.t_claw
				}
			}
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:eagle_injury_source ?= flag:training
				}
				desc = pet_animal.3030.desc_training
			}
			desc = pet_animal.3030.desc_intro
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:eagle_injury_variable = flag:eye
				}
				desc = pet_animal.3030.desc_eye
			}
			triggered_desc = {
				trigger = {
					scope:eagle_injury_variable = flag:wing
				}
				desc = pet_animal.3030.desc_wing
			}
			triggered_desc = {
				trigger = {
					scope:eagle_injury_variable = flag:claw
				}
				desc = pet_animal.3030.desc_claw
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_modifier = very_weak_eagle_modifier
				}
				desc = pet_animal.3030.desc_weak
			}
		}
		desc = pet_animal.3030.desc_outro
	}

	theme = pet

	cooldown = { years = 5 }

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		trigger = {
			exists = scope:court_physician
		}
		character = scope:court_physician
		animation = thinking
	}

	lower_right_portrait = {
		trigger = {
			exists = scope:court_huntsman
		}
		character = scope:court_huntsman
	}

	lower_center_portrait = {
		trigger = {
			exists = scope:random_smart_courtier
		}
		character = scope:random_smart_courtier
	}

	trigger = {
		NOT = { has_character_flag = eagle_marked_for_death }
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:story }
			}
			every_owned_story = {
				limit = { story_type = story_cycle_pet_eagle }
				save_scope_as = story
			}
		}
		# Random injury
		random_list = {
			10 = { save_scope_value_as = { name = eagle_injury_variable value = flag:eye } }
			10 = { save_scope_value_as = { name = eagle_injury_variable value = flag:wing } }
			10 = { save_scope_value_as = { name = eagle_injury_variable value = flag:claw } }
		}
		weaken_eagle_effect = yes
		if = {
			limit = {
				any_court_position_holder = {
					type = court_physician_court_position
					is_available_adult = yes
					location = root.location
				}
			}
			random_court_position_holder = {
				type = court_physician_court_position
				limit = {
					is_available_adult = yes
					location = root.location
				}
				save_scope_as = court_physician
			}
		}
		if = {
			limit = {
				any_court_position_holder = {
					type = master_of_horse_court_position
					is_available_adult = yes
					NOT = { scope:court_physician ?= this }
					location = root.location
				}
			}
			random_court_position_holder = {
				type = master_of_horse_court_position
				limit = {
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
				save_scope_as = court_huntsman
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = kennelperson_camp_officer
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
			}
			random_court_position_holder = {
				type = kennelperson_camp_officer
				limit = {
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
				save_scope_as = court_huntsman
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = master_of_hunt_court_position
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
			}
			random_court_position_holder = {
				type = master_of_hunt_court_position
				limit = {
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
				save_scope_as = court_huntsman
			}
		}
		else_if = {
			limit = {
				any_court_position_holder = {
					type = huntperson_camp_officer
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
			}
			random_court_position_holder = {
				type = huntperson_camp_officer
				limit = {
					is_available_adult = yes
					location = root.location
					NOT = { scope:court_physician ?= this }
				}
				save_scope_as = court_huntsman
			}
		}
		ordered_courtier_or_guest = {
			limit = {
				is_ai = yes
				is_available_adult = yes
				location = root.location
				NOR = {
					scope:court_physician ?= this 
					scope:court_huntsman ?= this 
				}
			}
			order_by = learning
			save_scope_as = random_smart_courtier
		}	
	}

	option = { # Court physician treatment
		name = pet_animal.3030.court_physician
		trigger = { exists = scope:court_physician }
		eagle_treatment_effect = { HEALER = scope:court_physician BONUS = court_physician }

		ai_chance = {
			base = 1
			modifier = {
				always = yes 
				add = scope:court_physician.learning
			}
		}
	}

	option = { # Master of the horse / hunt treatmnet
		name = pet_animal.3030.court_huntsman
		trigger = { exists = scope:court_huntsman }
		eagle_treatment_effect = { HEALER = scope:court_huntsman BONUS = hunter }
		ai_chance = {
			base = 1
			modifier = {
				always = yes 
				add = scope:court_huntsman.learning
			}
		}
	}

	option = { # Pay someone else
		name = pet_animal.3030.random_smart_courtier
		trigger = { 
			exists = scope:random_smart_courtier
			short_term_gold >= minor_gold_value
		}
		show_as_unavailable = {
			short_term_gold < minor_gold_value
		}
		pay_short_term_gold = {
			target = scope:random_smart_courtier
			gold = minor_gold_value
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}

		eagle_treatment_effect = { HEALER = scope:random_smart_courtier BONUS = courtier }

		ai_chance = {
			base = 5
			modifier = {
				has_trait = greedy
				add = -10
			}
			modifier = {
				always = yes 
				add = scope:random_smart_courtier.learning
			}
		}
	}

	option = { # Do it myself
		name = pet_animal.3030.self
		trigger = {
            learning >= 13
        }
        show_as_unavailable = {
			always = yes
		}
		random_list = {
			50 = {
				show_chance = no
				desc = pet_animal.3030.good_self
				send_interface_toast = {
					title = pet_animal.eagle_unweak_title
					type = event_toast_effect_good
					left_icon = root
					unweaken_eagle_effect = { FULL = no }
				}
			}	
			50 = {
				modifier = { 
					add = 15
					learning >= 25
				}
				show_chance = no
				desc = pet_animal.3030.very_good_self
				send_interface_toast = {
					title = pet_animal.eagle_unweak_title
					type = event_toast_effect_good
					left_icon = root
					unweaken_eagle_effect = { FULL = yes }
					add_character_modifier = {
						modifier = strong_eagle_modifier
						years = 1
					}
				}
			}
		}

		ai_chance = {
			base = 100
		}
	}

	option = { # Can't do anything
		name = pet_animal.3030.none

		add_prestige = miniscule_prestige_loss

		stress_impact = {
			compassionate = minor_stress_impact_gain
			callous = minor_stress_impact_loss
		}

		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_compassion = -0.2
			}
		}
	}
}

pet_animal.3040 = { # Eagle training session, chance to level and/or gain personality trait
	type = character_event
	title = pet_animal.3040.t
	desc = pet_animal.3040.desc

	theme = pet

	cooldown = { years = 3 }

	left_portrait = {
		character = root
		animation = hunting_falcon #TODO_MPO - Change to eagle
	}

	immediate = {
		# Get only a few training methods so we don't have 69 options on the screen
		hidden_effect = {
			while = { # Will get 1-3 extra option
				count = 3
				get_eagle_training_method_effect = yes
			}
		}
	}

	trigger = {
		has_variable = eagle_age_variable
		var:eagle_age_variable >= 2
	}

	option = { # Martial
		name = pet_animal.3040.martial
		trigger = { any_in_list = { variable = eagle_training_methods this = flag:martial } }
		eagle_training_effect = { METHOD = martial }

		ai_chance = {
			base = 10
			modifier = {
				add = martial
				always = yes
			}
			modifier = {
				highest_skill = martial 
				factor = 1.5
			}
		}
	}

	option = { # Stewardship
		name = pet_animal.3040.stewardship
		trigger = { any_in_list = { variable = eagle_training_methods this = flag:stewardship } }
		eagle_training_effect = { METHOD = stewardship }

		ai_chance = {
			base = 10
			modifier = {
				add = stewardship
				always = yes
			}
			modifier = {
				highest_skill = stewardship 
				factor = 1.5
			}
		}
	}

	option = { # Diplomacy
		name = pet_animal.3040.diplomacy
		trigger = { any_in_list = { variable = eagle_training_methods this = flag:diplomacy } }
		eagle_training_effect = { METHOD = diplomacy }

		ai_chance = {
			base = 10
			modifier = {
				add = diplomacy
				always = yes
			}
			modifier = {
				highest_skill = diplomacy 
				factor = 1.5
			}
		}
	}

	option = { # Intrigue
		name = pet_animal.3040.intrigue
		trigger = { any_in_list = { variable = eagle_training_methods this = flag:intrigue } }
		eagle_training_effect = { METHOD = intrigue }

		ai_chance = {
			base = 10
			modifier = {
				add = intrigue
				always = yes
			}
			modifier = {
				highest_skill = intrigue 
				factor = 1.5
			}
		}
	}

	option = { # Learning
		name = pet_animal.3040.learning
		trigger = { any_in_list = { variable = eagle_training_methods this = flag:learning } }
		eagle_training_effect = { METHOD = learning }

		ai_chance = {
			base = 10
			modifier = {
				add = learning	
				always = yes
			}
			modifier = {
				highest_skill = learning 
				factor = 1.5
			}
		}
	}

	option = { # Money
		name = pet_animal.3040.money
		trigger = {
			OR = {
				AND = {
					has_character_flag = eagle_training_money
					short_term_gold >= medium_gold_value
				}
				short_term_gold >= minor_gold_value
			}
			NOT = {
				any_in_list = {
					variable = eagle_training_methods
					count > 1
				}
			}
		}
		show_as_unavailable = {
			short_term_gold < minor_gold_value
		}
		custom_tooltip = pet_animal.3040.money_tt

		if = {
			limit = {
				has_character_flag = eagle_training_money
			}
			remove_short_term_gold = medium_gold_value
		}
		else = {
			remove_short_term_gold = minor_gold_value
			add_character_flag = {
				flag = eagle_training_money
				years = 5
			}
		}
		
		eagle_training_success_effect = { METHOD = none }
		
		ai_chance = {
			base = 25
			modifier = {
				has_trait = greedy
				add = -10
			}
		}
	}

	option = { # Lazy person option
		name = pet_animal.3040.none
		add_prestige = miniscule_prestige_loss

		ai_chance = {
			base = 10
			modifier = {
				has_trait = lazy
				add = 10
			}
		}
	}

	after = {
		clear_variable_list = eagle_training_methods
	}
}

#A rival has an eagle...
pet_animal.3050 = {
	type = character_event
	title = pet_animal.3050.t
	desc = pet_animal.3050.desc
	theme = pet

	left_portrait = scope:rival

	lower_right_portrait = {
		trigger = {
			exists = scope:token_child
		}
		character = scope:token_child
	}
	
	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		NOR = {
			has_character_flag = had_pet_animal_5001_event
			has_character_flag = had_pet_animal_5002_event
			has_character_flag = had_pet_animal_3050_event
		}
		any_relation = {
			type = rival
			is_ai = yes
			any_owned_story = {
				story_type = story_cycle_pet_eagle
			}
			has_variable = story_cycle_eagle_name
		}
	}

	immediate = {
		random_relation = {
			type = rival
			limit = {
				is_ai = yes
				any_owned_story = {
					story_type = story_cycle_pet_eagle
				}
				has_variable = story_cycle_eagle_name
			}	
			save_scope_as = rival

			random_owned_story = {
				limit = {
					story_type = story_cycle_pet_eagle
				}
				save_scope_as = rival_eagle_story
			}

			capital_province = {
				save_scope_as = rival_home
			}
		}

		if = {
			limit = {
				has_eagle_trigger = yes
			}
			ordered_child = {
				limit = {
					NOT = { has_eagle_trigger = yes }
					age >= 12
				}
				order_by = age
				save_scope_as = token_child
			}
		}
	}

	option = { #Injure it!
		name = pet_animal.5002.a
		flavor = pet_animal.5001.a.tt

		duel = {
			value = decent_skill_rating
			skill = prowess
			desc = pet_animal.3050.a.tt
			70 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -69
				}
				desc = pet_animal.3050.good
				send_interface_toast = {
					title = pet_animal.3050.good
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:rival
					scope:rival = { weaken_eagle_effect = yes }

					stress_impact = {
						compassionate = major_stress_impact_gain
						sadistic = medium_stress_impact_loss
					}
				}
			}
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -29
				}
				desc = pet_animal.3050.bad
				send_interface_toast = {
					title = pet_animal.3050.bad
					type = event_toast_effect_bad
					left_icon = root
					right_icon = scope:rival

					random = {
						chance = 10 
						increase_wounds_effect = {
							REASON = eagle_attack
						}
					}

					stress_impact = {
						base = miniscule_stress_impact_gain
					}
				}
			}
		}

		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_compassion = -0.5
			}
		}
	}
	
	option = { #Steal it for yourself!
		name = pet_animal.3050.steal
		trigger = { 
			exists = scope:token_child
			NOT = { has_eagle_trigger = yes }
		}
		flavor = pet_animal.3050.b.flavor

		duel = {
			target = scope:rival
			skill = intrigue
			desc = pet_animal.3050.steal.tt
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = pet_animal.3050.good
				send_interface_toast = {
					title = pet_animal.3050.good
					type = event_toast_effect_good
					left_icon = root
					transfer_eagle_effect = {
						RECIPIENT = root
						GIVER = scope:rival
						METHOD = stolen
					}

					add_prestige = miniscule_prestige_gain

					stress_impact = {
						honest = medium_stress_impact_gain
						just = minor_stress_impact_gain
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = pet_animal.3050.bad
				send_interface_toast = {
					title = pet_animal.3050.bad
					type = event_toast_effect_bad
					left_icon = root
					stress_impact = {
						base = miniscule_stress_impact_gain
					}
				}
			}
		}

		ai_chance = {
			base = 50
			opinion_modifier = { # I actually like this kid
				who = root
				opinion_target = scope:token_child
				multiplier = 0.75
			}
		}
	}

	option = { #Steal it for one of your children!
		name = pet_animal.3050.b
		trigger = { 
			exists = scope:token_child
			has_eagle_trigger = yes
		}
		flavor = pet_animal.3050.b.flavor

		duel = {
			target = scope:rival
			skill = intrigue
			desc = pet_animal.3050.b.tt
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = pet_animal.3050.good
				send_interface_toast = {
					title = pet_animal.3050.good
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:token_child
					transfer_eagle_effect = {
						RECIPIENT = scope:token_child
						GIVER = scope:rival
						METHOD = stolen
					}

					add_prestige = miniscule_prestige_gain
					
					scope:token_child = {
						add_opinion = {
							modifier = grateful_opinion
							target = root
							opinion = 30
						}
					}

					stress_impact = {
						honest = medium_stress_impact_gain
						just = minor_stress_impact_gain
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = pet_animal.3050.bad
				send_interface_toast = {
					title = pet_animal.3050.bad
					type = event_toast_effect_bad
					left_icon = root
					stress_impact = {
						base = miniscule_stress_impact_gain
					}
				}
			}
		}

		ai_chance = {
			base = 50
			opinion_modifier = { # I actually like this kid
				who = root
				opinion_target = scope:token_child
				multiplier = 0.75
			}
		}
	}

	option = { #Sell it for moneys
		name = pet_animal.3050.c
		flavor = pet_animal.3050.c.tt
		trigger = {
			scope:rival.hunting_eagle_sell_value > 0
		}

		duel = {
			value = decent_skill_rating
			skills = { intrigue stewardship }
			desc = pet_animal.3050.c_tt
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = pet_animal.3050.good
				send_interface_toast = {
					title = pet_animal.3050.good
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:rival
					add_gold = scope:rival.hunting_eagle_sell_value
					show_as_tooltip = {
						scope:rival = { remove_eagle_story_modifiers_effect = yes }
					}
					scope:rival_eagle_story = {
						hidden_effect = { end_story = yes }
					}
					stress_impact = {
						honest = medium_stress_impact_gain
						greedy = medium_stress_impact_loss
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = pet_animal.3050.bad
				send_interface_toast = {
					title = pet_animal.3050.bad
					type = event_toast_effect_bad
					left_icon = root
					right_icon = scope:rival

					stress_impact = {
						base = miniscule_stress_impact_gain
					}
				}
			}
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 1
			}
			modifier = {
				add = 20
				short_term_gold <= 75
			}
		}
	}

	option = { #Ok
		name = pet_animal.3050.d
		add_stress = medium_stress_loss
	}

	after = {
		add_character_flag = {
			flag = had_pet_animal_3050_event
			years = 40
		}
	}
}

pet_animal.3060 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:token_child = { is_female = no }
				}
				desc = pet_animal.3060.t
			}
			desc = pet_animal.3060.t_girl
		}
	}
	desc = {
		desc = pet_animal.3060.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:token_child = { has_eagle_trigger = yes }
				}
				desc = pet_animal.3060.desc_child
			}
			desc = pet_animal.3060.desc
		}
	}

	theme = pet

	cooldown = { years = 5 }

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:token_child
		animation = hunting_falcon #TODO_MPO - Change to eagle
	}

	trigger = {
		any_child = {
			age >= 12
			NOT = { exists = var:eagle_childhood_teacher }
		}
	}

	weight_multiplier = {
        base = 1
		modifier = {
			add = 100
			any_child = {
				age >= 12
				has_available_eagle_trigger = yes
			}
		}
		modifier = { 
            add = 1
            NOT = {
                current_season_trigger = {
                    SEASON = winter
                }
            }
        }
	}

	immediate = {
		random_child = {
			limit = {
				age >= 12
				NOT = { exists = var:eagle_childhood_teacher }
			}
			save_scope_as = token_child
			set_variable = {
				name = eagle_childhood_teacher
				value = root
			}
		}
	}

	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:token_child = { is_female = no }
						}
						desc = pet_animal.3060.a
					}
					desc = pet_animal.3060.a_girl
				}
			}
		}

		duel = {
			skills = { learning prowess }
			value = decent_skill_rating
			# No "bad" outcome
			60 = {
				modifier = {
					factor = 1.5
					scope:token_child = { 
						OR = {
							has_focus = education_martial
							has_trait = education_martial_1
							has_trait = education_martial_2
							has_trait = education_martial_3
							has_trait = education_martial_4
						}
					}
				}
				modifier = {
					factor = 1.5
					scope:token_child = { 
						OR = {
							has_focus = education_learning
							has_trait = education_learning_1
							has_trait = education_learning_2
							has_trait = education_learning_3
							has_trait = education_learning_4
						}
					}
				}
				modifier = {
					factor = 1.2
					scope:token_child = { is_adult = yes }
				}
				modifier = {
					factor = 1.2
					scope:token_child = { has_trait = lifestyle_hunter }
				}
				modifier = {
					factor = 1.25
					scope:token_child = {
						OR = {
							has_trait = diligent
							has_trait = ambitious
						}
					}
				}
				modifier = {
					factor = 1.2
					has_trait = lifestyle_hunter 
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -59
				}
				desc = pet_animal.3060.good
				send_interface_toast = {
					title = pet_animal.3060.good
					type = event_toast_effect_good
					left_icon = root
					right_icon = scope:token_child
					add_prestige = minor_prestige_gain
					scope:token_child = {
						add_character_modifier = {
							modifier = eagle_hunter_childhood_modifier
							years = 10
						}
						add_stress = medium_stress_loss
						add_opinion = {
							modifier = grateful_opinion
							target = root
							opinion = 30
						}
						add_prowess_skill = 2
						add_trait_xp = {
							trait = lifestyle_hunter
							track = falconer
							value = 5
						}
					}
				}
			}
			30 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -29
				}
				modifier = {
					factor = 1.5
					scope:token_child = { has_trait = lazy }
				}
				modifier = {
					factor = 1.2
					scope:token_child = {
						has_trait = impatient
					}
				}
				desc = pet_animal.3060.decent
				send_interface_toast = {
					title = pet_animal.3060.decent
					type = event_toast_effect_neutral
					left_icon = root
					right_icon = scope:token_child
					scope:token_child = {
						add_prowess_skill = 1
						add_opinion = {
							modifier = grateful_opinion
							target = root
							opinion = 15
						}
						add_trait_xp = {
							trait = lifestyle_hunter
							track = falconer
							value = 2
						}
					}
				}
			}
		}
	}
}

pet_animal.3070 = { # Your eagle helps you with a romance scheme
	type = character_event
	title = pet_animal.3070.t
	desc = pet_animal.3070.desc
	theme = romance_scheme

	override_background = { 
		reference = garden # Do steppe people have a garden? please advise
	}

	cooldown = { years = 20 }

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:target
		animation = laugh
	}

	weight_multiplier = {
        base = 1
		modifier = {
			add = 1
			scope:target = { has_personality_annoying_trigger = yes }
		}
		modifier = { # You gotta be kinda dumb to think this is cute/funny
			add = 1
			scope:target = { probably_unintelligent_trigger = yes }
		}
	}

	trigger = {
		has_available_eagle_trigger = yes
		any_scheme = {
			scheme_type = courting
		}
	}
	
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:scheme }
			}
			random_scheme = {
				limit = { scheme_type = courting }
				save_scope_as = scheme
			}
		}
		scope:scheme = {
			add_scheme_modifier = { type = eagle_funny_sing_modifier }
			scheme_target_character = { save_scope_as = target }
		}
		scope:target = {
			add_stress = minor_stress_loss
		}
		if = {
			limit = {
				has_eagle_personality_trait_trigger = yes
			}
			remove_eagle_personality_trait_effect = yes
		}
		random_list = {
			50 = { set_eagle_personality_trait_effect = { ADD_MODIFIER = no TRAIT = cunning } }
			50 = { set_eagle_personality_trait_effect = { ADD_MODIFIER = no TRAIT = curious } }
		}
	}

	option = {
		name = pet_animal.3070.a
		add_eagle_personality_modifier_effect = yes
	}
}
pet_animal.3080 = { # Your eagle brings you a little gift
	type = character_event
	title = pet_animal.3080.t
	desc = pet_animal.3080.desc
	theme = pet

	#override_background = { reference = ep2_travel_steppe } #TODO_MPO

	cooldown = { years = 15 }

	left_portrait = {
		character = root
		animation = hunting_falcon #TODO_MPO - Change to eagle
	}

	weight_multiplier = {
        base = 1
		modifier = {
			add = 1
			has_any_artifact = no
		}
	}

	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	trigger = {
		NOT = {
			any_artifact = { # Don't want to give this event to someone who's already stacked on artifacts
				artifact_owner = root
				count >= 3
			}
		}
	}

	immediate = {
		create_artifact_animal_hide_effect = {
			OWNER = root
			HUNTER = root
			LEGENDARY = no
			ANIMAL = flag:hare
		}
		if = {
			limit = {
				has_eagle_personality_trait_trigger = yes
			}
			remove_eagle_personality_trait_effect = yes
		}
		random_list = {
			50 = { set_eagle_personality_trait_effect = { ADD_MODIFIER = no TRAIT = brave } }
			50 = { set_eagle_personality_trait_effect = { ADD_MODIFIER = no TRAIT = loyal } }
		}
	}

	option = {
		name = pet_animal.3080.a
		scope:newly_created_artifact = { set_owner = root }
		add_eagle_personality_modifier_effect = yes
	}
}

#Eagle 'dies'
pet_animal.3199 = {
	type = character_event
	title = pet_animal.3199.t
	desc = {
		desc = pet_animal.3199.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = eagle_marked_for_death
				}
				desc = pet_animal.3199.desc_dying
			}
			desc = pet_animal.3199.desc
		}
		desc = pet_animal.3199.desc_outro
	}
	theme = pet

	left_portrait = {
		character = root
		animation = sadness
	}

	trigger = {
		OR = {
			has_character_flag = eagle_is_dying # Via story cycle
			AND = { 
				has_character_flag = eagle_marked_for_death # Via event 
				OR = { # Just in case eagle feels better
					has_character_modifier = weak_eagle_modifier
					has_character_modifier = very_weak_eagle_modifier
				}
			}
		}
	}

	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	immediate = {
		play_music_cue = "mx_cue_prison"
		create_artifact_bird_feather_effect = {
			OWNER = root
			HUNTER = root
			ANIMAL = flag:eagle
		}
	}

	option = {
		name = pet_animal.3199.a
		if = {
			limit = { exists = scope:newly_created_artifact }
			hidden_effect = { destroy_artifact = scope:newly_created_artifact }
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = {
		name = pet_animal.0199.b
		remove_short_term_gold = { 10 20 }
		scope:newly_created_artifact = { set_owner = root }
		ai_chance = {
			base = 10
		}
	}

	after = {
		show_as_tooltip = {
			remove_eagle_story_modifiers_effect = yes
		}
		scope:story = {
			hidden_effect = { end_story = yes }
		}
	}
}