﻿namespace = destiny_child

##################################################
# The Child of Destiny
# by Nick Meredith
##################################################

#Lead-in event
destiny_child.0001 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.0001.t
	desc = destiny_child.0001.desc
	theme = family
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:destiny_child
		animation = personality_honorable
	}
	cooldown = { years = 100 } #Ensure we don't have too many children of destiny!
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		#You are either a parent or guardian of a wondrous child
		OR = {
			any_warden_hostage = {
				age < 14
				age > 9
				NOR = { #Allowed to be physically weak, but not an idiot
					has_trait = intellect_bad
					has_trait = dull
				}
			}
			any_child = {
				age < 14
				age > 9
				NOR = { #Allowed to be physically weak, but not an idiot
					has_trait = intellect_bad
					has_trait = dull
				}
				save_temporary_scope_as = child_destiny
			}
		}
	}

	immediate = {
		if = {
			limit = {
				any_warden_hostage = {
					age < 14
					age > 9
					NOR = {
						has_trait = intellect_bad
						has_trait = dull
					}
				}
			}
			random_warden_hostage = {
				limit = {
					age < 14
					age > 9
					NOR = {
						has_trait = intellect_bad
						has_trait = dull
					}
				}
				save_scope_as = destiny_child
			}
		}
		else = {
			random_child = {
				limit = {
					age < 14
					age > 9
					NOR = {
						has_trait = intellect_bad
						has_trait = dull
					}
				}
				save_scope_as = destiny_child
			}
		}
	}

	#Yes, I think they are!
	option = {
		name = destiny_child.0001.a

		flavor = destiny_child.0001.a.tt

		scope:destiny_child = {
			add_character_modifier = {
				modifier = bp2_destined_modifier
			}
			set_variable = {
				name = destiny_child
				value = scope:destiny_child
			}
		}

		create_story = {
			type = story_destiny_child
			save_scope_as = story
		}

		random_owned_story = {
			type = story_destiny_child
			set_variable = {
				name = destiny_child
				value = scope:destiny_child
			}
		}

		stress_impact = {
			paranoid = minor_stress_impact_gain
			content = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			patient = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			humble = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_sociability = 0.5
			}
		}
	}

	#What nonsense.
	option = {
		name = destiny_child.0001.b

		scope:destiny_child = {
			add_character_modifier = {
				modifier = bp2_stifled_potential_modifier
				years = 10
			}
		}

		stress_impact = {
			paranoid = minor_stress_impact_loss
			content = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			impatient = miniscule_stress_impact_loss
			patient = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -1 
				ai_sociability = -0.5
			}
		}
	}
}

#Child is developing physically
destiny_child.1000 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1000.t
	desc = destiny_child.1000.desc
	theme = physical_health
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:destiny_child
		animation = marshal_wooden_sword
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		#Just to make sure it doesn't seem strange
		scope:destiny_child = {
			NOR = {
				has_trait = weak
				has_trait = physique_bad
			}
		}
	}

	#Yes, continue as you're doing!
	option = {
		name = destiny_child.1000.a

		scope:destiny_child = {
			add_trait = strong
			add_prowess_skill = 2
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			strong = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_sociability = 0.5
			}
		}
	}

	#Remember to be sensible
	option = {
		name = destiny_child.1000.b

		scope:destiny_child = {
			add_trait = athletic
			add_martial_skill = 2
		}

		stress_impact = {
			diligent = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			athletic = minor_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1 
				ai_sociability = -0.5
			}
		}
	}
}

#Child is debating religious scholars
destiny_child.1005 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1005.t
	desc = destiny_child.1005.desc
	theme = learning
	override_background = { reference = garden }
	left_portrait = {
		character = root
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:destiny_child
		animation = go_to_your_room
	}
	lower_right_portrait = {
		character = scope:realm_priest
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		OR = {
			cp:councillor_court_chaplain ?= {
				is_available_ai_adult = yes
				location = root.location
			}
			any_court_position_holder = {
				type = camp_priest_camp_officer
				is_available_ai_adult = yes
				location = root.location
			}
		}
	}

	immediate = {

		cp:councillor_court_chaplain ?= {
			save_scope_as = realm_priest
		}
		if = {
			limit = {
				NOT = { exists = scope:realm_priest }
			}
			random_court_position_holder = {
				type = camp_priest_camp_officer
				save_scope_as = realm_priest
			}
		}
	}

	#Really push yourself!
	option = {
		name = destiny_child.1005.a

		if = {
			limit = {
				scope:destiny_child = {
					NOT = {
						has_trait = shrewd
					}
				}
			}
			scope:destiny_child = {
				random = {
					chance = 75
					add_trait = shrewd
				}
			}
		}
		else = {
			scope:destiny_child = {
				random = {
					chance = 75
					add_learning_skill = 4
				}
			}
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			zealous = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
				ai_sociability = 0.5
			}
		}
	}

	#You should be a warrior first!
	option = {
		name = destiny_child.1005.b

		scope:destiny_child = {
			add_learning_skill = -1
			add_martial_skill = { 1 2 }
			add_prowess_skill = { 1 2 }
		}

		reverse_add_opinion = {
	 		target = scope:realm_priest
	 		modifier = disappointed_opinion
	 		opinion = -30
	 	}

		stress_impact = {
			brave = miniscule_stress_impact_loss
			cynical = minor_stress_impact_loss
			wrathful = miniscule_stress_impact_loss
			craven = minor_stress_impact_gain
			zealous = medium_stress_impact_gain
			calm = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = -1 
				ai_sociability = -0.5
			}
		}
	}

	#Keep it up
	option = {
		name = destiny_child.1005.c

		scope:destiny_child = {
			add_learning_skill = 2
			add_stress = minor_stress_loss
		}

		stress_impact = {
			diligent = miniscule_stress_impact_gain
			ambitious = miniscule_stress_impact_gain
			zealous = medium_stress_impact_gain
			lazy = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
			cynical = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_sociability = 1
			}
		}
	}
}

#They offer advice on military strategy
destiny_child.1010 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1010.t
	desc = destiny_child.1010.desc
	theme = martial
	override_background = {
		reference = study
	}
	left_portrait = {
		character = root
		animation = throne_room_one_handed_passive_2
	}
	right_portrait = {
		character = scope:destiny_child
		animation = thinking
	}
	lower_right_portrait = {
		character = scope:marshal
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		OR = {
			root.cp:councillor_marshal ?= {
				location = root.location
				is_available_ai_adult = yes
			}
			any_court_position_holder = {
				type = second_camp_officer
				is_available_ai_adult = yes
			}
		}
	}

	immediate = {
		if = {
			limit = {
				exists = root.cp:councillor_marshal
			}
			cp:councillor_marshal = {
				save_scope_as = marshal
			}
		}
		else = {
			random_court_position_holder = {
				type = second_camp_officer
				save_scope_as = marshal
			}
		}
	}

	#Well done! But there is another way...
	option = {
		name = destiny_child.1010.a

		trigger = {
			OR = {
				martial > 15
				has_trait = education_martial_4
				has_trait = education_martial_5
			}
		}

		flavor = destiny_child.1010.a.tt

		scope:destiny_child = {
			add_martial_skill = { 3 5 }
		}

		stress_impact = {
			base = miniscule_stress_impact_loss
			brave = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			fickle = miniscule_stress_impact_loss
			craven = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			strategist = minor_stress_impact_loss
		}

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

	#My goodness, they're right!
	option = {
		name = destiny_child.1010.b

		trigger = {
			NOR = {
				martial > 15
				has_trait = education_martial_4
			}
		}

		scope:destiny_child = {
			add_martial_skill = { 2 4 }
		}

		stress_impact = {
			brave = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			fickle = miniscule_stress_impact_loss
			craven = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			strategist = minor_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_honor = 1
			}
		}
	}

	#Go over it with me again?
	option = {
		name = destiny_child.1010.c

		scope:destiny_child = {
			add_martial_skill = { 1 2 }
		}

		add_character_modifier = {
			modifier = bp2_destiny_tutor_modifier
			years = 20
		}

		add_martial_lifestyle_xp = minor_lifestyle_experience

		stress_impact = {
			paranoid = minor_stress_impact_loss
			content = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			impatient = miniscule_stress_impact_loss
			patient = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = -1
				ai_sociability = 1
			}
		}
	}
}

#You find the child practicing the blade with a knight
destiny_child.1015 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1015.t
	desc = destiny_child.1015.desc
	theme = martial
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:destiny_child
		animation = sword_coup_degrace
	}
	lower_right_portrait = {
		character = scope:knight
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		any_knight = {
			location = root.location
			is_available_ai_adult = yes
		}
	}

	immediate = {
		random_knight = {
			limit = {
				location = root.location
				is_available_ai_adult = yes	
			}
			save_scope_as = knight
		}
	}

	#Push yourself. You must achieve greatness!
	option = {
		name = destiny_child.1015.a

		scope:destiny_child = {
			duel = {
				 skill = prowess
				 target = scope:knight

				50 = { #They push themselves to new heights
					compare_modifier = {
						 value = scope:duel_value
						 multiplier = 3.5
						 min = -49
					}

					desc = destiny_child.1015.a.success
					send_interface_toast = {
						title = destiny_child.1015.a.success
						left_icon = root
						right_icon = scope:destiny_child  

						scope:destiny_child = {
							add_prowess_skill = { 2 4 }
						}
					}
				}

				40 = { #They exert themselves too hard and injure themselves
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = destiny_child.1015.a.failure
					send_interface_toast = {
						title = destiny_child.1015.a.failure
						left_icon = root
						right_icon = scope:destiny_child  

						scope:destiny_child = {
							increase_wounds_effect = { REASON = accident }
						}
					}
				}

				10 = { #They are woefully short of standards and gain something potentially nasty
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = destiny_child.1015.a.critfailure
					send_interface_toast = {
						title = destiny_child.1015.a.critfailure
						left_icon = root
						right_icon = scope:destiny_child  
						
						scope:destiny_child = {
							random_list = {
								1 = {
									add_trait = scarred
								}
								1 = {
									add_trait = disfigured
								}
								1 = {
									apply_maimed_trait_and_modifier_effect = yes
								}
							}
							progress_towards_rival_effect = {
								REASON = rival_pushed_too_far
								CHARACTER = root
								OPINION = default_rival_opinion
							}
						}
					}
				}
			}
		}

		stress_impact = {
			humble = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_energy = -0.5
			}
		}
	}

	#Here, let me teach you
	option = {
		name = destiny_child.1015.b

		duel = {
			skill = prowess
			value = high_skill_rating

			50 = { #You teach them even better than the knight would
				compare_modifier = {
					 value = scope:duel_value
					 multiplier = 3.5
					 min = -49
				}

				desc = destiny_child.1015.b.success
				send_interface_toast = {
					title = destiny_child.1015.b.success
					left_icon = root
					right_icon = scope:destiny_child  

					add_stress = minor_stress_loss

					scope:destiny_child = {
						add_prowess_skill = { 3 5 }
					}
				}
			}

			50 = { #Your skills already pale next to the chosen one's
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = destiny_child.1015.b.failure
				send_interface_toast = {
					title = destiny_child.1015.b.failure
					left_icon = root
					right_icon = scope:destiny_child  
				
					add_stress = minor_stress_gain

					scope:destiny_child = {
						add_prowess_skill = -1
					}
				}
			}
		}

		stress_impact = {
			humble = minor_stress_impact_gain
			content = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			diligent = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
		}

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

	#Keep at it, you two, and a penny for [knight's] troubles!
	option = {
		name = destiny_child.1015.c

		scope:destiny_child = {
			add_prowess_skill = { 1 2 }
		}

		pay_short_term_gold = {
			target = scope:knight
			gold = 15
		}

		reverse_add_opinion = {
	 		target = scope:knight
	 		modifier = grateful_opinion
	 		opinion = 15
	 	}		

		stress_impact = {
			humble = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			generous = miniscule_stress_impact_loss
			arrogant = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1
				ai_greed = -1
			}
		}
	}
}

#They learn from a midwife or physician
destiny_child.1020 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1020.t
	desc = destiny_child.1020.desc
	theme = physical_health
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:destiny_child
		animation = throne_room_conversation_1
	}
	lower_right_portrait = {
		character = scope:herbalist
	}
	lower_left_portrait = {
		character = scope:physician
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		#You have a court physician
		court_position:court_physician_court_position ?= {
			location = root.location
		}

		#Ensure landed
		is_landed = yes
	}

	immediate = {
		court_position:court_physician_court_position = { save_scope_as = physician }
		if = {
			limit = {
				any_courtier_or_guest = {
					location = root.location
					is_available_ai_adult = yes
					has_trait = lifestyle_herbalist
					scope:physician != this
				}
			}
			random_courtier_or_guest = {
				limit = {
					location = root.location
					is_available_ai_adult = yes
					has_trait = lifestyle_herbalist
					scope:physician != this
				}
				save_scope_as = herbalist
			}
		}
		else = {
			create_character = {
				template = servant_character
				dynasty = none
				location = root.capital_province
				gender_female_chance = 50
				save_scope_as = herbalist
				after_creation = {
					add_character_flag = created
				}
			}
			scope:herbalist = {
				add_trait = lifestyle_herbalist
			}
		}
		
	}

	#Your time with the physician could be time well spent
	option = {
		name = destiny_child.1020.a

		scope:destiny_child = {
			add_trait = lifestyle_physician
			add_learning_skill = 2
		}

		stress_impact = {
			trusting = minor_stress_impact_gain
			paranoid = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	#Herbalism is an interesting area of research!
	option = {
		name = destiny_child.1020.b

		scope:destiny_child = {
			add_trait = lifestyle_herbalist
			add_learning_skill = 2
		}

		stress_impact = {
			trusting = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	#Just... don't let it take too much time away from your studies
	option = {
		name = destiny_child.1020.c

		scope:destiny_child = {
			random = {
				chance = 25
				add_trait = lifestyle_herbalist
			}
			random = {
				chance = 25
				add_trait = lifestyle_physician
			}
			random_list = {
				1 = {
					add_diplomacy_skill = { 1 2 }
				}
				1 = {
					add_martial_skill = { 1 2 }
				}
				1 = {
					add_stewardship_skill = { 1 2 }
				}
				1 = {
					add_intrigue_skill = { 1 2 }
				}
			}
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			lazy = minor_stress_impact_gain
			impatient = miniscule_stress_impact_loss
			patient = minor_stress_impact_gain			
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_honor = 0.5
			}
		}
	}
	after = {
		scope:herbalist = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

#A great knight has heard of your child's ability and wants to meet them
destiny_child.1025 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1025.t
	desc = destiny_child.1025.desc
	theme = martial
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:famous_knight
		animation = jockey_idle
		camera = camera_event_horse_right
	}
	lower_center_portrait = {
		character = scope:destiny_child
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes
	}

	immediate = {
		create_character = {
			template = new_commander_character
			dynasty = none
			culture = root.culture
			faith = root.faith
			location = root.location
			gender_female_chance = root_soldier_female_chance
			save_scope_as = famous_knight
		}
		hidden_effect = {
			scope:famous_knight = {
				add_trait = tourney_participant
				random_list = {
					1 = {
						add_trait_xp = {
							trait = tourney_participant
							track = horse
							value = {
								integer_range = {
									min = 50
									max = 75
								}
							}
						}
					}
					1 = {
						add_trait_xp = {
							trait = tourney_participant
							track = bow
							value = {
								integer_range = {
									min = 50
									max = 75
								}
							}
						}
					}
					1 = {
						add_trait_xp = {
							trait = tourney_participant
							track = foot
							value = {
								integer_range = {
									min = 50
									max = 75
								}
							}
						}
					}
				}
			}
		}
	}

	#STAY AWAY!
	option = {
		name = destiny_child.1025.a

		trigger = {
			has_trait = paranoid
		}

		scope:destiny_child = {
			add_character_modifier = {
				modifier = watchful_modifier
				days = watchful_modifier_duration
			}
		}

		reverse_add_opinion = {
	 		target = scope:destiny_child
	 		modifier = disappointed_opinion
	 		opinion = -15
	 	}

		reverse_add_opinion = {
	 		target = scope:famous_knight
	 		modifier = annoyed_opinion
	 		opinion = -25
	 	}

		stress_impact = {
			base = major_stress_impact_loss #Throw Paranoid a bit of a bone
			content = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			arrogant = miniscule_stress_impact_loss
			ambitious = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1
				ai_sociability = -1
			}
		}
	}

	#Train them? A wonderful idea!
	option = {
		name = destiny_child.1025.b

		scope:destiny_child = {
			add_trait = tourney_participant
		}

		if = {
			limit = {
				scope:famous_knight = {
					has_trait_xp = {
						trait = tourney_participant
						track = horse
						value >= 70
					}
				}
			}
			scope:destiny_child = {
				add_trait_xp = {
					trait = tourney_participant
					track = horse
					value = {
						integer_range = {
							min = 25
							max = 75
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				scope:famous_knight = {
					has_trait_xp = {
						trait = tourney_participant
						track = bow
						value >= 70
					}
				}
			}
			scope:destiny_child = {
				add_trait_xp = {
					trait = tourney_participant
					track = bow
					value = {
						integer_range = {
							min = 25
							max = 75
						}
					}
				}
			}
		}
		else = {
			scope:destiny_child = {
				add_trait_xp = {
					trait = tourney_participant
					track = foot
					value = {
						integer_range = {
							min = 25
							max = 75
						}
					}
				}
			}
		}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
			diligent = miniscule_stress_impact_loss
			lazy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_sociability = 0.5
			}
		}
	}

	#Perhaps the knight can stay?
	option = {
		name = destiny_child.1025.c

		add_courtier = scope:famous_knight

		scope:destiny_child = {
			add_prowess_skill = 1
		}

		stress_impact = {
			generous = miniscule_stress_impact_loss
			greedy = minor_stress_impact_gain
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
				ai_sociability = 1
			}
		}
	}
	after = {
		scope:famous_knight = {
			silent_disappearance_ai_effect = yes
		}
	}
}

#You designate the child as your primary heir
destiny_child.1030 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1030.t
	desc = destiny_child.1030.desc
	theme = family
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:destiny_child
		animation = personality_honorable
	}
	lower_center_portrait = {
		character = scope:current_heir
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Age check
		is_available_adult = yes

		#Ensure you are actually their liege and they aren't your primary heir
		any_heir = {
			has_variable = destiny_child
			NOT = {
				is_primary_heir_of = root
			}
		}

		any_heir = {
			is_primary_heir_of = root
			NOT = {
				has_variable = destiny_child
			}
		}

		#Ensure you can't already just switch 'em
		NOT = {
			has_realm_law = crown_authority_3
		}
	}

	immediate = {
		random_heir = {
			limit = {
				is_primary_heir_of = root
				this != scope:destiny_child
			}
			save_scope_as = current_heir
		}
	}

	#Try to work them into position
	option = {
		name = destiny_child.1030.a

		trigger = {
			OR = {
				intrigue > 15
				has_trait = schemer
			}
		}

		duel = {
			skill = intrigue
			value = decent_skill_rating

			50 = { #You subtly shift them into position
				compare_modifier = {
					 value = scope:duel_value
					 multiplier = 3.5
					 min = -49
				}

				desc = destiny_child.1030.a.success
			
				send_interface_toast = {
					title = designate_heir_interaction_notification
					left_icon = root
					right_icon = scope:destiny_child
					
					set_designated_heir = scope:destiny_child
				}
			}

			50 = { #You fail to do it quietly
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = destiny_child.1030.a.failure
				send_interface_toast = {
					title = designate_heir_interaction_notification
					left_icon = root
					right_icon = scope:destiny_child
					
					set_designated_heir = scope:destiny_child

					add_tyranny = medium_tyranny_gain

					add_prestige = medium_prestige_loss

					every_vassal = {
						vassal_stance = courtly
						custom = every_courtly_vassal
						add_opinion = {
							modifier = angry_opinion
							opinion = -40
							target = root
						}
					}
				}
			}
		}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			content = medium_stress_impact_gain
			deceitful = miniscule_stress_impact_loss
			honest = minor_stress_impact_gain
			patient = minor_stress_impact_loss
			impatient = minor_stress_impact_gain
		}

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

	#Designate them your heir
	option = {
		name = destiny_child.1030.b

		set_designated_heir = scope:destiny_child

		add_tyranny = medium_tyranny_gain

		add_prestige = major_prestige_loss

		every_vassal = {
			limit = {
				NOT = {
					has_vassal_stance = courtly
				}
			}
			custom = all_vassals
			add_opinion = {
				modifier = suspicion_opinion
				opinion = -40
				target = root
			}
		}

		every_vassal = {
			vassal_stance = courtly
			custom = every_courtly_vassal
			add_opinion = {
				modifier = angry_opinion
				opinion = -60
				target = root
			}
		}

		reverse_add_opinion = {
	 		target = scope:destiny_child
	 		modifier = grateful_opinion
	 		opinion = 35
	 	}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			impatient = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_sociability = 0.5
			}
		}
	}

	#Leave it as it is
	option = {
		name = destiny_child.1030.c

		flavor = destiny_child.1030.c.tt

		if = {
			limit = {
				scope:current_heir = {
					is_ai = yes
				}
			}
			scope:current_heir = {
				add_stewardship_skill = { 1 2 }
			}
		}
		scope:destiny_child = {
			add_intrigue_skill = { 2 3 }
		}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
			patient = miniscule_stress_impact_loss
			impatient = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1
				ai_compassion = 0.5
			}
		}
	}
}

#The destiny child is being fawned over by their peers
destiny_child.1035 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.1035.t
	desc = {
		desc = destiny_child.1035.desc
		triggered_desc = {
			trigger = {
				scope:destiny_child = {
					NOR = {
						is_attracted_to_gender_of = scope:flirter_1
						is_attracted_to_gender_of = scope:flirter_2
					}
				}
			}
			desc = destiny_child.1035.notinterested
		}
		triggered_desc = {
			trigger = {
				scope:destiny_child = {
					OR = {
						is_attracted_to_gender_of = scope:flirter_1
						is_attracted_to_gender_of = scope:flirter_2
					}
				}
			}
			desc = destiny_child.1035.interested
		}
	}
	theme = love
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:destiny_child
		animation = flirtation
	}
	lower_center_portrait = {
		character = scope:flirter_1
	}
	lower_right_portrait = {
		character = scope:flirter_2
	}
	cooldown = { years = 10 }
	trigger = {
		has_bp2_dlc_trigger = yes

		#Standard checks check
		is_available_adult = yes
		location = capital_province #To ensure the pool triggers work

		#Make sure destiny child is old enough for this not to be weird
		scope:destiny_child = {
			age > 12
		}

		#Ensure landed
		is_landed = yes
	}

	immediate = {

		create_character = {
			template = servant_character
			age = { 12 15 }
			dynasty = none
			location = root.location
			gender_female_chance = scope:destiny_child.marriage_gender_adjusted_female_chance
			save_scope_as = flirter_1
		}

		create_character = {
			template = servant_character
			age = { 12 15 }
			dynasty = none
			location = root.location
			gender_female_chance = scope:destiny_child.marriage_gender_adjusted_female_chance
			save_scope_as = flirter_2
		}

		hidden_effect = { #Tooltip doesn't like this for some reason
			scope:flirter_1 = {
				set_relation_crush = scope:destiny_child
			}
			scope:flirter_2 = {
				set_relation_crush = scope:destiny_child
			}
		}
	}

	#Destiny child seems taken with the first one!
	option = {
		name = destiny_child.1035.a

		trigger = {
			scope:destiny_child = {
				is_attracted_to_gender_of = scope:flirter_1
			}
		}

		if = {
			limit = {
				scope:destiny_child = {
					AND = {
						number_of_personality_traits < childhood_personality_trait_gain_limit
						NOR = {
							has_trait = lustful
							has_trait = chaste
						}
					}
				}
			}
			random = {
				chance = 50
				scope:destiny_child = {
					add_trait = lustful
				}
			}
		}

		add_courtier = scope:flirter_1

		scope:destiny_child = {
			set_relation_crush = scope:flirter_1
		}

		reverse_add_opinion = {
	 		target = scope:flirter_1
	 		modifier = grateful_opinion
	 		opinion = 35
	 	}

		stress_impact = {
			lustful = miniscule_stress_impact_loss
			chaste = minor_stress_impact_gain
			compassionate = miniscule_stress_impact_loss
			callous =  minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_sociability = 1
			}
		}
	}

	#Destiny child seems taken with the second one!
	option = {
		name = destiny_child.1035.b

		trigger = {
			scope:destiny_child = {
				is_attracted_to_gender_of = scope:flirter_2
			}
		}

		if = {
			limit = {
				scope:destiny_child = {
					AND = {
						number_of_personality_traits < childhood_personality_trait_gain_limit
						NOR = {
							has_trait = lustful
							has_trait = chaste
						}
					}
				}
			}
			random = {
				chance = 50
				scope:destiny_child = {
					add_trait = lustful
				}
			}
		}

		add_courtier = scope:flirter_2

		scope:destiny_child = {
			set_relation_crush = scope:flirter_2
		}

		reverse_add_opinion = {
	 		target = scope:flirter_2
	 		modifier = grateful_opinion
	 		opinion = 35
	 	}

		stress_impact = {
			lustful = miniscule_stress_impact_loss
			chaste = minor_stress_impact_gain
			compassionate = miniscule_stress_impact_loss
			callous =  minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_sociability = 1
			}
		}
	}

	#It's good that you don't let it get to you
	option = {
		name = destiny_child.1035.c

		trigger = {
			scope:destiny_child = {
				NOR = {
					is_attracted_to_gender_of = scope:flirter_1
					is_attracted_to_gender_of = scope:flirter_2
				}
			}
		}

		if = {
			limit = {
				scope:destiny_child = {
					AND = {
						number_of_personality_traits < childhood_personality_trait_gain_limit
						NOR = {
							has_trait = diligent
							has_trait = lazy
						}
					}
				}
			}
			random = {
				chance = 75
				scope:destiny_child = {
					add_trait = diligent
				}
			}
		}

		reverse_add_opinion = {
	 		target = scope:destiny_child
	 		modifier = confusedly_appreciative_opinion
	 		opinion = 20
	 	}

		stress_impact = {
		 	base = miniscule_stress_impact_loss
			lustful = minor_stress_impact_gain
			chaste = miniscule_stress_impact_loss
			callous = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_compassion = 1
			}
		}
	}

	#Kid, you gotta concentrate!
	option = {
		name = destiny_child.1035.d

		flavor = destiny_child.1035.d.tt

		if = {
			limit = {
				scope:destiny_child = {
					AND = {
						number_of_personality_traits < childhood_personality_trait_gain_limit
						NOR = {
							has_trait = lustful
							has_trait = chaste
						}
					}
				}
			}
			random = {
				chance = 50
				scope:destiny_child = {
					add_trait = chaste
				}
			}
		}

		random = {
			chance = 25
			scope:destiny_child = {
				add_diplomacy_skill = 1
			}
		}

		random = {
			chance = 25
			scope:destiny_child = {
				add_stewardship_skill = 1
			}
		}

		random = {
			chance = 25
			scope:destiny_child = {
				add_learning_skill = 1
			}
		}

		reverse_add_opinion = {
	 		target = scope:destiny_child
	 		modifier = disappointed_opinion
	 		opinion = -15
	 	}

		stress_impact = {
			lustful = medium_stress_impact_gain
			chaste = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			callous = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_sociability = -1
			}
		}
	}
	after = {
		scope:flirter_1 = {
			silent_disappearance_ai_effect = yes
		}
		scope:flirter_2 = {
			silent_disappearance_ai_effect = yes
		}
	}
}

#Destiny child becomes an adult
destiny_child.9999 = {
	type = character_event
	content_source = dlc_009
	title = destiny_child.9999.t
	desc = destiny_child.9999.desc
	theme = family
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:destiny_child
		animation = personality_honorable
	}
	override_background = { reference = council_chamber }
	trigger = {
		has_bp2_dlc_trigger = yes
	}

	immediate = {
		if = {
			limit = {
				scope:destiny_child = {
					has_character_modifier = bp2_destined_modifier
				}
			}
			scope:destiny_child = {
				remove_character_modifier = bp2_destined_modifier
			}
		}
		random_owned_story = {
			type = story_destiny_child
			end_story = yes
		}
	}

	#End story cycle
	option = {
		name = destiny_child.9999.a

		scope:destiny_child = {
			add_character_modifier = bp2_tool_of_fate_modifier
		}

		scope:destiny_child = {
			add_diplomacy_skill = { 2 4 }
			add_martial_skill = { 2 4 }
			add_stewardship_skill = { 2 4 }
			add_intrigue_skill = { 2 4 }
			add_learning_skill = { 2 4 }
		}

		scope:destiny_child = { remove_variable = destiny_child }

		stress_impact = {
			base = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}
}
