
namespace = learning_medicine
namespace = learning_medicine_special
##################################################

# Learning Medicine Lifestyle events

	# 2001			- Become Herbalist, by Mathilda Bjarnehed
	# 2010			- Improve court Physician, by Mathilda Bjarnehed
	# 2020			- Fertility treatment, by Mathilda Bjarnehed
	# 2030			- Healthy coping mechanism: becoming a confider, by Mathilda Bjarnehed
	# 2040			- Healthy coping mechanism: journaller or athletic, by Mathilda Bjarnehed
	# 2050			- Helping healing hand (medicine friend), by Mathilda Bjarnehed
	# 2110			- A vassal (or your liege) wants to eat some hashish while visiting your capital, by Ewan Cowhig Croft

#Special Learning Medicine Lifestyle events
	# 1001 			- Study Cadavers, by Linnéa Thimrén
	# 2100			- You consume a hallucinogenic fish, by Ewan Cowhig Croft

##################################################


##################################################
# Become a herbalist
# by Mathilda Bjarnehed
##################################################

scripted_trigger learning_medicine_2001_basic_herbalist_trigger = {
	has_trait = lifestyle_herbalist
	is_available_ai = yes
	is_adult = yes
}

scripted_trigger learning_medicine_2001_pool_herbalist_trigger = {
	learning_medicine_2001_basic_herbalist_trigger = yes
	guest_allowed_to_arrive_trigger = { HOST = root }
}

learning_medicine.2001 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:herbalist = { is_pool_character = yes } }
				desc = learning_medicine.2001.pool.desc
			}
			desc = learning_medicine.2001.no_pool.desc
		}
		triggered_desc = {
			trigger = { exists = scope:chaplain_hates_herbs }
			desc = learning_medicine.2001.chaplain_hates_herbs.desc
		}
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:herbalist
		animation = physician
	}
	lower_right_portrait = scope:chaplain_hates_herbs

	trigger = {
		exists = root.capital_province
		OR = {
			learning >= high_skill_rating
			culture = { has_cultural_parameter = herbalist_traits_more_common }
		}
		NOR = {
			has_character_flag = had_event_learning_medicine_2001
			has_trait = lifestyle_herbalist
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_courtier_or_guest = { learning_medicine_2001_basic_herbalist_trigger = yes }
				any_relation = { type = friend learning_medicine_2001_basic_herbalist_trigger = yes }
			}
			add = 0.75
		}
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_learning_medicine_2001
			years = 5
		}
		#Pick a herbalist
		#Friends get extra chance by not being merged with court/pool and witches are weighted for/are prioritized
		random_list = {
			3 = { #Friends
				trigger = { any_relation = { type = friend learning_medicine_2001_basic_herbalist_trigger = yes } }
				modifier = {
					any_relation = {
						type = friend
						learning_medicine_2001_basic_herbalist_trigger = yes
						is_witch_trigger = yes
					}
					factor = 3
				}
				random_relation = {
					type = friend
					limit = {
						learning_medicine_2001_basic_herbalist_trigger = yes
						is_witch_trigger = yes
					}
					alternative_limit = { learning_medicine_2001_basic_herbalist_trigger = yes }
					save_scope_as = herbalist
				}
			}
			2 = { #Courtiers
				trigger = { any_courtier_or_guest = { learning_medicine_2001_basic_herbalist_trigger = yes } }
				modifier = {
					any_courtier_or_guest = {
						learning_medicine_2001_basic_herbalist_trigger = yes
						is_witch_trigger = yes
					}
					factor = 3
				}
				random_courtier_or_guest = {
					limit = {
						learning_medicine_2001_basic_herbalist_trigger = yes
						is_witch_trigger = yes
					}
					alternative_limit = { learning_medicine_2001_basic_herbalist_trigger = yes }
					save_scope_as = herbalist
				}
			}
			1 = { #Pool characters
				trigger = {
					any_pool_character = {
						province = root.capital_province
						learning_medicine_2001_pool_herbalist_trigger = yes
					}
				}
				random_pool_character = {
					province = root.capital_province
					limit = { learning_medicine_2001_pool_herbalist_trigger = yes }
					weight = { #Pool characters don't get witch prio, only witch weight, or it will be super easy to find a witch (probably)
						base = 1
						modifier = {
							factor = 3
							is_witch_trigger = yes
						}
					}
					save_scope_as = herbalist
				}
			}
		}

		#No one there? Make one
		if = {
			limit = { NOT = { exists = scope:herbalist } }
			save_scope_as = created_char
			random_list = {
				90 = { #Make a regular herbalist
					create_character = {
						location = root.capital_province
						faith = root.faith
						culture = root.culture
						template = witchy_template
						save_scope_as = herbalist
					}
				}
				10 = { #Make a witch
					modifier = {
						root = { is_ai = no }
						add = 20
					}
					create_witch_effect = { WHO = root }
					scope:created_witch = { save_scope_as = herbalist }
				}
			}
		}

		#Give a flower to someone option?
		if = {
			limit = {
				any_scheme = {
					OR = {
						scheme_type = seduce
						scheme_type = courting
					}
				}
			}
			random_scheme = {
				limit = {
					OR = {
						scheme_type = seduce
						scheme_type = courting
					}
				}
				scheme_target_character = { save_scope_as = flower_receiver }
			}
		}
		else_if = {
			limit = { any_relation = { type = soulmate always = yes } }
			random_relation = { type = soulmate save_scope_as = flower_receiver }
		}
		else_if = {
			limit = { exists = primary_spouse }
			primary_spouse = { save_scope_as = flower_receiver }
		}

		#Would the court chaplain disagree?
		random_learning_councillor = {
			limit = {
				NOR = {
					has_trait = lifestyle_herbalist
					faith = { has_doctrine_parameter = witchcraft_accepted }
					ai_zeal <= high_negative_ai_value
				}
			}
			save_scope_as = chaplain_hates_herbs
		}
	}


	#Learn herbalism
	option = {
		name = learning_medicine.2001.a

		add_trait = lifestyle_herbalist

		if = {
			limit = { exists = scope:chaplain_hates_herbs }
			reverse_add_opinion = {
				target = scope:chaplain_hates_herbs
				modifier = impious_opinion
				opinion = -20
			}
		}

		if = {
			limit = {
				NOR = {
					has_trait = witch
					any_secret = { type = secret_witch }
				}
			}
			#Chance to become witch
			hidden_effect = {
				random_list = {
					#Yes
					30 = {
						trigger_event = {
							id = learning_medicine.2002
							days = { 7 14 }
						}
						modifier = {
							add = 30
							OR = {
								# Driven to look for deeper meanings to things (Regardless of if they're there or not)
								has_trait = ambitious
								has_trait = paranoid
							}
						}
					}
					#No
					70 = {
						modifier = {
							scope:herbalist = { is_witch_trigger = yes }
							add = -70
						}
						modifier = {
							add = 50
							OR = {
								# Unwilling to see the truth...
								has_trait = zealous
								has_trait = trusting
								# ...or unable to see the truth.
								has_trait = dull
								has_trait = intellect_bad
							}
						}
					}
				}
			}
		}

		#Pool character becomes guest
		if = {
			limit = { scope:herbalist = { is_pool_character = yes } }
			add_visiting_courtier = scope:herbalist
		}
	}

	#Arrange a garden
	option = {
		name = learning_medicine.2001.c
		add_piety = medium_piety_value
		#Pool character becomes guest
		if = {
			limit = { scope:herbalist = { is_pool_character = yes } }
			add_visiting_courtier = scope:herbalist
		}
	}

	#Help me pick a bouqet
	option = {
		trigger = {
			exists = scope:flower_receiver
		}
		name = learning_medicine.2001.b
		#Scheme modifier or opinion bonus
		if = {
			limit = {
				any_scheme = {
					OR = {
						scheme_type = seduce
						scheme_type = courting
					}
					scheme_target_character = scope:flower_receiver
				}
			}
			random_scheme = {
				limit = {
					OR = {
						scheme_type = seduce
						scheme_type = courting
					}
					scheme_target_character = scope:flower_receiver
				}
				add_scheme_modifier = {
					type = seduce_and_courting_fragrant_flowers_modifier
				}
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:flower_receiver
				modifier = romance_opinion
				opinion = 20
			}
		}

		#Pool character becomes guest
		if = {
			limit = { scope:herbalist = { is_pool_character = yes } }
			add_visiting_courtier = scope:herbalist
		}
	}

	#Condemn
	option = {
		name = {
			trigger = { NOT = { exists = scope:chaplain_hates_herbs } }
			text = learning_medicine.2001.d
		}
		name = {
			trigger = { exists = scope:chaplain_hates_herbs }
			text = learning_medicine.2001.d.chaplain_hates_herbs
		}

		zealous_progression_effect = yes

		reverse_add_opinion = {
			target = scope:herbalist
			modifier = insulted_opinion
			opinion = -15
		}

		if = {
			limit = { exists = scope:chaplain_hates_herbs }
			reverse_add_opinion = {
				target = scope:chaplain_hates_herbs
				modifier = pious_opinion
				opinion = 25
			}
		}

	}

	after = {
		add_learning_lifestyle_xp = minor_lifestyle_xp
		if = {
			limit = {
				exists = scope:created_char
			}
			scope:herbalist = {
				silent_disappearance_ai_effect = yes
			}
		}
	}
}

#Become a witch?
learning_medicine.2002 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2001.t
	desc = {
		desc = learning_medicine.2002.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:chaplain_hates_herbs
					any_learning_councillor = { this = scope:chaplain_hates_herbs }
				}
				desc = learning_medicine.2002.chaplain_hates_herbs.desc
			}
			triggered_desc = {
				trigger = {
					faith = { NOT = { has_doctrine_parameter = witchcraft_accepted } }
				}
				desc = learning_medicine.2002.not_witchcraft_accepted.desc
			}
			desc = learning_medicine.2002.witchcraft_accepted.desc
		}
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = page_flipping
	}
	right_portrait = {
		character = scope:herbalist
		animation = physician
	}

	trigger = {
		scope:herbalist = {
			basic_is_available_ai = yes
			OR = {
				has_relation_friend = root
				is_courtier_of = root
				is_foreign_court_or_pool_guest_of = root
			}
		}
	}

	#Ask to be made witch
	option = {
		name = learning_medicine.2002.a

		random_list = {
			1 = { #Become a witch
				show_chance = no
				desc = learning_medicine.2002.a.success.t
				modifier = {
					scope:herbalist = { is_witch_trigger = no }
					add = -1
				}
				show_as_tooltip = { give_witch_secret_or_trait_effect = yes }
				trigger_event = learning_medicine.2003
			}
			1 = { #They're not actually a witch
				show_chance = no
				desc = learning_medicine.2002.a.failure.t
				trigger = { #If we know that she is a witch, don't even bother showing failure
					scope:herbalist = {
						NOR = {
							has_trait = witch
							any_secret = {
								type = secret_witch
								is_known_by = root
							}
						}
					}
				}
				modifier = {
					scope:herbalist = { is_witch_trigger = yes }
					add = -1
				}
				send_interface_toast = {
					title = learning_medicine.2002.a.failure.t
					left_icon = scope:herbalist
					if = {
						limit = { scope:herbalist = { faith = { NOT = { has_doctrine_parameter = witchcraft_accepted } } } }
						reverse_add_opinion = {
							target = scope:herbalist
							modifier = impious_opinion
							opinion = -15
						}

						if = {
							limit = { faith = { NOT = { has_doctrine_parameter = witchcraft_accepted } } }
							add_piety = minor_piety_loss
						}
					}
				}
			}
		}
	}

	#Investigate
	option = {
		trigger = {
			intrigue >= mediocre_skill_rating
			scope:herbalist = {
				NOR = {
					has_trait = witch
					any_secret = {
						type = secret_witch
						is_known_by = root
					}
				}
			}
		}
		skill = intrigue
		name = learning_medicine.2002.b

		duel = {
			skill = intrigue
			target = scope:herbalist
			20 = { #TRUTH
				desc = learning_medicine.2002.b.success.t
				compare_modifier = {
					value = scope:duel_value
				}
				custom_tooltip = learning_medicine.2002.b.success.tt

				hidden_effect = {
					if = {
						limit = { scope:herbalist = { is_witch_trigger = yes } }
						send_interface_toast = {
							title = learning_medicine.2002.b.success.witch.t
							left_icon = scope:herbalist
							add_learning_lifestyle_xp = minor_lifestyle_xp
							scope:herbalist = {
								random_secret = {
									type = secret_witch
									reveal_to = root
								}
							}
						}
					}
					else = {
						send_interface_toast = {
							title = learning_medicine.2002.b.success.no_witch.t
							left_icon = scope:herbalist
							desc = learning_medicine.2002.b.success.no_witch.desc
							add_learning_lifestyle_xp = minor_lifestyle_xp
						}
					}
				}
			}
			10 = { #INCONCLUSIVE
				desc = learning_medicine.2002.b.inconclusive.t
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.2
				}
				send_interface_toast = {
					title = learning_medicine.2002.b.inconclusive.t
					left_icon = scope:herbalist
					desc = learning_medicine.2002.b.inconclusive.desc
				}
			}
			10 = { #CAUGHT
				desc = learning_medicine.2002.b.failure.t
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				send_interface_toast = {
					title = learning_medicine.2002.b.failure.t
					left_icon = scope:herbalist
					reverse_add_opinion = {
						target = scope:herbalist
						modifier = disappointed_opinion
						opinion = -20
					}
				}
			}
		}
	}

	#Let it go
	option = {
		name = learning_medicine.2002.c

		add_character_modifier = {
			modifier = diligent_student
			years = 5
		}

		reverse_add_opinion = {
			target = scope:herbalist
			modifier = respect_opinion
			opinion = 15
		}
	}
}

#You become a cool witch!
learning_medicine.2003 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2001.t
	desc = learning_medicine.2003.desc

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = ecstasy
	}
	right_portrait = {
		character = scope:herbalist
		animation = eccentric
	}

	immediate = {
		play_music_cue = "mx_cue_murder"
		scope:herbalist = {
			random_secret = {
				type = secret_witch
				limit = {
					NOT = { is_known_by = root }
				}
				reveal_to = root
			}
		}
	}

	option = {
		name = learning_medicine.2003.a
		give_witch_secret_or_trait_effect = yes
	}
}


##################################################
# Improve the skills of your court physician
# by Mathilda Bjarnehed
##################################################
learning_medicine.2010 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2010.t
	desc = {
		desc = learning_medicine.2010.start.desc
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						is_valid_for_east_asian_events_trigger = no
						NOR = {
							has_culture = culture:greek
							scope:court_physician = { has_culture = culture:greek }
						}
					}
					desc = learning_medicine.2010.galen.desc
				}
				triggered_desc = {
					trigger = {
						is_valid_for_east_asian_events_trigger = no
						NOR = {
							has_culture = culture:greek
							scope:court_physician = { has_culture = culture:greek }
						}
					}
					desc = learning_medicine.2010.hippocrates.desc
				}
				triggered_desc = {
					trigger = {
						is_valid_for_east_asian_events_trigger = no
						NOR = {
							has_culture = culture:greek
							scope:court_physician = { has_culture = culture:greek }
						}
					}
					desc = learning_medicine.2010.herophilus.desc
				}
				triggered_desc = {
					trigger = {
						OR = {
							is_valid_for_east_asian_events_trigger = yes # Culture is Japanese, Chinese or Korean
							scope:court_physician = { is_valid_for_east_asian_events_trigger = yes }
						}
						NOR = { 
							culture = { has_cultural_pillar = heritage_chinese }
							scope:court_physician.culture = { has_cultural_pillar = heritage_chinese }
						}
					}
					desc = learning_medicine.2010.bianque.desc
				}
				triggered_desc = {
					trigger = {
						OR = {
							culture = { has_cultural_pillar = heritage_chinese }
							scope:court_physician.culture = { has_cultural_pillar = heritage_chinese }
						}
					}
					desc = learning_medicine.2010.sun_simiao.desc
				}
				triggered_desc = {
					trigger = {
						OR = {
							culture = { has_cultural_pillar = heritage_chinese }
							scope:court_physician.culture = { has_cultural_pillar = heritage_chinese }
						}
					}
					desc = learning_medicine.2010.zhan_zhongjing.desc
				}
				triggered_desc = {
					trigger = {
						OR = {
							location = { geographical_region = world_asia }
							is_valid_for_east_asian_events_trigger = yes # Culture is Japanese, Chinese or Korean
							scope:court_physician.culture = { is_valid_for_east_asian_events_trigger = yes }
						}
					}
					desc = learning_medicine.2010.hua_tuo.desc
				}
				triggered_desc = {
					trigger = {
						current_date >= 984.1.1
						OR = {
							culture = { has_cultural_pillar = heritage_japonic }
							scope:court_physician.culture = { has_cultural_pillar = heritage_japonic }
						}
					}
					desc = learning_medicine.2010.tamba_yasuyori.desc
				}
				triggered_desc = {
					trigger = {
						current_date >= 1120.1.1
						location = {
							geographical_region = world_europe
						}
					}
					desc = learning_medicine.2010.hildegard.desc
				}
				triggered_desc = {
					trigger = {
						current_date >= 1316.12.30
						location = {
							geographical_region = world_europe
						}
					}
					desc = learning_medicine.2010.mundinus.desc
				}
				triggered_desc = {
					trigger = {
						NOR = {
							culture = { has_cultural_pillar = heritage_arabic }
							scope:court_physician = { culture = { has_cultural_pillar = heritage_arabic } }
							faith = { religion_tag = islam_religion }
							scope:court_physician.faith = { religion_tag = islam_religion }
						}
						current_date >= 1225.1.1
					}
					desc = learning_medicine.2010.avicenna.desc
				}
				triggered_desc = {
					trigger = {
						NOR = {
							has_culture = culture:italian
							scope:court_physician = { has_culture = culture:italian }
						}
						current_date >= 1150.1.1
					}
					desc = learning_medicine.2010.trota.desc
				}
			}
			desc = learning_medicine.2010.fallback.desc
		}
		desc = learning_medicine.2010.end.desc
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:court_physician
		animation = stressed_teacher
	}

	trigger = {
		court_physician_available_trigger = yes
		NOT = { has_character_flag = had_event_learning_medicine_2010 }
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		save_court_physician_as_effect = { SCOPE_NAME = court_physician }
		add_character_flag = {
			flag = had_event_learning_medicine_2010
			years = 5
		}
	}

	#Help out
	option = {
		name = learning_medicine.2010.a
		duel = {
			skill = learning
			value = mediocre_skill_rating
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				desc = learning_medicine.2010.a.success.desc
				send_interface_toast = {
					title = learning_medicine.2010.a.success.desc
					left_icon = scope:court_physician
					scope:court_physician = {
						add_learning_skill = 2
					}
					add_learning_lifestyle_xp = major_lifestyle_xp
				}
			}
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
				}
				desc = learning_medicine.2010.a.failure.desc
				send_interface_toast = {
					title = learning_medicine.2010.a.failure.desc
					left_icon = scope:court_physician
					reverse_add_opinion = {
						target = scope:court_physician
						modifier = disappointed_opinion
						opinion = -10
					}
				}
			}
		}
		cynical_progression_effect = yes
	}

	#These books are bad, I know better ones
	option = {
		name = learning_medicine.2010.b
		add_learning_lifestyle_xp = minor_lifestyle_xp
		remove_short_term_gold = minor_gold_value

		scope:court_physician = {
			physician_lifestyle_rank_up_effect = yes
		}
	}

	#You should look to the holy text instead!
	option = {
		name = learning_medicine.2010.c
		add_learning_lifestyle_xp = minor_lifestyle_xp
		add_piety = medium_piety_value
		if = {
			limit = {
				scope:court_physician = { ai_zeal >= low_positive_ai_value }
				faith = scope:court_physician.faith
			}
			reverse_add_opinion = {
				target = scope:court_physician
				modifier = pious_opinion
				opinion = 15
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:court_physician
				modifier = disappointed_opinion
				opinion = -10
			}
		}

		zealous_progression_effect = yes
	}
}


##################################################
# Fertility treatment
# by Mathilda Bjarnehed
##################################################

scripted_trigger learning_medicine_2020_can_have_child_trigger = {
	trigger_if = {
		limit = { is_male = yes }
		is_visibly_fertile = yes
		fertility >= 0.1
	}
	trigger_if = {
		limit = { is_female = yes }
		is_visibly_fertile = yes
		fertility >= 0.1
		is_pregnant = no
	}
	NOT = {
		has_court_position = court_physician_court_position
	}
}

learning_medicine.2020 = {
	hidden = yes

	trigger = {
		learning_medicine_2020_can_have_child_trigger = yes
		any_spouse = {
			learning_medicine_2020_can_have_child_trigger = yes #Also checking that they are in fact not the court physician
		}
		NAND = {
			any_child = {
				character_gender_can_inherit_from_trigger = { CHARACTER = root }
				count >= 4
			}
			player_heir.dynasty = root.dynasty
		}
		NOT = { has_character_flag = had_event_learning_medicine_2020 }
	}

	weight_multiplier = {
		base = 1

		#Age
		modifier = {
			add = {
				value = age
				subtract = 30 #An age where you could start to worry
				multiply = 0.06 #45 years = 1
				min = -1
				max = 1.5
			}
		}

		#Fertility
		modifier = {
			add = {
				add = 1 #100% fertility
				subtract = {
					add = fertility
					add = primary_spouse.fertility
					divide = 2 #To get the average fertility
				}
				#Now we have the inverted fertility, the lower the fertility, the higher the remaining number is
				subtract = medium_fertility #So high fertility equals negative modifier
			}
		}

		#Number of children
		modifier = {
			add = {
				every_child = {
					if = {
						limit = { character_gender_can_inherit_from_trigger = { CHARACTER = root } }
						add = -0.25
					}
					else = {
						add = -0.1
					}
				}
			}
		}

		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		save_court_physician_as_effect = { SCOPE_NAME = physician }

		if = {
			limit = { exists = scope:physician }
			save_scope_value_as = {
				name = new_physician
				value = no
			}
			trigger_event = learning_medicine.2022
		}
		else_if = {
			limit = {
				can_employ_court_position_type = court_physician_court_position
			}
			save_scope_value_as = {
				name = new_physician
				value = yes
			}
			trigger_event = learning_medicine.2021
		}

		add_character_flag = {
			flag = had_event_learning_medicine_2020
			years = 10
		}
	}
}


#You have no physician but this person wants to help you with fertility issues!
learning_medicine.2021 = { #by Mathilda Bjarnehed
	type = letter_event
	opening = learning_medicine.2021.t
	desc = learning_medicine.2021.desc
	sender = scope:physician

	immediate = {
		random_pool_character = {
			province = root.capital_province
			limit = { learning >= medium_skill_rating }
			weight = {
				base = 1
				modifier = {
					add = {
						value = learning
						subtract = medium_skill_rating
					}
				}
			}
			save_scope_as = physician
		}
		if = {
			limit = { NOT = { exists = scope:physician } }
			create_character = {
				template = pool_repopulate_learning
				gender_female_chance = 50
				location = root.capital_province
				save_scope_as = physician
			}
		}
	}

	#Yes I want your services
	option = {
		name = learning_medicine.2021.a
		pay_treasury_or_gold = {
			value = high_skill_court_physician_cost
			target = scope:physician
		}
		set_court_physician_effect = {
			EMPLOYER = root
			PHYSICIAN = scope:physician
		}
		custom_tooltip = learning_medicine.2021.a.tt
		trigger_event = {
			id = learning_medicine.2022
			days = { 7 10 }
		}
	}

	#Maybe there is something else you can help me with
	option = {
		name = learning_medicine.2021.b
		custom_tooltip = learning_medicine.2021.b.tt
		pay_treasury_or_gold = {
			value = low_skill_court_physician_cost
			target = scope:physician
		}
		set_court_physician_effect = {
			EMPLOYER = root
			PHYSICIAN = scope:physician
		}
	}

	#Nah thanks
	option = {
		name = learning_medicine.2021.c
		add_prestige = miniscule_prestige_gain
	}
}

#Physician offers you to try different methods
scripted_trigger learning_medicine_2022_valid_physician_trigger = {
	exists = scope:physician
	root = {
		any_court_position_holder = {
	        type = court_physician_court_position
	        this = scope:physician
	    }
	}
}

learning_medicine.2022 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2022.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:new_physician = no }
				desc = learning_medicine.2022.old_physician.desc
			}
			triggered_desc = {
				trigger = { scope:new_physician = yes }
				desc = learning_medicine.2022.new_physician.desc
			}
		}
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = stunned
	}
	right_portrait = {
		character = scope:physician
		animation = physician
	}
	lower_right_portrait = scope:spouse

	trigger = {
		learning_medicine_2022_valid_physician_trigger = yes
		any_spouse = { learning_medicine_2020_can_have_child_trigger = yes }
	}

	immediate = {
		#pick a spouse
		random_spouse = {
			limit = {
				learning_medicine_2020_can_have_child_trigger = yes
				this = root.primary_spouse
			}
			alternative_limit = {
				learning_medicine_2020_can_have_child_trigger = yes
			}
			save_scope_as = spouse
			if = {
				limit = { is_female = yes }
				save_scope_as = woman
			}
			else = {
				save_scope_as = man
			}
		}
		if = {
			limit = { is_female = yes }
			save_scope_as = woman
		}
		else = {
			save_scope_as = man
		}
	}

	#Something safe
	option = {
		name = learning_medicine.2022.b

		random_list = {
			85 = {
				modifier = {
					add = {
						value = scope:physician.learning
						subtract = average_skill_rating
						multiply = 5
					}
				}
				desc = learning_medicine.2022.b.success
				send_interface_toast = {
					title = learning_medicine.2022.b.success
					left_icon = scope:physician
					right_icon = scope:spouse
					add_character_modifier = {
						modifier = successful_fertility_treatment
						years = 10
					}
					scope:spouse = {
						add_character_modifier = {
							modifier = successful_fertility_treatment
							years = 10
						}
					}
				}
			}
			15 = {
				modifier = {
					add = {
						value = scope:physician.learning
						subtract = average_skill_rating
						multiply = -1
						min = -10
					}
				}
				desc = learning_medicine.2022.b.failure
				send_interface_toast = {
					title = learning_medicine.2022.b.failure
					left_icon = scope:physician
					right_icon = scope:spouse
					add_character_modifier = {
						modifier = botched_fertility_treatment
						years = 5
					}
					scope:spouse = {
						add_character_modifier = {
							modifier = botched_fertility_treatment
							years = 5
						}
					}
				}
			}
		}
	}

	#Something new
	option = {
		name = learning_medicine.2022.a

		random_list = {
			desc = outcome_in_a_few_days
			55 = { #Good outcome
				modifier = {
					add = {
						value = scope:physician.learning
						subtract = average_skill_rating
						multiply = 5
					}
				}
				desc = learning_medicine.2022.a.success
				show_as_tooltip = {
					add_character_modifier = {
						modifier = very_successful_fertility_treatment
						years = 10
					}
					scope:spouse = {
						add_character_modifier = {
							modifier = very_successful_fertility_treatment
							years = 10
						}
					}
				}
				trigger_event = {
					id = learning_medicine.2023
					days = { 3 7 }
				}
			}
			30 = { #Strange outcome
				modifier = {
					scope:physician = {
						OR = {
							has_trait = lifestyle_mystic
							ai_honor <= medium_negative_ai_value
						}
					}
					add = 20
				}
				trigger = {
					is_ai = no
					scope:spouse = { might_cheat_on_every_partner_trigger = yes }
					scope:physician = { might_cheat_on_every_partner_trigger = yes }
				}
				desc = learning_medicine.2022.a.unexpected
				custom_tooltip = learning_medicine.2022.a.unexpected.tt
				hidden_effect = {
					random_list = {
						30 = { #Did the court physician have sex with my spouse...?
							trigger = {
								scope:spouse = { is_female = yes }
								scope:physician = {
									is_male = yes
									learning_medicine_2020_can_have_child_trigger = yes
								}
							}
							modifier = {
								add = {
									value = scope:physician.ai_honor
									divide = high_negative_ai_value
									multiply = 30
								}
							}
							hidden_effect = {
								scope:spouse = {
									random_list = {
										80 = {
											had_sex_with_effect = { #Use effect because we want possibility of suspicion
												CHARACTER = scope:physician
												PREGNANCY_CHANCE = 100
											}
										}
										20 = {
											make_pregnant = {
												father = root
											}
										}
									}
								}
							}
							trigger_event = {
								id = learning_medicine.2025
								days = { 30 40 }
							}
						}
						70 = { #Regular side effects (good outcome + additional effects)
							save_scope_value_as = {
								name = side_effects
								value = yes
							}
							trigger_event = {
								id = learning_medicine.2023 #The good outcome
								days = { 3 7 }
							}
						}
					}
				}
			}
			15 = { # Bad outcome
				modifier = {
					add = {
						value = scope:physician.learning
						subtract = average_skill_rating
						multiply = -1
						min = -10
					}
				}
				desc = learning_medicine.2022.a.failure
				trigger_event = {
					id = learning_medicine.2024
					days = { 3 7 }
				}
				show_as_tooltip = {
					add_character_modifier = {
						modifier = botched_fertility_treatment
						years = 5
					}
					scope:spouse = {
						add_character_modifier = {
							modifier = botched_fertility_treatment
							years = 5
						}
					}
				}
			}
		}
	}



	#Actually, I just want some... tricks
	option = {
		name = learning_medicine.2022.c

		reverse_add_opinion = {
			target = scope:spouse
			modifier = romance_opinion
			opinion = 25
		}
	}

	#Nah thanks
	option = {
		trigger = { scope:new_physician = no }
		name = learning_medicine.2021.c
		add_prestige = miniscule_prestige_gain
	}
}

scripted_trigger learning_medicine_2023_continue_chain_trigger = {
	learning_medicine_2022_valid_physician_trigger = yes
	exists = scope:spouse
	scope:spouse = {
		is_alive = yes
		is_consort_of = root
	}
}

scripted_trigger learning_medicine_2023_random_foreign_ruler_trigger = {
	is_landed = yes
	is_ai = yes
	NOT = { in_diplomatic_range = root }
	might_cheat_on_every_partner_trigger = yes
}

scripted_trigger learning_medicine_2023_random_family_member_trigger = {
	is_male = yes
	is_ai = yes
	learning_medicine_2020_can_have_child_trigger = yes
	might_cheat_on_every_partner_trigger = yes
	save_temporary_scope_as = incest_relative
	NOR = {
		has_trait = chaste
		guaranteed_under_20_incest_rejection_trigger = {
			TARGET = scope:incest_relative
			SEDUCER = scope:spouse
		}
		guaranteed_under_20_incest_rejection_trigger = {
			TARGET = scope:spouse
			SEDUCER = scope:incest_relative
		}
	}
}

#Risky option: It went great!
learning_medicine.2023 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2022.t
	desc = {
		random_valid = {
			desc = {
				desc = learning_medicine.2023.urine.desc
				desc = learning_medicine.2023.unpleasant_end.desc
			}
			desc = {
				desc = learning_medicine.2023.pig_testicles.desc
				desc = learning_medicine.2023.pig_testicles_end.desc
			}
			desc = {
				desc = learning_medicine.2023.udder.desc
				desc = learning_medicine.2023.unpleasant_end.desc
			}
			desc = {
				desc = learning_medicine.2023.milk_bath.desc
				desc = learning_medicine.2023.milk_bath_end.desc
			}
			desc = {
				desc = learning_medicine.2023.female_orgasm.start.desc
				first_valid = {
					triggered_desc = {
						trigger = { is_female = yes }
						desc = learning_medicine.2023.female_orgasm.female.desc
					}
					triggered_desc = {
						trigger = { is_male = yes }
						desc = learning_medicine.2023.female_orgasm.male.desc
					}
				}
			}
		}
		desc = learning_medicine.2023.end.desc
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:physician
		triggered_animation = {
			trigger = { OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion } }
			animation = acknowledging # anim uses crucifix scepter
		}
		animation = war_over_tie
	}
	lower_right_portrait = scope:spouse

	trigger = {
		learning_medicine_2023_continue_chain_trigger = yes
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		hidden_effect = {
			if = {
				limit = {
					scope:woman = { is_pregnant = no } #We could have gotten pregnant while waiting
				}
				if = {
					limit = { exists = scope:side_effects }

					random_list = {
						10 = { #Far away pregnancy
							trigger = {
								scope:spouse = {
									is_female = yes
									might_cheat_on_every_partner_trigger = yes
								}
								any_independent_ruler = { learning_medicine_2023_random_foreign_ruler_trigger = yes }
							}
							random_independent_ruler = {
								limit = { learning_medicine_2023_random_foreign_ruler_trigger = yes }
								weight = {
									base = 1
									modifier = {
										add = 1000
										capital_province = {
											squared_distance = {
												target = root.capital_province
												value >= squared_distance_monstrous
											}
										}
									}
								}
								save_scope_as = foreign_ruler
								create_character = {
									location = root.capital_province
									template_character = scope:foreign_ruler
									gender = male
									age = { 15 35 }
									save_scope_as = foreign_father
								}
							}
							scope:spouse = {
								had_sex_with_effect = {
									CHARACTER = scope:foreign_father
									PREGNANCY_CHANCE = pregnancy_chance
								}
							}
						}
						15 = { #Incest pregnancy
							trigger = {
								scope:spouse = {
									is_female = yes
									NOT = { has_trait = chaste }
									might_cheat_on_every_partner_trigger = yes
									any_close_family_member = { learning_medicine_2023_random_family_member_trigger = yes }
								}
							}
							scope:spouse = {
								random_close_family_member = {
									limit = { learning_medicine_2023_random_family_member_trigger = yes }
									save_scope_as = incest_father
								}
								had_sex_with_effect = { #Use effect because we want possibility of suspicion
									CHARACTER = scope:incest_father
									PREGNANCY_CHANCE = 100
								}
							}
						}
						30 = { #Unexpected trait
							scope:woman = {
								add_character_flag = {
									flag = medicine_learning_fertility_treamtent_unexpected_trait
									years = 1
								}
								make_pregnant = {
									father = scope:man
								}
							}
						}
						45 = { #Twins
							scope:woman = {
								make_pregnant = {
									father = scope:man
									number_of_children = 2
								}
							}
						}
					}
				}
				else = { #Just regular pregnancy roll
					random = {
						chance = 50
						scope:woman = {
							had_sex_with_effect = {
								CHARACTER = scope:man
								PREGNANCY_CHANCE = pregnancy_chance
							}
						}
					}
				}
			}

			location = { save_scope_as = location }
		}
	}

	option = {
		name = learning_medicine.2023.a

		add_character_modifier = {
			modifier = very_successful_fertility_treatment
			years = 10
		}
		reverse_add_opinion = {
			modifier = romance_opinion
			target = scope:spouse
			opinion = 15
		}
		scope:spouse = {
			add_character_modifier = {
				modifier = very_successful_fertility_treatment
				years = 10
			}
		}
	}
}


#Risky option: It went awful!
learning_medicine.2024 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2022.t
  	desc = {
		random_valid = {
			desc = learning_medicine.2023.urine.desc
			desc = learning_medicine.2023.pig_testicles.desc
			desc = learning_medicine.2023.udder.desc
			desc = learning_medicine.2023.milk_bath.desc
		}
		desc = learning_medicine.2024.end.desc
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = sick_stomach
	}
	right_portrait = {
		character = scope:physician
		animation = worry
	}
	lower_right_portrait = scope:spouse

	trigger = {
		learning_medicine_2023_continue_chain_trigger = yes
	}

	immediate = {
		add_character_modifier = {
			modifier = botched_fertility_treatment
			years = 5
		}
		scope:spouse = {
			add_character_modifier = {
				modifier = botched_fertility_treatment
				years = 5
			}
		}
		location = { save_scope_as = location }
	}

	#Forgive
	option = {
		name = learning_medicine.2024.a

		reverse_add_opinion = {
			target = scope:physician
			modifier = grateful_opinion
			opinion = 10
		}

		stress_impact = {
			wrathful = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			vengeful = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_compassion_target_modifier = { VALUE = 50 }
			ai_vengefulness_target_modifier = { VALUE = -50 }
		}
	}

	#Imprison
	option = {
		name = learning_medicine.2024.b

		imprison_physician_effect = yes

		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_compassion_target_modifier = { VALUE = -30 }
			ai_vengefulness_target_modifier = { VALUE = 100 }
		}
	}
}


#Risky option: My spouse is pregnant but nothing was done...?
learning_medicine.2025 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2022.t
	desc = {
		desc = learning_medicine.2025.start.desc
		 	first_valid = {
			triggered_desc = {
				trigger = { scope:physician.faith = { fertilitygod_is_active_trigger = yes } }
				desc = learning_medicine.2025.fertilitygod.desc
			}
			desc = learning_medicine.2025.the_universe.desc
		}
		desc = learning_medicine.2025.end.desc
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:physician
		animation = happiness
	}
	lower_right_portrait = scope:spouse

	trigger = {
		learning_medicine_2023_continue_chain_trigger = yes
	}

	#Ok
	option = {
		name = learning_medicine.2025.b

		stress_impact = {
			paranoid = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				has_trait = paranoid
				add = -90
			}
		}
	}

	option = { #Confront spouse!
		name = learning_medicine.2025.a
		custom_tooltip = learning_medicine.2025.a.tt

		add_character_flag = confront_spouse

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

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_flag = confront_spouse }
				remove_character_flag = confront_spouse
				scope:spouse = { save_scope_as = lover_spouse }
				save_scope_as = spouse
				scope:lover_spouse = {
					trigger_event = {
						id = adultery.0003
					}
				}
			}
		}
	}
}

#######################################
# Healthy coping mechanism: becoming a confider
# by Mathilda Bjarnehed
#######################################

scripted_trigger leaning_medicine_2030_potential_confider_friend_trigger = {
	opinion = {
		target = root
		value >= low_positive_opinion
	}
	target_is_liege_or_above = root.top_liege
	basic_is_available_ai = yes
	is_adult = yes
	NOT = { has_relation_rival = root }
}

scripted_effect medicine_2030_confider_chance_effect = {
	random = {
		chance = 40
		modifier = {
			has_relation_friend = $FRIEND$
			add = 25
		}
		modifier = {
			add = {
				value = ai_honor
				divide = high_positive_ai_value
				multiply = 40
				max = 40
				min = -20
			}
		}


		send_interface_toast = {
			title = learning_medicine.2030.a.message
			add_trait = confider
			scope:confider_target = {
				if = {
					limit = { has_relation_friend = root }
					if = {
						limit = {
							has_relation_best_friend = root
						}
						add_relation_flag = {
							target = root
							relation = best_friend
							flag = has_been_confided_in
						}
					}
					else = {
						add_relation_flag = {
							target = root
							relation = friend
							flag = has_been_confided_in
						}
					}
				}
			}
			add_stress = medium_stress_loss
		}
	}
}

learning_medicine.2030 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2030.t
	desc = learning_medicine.2030.desc

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:confider_target
		animation = personality_compassionate
	}
	lower_right_portrait = scope:confider_target_2

	trigger = {
		NOR = {
			has_trait = confider
			has_character_flag = had_event_learning_medicine_2030
		}
		get_characters_of_major_interest_trigger = { LISTNAME = confider_list }
		any_in_list = {
			list = confider_list
			leaning_medicine_2030_potential_confider_friend_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = stress
				divide = extremely_high_stress
				multiply = 2
				subtract = 0.5
				max = 1 #Will end up with a modifier between -0.5 at 0 stress and 1 at upper third of stress scale
			}
		}
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_learning_medicine_2030
			years = 10
		}

		#Build confider list
		get_characters_of_major_interest_effect = { LISTNAME = confider_list }

		#OPTION 1 alternatives:
		# Alt 1: Medicine friend helps you out (guaranteed confider)
		# Alt 2: Confide in list character (random chance of confider)

		#Do I have a medicine friend? if so, alt 1
		random_relation = {
			type = friend
			limit = {
				basic_is_available_ai = yes
				lifestyle_friend_trigger = { CHARACTER = root FOCUS = learning_medicine_focus }
			}
			save_scope_as = confider_target
			save_scope_value_as = {
				name = option_1
				value = flag:medicine_friend_guaranteed
			}
		}

		#No medicine friend? pick someone in list for alt 2
		if = {
			limit = { NOT = { exists = scope:option_1 } }

			#Find someone to confide in (OPTION 1)
			random_in_list = {
				list = confider_list
				limit = {
					leaning_medicine_2030_potential_confider_friend_trigger = yes
					lifestyle_friend_trigger = { CHARACTER = root FOCUS = learning_medicine_focus }
				}
				alternative_limit = { leaning_medicine_2030_potential_confider_friend_trigger = yes }
				weight = {
					base = 1
					modifier = {
						OR = {
							is_close_family_of = root
							is_powerful_vassal = yes
						}
						add = 5
					}
					modifier = {
						has_relation_potential_friend = root
						add = 10
					}
					compatibility_modifier = {
						compatibility_target = root
						min = -20
						max = 20
						multiplier = 1
					}
					modifier = {
						any_secret = {
							NOT = { is_known_by = root }
						}
						add = 20
					}
				}
				save_scope_as = confider_target
				save_scope_value_as = {
					name = option_1
					value = flag:list_character_random
				}
			}
		}


		#OPTION 2 alternatives:
		# Alt 1: Confide in list character (random chance of confider), if option 1 is medicine friend or I have no secret to trade
		# Alt 2: Secret trade with random list character (guaranteed confider)


		#Alt 1: Confide in list character
		if = {
			limit = {
				OR = {
					scope:option_1 = flag:medicine_friend_guaranteed
					NOT = {
						any_secret = {
							is_known_by = scope:confider_target
						}
					}
				}
			}

			random_in_list = {
				list = confider_list
				limit = {
					this != scope:confider_target
					leaning_medicine_2030_potential_confider_friend_trigger = yes
					NOT = { has_relation_friend = root } #Because there is no friend benefit on this option
					lifestyle_friend_trigger = { CHARACTER = root FOCUS = learning_medicine_focus }
				}
				alternative_limit = {
					this != scope:confider_target
					NOT = { has_relation_friend = root } #Because there is no friend benefit on this option
					leaning_medicine_2030_potential_confider_friend_trigger = yes
				}
				weight = {
					base = 1
					modifier = {
						OR = {
							is_close_family_of = root
							is_powerful_vassal = yes
						}
						add = 5
					}
					modifier = {
						has_relation_potential_friend = root
						add = 10
					}
					compatibility_modifier = {
						compatibility_target = root
						min = -20
						max = 20
						multiplier = 1
					}
				}
				save_scope_as = confider_target_2
				save_scope_value_as = {
					name = option_2
					value = flag:list_character_random
				}
			}
		}
		## Alt 2: Secret trade with random list character
		else = {
			#Find one of my secrets
			random_secret = {
				limit = {
					is_shunned_for = root
					NOT = { is_known_by = scope:confider_target }
				}
				alternative_limit = {
					NOT = { is_known_by = scope:confider_target }
				}
				save_scope_as = root_secret
			}

			#Try to find one of their secrets for the trade
			scope:confider_target = {
				if = {
					limit = { NOT = { any_secret = { NOT = { is_known_by = root } } } }
					give_random_likely_secret_effect = yes
				}

				random_secret = {
					limit = {
						is_blackmailable_secret_trigger = {
							PARTICIPANT = scope:confider_target
							BLACKMAILER = root
						}
						NOT = { is_known_by = root }
					}
					alternative_limit = {
						NOT = { is_known_by = root }
					}
					save_scope_as = confider_target_secret
				}
			}

			save_scope_value_as = {
				name = option_2
				value = flag:secret_trading_guaranteed
			}
		}
	}

	#OPTION 1

	#Medicine friend helps you
	option = {
		trigger = { scope:option_1 = flag:medicine_friend_guaranteed }
		name = learning_medicine.2030.a

		add_trait = confider

		scope:confider_target = {
			add_relation_flag = {
				target = root
				relation = friend
				flag = has_been_confided_in
			}
		}

		stress_impact = {
			base = major_stress_loss
			deceitful = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
		}
	}

	#Regular confide in target 1
	option = {
		trigger = { scope:option_1 = flag:list_character_random }
		name = learning_medicine.2030.a

		#Become friends or potential friend
		progress_towards_friend_effect = {
			CHARACTER = scope:confider_target
			REASON = friend_free_therapy
			OPINION = default_friend_opinion
		}

		#Might become confider
		medicine_2030_confider_chance_effect = { FRIEND = scope:confider_target }

		#Save them as a confidant if they became your friend
		if = {
			limit = {
				has_relation_friend = scope:confider_target
			}
			scope:confider_target = {
				add_relation_flag = {
					target = root
					relation = friend
					flag = has_been_confided_in
				}
			}
		}

		stress_impact = {
			deceitful = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_boldness_target_modifier = { VALUE = 30 }
			ai_honor_target_modifier = { VALUE = 100 }
		}
	}

	#OPTION 2

	#Regular confide in target 2
		option = {
			trigger = {
				exists = scope:option_2
				scope:option_2 = flag:list_character_random
			}
			name = learning_medicine.2030.b

			#Become friends or potential friend
		progress_towards_friend_effect = {
			CHARACTER = scope:confider_target_2
			REASON = friend_free_therapy
			OPINION = default_friend_opinion
		}

		#Might become confider
		medicine_2030_confider_chance_effect = { FRIEND = scope:confider_target_2 }

		#Save them as a confidant if they became your friend
		if = {
			limit = {
				has_relation_friend = scope:confider_target
			}
			scope:confider_target = {
				if = {
					limit = {
						has_relation_best_friend = root
					}
					add_relation_flag = {
						target = root
						relation = best_friend
						flag = has_been_confided_in
					}
				}
				else = {
					add_relation_flag = {
						target = root
						relation = friend
						flag = has_been_confided_in
					}
				}
			}
		}

		stress_impact = {
			deceitful = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_boldness_target_modifier = { VALUE = 30 }
			ai_honor_target_modifier = { VALUE = 100 }
		}
		}

	#Trader secrets with target 1
	option = {
		trigger = {
			exists = scope:option_2
			scope:option_2 = flag:secret_trading_guaranteed
			exists = scope:root_secret
		}
		name = learning_medicine.2030.c

		#Secret trading
		scope:root_secret = {
			reveal_to = scope:confider_target
		}
		custom_tooltip = learning_medicine.2030.c.tt
		if = {
			limit = { exists = scope:confider_target }
			hidden_effect = {
				send_interface_toast = {
					title = learning_medicine.2030.c.message
					left_icon = scope:confider_target
					scope:confider_target_secret = {
						reveal_to = root
					}
				}
			}
		}

		#Set friendship, add trait and lose stress
		if = {
			limit = {
				can_set_relation_friend_trigger = { CHARACTER = scope:confider_target }
			}
			set_relation_friend = { reason = friend_confiding_each_other target = scope:confider_target }
		}

		add_trait = confider

		scope:confider_target = {
			add_relation_flag = {
				target = root
				relation = friend
				flag = has_been_confided_in
			}
		}

		stress_impact = {
			base = medium_stress_loss
			deceitful = major_stress_impact_gain
			paranoid = major_stress_impact_gain
			shy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_boldness_target_modifier = { VALUE = 15 }
			ai_honor_target_modifier = { VALUE = 30 }
		}
	}

	#OPTION 3 (fallback)

	#Keep secrets close to chest
	option = {
		name = learning_medicine.2030.d

		add_character_modifier = {
			modifier = guarded_modifier
			years = 15
		}

		stress_impact = {
			honest = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_boldness_target_modifier = { VALUE = -30 }
			ai_honor_target_modifier = { VALUE = -50 }
		}
	}
}



################################################
# Healthy coping mechanism: journaller or athletic
# by Mathilda Bjarnehed
################################################

learning_medicine.2040 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2040.t
	desc = {
		desc = learning_medicine.2040.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:friend_help
					scope:friend_help = flag:athletic
				}
				desc = learning_medicine.2040.athletic_friend.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:friend_help
					scope:friend_help = flag:journaller
				}
				desc = learning_medicine.2040.journaller_friend.desc
			}
			desc = learning_medicine.2040.no_friend.desc
		}
	}

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:friend
		triggered_animation = {
			trigger = { scope:friend_help ?= flag:journaller }
			animation = writing
		}
		triggered_animation = {
			trigger = { scope:friend_help ?= flag:athletic }
			animation = hero_flex
		}
		animation = personality_compassionate
		trigger = {
			exists = scope:friend
		}
	}

	trigger = {
		NOR = {
			has_traits_that_negate_athletic_trigger = yes #Are we already athletic or does any of our traits contradict athletic?
			has_trait = journaller
			has_character_flag = had_event_learning_medicine_2040
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = {
				value = stress
				divide = extremely_high_stress
				multiply = 2
				subtract = 0.5
				max = 1 #Will end up with a modifier between -0.5 at 0 stress and 1 at upper third of stress scale
			}
		}
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_learning_medicine_2040
			flag = had_event_learning_medicine_2040
			flag = had_event_learning_medicine_2040
			years = 10
		}

		#Grab a medicine friend if we have one and randomize what they can help you with
		random_relation = {
			type = friend
			limit = {
				basic_is_available_ai = yes
				OR = {
					lifestyle_friend_trigger = { CHARACTER = root FOCUS = learning_medicine_focus }
					has_trait = athletic
					has_trait = journaller
				}
			}
			save_scope_as = friend
			random_list = {
				100 = { #Athletic
					modifier = {
						add = {
							value = prowess
							subtract = average_skill_rating
							multiply = 10
						}
					}
					modifier = {
						add = {
							value = ai_energy
							divide = high_positive_ai_value
							multiply = 50
						}
					}
					modifier = {
						factor = 0
						has_trait = journaller
					}
					save_scope_value_as = {
						name = friend_help
						value = flag:athletic
					}
					if = {
						limit = {
							NOT = { has_trait = athletic }
						}
						add_trait = athletic
					}
				}
				100 = { #Journaller
					modifier = {
						add = {
							value = learning
							subtract = average_skill_rating
							multiply = 10
						}
					}
					modifier = {
						add = {
							value = ai_energy
							divide = high_positive_ai_value
							multiply = -30
						}
					}
					modifier = {
						has_trait = shy
						add = 30
					}
					modifier = {
						factor = 0
						has_trait = athletic
					}
					save_scope_value_as = {
						name = friend_help
						value = flag:journaller
					}
					if = {
						limit = {
							NOT = { has_trait = journaller }
						}
						add_trait = journaller
					}
				}
			}
		}
	}

	#FRIEND HELP OPTIONS

	#Friend helps with athletic
	option = {
		trigger = {
			exists = scope:friend_help
			scope:friend_help = flag:athletic
		}
		name = learning_medicine.2040.a

		add_trait = athletic

		stress_impact = {
			base = medium_stress_loss
			lazy = minor_stress_impact_gain
		}
	}

	#Friend helps with journaller
	option = {
		trigger = {
			exists = scope:friend_help
			scope:friend_help = flag:journaller
		}
		name = learning_medicine.2040.b

		add_trait = journaller

		stress_impact = {
			base = medium_stress_loss
			dull = minor_stress_impact_gain
			intellect_bad_1 = minor_stress_impact_gain
			intellect_bad_2 = minor_stress_impact_gain
			intellect_bad_3 = minor_stress_impact_gain
		}
	}


	#REGULAR OPTIONS

	#Athletic
	option = {
		trigger = {
			has_traits_that_negate_athletic_trigger = no 	#Fail-safe in case the event gets triggered somehow
			OR = {
				NOT = { exists = scope:friend_help }
				trigger_if = {
					limit = {
						exists = scope:friend_help
					}
					NOT = { scope:friend_help = flag:athletic }
				}
			}
		}
		name = learning_medicine.2040.c

		random_list = {
			50 = {
				desc = learning_medicine.2030.c.trait
				send_interface_toast = {
					title = learning_medicine.2030.c.trait
					add_trait = athletic
					stress_impact = {
						base = minor_stress_loss
					}
				}
			}
			50 = {
				desc = learning_medicine.2030.c.modifier
				send_interface_toast = {
					title = learning_medicine.2030.c.modifier
					add_character_modifier = {
						modifier = exercise_modifier
						years = 15
					}
				}
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
		}
	}

	#Journaller
	option = {
		trigger = {
			OR = {
				NOT = { exists = scope:friend_help }
				trigger_if = {
					limit = {
						exists = scope:friend_help
					}
					NOT = { scope:friend_help = flag:journaller }
				}
			}
		}
		name = learning_medicine.2040.d

		random_list = {
			50 = {
				desc = learning_medicine.2030.d.trait
				send_interface_toast = {
					title = learning_medicine.2030.d.trait
					add_trait = journaller
					stress_impact = {
						base = minor_stress_loss
					}
				}
			}
			50 = {
				desc = learning_medicine.2030.d.modifier
				send_interface_toast = {
					title = learning_medicine.2030.d.modifier
					add_character_modifier = {
						modifier = wide_vocabulary_modifier
						years = 15
					}
				}
			}
		}

		stress_impact = {
			dull = minor_stress_impact_gain
			intellect_bad_1 = minor_stress_impact_gain
			intellect_bad_2 = minor_stress_impact_gain
			intellect_bad_3 = minor_stress_impact_gain
		}
	}


	#OPT OUT
	option = {
		name = learning_medicine.2040.e

		stress_impact = {
			base = medium_stress_loss
			diligent = minor_stress_impact_gain
		}
	}
}


#########################################################
# Helping healing hand (medicine friend)
# by Mathilda Bjarnehed
##########################################################

learning_medicine.2050 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2050.t
	desc = {
		desc = learning_medicine.2050.start.desc
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:physician }
				desc = learning_medicine.2050.physician.desc
			}
			desc = learning_medicine.2050.no_physician.desc
		}
		desc = learning_medicine.2050.end.desc
	}

	theme = learning_medicine_focus
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:soldier
		animation = shiver
	}
	lower_right_portrait = scope:helper

	trigger = {
		NOT = {
			has_character_flag = had_event_learning_medicine_2050
		}
		is_playable_character = yes
		exists = root.capital_province.culture
		number_of_maa_regiments >= 1
	}

	weight_multiplier = {
		base = 1
		modifier = {
			OR = {
				any_knight = { prowess < average_skill_rating }
				number_of_knights < max_number_of_knights
			}
			add = 0.5
		}
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		play_music_cue = "mx_cue_stress"
		add_character_flag = {
			flag = had_event_learning_medicine_2050
			years = 10
		}
		#Find a helper (potential friend)
		if = {
			limit = {
				NOT = {
					any_relation = {
						type = friend
						lifestyle_friend_trigger = { CHARACTER = root FOCUS = learning_medicine_focus }
					}
				}
			}
			potential_lifestyle_friend_saving_effect = { FOCUS = learning_medicine_focus SCOPE_NAME = helper }
		}
		else = {
			random_relation = {
				type = friend
				limit = {
					lifestyle_friend_trigger = { CHARACTER = root FOCUS = learning_medicine_focus }
				}
				save_scope_as = helper
			}
		}

		#Create a soldier
		create_character = {
			location = root.capital_province
			culture = root.capital_province.culture
			faith = root.capital_province.faith
			template = pool_repopulate_prowess
			save_scope_as = soldier
			trait = wounded_2
		}

		#Grab physician for loc
		if = {
			limit = {
				employs_court_position = court_physician_court_position
				any_court_position_holder = {
					type = court_physician_court_position
					this != scope:helper
					is_physically_able = yes
			    }
			}
			random_court_position_holder = {
				type = court_physician_court_position
				save_scope_as = physician
		    }
		}
	}

	#Accept help
	option = {
		name = learning_medicine.2050.a

		if = {
			limit = {
				has_relation_friend = scope:helper
			}
			show_as_tooltip = { medicine_2050_a_success_effect = yes }
			trigger_event = learning_medicine.2051
		}
		else = {
			duel = {
				skill = learning
				value = average_skill_rating
				60 = {
					desc = learning_medicine.2050.a.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 2
					}
					modifier = {
						add = {
							value = scope:helper.learning
							subtract = average_skill_rating
							multiply = 2
							min = 10 #Guaranteed help
						}
					}
					show_as_tooltip = { medicine_2050_a_success_effect = yes }
					trigger_event = learning_medicine.2051
				}
				40 = {
					desc = learning_medicine.2050.a.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -2
					}
					modifier = {
						add = {
							value = scope:helper.learning
							subtract = average_skill_rating
							multiply = -2
							max = 0 #They shouldn't make this worse
						}
					}
					show_as_tooltip = { medicine_2050_a_failure_effect = yes }
					trigger_event = learning_medicine.2052
				}
			}
		}

		stress_impact = {
			arrogant = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}

	#Do it yourself
	option = {
		name = learning_medicine.2050.b

		reverse_add_opinion = {
			target = scope:helper
			modifier = insult_opinion
			opinion = -10
		}

		duel = {
			skill = learning
			value = average_skill_rating
			60 = {
				desc = learning_medicine.2050.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
				}
				show_as_tooltip = { medicine_2050_b_success_effect = yes }
				trigger_event = learning_medicine.2053
			}
			40 = {
				desc = learning_medicine.2050.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2
				}
				show_as_tooltip = { medicine_2050_b_failure_effect = yes }
				trigger_event = learning_medicine.2054
			}
		}

		stress_impact = {
			humble = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}

	#Let them die
	option = {
		 	name = learning_medicine.2050.c
		add_dread = medium_dread_gain


		stress_impact = {
			base = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
			forgiving = medium_stress_impact_gain
			just = minor_stress_impact_gain
			sadistic = major_stress_impact_loss
			callous = medium_stress_impact_loss
			vengeful = minor_stress_impact_loss
			arbitrary = minor_stress_impact_loss
		}

		if = {
			limit = {
				scope:helper = { ai_compassion >= low_negative_ai_value }
			}
			reverse_add_opinion = {
				target = scope:helper
				modifier = cruelty_opinion
				opinion = -20
			}
			progress_towards_rival_effect = {
				REASON = rival_let_soldier_die
				CHARACTER = scope:helper
				OPINION = 0
			}
		}

		scope:soldier = {
			death = {
				death_reason = death_wounds
			}
		}

		ai_chance = {
			base = 20
			ai_compassion_target_modifier = { VALUE = -100 }
			ai_vengefulness_target_modifier = { VALUE = 50 }
		}
	}
	after = {
		scope:soldier = {
			silent_disappearance_ai_effect = yes
		}
		scope:helper = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

#We saved soldier together!
learning_medicine.2051 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2050.t
	desc = {
		desc = learning_medicine.2051.start_our.desc
		desc = learning_medicine.2051.start.desc
		desc = learning_medicine.2051.middle.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:helper.highest_held_title_tier >= root.highest_held_title_tier
						is_spouse_of = scope:helper
						is_close_family_of = scope:helper
					}
				}
				desc = learning_medicine.2051.my_ladylord.desc
			}
			desc = learning_medicine.2051.firstname.desc
		}
		desc = learning_medicine.2051.end.desc
	}

	theme = learning_medicine_focus
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = personality_bold
	}
	right_portrait = {
		character = scope:soldier
		animation = admiration
	}
	lower_right_portrait = scope:helper

	immediate = {
		medicine_2050_a_success_effect = yes
	}

	option = {
		name = learning_medicine.2051.a
	}
}


#We lost the soldier together...
learning_medicine.2052 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2050.t
	desc = {
		desc = learning_medicine.2051.start_our.desc
		desc = learning_medicine.2051.start.desc
		desc = learning_medicine.2052.middle.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:helper.highest_held_title_tier >= root.highest_held_title_tier
						is_spouse_of = scope:helper
						is_close_family_of = scope:helper
					}
				}
				desc = learning_medicine.2051.my_ladylord.desc
			}
			desc = learning_medicine.2051.firstname.desc
		}
		desc = learning_medicine.2052.end.desc
	}

	theme = learning_medicine_focus
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:soldier
		animation = dead
	}
	lower_right_portrait = scope:helper

	immediate = {
		medicine_2050_a_failure_effect = yes
	}

	#Accept comfort
	option = {
		name = learning_medicine.2052.a
		if = {
			limit = {
				can_set_relation_potential_friend_trigger = { CHARACTER = scope:helper }
			}
			progress_towards_friend_effect = {
				CHARACTER = scope:helper
				OPINION = 20
				REASON = friend_reassurance
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
	}

	#Be proud
	option = {
		name = learning_medicine.2052.b
		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			target = scope:helper
			modifier = insulted_opinion
			opinion = -5
		}

		stress_impact = {
			humble = minor_stress_impact_gain
		}
	}
}

#I saved the soldier!
learning_medicine.2053 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2050.t
	desc = {
		desc = learning_medicine.2053.start_my.desc
		desc = learning_medicine.2051.start.desc
		desc = learning_medicine.2053.desc
	}

	theme = learning_medicine_focus
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:soldier
		animation = admiration
	}

	immediate = {
		medicine_2050_b_success_effect = yes
	}

	option = {
		name = learning_medicine.2053.a
	}
}

#I lost the soldier...
learning_medicine.2054 = { #by Mathilda Bjarnehed
	type = character_event
	title = learning_medicine.2050.t
	desc = {
		desc = learning_medicine.2053.start_my.desc
		desc = learning_medicine.2051.start.desc
		desc = learning_medicine.2054.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:helper = {
						OR = {
							ai_vengefulness >= medium_positive_ai_value
							ai_compassion <= 0
						}
					}
				}
				desc = learning_medicine.2054.disgust.desc
			}
			desc = learning_medicine.2054.pity.desc
		}
	}

	theme = learning_medicine_focus
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:soldier
		animation = dead
	}

	immediate = {
		medicine_2050_b_failure_effect = yes
	}

	option = {
		name = learning_medicine.2054.a
	}
}


##################################################
# Tea and Cakes
# by Ewan Cowhig Croft
# 2110
##################################################

scripted_trigger learning_medicine_2110_valid_hashish_vassal_or_liege = {
	is_available_ai_adult = yes
	NOR = {
		has_trait = zealous
		has_trait = temperate
	}
	OR = {
		AND = {
			highest_held_title_tier = tier_barony
			is_powerful_vassal_of = root
		}
		highest_held_title_tier >= tier_county
	}
}

#	A vassal (or your liege) wants to eat some hashish while visiting your capital.
#		by Ewan Cowhig Croft
learning_medicine_special.2110 = {
	type = character_event
	title = learning_medicine.2110.t
	desc = {
		desc = learning_medicine.2110.desc	#Preamble.
		first_valid = {
			triggered_desc = {	#Oh, hey, I like that guy.
				trigger = { scope:hashish_relation = flag:positive }
				desc = learning_medicine.2110.desc_good_terms
			}
			triggered_desc = {	#What is this bastard doing in my city?
				trigger = { scope:hashish_relation = flag:negative }
				desc = learning_medicine.2110.desc_bad_terms
			}
			triggered_desc = {	#Yes. You. Person who I have met at some point.
				trigger = { scope:hashish_relation = flag:neutral }
				desc = learning_medicine.2110.desc_neutral_terms
			}
		}
	}
	theme = learning_medicine_focus
	override_background = {
		reference = bp1_crossroads_inn
	}
	left_portrait =	{
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:hashish_vassal_or_liege
		animation = toast_goblet
	}

	trigger = {
		is_at_war = no
		NOT = { has_character_flag = had_event_learning_medicine_2110 }
		any_vassal = { learning_medicine_2110_valid_hashish_vassal_or_liege = yes }
		root.capital_province = {
			NOR = {
				geographical_region = world_europe
				geographical_region = world_asia
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_learning_medicine_2110
			days = 1825
		}
		every_vassal = {
			limit = { learning_medicine_2110_valid_hashish_vassal_or_liege = yes }
			add_to_list = potential_hashish_vassal_or_liege_list
		}
		root.liege = {
			if = {
				limit = {
					learning_medicine_2110_valid_hashish_vassal_or_liege = yes
					top_liege != this
				}
				add_to_list = potential_hashish_vassal_or_liege_list
			}
		}
		random_in_list = {
			list = potential_hashish_vassal_or_liege_list
			weight = {
				base = 1
				modifier = {	#Powerful vassals are interesting characters.
					add = 30
					is_powerful_vassal_of = root
				}
				modifier = {	#Vassals who aren't on the council likely have more tense relations, so major non-councillors are a good pick.
					add = 30
					AND = {
						highest_held_title_tier >= tier_barony
						NOT = { is_councillor_of = root }
					}
				}
				modifier = {	#What an excellent way to get over a rivalry!
					add = 20
					OR = {
						has_relation_potential_rival = root
						has_relation_rival = root
					}
				}
				modifier = {	#Also good for dealing with factions.
					add = 20
					AND = {
						this != root.liege
						OR = {
							is_a_faction_leader = yes
							is_a_faction_member = yes
						}
					}
				}
				modifier = {
					add = 20
					this = root.liege
				}
				modifier = {	#Plus weight up a little for gluttons and gloriers of gluttony.
					add = 10
					OR = {
						has_trait = gluttonous
						faith = { trait_is_virtue = gluttonous }
					}
				}
				modifier = {	#We just like meeting interesting people, to be honest.
					add = 5
					martial >= high_skill_rating
				}
				modifier = {
					add = 5
					intrigue >= high_skill_rating
				}
				modifier = {
					add = 5
					diplomacy >= high_skill_rating
				}
				modifier = {	#Except barons. Barons suck.
					add = -20
					highest_held_title_tier = tier_barony
				}
			}
			save_scope_as = hashish_vassal_or_liege
		}
		scope:hashish_vassal_or_liege = {
			if = {
				limit = {
					OR = {
						has_relation_friend = root
						has_relation_potential_friend = root
						AND = {
							NOR = {
								has_relation_rival = root
								has_relation_potential_rival = root
							}
							opinion = {
								target = root
								value >= medium_positive_opinion
							}
						}
					}
				}
				save_scope_value_as = {
					name = hashish_relation
					value = flag:positive
				}
			}
			else_if = {
				limit = {
					OR = {
						has_relation_rival = root
						has_relation_potential_rival = root
						AND = {
							NOR = {
								has_relation_friend = root
								has_relation_potential_friend = root
							}
							opinion = {
								target = root
								value <= medium_negative_opinion
							}
						}
					}
				}
				save_scope_value_as = {
					name = hashish_relation
					value = flag:negative
				}
			}
			else = {
				save_scope_value_as = {
					name = hashish_relation
					value = flag:neutral
				}
			}
		}
		root.capital_province = { save_scope_as = capital }
	}

	option = {	#You politely, but firmly, turn them down.
		name = {
			text = learning_medicine.2110.a.good_terms
			trigger = { scope:hashish_relation = flag:positive }
		}
		name = {
			text = learning_medicine.2110.a.bad_terms
			trigger = { scope:hashish_relation = flag:negative }
		}
		name = {
			text = learning_medicine.2110.a.neutral_terms
			trigger = { scope:hashish_relation = flag:neutral }
		}
		scope:hashish_vassal_or_liege = {
			add_opinion = {
				modifier = insult_opinion
				opinion = -25
				target = root
			}
		}
		if = {	#Muslims receive additional piety due to their religion's prohibitions on intoxicants.
			limit = {
				faith = { religion_tag = islam_religion }
			}
			add_piety = medium_piety_gain
		}
		else_if = {	#If your faith hates such things, you get a little piety.
			limit = {
				faith = { trait_is_sin = gluttonous }
			}
			add_piety = minor_piety_gain
		}
		else_if = {	#Unless they like them, in which case you confuse and annoy people.
			limit = {
				faith = { trait_is_virtue = gluttonous }
			}
			add_piety = minor_piety_loss
		}
		else = { add_prestige = miniscule_prestige_gain }	#Otherwise you're just a bit of a neutral kill-joy, I guess.
		stress_impact = {
			gregarious = minor_stress_impact_gain
			hashishiyah = medium_stress_impact_gain
			shy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.25	#Who the hell just turns up on my doorstep and expects me to go out? Rude.
				ai_sociability = -0.5
			}
			modifier = {
				add = 40
				has_trait = shy
			}
			modifier = {
				add = 30
				has_trait = temperate
			}
			modifier = {
				add = -20
				has_trait = gregarious
			}
			modifier = {
				add = -20
				has_trait = gluttonous
			}
			modifier = {
				add = -30
				has_trait = hashishiyah
			}
		}
	}
	option = {	#The two of you have a mellow evening of hashishery.
		name = {
			text = learning_medicine.2110.b.good_terms
			trigger = { scope:hashish_relation = flag:positive }
		}
		name = {
			text = learning_medicine.2110.b.bad_terms
			trigger = { scope:hashish_relation = flag:negative }
		}
		name = {
			text = learning_medicine.2110.b.neutral_terms
			trigger = { scope:hashish_relation = flag:neutral }
		}
		flavor = learning_medicine.2110.b.flavour
		scope:hashish_vassal_or_liege = {
			if = {	#Rivalries are overcome!
				limit = { has_relation_rival = root }
				remove_relation_rival = root
				add_opinion = {
					modifier = friendliness_opinion
					opinion = 20
					target = root
				}
			}
			else_if = {	#Potential foeships are nipped in the bud. So to speak.
				limit = { has_relation_potential_rival = root }
				remove_relation_potential_rival = root
				add_opinion = {
					modifier = friendliness_opinion
					opinion = 20
					target = root
				}
			}
		}
		progress_towards_friend_effect = {	#Make some friends!
			CHARACTER = scope:hashish_vassal_or_liege
			OPINION = 30
			REASON = friend_got_high_together
		}
		add_character_modifier = {
			modifier = cosmic_insights_modifier
			days = 3650
		}
		stress_impact = {
			temperate = medium_stress_impact_gain
			shy = minor_stress_impact_gain
			hashishiyah = major_stress_impact_loss
		}
		if = {
			limit = {
				faith = {
					OR = {
						religion_tag = islam_religion
						trait_is_sin = gluttonous
					}
				}
			}
			stress_impact = { zealous = minor_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_vengefulness = -0.25
			}
			modifier = {
				add = 30
				has_trait = hashishiyah
			}
			modifier = {
				add = 20
				has_trait = gluttonous
			}
			modifier = {
				add = 10
				has_trait = gregarious
			}
			modifier = {
				add = -20
				has_trait = temperate
			}
			modifier = {
				add = 20
				has_trait = shy
			}
		}
	}
	option = {	#You and your vassal have it large.
		name = {
			text = learning_medicine.2110.c.good_terms
			trigger = { scope:hashish_relation = flag:positive }
		}
		name = {
			text = learning_medicine.2110.c.bad_terms
			trigger = { scope:hashish_relation = flag:negative }
		}
		name = {
			text = learning_medicine.2110.c.neutral_terms
			trigger = { scope:hashish_relation = flag:neutral }
		}
		duel = {
			skill = learning
			target = scope:hashish_vassal_or_liege
			50 = {	#You steer the conversation to favour you.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = learning_medicine.2110.c.tt_success
				send_interface_toast = {
					title = learning_medicine.2110.c.tt_success
					left_icon = scope:hashish_vassal_or_liege
					if = {
						limit = {
							can_add_hook = {
								target = scope:hashish_vassal_or_liege
								type = manipulation_hook
							}
						}
						add_hook = {
							type = manipulation_hook
							target = scope:hashish_vassal_or_liege
						}
						add_prestige = medium_prestige_gain
					}
					else = { add_prestige = major_prestige_gain }
					scope:hashish_vassal_or_liege = {
						add_opinion = {
							modifier = friendliness_opinion
							opinion = 40
							target = root
						}
					}
				}
			}
			50 = {	#Your vassal manages to dominate the discussion.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = learning_medicine.2110.c.tt_fail
				send_interface_toast = {
					title = learning_medicine.2110.c.tt_fail
					left_icon = scope:hashish_vassal_or_liege
					scope:hashish_vassal_or_liege = {
						if = {
							limit = {
								can_add_hook = {
									target = root
									type = manipulation_hook
								}
							}
							add_hook = {
								type = manipulation_hook
								target = root
							}
							add_prestige = medium_prestige_gain
						}
						else = { add_prestige = major_prestige_gain }
						add_opinion = {
							modifier = friendliness_opinion
							opinion = 30
							target = root
						}
					}
				}
			}
		}
		stress_impact = {
			temperate = major_stress_impact_gain
			shy = medium_stress_impact_gain
			hashishiyah = major_stress_impact_loss
		}
		if = {
			limit = {
				faith = {
					OR = {
						religion_tag = islam_religion
						trait_is_sin = gluttonous
					}
				}
			}
			stress_impact = { zealous = medium_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_sociability = 0.75
				ai_vengefulness = -0.5
			}
			modifier = {
				add = 40
				has_trait = hashishiyah
			}
			modifier = {
				add = 30
				has_trait = gluttonous
			}
			modifier = {
				add = 15
				has_trait = gregarious
			}
			modifier = {
				add = -30
				has_trait = shy
			}
			modifier = {
				add = -40
				has_trait = temperate
			}
		}
	}
}

#########################################################################################
################# SPECIAL EVENTS ########################################################
#########################################################################################



##################################################
# Study human cadavers
# by Linnéa Thimrén and Flavio Verna
##################################################

learning_medicine_special.1001 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = learning_medicine_special.1001.desc

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = page_flipping
	}

	trigger = {
		OR = {
			has_focus = learning_medicine_focus
			has_focus = learning_adventurer_focus
			has_realm_law = camp_purpose_scholars
		}
		NOT = { has_character_flag = had_learning_medicine_special_1001_this_lifetime }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1.5
			has_trait = sadistic
		}
		modifier = {
			add = 1.75
			has_trait = callous
		}
	}

	immediate = {
		add_character_flag = {
			flag = is_in_learning_special_event
			days = 200
		}
		add_character_flag = had_learning_medicine_special_1001_this_lifetime
	}
	option = { #Proceed.
		name = learning_medicine_special.1001.a
		custom_tooltip = learning_lifestyle_rank_up_indication
		trigger_event = {
			id = learning_medicine_special.1002
			days = { 3 7 }
		}
		ai_chance = {
			base = 75
		}
	}

	option = { #nah
		name = learning_medicine_special.1001.b
		add_piety = medium_piety_gain
		remove_character_flag = is_in_learning_special_event
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 0.4
				ai_compassion = 0.4
			}
		}
	}
}

#First botched autopsy, need more bodies.
learning_medicine_special.1002 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = learning_medicine_special.1002.desc

	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = disgust
	}
	right_portrait = {
		character = scope:scoped_physician
		animation = interested
	}
	immediate = {
		if = {
			limit = {
				court_physician_available_trigger = yes
			}
			save_court_physician_as_effect = { SCOPE_NAME = scoped_physician }
		}

		if = {
			limit = {
				exists = capital_county
			}
			capital_county = {
				save_scope_as = scoped_capital

			}
		}
	}
	option = { #Ask Court Physician to provide more bodies.
		name = learning_medicine_special.1002.a
		trigger = {
			exists = scope:scoped_physician
		}
		duel = {
			skill = diplomacy
			target = scope:scoped_physician
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -14
				}
				opinion_modifier = { #their opinion of you matters
					who = scope:scoped_physician
					opinion_target = root
					multiplier = 0.25
				}
				desc = learning_medicine_special.1002.a.good
				show_as_tooltip = {add_learning_lifestyle_xp = minor_lifestyle_xp }
				trigger_event = {
					id = learning_medicine_special.1003
					days = { 7 14 }
				}
			}
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -14
				}
				desc = learning_medicine_special.1002.a.bad
				show_as_tooltip = {
					scope:scoped_physician = {
						add_opinion = {
							target = root
							modifier = pious_opinion
							opinion = -20
						}
					}
				}
				trigger_event = {
					id = learning_medicine_special.1004
					days = { 7 14 }
				}
			}
		}
		ai_chance = {
			base = 50
			opinion_modifier = { #their opinion of you matters
				who = scope:scoped_physician
				opinion_target = root
				multiplier = 0.4
			}
		}
	}

	option = { #Find bodies through other means...
		name = learning_medicine_special.1002.b
		trigger_event = {
			id = learning_medicine_special.1103
			days = { 3 7 }
		}
		if = {
			limit = {
				exists = scope:scoped_capital
				scope:scoped_capital.holder = root
			}
			scope:scoped_capital = {
				add_county_modifier = {
					modifier = tomb_defiler_modifier
					years = 10
				}
			}
		}
		add_learning_lifestyle_xp = minor_lifestyle_xp
		stress_impact = {
			base = medium_stress_impact_gain
			callous = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
		}
		ai_chance = {
			base = 75
		}
	}

	option = { #Back out
		name = learning_medicine_special.1002.c
		add_piety = minor_piety_gain
		add_learning_lifestyle_xp = minor_lifestyle_xp
		remove_character_flag = is_in_learning_special_event
		ai_chance = {
			base = 0
		}
	}
}

#Court Physician (or ruler) provides bodies.
learning_medicine_special.1003 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = {
		desc = learning_medicine_special.1003.desc_physician
		desc = learning_medicine_special.1003.desc_ending
	}
	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:scoped_physician
		animation = sick
	}

	trigger = {
		scope:scoped_physician = {
			is_available_ai_adult = yes
		}
	}

	on_trigger_fail = {
		trigger_event = learning_medicine_special.1004
	}

	immediate = {
		add_learning_lifestyle_xp = minor_lifestyle_xp
	}

	option = {
		name = learning_medicine_special.1003.a
		duel = {
			skill = learning
			value = 12
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
				}
				desc = learning_medicine_special.1003.a.good
				show_as_tooltip = { add_learning_lifestyle_perk_points = 1 }
				trigger_event = {
					id = learning_medicine_special.1005
					days = { 7 14 }
				}
			}
			5 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
				}
				desc = learning_medicine_special.1003.a.bad
				show_as_tooltip = {
					if = {
						limit = {
							has_trait = ill
						}
						death = {
							death_reason = death_ill
						}
					}
					else = {
						contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
						add_learning_lifestyle_xp = medium_lifestyle_xp
					}
					if = {
						limit = {
							NOT = { has_game_rule = epidemic_frequency_disabled }
						}
						random = {
							chance = 10
							scope:scoped_capital ?= {
								title_province = {
									create_epidemic_outbreak = {
										type = dysentery
										intensity = minor
									}
								}
							}
						}
					}
				}
				trigger_event = {
					id = learning_medicine_special.1006
					days = { 7 14 }
				}
			}
		}
	}
	option = { #Stop working.
		name = learning_medicine_special.1003.b
		add_learning_lifestyle_xp = medium_lifestyle_xp
		remove_character_flag = is_in_learning_special_event
	}
}

#Gained bodies in some other fashion
learning_medicine_special.1103 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = {
		desc = learning_medicine_special.1003.desc_fallback
		desc = learning_medicine_special.1003.desc_ending
	}
	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = worry
	}

	immediate = {
		add_learning_lifestyle_xp = minor_lifestyle_xp
	}

	option = {
		name = learning_medicine_special.1003.a
		duel = {
			skill = learning
			value = high_skill_rating
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -14
				}
				desc = learning_medicine_special.1003.a.good
				show_as_tooltip = { add_learning_lifestyle_perk_points = 1 }
				trigger_event = {
					id = learning_medicine_special.1005
					days = { 7 14 }
				}
			}
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -14
				}
				desc = learning_medicine_special.1003.a.bad
				show_as_tooltip = {
					if = {
						limit = {
							has_trait = ill
						}
						death = {
							death_reason = death_ill
						}
					}
					else = {
						contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
						add_learning_lifestyle_xp = medium_lifestyle_xp
					}
					if = {
						limit = {
							NOT = { has_game_rule = epidemic_frequency_disabled }
						}
						random = {
							chance = 10
							scope:scoped_capital ?= {
								title_province = {
									create_epidemic_outbreak = {
										type = dysentery	
										intensity = minor
									}
								}
							}
						}
					}
				}
				trigger_event = {
					id = learning_medicine_special.1006
					days = { 7 14 }
				}
			}
		}
	}
	option = { #Stop working.
		name = learning_medicine_special.1003.b
		add_learning_lifestyle_xp = medium_lifestyle_xp
		remove_character_flag = is_in_learning_special_event
	}
}


#Court Physician disapproves
learning_medicine_special.1004 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = {
		triggered_desc = {
			trigger = {
				scope:scoped_physician = { is_available_ai_adult = yes }
			}
			desc = learning_medicine_special.1004.desc
		}
		triggered_desc = {
			trigger = {
				scope:scoped_physician = { is_available_ai_adult = no }
			}
			desc = learning_medicine_special.1004.unavailable.desc
		}
	}
	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:scoped_physician
		animation = anger
	}

	option = {
		name = {
			trigger = {
				scope:scoped_physician = { is_available_ai_adult = yes }
			}
			text = learning_medicine_special.1004.a
		}
		name = {
			trigger = {
				scope:scoped_physician = { is_available_ai_adult = no }
			}
			text = learning_medicine_special.1004.unavailable.a
		}

		if = {
			limit = {
				scope:scoped_physician = { is_available_ai_adult = yes }
			}
			scope:scoped_physician = {
				add_opinion = {
					target = root
					modifier = pious_opinion
					opinion = -20
				}
			}
		}
		else = {
			custom_tooltip = learning_medicine_special.1004.unavailable.tt
		}

		remove_character_flag = is_in_learning_special_event
	}
}

#No sickness!
learning_medicine_special.1005 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = learning_medicine_special.1005.desc
	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = eccentric
	}

	option = {
		name = learning_medicine_special.1005.a
		add_learning_lifestyle_perk_points = 1
		remove_character_flag = is_in_learning_special_event
	}
}

#Sickness
learning_medicine_special.1006 = {
	type = character_event
	title = learning_medicine_special.1001.t
	desc = {
		desc = learning_medicine_special.1006.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = ill
				}
				desc = learning_medicine_special.1006.desc_death
			}
			desc = learning_medicine_special.1006.desc
		}
	}
	theme = learning_medicine_focus
	left_portrait = {
		character = root
		animation = sick
	}

	immediate = {
		random = {
			chance = 10
			scope:scoped_capital ?= {
				title_province = {
					create_epidemic_outbreak = {
						type = dysentery					
						intensity = minor
					}
				}
			}
		}
	}

	option = {
		name = learning_medicine_special.1006.a
		 if = {
			limit = {
				has_trait = ill
			}
			death = {
				death_reason = death_ill
			}
		}
		else = {
			contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
			add_learning_lifestyle_xp = medium_lifestyle_xp
		}
		if = {
			limit = { is_alive = yes }
			remove_character_flag = is_in_learning_special_event
		}
	}
}


##################################################
# #A Most Miraculous Fish
# by Ewan Cowhig Croft
# #2100
##################################################

scripted_trigger learning_medicine_special_2100_broad_dreamfish_range = {
	is_coastal = yes
	OR = {
		geographical_region = world_europe_west_britannia
		geographical_region = world_europe_west_francia
		geographical_region = world_europe_west_iberia
		geographical_region = world_europe_south
		geographical_region = world_asia_minor
		geographical_region = world_middle_east_jerusalem
		geographical_region = world_africa_north
		geographical_region = world_africa_west
	}
}

#	You consume a hallucinogenic fish.
#		by Ewan Cowhig Croft
learning_medicine_special.2100 = {
	type = character_event
	title = learning_medicine_special.2100.t
	desc = learning_medicine_special.2100.desc
	theme = learning_medicine_focus
	left_portrait =	{
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:fish_alchemist
		animation = scheme
	}

	trigger = {
		is_ai = no
		is_at_war = no
		house ?= {
			NOT = { has_variable = had_event_learning_medicine_special_2100 }
		}
		OR = {
			any_directly_owned_province = { learning_medicine_special_2100_broad_dreamfish_range = yes }
			domicile ?= {
				domicile_location = {
					learning_medicine_special_2100_broad_dreamfish_range = yes
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = learning_medicine_focus }
	}

	immediate = {
		house ?= {
			set_variable = {
				name = had_event_learning_medicine_special_2100
				value = yes
				days = 36500
			}
		}
		random_directly_owned_province = {
			limit = { learning_medicine_special_2100_broad_dreamfish_range = yes }
			save_scope_as = hallucinogenic_fish_locale
		}
		if = {
			limit = {
				NOT = { exists = scope:hallucinogenic_fish_locale }
			}
			domicile ?= {
				domicile_location = {
					save_scope_as = hallucinogenic_fish_locale
				}
			}
		}
		scope:hallucinogenic_fish_locale.county = { save_scope_as = hallucinogenic_fish_county }#For loc.
		create_character = {
			age = { 25 70 }
			gender_female_chance = 50
			trait = deceitful
			random_traits_list = {
				count = 1
				education_diplomacy_1 = {}
				education_martial_1 = {}
				education_stewardship_1 = {}
				education_intrigue_1 = {}
				education_learning_1 = {}
			}
			trait = lifestyle_herbalist
			random_traits_list = {
				count = 1
				ambitious = {}
				gregarious = {}
				impatient = {}
				lustful = {}
				wrathful = {}
				compassionate = {}
				callous = {}
				stubborn = {}
				vengeful = {}
			}
			random_traits = no
			employer = root
			faith = scope:hallucinogenic_fish_locale.faith
			culture = scope:hallucinogenic_fish_locale.culture
			intrigue = 10
			learning = 10
			dynasty = none
			save_scope_as = fish_alchemist
		}
		scope:fish_alchemist ?= { give_witch_secret_or_trait_effect = yes }
	}

	option = {	#Eat the hallucinogenic fish.
		name = learning_medicine_special.2100.a
		random_list = {
			40 = {	#You seem some radical angels and such.
				desc = learning_medicine_special.2100.a.tt_success
				send_interface_toast = {
					title = learning_medicine_special.2100.a.tt_success
					left_icon = scope:fish_alchemist
					add_character_modifier = {
						modifier = hallucinogenic_visions_uplifting_modifier
						days = 7300
					}
					random_secret = {
						type = secret_non_believer
						remove_secret = yes
					}
				}
				modifier = {
					add = 30
					OR = {
						has_trait = lifestyle_herbalist
						has_trait = lifestyle_mystic
						has_trait = witch
						any_secret = { type = secret_witch }
					}
				}
			}
			60 = {	#The devil tries to rip your heart out through your kneecaps.
				desc = learning_medicine_special.2100.a.tt_failure
				send_interface_toast = {
					title = learning_medicine_special.2100.a.tt_failure
					left_icon = scope:fish_alchemist
					add_character_modifier = {
						modifier = hallucinogenic_visions_terrifying_modifier
						days = 7300
					}
					random_secret = {
						type = secret_non_believer
						remove_secret = yes
					}
				}
				modifier = {
					add = -30
					OR = {
						has_trait = lifestyle_herbalist
						has_trait = lifestyle_mystic
						has_trait = witch
						any_secret = { type = secret_witch }
					}
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			temperate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = 0.5 }
			ai_value_modifier = {
				trigger = {
					faith = { has_doctrine_parameter = witchcraft_shunned }
				}
				ai_zeal = -0.25
			}
			ai_value_modifier = {
				trigger = {
					faith = { has_doctrine_parameter = witchcraft_illegal }
				}
				ai_zeal = -0.50
			}
			modifier = {
				add = 20
				OR = {
					has_trait = lifestyle_herbalist
					has_trait = lifestyle_mystic
					has_trait = witch
					any_secret = { type = secret_witch }
				}
			}
			modifier = {
				add = -20
				has_trait = craven
			}
			modifier = {
				add = -20
				has_trait = temperate
			}
		}
	}
	option = {	#You MUST teach me this ritual!
		name = learning_medicine_special.2100.b
		duel = {
			skill = learning
			target = scope:fish_alchemist
			60 = {	#The alchemist teaches you where to catch the right fish and how to prepare them.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = learning_medicine_special.2100.b.tt_success
				send_interface_toast = {
					title = learning_medicine_special.2100.b.tt_success
					left_icon = scope:fish_alchemist
					if = {
						limit = { number_of_lifestyle_traits = 0 }
						add_trait = lifestyle_herbalist
					}
					add_learning_skill = 5
					if = {
						limit = {
							NOT = {
								any_secret = { type = secret_witch }
							}
						}
						give_witch_secret_or_trait_effect = yes
					}
					custom_tooltip = learning_medicine_special.2100.b.tt_success.tt
					hidden_effect = {
						scope:fish_alchemist = {
							add_opinion = {
								target = root
								modifier = loyal_servant
							}
							set_relation_potential_friend = root
						}
					}
				}
			}
			40 = {	#The alchemist is having none of your tomfoolery, and flees the court, causing a scandal.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = learning_medicine_special.2100.b.tt_fail
				send_interface_toast = {
					title = learning_medicine_special.2100.b.tt_fail
					left_icon = scope:fish_alchemist
					add_character_modifier = {
						modifier = associates_with_strange_peasants_modifier
						days = 3650
					}
					if = {
						limit = { has_any_nickname = no }
						give_nickname = nick_the_fishy
					}
					custom_tooltip = learning_medicine_special.2100.b.tt_failure.tt
					hidden_effect = {
						scope:fish_alchemist = {
							move_to_pool = yes
							add_opinion = {
								modifier = spell_thief_attempted_opinion
								target = root
							}
							set_relation_potential_rival = root
						}
					}
				}
			}
		}
		if = {
			limit = {
				faith = {
					OR = {
						has_doctrine_parameter = witchcraft_shunned
						has_doctrine_parameter = witchcraft_illegal
					}
				}
			}
			stress_impact = { zealous = medium_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_greed = 0.25
			}
			ai_value_modifier = {
				trigger = {
					faith = { has_doctrine_parameter = witchcraft_shunned }
				}
				ai_zeal = -0.50
			}
			ai_value_modifier = {
				trigger = {
					faith = { has_doctrine_parameter = witchcraft_illegal }
				}
				ai_zeal = -0.75
			}
			modifier = {
				add = 20
				OR = {
					has_trait = lifestyle_herbalist
					has_trait = lifestyle_mystic
					has_trait = witch
					any_secret = { type = secret_witch }
				}
			}
			modifier = {
				add = -20
				trigger = {
					faith = {
						OR = {
							has_doctrine_parameter = witchcraft_shunned
							has_doctrine_parameter = witchcraft_illegal
						}
					}
				}
				has_trait = zealous
			}
		}
	}
	option = {	#Suffer not the witch to live.
		name = learning_medicine_special.2100.c
		trigger = {
			faith = { has_doctrine_parameter = witchcraft_illegal }
		}
		add_piety = major_piety_gain
		custom_tooltip = learning_medicine_special.2100.c.tt
		hidden_effect = {
			scope:fish_alchemist = {
				death = {
					death_reason = death_burned_witch
					killer = root
				}
			}
		}
		stress_impact = { compassionate = medium_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				trigger = {
					faith = { has_doctrine_parameter = witchcraft_illegal }
				}
				ai_zeal = 0.75
			}
			modifier = {
				add = -20
				OR = {
					has_trait = lifestyle_herbalist
					has_trait = lifestyle_mystic
					has_trait = witch
					any_secret = { type = secret_witch }
				}
			}
			modifier = {
				add = -30
				has_trait = compassionate
			}
			modifier = {
				add = 20
				has_trait = callous
			}
			modifier = {
				add = 30
				has_trait = sadistic
			}
		}
	}
	option = {	#Magic or no, get this commoner out of my good [faith] court.
		name = learning_medicine_special.2100.d
		if = {
			limit = {
				faith = { has_doctrine_parameter = witchcraft_shunned }
			}
			add_prestige = minor_prestige_gain
		}
		else_if = {
			limit = {
				faith = { has_doctrine_parameter = witchcraft_illegal }
			}
			add_prestige = medium_prestige_gain
		}
		add_character_modifier = {
			modifier = aloof_from_the_commoners_modifier
			days = 3650
		}
		custom_tooltip = learning_medicine_special.2100.d.tt
		hidden_effect = {
			scope:fish_alchemist = {
				move_to_pool = yes
				add_opinion = {
					target = root
					modifier = refusal_opinion
					opinion = -30
				}
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.25
			}
		}
	}
}
