﻿namespace = learning_scholarship

namespace = learning_scholarship_special

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

# Learning Scholarship Lifestyle events

	# 1101			- Learn to Read
	# 1201			- Automaton
	# 1401			- Reading Stone
	# 3001			- Brass Orb Experiments
	# 4000			- Dear God, go outside
	# 5000-5007		- Bibliomancy
	# 6000			- The Man of Few Letters

#Special Learning Scholarship Lifestyle events

	# 2001 			- Translate Great Work
	# 3001  		- Lead to Gold

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

##################################################
# Learn to read
# by Linnéa Thimrén
##################################################
learning_scholarship.1101 = {
	type = character_event
	title = learning_scholarship.1101.t
	desc = learning_scholarship.1101.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:bishop
		animation = happy_teacher
	}

	trigger = {
		NOT = {
			has_character_flag = had_event_learning_scholarship_1101
		}
		learning < mediocre_skill_rating #triggers if you need a boost
		OR = {
			AND = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_ai = yes
				}
			}
			AND = {
				has_government = landless_adventurer_government
				any_court_position_holder = {
					learning > high_skill_rating
				}
			}
		}
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_learning_scholarship_1101
			years = 5
		}
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = {
				save_scope_as = bishop
			}
		}
		else = {
			random_court_position_holder = {
				limit = {
					learning > high_skill_rating
				}
				save_scope_as = bishop
			}
		}
	}

	option = { #Accept help
		name = learning_scholarship.1101.a
		add_learning_skill = 1
		add_stress = minor_stress_gain
		add_learning_lifestyle_xp = miniscule_lifestyle_xp
		if = {
			limit = {
				exists = scope:bishop
			}
			add_opinion = {
				target = scope:bishop
				modifier = grateful_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 0.25
			}
		}
	}

	option = { #nah
		name = learning_scholarship.1101.b
		add_prestige = medium_prestige_gain
		add_stress = minor_stress_loss
		ai_chance = {
			base = 25
			modifier = {
				add = 25
				has_trait = arrogant
			}
		}
	}
}


##################################################
# Automaton
# by Linnéa Thimrén & Mathilda Bjarnehed
##################################################
scripted_trigger learning_scholarship_1201_friendly_ruler_trigger = {
	is_adult = yes
	basic_is_available_ai = yes
	NOR = {
		is_at_war_with = root
		government_has_flag = government_is_tribal
	}
	is_landed = yes
	exists = capital_province
	capital_province.culture = { has_innovation = innovation_guilds } #Highly Advanced mechanical bird should not come from an underdeveloped tribe.
	OR = {
		highest_held_title_tier >= tier_kingdom
		AND = {
			learning >= high_skill_rating
			highest_held_title_tier >= tier_duchy
		}
	}
	opinion = {
		target = root
		value >= neutral_opinion
	}
}

learning_scholarship.1201 = {
	type = character_event
	title = learning_scholarship.1201.t
	desc = learning_scholarship.1201.desc

	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:bird_sender
		animation = happiness
	}

	trigger = {
		NOT = {
			has_character_flag = had_event_learning_scholarship_1201
		}
		OR = {
			AND = {
				top_liege = this
				any_neighboring_and_across_water_top_liege_realm_owner = {
					learning_scholarship_1201_friendly_ruler_trigger = yes
				}
			}
			any_vassal = {
				learning_scholarship_1201_friendly_ruler_trigger = yes
			}
			AND = {
				exists = liege
				liege != root
				liege = { learning_scholarship_1201_friendly_ruler_trigger = yes }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			top_liege = this
			any_neighboring_and_across_water_top_liege_realm_owner = {
				learning_scholarship_1201_friendly_ruler_trigger = yes
				opinion = {
					target = root
					value >= medium_positive_opinion
				}
			}
		}
		upweight_for_focus_modifier = { FOCUS = learning_scholarship_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_learning_scholarship_1201
			years = 5
		}
		#Pick someone who sent the bird
		if = {
			limit = {
				top_liege = this
			}
			every_neighboring_and_across_water_top_liege_realm_owner = {
				limit = { learning_scholarship_1201_friendly_ruler_trigger = yes }
				add_to_list = bird_senders
			}
		}
		every_vassal = {
			limit = { learning_scholarship_1201_friendly_ruler_trigger = yes }
			add_to_list = bird_senders
		}
		if = {
			limit = {
				exists = liege
				liege != root
				liege = { learning_scholarship_1201_friendly_ruler_trigger = yes }
			}
			liege = { add_to_list = bird_senders }
		}
		random_in_list = {
			list = bird_senders
			weight = {
				base = 0
				opinion_modifier = {
					opinion_target = root
				}
			}
			save_scope_as = bird_sender
		}
	}

	option = { #have it sing in your halls
		name = learning_scholarship.1201.b

		add_character_modifier = {
			modifier = scholarship_bird_automaton_modifier
			years = 15
		}
		reverse_add_opinion = {
			target = scope:bird_sender
			modifier = pleased_opinion
			opinion = 20
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
				ai_energy = 0.25
			}
		}
	}

	option = { #sell
		name = learning_scholarship.1201.a
		add_gold = medium_gold_value

		reverse_add_opinion = {
			target = scope:bird_sender
			modifier = angry_opinion
			opinion = -20
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.75
			}
		}
	}


	option = { #take apart and study!
	name = learning_scholarship.1201.c
		add_character_modifier = {
			modifier = scholarship_bird_dissection_modifier
			years = 15
		}
		add_learning_lifestyle_xp = medium_lifestyle_xp

		random_list = {
			20 = { #They like your inquisitiveness
				modifier = {
					#At decent learning, x6 (60% chance)
					#At high learning, x15 (~80% chance)
					scope:bird_sender.learning >= medium_skill_rating
					factor = {
						value = scope:bird_sender.learning
						subtract = medium_skill_rating
						multiply = 3
					}
				}
				show_chance = no
				desc = learning_scholarship.1201.c.success
				send_interface_toast = {
					left_icon = scope:bird_sender
					title = learning_scholarship.1201.c.success
					reverse_add_opinion = {
						target = scope:bird_sender
						modifier = respect_opinion
						opinion = 20
					}
				}
				hidden_effect = {
					progress_towards_friend_effect = {
						CHARACTER = scope:bird_sender
						OPINION = 0
						REASON = friend_curiosity_mech_bird
					}
				}
			}
			80 = { #They are offended
				desc = learning_scholarship.1201.c.failure
				show_chance = no
				send_interface_toast = {
					left_icon = scope:bird_sender
					title = learning_scholarship.1201.c.failure
					reverse_add_opinion = {
						target = scope:bird_sender
						modifier = angry_opinion
						opinion = -20
					}
				}
			}
		}

		ai_chance = {
			base = 100
		}
	}
}

##################################################
# Acquire a reading stone
# by Linnéa Thimrén
##################################################
learning_scholarship.1401 = {
	type = character_event
	title = learning_scholarship.1401.t
	desc = learning_scholarship.1401.desc

	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = reading
	}
	right_portrait = {
		character = scope:bishop
		animation = interested
	}

	trigger = {
		NOR = {
			has_character_flag = had_event_learning_scholarship_1401
			has_trait = blind
		}
		OR = {
			is_ai = no
			short_term_gold >= minor_gold_value
		}
	}

	weight_multiplier = {
		base = 0.25
		modifier = {
			# Becomes increasingly common as characters get older.
			# Additional 1.75 weight at 35 years of age (x2 as likely as normal event)
			# Average age for people needing reading glasses is 40-45 in real life.
			add = {
				value = age
				multiply = 0.05
			}
		}
		upweight_for_focus_modifier = { FOCUS = learning_scholarship_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_learning_scholarship_1401
			years = 10
		}
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					NOT = {
						has_hook_of_type = {
							target = root
							type = favor_hook
						}
					}
				}
			}
			cp:councillor_court_chaplain = {
				save_scope_as = bishop
			}
		}
	}

	option = { #Ask Chaplain for help
		name = learning_scholarship.1401.c
		trigger = {
			exists = scope:bishop
		}
		add_learning_lifestyle_xp = major_lifestyle_xp
		scope:bishop = {
			if = {
				limit = {
					can_add_hook = {
						target = root
						type = favor_hook
					}
				}
				add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		ai_chance = {
			base = 75
		}
	}

	option = { #Get a reading stone
		name = learning_scholarship.1401.a
		remove_short_term_gold = medium_gold_value
		add_learning_lifestyle_xp = major_lifestyle_xp
		if = {
			limit = {
				NOT = { government_has_flag = government_is_nomadic }
			}
			add_character_flag = has_reading_glasses
		}
		ai_chance = {
			base = 5
		}
	}

	option = { #Sell all writing that's too small
		name = learning_scholarship.1401.b
		add_gold = medium_gold_value
		add_stress = minor_stress_loss
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.75
			}
		}
	}
}


##################################################
# Scientific Experiments
# by Petter Vilberg
##################################################
#Brass orbs and candles
learning_scholarship.3001 = {
	type = character_event
	title = learning_scholarship.3001.t
	desc = learning_scholarship.3001.desc

	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = manic
	}
	right_portrait = {
		character = scope:chaplain
		animation = worry
	}

	trigger = {
		NOT = { has_character_flag = had_event_learning_scholarship_3001 }
		religion_has_angels_trigger = yes
		OR = {
			exists = cp:councillor_court_chaplain
			AND = {
				has_government = landless_adventurer_government
				any_court_position_holder = {
					learning > high_skill_rating
				}
			}
		}
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_learning_scholarship_3001
			years = 5
		}
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = {
				save_scope_as = chaplain
			}
		}
		else = {
			random_court_position_holder = {
				limit = {
					learning > high_skill_rating
				}
				save_scope_as = chaplain
			}
		}
	}

	option = {
		name = learning_scholarship.3001.c
		duel = {
			skill = learning
			target = scope:chaplain
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -14
				}
				desc = learning_scholarship.3001.c.tt1
				send_interface_toast = {
					title = learning_scholarship.3001.c.toast.tt1
					add_learning_lifestyle_xp = medium_lifestyle_xp
				}
			}
			15 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -14
				}
				desc = learning_scholarship.3001.c.tt2
				send_interface_toast = {
					title = learning_scholarship.3001.c.toast.tt2
					scope:chaplain = {
						add_opinion = {
							target = root
							modifier = impious_opinion
							opinion = -5
						}
					}
				}
			}
		}
	}

	option = {
		name = learning_scholarship.3001.a
		add_learning_lifestyle_xp = minor_lifestyle_xp
		scope:chaplain = {
			add_opinion = {
				target = root
				modifier = impious_opinion
				opinion = -25
			}
		}
		cynical_progression_effect = yes
	}

	option = {
		name = learning_scholarship.3001.b
		add_learning_lifestyle_xp = miniscule_lifestyle_xp
		scope:chaplain = {
			add_opinion = {
				target = root
				modifier = pious_opinion
				opinion = 20
			}
		}
		zealous_progression_effect = yes
	}
}

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

##################################################
# Translate a Great Work
# by Petter Vilberg
##################################################
learning_scholarship_special.2001 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2001.desc

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

	trigger = {
		is_ai = no #Limit the amount of story cycles for AI
		OR = {
			has_focus = learning_scholarship_focus
			has_focus = learning_adventurer_focus
			has_realm_law = camp_purpose_scholars
		}
		NOT = { has_character_flag = had_learning_scholarship_special_2001_this_lifetime }
		NOT = {	has_character_flag = had_book_translation_story }
		any_courtier = { #Requires a scribe
			count >= 1
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = is_in_learning_special_event
			days = 365
		}
		add_character_flag = had_learning_scholarship_special_2001_this_lifetime

		pick_translation_book_effect = {
			OPTION = option_1
		}
		pick_translation_book_effect = {
			OPTION = option_2
		}
	}

	option = {
		name = learning_scholarship_special.2001.regula_pastoralis
		trigger = {
			OR = {
				scope:option_1 = flag:regula_pastoralis
				scope:option_2 = flag:regula_pastoralis
			}
		}
		set_up_translation_story_effect = {
			BOOK = regula_pastoralis
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.physica_elementa
		trigger = {
			OR = {
				scope:option_1 = flag:physica_elementa
				scope:option_2 = flag:physica_elementa
			}
		}
		set_up_translation_story_effect = {
			BOOK = physica_elementa
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.almagest
		trigger = {
			OR = {
				scope:option_1 = flag:almagest
				scope:option_2 = flag:almagest
			}
		}
		set_up_translation_story_effect = {
			BOOK = almagest
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.elements
		trigger = {
			OR = {
				scope:option_1 = flag:elements
				scope:option_2 = flag:elements
			}
		}
		set_up_translation_story_effect = {
			BOOK = elements
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.corpus_hermeticus
		trigger = {
			OR = {
				scope:option_1 = flag:corpus_hermeticus
				scope:option_2 = flag:corpus_hermeticus
			}
		}
		set_up_translation_story_effect = {
			BOOK = corpus_hermeticus
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.treatises_of_hippocrates
		trigger = {
			OR = {
				scope:option_1 = flag:treatises_of_hippocrates
				scope:option_2 = flag:treatises_of_hippocrates
			}
		}
		set_up_translation_story_effect = {
			BOOK = treatises_of_hippocrates
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.peri_psyches
		trigger = {
			OR = {
				scope:option_1 = flag:peri_psyches
				scope:option_2 = flag:peri_psyches
			}
		}
		set_up_translation_story_effect = {
			BOOK = peri_psyches
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.kategoriai
		trigger = {
			OR = {
				scope:option_1 = flag:kategoriai
				scope:option_2 = flag:kategoriai
			}
		}
		set_up_translation_story_effect = {
			BOOK = kategoriai
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.avesta
		trigger = {
			OR = {
				scope:option_1 = flag:avesta
				scope:option_2 = flag:avesta
			}
		}
		set_up_translation_story_effect = {
			BOOK = avesta
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.de_oratore
		trigger = {
			OR = {
				scope:option_1 = flag:de_oratore
				scope:option_2 = flag:de_oratore
			}
		}
		set_up_translation_story_effect = {
			BOOK = de_oratore
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.book_of_arda_viraf
		trigger = {
			OR = {
				scope:option_1 = flag:book_of_arda_viraf
				scope:option_2 = flag:book_of_arda_viraf
			}
		}
		set_up_translation_story_effect = {
			BOOK = book_of_arda_viraf
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.upanishads
		trigger = {
			OR = {
				scope:option_1 = flag:upanishads
				scope:option_2 = flag:upanishads
			}
		}
		set_up_translation_story_effect = {
			BOOK = upanishads
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.rigveda
		trigger = {
			OR = {
				scope:option_1 = flag:rigveda
				scope:option_2 = flag:rigveda
			}
		}
		set_up_translation_story_effect = {
			BOOK = rigveda
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.book_of_balances
		trigger = {
			OR = {
				scope:option_1 = flag:book_of_balances
				scope:option_2 = flag:book_of_balances
			}
		}
		set_up_translation_story_effect = {
			BOOK = book_of_balances
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.secret_of_secrets
		trigger = {
			OR = {
				scope:option_1 = flag:secret_of_secrets
				scope:option_2 = flag:secret_of_secrets
			}
		}
		set_up_translation_story_effect = {
			BOOK = secret_of_secrets
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.court_of_agriculture
		trigger = {
			OR = {
				scope:option_1 = flag:court_of_agriculture
				scope:option_2 = flag:court_of_agriculture
			}
		}
		set_up_translation_story_effect = {
			BOOK = court_of_agriculture
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.lanterns_of_wisdom
		trigger = {
			OR = {
				scope:option_1 = flag:lanterns_of_wisdom
				scope:option_2 = flag:lanterns_of_wisdom
			}
		}
		set_up_translation_story_effect = {
			BOOK = lanterns_of_wisdom
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.shahnameh
		trigger = {
			OR = {
				scope:option_1 = flag:shahnameh
				scope:option_2 = flag:shahnameh
			}
		}
		set_up_translation_story_effect = {
			BOOK = shahnameh
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.arithmetica
		trigger = {
			OR = {
				scope:option_1 = flag:arithmetica
				scope:option_2 = flag:arithmetica
			}
		}
		set_up_translation_story_effect = {
			BOOK = arithmetica
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.pali_canon
		trigger = {
			OR = {
				scope:option_1 = flag:pali_canon
				scope:option_2 = flag:pali_canon
			}
		}
		set_up_translation_story_effect = {
			BOOK = pali_canon
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.the_norse_sagas
		trigger = {
			OR = {
				scope:option_1 = flag:the_norse_sagas
				scope:option_2 = flag:the_norse_sagas
			}
		}
		set_up_translation_story_effect = {
			BOOK = the_norse_sagas
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.family_history
		trigger = {
			OR = {
				scope:option_1 = flag:family_history
				scope:option_2 = flag:family_history
			}
		}
		set_up_translation_story_effect = {
			BOOK = family_history
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.ancient_myths
		trigger = {
			OR = {
				scope:option_1 = flag:ancient_myths
				scope:option_2 = flag:ancient_myths
			}
		}
		set_up_translation_story_effect = {
			BOOK = ancient_myths
		}
		custom_tooltip = learning_lifestyle_rank_up_indication
	}

	option = {
		name = learning_scholarship_special.2001.decline
		stress_impact = {
			base = minor_stress_loss
		}
		remove_character_flag = is_in_learning_special_event
	}
}

#Confusing passage
learning_scholarship_special.2011 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2011.desc

	left_portrait = {
		character = root
		animation = stressed_teacher
	}
	theme = learning_scholarship_focus

	trigger = {
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_2011
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_2011
				value = yes
			}
		}
	}

	option = { #My interpretation is better
		name = learning_scholarship_special.2011.a
		duel = {
			skill = learning
			value = average_skill_rating

			20 = {
				desc = learning_scholarship_special.2011.a.success
				compare_modifier = {
					value = scope:duel_value
				}
				learning_scholarship_special_2011_significantly_improve_translation_effect = yes
				send_interface_toast = {
					title = book_translation_toast.more_good
					left_icon = root
					add_prestige = medium_prestige_gain
				}
			}
			20 = {
				desc = learning_scholarship_special.2011.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
				}
				custom_tooltip = book_translation_tooltip.unchanged
				send_interface_toast = {
					title = book_translation_toast.unchanged
					left_icon = root
					add_prestige = minor_prestige_gain
				}
			}
		}
		cynical_progression_effect = yes
	}

	option = { #Let's stay true to the text
		name = learning_scholarship_special.2011.b
		add_piety = medium_piety_gain
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
		zealous_progression_effect = yes
	}

	option = { #Oh, the meaning is obvious
		name = learning_scholarship_special.2011.c
		trigger = {
			has_trait = scholar
		}
		trait = scholar
		add_prestige = minor_prestige_gain
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
	}

	option = { #Oh, the meaning is obvious
		name = learning_scholarship_special.2011.c
		trigger = {
			NOT = {	has_trait = scholar }
			learning >= very_high_skill_rating
		}
		skill = learning
		add_prestige = minor_prestige_gain
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
	}
}

#Realm Priest offers help
learning_scholarship_special.2012 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2012.desc

	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = reading
	}
	right_portrait = {
		character = scope:realm_priest
		animation = happy_teacher
	}

	trigger = {
		OR = {
			AND = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_ai = yes
				}
			}
			employs_court_position = camp_priest_camp_officer
		}
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_2012
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			cp:councillor_court_chaplain = {
				opinion = {
					target = root
					value < 30
				}
			}
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_2012
				value = yes
			}
		}
		cp:councillor_court_chaplain ?= {
			save_scope_as = realm_priest
		}
		if = {
			limit = {
				NOT = { exists = scope:realm_priest }
			}
			random_court_position_holder = {
				type = camp_priest_camp_officer
				save_scope_as = realm_priest
			}
		}
	}

	option = {
		name = learning_scholarship_special.2012.a
		scope:realm_priest = {
			duel = {
				skill = learning
				value = average_skill_rating
				20 = {
					desc = learning_scholarship_special.2012.a.success
					compare_modifier = {
						value = scope:duel_value
					}
					learning_scholarship_special_2011_significantly_improve_translation_effect = yes
					send_interface_toast = {
						title = book_translation_toast.more_good
						left_icon = scope:realm_priest
						add_learning_lifestyle_xp = minor_lifestyle_xp
					}
				}
				20 = {
					desc = learning_scholarship_special.2012.a.failure
					compare_modifier = {
						value = scope:duel_value
					}
					learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
					send_interface_toast = {
						title = book_translation_toast.less_good
						left_icon = scope:realm_priest
					}
				}
			}
		}
	}

	option = {
		name = learning_scholarship_special.2012.b
		scope:realm_priest = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}
		add_prestige = minor_prestige_loss
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
	}

	option = {
		name = learning_scholarship_special.2012.c
		trigger = {
			has_relation_friend = scope:realm_priest
		}
		custom_tooltip = learning_scholarship_special.2012.c.friendship_tooltip
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
		scope:realm_priest = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = low_positive_opinion
			}
		}
	}
}

#Sudden Insight
learning_scholarship_special.2013 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2013.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = happy_teacher
	}

	trigger = {
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_translation_quality_event
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_translation_quality_event
				value = yes
			}
		}
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
		add_learning_lifestyle_xp = minor_lifestyle_xp
	}

	option = { #Unlike ReligiousText...
		name = learning_scholarship_special.2013.a
		cynical_progression_effect = yes
		add_prestige = medium_prestige_gain

	}

	option = { #As evident from the will of HighGod...
		name = learning_scholarship_special.2013.b
		zealous_progression_effect = yes
		add_piety = medium_piety_gain
	}
}

#The Book is Boring
learning_scholarship_special.2014 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2014.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = eyeroll
	}

	trigger = {
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_translation_quality_event
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_translation_quality_event
				value = yes
			}
		}
	}

	option = { #I'll still get it done!
		name = learning_scholarship_special.2014.a
		add_stress = medium_stress_gain
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
	}

	option = { #My scribes can work overtime
		name = learning_scholarship_special.2014.b
		remove_short_term_gold = 2
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
	}

	option = { #Take a break
		name = learning_scholarship_special.2014.c
		add_stress = medium_stress_loss
		custom_tooltip = book_translation_tooltip.unchanged
	}
}

#Working long into the night
learning_scholarship_special.2015 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2015.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = page_flipping
	}
	right_portrait = {
		character = scope:realm_priest
		animation = worry
	}

	trigger = {
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_2015
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_2015
				value = yes
			}
		}
	}

	option = { # Let's keep going
		name = learning_scholarship_special.2015.a
		# Note: This option is intentionally worse in almost all situations
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
		speed_up_translation_effect = yes
		add_learning_lifestyle_xp = minor_lifestyle_xp
		add_stress = minor_stress_gain
	}

	option = { # Get some rest
		name = learning_scholarship_special.2015.b
		add_learning_lifestyle_xp = miniscule_lifestyle_xp
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
	}

	option = { # Scribes can work while I sleep
		name = learning_scholarship_special.2015.c
		custom_tooltip = book_translation_tooltip.unchanged
		add_stress = medium_stress_loss
	}
}

# Scribe makes unapproved changes
learning_scholarship_special.2016 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2016.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = stressed_teacher
	}

	trigger = {
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_2016
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_2016
				value = yes
			}
		}
	}

	option = { # Get out of here!
		name = learning_scholarship_special.2016.a
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
		add_prestige = minor_prestige_loss
	}

	option = { # The rest of you better learn from this
		name = learning_scholarship_special.2016.b
		flavor = learning_scholarship_special.2016.b.flavor
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
		add_character_modifier = {
			modifier = terrified_courtiers_modifier
			years = 5
		}
	}

	option = { # These are pretty good, actually
		name = learning_scholarship_special.2016.c
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
		speed_up_translation_effect = yes
	}
}

# Tired from constant work
learning_scholarship_special.2017 = {
	type = character_event
	title = learning_scholarship_special.2001.t
	desc = learning_scholarship_special.2017.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = sadness
	}

	trigger = {
		NOR = {
			exists = scope:story.var:had_learning_scholarship_special_2017
			is_imprisoned = yes
			has_trait = incapable
		}
	}

	immediate = {
		scope:story = {
			set_variable = {
				name = had_learning_scholarship_special_2017
				value = yes
			}
		}
	}

	option = { # I can do a few more events- I mean pages, at least
		name = learning_scholarship_special.2017.a
		add_stress = medium_stress_gain
		learning_scholarship_special_2011_significantly_improve_translation_effect = yes
	}

	option = { # I will seclude myself with prayer and focus
		name = learning_scholarship_special.2017.b
		add_prestige = medium_prestige_gain
		learning_scholarship_special_2011_somewhat_improve_translation_effect = yes
	}

	option = { # I'd rather do something else
		name = learning_scholarship_special.2017.c
		add_stress = minor_stress_loss
		custom_tooltip = book_translation_tooltip.unchanged
	}
}


# Good outcome of the translation
learning_scholarship_special.2097 = {
	type = character_event
	title = learning_scholarship_special.2097.t
	desc = {
		desc = learning_scholarship_special.2097.opening
		desc = learning_scholarship_special.2097.conclusion
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = learning_scholarship_special.2097.a
		add_character_modifier = {
			modifier = book_translation_excellent_modifier
			years = 10
		}
		add_learning_lifestyle_perk_points = 1
	}

	after = {
		remove_character_modifier = book_translation_ongoing_modifier
		hidden_effect = {
			scope:story = {
				end_story = yes
			}
		}
	}
}


# Bad outcome of the translation
learning_scholarship_special.2098 = {
	type = character_event
	title = learning_scholarship_special.2098.t
	desc = {
		desc = learning_scholarship_special.2098.opening
		desc = learning_scholarship_special.2098.conclusion
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = happiness
	}

	option = {
		name = learning_scholarship_special.2098.a
		add_character_modifier = {
			modifier = book_translation_mediocre_modifier
			years = 10
		}
		add_learning_lifestyle_perk_points = 1
	}

	after = {
		remove_character_modifier = book_translation_ongoing_modifier
		hidden_effect = {
			scope:story = {
				end_story = yes
			}
		}
	}
}

### Great Work Translation - END

##################################################
# Lead to Gold									#
# by Sean Hughes and Linnéa Thimrén				#
# 3001-3005										#
##################################################

# Could these scribbles in this book actually be useful information?
learning_scholarship_special.3001 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		desc = learning_scholarship_special.3001.desc_opening
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3001.desc_alchemist
			}
			desc = learning_scholarship_special.3001.desc
		}
		desc = learning_scholarship_special.3001.desc_ending
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:alchemist }
			animation = eccentric
		}
		animation = page_flipping
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = page_flipping
	}

	trigger = {
		OR = {
			has_focus = learning_scholarship_focus
			has_focus = learning_adventurer_focus
			has_realm_law = camp_purpose_scholars
		}
		NOT = {	has_character_flag = had_learning_scholarship_special_3001_this_lifetime }
	}

	weight_multiplier = {
		base = 1
		modifier = { # A bit more likely to trigger if we are currently sponsoring an alchemist
			add = 0.25
			any_sponsored_inspiration = {
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = { is_available_ai_adult = yes }
			}
		}
		modifier = { # A lot more likely to trigger if we are currently sponsoring an alchemist that's looking into gold
			add = 4
			any_sponsored_inspiration = {
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = {
					is_available_ai_adult = yes
					exists = var:artifact_alchemy_type_metal_subtype
					var:artifact_alchemy_type_metal_subtype = flag:gold
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = is_in_learning_special_event
			days = 200
		}
		add_character_flag = had_learning_scholarship_special_3001_this_lifetime

		# Let's save the alchemist we're sponsoring!
		if = {
			limit = {
				any_sponsored_inspiration = {
					has_inspiration_type = alchemy_inspiration
					inspiration_owner = { is_available_ai_adult = yes }
				}
			}
			random_sponsored_inspiration = {
				limit = {
					has_inspiration_type = alchemy_inspiration
					inspiration_owner = { is_available_ai_adult = yes }
				}
				inspiration_owner = {
					save_scope_as = alchemist
				}
			}
		}
	}

	# Option A: Attempt the experiment!
	option = {
		name = learning_scholarship_special.3001.a
		custom_tooltip = learning_lifestyle_rank_up_indication
		trigger_event = {
			id = learning_scholarship_special.3002
			days = { 5 9 }
		}

		if = {
			limit = {
				faith = {
					OR = {
						NOT = { has_doctrine_parameter = witchcraft_accepted }
						trait_is_sin = greedy
					}
				}
			}
			stress_impact = {
				# Non-trusting characters find this notion to be absurd.
				cynical = minor_stress_impact_gain
				paranoid = minor_stress_impact_gain

				# If greed is a sin, this path is also stressful for zealous characters.
				zealous = minor_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				# Non-trusting characters find this notion to be absurd.
				cynical = minor_stress_impact_gain
				paranoid = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 33

			ai_value_modifier = {
				ai_greed = 500
				ai_zeal = -200
				ai_rationality = -100
			}
		}
	}

	# Option B: Cynical Opt-Out (it really is a silly idea, even if it technically works)
	option = {
		name = learning_scholarship_special.3001.b
		add_character_modifier = {
			modifier = logical_thinking_modifier
			years = 5
		}
		cynical_progression_effect = yes


		stress_impact = {
			eccentric = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 33

			ai_value_modifier = {
				ai_zeal = -100
				ai_rationality = 200
			}
		}
	}

	# Option C-1: Zealous Opt-Out (requires Greedy to be a sin)
	option = {
		trigger = {
			faith = {
				trait_is_sin = greedy
			}
		}
		name = learning_scholarship_special.3001.c

		add_piety = medium_piety_gain
		zealous_progression_effect = yes

		stress_impact = {
			eccentric = medium_stress_impact_gain
			cynical = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 33

			ai_value_modifier = {
				ai_zeal = 200
			}
		}
	}

	# Option C-2: Zealous Opt-Out (requires Witchcraft to be shunned or criminal)
	option = {
		trigger = {
			faith = {
				NOR = {
					has_doctrine_parameter = witchcraft_accepted
					trait_is_sin = greedy
				}
			}
		}
		name = learning_scholarship_special.3001.d

		add_piety = medium_piety_gain
		zealous_progression_effect = yes

		stress_impact = {
			greedy = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 33

			ai_value_modifier = {
				ai_zeal = 200
			}
		}
	}
}


# Okay, so how do we get our lead?
# scripted trigger to make sure the alchemist is still available (if we're using them)
scripted_trigger learning_scholarship_special_3001_alchemist_available_trigger = {
	exists = scope:alchemist
	scope:alchemist = {
		is_alive = yes
		is_available_ai_adult = yes
	}
}

learning_scholarship_special.3002 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3002.desc_alchemist
			}
			desc = learning_scholarship_special.3002.desc
		}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = physician
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = page_flipping
	}

	trigger = {
		NOR = {
			is_imprisoned = yes
			has_trait = incapable
		}
	}
	on_trigger_fail = {
		trigger_event = learning_scholarship_special.3099
	}

	immediate = {
		if = { #If the alchemist is no longer around we clear them out
			limit = {
				learning_scholarship_special_3001_alchemist_available_trigger = no
			}
			clear_saved_scope = alchemist
		}
	}

	# Option A: Buy it! The safer choice.
	option = {
		trigger = {
			OR = {
				is_ai = no
				short_term_gold > medium_gold_value
			}
		}
		name = learning_scholarship_special.3002.a
		remove_short_term_gold = medium_gold_value
		custom_tooltip = learning_scholarship_special.3002.tt
		trigger_event = {
			id = learning_scholarship_special.3003
			days = { 11 17 }
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50

			ai_value_modifier = {
				ai_greed = -200
				ai_rationality = 200
			}
		}
	}

	# Option B: Make it ourselves! Risk of gaining long-term lead poisoning, but low-Learning characters will earn a base Learning increase.
	option = {
		name = {
			trigger = { NOT = { exists = scope:alchemist } }
			text = learning_scholarship_special.3002.b
		}
		name = {
			trigger = { exists = scope:alchemist }
			text = learning_scholarship_special.3002.b_alchemist
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			craven = minor_stress_impact_gain
		}

		if = {
			limit = {
				learning < high_skill_rating
			}
			add_learning_skill = 1
		}

		if = {
			limit = {
				exists = scope:alchemist
				scope:alchemist = { learning < high_skill_rating }
			}
			scope:alchemist = { add_learning_skill = 1 }
		}

		# Since the learning skill might be different if they get +1, we don't/can't want to reveal the exact event outcomes & their probabilities to the player
		show_as_tooltip = {
			duel = {
				skill = learning
				value = 0
				1 = {
					desc = learning_scholarship_special.3002.a.success
					show_chance = no
					add_learning_lifestyle_xp = medium_lifestyle_xp
				}
				1 = {
					desc = learning_scholarship_special.3002.a.failure
					show_chance = no
					add_character_modifier = {
						modifier = chronic_headaches_modifier
						years = 20
					}
					add_learning_lifestyle_xp = miniscule_lifestyle_xp
				}
			}
		}

		# Real dueal logic here
		hidden_effect = {
			duel = {
				skill = learning
				value = medium_skill_rating
				50 = {
					desc = learning_scholarship_special.3002.a.success
					send_interface_toast = {
						title = learning_scholarship_special.3002.a.success
						left_icon = root
						custom_tooltip = learning_scholarship_special.3002.tt
						add_learning_lifestyle_xp = medium_lifestyle_xp
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
	  					multiplier = -10
	  					min = -49
	  				}
					desc = learning_scholarship_special.3002.a.failure
					send_interface_toast = {
						title = learning_scholarship_special.3002.a.failure
						left_icon = root
						add_character_modifier = {
							modifier = chronic_headaches_modifier
							years = 20
						}
						custom_tooltip = learning_scholarship_special.3002.tt
						add_learning_lifestyle_xp = miniscule_lifestyle_xp
					}
				}
			}
			trigger_event = {
				id = learning_scholarship_special.3003
				days = { 7 11 }
			}
		}

		ai_chance = {
			base = 50

			ai_value_modifier = {
				ai_energy = -100
				ai_boldness = 100
				ai_greed = 200
			}
		}
	}

	# Option C: On second thought maybe experimenting with lead is a bad idea?
	option = {
		name = learning_scholarship_special.3002.c
		add_learning_lifestyle_xp = minor_lifestyle_xp
		ai_chance = {
			base = 0
		}
	}
}

# Lead obtained, now we need to get some seaweed...
learning_scholarship_special.3003 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3003.desc_alchemist
			}
			desc = learning_scholarship_special.3003.desc
		}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = physician
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = page_flipping
	}

	trigger = {
		NOR = {
			is_imprisoned = yes
			has_trait = incapable
		}
	}
	on_trigger_fail = {
		trigger_event = learning_scholarship_special.3099
	}

	immediate = {
		if = { #If the alchemist is no longer around we clear them out
			limit = {
				learning_scholarship_special_3001_alchemist_available_trigger = no
			}
			clear_saved_scope = alchemist
		}
	}

	# Option A: Buy it! Again!
	option = {
		trigger = {
			OR = {
				is_ai = no
				short_term_gold > medium_gold_value
			}
		}
		name = learning_scholarship_special.3003.a
		remove_short_term_gold = medium_gold_value
		custom_tooltip = learning_scholarship_special.3003.tt
		trigger_event = {
			id = learning_scholarship_special.3004
			days = { 11 17 }
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50

			ai_value_modifier = {
				ai_greed = -200
				ai_rationality = 100
			}
		}
	}

	# Option B: Demand it from your vassals. They will do it, but think you a bit daft...
	option = {
		name = learning_scholarship_special.3003.b
		add_prestige = medium_prestige_loss
		custom_tooltip = learning_scholarship_special.3003.tt
		trigger_event = {
			id = learning_scholarship_special.3004
			days = { 21 28 }
		}

		stress_impact = {
			humble = minor_stress_impact_gain
			just = minor_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50

			ai_value_modifier = {
				ai_boldness = 200
				ai_rationality = -100
			}
		}
	}

	# Option C: Opt-Out. Just use the lead you acquired in the previous event to make sweetened wine.
	option = {
		name = learning_scholarship_special.3003.c
		add_gold = minor_gold_value
		add_prestige = minor_prestige_gain
		add_learning_lifestyle_xp = minor_lifestyle_xp

		stress_impact = {
			eccentric = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
		}
	}
}

# Reagents obtained, time to experiment!
learning_scholarship_special.3004 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3004.desc_alchemist
			}
			desc = learning_scholarship_special.3004.desc
		}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = eccentric
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = interested
	}

	trigger = {
		NOR = {
			is_imprisoned = yes
			has_trait = incapable
		}
	}
	on_trigger_fail = {
		trigger_event = learning_scholarship_special.3099
	}

	immediate = {
		if = { #If the alchemist is no longer around we clear them out
			limit = {
				learning_scholarship_special_3001_alchemist_available_trigger = no
			}
			clear_saved_scope = alchemist
		}
	}

	# Option A: Begin the experiment!
	option = {
		name = learning_scholarship_special.3004.a

		# We don't want to reveal the exact event outcomes & their probabilities to the player, so we will show this fake duel to them instead.
		show_as_tooltip = {
			duel = {
				skill = learning
				value = 0
				desc = outcome_in_a_few_days
				1 = {
					desc = learning_scholarship_special.3004.a.success
					show_chance = no
					custom_tooltip = learning_scholarship_special.3004.a.success.tt
					add_learning_lifestyle_perk_points = 1
					if = {
						limit = { exists = scope:alchemist }
						scope:alchemist = {
							change_artifact_quality_effect = { AMOUNT = 2 }
						}
					}
				}
				1 = {
					desc = learning_scholarship_special.3004.a.failure
					show_chance = no
					custom_tooltip = learning_scholarship_special.3004.a.failure.tt
					add_learning_lifestyle_xp = minor_lifestyle_xp
				}
			}
		}

		# The real event outcome logic happens here.
		hidden_effect = {
			duel = {
				skill = learning
				value = medium_skill_rating
				# Low chance of getting a critical success, growing to ~50% at 15 skill.
				01 = {
					compare_modifier = {
						value = scope:duel_value
	  					multiplier = 20
	  				}
					trigger_event = {
						id = learning_scholarship_special.3005
						days = { 3 5 }
					}
				}
				# Above average chance of getting a success, which very slowly shrinks to ~45% at 15 skill.
				59 = {
					desc = learning_scholarship_special.3005.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 5
					}
					trigger_event = {
						id = learning_scholarship_special.3006
						days = { 3 5 }
					}
				}
				# Below average chance of failing, which rapidly shrinks to 0% at 18 skill.
				40 = {
					desc = learning_scholarship_special.3005.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -5
					}
					trigger_event = {
						id = learning_scholarship_special.3007
						days = { 3 5 }
					}
				}
			}
		}

		ai_chance = {
			base = 100
		}
	}

	# Option B: Final chance for opt-out.
	option = {
		name = learning_scholarship_special.3004.b
		add_learning_lifestyle_xp = medium_lifestyle_xp
		add_character_modifier = {
			modifier = logical_thinking_modifier
			years = 10
		}

		ai_chance = {
			base = 0
		}
	}
}

# Critical Success! Knowledge, Wealth, Glory... all mine!
learning_scholarship_special.3005 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3005.desc_alchemist
			}
			desc = learning_scholarship_special.3005.desc
		}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = ecstasy
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = dancing
	}

	trigger = {
		NOR = {
			is_imprisoned = yes
			has_trait = incapable
		}
	}
	on_trigger_fail = {
		trigger_event = learning_scholarship_special.3099
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		if = { #If the alchemist is no longer around we clear them out
			limit = {
				learning_scholarship_special_3001_alchemist_available_trigger = no
			}
			clear_saved_scope = alchemist
		}
	}

	option = {
		name = {
			trigger = { NOT = { exists = scope:alchemist } }
			text = learning_scholarship_special.3005.a
		}
		name = {
			trigger = { exists = scope:alchemist }
			text = learning_scholarship_special.3005.a_alchemist
		}
		add_learning_lifestyle_perk_points = 1
		add_gold = medium_gold_value
		add_prestige = major_prestige_gain
		if = {
			limit = { exists = scope:alchemist }
			scope:alchemist = {
				change_artifact_quality_effect = { AMOUNT = 2 }
			}
		}
	}
}

# Success. Rank up + some gold gain.
learning_scholarship_special.3006 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3006.desc_alchemist
			}
			desc = learning_scholarship_special.3006.desc
		}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = ecstasy
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = dancing
	}

	trigger = {
		NOR = {
			is_imprisoned = yes
			has_trait = incapable
		}
	}
	on_trigger_fail = {
		trigger_event = learning_scholarship_special.3099
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		if = { #If the alchemist is no longer around we clear them out
			limit = {
				learning_scholarship_special_3001_alchemist_available_trigger = no
			}
			clear_saved_scope = alchemist
		}
	}

	option = {
		name = learning_scholarship_special.3006.a
		add_learning_lifestyle_perk_points = 1
		add_gold = minor_gold_value
		if = {
			limit = { exists = scope:alchemist }
			scope:alchemist = {
				change_artifact_quality_effect = { AMOUNT = 2 }
			}
		}
	}
}

# Failure. No rank-up, but character is compensated with small province tax boost.
learning_scholarship_special.3007 = {
	type = character_event
	title = learning_scholarship_special.3001.t
	desc = {
		first_valid = {
			triggered_desc = {
			    trigger = {
					exists = scope:alchemist
			    }
			    desc = learning_scholarship_special.3007.desc_alchemist
			}
			desc = learning_scholarship_special.3007.desc
		}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = stunned
	}
	right_portrait = {
		trigger = { exists = scope:alchemist }
		character = scope:alchemist
		animation = shame
	}

	trigger = {
		NOR = {
			is_imprisoned = yes
			has_trait = incapable
		}
	}
	on_trigger_fail = {
		trigger_event = learning_scholarship_special.3099
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		if = { #If the alchemist is no longer around we clear them out
			limit = {
				learning_scholarship_special_3001_alchemist_available_trigger = no
			}
			clear_saved_scope = alchemist
		}
	}

	option = {
		name = learning_scholarship_special.3007.a
		add_learning_lifestyle_xp = medium_lifestyle_xp
		if = {
			limit = {
				exists = capital_province
			}
			capital_province = {
				county = {
					add_county_modifier = {
						modifier = rich_fertilizer_modifier
						years = 3
					}
				}
			}
		}
	}
}

learning_scholarship_special.3099 = {
	hidden = yes

	immediate = {
		if = {
			limit = {
				is_imprisoned = yes
			}
			send_interface_toast = {
				title = learning_scholarship_special.3099.termination.toast
				custom_tooltip = learning_scholarship_special.3099.termination.desc.prison
			}
		}
		else = {
			send_interface_toast = {
				title = learning_scholarship_special.3099.termination.toast
				custom_tooltip = learning_scholarship_special.3099.termination.desc.incapable
			}
		}
	}
}

##################
# 4000 - Dear God, go outside. By Isabella Welch
##################

learning_scholarship.4000 = {
	type = character_event
	title = learning_scholarship.4000.t
	desc = learning_scholarship.4000.desc
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = page_flipping
	}
	right_portrait = {
		character = scope:spouse_uninterested_in_study
		animation = stayback
	}
	lower_left_portrait = {
		character = scope:child_educated
	}
	override_background = {
		reference = corridor_night
	}

	trigger = {
		NOR = {
			has_government = celestial_government
			has_character_flag = has_had_learning_scholarship_4000
			has_trait = celibate
		}
		OR = {
			has_focus = learning_scholarship_focus
			has_focus = learning_adventurer_focus
			has_realm_law = camp_purpose_scholars
		}
		is_married = yes
		any_spouse = {
			NOR = {
				has_trait_rank = {
					trait = education_learning
					rank >= 1
				}
				has_trait = intellect_good
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = has_had_learning_scholarship_4000
			years = 5
		}
		if = {
			limit = {
				any_child = {
					has_focus = education_learning
					has_relation_guardian = root
					is_child_of = root
				}
			}
			random_child = {
				limit = {
					has_focus = education_learning
					has_relation_guardian = root
					is_child_of = root
				}
				save_scope_as = child_educated
			}
		}
		random_spouse = {
			weight = {
				base = 1
				compare_modifier = {
   					value = learning
   					multiplier = -0.5
   				}
			}
			save_scope_as = spouse_uninterested_in_study
		}
		if = {
			limit = {
				any_courtier_or_guest = {
					can_set_relation_lover_trigger = {
						CHARACTER = scope:spouse_uninterested_in_study
					}
				}
			}
			random_courtier_or_guest = {
				limit = {
					can_set_relation_lover_trigger = {
						CHARACTER = scope:spouse_uninterested_in_study
					}
				}
				save_scope_as = potential_new_spouse_lover
			}
		}
	}

	option = {
		name = learning_scholarship.4000.a
		add_character_modifier = {
			modifier = alluring_confidence
			years = 1
		}
		scope:spouse_uninterested_in_study = {
			add_opinion = {
				target = root
				opinion = 20
				modifier = grateful_opinion
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -0.5
			}
		}
  	}

	option = {
		name = learning_scholarship.4000.b
		trigger = {
			NOT = { exists = scope:child_educated }
		}
		scope:spouse_uninterested_in_study = {
			add_learning_skill = 2
			add_opinion = {
				target = root
				opinion = -20
				modifier = insulted_opinion
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}

	option = {
		name = learning_scholarship.4000.c
		trigger = {
			exists = scope:child_educated
		}
		scope:child_educated = {
			add_learning_skill = 2
			add_opinion = {
				target = root
				opinion = 20
				modifier = supportive_parent
			}
		}
		if = {
			limit = {
				scope:spouse_uninterested_in_study = {
					NOT = { is_parent_of = scope:child_educated }
				}
			}
			custom_tooltip = learning_scholarship.4000.c.tt
			scope:spouse_uninterested_in_study = {
				add_opinion = {
					target = root
					opinion = -15
					modifier = weak_opinion
				}
			}
		}
		add_character_modifier = {
			modifier = busy_tutoring_modifier
			years = 5
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 2
			}
		}
	}

	option = {
		name = learning_scholarship.4000.d
		add_character_modifier = {
			modifier = focused_reading_modifier
			years = 5
		}
		add_learning_lifestyle_xp = medium_lifestyle_xp
		scope:spouse_uninterested_in_study = {
			add_opinion = {
				target = root
				opinion = -40
				modifier = weak_opinion
			}
			hidden_effect = {
				if = {
					limit = { exists = scope:potential_new_spouse_lover }
					set_relation_lover = { reason = lover_bored_lover target = scope:potential_new_spouse_lover involved_character = root }
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 2
			}
		}
	}
}


##################################################
# Bibliomancy									#
# by Chad Uhl									#
# 5000-5007										#
##################################################

scripted_effect create_bibliomancy_book_effect = {
	scope:merchant_mystic = {
		trigger_event = learning_scholarship.5007
	}
}

learning_scholarship.5000 = {
	type = character_event
	title = learning_scholarship.5000.t
	desc = learning_scholarship.5000.desc
	theme = learning_scholarship_focus
	override_background = {
		reference = market
	}
	left_portrait = {
		character = root
		animation = interested_left
	}
	right_portrait = {
		character = scope:merchant_mystic
		animation = beg
	}

	trigger = {
		# Haven't had the event before
		NOT = { has_character_flag = had_event_bibliomancy_5000 }
		has_focus = learning_scholarship_focus

		# You practice Bibliomancy
		faith = { religion_tag = christianity_religion }

		# Need to ensure that a powerful vassal exists for a later event
		any_vassal = {
			is_available_ai_adult = yes
			is_powerful_vassal = yes
			NOR = {
				has_secret_relation_lover = root
				has_relation_lover = root
				has_relation_soulmate = root
				has_relation_friend = root
				has_relation_best_friend = root
			}
		}
	}

	weight_multiplier = {
		base = 1

		#Aimed at players livin that Scholarship Lifestyle
		upweight_for_focus_modifier = { FOCUS = learning_scholarship_focus }

		#Bonus points if you're a ~~mystic~~
		modifier = {
			has_trait = lifestyle_mystic
			add = 1
		}
	}

	immediate = {
		root = { save_scope_as = bibliomancy_main_character }
		add_character_flag = had_event_bibliomancy_5000

		# Keeps track of how many times player fails skill checks or opts out. Higher value = more likely to get the paranoid trait at the end.
		set_variable = {
			name = paranoia_level_var
			value = 0
		}

		# Create a mystic character
		hidden_effect = {
			#Pick a suitable culture for the wandering mystic
			random_ruler = {
				# Prefer religion with mystical tenets
				limit = {
					is_within_diplo_range = { CHARACTER = root }
					faith = {
						has_doctrine = tenet_esotericism
					}
				}
				# Fallback to just choose some nearby culture
				alternative_limit = {
					is_within_diplo_range = { CHARACTER = root }
				}
				culture = {
					save_scope_as = mystic_culture
				}
				faith = {
					save_scope_as = mystic_faith
				}
			}

			# Create mystic character
			create_character = {
				template = default_mystic_character
				location = root.location
				faith = scope:mystic_faith
				culture = scope:mystic_culture
				gender_female_chance = 50
				save_scope_as = merchant_mystic
			}
			add_visiting_courtier = scope:merchant_mystic
		}
	}

	option = { # Option A: Buy the Book
		name = learning_scholarship.5000.a

		# Effect
		remove_short_term_gold = medium_gold_value
		custom_tooltip = bibliomancy_book_purchased
		create_bibliomancy_book_effect = yes

		ai_chance = {
			base = 25
			modifier = {
				add = 100
				has_trait = lifestyle_mystic
			}
			ai_value_modifier = {
				ai_zeal = medium_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
	}

	option = { # Option B: Haggle the price
		name = learning_scholarship.5000.b

		# Effect
		duel = {
			skill = diplomacy
			value = 10
			15 = {
				desc = learning_scholarship.5000.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					title = learning_scholarship.5000.b.success
					left_icon = root
					right_icon = scope:merchant_mystic
					remove_short_term_gold = minor_gold_value
				}
			}
			20 = {
				desc = learning_scholarship.5000.b.failure
				send_interface_toast = {
					title = learning_scholarship.5000.b.failure
					left_icon = root
					right_icon = scope:merchant_mystic
					remove_short_term_gold = medium_gold_value
					add_prestige = minor_prestige_loss
				}
			}
		}

		create_bibliomancy_book_effect = yes
		custom_tooltip = bibliomancy_book_purchased

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = high_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			honest = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
	}

	option = { # Option C: Take it by force
		name = learning_scholarship.5000.c

		# Effect
		add_dread = minor_dread_gain
		stress_impact = {
			base = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}

		create_bibliomancy_book_effect = yes
		custom_tooltip = bibliomancy_book_purchased

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = low_chance_impact_positive_ai_value
			}
		}
	}

	option = { # Option D: Nope
		name = learning_scholarship.5000.d
		add_prestige = minor_prestige_gain
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = low_chance_impact_negative_ai_value
				ai_boldness = low_chance_impact_negative_ai_value
				ai_greed = low_chance_impact_negative_ai_value
				ai_energy = high_chance_impact_negative_ai_value
			}
		}

		stress_impact = {
			zealous = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			calm = minor_stress_impact_gain
			temperate = minor_stress_impact_gain
		}
	}
}

learning_scholarship.5001 = {
	type = character_event
	title = learning_scholarship.5001.t
	desc = learning_scholarship.5001.desc

	left_portrait = {
		character = root
		animation = worry
	}
	theme = learning_scholarship_focus
	artifact = {
		target = scope:sacred_text
		position = lower_center_portrait
		trigger = { exists = scope:sacred_text }
	}

	trigger = {
		# Make sure the character has scope:sacred_text
		exists = scope:sacred_text
		scope:sacred_text = {
			artifact_owner = root
		}
	}

	immediate = {
		scope:merchant_mystic = { silent_disappearance_effect = yes }
	}

	option = { # Perform Bibliomancy
		name = learning_scholarship.5001.a

		custom_tooltip = learning_lifestyle_rank_up_indication
		trigger_event = learning_scholarship.5002

		ai_chance = {
			base = 50
			modifier = {
				add = 100
				has_trait = lifestyle_mystic
			}
			ai_value_modifier = {
				ai_energy = medium_chance_impact_positive_ai_value
				ai_zeal = medium_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
			craven = minor_stress_impact_gain
		}
	}

	option = { # Do not perform Bibliomancy
		name = learning_scholarship.5001.b

		#if faith has Righteous doctrine
		if = {
			limit = {
				ROOT.faith = {
					has_doctrine = doctrine_pluralism_righteous
				}
			}
			add_piety = minor_piety_value
		}

		stress_impact = {
			base = minor_stress_loss
			lifestyle_mystic = minor_stress_impact_gain
			zealous = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = medium_chance_impact_negative_ai_value
				ai_zeal = medium_chance_impact_negative_ai_value
				ai_rationality = medium_chance_impact_negative_ai_value
			}
		}
	}
}

learning_scholarship.5002 = { # A Fateful Reading - Fear is the mind-killer!

	type = character_event
	title = learning_scholarship.5002.t
	desc = learning_scholarship.5002.desc

	left_portrait = {
		character = root
		animation = worry
	}
	theme = learning_scholarship_focus
	artifact = {
		target = scope:sacred_text
		position = lower_center_portrait
		trigger = { exists = scope:sacred_text }
	}

	immediate = {
			if = {
				limit = {
					employs_court_position = antiquarian_court_position
					any_court_position_holder = {
						type = antiquarian_court_position
					}
				}
				random_court_position_holder = {
					type = antiquarian_court_position
					save_scope_as = antiquarian
				}
			}
		}

	option = { # Option A: Easy Interpretation
		name = learning_scholarship.5002.a

		add_learning_lifestyle_xp = minor_lifestyle_xp

		stress_impact = {
			scholar = minor_stress_impact_gain
		}

		trigger_event = {
			id = learning_scholarship.5003
			days = 5
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = medium_chance_impact_negative_ai_value
				ai_energy = medium_chance_impact_negative_ai_value
				ai_boldness = high_chance_impact_positive_ai_value
				ai_zeal = low_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			diligent = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
	}

	option = { # Option B: Learning Skill Challenge
		name = learning_scholarship.5002.b

		# Learning Skill Challenge
		duel = {
			skill = learning
			value = 10

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = learning_scholarship.5002.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = learning_scholarship.5002.b.success
					left_icon = root

					#Effect
					add_learning_lifestyle_xp = medium_lifestyle_xp
					add_character_modifier = {
						modifier = focused_reading_modifier
						years = 3
					}
					#Gain a prestige bonus for doing this yourself.
					add_prestige = minor_prestige_gain

					trigger_event = {
						id = learning_scholarship.5005
						days = 5
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = learning_scholarship.5002.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = learning_scholarship.5002.b.failure
					left_icon = root

					#Effect
					change_variable = { name = paranoia_level_var add = 1 }
					add_learning_lifestyle_xp = minor_lifestyle_xp
					add_character_modifier = {
						modifier = bibliomancy_tense_modifier
						years = 2
					}

					trigger_event = {
						id = learning_scholarship.5004
						days = 5
					}
				}

			}
		}

		stress_impact = {
			lazy = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = medium_chance_impact_positive_ai_value
				ai_energy = medium_chance_impact_positive_ai_value
				ai_zeal = medium_chance_impact_positive_ai_value
			}
		}

	}

	option = { # Option C: Disregard - Opt out
		name = learning_scholarship.5002.c

		stress_impact = {
			base = minor_stress_impact_gain
			lazy = minor_stress_impact_loss
			scholar = medium_stress_impact_gain
			theologian = medium_stress_impact_gain
			lifestyle_mystic = medium_stress_impact_gain
		}

		change_variable = { name = paranoia_level_var add = 1 }
		custom_tooltip = learning_scholarship_paranoid_trait_possible
		trigger_event = {
			id = learning_scholarship.5006
			days = 20
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = high_chance_impact_negative_ai_value
				ai_energy = high_chance_impact_negative_ai_value
				ai_zeal = high_chance_impact_negative_ai_value
			}
		}
	}

	option = { # Option D: Antiquarian Specialist Option
		name = learning_scholarship.5002.d

		trigger = {
			employs_court_position = antiquarian_court_position
		}

		# Learning Skill Challenge, made easier
		scope:antiquarian = {
			duel = {
				skill = learning
				value = 10

				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = learning_scholarship.5002.b.success
					root = {
						send_interface_toast = {
							type = event_toast_effect_good
							title = learning_scholarship.5002.b.success
							left_icon = root

							#Effect
							add_learning_lifestyle_xp = medium_lifestyle_xp
							add_character_modifier = {
								modifier = focused_reading_modifier
								years = 1
							}
							trigger_event = {
								id = learning_scholarship.5005
								days = 5
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = learning_scholarship.5002.b.failure
					root = {
						send_interface_toast = {
							type = event_toast_effect_bad
							title = learning_scholarship.5002.b.failure
							left_icon = root

							#Effect
							add_learning_lifestyle_xp = minor_lifestyle_xp
							change_variable = { name = paranoia_level_var add = 1 }
							trigger_event = {
								id = learning_scholarship.5004
								days = 1
							}
						}
					}
				}
			}
		}

		if = {
			limit = {
				can_set_relation_potential_friend_trigger = { CHARACTER = scope:antiquarian }
			}
			set_relation_potential_friend = scope:antiquarian
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = medium_chance_impact_positive_ai_value
				ai_energy = medium_chance_impact_positive_ai_value
				ai_zeal = medium_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			lazy = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
	}
}

learning_scholarship.5003 = { # A Simple Reading
	type = character_event
	title = learning_scholarship.5003.t
	desc = learning_scholarship.5003.desc

	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:bibliomancy_antagonist
		animation = personality_bold
	}

	theme = court

	weight_multiplier = {
		base = 1
	}

	# Check that powerful vassal exists at the beginning
	trigger = {
		any_vassal = {
			is_available_ai_adult = yes
			is_powerful_vassal = yes
			NOR = {
				has_secret_relation_lover = root
				has_relation_lover = root
				has_relation_soulmate = root
				has_relation_friend = root
				has_relation_best_friend = root
			}
		}
	}

	immediate = {
		random_vassal = {
			# Calling all vassals who dislike me
			limit = {
				is_available_ai_adult = yes
				is_powerful_vassal = yes
				NOR = {
					has_secret_relation_lover = root
					has_relation_lover = root
					has_relation_soulmate = root
					has_relation_friend = root
					has_relation_best_friend = root
				}
				opinion = {
					target = root
					value <= 0
				}
			}
			# Fallback to any vassal that is available
			alternative_limit = {
				is_available_ai_adult = yes
				is_powerful_vassal = yes
				NOR = {
					has_secret_relation_lover = root
					has_relation_lover = root
					has_relation_soulmate = root
					has_relation_friend = root
					has_relation_best_friend = root
				}
			}
			save_scope_as = bibliomancy_antagonist
		}

	}

	option = { # Option A: Debate the Vassal
		name = learning_scholarship.5003.a
		custom_tooltip = learning_scholarship.5003.a.tt

		duel = {
			skill = learning
			target = scope:bibliomancy_antagonist

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = learning_scholarship.5003.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = learning_scholarship.5003.a.success
					left_icon = root

					#Effect
					add_learning_lifestyle_xp = medium_lifestyle_xp
					add_prestige = minor_prestige_gain
				}
				trigger_event = {
					id = learning_scholarship.5005
					days = 5
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = learning_scholarship.5003.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = learning_scholarship.5003.a.failure
					left_icon = root

					add_learning_lifestyle_xp = minor_lifestyle_xp
					every_vassal = {
						custom = learning_scholarship.5003.vassal.tt
						add_opinion = {
							modifier =  thinks_liege_incapable_opinion
							target = root
						}
					}
				}
			}
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_energy = low_chance_impact_positive_ai_value
				ai_boldness = high_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			shy = medium_stress_impact_gain
			craven = minor_stress_impact_gain
		}
	}

	option = { # Option B: Make formal overtures (Diplomacy Challenge)
		name = learning_scholarship.5003.b

		custom_tooltip = learning_scholarship.5003.b.tt
		# Diplomacy Skill Challenge
		duel = {
			skill = diplomacy
			target = scope:bibliomancy_antagonist

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = learning_scholarship.5003.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = learning_scholarship.5003.b.success
					left_icon = root

					#Effect
					add_learning_lifestyle_xp = medium_lifestyle_xp

					#Gain a prestige bonus for doing this yourself.
					add_prestige = minor_prestige_gain
				}
				trigger_event = {
					id = learning_scholarship.5005
					days = 5
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = learning_scholarship.5003.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = learning_scholarship.5003.b.failure
					left_icon = root

					add_learning_lifestyle_xp = minor_lifestyle_xp
					add_prestige = medium_prestige_loss
				}
			}
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_energy = low_chance_impact_positive_ai_value
				ai_rationality = high_chance_impact_positive_ai_value
			}
		}

		stress_impact = {
			stubborn = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
	}

	option = { # Option C: Give him a hook and be done with it
		name = learning_scholarship.5003.c

		# Vassal gains hook on you to renegotiate contract later
		scope:bibliomancy_antagonist = {
			if = {
				limit = {
					can_add_hook = {
					  	type = favor_hook
					  	target = root
					}
				}
				add_hook = {
					type = favor_hook
					target = root
				}
			}
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_energy = high_chance_impact_negative_ai_value
				ai_boldness = medium_chance_impact_negative_ai_value
				ai_honor = low_chance_impact_negative_ai_value
			}
		}

		stress_impact = {
			arrogant = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
		}
	}
}


learning_scholarship.5004 = { # Skill Challenge Failure
	type = character_event
	title = learning_scholarship.5004.t
	desc = learning_scholarship.5004.desc

	left_portrait = cp:councillor_court_chaplain
	right_portrait = scope:target_courtier
	theme = learning_scholarship_focus

	trigger = {
		OR = {
			exists = cp:councillor_court_chaplain
			employs_court_position = camp_priest_camp_officer			
		}
	}

	immediate = {
		# Save chaplain scope
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
			}
			cp:councillor_court_chaplain = {
				save_scope_as = court_chaplain
			}
		}
		else = {
			random_court_position_holder = {
				type = camp_priest_camp_officer
				save_scope_as = court_chaplain
			}
			
		}
		# Pick a courtier with high learning who isn't the chaplain
		ordered_courtier = {
			limit = {
				is_available_ai_adult = yes
				this != scope:court_chaplain
			}
			order_by = learning
			max = 1

			save_scope_as = target_courtier
		}

	}

	option = { # Option A: Ask Chaplain for help
		name = learning_scholarship.5004.a

		# Learning Skill Challenge

		scope:court_chaplain = {
			duel = {
				skill = learning
				value = 8

				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = learning_scholarship.5004.a.success
					root = {
						send_interface_toast = {
							type = event_toast_effect_good
							title = learning_scholarship.5004.a.success
							left_icon = scope:court_chaplain

							#Effect
							add_learning_lifestyle_xp = medium_lifestyle_xp
							add_character_modifier = {
								modifier = focused_reading_modifier
								years = 3
							}
							trigger_event = {
								id = learning_scholarship.5005
								days = 5
							}
						}
					}
				}

				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = learning_scholarship.5004.a.failure
					root = {
						send_interface_toast = {
							type = event_toast_effect_bad
							title = learning_scholarship.5004.a.failure
							left_icon = scope:court_chaplain

							#Effect
							add_prestige = minor_prestige_loss
							change_variable = {
								name = paranoia_level_var
								add = 1
							}
							trigger_event = {
								id = learning_scholarship.5006
								days = 15
							}
						}
					}
				}
			}
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 15
			}
		}

		ai_chance = {
			base = 45
			ai_value_modifier = {
				ai_honor = low_chance_impact_negative_ai_value
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
	}

	option = { # Option B: Ask Courtier for help


		name = learning_scholarship.5004.b

		trigger = {
			exists = scope:target_courtier
		}

		# Learning Skill Challenge
		scope:target_courtier = {
			duel = {
				skill = learning
				value = 8

				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = learning_scholarship.5004.b.success

					root = {
						send_interface_toast = {
							type = event_toast_effect_good
							title = learning_scholarship.5004.b.success
							left_icon = scope:target_courtier

							#Effect
							add_learning_lifestyle_xp = medium_lifestyle_xp
							add_character_modifier = {
								modifier = focused_reading_modifier
								years = 3
							}
							trigger_event = {
								id = learning_scholarship.5005
								days = 5
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					desc = learning_scholarship.5004.b.failure
					root = {
						send_interface_toast = {
							type = event_toast_effect_bad
							title = learning_scholarship.5004.b.failure
							left_icon = scope:target_courtier

							#Effect
							add_prestige = minor_prestige_loss
							change_variable = {
								name = paranoia_level_var
								add = 1
							}
							trigger_event = {
								id = learning_scholarship.5006
								days = 15
							}
						}
					}
				}
			}
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 15
			}
		}

		ai_chance = {
			base = 45
			ai_value_modifier = {
				ai_honor = low_chance_impact_negative_ai_value
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
	}

	option = { # Give up
		name = learning_scholarship.5004.c

		add_stress = minor_stress_loss
		change_variable = { name = paranoia_level_var add = 2 }

		trigger_event = {
			id = learning_scholarship.5006
			days = 15
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = high_chance_impact_negative_ai_value
				ai_rationality = medium_chance_impact_negative_ai_value
			}
		}

		stress_impact = {
			base = minor_stress_impact_gain
			lazy = minor_stress_impact_loss
			scholar = medium_stress_impact_gain
			theologian = medium_stress_impact_gain
			lifestyle_mystic = medium_stress_impact_gain
		}
	}
}

learning_scholarship.5005 = { # Skill Challenge Success
	type = character_event
	title = learning_scholarship.5005.t
	desc = learning_scholarship.5005.desc

	left_portrait = {
		character = root
		animation = personality_bold
	}
	theme = learning_scholarship_focus

	option = {
		name = learning_scholarship.5005.a
		add_learning_lifestyle_perk_points = 1
	}
}

learning_scholarship.5006 = { # Ultimate Failure
	type = character_event
	title = learning_scholarship.5006.t
	desc = learning_scholarship.5006.desc

	left_portrait = {
		character = root
		animation = paranoia
	}
	theme = learning_scholarship_focus

	option = { # Chance to pick up paranoid trait
		name = learning_scholarship.5006.a
		if = {
			limit = {
				has_character_modifier = bibliomancy_tense_modifier
			}
			remove_character_modifier = bibliomancy_tense_modifier
		}
		add_character_modifier = {
			modifier = bibliomancy_fearful_modifier
			years = 5
		}
		if = {
			limit = {
				NOT = { has_trait = paranoid }
				var:paranoia_level_var > 1
			}
			add_trait = paranoid
			custom_tooltip = learning_scholarship_paranoid_trait.tt
		}
	}
}

learning_scholarship.5007 = { # Create the book artifact in merchant's scope and transfer to the player
	type = character_event
	hidden = yes

	immediate = {
		# Check if bibliomancy_main_character has a royal court or notification
		if = {
			limit = {
				scope:bibliomancy_main_character = {
					has_royal_court = no
				}
			}
			save_temporary_scope_value_as = {
				name = should_be_trinket
				value = yes
			}
		}
		# Create the book
		random_dummy_gender_effect = yes
		create_artifact_book_effect = {
			OWNER = root
			CREATOR = scope:dummy_gender
			SET_SUBJECT = flag:learning
			SET_TOPIC = flag:no
		}
		scope:newly_created_artifact = {
			set_owner = scope:bibliomancy_main_character
			save_scope_as = sacred_text
		}
		scope:bibliomancy_main_character = {
			# Let the player know they received the book
			send_interface_toast = {
				title = learning_scholarship_sacred_artifact_obtained
				left_icon = scope:bibliomancy_main_character
				right_icon = scope:sacred_text
				show_as_tooltip = {
					scope:sacred_text = { set_owner = scope:bibliomancy_main_character }
				}
			}
			trigger_event = {
				id = learning_scholarship.5001
				days = 5
			}
		}
	}
}

# END Bibliomancy 5000-5007

##################################################
# The Man of Few Letters						#
# by Jason Cantalini							#
# 6000											#
##################################################

scripted_trigger learning_scholarship_6000_illiterate_trigger = {
	is_powerful_vassal = yes
	is_ai = yes
	is_adult = yes
	is_imprisoned = no
	is_incapable = no
	NOR = {
		has_trait = bubonic_plague
		has_trait = smallpox
	}
	trigger_if = {
		limit = {
			government_has_flag = government_is_tribal
		}
		learning <= 14
	}
	trigger_else = {
		learning <= 6
	}
	any_courtier = { is_available_ai_adult = yes }
	NOT = { has_relation_rival = root }
	NOT = { has_character_flag = had_event_born_to_lead_not_to_read_6000 }
}

learning_scholarship.6000 = {
	type = character_event
	title = learning_scholarship.6000.t
	desc = {
		desc = learning_scholarship.6000.desc
		# Illiterate character is frustrated by different reading based on character
			triggered_desc = {
				trigger = {
					scope:illiterate = {
						OR = {
							has_trait = arrogant
							has_trait = impatient
							has_trait = lazy
							has_trait = stubborn
						}
						NOR = {
							has_trait = cynical
							has_trait = fickle
							has_trait = wrathful
							has_trait = arbitrary
						}

					}
				}
				desc = learning_scholarship.6000.willing_pupil
			}
			triggered_desc = {
				trigger = {
					faith = { religion_tag = christianity_religion }
					scope:illiterate = {
						OR = {
							has_trait = cynical
							has_trait = fickle
							has_trait = wrathful
							has_trait = arbitrary
						}
						NOR = {
							has_trait = arrogant
							has_trait = impatient
							has_trait = lazy
							has_trait = stubborn
						}
					}
				}
				desc = learning_scholarship.6000.holy_book_insult
			}
			triggered_desc = {
				trigger = {
					scope:illiterate = {
						OR = {
							has_trait = arrogant
							has_trait = impatient
							has_trait = lazy
							has_trait = stubborn
						}
						OR = {
							has_trait = cynical
							has_trait = fickle
							has_trait = wrathful
							has_trait = arbitrary
						}
					}
				}
				desc = learning_scholarship.6000.poetry_insult
			}
			triggered_desc = {
				trigger = {
					scope:illiterate = {
						NOR = {
							has_trait = arrogant
							has_trait = impatient
							has_trait = lazy
							has_trait = cynical
							has_trait = fickle
							has_trait = wrathful
							has_trait = stubborn
							has_trait = arbitrary
						}
					}
				}
				desc = learning_scholarship.6000.very_willing_pupil
			}
	}
	theme = learning_scholarship_focus
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:teacher
		animation = personality_forgiving
	}
	lower_center_portrait = scope:illiterate

	cooldown = {
		years = 5
	}

	trigger = {
		has_focus = learning_scholarship_focus
		NOT = { has_character_flag = is_in_learning_special_event }
		learning > low_skill_rating
		is_available_adult = yes
		is_landed = yes
		# Literacy wasn't expected in many tribal contexts
		NOR = {
			government_has_flag = government_is_tribal
			government_has_flag = government_is_nomadic
		}

		# Must have a suitably illiterate vassal
		any_vassal = {
			learning_scholarship_6000_illiterate_trigger = yes
		}
	}

	immediate = {
		# Who needs to know what words do?
		random_vassal = {
			limit = {
				learning_scholarship_6000_illiterate_trigger = yes
			}
			save_scope_as = illiterate
		}

		# The vassal doesn't need to learn to read twice
		scope:illiterate = {
			add_character_flag = had_event_born_to_lead_not_to_read_6000
		}
		# Who is trying to teach words?
		if = {
			limit = {
				scope:illiterate = { employs_court_position = court_tutor_court_position }
				scope:illiterate = {
					any_court_position_holder = {
						type = court_tutor_court_position
						is_available_ai = yes
					}
				}
			}
			scope:illiterate = {
				random_court_position_holder = {
					type = court_tutor_court_position
					limit = {
						is_available_ai = yes
					}
					save_scope_as = teacher
				}
			}
		}
		else_if = {
			limit = {
				scope:illiterate = {
					exists = cp:councillor_court_chaplain
					cp:councillor_court_chaplain = {
						is_available_ai = yes
					}
				}
			}
			scope:illiterate = {
				cp:councillor_court_chaplain = {
					save_scope_as = teacher
				}
			}
		}
		else = {
			scope:illiterate = {
				random_courtier = {
					limit = {
						is_available_ai_adult = yes
					}
					weight = {
						base = 1
						modifier = {
							add = {
								value = learning
								multiply = 4
							}
						}
					}
				save_scope_as = teacher
				}
			}
		}
	}

	#One of the following options appear based on a councillor position the illiterate holds
	option = {
		trigger = {
			scope:illiterate = root.cp:councillor_chancellor
		}
		name = learning_scholarship.6000.a
		add_learning_lifestyle_xp = minor_lifestyle_experience
		scope:illiterate = {
			add_diplomacy_skill = 1
			add_learning_skill = 1
		}
		stress_impact = {
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -25
				has_trait = content
			}
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
				ai_sociability = 0.5
			}
		}
	}

	option = {
		trigger = {
			scope:illiterate = root.cp:councillor_spymaster
		}
		name = learning_scholarship.6000.b
		add_learning_lifestyle_xp = minor_lifestyle_experience
		scope:illiterate = {
			add_intrigue_skill = 1
			add_learning_skill = 1
		}
		stress_impact = {
			honest = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -25
				has_trait = content
			}
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -0.75
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		trigger = {
			scope:illiterate = root.cp:councillor_marshal
		}
		name = learning_scholarship.6000.c
		add_learning_lifestyle_xp = minor_lifestyle_experience
		scope:illiterate = {
			add_martial_skill = 1
			add_learning_skill = 1
		}
		stress_impact = {
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -25
				has_trait = content
			}
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = {
		trigger = {
			scope:illiterate = root.cp:councillor_steward
		}
		name = learning_scholarship.6000.d
		add_learning_lifestyle_xp = minor_lifestyle_experience
		scope:illiterate = {
			add_stewardship_skill = 1
			add_learning_skill = 1
		}
		stress_impact = {
			arbitrary = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				has_trait = content
			}
			ai_value_modifier = {
				ai_energy = 0.25
				ai_zeal = 1
				ai_honor = 1
			}
		}
	}

	option = {
		trigger = {
			scope:illiterate = root.cp:councillor_court_chaplain
		}
		name = learning_scholarship.6000.e
		add_learning_lifestyle_xp = minor_lifestyle_experience
		scope:illiterate = {
			add_learning_skill = 2
		}
		stress_impact = {
			cynical = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				has_trait = content
			}
			ai_value_modifier = {
				ai_energy = 0.5
				ai_zeal = 1
			}
		}
	}

	option = {
		name = learning_scholarship.6000.f
		flavor = learning_scholarship.6000.f.tt
		duel = {
			skill = learning
			value = average_skill_rating
			55 = {
				desc = learning_scholarship.6000.f.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
				}
				send_interface_toast = {
					title = learning_scholarship.6000.f.success
					left_icon = root
					right_icon = scope:illiterate
					add_learning_lifestyle_xp = medium_lifestyle_experience
					scope:illiterate = {
						add_learning_skill = 1
					}
				}
				create_character_memory = {
					type = reading_aid
					participants = {
						illiterate = scope:illiterate
					}
				}
			}
			45 = {
				desc = learning_scholarship.6000.f.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
				}
				send_interface_toast = {
					title = learning_scholarship.6000.f.failure
					left_icon = root
					right_icon = scope:illiterate
					add_prestige = minor_prestige_loss
					scope:illiterate = {
						add_opinion = {
							target = root
							modifier = annoyed_opinion
							opinion = -10
						}
					}
				}
			}
		}
		stress_impact = {
			journaller = minor_stress_impact_loss
			lazy = major_stress_impact_gain
			humble = medium_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			modifier = {
				add = 25
				has_trait = journaller
			}
			modifier = {
				add = 25
				learning >= medium_skill_rating
			}
			modifier = {
				add = 50
				learning >= high_skill_rating
			}
			modifier = {
				add = -100
				has_trait = lazy
			}
			modifier = {
				add = -25
				has_trait = humble
			}
			ai_value_modifier = {
				ai_sociability = 0.75
				ai_energy = 0.5
				ai_compassion = 0.25
			}
		}
	}

	#The following option changes along with the loc which describes illiterate's response to reading
	#if the illiterate is a lazy pupil
	option = {
		name = learning_scholarship.6000.g
		trigger = {
			scope:illiterate = {
				OR = {
					has_trait = arrogant
					has_trait = impatient
					has_trait = lazy
					has_trait = stubborn
				}
				NOR = {
					has_trait = cynical
					has_trait = fickle
					has_trait = wrathful
					has_trait = arbitrary
				}
			}
		}
		flavor = learning_scholarship.6000.g.tt
		progress_towards_friend_effect = {
			CHARACTER = scope:illiterate
			OPINION = 30
			REASON = friend_supported_illiterate
		}
		create_character_memory = {
			type = supported_illiterate
			participants = {
				illiterate = scope:illiterate
			}
		}
		stress_impact = {
			patient = major_stress_impact_gain
			diligent = medium_stress_impact_gain
			stubborn = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -15
				has_trait = stubborn
			}
			modifier = {
				add = -50
				has_trait = patient
			}
			modifier = {
				add = -25
				has_trait = diligent
			}
			ai_value_modifier = {
				ai_rationality = -0.25
				ai_energy = -0.25
				ai_boldness = -0.5
				ai_compassion = 0.25
			}
		}
	}

	#if the illiterate was frustrated about the holy book
	option = {
		name = learning_scholarship.6000.h
		trigger = {
			scope:illiterate = {
				OR = {
					has_trait = cynical
					has_trait = fickle
					has_trait = wrathful
					has_trait = arbitrary
				}
				NOR = {
					has_trait = arrogant
					has_trait = impatient
					has_trait = lazy
					has_trait = stubborn
				}
			}
		}
		flavor = learning_scholarship.6000.h.tt
		custom_tooltip = learning_scholarship.6000.non_believer
		add_piety = minor_piety_gain
		progress_towards_rival_effect = {
			REASON = rival_holy_book
			CHARACTER = scope:illiterate
			OPINION = default_rival_opinion
		}
		if = {
			limit = {
				scope:illiterate = {
					NOT = { any_secret = { type = secret_non_believer } }
				}
			}
			hidden_effect = {
				scope:illiterate = {
					add_secret = {
						type = secret_non_believer
					}
				}
			}
		}
		scope:illiterate = {
			random_secret = {
				type = secret_non_believer
				reveal_to = root
			}
		}
		stress_impact = {
			forgiving = major_stress_impact_gain
			cynical = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			modifier = {
				add = -25
				has_trait = cynical
			}
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -0.5
				ai_honor = -1
				ai_zeal = 1
			}
		}
	}

	#if the illiterate raged at reading poetry
	option = {
		name = learning_scholarship.6000.i
		trigger = {
			scope:illiterate = {
				OR = {
					has_trait = arrogant
					has_trait = impatient
					has_trait = lazy
					has_trait = stubborn
				}
				OR = {
					has_trait = cynical
					has_trait = fickle
					has_trait = wrathful
					has_trait = arbitrary
				}
			}
		}
		flavor = learning_scholarship.6000.i.tt
		if = {
			limit = {
				scope:illiterate = {
					culture = root.culture
				}
			}
			add_character_modifier = {
				modifier = court_of_poetry_modifier
				years = 2
			}
			if = {
				limit = {
					has_royal_court = no
				}
				add_prestige = minor_prestige_gain
			}
			else_if = {
				limit = {
					has_royal_court = yes
					has_dlc_feature = royal_court
				}
				change_current_court_grandeur = minor_court_grandeur_gain
			}
		}
		else = {
			add_character_modifier = {
				modifier = court_of_poetry_modifier
				years = 2
			}
			scope:illiterate.culture = {
				change_cultural_acceptance = {
					target = root.culture
					value = miniscule_positive_culture_acceptance
					desc = cultural_acceptance_gain_hold_court_event_outcome
				}
			}
		}
		stress_impact = {
			cynical = major_stress_impact_gain
			impatient = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			shy = minor_stress_impact_gain

		}
		ai_chance = {
			base = 20
			modifier = {
				add = -25
				has_trait = cynical
			}
			modifier = {
				add = -25
				has_trait = callous
			}
			ai_value_modifier = {
				ai_zeal = 0.25
				ai_compassion = 0.5
				ai_vengefulness = -0.25
				ai_honor = 0.5
				ai_sociability = 0.75
			}
		}
	}
#if the illiterate actually wants help
	option = {
		name = learning_scholarship.6000.j
		trigger = {
			scope:illiterate = {
				NOR = {
					has_trait = arrogant
					has_trait = impatient
					has_trait = lazy
					has_trait = cynical
					has_trait = fickle
					has_trait = wrathful
					has_trait = stubborn
					has_trait = arbitrary
				}
			}
		}
		flavor = learning_scholarship.6000.j.tt
		add_character_modifier = {
			modifier = beauty_of_language_modifier
			years = 10
		}
		stress_impact = {
			content = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			calm = minor_stress_impact_loss
			ambitious = massive_stress_impact_gain
			cynical = major_stress_impact_gain
			impatient = major_stress_impact_gain
			arrogant = major_stress_impact_gain
			diligent = major_stress_impact_gain
		}
		scope:illiterate = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 15
			}
		}
		ai_chance = {
			base = 20
			modifier = {
				add = -100
				has_trait = ambitious
			}
			modifier = {
				add = -50
				has_trait = cynical
			}
			modifier = {
				add = -25
				has_trait = impatient
			}
			modifier = {
				add = -25
				has_trait = arrogant
			}
			modifier = {
				add = -25
				has_trait = diligent
			}
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_energy = -0.5
				ai_compassion = 0.25
			}
		}
	}

	option = {
		name = learning_scholarship.6000.k
		flavor = learning_scholarship.6000.k.tt
		add_prestige = minor_prestige_gain
		scope:illiterate = {
			add_prestige = minor_prestige_loss
		}

		progress_towards_rival_effect = {
			REASON = rival_holy_book_illiterate
			CHARACTER = scope:illiterate
			OPINION = 0
		}
		scope:illiterate = {
  			add_opinion = {
   				target = root
				modifier = insult_opinion
				opinion = -25
			}
		}
		if = {
			limit = {
				any_vassal = {
					learning > decent_skill_rating
					NOT = {
						has_trait = compassionate
					}
				}
			}
			every_vassal = {
				custom = high_learning_custom
				limit = {
					learning > decent_skill_rating
					NOT = {
						has_trait = compassionate
					}
				}
				add_opinion = {
					modifier = respect_opinion
					target = root
					opinion = 20
				}
			}
		}
		create_character_memory = {
			type = humiliated_illiterate
			participants = {
				illiterate = scope:illiterate
			}
		}
		stress_impact = {
			irritable = medium_stress_impact_loss
			humble = medium_stress_impact_gain
			patient = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			trusting = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		ai_chance = {
			base = 15
			ai_value_modifier = {
				ai_zeal = 0.25
				ai_boldness = 0.75
				ai_compassion = -1
				ai_honor = -0.5
			}
		}
	}
}
