﻿
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.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.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.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.1199 - Dog dies
#
# 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
#
###########################################


###########################################
# 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 = pets_expanded
	left_portrait = {
		character = root
		animation = personality_cynical
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }

		# This is to avoid more than one naming event showing at once and messing up flags etc
		NOT = { exists = var:is_naming_pet }
	}

	immediate = {
		set_variable = {
			name = is_naming_pet
			value = scope:story
		}
		pets_expanded_setup_event_effect = yes
		#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"
	}

	widget = {
		gui = "event_window_widget_enter_pet_name"
		container = "dynamic_birth_name"
		controller = name_character
		setup_scope = { scope:story.var:pet_dummy = { save_scope_as = name_character_target } }
	}

	option = { 
		name = pet_animal.0001.a
	}

	after = {
		hidden_effect = {
			#We save this to avoid errors in court_yearly.5021
			if = {
				limit = {
					exists = var:pet_chosen_name
					var:pet_chosen_name = flag:name_mittens
				}
				set_variable = {
					name = story_cycle_cat_name
					value = flag:cat_name_mittens
				}
			}
			remove_variable = pet_chosen_name
			remove_variable = pet_name_1
			remove_variable = pet_name_2
			remove_variable = pet_name_3

			remove_variable = is_naming_pet
			scope:story = { remove_variable = pet_has_not_been_named }
			scope:story = { pets_expanded_cleanup_after_event_effect = yes }
		}		
	}
}

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


#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 = pets_expanded
	left_portrait = {
		character = root
		animation = personality_content
	}
	
	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		NOT = { has_character_flag = had_pet_animal_0104_event }
		stress > normal_baseline_stress
	}

	weight_multiplier = {
		base = 0.75
		modifier = { #More likely if the pet likes you!
			add = 0.25
			scope:story.var:opinion_of_owner >= good_pet_opinion
		}
		modifier = { #More likely if the cat is friendly!
			add = 0.5
			scope:story.var:personality = flag:friendly
		}
		modifier = { #Less likely if the cat is aggressive!
			add = -0.2
			scope:story.var:personality = flag:aggressive
		}
		modifier = { #A little less likely if the cat is skittish!
			add = -0.5
			scope:story.var:personality = flag:skittish
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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
		pet_opinion_change_effect = { STORY = scope:story CHANGE = increase_minor }
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}


#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 = pets_expanded
	left_portrait = scope:person

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		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 }
				}
			}
		}
		scope:story = { pet_is_free_roaming_trigger = yes }
	}

	weight_multiplier = {
		base = 0.75
		modifier = { #More likely if the pet likes you!
			add = 0.25
			scope:story.var:opinion_of_owner >= good_pet_opinion
		}
		modifier = { #More likely if the cat is curious!
			add = 0.4
			scope:story.var:personality = flag:curious
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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

		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:person
				multiplier = 1.5
			}
			ai_value_modifier = {
				ai_compassion = 2
				ai_honor = 0.5
				ai_vengefulness = -0.75
			}
		}
	}

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

		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:person
				multiplier = -1
			}
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 0.5
				ai_compassion = -1
				ai_honor = -0.5
			}
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	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 = {
		scope:story = { story_type = PE_story_cycle_cat }
	}

	# Trigger removed as it is handled by pet_animal.6055
	immediate = {
		pets_expanded_setup_event_effect = yes
		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 = PE_story_cycle_cat
							}
					}
					NOT = { this = scope:spouse }
				}
			}
			every_relation = {
				type = friend
				limit = {
					NOT = {
						any_owned_story = {
								story_type = PE_story_cycle_cat
							}
					}
					NOT = { this = scope:spouse }
				}
				add_to_list = can_get_cat
			}
		}
		if = {
			limit = {
				any_relation = {
					type = lover
					NOT = {
						any_owned_story = {
								story_type = PE_story_cycle_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
			}
			every_relation = {
				type = lover
				limit = {
					NOT = {
						any_owned_story = {
								story_type = PE_story_cycle_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 = PE_story_cycle_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 = PE_story_cycle_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 = PE_story_cycle_cat
							}
					}
					NOT = { is_in_list = can_get_cat }
					NOT = { this = scope:spouse }
				}
			}
			every_consort = {
				limit = {
					NOT = {
						any_owned_story = {
								story_type = PE_story_cycle_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
		}
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
		transfer_cat_story_cycle_to_effect = { CHARACTER = scope:receiver_1 STORY = scope:story }
		scope:receiver_1 = {
			trigger_event = pet_animal.0107
		}

		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:receiver_1
				multiplier = 1.5
			}
		}
	}

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

		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:receiver_2
				multiplier = 1.5
			}
		}
	}

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

		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:receiver_3
				multiplier = 1.5
			}
		}
	}

	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
			}
		}
		pet_opinion_change_effect = { STORY = scope:story CHANGE = increase_major }

		scope:story = { pets_expanded_cleanup_after_event_effect = yes }

		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:spouse
				multiplier = -1.5
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_honor = -0.25
				ai_compassion = -1
			}
		}
	}

	option = { #I'll... I'll get rid of it...
		name = pet_animal.0106.e
		trigger = {
			NOT = { exists = scope:receiver_1 }
		}
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = cat
		}

		ai_chance = {
			base = 10
		}
	}
}


#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 = pets_expanded
	left_portrait = {
		character = scope:giver
		animation = sadness
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		save_scope_as = receiver
	}

	option = { #Nice!
		name = pet_animal.0107.a
		show_as_tooltip = { start_pet_story_cycle_effect = { PET_TYPE = cat } }
		scope:story = { pets_expanded_cleanup_after_event_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
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = cat
		}

		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.15
				ai_compassion = -0.5
			}
			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 = pets_expanded
	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 = PE_story_cycle_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 = pets_expanded
	left_portrait = {
		character = root
		animation = happiness
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		NOT = { has_character_flag = had_pet_animal_0109_event }
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if the pet likes you!
			add = 0.25
			scope:story.var:opinion_of_owner >= good_pet_opinion
		}
		modifier = { #More likely if the cat is adventurous!
			add = 0.75
			scope:story.var:personality = flag:adventurous
		}
		modifier = { #More likely if the cat is aggressive!
			add = 0.75
			scope:story.var:personality = flag:aggressive
		}
		modifier = { #Less likely if the cat is lazy!
			add = -0.35
			scope:story.var:personality = flag:lazy
		}
	}

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

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

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}


#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 = {
					OR = {
						has_character_flag = had_event_court_5020
						scope:story = { pet_is_free_roaming_trigger = no }
					}
				}
				desc = pet_animal.0197.desc_court_5020
			}
			desc = pet_animal.0197.desc
		}
	}
	theme = pets_expanded
	left_portrait = {
		character = root
		animation = sadness
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		play_music_cue = "mx_cue_prison"
	}

	option = {
		name = pet_animal.0197.a
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = cat
		}
	}
	
	after = {
		if = {
			limit = { has_character_flag = cat_is_dying }
			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 = pets_expanded
#	left_portrait = {
#		character = root
#		animation = sadness
#	}
#	artifact = {
#		position = lower_right_portrait
#		target = scope:newly_created_artifact
#	}
#
#	trigger = {
#		scope:story = { story_type = PE_story_cycle_cat }
#	}
#
#	immediate = {
#		play_music_cue = "mx_cue_prison"
#
#		pets_expanded_setup_event_effect = yes
#		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 = {
#		end_pet_story_cycle_effect = {
#			STORY = scope:story
#			PET_TYPE = cat
#		}
#		if = {
#			limit = { has_character_flag = cat_is_dying }
#			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 = pets_expanded
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = laugh
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		is_available_healthy_adult = yes
	}

	cooldown = { years = 15 }

	immediate = {
		pets_expanded_setup_event_effect = yes
	}

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

		pet_opinion_change_effect = { STORY = scope:story CHANGE = decrease_minor }

		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = shock
	}
	cooldown = { years = 15 }

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		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
			}
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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
				}
			}
		}

		pet_opinion_change_effect = { STORY = scope:story CHANGE = decrease_minor }

		stress_impact = {
			craven = miniscule_stress_impact_gain
			brave = miniscule_stress_impact_loss
		}

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

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = worry
		outfit_tags = { no_clothes }
	}
	right_portrait = {
		character = scope:cat_lover
		animation = anger
		outfit_tags = { no_clothes }
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		NOT = {
			has_trait = celibate
		}
		any_relation = {
			type = lover
			is_available_healthy_ai_adult = yes
			location = root.location
		}
	}

	cooldown = { years = 15 }

	immediate = {
		pets_expanded_setup_event_effect = yes
		random_relation = {
			type = lover
			limit = {
				is_available_healthy_ai_adult = yes
				location = root.location
			}
			save_scope_as = cat_lover
		}
	}

	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
					}
				}
			}
		}

		pet_opinion_change_effect = { STORY = scope:story CHANGE = decrease_minor }

		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 = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:random_courtier
		animation = ecstasy
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		is_available_healthy_adult = yes
		any_courtier_or_guest = {
			is_available_healthy_ai_adult = yes
			location = root.location
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if the cat is friendly!
			add = 0.75
			scope:story.var:personality = flag:friendly
		}
		modifier = { #Less likely if the cat is aggressive!
			add = -0.3
			scope:story.var:personality = flag:aggressive
		}
		modifier = { #A little less likely if the cat is skittish!
			add = -0.2
			scope:story.var:personality = flag:skittish
		}
	}

	cooldown = { years = 15 }

	immediate = {
		pets_expanded_setup_event_effect = yes
		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
			}
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = sick
		outfit_tags = { nightgown }
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		is_available_adult = yes
		is_healthy = no
	}

	cooldown = { years = 15 }

	immediate = {
		pets_expanded_setup_event_effect = yes
	}

	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
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

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

	trigger = {
		scope:story = { story_type = PE_story_cycle_cat }
		is_available_adult = yes
		any_councillor = {
			is_available_adult = yes
			location = root.location
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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

		pet_opinion_change_effect = { STORY = scope:story CHANGE = increase_medium }

		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
		}

		pet_opinion_change_effect = { STORY = scope:story CHANGE = decrease_minor }

		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
		}

		pet_opinion_change_effect = { STORY = scope:story CHANGE = increase_minor }

		stress_impact = {
			base = miniscule_stress_impact_loss
		}

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

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}




##############
##############
## 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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = personality_cynical
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_dog }

		# This is to avoid more than one naming event showing at once and messing up flags etc
		NOT = { exists = var:is_naming_pet }
	}

	immediate = {
		set_variable = {
			name = is_naming_pet
			value = scope:story
		}
		pets_expanded_setup_event_effect = yes
		#To give some options to show
		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"
	}

	widget = {
		gui = "event_window_widget_enter_pet_name"
		container = "dynamic_birth_name"
		controller = name_character
		setup_scope = { scope:story.var:pet_dummy = { save_scope_as = name_character_target } }
	}

	option = { 
		name = pet_animal.0001.a
	}

	after = {
		remove_variable = pet_name_1
		remove_variable = pet_name_2
		remove_variable = pet_name_3

		remove_variable = is_naming_pet
		scope:story = { remove_variable = pet_has_not_been_named }
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}



###########################################
# 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 = pets_expanded
	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 = {
		scope:story = { story_type = PE_story_cycle_dog }
		NOT = { has_character_flag = had_pet_animal_1101_event }
	}

	weight_multiplier = {
		base = 1
		modifier = { #Less likely if the dog is lazy!
			add = -0.75
			scope:story.var:personality = flag:lazy
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = root
		animation = worry
	}
	
	trigger = {
		scope:story = { story_type = PE_story_cycle_dog }
		NOT = { has_character_flag = had_pet_animal_1102_event }
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if the pet dislikes you!
			add = 0.7
			scope:story.var:opinion_of_owner <= bad_pet_opinion
		}
		modifier = { #More likely if the dog is adventurous!
			add = 0.5
			scope:story.var:personality = flag:adventurous
		}
		modifier = { #Less likely if the dog is lazy!
			add = -0.3
			scope:story.var:personality = flag:lazy
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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 = pets_expanded
	override_background = {
		reference = terrain
	}
	left_portrait = root

	trigger = {
		exists = scope:story
	}

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

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	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
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = dog
		}
	}
}

#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 = pets_expanded
	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
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = dog
		}
		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 = pets_expanded
	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
			}
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}


#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 = pets_expanded
	override_background = {
		reference = sitting_room
	}
	left_portrait = scope:agent
	
	trigger = {
		scope:story = { story_type = PE_story_cycle_dog }
		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
			}
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if the pet likes you!
			add = 0.25
			scope:story.var:opinion_of_owner >= good_pet_opinion
		}
		modifier = { #More likely if the dog is adventurous!
			add = 0.5
			scope:story.var:personality = flag:adventurous
		}
		modifier = { #More likely if the dog is aggressive!
			add = 0.5
			scope:story.var:personality = flag:aggressive
		}
		modifier = { #Less likely if the dog is lazy!
			add = -0.3
			scope:story.var:personality = flag:lazy
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
		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
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = 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 = pets_expanded
	override_background = {
		trigger = {
			culture = { has_cultural_pillar = heritage_north_germanic }
			religion = religion:germanic_religion
		}
		reference = fp1_runestone
	}
	left_portrait = scope:other_owner
	
	trigger = {
		scope:story = { story_type = PE_story_cycle_dog }
		OR = {
			any_vassal = {
				is_available_ai = yes
				any_owned_story = {
					story_type = PE_story_cycle_dog
					pet_available_for_ongoing_events_trigger = yes
				}
			}
			any_courtier = {
				is_available_ai = yes
				any_owned_story = {
					story_type = PE_story_cycle_dog
					pet_available_for_ongoing_events_trigger = yes
				}
			}
			any_neighboring_top_liege_realm_owner = {
				is_available_ai = yes
				any_owned_story = {
					story_type = PE_story_cycle_dog
					pet_available_for_ongoing_events_trigger = yes
				}
			}
			AND = {
				exists = liege
				liege = {
					is_available_ai = yes
					NOT = { this = root }
					any_owned_story = {
						story_type = PE_story_cycle_dog
						pet_available_for_ongoing_events_trigger = yes
					}
				}
			}
		}
	}

	cooldown = { years = 10 }

	immediate = {
		pets_expanded_setup_event_effect = yes
		
		hidden_effect = {
			random_list = {
				10 = {
					trigger = {
						any_vassal = {
							is_available_ai = yes
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
					}
					random_vassal = {
						limit = {
							is_available_ai = yes
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
							save_scope_as = other_story
							set_variable = {
								name = busy_in_events
								years = 5
							}
						}
					}
				}
				10 = {
					trigger = {
						any_courtier = {
							is_available_ai = yes
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
					}
					random_courtier = {
						limit = {
							is_available_ai = yes
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
							save_scope_as = other_story
							set_variable = {
								name = busy_in_events
								years = 5
							}
						}
					}
				}
				10 = {
					trigger = {
						any_neighboring_top_liege_realm_owner = {
							is_available_ai = yes
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
					}
					random_neighboring_top_liege_realm_owner = {
						limit = {
							is_available_ai = yes
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
							save_scope_as = other_story
							set_variable = {
								name = busy_in_events
								years = 5
							}
						}
					}
				}
				10 = {
					trigger = {
						exists = liege
						liege = {
							is_available_ai = yes
							NOT = { this = root }
							any_owned_story = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
						}
					}
					liege = {
						save_scope_as = other_owner
						random_owned_story = {
							limit = {
								story_type = PE_story_cycle_dog
								pet_available_for_ongoing_events_trigger = yes
							}
							save_scope_as = other_story
							set_variable = {
								name = busy_in_events
								years = 5
							}
						}
					}
				}
			}
		}
	}

	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:pet_dummy = { is_female = yes }
									pet_can_breed_trigger = yes
								}
								scope:other_story = {
									var:pet_dummy = { is_female = no }
									pet_can_breed_trigger = yes
								}
							}
							AND = {
								scope:story = {
									var:pet_dummy = { is_female = no }
									pet_can_breed_trigger = yes
								}
								scope:other_story = {
									var:pet_dummy = { is_female = yes }
									pet_can_breed_trigger = yes
								}
							}
						}
					}
					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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = scope:other_owner

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

	immediate = {
		if = { #We only care if it was your dog
			limit = {
				scope:story.var:pet_dummy = { is_female = yes }
			}
			scope:story.var:pet_dummy = {
				change_age = 5
				save_scope_as = mother_scope
			}
			scope:other_story.var:pet_dummy = {
				change_age = 5
				save_scope_as = father_scope
			}
			custom_tooltip = dog_got_pregnant_tooltip
			save_scope_value_as = {
				name = your_dog
				value = yes
			}
		}
		else = {
			scope:story = {
				var:pet_dummy = { change_age = 5 }
				save_scope_as = mother_scope
			}
			scope:other_story = {
				var:pet_dummy = { change_age = 5 }
				save_scope_as = father_scope
			}
		}
	}

	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
				}
				trigger_event = {
					id = pet_animal.1190
					days = { 60 70 }
				}
			}
		}
		else = {
			trigger_event = {
				id = pet_animal.1190
				days = { 60 70 }
			}
		}
	}
}

#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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = scope:other_owner
		animation = happiness
	}

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

		scope:story = { pet_available_for_ongoing_events_trigger = yes }
		scope:other_story = { pet_available_for_ongoing_events_trigger = yes }
	}

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

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
		scope:other_story = {
			remove_variable = busy_in_events
		}
	}
}

#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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = scope:other_owner
		animation = anger
	}

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

		scope:story = { pet_available_for_ongoing_events_trigger = yes }
		scope:other_story = { pet_available_for_ongoing_events_trigger = 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
					}
					end_pet_story_cycle_effect = {
						STORY = scope:other_story
						PET_TYPE = dog
					}
				}
			}
		}
		else = {
			scope:other_owner = {
				add_opinion = {
					target = root
					modifier = hate_opinion
					opinion = -10
				}
			}
			scope:other_story = {
				remove_variable = busy_in_events
			}
		}
	}

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

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}


#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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = root
	
	trigger = {
		scope:story = { story_type = PE_story_cycle_dog }
	}

	cooldown = { years = 10 }

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if the pet likes you!
			add = 0.5
			scope:story.var:opinion_of_owner >= good_pet_opinion
		}
		modifier = { #Less likely if the pet dislikes you!
			add = -0.4
			scope:story.var:opinion_of_owner <= bad_pet_opinion
		}
		modifier = { #More likely if the dog is friendly!
			add = 0.5
			scope:story.var:personality = flag:friendly
		}
		modifier = { #More likely if the dog is spoiled!
			add = 0.5
			scope:story.var:personality = flag:spoiled
		}
		modifier = { #A little less likely if the dog is skittish!
			add = -0.25
			scope:story.var:personality = flag:skittish
		}
		modifier = { #A little less likely if the dog is aloof!
			add = -0.25
			scope:story.var:personality = flag:aloof
		}
	}

	immediate = {
		pets_expanded_setup_event_effect = yes
	}

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

		every_councillor = {
			custom = every_councillor
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -5
			}
		}
		
		random_list = {
			50 = { #They make you seem cool!
				desc = pet_animal.1113.a_success
				show_chance = no
				modifier = { #More likely if the dog is aggressive!
					add = 25
					scope:story.var:personality = flag:aggressive
				}
				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 }
				}
			}
		}
		pet_opinion_change_effect = { STORY = scope:story CHANGE = increase_medium }
	}

	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
				modifier = { #More likely if the dog is friendly!
					add = 25
					scope:story.var:personality = flag:friendly
				}
				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
				modifier = { #More likely if the dog is aggressive!
					add = 25
					scope:story.var:personality = flag:aggressive
				}
				custom_tooltip = pet_animal.1113.a_failure.tt
				trigger_event = {
					id = pet_animal.1117
					days = { 7 10 }
				}
			}
		}

		pet_opinion_change_effect = { STORY = scope:story CHANGE = decrease_medium }
	}
}

#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 = pets_expanded
	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:pet_dummy = { is_female = yes } }
			text = pet_animal.1014.a_girl
		}
		name = {
			trigger = { scope:story.var:pet_dummy = { is_female = no } }
			text = pet_animal.1014.a_boy
		}
		add_prestige = minor_prestige_gain
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}


#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 = pets_expanded
	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
		
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	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
			}
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}

#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 = pets_expanded
	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
			}
		}
	}

	after = {
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
	}
}



#Puppies!
scripted_trigger pet_animal_1190_pet_target_trigger = {
	is_available_ai = yes
	has_dog_trigger = no
	NOT = { is_in_list = can_get_dog }
}

#by Linnéa Thimrén
pet_animal.1190 = {
	type = character_event
	title = pet_animal.1190.t
	desc = pet_animal.1190.desc
	theme = pets_expanded
	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

		if = {
			limit = {
				NOT = { exists = var:save_newly_created_pet_scope }
			}
			start_story_cycle_from_birth_effect = {
				PET_TYPE = dog
				MOTHER_SCOPE = scope:mother_scope
				FATHER_SCOPE = scope:father_scope
			}
			var:save_newly_created_pet_scope = { save_scope_as = story }
		}
		
		#Who can get a puppy?
		if = {
			limit = {
				any_relation = {
					type = friend
					pet_animal_1190_pet_target_trigger = yes
				}
			}
			every_relation = {
				type = friend
				limit = {
					pet_animal_1190_pet_target_trigger = yes
				}
				add_to_list = can_get_dog
			}
		}
		if = {
			limit = {
				any_relation = {
					type = lover
					pet_animal_1190_pet_target_trigger = yes
				}
			}
			every_relation = {
				type = lover
				limit = {
					pet_animal_1190_pet_target_trigger = yes
				}
				add_to_list = can_get_dog
			}
		}
		if = {
			limit = {
				any_vassal = {
					NOT = { has_relation_rival = root }
					pet_animal_1190_pet_target_trigger = yes
				}
			}
			every_vassal = {
				limit = {
					NOT = { has_relation_rival = root }
					pet_animal_1190_pet_target_trigger = yes
				}
				add_to_list = can_get_dog
			}
		}
		if = {
			limit = {
				any_consort = {
					pet_animal_1190_pet_target_trigger = yes
				}
			}
			every_consort = {
				limit = {
					pet_animal_1190_pet_target_trigger = yes
				}
				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 = { #Keep it
		name = pet_animal.1190.a

		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
		scope:mother_scope = { pets_expanded_cleanup_after_event_effect = yes }
		scope:father_scope = { pets_expanded_cleanup_after_event_effect = yes }

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 2
				ai_honor = 0.5
				ai_vengefulness = -1
			}
		}
	}

	option = { #I'll give it away to receiver_1
		name = pet_animal.1190.b
		trigger = {
			exists = scope:receiver_1
		}
		transfer_pet_story_cycle_to_effect = {
			CHARACTER = scope:receiver_1
			STORY = scope:story
		}
		scope:receiver_1 = {
			trigger_event = pet_animal.1191
		}

		scope:mother_scope = { pets_expanded_cleanup_after_event_effect = yes }
		scope:father_scope = { pets_expanded_cleanup_after_event_effect = yes }

		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:receiver_1
				multiplier = 1.5
			}
		}
	}

	option = { #I'll give it away to receiver_2
		name = pet_animal.1190.c
		trigger = {
			exists = scope:receiver_2
		}
		transfer_pet_story_cycle_to_effect = {
			CHARACTER = scope:receiver_2
			STORY = scope:story
		}
		scope:receiver_2 = {
			trigger_event = pet_animal.1191
		}
		scope:mother_scope = { pets_expanded_cleanup_after_event_effect = yes }
		scope:father_scope = { pets_expanded_cleanup_after_event_effect = yes }
		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:receiver_2
				multiplier = 1.5
			}
		}
	}

	option = { #I'll give it away to receiver_3
		name = pet_animal.1190.d
		trigger = {
			exists = scope:receiver_3
		}
		transfer_pet_story_cycle_to_effect = {
			CHARACTER = scope:receiver_3
			STORY = scope:story
		}
		scope:receiver_3 = {
			trigger_event = pet_animal.1191
		}
		scope:mother_scope = { pets_expanded_cleanup_after_event_effect = yes }
		scope:father_scope = { pets_expanded_cleanup_after_event_effect = yes }

		ai_chance = {
			base = 10
			opinion_modifier = {
				opinion_target = scope:receiver_3
				multiplier = 1.5
			}
		}
	}

	option = { #No one to give it to :(
		name = pet_animal.1190.e
		trigger = {
			NOT = { exists = scope:receiver_1 }
		}
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = dog
		}
		add_gold = 10

		scope:mother_scope = { pets_expanded_cleanup_after_event_effect = yes }
		scope:father_scope = { pets_expanded_cleanup_after_event_effect = yes }

		ai_chance = {
			base = 10
			
			ai_value_modifier = {
				ai_compassion = -1
				ai_honor = -0.5
				ai_greed = 2
			}
		}
	}
}

#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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = scope:giver

	immediate = {
		save_scope_as = receiver

		set_variable = {
			name = dog_story_to_check_up_on
			value = scope:story
		}
	}

	option = { #Nice!
		name = pet_animal.1191.a
		show_as_tooltip = {
			start_pet_story_cycle_effect = { PET_TYPE = dog }
		}
		scope:story = { pets_expanded_cleanup_after_event_effect = yes }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}

	option = { #I don't want it...
		name = pet_animal.1191.b
		add_gold = 10
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = dog
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = 0.15
				ai_compassion = -1
			}
			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 = pets_expanded
	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 = {
				exists = scope:receiver.var:dog_story_to_check_up_on
				scope:receiver = {
					any_owned_story = { this = scope:receiver.var:dog_story_to_check_up_on }
				}
			}
			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 = pets_expanded
	override_background = { reference = ep2_dog_kennels }
	left_portrait = {
		character = root
		animation = sadness
	}
	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	trigger = {
		scope:story = { story_type = PE_story_cycle_dog }
	}

	immediate = {
		play_music_cue = "mx_cue_prison"

		pets_expanded_setup_event_effect = yes
		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 = {
		end_pet_story_cycle_effect = {
			STORY = scope:story
			PET_TYPE = dog
		}
		if = {
			limit = { has_character_flag = dog_is_dying }
			remove_character_flag = dog_is_dying
		}
	}
}



#########################
#########################
## 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 = pets_expanded
	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
		}
		any_relation = {
			type = rival
			is_ai = yes
			any_owned_story = {
				story_type = PE_story_cycle_cat
				pet_available_for_ongoing_events_trigger = yes
			}
		}
	}

	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 = PE_story_cycle_cat
					pet_available_for_ongoing_events_trigger = yes
				}
			}
			save_scope_as = rival

			random_owned_story = {
				limit = {
					story_type = PE_story_cycle_cat
					pet_available_for_ongoing_events_trigger = yes
				}
				save_scope_as = rival_cat_story
				set_variable = {
					name = busy_in_events
					years = 5
				}
				var:pet_dummy = { save_scope_as = rivals_cat_pet_dummy }
			}

			capital_province = {
				save_scope_as = rival_home
			}
		}
	}

	option = { #Kill it
		name = pet_animal.5001.a
		flavor = pet_animal.5001.a.tt
		end_pet_story_cycle_effect = {
			STORY = scope:rival_cat_story
			PET_TYPE = cat
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			sadistic = medium_stress_impact_loss
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 2
				ai_compassion = -2
			}
		}
	}

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

		scope:rival_cat_story = { pets_expanded_cleanup_after_event_effect = yes }

		ai_chance = {
			base = 10
		}
	}
}

#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 = pets_expanded
	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
		}
		any_relation = {
			type = rival
			is_ai = yes
			any_owned_story = {
				story_type = PE_story_cycle_dog
				pet_available_for_ongoing_events_trigger = yes
			}
		}
	}

	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 = PE_story_cycle_dog
					pet_available_for_ongoing_events_trigger = yes
				}
			}
			save_scope_as = rival

			random_owned_story = {
				limit = {
					story_type = PE_story_cycle_dog
					pet_available_for_ongoing_events_trigger = yes
				}
				save_scope_as = rival_dog_story
				set_variable = {
					name = busy_in_events
					years = 5
				}
				var:pet_dummy = { save_scope_as = rivals_dog_pet_dummy }
			}

			capital_province = {
				save_scope_as = rival_home
			}
		}
	}

	option = { #Kill it
		name = pet_animal.5002.a
		flavor = pet_animal.5001.a.tt
		end_pet_story_cycle_effect = {
			STORY = scope:rival_dog_story
			PET_TYPE = dog
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			sadistic = medium_stress_impact_loss
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 2
				ai_compassion = -2
			}
		}
	}

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

		scope:rival_dog_story = { pets_expanded_cleanup_after_event_effect = yes }
		
		ai_chance = {
			base = 10
		}
	}
}


#########################
#########################
## 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 = pets_expanded
#	override_background = { reference = ep2_dog_kennels }
#	left_portrait = {
#		character = root
#		animation = happiness
#	}
#
#	trigger = { scope:story = { story_type = PE_story_cycle_dog } }
#
#	immediate = {
#		pets_expanded_setup_event_effect = yes
#	}
#
#	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 = pets_expanded
#	override_background = { reference = ep2_dog_kennels }
#	left_portrait = {
#		character = root
#		animation = happiness
#	}
#
#	trigger = { scope:story = { story_type = PE_story_cycle_dog } }
#
#	immediate = {
#		pets_expanded_setup_event_effect = yes
#	}
#
#	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 = pets_expanded
#	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
#		scope:story = { story_type = PE_story_cycle_dog }
#	}
#
#	immediate = {
#		pets_expanded_setup_event_effect = yes
#		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 = pets_expanded
#	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
#		scope:story = { story_type = PE_story_cycle_dog }
#	}
#
#	immediate = {
#		pets_expanded_setup_event_effect = yes
#		add_character_flag = {
#			flag = had_pet_animal_6004_event
#			years = 10
#		}
#		random_owned_story = {
#			limit = {
#				story_type = PE_story_cycle_dog
#			}
#			save_scope_as = story
#		}
#		increase_wounds_effect = { REASON = dog_attack }
#	}
#
#	option = {
#		name = pet_animal.6004.a
#	}
#
#	option = {
#		name = pet_animal.6004.b
#		end_pet_story_cycle_effect = {
#			STORY = scope:story
#			PET_TYPE = dog
#		}
#	}
#}
#
#
##########################
##########################
### 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 = pets_expanded
#	override_background = {
#		reference = sitting_room
#	}
#	left_portrait = {
#		character = root
#		animation = happiness
#	}
#
#	trigger = { scope:story = { story_type = PE_story_cycle_cat } }
#
#	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 = {
#		pets_expanded_setup_event_effect = yes
#		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 = pets_expanded
#	left_portrait = {
#		character = root
#		animation = happiness
#	}
#
#	trigger = { scope:story = { story_type = PE_story_cycle_cat } }
	#
#	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 = {
#		pets_expanded_setup_event_effect = yes
#		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 = {
			40 = { trigger_event = pet_animal.0106 } # Allow spouse to be allergic
			60 = { # 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 }
		}
	}
}