namespace = jester

jester.100 = { # My Rival Fool, Covered in Stool
	type = character_event
	title = jester.100.t
	desc = jester.100.desc
	theme = friendly
	left_portrait = {
		character = root
		animation = ecstasy
	}
	right_portrait = {
		character = scope:jester
		animation = rage
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_court_position_holder = {
			type = court_jester_court_position
			has_relation_rival = root
		}
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		scope:jester = {
			add_character_modifier = {
				modifier = covered_in_feces
				years = 10
			}
		}
	}

	option = {
		name = jester.100.a
		
		stress_impact = {
			base = major_stress_impact_loss
			vengeful = major_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
	}
}

jester.200 = { # Laughter is the Best Medicine
	type = character_event
	title = jester.200.t
	desc = jester.200.desc
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = laugh
	}
	right_portrait = {
		character = scope:jester
		animation = storyteller
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
	}

	option = {
		name = jester.200.a
		
		stress_impact = {
			base = -20
			diligent = 19
		}
		random = {
			chance = 1
			death = {
				death_reason = death_laughter
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = diligent
			}
		}
	}

	option = {
		name = jester.200.b
		
		stress_impact = {
			base = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = lazy
			}
		}
	}
}

jester.300 = { # Masterful Juggling
	type = character_event
	title = jester.300.t
	desc = {
		desc = jester.300.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:child_to_juggle
				}
				desc = jester.300.desc_child
			}
			desc = SCOPE_EMPTY
		}
		desc = jester.300.desc_2
	}
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = throne_room_applaud_1
	}
	right_portrait = {
		character = scope:jester
		animation = throne_room_cheer_2
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_court_position_holder = {
			type = court_jester_court_position
			aptitude:court_jester_court_position >= 3
			NOR = {
				has_trait = infirm
				has_trait = maimed
				has_trait = one_legged
				has_trait = gout_ridden
				has_trait = blind
				has_trait = physique_bad
				has_trait = weak
			}
		}
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		if = {
			limit = {
				any_courtier_or_guest = {
					age <= 2
				}
			}
			random_courtier_or_guest = {
				limit = {
					age <= 2
				}
				save_scope_as = child_to_juggle
			}
		}
	}

	option = {
		name = jester.300.a
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.300.b
		trigger = {
			exists = scope:child_to_juggle
		}
		
		stress_impact = {
			base = medium_stress_impact_gain
			sadistic = massive_stress_impact_loss
		}
		rightfully_imprison_character_effect = {
			TARGET = scope:jester
			IMPRISONER = root
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOT = {
					has_trait = sadistic
				}
			}
		}
	}
}

jester.400 = { # A Flatulist and a Gentleman
	type = character_event
	title = jester.400.t
	desc = jester.400.desc
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = laugh
	}
	right_portrait = {
		character = scope:jester
		animation = storyteller
	}
	
	cooldown = { years = 50 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_court_position_holder = {
			type = court_jester_court_position
			NOT = {
				has_trait = blind
			}
		}
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
			# Roll for theme.
			select_poem_theme_random_effect = yes
			# Set up a subject gender.
			select_poem_subject_gender_effect = {
				SUBJECT = flag:no
				SUBJECT_TARGET = root
			}
		}
	}

	option = {
		name = jester.400.a
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 75
		}
	}

	option = {
		name = jester.400.b
		
		stress_impact = {
			base = miniscule_stress_impact_loss
		}
		add_character_modifier = {
			modifier = aspiring_flatulist
			years = 10
		}
		ai_chance = {
			base = 25
		}
	}
}

jester.500 = { # Clothes Thief
	type = character_event
	title = jester.500.t
	desc = jester.500.desc
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = scope:courtier
		animation = aggressive_axe
	}
	right_portrait = {
		character = scope:jester
		animation = laugh
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 5
			}
		}
	}
	
	trigger = {
		NOT = {
			faith = {
				has_doctrine = tenet_natural_primitivism #Nakedness is not a notable thing
			}
		}
		any_courtier_or_guest = {
			is_available_ai_adult = yes
			age >= 18
			NOT = {
				has_court_position = court_jester_court_position
			}
		}
	}

	immediate = {
		save_scope_as = you
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		random_courtier_or_guest = {
			limit = {
				is_available_ai_adult = yes
				age >= 18
				NOT = {
					has_court_position = court_jester_court_position
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_minor_interest_to_root_trigger = yes
				}
				modifier = {
					add = 100
					sex_same_as = scope:jester
				}
				modifier = {
					add = 100
					has_relation_rival = root
				}
			}
			save_scope_as = courtier
			add_character_modifier = {
				modifier = diplomacy_majesty_4090_no_raiment_modifier
				years = 5
			}
			progress_towards_rival_effect = {
				REASON = rival_clothes_stolen
				CHARACTER = scope:jester
				OPINION = 0
			}
		}
	}

	option = {
		name = jester.500.a
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 75
		}
	}

	option = {
		name = jester.500.b
		
		stress_impact = {
			base = miniscule_stress_impact_loss
		}
		scope:jester = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -5
			}
		}
		scope:courtier = {
			remove_character_modifier = diplomacy_majesty_4090_no_raiment_modifier
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 15
			}
		}
		ai_chance = {
			base = 25
		}
	}
}

jester.600 = { # Food Fight
	type = character_event
	title = jester.600.t
	desc = jester.600.desc
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = scope:courtier
		animation = disgust
	}
	right_portrait = {
		character = scope:jester
		animation = wrestling_victory
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_courtier_or_guest = {
			is_available_ai_adult = yes
			NOT = {
				has_court_position = court_jester_court_position
			}
		}
		any_court_position_holder = {
			type = court_jester_court_position
			NOT = {
				has_trait = blind
			}
		}
	}

	immediate = {
		save_scope_as = you
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		random_courtier_or_guest = {
			limit = {
				is_available_ai_adult = yes
				NOT = {
					has_court_position = court_jester_court_position
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = courtier
		}
	}

	option = {
		name = jester.600.a
		
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.600.b
		
		stress_impact = {
			base = miniscule_stress_impact_loss
		}
		scope:courtier = {
			progress_towards_friend_effect = {
				CHARACTER = root
				REASON = friend_helped_after_food_fight
				OPINION = 0
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.600.c
		trigger = {
			scope:jester = {
				NOT = {
					has_relation_rival = scope:courtier
				}
			}
		}
		
		stress_impact = {
			base = medium_stress_impact_gain
			sadistic = massive_stress_impact_loss
		}
		scope:jester = {
			increase_wounds_effect = { REASON = fight }
		}
		scope:courtier = {
			set_relation_rival = {
				target = scope:jester
				reason = rival_food_fight
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOT = {
					has_trait = sadistic
				}
			}
		}
	}
}

jester.700 = { # Sunday Roast
	type = character_event
	title = jester.700.t
	desc = jester.700.desc
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = scope:courtier
		animation = pain
	}
	right_portrait = {
		character = scope:jester
		animation = debating
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_courtier_or_guest = {
			is_available_ai_adult = yes
			NOR = {
				has_court_position = court_jester_court_position
				is_close_family_of = root
				is_consort_of = root
			}
		}
	}

	immediate = {
		save_scope_as = you
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		random_courtier_or_guest = {
			limit = {
				is_available_ai_adult = yes
				NOR = {
					has_court_position = court_jester_court_position
					is_close_family_of = root
					is_consort_of = root
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = courtier
			scope:courtier = {
				add_prestige = medium_prestige_loss
			}
		}
	}

	option = {
		name = jester.700.a
		
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.700.b
		
		stress_impact = {
			base = miniscule_stress_impact_loss
		}
		scope:courtier = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		ai_chance = {
			base = 100
		}
	}
}

jester.800 = { # Slapstick
	type = character_event
	title = jester.800.t
	desc = {
		desc = jester.800.desc
		random_valid = {
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						is_equipped = yes
						artifact_slot_type = sculpture
					}
				}
				desc = fall_into_sculpture
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						is_equipped = yes
						artifact_slot_type = sculpture
					}
				}
				desc = somersault_into_sculpture
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						artifact_slot_type = primary_armament
					}
				}
				desc = weapon_pratfall
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						artifact_slot_type = primary_armament
					}
				}
				desc = weapon_plummet
			}
			desc = faceplant
			desc = walk_into_wall
			desc = forceful_tumble
		}
		desc = jester.800.desc_2
		random_valid = {
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						is_equipped = yes
						artifact_slot_type = sculpture
					}
				}
				desc = fall_into_sculpture
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						is_equipped = yes
						artifact_slot_type = sculpture
					}
				}
				desc = somersault_into_sculpture
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						artifact_slot_type = primary_armament
					}
				}
				desc = weapon_pratfall
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						artifact_slot_type = primary_armament
					}
				}
				desc = weapon_plummet
			}
			desc = faceplant
			desc = walk_into_wall
			desc = forceful_tumble
		}
		desc = jester.800.desc_3
		random_valid = {
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						is_equipped = yes
						artifact_slot_type = sculpture
					}
				}
				desc = fall_into_sculpture
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						is_equipped = yes
						artifact_slot_type = sculpture
					}
				}
				desc = somersault_into_sculpture
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						artifact_slot_type = primary_armament
					}
				}
				desc = weapon_pratfall
			}
			triggered_desc = {
				trigger = {
					any_character_artifact = {
						artifact_slot_type = primary_armament
					}
				}
				desc = weapon_plummet
			}
			desc = faceplant
			desc = walk_into_wall
			desc = forceful_tumble
		}
		desc = jester.800.desc_4
	}
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = laugh
	}
	right_portrait = {
		character = scope:jester
		animation = wrestling_yield_start
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		if = {
			limit = {
				any_character_artifact = {
					is_equipped = yes
					artifact_slot_type = sculpture
				}
			}
			random_character_artifact = {
				limit = {
					is_equipped = yes
					artifact_slot_type = sculpture
				}
				save_scope_as = furniture_to_crash_into
			}
		}
		if = {
			limit = {
				any_character_artifact = {
					artifact_slot_type = primary_armament
				}
			}
			random_character_artifact = {
				limit = {
					artifact_slot_type = primary_armament
				}
				save_scope_as = weapon_pratfall
			}
		}
	}

	option = {
		name = jester.800.a
		
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.800.b
		
		stress_impact = {
			base = miniscule_stress_impact_loss
			compassionate = major_stress_impact_gain
			sadistic = massive_stress_impact_loss
		}
		
		scope:jester = {
			add_opinion = {
				target = root
				modifier = scared_opinion
				opinion = -25
			}
			increase_wounds_effect = { REASON = fall }
			hidden_effect = {
				random = {
					chance = 25
					increase_wounds_effect = { REASON = fall }
				}
			}
		}
		
		if = {
			limit = {
				exists = scope:furniture_to_crash_into
			}
			scope:furniture_to_crash_into = {
				add_durability = -5
			}
		}
		
		if = {
			limit = {
				exists = scope:weapon_pratfall
			}
			scope:weapon_pratfall = {
				add_durability = -5
			}
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOT = {
					has_trait = sadistic
				}
			}
		}
	}
}

jester.900 = { # Several Fools in One Coat
	type = character_event
	title = jester.900.t
	desc = {
		desc = jester.900.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:cat_story
				}
				desc = jester.900.cat
			}
			triggered_desc = {
				trigger = {
					exists = scope:dog_story
				}
				desc = jester.900.dog
			}
			triggered_desc = {
				trigger = {
					exists = scope:bird
				}
				desc = jester.900.bird
			}
			triggered_desc = {
				trigger = {
					exists = scope:eagle_story
				}
				desc = jester.900.eagle
			}
		}
	}
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:jester
		animation = ecstasy
	}
	
	cooldown = { years = 50 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		
		random_list = {
			30 = { # A bird of some sort
				save_scope_value_as = {
					name = bird
					value = yes
				}
			}
			10 = { # An eagle
				trigger = {
					location = { geographical_region = world_steppe }
					NOR = {
						has_eagle_trigger = yes
						has_character_modifier = eagle_story_modifier
					}
				}
				save_scope_value_as = {
					name = eagle_story
					value = yes
				}
			}
			10 = { # A catto
				trigger = {
					NOR = {
						any_owned_story = { type = story_cycle_pet_cat }
						has_character_modifier = cat_story_modifier
					}
				}
				save_scope_value_as = {
					name = cat_story
					value = yes
				}
			}
			10 = { # A pupperoni
				trigger = {
					NOR = {
						any_owned_story = { type = story_cycle_pet_dog }
						has_character_modifier = dog_story_modifier
					}
				}
				save_scope_value_as = {
					name = dog_story
					value = yes
				}
			}
		}
	}

	option = {
		name = jester.900.a
		
		trigger = {
			exists = scope:cat_story
		}
		
		start_cat_story_cycle_effect = yes
		
		stress_impact = {
			base = minor_stress_impact_loss
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.900.b
		
		trigger = {
			exists = scope:dog_story
		}
		
		start_dog_story_cycle_effect = yes
		
		stress_impact = {
			base = miniscule_stress_impact_loss
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.900.c
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.900.d
		
		trigger = {
			exists = scope:eagle_story
		}
		
		save_scope_value_as = {
			name = eagle_capture_method
			value = flag:gift
		}

		start_eagle_story_cycle_effect = yes
		
		stress_impact = {
			base = miniscule_stress_impact_loss
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

jester.1000 = { # A Good Story
	type = character_event
	title = jester.1000.t
	desc = jester.1000.desc
	theme = friendly
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:jester
		animation = page_flipping
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_court_position_holder = {
			type = court_jester_court_position
			NOT = {
				has_trait = blind
			}
		}
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		
		if = {
			limit = {
				any_character_artifact = {
					artifact_slot_type = book
				}
			}
			random_character_artifact = {
				limit = {
					artifact_slot_type = book
				}
				save_scope_as = my_book
			}
		}
		
		set_random_entertainment_text_effect = yes
	}

	option = {
		name = jester.1000.c
		flavor = jester.1000.c_flavor
		
		trigger = {
			exists = scope:my_book
		}
		
		add_character_modifier = {
			modifier = reinvigorating_reading_modifier
			years = 10
		}
		
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.1000.a
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.1000.b
		
		progress_towards_friend_effect = {
			CHARACTER = scope:jester
			OPINION = 10
			REASON = friend_showed_personal_interest
		}
		stress_impact = {
			base = minor_stress_impact_loss
			sadistic = massive_stress_impact_gain
			callous = major_stress_impact_gain
			arbitrary = major_stress_impact_gain
			arrogant = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = sadistic
					has_trait = callous
					has_trait = arbitrary
					has_trait = arrogant
				}
			}
		}
	}
}

jester.1100 = { # The *artifact name* Ghost
	type = character_event
	title = jester.1100.t
	desc = jester.1100.desc
	theme = friendly
	override_background = { reference = corridor_night }
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = craven
			}
			animation = fear
		}
		triggered_animation = {
			trigger = {
				NOT = { has_trait = craven }
			}
			animation = shock
		}
	}
	right_portrait = {
		character = scope:jester
		animation = happiness
	}
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 5
			}
		}
	}
	
	trigger = {
		any_character_artifact = {
			is_equipped = yes
			OR = {
				has_variable = cabinet
				has_variable = big_chest
			}
		}
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		if = {
			limit = {
				any_character_artifact = {
					is_equipped = yes
					OR = {
						has_variable = cabinet
						has_variable = big_chest
					}
				}
			}
			random_character_artifact = {
				limit = {
					is_equipped = yes
					OR = {
						has_variable = cabinet
						has_variable = big_chest
					}
				}
				save_scope_as = hiding_place
			}
		}
	}

	option = {
		name = jester.1100.a
		
		trigger = {
			NOT = {
				has_trait = craven
			}
		}
		
		stress_impact = {
			base = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = paranoid
			}
		}
	}

	option = {
		name = jester.1100.b
		
		trigger = {
			NOT = {
				has_trait = craven
			}
		}
		
		add_character_modifier = {
			modifier = suspicious_of_furniture
			years = 10
		}
		
		stress_impact = {
			base = miniscule_stress_impact_loss
			trusting = major_stress_impact_gain
		}
		
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				has_trait = trusting
			}
		}
	}

	option = {
		name = jester.1100.c
		
		trigger = {
			has_trait = craven
		}
		trait = craven
		
		random = {
			chance = {
				value = 0
				add = age
				divide = 10
				floor = yes
				min = 1
			}
			death = {
				death_reason = death_heart_attack
			}
		}
		
		add_opinion = {
			target = scope:jester
			modifier = treachery_opinion
			opinion = -20
		}
		
		stress_impact = {
			base = major_stress_impact_gain
		}
	}

	option = {
		name = jester.1100.d
		flavor = jester.1100.d_flavor
		
		trigger = {
			NOT = {
				has_trait = craven
			}
		}
		
		scope:jester = {
			death = {
				killer = root
				death_reason = death_nailed_in_cabinet
			}
		}
		
		scope:hiding_place = {
			add_durability = -10
            set_variable = {
            	name = ghost_cabinet
            	years = 50
            }
		}
		
		stress_impact = {
			base = major_stress_impact_gain
			compassionate = major_stress_impact_gain
			forgiving = major_stress_impact_gain
			sadistic = -160
			callous = -80
			paranoid = -80
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOR = {
					has_trait = sadistic
					has_trait = callous
					has_trait = paranoid
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = forgiving
				}
			}
		}
	}
}

scripted_trigger valid_secret_holder = {
	is_available_ai_adult = yes
	NOT = {
		has_court_position = court_jester_court_position
	}
	any_secret = {
		NOT = {
			is_known_by = root # Won't reveal a secret to you which you already know.
		}
	}
}

scripted_trigger generic_vassal = {
	is_available_ai_adult = yes
	is_married = yes
	primary_spouse = {
		is_ai = yes
	}
	NOT = {
		has_court_position = court_jester_court_position
	}
}

jester.1200 = { # The Rumor Mill
	type = character_event
	title = jester.1200.t
	desc = jester.1200.desc
	theme = friendly
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:jester
		animation = throne_room_conversation_2
	}
	lower_left_portrait = scope:vassal_1
	lower_center_portrait = scope:vassal_2
	lower_right_portrait = scope:secret_holder
	
	cooldown = { years = 10 }

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 1
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 2
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 3
			}
		}
		modifier = {
			add = 0.25
			any_court_position_holder = {
				type = court_jester_court_position
				aptitude:court_jester_court_position >= 4
			}
		}
	}
	
	trigger = {
		any_court_position_holder = {
			type = court_jester_court_position
			aptitude:court_jester_court_position >= 4
			NOR = {
				has_trait = shy
				has_relation_rival = root
				opinion = {
					target = root
					value <= -30
				}
			}
			save_temporary_scope_as = jester_check
		}
		any_vassal = {
			count >= 3
			generic_vassal = yes
		}
		OR = {
			any_vassal = {
				valid_secret_holder = yes
			}
			any_courtier_or_guest = {
				valid_secret_holder = yes
			}
		}
	}

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		every_vassal = {
			limit = {
				valid_secret_holder = yes
			}
			add_to_list = potential_secret_holders
		}
		every_courtier_or_guest = {
			limit = {
				valid_secret_holder = yes
			}
			add_to_list = potential_secret_holders
		}
		random_in_list = {
			list = potential_secret_holders
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = secret_holder
			hidden_effect = {
				if = {
					limit = {
							any_secret = {
								NOT = {
								is_known_by = scope:jester
							}
						}
					}
					every_secret = {
						limit = {
							NOT = {
								is_known_by = scope:jester
							}
						}
						reveal_to = scope:jester
					}
				}
			}
		}
		random_vassal = {
			limit = {
				generic_vassal = yes
				this != scope:secret_holder
			}
			save_scope_as = vassal_1
			hidden_effect = {
				add_character_modifier = {
					modifier = licentious_01_modifier
					years = 3
				}
			}
		}
		random_vassal = {
			limit = {
				generic_vassal = yes
				NOR = {
					this = scope:secret_holder
					this = scope:vassal_1
				}
			}
			save_scope_as = vassal_2
			hidden_effect = {
				primary_spouse = {
					save_scope_as = vassal_2_spouse
					progress_towards_rival_effect = {
						REASON = rival_spousal_gossip
						CHARACTER = scope:vassal_2
						OPINION = default_rival_opinion
					}
				}
			}
		}
	}

	option = {
		name = jester.1200.a
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = jester.1200.b
		
		scope:secret_holder = {
			every_secret = {
				limit = {
					NOT = {
						is_known_by = root
					}
				}
				reveal_to = root
			}
		}
		
		stress_impact = {
			base = miniscule_stress_impact_loss
		}
		
		ai_chance = {
			base = 100
		}
	}
}

jester.1300 = { # Generic Stress Loss Feed Message
	type = character_event
	hidden = yes

	immediate = {
		random_court_position_holder = {
			type = court_jester_court_position
			save_scope_as = jester
		}
		send_interface_message = {
			type = event_stress_good
			title = jester.1300.notification
			
			left_icon = scope:jester
			
			add_stress = minor_stress_impact_loss
		}
	}
}

jester.1400 = { # Courtier Stress Loss Feed Message
	type = character_event
	hidden = yes
	
	trigger = {
		scope:jester_from_task ?= {
			has_court_position = court_jester_court_position
		}
		scope:first_de_stress_target ?= {
			is_physically_able = yes
			is_courtier_of = root
		}
	}

	immediate = {
		send_interface_message = {
			type = secondary_character_stress_good
			title = jester.1400.notification
			
			left_icon = scope:jester_from_task
			right_icon = scope:first_de_stress_target
			
			scope:first_de_stress_target = {
				add_stress = medium_stress_impact_loss
			}
		}
	}
}

jester.1410 = { # Courtier Stress Loss Feed Message, 2nd scope
	type = character_event
	hidden = yes
	
	trigger = {
		scope:jester_from_task ?= {
			has_court_position = court_jester_court_position
		}
		scope:second_de_stress_target ?= {
			is_physically_able = yes
			is_courtier_of = root
		}
	}

	immediate = {
		send_interface_message = {
			type = secondary_character_stress_good
			title = jester.1410.notification
			
			left_icon = scope:jester_from_task
			right_icon = scope:second_de_stress_target
			
			scope:second_de_stress_target = {
				add_stress = medium_stress_impact_loss
			}
		}
	}
}
