namespace = bp2_yearly

bp2_yearly.4000 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4000.t
	desc = bp2_yearly.4000.desc

	theme = pregnancy

	override_background = { reference = bedchamber }

	left_portrait = {
		character = root
		animation = newborn
	}

	lower_center_portrait = {
		character = scope:char_father
	}

	lower_right_portrait = {
		character = scope:char_mother
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_playable_character = yes
		is_available_adult = yes
		is_physically_able_adult = yes
		any_memory = {
			memory_type = first_born
		}
		any_memory = {
			count = 2
			memory_type = relative_died
			any_memory_participant = {
				is_parent_of = root
			}
			has_variable = childhood_memory
		}
		any_child = {
			count = 1
		}
	}

	immediate = {
		random_child = {
			save_scope_as = first_babby
		}
		father = {
			save_scope_as = char_father
		}
		mother = {
			save_scope_as = char_mother
		}
	}

	weight_multiplier = {
		base = 1
	}

	option = { # I promise, I will not abandon you, my child
		name = bp2_yearly.4000.a
		trigger = {
			NOR = {
				has_trait = callous
				has_trait = sadistic
				has_trait = cynical
			}
		}
		flavor = bp2_yearly.4000.a.flavor
		add_character_modifier = {
			modifier = parental_conviction
			years = 10
		}
		stress_impact = {
			base = medium_stress_gain
		}

		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_honor = tiny_chance_impact_positive_ai_value
				ai_compassion = tiny_chance_impact_positive_ai_value
			}
		}		
	}

	option = { #the world is harsh and cruel, how sad
		name = bp2_yearly.4000.b
		trigger = {
			NOT = {
				has_trait = compassionate
			}
		}
		flavor = bp2_yearly.4000.b.flavor
		stress_impact = {
			base = medium_stress_loss
			cynical = minor_stress_loss
			callous = minor_stress_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = tiny_chance_impact_negative_ai_value
				ai_compassion = tiny_chance_impact_negative_ai_value
			}
		}	
	}

	option = { #religious option
		name = bp2_yearly.4000.c

		add_piety = medium_piety_gain
		stress_impact = {
			zealous = medium_stress_loss
			patient = minor_stress_loss
			cynical = medium_stress_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = tiny_chance_impact_positive_ai_value
			}
		}
	}
}

bp2_yearly.4001 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4001.t
	desc = bp2_yearly.4001.desc

	theme = prison

	override_background = { reference = dungeon }

	left_portrait = {
		character = root
		animation = thinking
	}

	right_portrait = {
		character = scope:imprisoned_murderer
		animation = prisondungeon
		override_imprisonment_visuals = yes
		triggered_outfit = {
 			remove_default_outfit = no
 			outfit_tags = { beggar_rags }
 		}
	}

	lower_center_portrait = {
		character = scope:murdered_relative
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		any_memory = {
			memory_type = relative_died
			any_memory_participant = {
				exists = this.killer
				killer = {
					is_imprisoned_by = root
				}
			}
			has_variable = childhood_memory
		}
	}

	immediate = {
		random_memory = {
			memory_type = relative_died
			limit = {
				has_variable = childhood_memory
				any_memory_participant = {
					killer = {
						is_imprisoned_by = root
					}
				}
			}
			random_memory_participant = {
				save_scope_as = murdered_relative
			}
		}

		scope:murdered_relative.killer = {
			save_scope_as = imprisoned_murderer
		}
	}

	option = { #haha, kill the prisoner, gain vengeful, gain piety if vengeful is a virtue
		name = bp2_yearly.4001.a
		execute_prisoner_effect = {
			VICTIM = scope:imprisoned_murderer
			EXECUTIONER = root
		}
		if = {
			limit = {
				NOR = {
					has_trait = vengeful
					number_of_personality_traits > 3
				}
			}
			random_list = {
				25 = {
					add_trait = vengeful
				}
				75 = {
					
				}
			}	
		}
		else_if = {
			limit = {
				has_trait = vengeful
			}
			add_character_modifier = {
				modifier = delayed_justive_stress
				years = 10
			}
		}

		if = {
			limit = {
				root.faith = {
					trait_is_virtue = vengeful
				}
			}
			add_character_modifier = {
				modifier = delayed_justice_piety
				years = 10
			}
		}
		

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = medium_chance_impact_positive_ai_value
				ai_compassion = medium_chance_impact_negative_ai_value
			}
		}
	}

	option = { #show mercy, add compassionate, release the prisoner, gain piety if compassionate is a virtue
		name = bp2_yearly.4001.b

		scope:imprisoned_murderer = { release_from_prison = yes }

		if = {
			limit = {
				NOR = {
					has_trait = forgiving
					number_of_personality_traits > 3
				}
			}
			random_list = {
				25 = {
					add_trait = forgiving
				}
				75 = {

				}
			}
		}
		else_if = {
			limit = {
				has_trait = forgiving
			}
			add_character_modifier = {
				modifier = delayed_justive_stress
				years = 10
			}
		}

		if = {
			limit = {
				root.faith = {
					trait_is_virtue = forgiving
				}
			}
			add_character_modifier = {
				modifier = delayed_justice_piety
				years = 10
			}
		}
		

		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_vengefulness = medium_chance_impact_negative_ai_value
				ai_compassion = tiny_chance_impact_positive_ai_value
			}
		}

	}
}

bp2_yearly.4002 = { #drunkard 
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4002.t
	desc = bp2_yearly.4002.desc

	theme = healthcare

	override_background = { reference = bp1_wine_cellar }

	left_portrait = {
		character = root
		animation = drink
	}

	lower_center_portrait = {
		character = scope:first_aa_relative
	}

	lower_right_portrait = {
		character = scope:second_aa_relative
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_adult = yes
		has_trait = drunkard
		any_memory = {
			count >= 2
			memory_type = relative_died
			has_variable = childhood_memory
			any_memory_participant = {
				death_reason = death_drinking_passive
			}
		}
	}

	immediate = {
		random_memory = {
			memory_type = relative_died
			limit = {
				has_variable = childhood_memory
				any_memory_participant = {
					death_reason = death_drinking_passive
				}
			}
			random_memory_participant = {
				save_scope_as = first_aa_relative
			}
		}
		random_memory = {
			memory_type = relative_died
			limit = {
				has_variable = childhood_memory
				any_memory_participant = {
					death_reason = death_drinking_passive
					this != scope:first_aa_relative
					
				}	
			}
			random_memory_participant = {
				save_scope_as = second_aa_relative
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	option = { #aaah, alcoholism bad
		name = bp2_yearly.4002.a

		remove_trait = drunkard
		add_character_modifier = {
			modifier = drinking_stop
			years = 5
		}
		stress_impact = {
			base = major_stress_gain
		}

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

	option = { #drink more
		name = bp2_yearly.4002.b

		stress_impact = {
			base = medium_stress_loss
		}
		add_character_modifier = {
			modifier = drinking_binge
			years = 5
		}

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

bp2_yearly.4003 = { #became a ruler at young age
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4003.t
	desc = bp2_yearly.4003.desc

	theme = realm

	left_portrait = {
		character = root
		animation = thinking
	}

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

	cooldown = { years = 10 }

	trigger = {
		has_bp2_dlc_trigger = yes
		highest_held_title_tier >= tier_duchy
		any_held_title = {
			count > 1
			title_tier = county
			is_landless_type_title = no
		}

		any_memory = {
			memory_type = ascended_throne_memory
			has_variable = childhood_memory
			save_temporary_scope_as = throne_memory_temp
			root = {
				any_child = {
					age >= 10
					age = {
						value = root.age
						subtract = scope:throne_memory_temp.memory_age_years
					}
					root = {
						has_relation_ward = prev
					}
					is_landed = no
					save_temporary_scope_as = child_ruler_temp
				}
			}
			memory_age_years = {
				value = root.age
				subtract = scope:child_ruler_temp.age
			}
		}
	}

	immediate = {
		random_held_title = {
			title_tier = county
			limit = {
				this != root.capital_county
				is_landless_type_title = no
			}
			save_scope_as = giveaway_county
		}
		random_memory = {
			memory_type = ascended_throne_memory
			limit = {
				has_variable = childhood_memory
				save_temporary_scope_as = throne_memory_temp
				root = {
						any_child = {
							age = {
								value = root.age
								subtract = scope:throne_memory_temp.memory_age_years
							}
							root = {
								has_relation_ward = prev
							}
							is_landed = no
							save_temporary_scope_as = child_ruler_temp
						}
				}
				memory_age_years = {
					value = root.age
					subtract = scope:child_ruler_temp.age
				}
			}
			save_scope_as = throne_memory
		}
		random_child = {
			limit = {
				age >= 10
				age = {
					value = root.age
					subtract = scope:throne_memory.memory_age_years
				}
				root = {
					has_relation_ward = prev
				}
				is_landed = no
			}
			save_scope_as = child_ruler
		}
	}

	weight_multiplier = {
		base = 1
	}

	option = { #nah, child will learn more by my side
		name = bp2_yearly.4003.b
		scope:child_ruler = {
			add_opinion = {
				modifier = thankful_opinion
				opinion = 20
				target = root
			}
			stress_impact = {
				base = medium_stress_loss
			}
		}
		random_list = {
			5 = {
				send_interface_toast = {
					title = bp2_yearly.4003.t
					left_icon = scope:child_ruler
					scope:child_ruler = {
						add_stewardship_skill = 2
					}
				}
			}
			5 = {
				send_interface_toast = {
					title = bp2_yearly.4003.t
					left_icon = scope:child_ruler
					scope:child_ruler = {
						add_stewardship_skill = 1
					}
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = tiny_chance_impact_positive_ai_value
			}
		}
	}

	option = { #yes, give away
		name = bp2_yearly.4003.a
		create_title_and_vassal_change = {
			type = granted
			save_scope_as = title_change
			add_claim_on_loss = no
		}
		scope:giveaway_county = {
			change_title_holder = {
				holder = scope:child_ruler
				change = scope:title_change
			}
		}
		resolve_title_and_vassal_change = scope:title_change
		scope:child_ruler = {
			add_opinion = {
				modifier = abandoned_opinion
				opinion = -20
				target = root
			}
			stress_impact = {
				base = minor_stress_gain
			}
		}
		send_interface_toast = {
			title = bp2_yearly.4003.t
			left_icon = scope:child_ruler
			scope:child_ruler = {
				add_stewardship_skill = 4
			}
		}
		stress_impact = {
			compassionate = minor_stress_gain
			callous = minor_stress_loss
		}

		ai_chance = {
			base = 0
		}
	}

	option = { #can't afford to lose my county!
		name = bp2_yearly.4003.c

		add_character_modifier = {
			modifier = focused_on_realm
			years = 4
		}
		
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_greed = tiny_chance_impact_positive_ai_value
				ai_rationality = tiny_chance_impact_positive_ai_value
			}
		}
	}
}

bp2_yearly.4010 = { #child parent is at least Illustrious
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4010.t
	desc = bp2_yearly.4010.desc

	theme = crown

	left_portrait = {
		character = root
		animation = admiration
	}

	right_portrait = {
		character = scope:famous_parent
		animation = personality_honorable
	}

	cooldown = {
		years = 50
	}

	#Fired from on_death for parent, which also saves:
	#scope:famous_parent
	#var:parent_fame_lvl

	trigger = { 
		NOR = { #double safeguard that only one event chain can happen
			has_character_flag = bp2_prestige_piety_chain
			government_has_flag = government_is_mandala
		}
	}

	immediate = {
		add_character_flag = bp2_prestige_piety_chain
	}

	option = { #humble switch to arrogant
		trigger = {
			has_trait = humble
		}
		name = bp2_yearly.4010.a
		remove_trait = humble
		add_trait = arrogant		

		stress_impact = {
			base = major_stress_gain
		}

		add_character_modifier = {
			modifier = famed_parent_lvl_1
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4011
				years = { 2 4 }
			}
		}

		ai_chance = { #don't want too many AI, stressed, arrogant chars, do we
			base = 0
		}
	}

	option = { #yeah, you go papa! I will be like you one day!
		trigger = {
			NOR = {
				has_trait = content
				has_trait = humble
			}
		}
		name = bp2_yearly.4010.b

		add_character_modifier = {
			modifier = famed_parent_lvl_1
		}

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

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4011
				years = { 2 4 }
			}
		}

	}

	option = { #it's fine I guess
		trigger = {
			NOR = {
				has_trait = ambitious
				has_trait = arrogant
			}
		}
		name = bp2_yearly.4010.c
		add_character_modifier = {
			modifier = famed_parent_opt_out_base
			years = 10
		}

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

bp2_yearly.4011 = { #the parent has been dead for a while
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4011.t
	desc = bp2_yearly.4011.desc

	theme = crown

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					has_trait = ambitious
				}
			}
			animation = personality_bold
		}
		triggered_animation = {
			trigger = {
				always = yes
			}
			animation = grief
		}
	}

	lower_right_portrait = {
		character = scope:famous_dead_parent
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_adult = yes
		any_memory = {
			memory_type = famed_parent_became_very_famous
			any_memory_participant = {
				is_alive = no
			}
		}
		has_variable = parent_fame_lvl
		has_character_modifier = famed_parent_lvl_1
	}

	immediate = {
		random_memory = {
			memory_type = famed_parent_became_very_famous
			random_memory_participant = {
				save_scope_as = famous_dead_parent
			}
		}
		remove_character_modifier = famed_parent_lvl_1

	}

	on_trigger_fail = {
		#If the trigger fails because we were not an available adult we queue the event again.
		if = {
			limit = {
				is_available_adult = yes
			}
			trigger_event = {
				id = bp2_yearly.4011
				days = 180
			}
		}
	}

	option = { #how sad, time to get out from the shadow
		trigger = {
			var:parent_fame_lvl > prestige_level
		}
		name = bp2_yearly.4011.a
		add_character_modifier = {
			modifier = famed_parent_lvl_2
		}
		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4012
				years = { 2 3 }
			}
		}

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

		}
	}

	option = { #actually, I am content. opt out from chain
		trigger = {
			var:parent_fame_lvl > prestige_level
			NOR = {
				has_trait = arrogant
				has_trait = ambitious
			}
		}
		name = bp2_yearly.4011.b
		add_character_modifier = {
			modifier = famed_parent_opt_out_base
			years = 10
		}

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

	option = { # I am as good as parent and I am content. opt out from the chain
		trigger = {
			var:parent_fame_lvl <= prestige_level
			NOR = {
				has_trait = ambitious
				has_trait = arrogant
			}
		}
		name = bp2_yearly.4011.c
		add_character_modifier = {
			modifier = famed_parent_opt_out_base
			years = 10
		}
		stress_impact = {
			base = medium_stress_loss
		}

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

	option = { # I am as good as parent but I can be better!
		trigger = {
			var:parent_fame_lvl <= prestige_level
		}
		name = bp2_yearly.4011.d
		stress_impact = {
			base = minor_stress_gain
			ambitious = minor_stress_loss
			arrogant = minor_stress_loss
		}
		add_character_modifier = {
			modifier = famed_parent_lvl_2
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4012
				years = { 1 2 }
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
			}
		}

	}

}

bp2_yearly.4012 = { #prestige vibe check
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4012.t
	desc = bp2_yearly.4012.desc

	theme = crown

	left_portrait = {
		character = root
		animation = personality_bold
	}

	lower_right_portrait = {
		character = scope:dead_famous_parent
	}

	immediate = {
		remove_character_modifier = famed_parent_lvl_2
	}

	option = { #there is still much to do
		trigger = {
			var:parent_fame_lvl > prestige_level
		}
		name = bp2_yearly.4012.a
		
		stress_impact = {
			base = minor_stress_gain
			ambitious = minor_stress_gain
			arrogant = minor_stress_gain
		}

		add_character_modifier = {
			modifier = famed_parent_lvl_3
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4013
				years = { 2 3 }
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
			}
		}
	}

	option = { #ah, why bother
		trigger = {
			var:parent_fame_lvl > prestige_level
			NOR = {
				has_trait = ambitious
				has_trait = arrogant
			}
		}
		name = bp2_yearly.4012.b
		add_character_modifier = {
			modifier = famed_parent_opt_out_base
		}

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

	option = { #I am as good as parent and I am content. opt out from the chain. Ambitious can opt out
		trigger = {
			var:parent_fame_lvl <= prestige_level
		}
		name = bp2_yearly.4012.c
		
		stress_impact = {
			base = minor_stress_loss
			ambitious = medium_stress_gain
			arrogant = medium_stress_gain
		}

		add_character_modifier = {
			modifier = famed_parent_opt_out_base
		}

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

	option = { #moaaar prestige
		trigger = {
			var:parent_fame_lvl <= prestige_level
		}
		name = bp2_yearly.4012.d
		
		stress_impact = {
			base = minor_stress_gain
			ambitious = minor_stress_loss
			arrogant = minor_stress_loss
		}

		add_character_modifier = {
			modifier = famed_parent_lvl_3
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4013
				years = { 1 2 }
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
			}
		}
	}
	
}

bp2_yearly.4013 = { #conclusion
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4013.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					var:parent_fame_lvl > prestige_level
				}
				desc = bp2_yearly.4013.desc_failure
			}
			triggered_desc = {
				trigger = {
					var:parent_fame_lvl <= prestige_level
				}
				desc = bp2_yearly.4013.desc_success
			}
		}
	}

	theme = crown

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				var:parent_fame_lvl <= prestige_level
			}
			animation = ecstasy
		}
		triggered_animation = {
			trigger = {
				var:parent_fame_lvl > prestige_level
			}
			animation = shame
		}
	}

	lower_right_portrait = {
		character = scope:dead_famous_parent
	}

	immediate = {
		remove_character_modifier = famed_parent_lvl_3
	}
	
	option = { #you are kinda failure, even after trying so hard, you get stress
		trigger = {
			var:parent_fame_lvl > prestige_level
		}
		name = bp2_yearly.4013.a
		stress_impact = {
			base = medium_stress_gain
			ambitious = medium_stress_gain
			arrogant = medium_stress_gain
		}
		ai_chance = {
			base = 100 #if this option shows, it is the only one
		}
	}

	option = { #you have succeeded, now chill
		name = bp2_yearly.4013.b
		trigger = {
			var:parent_fame_lvl <= prestige_level
		}
		
		stress_impact = {
			base = medium_stress_loss
			ambitious = major_stress_gain
			arrogant = major_stress_gain
		}

		add_character_modifier = {
			modifier = famed_parent_opt_out_advanced
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
			}
			modifier = {
				factor = 0
				has_trait = ambitious
			}
			modifier = {
				factor = 0
				has_trait = arrogant
			}
		}

	}

	option = { #you have succeeded, MOAR PRESTIGE
		name = bp2_yearly.4013.c
		trigger = {
			var:parent_fame_lvl <= prestige_level
		}
		
		stress_impact = {
			base = medium_stress_gain
			ambitious = medium_stress_loss
			arrogant = medium_stress_loss
		}

		add_character_modifier = {
			modifier = famed_parent_conclusion 
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 100
				has_trait = ambitious
			}
			modifier = {
				add = 100
				has_trait = arrogant
			}
		}

	}
}

bp2_yearly.4020 = { #child parent is at least Devoted Icon
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4020.t
	desc = bp2_yearly.4020.desc

	theme = faith

	left_portrait = {
		character = root
		animation = admiration
	}

	right_portrait = {
		character = scope:pious_parent
		animation = personality_zealous
	}

	#Fired from on_death which also provides:
	#scope:pious_parent
	#parent_piety_lvl

	trigger = { 
		NOR = { #double safeguard that only one event chain can happen
			has_character_flag = bp2_prestige_piety_chain
			government_has_flag = government_is_mandala
		}
	}

	immediate = {
		add_character_flag = bp2_prestige_piety_chain
	}

	option = { #yeah, you go papa! I will be like you one day!
		trigger = {
			NOR = {
				has_trait = content
				has_trait = cynical
			}
		}
		name = bp2_yearly.4020.b

		add_character_modifier = {
			modifier = pious_parent_lvl_1
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
				ai_zeal = tiny_chance_impact_positive_ai_value
			}
		}
		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4021
				years = { 2 4 }
			}
		}
	}

	option = { #it's fine I guess
		trigger = {
			NOR = {
				has_trait = ambitious
				has_trait = zealous
			}
		}
		name = bp2_yearly.4020.c
		add_character_modifier = {
			modifier = pious_parent_opt_out_base
			years = 10
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
				ai_zeal = tiny_chance_impact_positive_ai_value
			}
		}
	}
}

bp2_yearly.4021 = { #the parent has been dead for a while
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4021.t
	desc = bp2_yearly.4021.desc

	theme = faith


	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = ambitious
					has_trait = zealous
				}
			}
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = {
				always = yes
			}
			animation = grief
		}
	}

	lower_right_portrait = {
		character = scope:pious_dead_parent
	}

	trigger = {
		has_bp2_dlc_trigger = yes
		is_available_adult = yes
		has_variable = parent_piety_lvl
		has_character_modifier = pious_parent_lvl_1
	}

	on_trigger_fail = {
		#If it failed because we were not available we queue the event again.
		if = {
			limit = {
				is_available_adult = no
			}
			trigger_event = {
				id = bp2_yearly.4021
				days = 180
			}
		}
	}

	immediate = {
		random_memory = {
			memory_type = pious_parent_became_very_pious
			random_memory_participant = {
				save_scope_as = pious_dead_parent
			}
		}
		remove_character_modifier = pious_parent_lvl_1

	}

	option = { #how sad, time to get out from the shadow
		trigger = {
			var:parent_piety_lvl > piety_level
		}
		name = bp2_yearly.4021.a
		add_character_modifier = {
			modifier = pious_parent_lvl_2
		}
		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4022
				years = { 2 3 }
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
				ai_zeal = tiny_chance_impact_positive_ai_value
			}

		}
	}

	option = { #actually, I am content. opt out from chain
		trigger = {
			var:parent_piety_lvl > piety_level
			NOR = {
				has_trait = ambitious
				has_trait = zealous
			}
		}
		name = bp2_yearly.4021.b
		add_character_modifier = {
			modifier = pious_parent_opt_out_base
			years = 10
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
				ai_zeal = tiny_chance_impact_negative_ai_value
			}
		}
	}

	option = { # I am as good as parent and I am content. opt out from the chain
		trigger = {
			var:parent_piety_lvl <= piety_level
			NOR = {
				has_trait = ambitious
				has_trait = zealous
			}
		}
		name = bp2_yearly.4021.c
		
		stress_impact = {
			base = medium_stress_loss
		}

		add_character_modifier = {
			modifier = pious_parent_opt_out_base
			years = 10
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
				ai_zeal = tiny_chance_impact_negative_ai_value
			}
		}
	}

	option = { # I am as good as parent but I can be better!
		trigger = {
			var:parent_piety_lvl <= piety_level
		}
		name = bp2_yearly.4021.d
		stress_impact = {
			base = minor_stress_gain
			ambitious = medium_stress_loss
			zealous = medium_stress_loss
		}
		add_character_modifier = {
			modifier = pious_parent_lvl_2
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4022
				years = { 1 2 }
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
				ai_zeal = tiny_chance_impact_positive_ai_value
			}
		}

	}

}

bp2_yearly.4022 = { #piety vibe check
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4022.t
	desc = bp2_yearly.4022.desc

	theme = faith

	left_portrait = {
		character = root
		animation = personality_zealous
	}

	lower_right_portrait = {
		character = scope:pious_dead_parent
	}

	immediate = {
		remove_character_modifier = pious_parent_lvl_2
	}

	option = { #there is still much to do
		trigger = {
			var:parent_piety_lvl > piety_level
		}
		name = bp2_yearly.4022.a
		
		stress_impact = {
			base = minor_stress_gain
			ambitious = minor_stress_gain
			zealous = minor_stress_gain
		}

		add_character_modifier = {
			modifier = pious_parent_lvl_3
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4023
				years = { 2 3 }
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
				ai_zeal = tiny_chance_impact_positive_ai_value
			}
		}
	}

	option = { #ah, why bother
		trigger = {
			var:parent_piety_lvl > piety_level
			NOR = {
				has_trait = ambitious
				has_trait = zealous
			}
		}
		name = bp2_yearly.4022.b
		add_character_modifier = {
			modifier = pious_parent_opt_out_base
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
				ai_zeal = tiny_chance_impact_negative_ai_value
			}
		}
	}

	option = { #I am as good as parent and I am content. opt out from the chain. Ambitious can opt out
		trigger = {
			var:parent_piety_lvl <= piety_level
		}
		name = bp2_yearly.4022.c
		
		stress_impact = {
			base = minor_stress_loss
			ambitious = major_stress_gain
			zealous = major_stress_gain
		}

		add_character_modifier = {
			modifier = pious_parent_opt_out_base
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
				ai_Zeal = tiny_chance_impact_negative_ai_value
			}
		}
	}

	option = { #moaaar piety
		trigger = {
			var:parent_piety_lvl <= piety_level
		}
		name = bp2_yearly.4022.d
		
		stress_impact = {
			base = minor_stress_gain
			ambitious = minor_stress_loss
			zealous = minor_stress_loss
		}

		add_character_modifier = {
			modifier = pious_parent_lvl_3
		}

		hidden_effect = {
			trigger_event = {
				id = bp2_yearly.4023
				years = { 1 2 }
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_boldness = tiny_chance_impact_positive_ai_value
				ai_zeal = tiny_chance_impact_positive_ai_value
			}
		}
	}
	
}

bp2_yearly.4023 = { #conclusion
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4023.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					var:parent_piety_lvl > piety_level
				}
				desc = bp2_yearly.4023.desc_failure
			}
			triggered_desc = {
				trigger = {
					var:parent_piety_lvl <= piety_level
				}
				desc = bp2_yearly.4023.desc_success
			}
		}
	}

	theme = crown

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				var:parent_piety_lvl <= piety_level
			}
			animation = ecstasy
		}
		triggered_animation = {
			trigger = {
				var:parent_piety_lvl > piety_level
			}
			animation = shame
		}
	}

	lower_right_portrait = {
		character = scope:dead_pious_parent
	}

	immediate = {
		remove_character_modifier = pious_parent_lvl_3
	}
	
	option = { #you are kinda failure, even after trying so hard, you get stress
		trigger = {
			var:parent_piety_lvl > piety_level
		}
		name = bp2_yearly.4023.a
		stress_impact = {
			base = medium_stress_gain
			ambitious = minor_stress_gain
			zealous = minor_stress_gain
		}
		ai_chance = {
			base = 100 #if this option shows, it is the only one
		}
	}

	option = { #you have succeeded, now chill
		name = bp2_yearly.4023.b
		trigger = {
			var:parent_piety_lvl <= piety_level
		}
		
		stress_impact = {
			base = medium_stress_loss
			ambitious = medium_stress_gain
			zealous = medium_stress_gain
		}

		add_character_modifier = {
			modifier = pious_parent_opt_out_advanced
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_boldness = tiny_chance_impact_negative_ai_value
				ai_zeal = tiny_chance_impact_negative_ai_value
			}
			modifier = {
				factor = 0
				has_trait = ambitious
			}
			modifier = {
				factor = 0
				has_trait = zealous
			}
		}

	}

	option = { #you have succeeded, MOAR PIETY
		name = bp2_yearly.4023.c
		trigger = {
			var:parent_piety_lvl <= piety_level
		}
		
		stress_impact = {
			base = medium_stress_gain
			ambitious = medium_stress_loss
			zealous = medium_stress_loss
		}

		add_character_modifier = {
			modifier = pious_parent_conclusion 
		}

		ai_chance = {
			base = 0
			modifier = {
				add = 100
				has_trait = ambitious
			}
			modifier = {
				add = 100
				has_trait = zealous
			}
		}

	}
}

bp2_yearly.4030 = { #While commanding army in winter province, you are struck with first sunlight memory from childhood
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4030.t
	desc = bp2_yearly.4030.desc
	content_source = dlc_009
	theme = war

	override_background = { reference = ep2_hunt_snowy_forest } 
	widget = {
		gui = "event_window_widget_vfx_snow"
		container = "foreground_shader_vfx_container"
	}

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	right_portrait = {
		character = scope:frosty_knight
		animation = anger
	}

	cooldown = { years = 20 }

	trigger = {
		has_bp2_dlc_trigger = yes
		exists = scope:army
		is_playable_character = yes #Not for mercenaries
		is_in_army = yes
		commanding_army ?= scope:army
		location ?= {
			has_province_modifier = winter_harsh_modifier
			trigger_if = {
				limit = { exists = county }
				county.holder.top_liege != root.top_liege
			}
		}
		any_knight = {
			is_in_army = yes
			location = root.location
		}
	}

	immediate = {
		location = {
			save_scope_as = winter_location
		}
		random_knight = {
			limit = {
				is_in_army = yes
				location = root.location
			}
			save_scope_as = frosty_knight
		}
	}

	option = { #warm yourself with memories
		name = bp2_yearly.4030.a
		add_character_modifier = {
			modifier = memory_of_sunlight_personal
			years = 4
		}

		stress_impact = {
			base = minor_stress_loss
			shy = medium_stress_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = tiny_chance_impact_negative_ai_value
			}
		}
	}

	option = { #speech, speech, speech!
		name = bp2_yearly.4030.b
		flavor = bp2_yearly.4030.b.flavor
		add_character_modifier = {
			modifier = memory_of_sunlight_shared
			years = 4
		}

		stress_impact = {
			shy = minor_stress_gain
			brave = minor_stress_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = tiny_chance_impact_positive_ai_value
			}
		}
	}

	option = { #winter soldier
		trigger = {
			has_trait = winter_soldier
		}
		name = bp2_yearly.4030.c				
		send_interface_toast = {
			title = bp2_yearly.4030.c.tt
			left_icon = root
			random_list = {
				1 = {
					add_martial_skill = 1
				}
				1 = {
					add_prowess_skill = 2
				}
				1 = {
					add_martial_lifestyle_xp = medium_lifestyle_xp
				}
			}
		}
		ai_chance = {
			base = 400
		}
	}
}

bp2_yearly.4031 = { #you where imprisoned as a child, and guess what? You are imprisoned as an adult. Congratulations!
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4031.t
	content_source = dlc_009
	desc = {
		desc = bp2_yearly.4031.desc_first
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:new_imp != scope:old_imp
				}
				desc = bp2_yearly.4031.desc_base
			}
			triggered_desc = {
				trigger = {
					scope:new_imp = scope:old_imp
				}
				desc = bp2_yearly.4031.desc_same_captor
			}
		}
		desc = bp2_yearly.4031.desc_last
	}

	theme = prison

	override_background = {
		trigger = {
			OR = {
				scope:bg_override_char = { has_government = landless_adventurer_government }
				is_in_prison_type = dungeon
			}
		}
		reference = dungeon
	}
	override_background = {
		trigger = {
			NOR = {
				scope:bg_override_char = { has_government = landless_adventurer_government }
				is_in_prison_type = dungeon
			}
		}
		reference = relaxing_room
	}

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { is_in_prison_type = house_arrest }
			animation = prisonhouse
		}
		triggered_animation = {
			trigger = { is_in_prison_type = dungeon }
			animation = prisondungeon
		}
		override_imprisonment_visuals = yes
	}
	lower_left_portrait = scope:old_imp
	lower_right_portrait = {
		character = scope:imprisoner
		trigger = {
			scope:imprisoner != scope:old_imp
		}
	}

	cooldown = { years = 10 }

	trigger = {
		has_bp2_dlc_trigger = yes
		is_imprisoned = yes
		any_memory = {
			memory_type = imprisoned
			has_variable = childhood_memory
		}
	}

	immediate = {
		imprisoner = {
			save_scope_as = new_imp
			save_scope_as = bg_override_char
		}
		random_memory = {
			memory_type = imprisoned
			limit = {
				has_variable = childhood_memory
			}
			random_memory_participant = {
				save_scope_as = old_imp
			}
		}
	}

	option = { #use that memory to escape
		name = bp2_yearly.4031.a
		flavor = bp2_yearly.4031.a.flavor
		
		add_character_modifier = {
			modifier = childhood_prison_escape
			years = 10
		}

		custom_tooltip = bp2_yearly.4031.a.ct

		stress_impact = {
			brave = minor_stress_loss
			stubborn = minor_stress_loss
			impatient = minor_stress_loss
			arrogant = minor_stress_loss
			patient = minor_stress_gain
			craven = minor_stress_gain
			paranoid = minor_stress_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
			}
		}
	}

	option = { #use that memory to endure
		name = bp2_yearly.4031.b
		flavor = bp2_yearly.4031.b.flavor
		add_character_modifier = {
			modifier = childhood_prison_endure
			years = 10
		}

		stress_impact = {
			patient = minor_stress_loss
			craven = minor_stress_loss
			trusting = minor_stress_loss
			humble = minor_stress_loss
			impatient = minor_stress_gain
			brave = minor_stress_gain
			stubborn = minor_stress_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
			}
		}

	}
}

bp2_yearly.4032 = {
	type = character_event
	content_source = dlc_009
	title = bp2_yearly.4032.t
	desc = bp2_yearly.4032.desc
	content_source = dlc_009
	theme = hostage


	left_portrait = {
		character = root
		animation = grief
	}

	right_portrait = {
		character = scope:hostage_kiddo
		animation = jockey_idle
		camera = camera_event_horse_right
	}
	
	#Fired from on_hostage_taken which also saves:
	#scope:hostage_kiddo
	#scope:childhood_hostage_memory

	immediate = {
		add_character_flag = bp2_hostage_blues
		var:hostage_mem = {
			memory_participant:home_court = {
				save_scope_as = tru_papa
			}
			memory_participant:warden = {
				save_scope_as = new_papa
			}
		}
		var:hostage_kid = {
			save_scope_as = hostage_kiddo
		}
	}

	option = { #Dynasty Motto child!
		name = bp2_yearly.4032.a

		dynasty = {
			add_dynasty_prestige = minor_dynasty_prestige_gain
		}

		scope:hostage_kiddo = {
			add_opinion = {
				target = root
				modifier = abandoned_opinion
				opinion = -20
			}
		}

		stress_impact = {
			compassionate = medium_stress_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_negative_ai_value
				ai_rationality = tiny_chance_impact_positive_ai_value
			}
		}
		
	}

	option = { #You will return, as I did
		name = bp2_yearly.4032.b
		scope:hostage_kiddo = {
			add_character_modifier = {
				modifier = generational_hostage
				years = 8
			}
		}
		stress_impact = {
			compassionate = medium_stress_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = tiny_chance_impact_positive_ai_value
				ai_rationality = tiny_chance_impact_positive_ai_value
			}
		}
	}

	after = {
		remove_variable = hostage_mem
		remove_variable = hostage_kid
	}

}
