﻿#Events fired by your parents if they're still around

namespace = parent


#0000-0999: Parent maintenance/meddlesome increase and decrease
#1000-1999: Parents support you
#2000-2999: Parents are intrusive - negative outcome
#3000-3999: Parents are intrusive - positive outcome


#parent_meddling_value_effect has a chance of decreasing over time
parent.0001 = {
	type = character_event
	hidden = yes

	trigger = {
		is_ai = no
		has_variable = parent_meddling
	}

	immediate = {
		decrease_parent_meddling_value_effect = yes
	}
}

scripted_trigger parent_events_skill_check_trigger = {
	is_alive = yes
	is_ruler = no
	$SKILL$ >= decent_skill_rating
	NOT = { is_councillor_of = root }
}

#Parent helps in martial matters
# by Petter Vilberg
parent.1001 = {
	type = character_event
	title = parent.1001.t
	desc = parent.1001.desc
	theme = family
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:parent
		animation = marshal
	}
	override_background = { reference = courtyard }

	trigger = {
		NOT = { has_character_flag = had_parent_skill_support_event }
		NOT = { has_character_modifier = parent_aids_martial_modifier }
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = martial
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 2
			martial < average_skill_rating
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_skill_support_event
			days = 500
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = martial
				}
			}
			save_scope_as = parent
		}
	}

	option = {
		name = parent.1001.a
		add_character_modifier = {
			modifier = parent_aids_martial_modifier
			days = 1825
		}
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
	}

	option = {
		name = parent.1001.b
		scope:parent = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
	}
}



#Parent helps in diplomacy matters
# by Petter Vilberg
parent.1002 = {
	type = character_event
	title = parent.1001.t
	desc = parent.1002.desc
	theme = family
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:parent
		animation = writing
	}
	override_background = { reference = garden }

	trigger = {
		NOT = { has_character_flag = had_parent_skill_support_event }
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = diplomacy
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_skill_support_event
			days = 500
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = diplomacy
				}
			}
			save_scope_as = parent
		}
	}

	option = {
		name = parent.1002.a
		add_character_modifier = {
			modifier = parent_aids_diplomacy_modifier
			days = 1825
		}
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
	}

	option = {
		name = parent.1002.b
		scope:parent = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
	}
}


#Parent helps in intrigue matters
# by Petter Vilberg
parent.1003 = {
	type = character_event
	title = parent.1001.t
	desc = parent.1003.desc
	theme = family
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:parent
		animation = scheme
	}
	override_background = { reference = corridor_night }

	trigger = {
		NOT = { has_character_flag = had_parent_skill_support_event }
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = intrigue
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_skill_support_event
			days = 500
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = intrigue
				}
			}
			save_scope_as = parent
		}
	}

	option = {
		name = parent.1003.a
		add_character_modifier = {
			modifier = parent_aids_intrigue_modifier
			days = 730
		}
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
		if = {
			limit = {
				opinion = {
					target = scope:parent
					value < 10
				}
			}
			stress_impact = {
				paranoid = medium_stress_impact_gain
			}
		}
	}

	option = {
		name = parent.1003.b
		scope:parent = {
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -10
			}
		}
		if = {
			limit = {
				opinion = {
					target = scope:parent
					value >= 10
				}
			}
			stress_impact = {
				paranoid = minor_stress_impact_gain
			}
		}
	}
}


#Parent helps in stewardship matters
# by Petter Vilberg
parent.1004 = {
	type = character_event
	title = parent.1001.t
	desc = parent.1004.desc
	theme = family
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:parent
		animation = reading
	}
	override_background = { reference = study }

	trigger = {
		NOT = { has_character_flag = had_parent_skill_support_event }
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = stewardship
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_skill_support_event
			days = 500
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = stewardship
				}
			}
			save_scope_as = parent
		}
	}

	option = {
		name = parent.1004.a
		add_character_modifier = {
			modifier = parent_aids_stewardship_modifier
			days = 1825
		}
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
	}

	option = {
		name = parent.1004.b
		scope:parent = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
	}
}


#Parent helps in learning matters
# by Petter Vilberg
parent.1005 = {
	type = character_event
	title = parent.1001.t
	desc = parent.1005.desc
	theme = family
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:parent
		animation = debating
	}
	override_background = { reference = study }

	trigger = {
		NOT = { has_character_flag = had_parent_skill_support_event }
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = learning
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_skill_support_event
			days = 500
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = learning
				}
			}
			save_scope_as = parent
		}
	}

	option = {
		name = parent.1005.a
		add_character_modifier = {
			modifier = parent_aids_learning_modifier
			days = 1825
		}
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
	}

	option = {
		name = parent.1005.b
		scope:parent = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
	}
}


#Parent helps support a county of yours
# by Petter Vilberg
scripted_trigger parent_1006_county_trigger = {
	tier = tier_county
	this != root.capital_county
}

parent.1006 = {
	type = character_event
	title = parent.1006.t
	desc = parent.1006.desc
	theme = family
	left_portrait = {
		character = root
		animation = war_over_tie
	}
	right_portrait = {
		character = scope:parent
		animation = writing
	}
	override_background = { reference = study }

	trigger = {
		is_landed = yes
		has_variable = parent_meddling
		var:parent_meddling > 0
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = stewardship
			}
		}
		any_held_title = {
			parent_1006_county_trigger = yes
		}
	}

	immediate = {
		random_held_title = {
			limit = {
				parent_1006_county_trigger = yes
			}
			save_scope_as = county
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = stewardship
				}
			}
			save_scope_as = parent
		}
		increase_parent_meddling_value_effect = yes
	}

	option = {
		name = parent.1006.a
		scope:county = {
			add_county_modifier = {
				modifier = parent_managing_county_modifier
				days = 3650
			}
		}
		custom_tooltip = parent_meddling_tt
	}
}

# Parent helps with courtier opinion
# by Linnéa Thimrén and Petter Vilberg
scripted_trigger parent_1007_courtier_trigger = {
	is_adult = yes
	OR = {
		is_of_major_interest_to_root_trigger = yes
		is_of_minor_interest_to_root_trigger = yes
	}
	NOT = { has_relation_friend = root }
	NOT = { has_relation_potential_friend = root }
	reverse_opinion = {
		target = root
		value < 0
	}
}

parent.1007 = {
	type = character_event
	title = parent.1007.t
	desc = {
		desc = parent.1007.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = courtier_1
				}
				desc = parent.1007.courtier_1
			}
			triggered_desc = {
				trigger = {
					has_character_flag = courtier_2
				}
				desc = parent.1007.courtier_2
			}
		}
		desc = parent.1007.desc_end
	}
	theme = family
	left_portrait = {
		character = scope:courtier
		animation = dismissal
	}
	right_portrait = {
		character = scope:parent
		animation = war_over_tie
	}
	override_background = { reference = garden }
	
	trigger = {
		NOT = { has_character_flag = had_parent_courtier_event }
		NOR = {
			has_character_modifier = parent_dealing_with_courtiers_modifier
			has_character_modifier = parent_events_wrangling_courtiers_modifier
		}
		any_courtier_or_guest = {
			parent_1007_courtier_trigger = yes
		}
		any_parent = {
			parent_events_skill_check_trigger = {
				SKILL = diplomacy
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_courtier_event
			days = 730
		}
		random_courtier_or_guest = {
			limit = {
				parent_1007_courtier_trigger = yes
			}
			save_scope_as = courtier
		}
		random_parent = {
			limit = {
				parent_events_skill_check_trigger = {
					SKILL = diplomacy
				}
			}
			save_scope_as = parent
		}
		hidden_effect = {
			random_list = {
				25 = {
					modifier = {
						scope:courtier = {
							has_trait = gregarious
						}
						factor = 2
					}
					add_character_flag = courtier_1
				}
				25 = {
					add_character_flag = courtier_2
				}
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:courtier }
				}
				random = {
					chance = 25
					set_relation_potential_rival = scope:courtier
				}
			}
		}
	}

	option = {
		name = parent.1007.a
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
		add_character_modifier = {
			modifier = parent_dealing_with_courtiers_modifier
			days = 3650
		}
		scope:courtier = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 30
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_personality_submissive_trigger = yes
			}
		}
	}

	option = {
		name = parent.1007.b
		add_dread = minor_dread_gain
		add_character_modifier = {
			modifier = parent_events_wrangling_courtiers_modifier
			days = 1825
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_personality_dominant_trigger = yes
			}
		}
	}

	after = {
		remove_character_flag = courtier_1
		remove_character_flag = courtier_2
	}
}


# Parent gives you a new courtier
# by Linnéa Thimrén
scripted_trigger parent_1009_valid_new_courtier = {
	# Must be an adult, ai courtier.
	is_ai = yes
	is_adult = yes
	is_landed = no
	is_ruler = no

	# No poaching another ruler's spouse!
	trigger_if = {
		limit = { is_married = yes }
		any_spouse = { is_landed = no }
	}

	#Don't add our own parent/close family/spouse to our court!
	NOT = { is_parent_of = root }
	is_any_family_relation_or_spouse_of_root_trigger = no

	#If the character has a liege, the liege must be an AI character (no poaching courtiers from other players!)
	OR = {
		NOT = { exists = liege }
		liege = {
			is_ai = yes
			this != root #Not already our courtier!
		}
	}
	NOT = { is_in_the_same_court_as_or_guest = root }
}

parent.1009 = {
	type = character_event
	title = parent.1009.t
	desc = parent.1009.desc
	theme = family
	left_portrait = {
		character = scope:parent
		animation = admiration
	}
	right_portrait = {
		character = scope:new_courtier
		animation = obsequious_bow
	}
	override_background = { reference = courtyard }

	trigger = {
		NOT = { has_character_flag = had_parent_courtier_event }
		any_parent = {
			is_alive = yes
			is_ruler = no
			has_dynasty = yes
			dynasty = {
				any_dynasty_member = {
					parent_1009_valid_new_courtier = yes
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_courtier_event
			days = 1825
		}
		random_parent = {
			limit = {
				is_alive = yes
				is_ruler = no
				has_dynasty = yes
				dynasty = {
					any_dynasty_member = {
						parent_1009_valid_new_courtier = yes
					}
				}
			}
			save_scope_as = parent
		}
		scope:parent = {
			random_relation = {
				type = friend
				if = {
					limit = {
						parent_1009_valid_new_courtier = yes
					}
					save_scope_as = new_courtier
				}
			}
			if = {
				limit = {
					NOT = { exists = scope:new_courtier }
				}
				scope:parent.dynasty = {
					#Find a valid 'unimportant' character we can add to our court.
					random_dynasty_member = {
						limit = {
							parent_1009_valid_new_courtier = yes
							opinion = {
								target = scope:parent
								value >= 10
							}
						}
						alternative_limit = {
							parent_1009_valid_new_courtier = yes
						}
						save_scope_as = new_courtier
					}
				}
			}
			if = {
				limit = {
					can_set_relation_friend_trigger = { CHARACTER = scope:new_courtier }
				}
				hidden_effect = { set_relation_friend = { reason = friend_politics target = scope:new_courtier } }
			}
		}
	}

	option = {
		name = parent.1009.a
		increase_parent_meddling_value_effect = yes
		add_courtier = scope:new_courtier
		scope:new_courtier = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 30
			}
		}
		scope:parent = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
	}

	option = {
		name = parent.1009.b
		scope:parent = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
	}
}

#Parent gives stress_loss
# by Linnéa Thimrén
parent.1010 = {
	type = character_event
	title = parent.1010.t
	desc = parent.1010.desc
	theme = family
	left_portrait = {
		character = root
		animation = boredom
	}
	right_portrait = {
		character = scope:parent
		animation = writing
	}
	override_background = { reference = garden }


	trigger = {
		NOT = { has_character_flag = had_parent_stress_loss_event }
		stress > 50
		any_parent = {
			is_alive = yes
			is_ruler = no
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			value = stress
			offset = -25
			multiplier = 0.01
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_parent_stress_loss_event
			days = 730
		}
		random_parent = {
			limit = {
				is_alive = yes
				is_ruler = no
			}
			save_scope_as = parent
		}
	}

	option = {
		name = parent.1010.a
		custom_tooltip = parent_meddling_tt
		increase_parent_meddling_value_effect = yes
		stress_impact = {
			base = medium_stress_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_personality_submissive_trigger = yes
			}
			compare_modifier = {
				value = stress
				offset = -25
				multiplier = 0.01
			}
		}
	}

	option = {
		name = parent.1010.b
		stress_impact = {
			base = minor_stress_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_personality_dominant_trigger = yes
			}
		}
	}
}

#Parent sends your children away for their education
# by Petter Vilberg
scripted_trigger parent_2002_child_trigger = {
	is_adult = no
	age >= childhood_education_start_age
	age <= 13
	OR = {
		any_relation = {
			type = guardian
			OR = {
				this = root
				is_courtier_of = root
			}
		}
		NOT = {
			any_relation = {
				type = guardian
				always = yes
			}
		}
	}
}

scripted_trigger parent_2002_new_educator = {
	is_adult = yes
	is_ai = yes
	NOT = { is_in_the_same_court_as_or_guest = root }
	this != root
	this != scope:parent
	reverse_opinion = {
		target = scope:parent
		value >= -20
	}
	NOT = {
		any_relation = {
			type = ward
			count >= 2
		}
	}
	NOT = {
		any_relation = {
			type = ward
			this = scope:child
		}
	}
	OR = {
		top_liege = root.top_liege
		dynasty = root.dynasty
	}
}

parent.2002 = {
	type = character_event
	title = parent.2002.t
	desc = parent.2002.desc
	theme = family
	left_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:parent
		animation = dismissal
	}
	lower_left_portrait = scope:child
	lower_right_portrait = scope:new_guardian
	override_background = { reference = courtyard }

	trigger = {
		NOT = { has_character_flag = had_child_sent_away_event }
		is_ai = no
		has_variable = parent_meddling
		any_parent = {
			is_alive = yes
			is_ruler = no
			save_temporary_scope_as = parent
		}
		any_child = {
			parent_2002_child_trigger = yes
			save_temporary_scope_as = child
		}
		#Check whether a new educator might exist
		OR = {
			top_liege = {
				OR = {
					parent_2002_new_educator = yes
					any_vassal_or_below = {
						OR = {
							parent_2002_new_educator = yes
							any_courtier = {
								parent_2002_new_educator = yes
							}
						}
					}
					any_courtier = {
						parent_2002_new_educator = yes	
					}
				}
			}
			dynasty = {
				any_dynasty_member = {
					OR = {
						parent_2002_new_educator = yes
						any_courtier = {
							parent_2002_new_educator = yes
						}
					}
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_child_sent_away_event
			days = 1825
		}
		random_parent = {
			limit = {
				is_alive = yes
				is_ruler = no
			}
			save_scope_as = parent
		}
		random_child = {
			limit = {
				parent_2002_child_trigger = yes
			}
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = -0.03
					min = -0.9
				}
			}
			save_scope_as = child
		}

		#Find a new educator
		top_liege = {
			if = {
				limit = {
					parent_2002_new_educator = yes
				}
				add_to_list = educator_candidate
			}
			every_courtier = {
				limit = {
					parent_2002_new_educator = yes
				}
				add_to_list = educator_candidate
			}
			every_vassal_or_below = {
				limit = {
					parent_2002_new_educator = yes
				}
				add_to_list = educator_candidate
				every_courtier = {
					limit = {
						parent_2002_new_educator = yes
					}
					add_to_list = educator_candidate
				}
			}
		}
		dynasty = {
			every_dynasty_member = {
				limit = {
					parent_2002_new_educator = yes
				}
				add_to_list = educator_candidate
				if = {
					limit = {
						any_courtier = {
							always = yes
						}
					}
					every_courtier = {
						limit = {
							parent_2002_new_educator = yes
						}
						add_to_list = educator_candidate
					}
				}
			}
		}
		random_in_list = {
			list = educator_candidate
			weight = {
				base = 1
				opinion_modifier = {
					who = scope:parent
					opinion_target = this
					multiplier = 0.05
					min = -0.9
				}
			}
			save_scope_as = new_guardian
		}
		scope:child = {
			if = {
				limit = {
					any_relation = {
						type = guardian
						always = yes
					}
				}
				random_relation = {
					type = guardian
					save_scope_as = old_guardian
				}
			}
		}
	}

	option = {
		name = parent.2002.a
		custom_tooltip = child_sent_away_tt
		scope:child = {
			if = {
				limit = {
					exists = scope:old_guardian
				}
				remove_relation_guardian = scope:old_guardian
			}
			set_relation_guardian = scope:new_guardian
			if = {
				limit = {
					scope:new_guardian.court_owner != scope:child.host
				}
				visit_court_of = scope:new_guardian.court_owner
			}
		}
	}

	after = {
		remove_parent_meddling_value_effect = yes
	}
}

#Parent banishes courtier
# by Linnéa Thimrén and Petter Vilberg
scripted_trigger parent_2003_banish_candidate_trigger = {
	is_ai = yes
	is_adult = yes
	NOR = {
		this = scope:parent
		has_relation_friend = scope:parent
		dynasty = root.dynasty
		this = root.player_heir
		is_close_or_extended_family_of = root
	}
	reverse_opinion = {
		target = scope:parent
		value < 30
	}
}

parent.2003 = {
	type = character_event
	title = parent.2003.t
	desc = parent.2003.desc
	theme = family
	left_portrait = {
		character = scope:parent
		animation = dismissal
	}
	right_portrait = {
		character = scope:hated_courtier
		animation = disbelief
	}
	override_background = { reference = courtyard }
	
	trigger = {
			NOT = {
			has_character_flag = had_event_parent_2003
		}
		exists = var:parent_meddling
		var:parent_meddling > 1
		any_parent = {
			is_alive = yes
			is_ruler = no
			save_temporary_scope_as = parent
		}
		any_courtier = {
			parent_2003_banish_candidate_trigger = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_parent_2003
			days = 1825
		}
		random_parent = {
			limit = {
				is_alive = yes
				is_ruler = no
			}
			save_scope_as = parent
		}
		random_courtier = {
			limit = {
				parent_2003_banish_candidate_trigger = yes
			}
			save_scope_as = hated_courtier
		}
		scope:hated_courtier = {
			select_and_move_to_pool_effect = yes
			hidden_effect = {
				add_opinion = {
					modifier = banished_me
					target = scope:parent
				}
			}			
		}
	}

	option = {
		name = parent.2003.a
		trigger = {
			opinion = {
				target = scope:hated_courtier
				value > 0
			}
		}
		stress_impact = {
			base = minor_stress_gain
		}
	}

	option = {
		name = parent.2003.b
		trigger = {
			opinion = {
				target = scope:hated_courtier
				value <= 0
			}
		}
		stress_impact = {
			base = minor_stress_loss
		}
	}
	after = {
		remove_parent_meddling_value_effect = yes
	}
}

#Parent gives you stress
parent.2004 = {
	type = character_event
	title = parent.2004.t
	desc = {
		desc = parent.2004.opening
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						NOT = { has_trait_benevolent_trigger = yes }
						scope:parent = {
							has_trait_malicious_trigger = yes
						}
					}
					desc = parent.2004.malicious
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_malicious_trigger = yes }
						scope:parent = {
							has_trait_benevolent_trigger = yes
						}
					}
					desc = parent.2004.benevolent
				}
				triggered_desc = {
					trigger = {
						Not = { has_trait_submissive_trigger = yes }
						scope:parent = {
							has_trait_dominant_trigger = yes
						}
					}
					desc = parent.2004.dominant
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_dominant_trigger = yes }
						scope:parent = {
							has_trait_submissive_trigger = yes
						}
					}
					desc = parent.2004.submissive
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_introverted_trigger = yes }
						scope:parent = {
							has_trait_extroverted_trigger = yes
						}
					}
					desc = parent.2004.extroverted
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_extroverted_trigger = yes }
						scope:parent = {
							has_trait_introverted_trigger = yes
						}
					}
					desc = parent.2004.introverted
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_levelheaded_trigger = yes }
						scope:parent = {
							has_trait_emotional_trigger = yes
						}
					}
					desc = parent.2004.emotional
				}
				triggered_desc = {
					trigger = {
						NOT = { has_trait_emotional_trigger = yes }
						scope:parent = {
							has_trait_levelheaded_trigger = yes
						}
					}
					desc = parent.2004.levelheaded
				}
			}
			desc = parent.2004.fallback
		}
		desc = parent.2004.end
	}
	theme = family
	left_portrait = {
		character = root
		animation = boredom
	}
	right_portrait = {
		character = scope:parent
		animation = debating
	}
	override_background = { reference = throne_room }
	
	trigger = {
		any_parent = {
			is_alive = yes
			is_ruler = no
		}
		NOT = {
			has_character_flag = had_parent_stress_event
		}
		has_variable = parent_meddling
		var:parent_meddling > 1
		stress < 75
	}

	immediate = {
			random_parent = {
			limit = {
				is_alive = yes
				is_ruler = no
			}
			save_scope_as = parent
		}
		add_character_flag = {
			flag = had_parent_stress_event
			days = 1825
		}
	}

	option = {
		name = parent.2004.a
		add_stress = medium_stress_gain
	}
	after = {
		remove_parent_meddling_value_effect = yes
	}
}

#Your parent takes your child under their wing
# by Linnéa Thimrén
scripted_trigger parent_3001_child_trigger = {
	is_adult = no
	age >= childhood_education_start_age
	age <= 14
	OR = {
		any_relation = {
			type = guardian
			this = root
		}
		NOT = {
			any_relation = {
				type = guardian
				always = yes
			}
		}
	}
}

parent.3001 = {
	type = character_event
	title = parent.3001.t
	desc = parent.3001.desc
	theme = family
	left_portrait = {
		character = scope:child
		animation = page_flipping
	}
	right_portrait = {
		character = scope:parent
		animation = debating
	}
	override_background = { reference = throne_room }
	
	trigger = {
		NOT = { has_character_flag = had_child_reared_by_parent_event }
		has_variable = parent_meddling
		any_parent = {
			is_alive = yes
			is_ruler = no
		}
		any_child = {
			parent_3001_child_trigger = yes
		}	
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 3
			any_targeting_scheme = {
				scheme_type = murder
				OR = {
					scheme_owner = {
						is_parent_of = root
						is_courtier_of = root	
					}
					any_scheme_agent_character = {
						is_parent_of = root
						is_courtier_of = root
					}
				}
			}
		}
	}

	immediate = {
		increase_parent_meddling_value_effect = yes
		add_character_flag = {
			flag = had_child_reared_by_parent_event
			days = 1825
		}
		random_parent = {
			limit = {
				is_alive = yes
				is_ruler = no
				#Prioritize someone who is planning to murder you
				save_temporary_scope_as = parent_check
				root = {
					any_targeting_scheme = {
						scheme_type = murder
						OR = {
							scheme_owner = scope:parent_check
							any_scheme_agent_character = { this = scope:parent_check }
						}
					}
				}
			}
			alternative_limit = {
				is_alive = yes
				is_ruler = no
			}
			save_scope_as = parent
		}
		random_child = {
			limit = {
				parent_3001_child_trigger = yes
			}
			save_scope_as = child
			if = {
				limit = {
					any_relation = {
						type = guardian
						always = yes
					}
				}
				random_relation = {
					type = guardian
					save_scope_as = old_guardian
				}
			}
		}  	
	}
	option = {
		name = parent.3001.a
		trigger = {
			NOR = {
				opinion = {
					value <= 20
					target = scope:parent
				}
				has_trait = paranoid
				has_trait = lunatic
			}
		}
		if = {
			limit = { exists = scope:old_guardian }
			remove_guardian_effect = {
				GUARDIAN = scope:old_guardian
				WARD = scope:child
				RETURN_WARD = no
				HIDE_OPINION = no
			}
		}
		scope:child = { set_relation_guardian = scope:parent }
		custom_tooltip = parent_meddling_decrease_tt
		decrease_parent_meddling_value_effect = yes
		
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_personality_submissive_trigger = yes
			}
			opinion_modifier = {
				opinion_target = scope:parent
				multiplier = 0.05
				step = 5
			}
		}
	}
	option = {
		name = parent.3001.b
		trigger = {
			NOR = {
				opinion = {
					value <= 20
					target = scope:parent
				}
				has_trait = paranoid
				has_trait = lunatic
			}
		}
		add_stress = medium_stress_gain
		scope:parent = {
			add_opinion = {
				target = root
				modifier = insulted_parent
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_personality_dominant_trigger = yes
			}
			opinion_modifier = {
				opinion_target = scope:parent
				multiplier = -0.05
				step = 5
			}
		}
	}
	option = {
		name = parent.3001.c
		trigger = {	
			OR = {
				opinion = {
					value <= -30
					target = scope:parent
				}
		 		has_trait = paranoid
		 		has_trait = lunatic
			}
		}
		trait = paranoid
		trait = lunatic_1
		trait = lunatic_genetic
		scope:parent = {
			add_opinion = {
				target = ROOT
				modifier = gravely_insulted_parent
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = paranoid
		 		has_trait = lunatic
			}
		}
	}
}
