﻿namespace = imperial_examination_jay

#######################
### ACTIVITY EVENTS
#######################
# Events for parents of Examinees:
	# imperial_examination_jay.0010 - You bond with another Entrant's parent
	# imperial_examination_jay.0040 - You witness another parent bribing an Examiner
	# imperial_examination_jay.0080 - An Examiner trips and falls
	# imperial_examination_jay.0110 - A greedy Examiner fishes for a bribe
	# imperial_examination_jay.0120 - An Examiner sees promise in your child
	# imperial_examination_jay.0170 - An Examiner shows your family favoritism

# You bond with another Entrant's parent
# For Family
imperial_examination_jay.0010 = {
	type = activity_event
	title = imperial_examination_jay.0010.t
	desc = imperial_examination_jay.0010.desc
	theme = imperial_examination
	override_background = { reference = tgp_relaxing_room_asia }

	left_portrait = {
		character = root
		animation = personality_content
	}

	right_portrait = {
		character = scope:friend
		animation = admiration
	}

	lower_left_portrait = {
		character = scope:child
	}

	lower_right_portrait = {
		character = scope:friends_child
	}

	cooldown = { months = 6 }

	trigger = {
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_imperial_examination }
			}
			has_activity_intent = imperial_exam_support_entrants_intent
		}
		trigger_else = {
			has_activity_intent = local_exam_support_entrants_intent
		}
		involved_activity = {
			save_temporary_scope_as = temp_activity
			any_attending_character = {
				is_ai = yes
				this != root
				can_set_relation_friend_trigger = { CHARACTER = root }
				number_of_personality_traits_in_common = {
					target = root
					value >= 1
				}
				any_close_or_extended_family_member = {
					involved_activity = scope:activity
					is_ai = yes
					this != root
					NOR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
					is_in_guest_subset = { name = entrants }
					save_temporary_scope_as = temp_child
				}
			}
			any_attending_character = {
				is_ai = yes
				this != root
				OR = {
					is_close_or_extended_family_of = root
					has_relation_disciple = root
					this = root.primary_spouse
				}
				is_in_guest_subset = { name = entrants }
				this != scope:temp_child
			}
			
		}
	}

	immediate = {
		involved_activity = {
			# Grab your friend
			random_attending_character = {
				limit = {
					is_ai = yes
					this != root
					can_set_relation_friend_trigger = { CHARACTER = root }
					number_of_personality_traits_in_common = {
						target = root
						value >= 1
					}
					save_temporary_scope_as = temp_char
					any_close_or_extended_family_member = {
						involved_activity = scope:activity
						is_ai = yes
						this != root
						NOR = {
							is_close_or_extended_family_of = root
							has_relation_disciple = root
							this = root.primary_spouse
						}
						is_in_guest_subset = { name = entrants }
					}
				}
				weight = {
					base = 1
					modifier = {
						number_of_personality_traits_in_common = {
							target = root
							value >= 2
						}
						add = 1
					}
					modifier = {
						number_of_personality_traits_in_common = {
							target = root
							value >= 3
						}
						add = 1
					}
					modifier = {
						number_of_personality_traits_in_common = {
							target = root
							value >= 4
						}
						add = 2
					}
					modifier = {
						number_of_opposing_personality_traits = {
							target = root
							value >= 1
						}
						add = -1
					}
					modifier = {
						number_of_opposing_personality_traits = {
							target = root
							value >= 2
						}
						add = -1
					}
					modifier = {
						number_of_opposing_personality_traits = {
							target = root
							value >= 3
						}
						add = -1
					}
					modifier = {
						has_trait = shy
						factor = 0.5
					}
					modifier = {
						has_trait = gregarious
						factor = 1.5
					}
				}
				save_scope_as = friend
				assign_quirk_effect = yes
			}
			# Grab your kids
			scope:friend = {
				random_close_or_extended_family_member = {
					limit = {
						involved_activity = scope:activity
						is_ai = yes
						this != root
						NOR = {
							is_close_or_extended_family_of = root
							has_relation_disciple = root
							this = root.primary_spouse
						}
						is_in_guest_subset = { name = entrants }
					}
					save_scope_as = friends_child
				}	
			}
			random_attending_character = {
				limit = {
					this != scope:friends_child
					this != root
					is_ai = yes
					OR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
					is_in_guest_subset = { name = entrants }
				}
				save_scope_as = child
			}
		}
	}

	option = {
		name = imperial_examination_jay.0010.a

		reverse_add_opinion = {
			target = scope:friend
			modifier = befriended_opinion
			opinion = 30
		}
		set_relation_friend = {
			target = scope:friend
			reason = friend_bonded_over_children
		}

		stress_impact = {
			base = medium_stress_impact_loss
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 150
			modifier = {
				has_trait = shy
				add = -50
			}
			modifier = {
				has_trait = gregarious
				add = 25
			}
			modifier = {
				number_of_personality_traits_in_common = {
					target = scope:friend
					value = 2
				}
				add = 25
			}
			modifier = {
				number_of_personality_traits_in_common = {
					target = scope:friend
					value >= 3
				}
				add = 50
			}
			modifier = {
				scope:friend = {
					number_of_opposing_personality_traits = {
						target = root
						value >= 1
					}
				}
				add = -50
			}
			modifier = {
				scope:friend = {
					number_of_opposing_personality_traits = {
						target = root
						value >= 2
					}
				}
				add = -50
			}
			# More likely if you already have few friends
			modifier = {
				any_relation = {
					type = friend
					count = 0
				}
				add = 50
			}
			modifier = {
				any_relation = {
					type = friend
					count = 1
				}
				add = 25
			}
			modifier = {
				any_relation = {
					type = friend
					count = 3
				}
				add = -25
			}
			modifier = {
				any_relation = {
					type = friend
					count >= 4
				}
				add = -50
			}
		}
	}

	option = {
		name = imperial_examination_jay.0010.b
		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
		scope:child = {
			progress_towards_friend_effect = {
				REASON = friend_parents_introduced
				CHARACTER = scope:friends_child
				OPINION = 30
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				OR = {
					scope:friends_child = { has_trait = gregarious }
					scope:child = { has_trait = gregarious }
				}
				add = 50
			}
			modifier = {
				OR = {
					scope:friends_child = {
						has_trait = shy
						has_trait = reclusive
					}
					scope:child = {
						has_trait = shy
						has_trait = reclusive
					}
				}
				add = -50
			}
			modifier = {
				OR = {
					scope:child = {
						any_relation = {
							type = friend
							count = 0
						}
					}
					scope:friends_child = {
						any_relation = {
							type = friend
							count = 0
						}
					}
				}
				factor = 2
			}
			modifier = {
				OR = {
					scope:child = {
						any_relation = {
							type = friend
							count >= 4
						}
					}
					scope:friends_child = {
						any_relation = {
							type = friend
							count >= 4
						}
					}
				}
				factor = 0
			}
		}
	}

	option = {
		name = imperial_examination_jay.0010.c
		reverse_add_opinion = {
			target = scope:friend
			modifier = friendly_interaction
			opinion = 15
		}
		change_merit = minor_merit_gain
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				add = 50
			}
			modifier = {
				has_trait = august
				add = 50
			}
			modifier = {
				has_trait = shy
				add = 50
			}
			# More likely if you already have a lot of friends
			modifier = {
				any_relation = {
					type = friend
					count >= 2
				}
				add = 50
			}
			modifier = {
				any_relation = {
					type = friend
					count >= 3
				}
				add = 50
			}
			modifier = {
				any_relation = {
					type = friend
					count >= 4
				}
				add = 100
			}
		}
	}
}

# You witness upon another parent bribing an Examiner
# For Family
imperial_examination_jay.0040 = {
	type = activity_event
	title = imperial_examination_jay.0040.t
	desc = imperial_examination_jay.0040.desc
	theme = imperial_examination
	override_background = { reference = garden }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = just
					has_trait = honest
				}
			}
			animation = shock
		}
		animation = interested
		camera = camera_event_left_away_3_4_small
	}

	center_portrait = {
		character = scope:parent
		animation = interested
		camera = camera_event_center_background_crowd_left
	}

	right_portrait = {
		character = scope:examiner
		animation = chancellor
		camera = camera_event_center_background_crowd_right
	}

	lower_right_portrait = scope:cheater_child

	lower_left_portrait = scope:child

	cooldown = { months = 6 }

	trigger = {
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_imperial_examination }
			}
			has_activity_intent = imperial_exam_support_entrants_intent
		}
		trigger_else = {
			has_activity_intent = local_exam_support_entrants_intent
		}
		scope:activity = {
			any_attending_character = {
				is_ai = yes
				NOR = {
					this = scope:activity.activity_host
					is_in_guest_subset = { name = entrants }
					is_in_guest_subset = { name = imperial_examiners }
				}
				any_child = {
					involved_activity = scope:activity
					is_in_guest_subset = { name = entrants }
					is_ai = yes
				}
			}
			any_attending_character = {
				is_ai = yes
				OR = {
					is_child_of = root
					has_relation_disciple = root
				}
				is_in_guest_subset = { name = entrants }
			}
			any_guest_subset = {
				name = imperial_examiners
				count >= 1
				is_ai = yes
				this != scope:activity.activity_host
				trigger_if = {
					limit = { 
						root = { has_variable = discovering_examiner }
					}
					NOT = { this = root.var:discovering_examiner }
				}
				trigger_else = { always = yes }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				has_trait = shy
				has_trait = patient
			}
			add = 1
		}
		modifier = {
			scope:activity = {
				any_guest_subset = {
					name = entrants
					has_variable = parent_has_bribed_examiner
					count = all
				}
			}
			add = 1
		}
	}

	immediate = {
		scope:activity = {
			random_guest_subset = {
				name = imperial_examiners
				limit = {
					is_ai = yes
					this != scope:activity.activity_host
					trigger_if = {
						limit = { 
							root = { has_variable = discovering_examiner }
						}
						NOT = { this = root.var:discovering_examiner }
					}
					trigger_else = { always = yes }
				}
				weight = {
					base = 1
					modifier = {
						has_trait = arbitrary
						add = 2
					}
					modifier = {
						has_trait = greedy
						add = 2
					}
					modifier = {
						has_trait = deceitful
						add = 2
					}
					modifier = {
						has_trait = schemer
						add = 2
					}
					modifier = {
						has_trait = just
						add = -5
					}
					modifier = {
						has_trait = honest
						add = -2
					}
					modifier = {
						intrigue >= high_skill_rating # Should be a lot better at hiding this
						add = -5
					}
				}
				save_scope_as = examiner
			}
			random_attending_character = {
				limit = {
					is_ai = yes
					NOR = {
						this = scope:activity.activity_host
						is_in_guest_subset = { name = entrants }
						is_in_guest_subset = { name = imperial_examiners }
					}
					any_child = {
						involved_activity = scope:activity
						is_in_guest_subset = { name = entrants }
						is_ai = yes
					}
				}
				weight = {
					base = 1
					modifier = {
						has_trait = arbitrary
						add = 2
					}
					modifier = {
						has_trait = greedy
						add = 2
					}
					modifier = {
						has_trait = deceitful
						add = 2
					}
					modifier = {
						has_trait = schemer
						add = 2
					}
					modifier = {
						has_trait = just
						add = -2
					}
					modifier = {
						has_trait = honest
						add = -5
					}
					modifier = {
						intrigue >= high_skill_rating
						add = -5
					}
				}
				save_scope_as = parent
			}
			ordered_attending_character = {
				limit = {
					is_in_guest_subset = { name = entrants }
					is_child_of = scope:parent
					is_ai = yes
				}
				save_scope_as = cheater_child

				order_by = { # Grab the worst of the available kids
					value = 1
					add = {
						value = imperial_examination_score_value
						multiply = -1
					}
				}
				set_variable = {
					name = parent_has_bribed_examiner
					value = scope:examiner
				}
			}
			random_attending_character = {
				limit = {
					is_ai = yes
					OR = {
						is_child_of = root
						has_relation_disciple = root
					}
					is_in_guest_subset = { name = entrants }
				}
				save_scope_as = child
			}
		}
	}

	option = { # Get in on the action
		name = imperial_examination_jay.0040.a
		scope:child = {
			set_variable = {
				name = parent_has_bribed_examiner
				value = scope:examiner
			}
		}
		custom_tooltip = imperial_examination.cheat.child.tt
		change_merit = medium_merit_loss

		stress_impact = {
			just = medium_stress_impact_gain
			honest = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					has_trait = just
				}
			}
			modifier = {
				factor = 2
				has_trait = schemer
			}
		}
	}

	option = { # Reveal the cheaters
		name = imperial_examination_jay.0040.b
		trigger = {
			intrigue >= high_skill_rating
			can_add_hook = {
				target = scope:parent
				type = weak_blackmail_hook_no_secret
			}
			can_add_hook = {
				target = scope:examiner
				type = weak_blackmail_hook_no_secret
			}
		}
		add_internal_flag = special
		add_hook = {
			target = scope:parent
			type = weak_blackmail_hook_no_secret
		}
		add_hook = {
			target = scope:examiner
			type = weak_blackmail_hook_no_secret
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
			}
			modifier = {
				factor = 2
				OR = {
					has_trait = honest
					has_trait = just
				}
			}
		}
	}

	option = { # I'll wait for them to leave and get back to relaxing
		name = imperial_examination_jay.0040.c

		stress_impact = {
			base = medium_stress_impact_loss
			lazy = minor_stress_impact_loss
			honest = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = 50
				OR = {
					has_trait = honest
					has_trait = just
				}
			}
		}
	}

	after = {
		involved_activity = {
			if = {
				limit = {
					NOT = {
						any_guest_subset = {
							name = imperial_examiners
							this = scope:examiner
						}
					}
				}
				imperial_examination_create_appropriate_examiner_effect = yes
				scope:new_examiner = {
					add_to_activity = involved_activity
				}
				add_to_guest_subset = {
					name = imperial_examiners
					target = scope:new_examiner
				}
			}
		}
	}
}

# An Examiner trips and falls
# For Family
imperial_examination_jay.0080 = {
	type = activity_event
	title = imperial_examination_jay.0080.t
	desc = imperial_examination_jay.0080.desc
	theme = imperial_examination
	override_background = { reference = corridor_day }

	left_portrait = {
		character = root
		animation = shock
		camera = camera_event_left_pointing_back_fov20
	}

	right_portrait = {
		character = scope:examiner
		animation = beg
		camera = camera_event_ground_back
	}

	lower_left_portrait = {
		character = scope:child
	}

	cooldown = { months = 6 }

	trigger = {
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_imperial_examination }
			}
			has_activity_intent = imperial_exam_support_entrants_intent
		}
		trigger_else = {
			has_activity_intent = local_exam_support_entrants_intent
		}
		involved_activity = {
			any_attending_character = {
				is_ai = yes
				this != root
				OR = {
					is_close_or_extended_family_of = root
					has_relation_disciple = root
					this = root.primary_spouse
				}
				is_in_guest_subset = { name = entrants }
			}
			any_guest_subset = {
				name = imperial_examiners
				is_ai = yes
				this != root
			}
		}
	}

	immediate = {
		involved_activity = {
			random_guest_subset = {
				name = entrants
				limit = {
					is_ai = yes
					this != root
					OR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
				}
				save_scope_as = child
			}
			random_guest_subset = {
				name = imperial_examiners
				limit = {
					is_ai = yes
					this != root
				}
				save_scope_as = examiner
			}
		}
	}

	option = { # Haha, lol, lmao
		name = imperial_examination_jay.0080.c

		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
				has_trait = torturer
			}
		}

		trait = callous
		trait = sadistic
		trait = torturer

		add_prestige = minor_prestige_gain

		scope:examiner = {
			progress_towards_rival_effect = {
				CHARACTER = root
				OPINION = -20
				REASON = rival_laughed_at_misfortune
			}
		}

		scope:child = {
			custom_tooltip = imperial_examination.lose_advantage.child.tt
			imperial_examination_adjust_advantage_variable_neg_effect = yes
		}

		stress_impact = {
			base = major_stress_impact_loss
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 0
			modifier = {
				has_trait = callous
				add = 50
			}
			modifier = {
				has_trait = sadistic
				add = 50
			}
			modifier = {
				has_trait = torturer
				add = 50
			}
			modifier = {
				has_trait = compassionate
				factor = 0
			}
		}
	}

	option = { # Destroy a test
		name = imperial_examination_jay.0080.a

		duel = {
			skill = intrigue
			target = scope:examiner
			50 = { # Unnoticed
				desc = imperial_examination_jay.0080.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				root = {
					send_interface_toast = {
						title = imperial_examination_jay.0080.a.success
						type = event_intrigue_good
						left_icon = scope:child
						right_icon = scope:examiner

						scope:child = {
							custom_tooltip = imperial_examination.advantage.child.tt
							imperial_examination_adjust_advantage_variable_effect = yes
						}

						scope:examiner = {
							change_merit = minor_merit_loss
						}
					}
				}
			}
			50 = { # Caught
				desc = imperial_examination_jay.0080.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				root = {
					send_interface_toast = {
						title = imperial_examination_jay.0080.a.failure
						type = event_intrigue_bad
						left_icon = root
						right_icon = scope:examiner

						scope:child = {
							custom_tooltip = imperial_examination.lose_advantage.child.tt
							imperial_examination_adjust_advantage_variable_neg_effect = yes
						}

						change_merit = minor_merit_loss

						involved_activity = {
							every_attending_character = {
								custom = every_examiner
								limit = {
									this != root
									is_in_guest_subset = { name = imperial_examiners }
								}
								add_opinion = {
									modifier = angry_opinion
									target = root
									opinion = -25
								}
							}
						}
					}
				}
			}
		}

		stress_impact = {
			honest = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = just
				factor = 0.5
			}
			modifier = {
				has_trait = honest
				factor = 0.5
			}
			modifier = {
				OR = {
					has_trait = deceitful
					has_trait = schemer
				}
				factor = 2
			}
		}
	}

	option = { # Help them up
		name = imperial_examination_jay.0080.b

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

		scope:child = {
			custom_tooltip = imperial_examination.lose_advantage.child.tt
			imperial_examination_adjust_advantage_variable_neg_effect = yes
		}

		stress_impact = {
			arrogant = minor_stress_impact_gain
			sadistic = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 125
			modifier = {
				has_trait = compassionate
				factor = 2
			}
			modifier = {
				OR = {
					has_trait = sadistic
					has_trait = callous
				}
				factor = 0
			}
			modifier = {
				has_trait = arrogant
				factor = 0.5
			}
		}
	}
}

# A greedy Examiner fishes for a bribe
# For Family
imperial_examination_jay.0110 = {
	type = activity_event
	title = imperial_examination_jay.0110.t
	desc = imperial_examination_jay.0110.desc
	theme = imperial_examination

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = greedy
					has_trait = arbitrary
					has_trait = schemer
					has_trait = deceitful
				}
			}
			animation = interested
		}
		animation = eyeroll
	}

	right_portrait = {
		character = scope:examiner
		animation = storyteller
	}

	lower_left_portrait = {
		character = scope:child
	}

	cooldown = { months = 6 }

	override_background = { reference = tavern }

	trigger = {
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_imperial_examination }
			}
			has_activity_intent = imperial_exam_support_entrants_intent
		}
		trigger_else = {
			has_activity_intent = local_exam_support_entrants_intent
		}
		involved_activity = {
			any_guest_subset = {
				name = entrants
				is_ai = yes
				OR = {
					is_close_or_extended_family_of = root
					has_relation_disciple = root
					this = root.primary_spouse
				}
			}
			any_guest_subset = {
				name = imperial_examiners
				this != root
				is_ai = yes
				ai_greed > 0
			}
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			random_guest_subset = {
				name = entrants
				limit = {
					is_ai = yes
					OR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
				}
				save_scope_as = child
			}
			random_guest_subset = {
				name = imperial_examiners
				limit = {
					this != root
					is_ai = yes
					ai_greed > 0
				}
				weight = {
					base = 1
					modifier = {
						has_trait = arbitrary
						add = 1
					}
					modifier = {
						has_trait = arrogant
						add = 2
					}
					modifier = {
						has_trait = greedy
						add = 3
					}
					modifier = {
						has_trait = humble
						add = -2
					}
					modifier = {
						has_trait = just
						add = -3
					}
					modifier = {
						has_trait = honest
						add = -5
					}
				}
				save_scope_as = examiner
			}
		}
	}

	option = { # Bribe them
		name = imperial_examination_jay.0110.a

		pay_short_term_gold = {
			target = scope:examiner
			gold = major_gold_value
		}

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

		scope:child = {
			set_variable = {
				name = parent_has_bribed_examiner
				value = scope:examiner
			}
		}

		custom_tooltip = imperial_examination.cheat.child.tt

		stress_impact = {
			just = medium_stress_impact_gain
			greedy = minor_stress_impact_gain
			honest = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			modifier = {
				has_trait = arbitrary
				add = 50
			}
			modifier = {
				has_trait = just
				factor = 0
			}
			modifier = {
				has_trait = honest
				factor = 0.5
			}
			modifier = {
				has_trait = greedy
				factor = 0.5
			}
			modifier = {
				short_term_gold < major_gold_value
				factor = 0.5
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	option = {
		name = imperial_examination_jay.0110.b
		custom_tooltip = imperial_examination_jay.0110.b.tt
		# Take the artifact.
 		hidden_effect = {
 			create_artifact = {
				name = bribed_necklace_name
				description = bribed_necklace_desc
				modifier = artifact_monthly_minor_prestige_4_modifier
				visuals = necklace
				type = miscellaneous
				save_scope_as = bribed_necklace
			}
 		}
	    send_interface_toast = {
			title = imperial_examination_jay.0110.b.equipped_tt
		    left_icon = root
		    right_icon = scope:bribed_necklace
		    scope:bribed_necklace = {
		    	set_variable = {
					name = suppress_artifact_notifications
					value = yes
					days = 1
				}
		        set_owner = {
		        	target = root
					history = {
						location = root.capital_province
						actor = scope:examiner
						recipient = root
						type = given
					}
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}

	option = { # Ignore them
		name = imperial_examination_jay.0110.c

		add_prestige = minor_prestige_gain

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

		ai_chance = {
			base = 100
			modifier = {
				has_trait = shy
				add = 50
			}
			modifier = {
				has_trait = ambitious
				add = -25
			}
		}
	}
}

# An Examiner sees promise in your child
# For Family
imperial_examination_jay.0120 = {
	type = activity_event
	title = imperial_examination_jay.0120.t
	desc = imperial_examination_jay.0120.desc
	theme = imperial_examination

	left_portrait = {
		character = root
		animation = interested
	}

	right_portrait = {
		character = scope:examiner
		animation = obsequious_bow
	}

	lower_left_portrait = {
		character = scope:child
	}

	cooldown = { months = 6 }

	trigger = {
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_imperial_examination }
			}
			has_activity_intent = imperial_exam_support_entrants_intent
		}
		trigger_else = {
			has_activity_intent = local_exam_support_entrants_intent
		}
		involved_activity = {
			any_guest_subset = {
				name = entrants
				is_ai = yes
				OR = {
					is_close_or_extended_family_of = root
					has_relation_disciple = root
					this = root.primary_spouse
				}
				sum_of_all_skills_value >= sum_of_all_skills_threshold_good
			}
			any_guest_subset = {
				name = imperial_examiners
				is_ai = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			involved_activity = {
				any_guest_subset = {
					name = entrants
					is_ai = yes
					OR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
					sum_of_all_skills_value >= sum_of_all_skills_threshold_excellent
				}
			}
			add = 1
		}
	}

	immediate = {
		involved_activity = {
			ordered_guest_subset = {
				name = entrants
				limit = {
					is_ai = yes
					OR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
					sum_of_all_skills_value >= sum_of_all_skills_threshold_good
				}
				order_by = sum_of_all_skills_value
				save_scope_as = child
			}
			random_guest_subset = {
				name = imperial_examiners
				limit = {
					is_ai = yes
				}
				weight = { # Prefer skilled characters you'd actually want as a mentor
					base = 1
					modifier = {
						add = sum_of_all_skills_value
					}
					modifier = {
						add = "opinion(scope:child)"
					}
					modifier = {
						has_trait = confucian_education
						add = 10
					}
				}
				save_scope_as = examiner
				hidden_effect = {
					add_opinion = {
						target = scope:child
						modifier = impressed_opinion
						opinion = 30
					}
				}
			}
		}
	}

	option = { # Talk up the house
		name = imperial_examination_jay.0120.a

		trigger = {
			house = { has_house_power_parameter = learned_philosophers }
		}

		reason = learned_philosophers_attribute

		house = {
			add_house_modifier = {
				modifier = tgp_studious_house_modifier
				years = 10
			}
		}

		stress_impact = {
			humble = medium_stress_impact_gain
		}

		ai_chance = {
			base = 200
			modifier = {
				has_trait = family_first
				add = 50
			}
			modifier = {
				has_trait = humble
				add = -100
			}
		}
	}

	option = { # Ask them to mentor your child
		name = imperial_examination_jay.0120.b

		trigger = {
			scope:examiner = {
				NOT = { has_relation_disciple = scope:child }
				merit_level >= scope:child.merit_level
			}
		}

		set_elder_relation_no_breakup_effect = {
			ELDER = scope:examiner
			DISCIPLE = scope:child
		}

		scope:examiner = {
			add_opinion = {
				target = root
				modifier = honored_opinion
				opinion = 30
			}
			add_prestige = medium_prestige_gain
		}

		ai_chance = {
			base = 100

			modifier = {
				scope:examiner = {
					sum_of_all_skills_value >= sum_of_all_skills_threshold_excellent
				}
				factor = 2
			}
			modifier = {
				scope:child = {
					any_relation = { type = elder }
				}
				factor = 0.5
			}
		}
	}

	option = { # Praise your child
		name = imperial_examination_jay.0120.c

		scope:child = {
			add_opinion = {
				target = root
				modifier = supportive_parent
				opinion = 20
			}
			progress_towards_friend_effect = {
				REASON = friend_supportive_parent
				CHARACTER = root
				OPINION = 0
			}
			stress_impact = {
				base = medium_stress_impact_loss
			}
		}

		stress_impact = {
			callous = medium_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = compassionate
				add = 25
			}
			modifier = {
				has_trait = gregarious
				add = 25
			}
			modifier = {
				has_trait = family_first
				add = 25
			}
			modifier = {
				has_trait = sadistic
				factor = 0.5
			}
			modifier = {
				has_trait = callous
				factor = 0.25
			}
		}
	}

	option = { # Spread their name
		name = imperial_examination_jay.0120.d

		scope:child = {
			add_character_modifier = {
				modifier = tgp_known_prodigy_modifier
				years = 5
			}
			change_merit = medium_merit_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				add = 25
			}
			modifier = {
				has_activity_intent = imperial_exam_support_entrants_intent
				factor = 1.5
			}
			modifier = {
				has_trait = humble
				factor = 0.5
			}
		}
	}
}

# An Examiner shows your family favoritism
# For Family
imperial_examination_jay.0170 = {
	type = activity_event
	title = imperial_examination_jay.0170.t
	desc = imperial_examination_jay.0170.desc
	theme = imperial_examination
	override_background = { reference = garden }

	left_portrait = {
		character = root
		animation = interested
		camera = camera_event_left_pointing_right
	}

	center_portrait = {
		character = scope:examiner
		animation = admiration
		camera = camera_event_right_pointing_right
	}

	right_portrait = {
		character = scope:parent
		animation = disapproval
		camera = camera_event_very_right_fov35
	}

	lower_left_portrait = {
		character = scope:child
	}

	cooldown = { months = 6 }

	trigger = {
		trigger_if = {
			limit = {
				scope:activity = { has_activity_type = activity_imperial_examination }
			}
			has_activity_intent = imperial_exam_support_entrants_intent
		}
		trigger_else = {
			has_activity_intent = local_exam_support_entrants_intent
		}
		involved_activity = {
			any_guest_subset = {
				name = entrants
				OR = {
					is_close_or_extended_family_of = root
					has_relation_disciple = root
					this = root.primary_spouse
				}
				is_ai = yes
				house = root.house
			}
			any_guest_subset = {
				name = imperial_examiners
				this != root
				is_ai = yes
				NOT = { has_trait = just }
			}
			any_attending_character = {
				this != root
				has_activity_intent = exam_assist_exam_intent
			}
		}
	}

	immediate = {
		involved_activity = {
			save_scope_as = activity
			random_guest_subset = {
				name = entrants
				limit = {
					is_ai = yes
					OR = {
						is_close_or_extended_family_of = root
						has_relation_disciple = root
						this = root.primary_spouse
					}
					house = root.house
				}
				save_scope_as = child
			}
			random_guest_subset = {
				name = imperial_examiners
				limit = {
					is_ai = yes
					this != root
					NOT = { has_trait = just }
				}
				weight = {
					base = 1
					modifier = {
						opinion = {
							target = root
							value >= 25
						}
						add = 1
					}
					modifier = {
						opinion = {
							target = root
							value >= 50
						}
						add = 1
					}
					modifier = {
						opinion = {
							target = root
							value >= 75
						}
						add = 1
					}
					modifier = {
						has_trait = arbitrary
						factor = 2
					}
				}
				save_scope_as = examiner
			}
			random_attending_character = {
				limit = {
					is_ai = yes
					has_activity_intent = exam_assist_exam_intent
				}
				save_scope_as = parent
			}
		}
	}

	option = { # Publicly admonish them
		name = imperial_examination_jay.0170.a

		change_influence = medium_influence_gain

		involved_activity = {
			every_attending_character = {
				limit = {
					NOR = {
						is_in_guest_subset = { name = entrants }
						this = scope:examiner
						this = root
					}
					OR = {
						any_child = {
							involved_activity ?= { this = scope:activity }
							is_in_guest_subset = { name = entrants }
						}
						any_relation = {
							type = disciple
							involved_activity ?= { this = scope:activity }
							is_in_guest_subset = { name = entrants }
						}
					}
				}
				custom = every_attending_chaperone
				add_opinion = {
					modifier = respect_opinion
					target = root
					opinion = 15
				}
			}
		}

		scope:examiner = {
			change_merit = medium_merit_loss
			add_opinion = {
				target = root
				modifier = humiliated_opinion
				opinion = -30
			}
		}

		stress_impact = {
			arbitrary = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = arbitrary
				add = -50
			}
			modifier = {
				has_trait = shy
				add = -50
			}
			modifier = {
				has_trait = just
				factor = 2
			}
		}
	}

	option = { # Encourage the favoritism
		name = imperial_examination_jay.0170.c

		custom_tooltip = imperial_examination.advantage.child.tt

		involved_activity = {
			every_attending_character = {
				limit = {
					NOR = {
						is_in_guest_subset = { name = entrants }
						is_in_guest_subset = { name = imperial_examiners }
						this = root
					}
					OR = {
						any_child = {
							involved_activity ?= { this = scope:activity }
							is_in_guest_subset = { name = entrants }
						}
						any_relation = {
							type = disciple
							involved_activity ?= { this = scope:activity }
							is_in_guest_subset = { name = entrants }
						}
					}
				}
				custom = every_attending_chaperone
				add_opinion = {
					modifier = irritated_opinion
					target = root
					opinion = -15
				}
			}
		}

		change_merit = minor_merit_loss

		stress_impact = {
			honest = medium_stress_impact_gain
			just = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = just
				add = -50
			}
			modifier = {
				has_trait = honest
				add = -50
			}
			modifier = {
				has_trait = humble
				add = -25
			}
			modifier = {
				has_trait = arrogant
				add = 50
			}
		}
	}

	option = { # My child doesn't need your help!
		name = imperial_examination_jay.0170.b

		custom_tooltip = imperial_examination_jay.0170.b.tt

		scope:child = {
			add_character_flag = examination_prestige_reward
		}

		stress_impact = {
			humble = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = humble
				add = -25
			}
			modifier = {
				has_trait = arrogant
				factor = 2
			}
		}
	}
}
