﻿namespace = learn_language_ongoing

######################
# FREE-STANDING EVENTS
# 1000-4999
######################

# Young character picks up the language *really* fast
learn_language_ongoing.1000 = {
	type = character_event
	title = learn_language_ongoing.1000.t
	desc = learn_language_ongoing.1000.desc
	theme = education
	left_portrait = {
		character = root
		animation = happiness
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		NOT = { has_variable = had_event_learn_language_ongoing_1000 }
		age <= 20
		is_available = yes
		ai_energy > -1
		is_travelling = no
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 10
			has_trait = pensive
		}
		modifier = {
			add = 15
			has_trait = curious
		}
		modifier = {
			add = 15
			is_adult = no
		}
	}

	immediate = {
		set_variable = {	
			name = had_event_learn_language_ongoing_1000
			value = yes
			days = 1460
		}
		set_favorite_treat_effect = yes
		save_scope_as = fast_learner
	}

	option = { # Yes, spend all my focus on this!
		name = learn_language_ongoing.1000.a
		
		custom_tooltip = scheme_executes_immediately
		hidden_effect = {
			trigger_event = learn_language_outcome.1000
		}
		
		stress_impact = {
			impatient = massive_stress_impact_gain
			lazy = massive_stress_impact_gain
			shy = medium_stress_impact_gain
			rowdy = medium_stress_impact_gain
			fickle = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				OR = {
					has_trait = lazy
					has_trait = impatient
					ai_energy <= -25
				}
			}
		}
	}

	option = { # Nah... I have better things to do
		name = learn_language_ongoing.1000.b
		
		stress_impact = {
			diligent = massive_stress_impact_gain
			curious = major_stress_impact_gain
			gregarious = major_stress_impact_gain
			ambitious = medium_stress_impact_gain
			patient = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
		}
	}
}

scripted_trigger appropriate_lover_target = {
	culture = {
		has_same_culture_language = root.culture
	}
	can_set_relation_lover_trigger = { CHARACTER = root }
	is_attracted_to_gender_of = root
	root = {
		is_attracted_to_gender_of = prev
	}
	NOR = {
		has_trait = celibate
		has_trait = chaste
	}
	is_available_ai_adult = yes
	might_cheat_on_every_partner_trigger = yes
	accepts_incest_with_trigger = { CHARACTER = root } #No incest or 100% ok with incest
}

# Someone becomes infatuated with you when you speak the 'unbelievably romantic' foreign language
learn_language_ongoing.1010 = {
	type = character_event
	title = learn_language_ongoing.1010.t
	desc = learn_language_ongoing.1010.desc
	theme = education
	left_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:lover_target
		animation = flirtation
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	cooldown = { years = 10 }
	
	trigger = {
		is_adult = yes
		is_available = yes
		num_of_relation_lover <= 2
		any_courtier_or_guest = {
			appropriate_lover_target = yes
		}
		is_travelling = no
	}

	immediate = {
		random_courtier_or_guest = {
			limit = {
				appropriate_lover_target = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = lover_target
		}
	}

	option = { # Yes, I... meant to say that!
		name = learn_language_ongoing.1010.a
		trigger = { might_cheat_on_every_partner_trigger = yes }
		
		had_sex_with_effect = {
			CHARACTER = scope:lover_target
			PREGNANCY_CHANCE = pregnancy_chance
		}
		
		set_relation_lover = { reason = lover_language target = scope:lover_target involved_character = scope:target }
		
		scope:lover_target = {
			add_opinion = {
				target = root
				modifier = love_opinion
				opinion = 50
			}
		}
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}

		stress_impact = {
			chaste = massive_stress_impact_gain
			honest = massive_stress_impact_gain
			celibate = massive_stress_impact_gain
			just = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = chaste
					has_trait = celibate
					has_trait = honest
				}
			}
		}
	}

	option = { # No, no! that's not at all what I meant!
		name = learn_language_ongoing.1010.b
		
		scope:lover_target = {
			add_opinion = {
				target = root
				modifier = flirty_opinion
				opinion = 20
			}
			hidden_effect = {
				random = {
					chance = 50
					if = {
						limit = {
							can_set_relation_potential_lover_trigger = { CHARACTER = root }
						}
						set_relation_potential_lover = root
					}
				}
			}
		}
		
		
		stress_impact = {
			lustful = massive_stress_impact_gain
			gregarious = major_stress_impact_gain
			deceitful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lustful
					has_trait = deceitful
				}
			}
		}
	}

	option = { # Begone, harlot!
		name = learn_language_ongoing.1010.c
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		scope:lover_target = {
			add_opinion = {
				modifier = rude_opinion
				target = root
			}
			
			hidden_effect = {
				random = {
					chance = 50
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = root }
						}
						set_relation_potential_rival = root
					}
				}
			}
		}
		
		stress_impact = {
			lustful = massive_stress_impact_gain
			compassionate = major_stress_impact_gain
			gregarious = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lustful
					ai_compassion >= low_positive_ai_value
				}
			}
		}
	}
}

scripted_trigger valid_teacher_target = {
	NOR = {
		this = scope:target
		has_relation_rival = root
	}
	learning >= 12
	is_available_ai_adult = yes
	culture = {
		has_same_culture_language = scope:target.culture
	}
}

# Someone in your vicinity that speaks the language offers to help you learn it
learn_language_ongoing.1020 = {
	type = character_event
	title = learn_language_ongoing.1020.t_hash_collision
	desc = learn_language_ongoing.1020.desc
	theme = education
	left_portrait = {
		character = root
		animation = personality_cynical
	}
	right_portrait = {
		character = scope:language_helper
		animation = personality_content
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1020 }
		}
		is_available = yes
		is_travelling = no
		trigger_if = {
			limit = {
				is_ai = yes
			}
			any_courtier_or_guest = {
				valid_teacher_target = yes
			}
		}
		trigger_else = {
			OR = {
				any_courtier_or_guest = {
					valid_teacher_target = yes
				}
				trigger_if = {
					limit = {
						highest_held_title_tier >= tier_county
					}
					any_neighboring_and_across_water_realm_same_rank_owner = {
						valid_teacher_target = yes
					}
				}
				top_liege = {
					any_vassal_or_below = {
						valid_teacher_target = yes
					}
				}
				scope:target = {
					top_liege ?= {
						any_vassal_or_below = {
							valid_teacher_target = yes
						}
					}
				}
			}
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_learn_language_ongoing_1020
				value = yes
				days = 3650
			}
		}
		every_courtier_or_guest = {
			limit = {
				valid_teacher_target = yes
			}
			add_to_list = potential_helpers
		}
		if = {
			limit = {
				is_ai = no
			}
			if = {
				limit = {
					highest_held_title_tier >= tier_county
				}
				every_neighboring_and_across_water_realm_same_rank_owner = {
					limit = {
						valid_teacher_target = yes
					}
					add_to_list = potential_helpers
				}
			}
			top_liege = {
				every_vassal_or_below = {
					limit = {
						valid_teacher_target = yes
					}
					add_to_list = potential_helpers
				}
			}
			if = {
				limit = {
					exists = scope:target.top_liege
				}
				scope:target = {
					top_liege = {
						every_vassal_or_below = {
							limit = {
								valid_teacher_target = yes
							}
							add_to_list = potential_helpers
						}
					}
				}
			}
		}
		random_in_list = {
			list = potential_helpers
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					has_trait = scholar
				}
			}
			save_scope_as = language_helper
			assign_quirk_effect = yes
		}
	}

	option = { # I appreciate the offer, here's some gold.
		name = learn_language_ongoing.1020.a
		
		pay_short_term_gold = {
			target = scope:language_helper
			gold = scope:language_helper.medium_gold_value
		}
			
		scope:scheme = {
			add_scheme_modifier = {
				type = outside_help_modifier
			}
		}
		
		stress_impact = {
			greedy = massive_stress_impact_gain
			paranoid = major_stress_impact_gain
			arrogant = major_stress_impact_gain
			shy = medium_stress_impact_gain
			stubborn = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # I appreciate the offer, I'll be indebted
		name = learn_language_ongoing.1020.b
		
		trigger = {
			scope:language_helper = {
				can_add_hook = {
					target = root
					type = favor_hook
				}
			}
		}
		
		scope:language_helper = {
			add_hook = {
				target = root
				type = favor_hook
			}
		}
			
		scope:scheme = {
			add_scheme_modifier = {
				type = outside_help_modifier
			}
		}
		
		stress_impact = {
			paranoid = massive_stress_impact_gain
			greedy = major_stress_impact_gain
			arrogant = major_stress_impact_gain
			shy = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # You're so gracious to offer to help me *for free*
		name = learn_language_ongoing.1020.c
		
		duel = {
			skill = intrigue
			value = scope:language_helper.intrigue

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1020.c.success
				send_interface_toast = {
					title = learn_language_ongoing.1020.c.success
					left_icon = scope:language_helper
					
					scope:language_helper = {
						add_opinion = {
							target = root
							modifier = flattered_opinion
							opinion = 15
						}
					}
					
					scope:scheme = {
						add_scheme_modifier = {
							type = outside_help_modifier
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1020.c.failure
				send_interface_toast = {
					title = learn_language_ongoing.1020.c.failure
					left_icon = scope:language_helper

					scope:language_helper = {
						add_opinion = {
							target = root
							modifier = insult_opinion
							opinion = -25
						}
			
						hidden_effect = {
							random = {
								chance = 50
								if = {
									limit = {
										can_set_relation_potential_rival_trigger = { CHARACTER = root }
									}
									set_relation_potential_rival = root
								}
							}
						}
					}
				}
			}
		}
		
		stress_impact = {
			honest = massive_stress_impact_gain
			just = massive_stress_impact_gain
			trusting = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			shy = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			
			modifier = {
				factor = 0
				OR = {
					intrigue <= 8
					ai_honor >= low_positive_ai_value
				}
			}
		}
	}

	option = { # No, thank you
		name = learn_language_ongoing.1020.d
		
		scope:language_helper = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -5
			}
		}
		
		stress_impact = {
			diligent = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
		}
	}
}

scripted_trigger appropriately_dirty_peasant = {
	is_physically_able_ai_adult = yes
	has_no_particular_noble_roots_trigger = yes
	NOR = {
		exists = father
		has_relation_rival = root
	}
	gold < 50
	learning <= 8
	NOT = {
		has_trait = scholar
	}
	#makes no sense if the language manual is written in another language
	culture = {
		has_same_culture_language = root.culture
	}
}

# Someone offers you a trinket-slot book on learning languages
learn_language_ongoing.1030 = {
	type = character_event
	title = learn_language_ongoing.1030.t
	desc = learn_language_ongoing.1030.desc
	theme = education
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:chosen_peasant
		animation = beg
	}
	artifact = {
        target = scope:newly_created_artifact
        position = lower_left_portrait
    }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1030 }
		}
		NOT = {
			any_character_artifact = {
				has_variable = language_manual
			}
		}
		trigger_if = {
			limit = {
				is_ai = yes
			}
			any_pool_character = {
				province = root.capital_province
				appropriately_dirty_peasant = yes
			}
		}
		trigger_else = {
			OR = {
				any_courtier_or_guest = {
					appropriately_dirty_peasant = yes
				}
				any_pool_character = {
					province = root.capital_province
					appropriately_dirty_peasant = yes
				}
				any_vassal_or_below = {
					highest_held_title_tier = tier_barony
					appropriately_dirty_peasant = yes
				}
			}
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_learn_language_ongoing_1030
				value = yes
				days = 3650
			}
		}
		if = {
			limit = {
				is_ai = yes
			}
			every_pool_character = {
				province = root.capital_province
				limit = {
					appropriately_dirty_peasant = yes
				}
				add_to_list = appropriate_peasant
			}
		}
		else = {
			every_courtier_or_guest = {
				limit = {
					appropriately_dirty_peasant = yes
				}
				add_to_list = appropriate_peasant
			}
			every_pool_character = {
				province = root.capital_province
				limit = {
					appropriately_dirty_peasant = yes
				}
				add_to_list = appropriate_peasant
			}
			every_vassal_or_below = {
				limit = {
					highest_held_title_tier = tier_barony
					appropriately_dirty_peasant = yes
				}
				add_to_list = appropriate_peasant
			}
		}
		random_in_list = {
			list = appropriate_peasant
			save_scope_as = chosen_peasant
		}
		# Book creation
		random_dummy_gender_effect = yes #used for book creation
		scope:chosen_peasant = {
			assign_quirk_effect = yes

			save_temporary_scope_value_as = {
				name = should_be_trinket
				value = yes
			}
			hidden_effect_new_object = {
				create_artifact_book_effect = { #using effect to ensure that scope:owner is set properly
					OWNER = scope:chosen_peasant
					CREATOR = scope:dummy_gender
					SET_SUBJECT = flag:language_manual
					SET_TOPIC = flag:language_manual
				}
				scope:newly_created_artifact = {
					flag_as_trash_artifact = yes
					set_variable = {
						name = language_manual
						value = yes
					}
				}
			}
		}
	}

	option = { # Pay the peasant
		name = learn_language_ongoing.1030.a
		
		custom_tooltip = gain_artifact_tt
		
		pay_short_term_gold = {
			target = scope:chosen_peasant
			gold = medium_gold_value
		}
		
		scope:newly_created_artifact = {
			set_owner = {
				target = root
				history = {
					location = root.capital_province
					actor = scope:chosen_peasant
					recipient = root
					type = given
				}
			}
		}
		
		stress_impact = {
			greedy = massive_stress_impact_gain
			paranoid = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # Haggle with the peasant
		name = learn_language_ongoing.1030.b
		
		duel = {
			skill = stewardship
			value = scope:chosen_peasant.stewardship

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1020.b.success
				send_interface_toast = {
					title = learn_language_ongoing.1020.b.success
					left_icon = scope:chosen_peasant
					
					pay_short_term_gold = {
						target = scope:chosen_peasant
						gold = tiny_gold_value
					}
					
					custom_tooltip = gain_artifact_tt
					scope:newly_created_artifact = {
						set_owner = {
							target = root
							history = {
								location = root.capital_province
								actor = scope:chosen_peasant
								recipient = root
								type = given
							}
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1020.b.failure
				send_interface_toast = {
					title = learn_language_ongoing.1020.b.failure
					left_icon = scope:chosen_peasant

					scope:chosen_peasant = {
						add_opinion = {
							target = root
							modifier = insult_opinion
							opinion = -25
						}
			
						hidden_effect = {
							random = {
								chance = 50
								if = {
									limit = {
										can_set_relation_potential_rival_trigger = { CHARACTER = root }
									}
									set_relation_potential_rival = root
								}
							}
						}
					}
				}
			}
		}
		
		stress_impact = {
			generous = massive_stress_impact_gain
			honest = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					ai_greed <= low_negative_ai_value
				}
			}
		}
	}

	option = { # Seize it from the peasant
		name = learn_language_ongoing.1030.c
		
		custom_tooltip = steal_artifact_tt
		scope:newly_created_artifact = {
			set_owner = {
				target = root
				history = {
					location = root.capital_province
					actor = scope:chosen_peasant
					recipient = root
					type = stolen
				}
			}
			if = {
				limit = {
					NOT = { has_variable = stolen_artifact }
				}
				set_variable = {
					name = stolen_artifact
					value = 1
				}
			}
			else = {
				change_variable = {
					name = stolen_artifact
					add = 1
				}
			}
		}
		
		scope:chosen_peasant = {
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -50
			}
			progress_towards_rival_effect = {
				REASON = rival_peasant_artifact_stolen
				CHARACTER = root
				OPINION = 0
			}
		}
		
		stress_impact = {
			generous = massive_stress_impact_gain
			just = massive_stress_impact_gain
			honest = major_stress_impact_gain
			trusting = major_stress_impact_gain
			forgiving = medium_stress_impact_gain
			content = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				ai_honor <= medium_negative_ai_value
				ai_greed >= medium_positive_ai_value
			}
		}
	}

	option = { # Not interested.
		name = learn_language_ongoing.1030.d
		
		scope:chosen_peasant = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -5
			}
			hidden_effect = {
				destroy_artifact = scope:newly_created_artifact
			}
		}
		
		stress_impact = {
			trusting = major_stress_impact_gain
			lazy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = trusting
			}
		}
	}
}

# Earn the admiration of the one you're targeting
learn_language_ongoing.1040 = {
	type = character_event
	title = learn_language_ongoing.1040.t
	desc = learn_language_ongoing.1040.desc
	theme = education
	left_portrait = {
		character = scope:target
		animation = chancellor
	}
	override_background = {
		reference = sitting_room
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1040 }
			scheme_target_character = {
				ai_compassion >= 0
				ai_sociability >= 0
				NOT = {
					has_relation_rival = root
				}
			}
		}
	}

	immediate = {
		scope:scheme = {
			set_variable = {	
				name = had_event_learn_language_ongoing_1040
				value = yes
				days = 3650
			}
		}
	}

	option = { # Send a heartfelt response
		name = learn_language_ongoing.1040.a
		scope:target = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 15
			}
			if = {
				limit = {
					is_ai = yes
				}
				progress_towards_friend_effect = {
					CHARACTER = root
					OPINION = 0
					REASON = friend_penpals
				}
			}
		}
		stress_impact = {
			paranoid = massive_stress_impact_gain
			callous = major_stress_impact_gain
			sadistic = major_stress_impact_gain
			ambitious = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					has_trait = callous
					has_trait = sadistic
					ai_sociability <= 0
				}
			}
		}
	}

	option = { # Reverse-engineer the correspondence
		name = learn_language_ongoing.1040.b
		scope:target = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 15
			}
		}
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		stress_impact = {
			impatient = massive_stress_impact_gain
			arrogant = medium_stress_impact_gain
			lazy = medium_stress_impact_gain
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = impatient
					has_trait = arrogant
				}
			}
		}
	}

	option = { # I'm not doing it for *you*
		name = learn_language_ongoing.1040.c
		scope:target = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -15
			}
		}
		add_prestige = medium_prestige_gain
		stress_impact = {
			humble = massive_stress_impact_gain
			compassionate = major_stress_impact_gain
			forgiving = medium_stress_impact_gain
			patient = medium_stress_impact_gain
			content = medium_stress_impact_gain
			calm = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}
}

scripted_trigger appropriately_evil_rival = {
	is_available_ai_adult = yes
	ai_compassion <= low_positive_ai_value
}

# Your rival has sabotaged your notes! Lose progress.
learn_language_ongoing.1050 = {
	type = character_event
	title = learn_language_ongoing.1050.t
	desc = learn_language_ongoing.1050.desc
	theme = education
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:sabotage_rival
		animation = schadenfreude
	}
	override_background = {
		reference = study
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1050 }
		}
		OR = {
			any_relation = {
				type = rival
				appropriately_evil_rival = yes
			}
			any_relation = {
				type = potential_rival
				appropriately_evil_rival = yes
			}
		}
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {	
				name = had_event_learn_language_ongoing_1050
				value = yes
				days = 3650
			}
		}
		every_relation = {
			type = rival
			limit = {
				appropriately_evil_rival = yes
			}
			add_to_list = evil_fellas
		}
		every_relation = {
			type = potential_rival
			limit = {
				appropriately_evil_rival = yes
			}
			add_to_list = evil_fellas
		}
		
		random_in_list = {
			list = evil_fellas
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					has_relation_rival = root
				}
				modifier = {
					add = {
						value = ai_vengefulness
						divide = 5
					}
					ai_vengefulness > 0
				}
			}
			save_scope_as = sabotage_rival
		}
	}
	
	option = { # Ha-ha! I always keep backup notes!
		name = learn_language_ongoing.1050.c
		trigger = {
			has_trait = scholar
		}
		trait = scholar
		scope:sabotage_rival = {
			add_stress = major_stress_gain
			scope:target = { save_scope_as = relationship_reason_involved_character }
			progress_towards_rival_effect = {
				REASON = rival_crows_feet
				CHARACTER = root
				OPINION = 0
			}
			clear_saved_scope = relationship_reason_involved_character
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Nooooooo!
		name = learn_language_ongoing.1050.a
		add_stress = medium_stress_impact_gain
		scope:sabotage_rival = {
			add_stress = major_stress_impact_loss
			scope:target = { save_scope_as = relationship_reason_involved_character }
			progress_towards_rival_effect = {
				REASON = rival_crows_feet
				CHARACTER = root
				OPINION = 0
			}
			clear_saved_scope = relationship_reason_involved_character
		}
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		ai_chance = {
			base = 25
		}
	}

	option = { # They deserve to DIE!
		name = learn_language_ongoing.1050.b
		scope:sabotage_rival = {
			add_stress = major_stress_impact_loss
			scope:target = { save_scope_as = relationship_reason_involved_character }
			progress_towards_rival_effect = {
				REASON = rival_crows_feet
				CHARACTER = root
				OPINION = 0
			}
			clear_saved_scope = relationship_reason_involved_character
		}
		trigger = {
			OR = {
				any_scheme = {
					type = murder
					scheme_target_character = scope:sabotage_rival
				}
				can_start_scheme = {
					type = murder
					target_character = scope:sabotage_rival
				}
			}
		}
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		if = {
			limit = {
				NOT = {
					any_scheme = {
						type = murder
						scheme_target_character = scope:sabotage_rival
					}
				}
			}
			start_scheme = {
				target_character = scope:sabotage_rival
				type = murder
			}
		}
		custom_tooltip = diplomacy_family.2250.b.tt
		hidden_effect = {
			random_scheme = {
				type = murder
				limit = {
					scheme_target_character = scope:sabotage_rival
				}
				add_scheme_modifier = {
					type = extra_success_chance_modifier
				}
			}
		}
		stress_impact = {	
			base = medium_stress_impact_gain
			forgiving = massive_stress_impact_gain
			compassionate = major_stress_impact_gain
			calm = major_stress_impact_gain
		}
		ai_chance = {
			base = 0
			modifier = {
				add = ai_vengefulness
			}
		}
	}
}

scripted_trigger offendable_character = {
	is_available_ai_adult = yes
	ai_compassion <= low_positive_ai_value
	NOR = {
		has_trait = forgiving
		has_trait = shy
		has_relation_rival = root
		has_relation_friend = root
		has_relation_lover = root
		is_child_of = root
		culture = {
			has_same_culture_language = root.culture
		}
	}
}

# Offend someone who doesn't speak your language
learn_language_ongoing.1060 = {
	type = character_event
	title = learn_language_ongoing.1060.t
	desc = learn_language_ongoing.1060.desc
	theme = education
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		character = scope:offended_character
		animation = rage
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1060 }
		}
		OR = {
			any_courtier_or_guest = {
				offendable_character = yes
			}
			any_vassal_or_below = {
				offendable_character = yes
			}
		}
		age >= 12
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1060
				value = yes
				days = 3650
			}
		}
		every_courtier_or_guest = {
			limit = {
				offendable_character = yes
			}
			add_to_list = offendable_characters
		}
		every_vassal_or_below = {
			limit = {
				offendable_character = yes
			}
			add_to_list = offendable_characters
		}
		
		random_in_list = {
			list = offendable_characters
			weight = {
				base = 1
				modifier = {
					add = 50
					culture = {
						has_same_culture_language = scope:target.culture
					}
					exists = primary_title
					primary_title.tier > tier_county
				}
				modifier = {
					add = 100
					is_of_major_interest_to_root_trigger = yes
					culture = {
						has_same_culture_language = scope:target.culture
					}
				}
				modifier = {
					add = 50
					is_of_minor_interest_to_root_trigger = yes
					culture = {
						has_same_culture_language = scope:target.culture
					}
				}
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					culture = {
						has_same_culture_language = scope:target.culture
					}
				}
			}
			save_scope_as = offended_character
		}
	}

	option = { # Pay them
		name = learn_language_ongoing.1060.a
		
		pay_short_term_gold = {
			target = scope:offended_character
			gold = scope:offended_character.tiny_gold_value
		}
		
		scope:offended_character = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
			
		scope:scheme = {
			add_scheme_modifier = {
				type = extra_careful_modifier
			}
		}
		
		stress_impact = {
			greedy = massive_stress_impact_gain
			arrogant = major_stress_impact_gain
			wrathful = major_stress_impact_gain
			sadistic = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			fickle = medium_stress_impact_gain
			deceitful = medium_stress_impact_gain
			brave = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # Trick them into believing the opposite
		name = learn_language_ongoing.1060.b
		
		duel = {
			skill = intrigue
			value = scope:offended_character.intrigue

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1060.b.success
				send_interface_toast = {
					title = learn_language_ongoing.1060.b.success
					left_icon = scope:offended_character
					
					scope:offended_character = {
						add_opinion = {
							target = root
							modifier = pleased_opinion
							opinion = 25
						}
						progress_towards_friend_effect = {
							CHARACTER = root
							OPINION = 0
							REASON = friend_complimented_parent
						}
					}
					
					scope:scheme = {
						add_scheme_modifier = {
							type = carefully_chosen_words_modifier
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1060.b.failure
				send_interface_toast = {
					title = learn_language_ongoing.1060.b.failure
					left_icon = scope:offended_character

					scope:offended_character = {
						add_opinion = {
							target = root
							modifier = insult_opinion
							opinion = -15
						}
						
			
						hidden_effect = {
							random = {
								chance = 50
								if = {
									limit = {
										can_set_relation_potential_rival_trigger = { CHARACTER = root }
									}
									set_relation_potential_rival = root
								}
							}
						}
					}
					add_prestige = medium_prestige_loss
				}
			}
		}
		
		stress_impact = {
			honest = massive_stress_impact_gain
			forgiving = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					ai_honor >= low_positive_ai_value
					intrigue <= 8
				}
			}
		}
	}

	option = { # Double-down on the insult
		name = learn_language_ongoing.1060.c
		
		add_prestige = medium_prestige_gain
		
		scope:offended_character = {
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -30
			}
			hidden_effect = {
				random = {
					chance = 50
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = root }
						}
						set_relation_potential_rival = root
					}
				}
			}
		}
			
		
		stress_impact = {
			compassionate = massive_stress_impact_gain
			calm = massive_stress_impact_gain
			craven = major_stress_impact_gain
			forgiving = medium_stress_impact_gain
			patient = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			gregarious = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			just = minor_stress_impact_gain
			temperate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # Try to defuse the situation diplomatically
		name = learn_language_ongoing.1060.d
		
		duel = {
			skill = diplomacy
			value = scope:offended_character.diplomacy

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1060.d.success
				send_interface_toast = {
					title = learn_language_ongoing.1060.d.success
					left_icon = scope:offended_character
					
					scope:offended_character = {
						add_opinion = {
							target = root
							modifier = pleased_opinion
							opinion = 15
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1060.d.failure
				send_interface_toast = {
					title = learn_language_ongoing.1060.d.failure
					left_icon = scope:offended_character

					scope:offended_character = {
						add_opinion = {
							target = root
							modifier = insult_opinion
							opinion = -15
						}
			
						hidden_effect = {
							random = {
								chance = 50
								if = {
									limit = {
										can_set_relation_potential_rival_trigger = { CHARACTER = root }
									}
									set_relation_potential_rival = root
								}
							}
						}
					}
				}
			}
		}
		
		stress_impact = {
			arrogant = major_stress_impact_gain
			deceitful = major_stress_impact_gain
			stubborn = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = deceitful
				}
			}
		}
	}
}

# The target 'helps' you by sending you a lewd book
# Loosely based on a true story where the project's Content Design Lead was tricked into reading lewd Latin poetry out loud in class
learn_language_ongoing.1070 = {
	type = character_event
	title = learn_language_ongoing.1070.t
	desc = learn_language_ongoing.1070.desc
	theme = education
	left_portrait = {
		character = root
		animation = chancellor
	}
	right_portrait = {
		character = scope:target
		animation = schadenfreude
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1070 }
			scheme_target_character = {
				is_available_ai_adult = yes
				OR = {
					has_trait = arbitrary
					has_trait = sadistic
					NOR = {
						has_relation_friend = root
						has_relation_lover = root
						opinion = {
							target = root
							value >= 25
						}
						has_trait = shy
						ai_compassion >= high_positive_ai_value
					}
				}
			}
		}
		is_adult = yes
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1070
				value = yes
				days = 3650
			}
		}
	}

	option = { # What an insult to my honor!
		name = learn_language_ongoing.1070.a
		
		add_prestige = medium_prestige_loss
		
		add_character_modifier = {
			modifier = lauded_loud_reader_modifier
			years = 10
		}
		
		hidden_effect = {
			random = {
				chance = 50
				if = {
					limit = {
						can_set_relation_potential_rival_trigger = { CHARACTER = scope:target }
					}
					set_relation_potential_rival = scope:target
				}
			}
		}
		
		stress_impact = {
			calm = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = forgiving
					has_trait = trusting
				}
			}
		}
	}

	option = { # Have them all flogged
		name = learn_language_ongoing.1070.b
		
		add_prestige = medium_prestige_loss
		
		add_dread = medium_dread_gain
		
		stress_impact = {
			compassionate = massive_stress_impact_gain
			forgiving = massive_stress_impact_gain
			calm = major_stress_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOR = {
					has_trait = sadistic
					has_trait = callous
					has_trait = wrathful
				}
			}
		}
	}

	option = { # Oh well, at least I learned something...
		name = learn_language_ongoing.1070.c
		
		add_prestige = medium_prestige_loss
			
		scope:scheme = {
			add_scheme_modifier = {
				type = erotic_novel_connoisseur_modifier
			}
		}
		
		stress_impact = {
			vengeful = massive_stress_impact_gain
			arrogant = major_stress_gain
			wrathful = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = vengeful
					has_trait = arrogant
				}
			}
		}
	}
}

scripted_trigger court_tutor_requirements = {
	is_available_ai_adult = yes
	has_court_position = court_tutor_court_position
}

# Your Court Tutor helps you along
learn_language_ongoing.1080 = {
	type = character_event
	title = learn_language_ongoing.1080.t
	desc = learn_language_ongoing.1080.desc
	theme = education
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:court_tutor
		animation = chancellor
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1080 }
		}
		any_courtier = {
			court_tutor_requirements = yes
		}
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1080
				value = yes
				days = 3650
			}
		}
		random_courtier = {
			limit = {
				court_tutor_requirements = yes
			}
			save_scope_as = court_tutor
		}
	}

	option = { # They deserve a reward!
		name = learn_language_ongoing.1080.a
		
		pay_short_term_gold = {
			target = scope:court_tutor
			gold = tiny_gold_value
		}
		
		scope:court_tutor = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
			progress_towards_friend_effect = {
				CHARACTER = root
				OPINION = 0
				REASON = friend_court_tutor_reward
			}
		}
		
		scope:scheme = {
			add_scheme_modifier = {
				type = attended_by_tutor_modifier
			}
		}
		
		stress_impact = {
			greedy = massive_stress_impact_gain
			paranoid = major_stress_gain
			arrogant = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # They're doing a fine job.
		name = learn_language_ongoing.1080.b
		
		scope:scheme = {
			add_scheme_modifier = {
				type = attended_by_tutor_modifier
			}
		}
		
		stress_impact = {
			generous = massive_stress_impact_gain
			compassionate = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				ai_greed < low_negative_ai_value
			}
		}
	}
}

# Learning a language is hard
learn_language_ongoing.1090 = {
	type = character_event
	title = learn_language_ongoing.1090.t
	desc = {
		desc = learn_language_ongoing.1090.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:helpful_friend
				}
				desc = learn_language_ongoing.1090.friend.desc
			}
			desc = learn_language_ongoing.1090.no_friend.desc
		}
	}
	theme = education
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:helpful_friend
		animation = admiration
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		NOT = { has_character_modifier = ulp_unlimited_languages_player_modifier }
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1090 }
		}
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1090
				value = yes
				days = 3650
			}
			scheme_target_character = {
				save_scope_as = target
			}
		}
		if = {
			limit = {
				any_relation = {
					type = friend
					is_available_ai_adult = yes
				}
			}
			random_relation = {
				type = friend
				limit = {
					is_available_ai_adult = yes
				}
				save_scope_as = helpful_friend
			}
		}
	}

	option = { # I can always lean on X for support!
		name = learn_language_ongoing.1090.a
		
		trigger = {
			exists = scope:helpful_friend
		}
		
		scope:scheme = {
			add_scheme_modifier = {
				type = encouraged_by_friend_modifier
			}
		}
		
		if = {
			limit = {
				can_set_relation_best_friend_trigger = { CHARACTER = scope:helpful_friend }
			}
			set_relation_best_friend = { reason = best_friend_language_help copy_reason = friend target = scope:helpful_friend involved_character = scope:target }
		}
		
		stress_impact = {
			paranoid = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					ai_greed >= medium_positive_ai_value
					gold <= 100
				}
			}
		}
	}

	option = { # No! I must power through this.
		name = learn_language_ongoing.1090.b
		
		add_stress = major_stress_gain
		
		stress_impact = {
			lazy = massive_stress_impact_gain
			fickle = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					exists = scope:helpful_friend
					has_trait = lazy
				}
			}
		}
	}

	option = { # I need to take a break.
		name = learn_language_ongoing.1090.c
		
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		
		stress_impact = {
			stubborn = massive_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					exists = scope:helpful_friend
					has_trait = stubborn
				}
			}
		}
	}
}

# News of your efforts are spreading, gain cultural acceptance
learn_language_ongoing.1100 = {
	type = character_event
	title = learn_language_ongoing.1100.t
	desc = learn_language_ongoing.1100.desc
	theme = education
	left_portrait = {
		character = root
		animation = happiness
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1100 }
		}
		any_realm_county = {
			culture = scope:target.culture
		}
		is_adult = yes
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1100
				value = yes
				days = 3650
			}
		}
	}

	option = { # Perhaps I should make a speech?
		name = learn_language_ongoing.1100.a
		
		duel = {
			skill = diplomacy
			value = 16

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1100.a.success
				send_interface_toast = {
					title = learn_language_ongoing.1100.a.success
					left_icon = root
					
					culture = {
						change_cultural_acceptance = {
							target = scope:target.culture
							value = 2
							desc = cultural_acceptance_gain_event
						}
					}
					add_prestige = medium_prestige_gain
					set_nickname_effect = { NICKNAME = nick_the_kind }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1100.a.failure
				send_interface_toast = {
					title = learn_language_ongoing.1100.a.failure
					left_icon = root

					add_prestige = medium_prestige_loss
				}
			}
		}
		
		stress_impact = {
			humble = massive_stress_impact_gain
			shy = massive_stress_impact_gain
			paranoid = major_stress_gain
			content = medium_stress_impact_gain
			lazy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = shy
					ai_sociability <= low_negative_ai_value
				}
			}
		}
	}

	option = { # Kill the rumors, I must not be distracted
		name = learn_language_ongoing.1100.b
		
		scope:scheme = {
			add_scheme_progress = {
				value = scheme_progress_gain
				multiply = 2
			}
		}
		
		stress_impact = {
			arrogant = massive_stress_impact_gain
			ambitious = major_stress_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = ambitious
				}
			}
		}
	}

	option = { # Most fortunate!
		name = learn_language_ongoing.1100.c
		
		culture = {
			change_cultural_acceptance = {
				target = scope:target.culture
				value = 1
				desc = cultural_acceptance_gain_event
			}
		}
		
		stress_impact = {
			arrogant = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				ai_greed < low_negative_ai_value
			}
		}
	}
}

scripted_trigger appropriate_poet = {
	culture = scope:target.culture
	is_available_ai_adult = yes
	has_no_particular_noble_roots_trigger = yes
}

scripted_trigger good_potential_lover = {
	can_set_relation_lover_trigger = { CHARACTER = root }
	is_attracted_to_gender_of = root
	root = {
		is_attracted_to_gender_of = prev
	}
	is_available_ai_adult = yes
}

# Become a Poet?
learn_language_ongoing.1110 = {
	type = character_event
	title = learn_language_ongoing.1110.t
	desc = learn_language_ongoing.1110.desc
	theme = education
	left_portrait = {
		character = scope:the_poet
		animation = chancellor
	}
	lower_left_portrait = scope:lover_to_be
	override_background = { reference = garden }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1110 }
		}
		NOT = { has_trait = lifestyle_poet }
		
		scope:target.culture = {
			any_culture_county = {
				holder = {
					NOR = {
						this = root
						is_ai = no
					}
					any_courtier_or_guest = {
						appropriate_poet = yes
					}
				}
			}
		}
		age >= 14
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1110
				value = yes
				days = 3650
			}
		}
		scope:target.culture = {
			random_culture_county = {
				limit = {
					holder = {
						NOR = {
							this = root
							is_ai = no
						}
						any_courtier_or_guest = {
							appropriate_poet = yes
						}
					}
				}
				save_scope_as = poet_location
				holder = {
					random_courtier_or_guest = {
						limit = {
							appropriate_poet = yes
						}
						save_scope_as = the_poet
						scope:the_poet = {
							hidden_effect = {
								if = {
									limit = {
										NOT = {
											has_trait = lifestyle_poet
										}
									}
									add_trait = lifestyle_poet
								}
							}
						}
					}
				}
			}
		}
		# Roll for theme.
		select_poem_theme_random_effect = yes
		# Set up a subject gender.
		select_poem_subject_gender_effect = {
			SUBJECT = flag:no
			SUBJECT_TARGET = scope:target
		}
		
		every_consort = {
			limit = {
				good_potential_lover = yes
			}
			add_to_list = potential_lovers
		}
		every_relation = {
			type = potential_lover
			limit = {
				good_potential_lover = yes
			}
			add_to_list = potential_lovers
		}
		random_in_list = {
			list = potential_lovers
			weight = {
				base = 1
				modifier = {
					add = 10
					has_relation_potential_lover = root
				}
				modifier = {
					add = 10
					has_relation_potential_lover = root
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = lover_to_be
		}
	}

	option = { # Try your hand at poetry
		name = learn_language_ongoing.1110.a
		
		duel = {
			skill = learning
			value = 10

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1110.a.success
				send_interface_toast = {
					title = learn_language_ongoing.1110.a.success
					left_icon = root
					
					add_trait = lifestyle_poet
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1110.a.failure
				send_interface_toast = {
					title = learn_language_ongoing.1110.a.failure
					left_icon = root

					add_prestige = minor_prestige_loss
				}
			}
		}
		
		stress_impact = {
			impatient = major_stress_gain
			wrathful = medium_stress_impact_gain
			lazy = medium_stress_impact_gain
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = impatient
			}
		}
	}

	option = { # Recite a romantic poem to someone
		name = learn_language_ongoing.1110.b
		
		trigger = {
			exists = scope:lover_to_be
		}
		
		scope:lover_to_be = {
			add_opinion = {
				target = root
				modifier = flirty_opinion
				opinion = 20
				years = 20
			}
			progress_towards_lover_effect = {
				CHARACTER = root
				REASON = lover_written_romantic_poetry
				OPINION = 0
			}
		}
		
		stress_impact = {
			chaste = massive_stress_impact_gain
			diligent = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = chaste
					has_trait = shy
					ai_sociability <= low_negative_ai_value
				}
			}
		}
	}

	option = { # Use the poetry as study material
		name = learn_language_ongoing.1110.c
		
		scope:scheme = {
			add_scheme_modifier = {
				type = poetry_collector_modifier
			}
		}
		
		stress_impact = {
			arbitrary = medium_stress_impact_gain
			fickle = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}

scripted_trigger insensitive_asshole_character = {
	is_available = yes
	is_ai = yes
	ai_compassion <= low_negative_ai_value
	NOR = {
		has_relation_friend = root
		has_relation_lover = root
	}
}

# Lose prestige for reading children's fables
learn_language_ongoing.1120 = {
	type = character_event
	title = learn_language_ongoing.1120.t
	desc = learn_language_ongoing.1120.desc
	theme = education
	left_portrait = {
		character = root
		animation = chancellor
	}
	right_portrait = {
		character = scope:insensitive_asshole
		animation = disgust
	}
	override_background = { reference = study }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1120 }
		}
		is_adult = yes # It's not exactly shameful to read children's books if you're a child...
		OR = {
			any_consort = {
				insensitive_asshole_character = yes
			}
			any_close_family_member = {
				insensitive_asshole_character = yes
				top_liege ?= root.top_liege
			}
			any_vassal = {
				insensitive_asshole_character = yes
			}
		}
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1120
				value = yes
				days = 3650
			}
		}
		scope:target = {
			save_scope_as = second
		}
		
		every_consort = {
			limit = {
				insensitive_asshole_character = yes
			}
			add_to_list = insensitive_assholes
		}
		every_close_family_member = {
			limit = {
				insensitive_asshole_character = yes
				top_liege ?= root.top_liege
			}
			add_to_list = insensitive_assholes
		}
		every_vassal = {
			limit = {
				insensitive_asshole_character = yes
			}
			add_to_list = insensitive_assholes
		}
		random_in_list = {
			list = insensitive_assholes
			weight = {
				base = 1
				modifier = {
					add = 25
					OR = {
						has_relation_rival = root
						has_relation_potential_rival = root
					}
				}
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = insensitive_asshole
		}
		select_local_animal_effect = { TYPE = any } # Save scope to limit possible animals: any/big/small/dangerous/harmless/prowling
		save_scope_as = root_for_loc
	}

	option = { # Fool the rude dude
		name = learn_language_ongoing.1120.a
		
		duel = {
			skill = intrigue
			value = scope:insensitive_asshole.intrigue

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}

				desc = learn_language_ongoing.1120.a.success
				send_interface_toast = {
					title = learn_language_ongoing.1120.a.success
					left_icon = scope:insensitive_asshole
					
					add_prestige = medium_prestige_gain
					
					scope:insensitive_asshole = {
						add_opinion = {
							target = root
							modifier = impressed_opinion
							opinion = 15
						}
					}
					
					scope:scheme = {
						add_scheme_modifier = {
							type = easily_read_fables_modifier
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = learn_language_ongoing.1120.a.failure
				send_interface_toast = {
					title = learn_language_ongoing.1120.a.failure
					left_icon = scope:insensitive_asshole

					add_prestige = major_prestige_loss
		
					add_character_modifier = {
						modifier = seemingly_feeble_minded_modifier
						years = 10
					}
				}
			}
		}
		
		stress_impact = {
			honest = massive_stress_impact_gain
			just = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				ai_honor > 0
			}
		}
	}

	option = { # Punish them for their insolence
		name = learn_language_ongoing.1120.b
		
		trigger = {
			can_start_single_combat_trigger = yes
			scope:insensitive_asshole = {
				can_be_warrior_trigger = { ARMY_OWNER = root }
				can_start_single_combat_trigger = yes
			}
		}
		custom_tooltip = learn_language_ongoing.1120.b.tt
		
		configure_start_single_combat_effect = {
			SC_INITIATOR = root
			SC_ATTACKER = root
			SC_DEFENDER = scope:insensitive_asshole
			FATALITY = no
			FIXED = no
			LOCALE = terrain_scope
			OUTPUT_EVENT = learn_language_ongoing.1122
			INVALIDATION_EVENT = learn_language_ongoing.1121
		}

		stress_impact = {
			craven = massive_stress_impact_gain
			calm = major_stress_gain
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			temperate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				NOR = {
					has_trait = brave
					has_trait = wrathful
					has_trait = arrogant
					has_trait = vengeful
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = calm
				}
			}
		}
	}

	option = { # Get rid of the fables
		name = learn_language_ongoing.1120.c
					
		scope:insensitive_asshole = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}
		scope:scheme = {
			add_scheme_progress = scheme_progress_loss
		}
		
		stress_impact = {
			ambitious = major_stress_impact_gain
			arbitrary = medium_stress_impact_gain
			fickle = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
			deceitful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = ambitious
					has_trait = arbitrary
					has_trait = fickle
					has_trait = callous
				}
			}
		}
	}

	option = { # Bite the bullet and keep reading
		name = learn_language_ongoing.1120.d
		
		add_prestige = medium_prestige_loss
		
		add_character_modifier = {
			modifier = seemingly_feeble_minded_modifier
			years = 10
		}
		
		scope:scheme = {
			add_scheme_modifier = {
				type = easily_read_fables_modifier
			}
		}
		
		stress_impact = {
			arrogant = medium_stress_impact_gain
			lazy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = lazy
				}
			}
		}
	}
}

# Invalidated
learn_language_ongoing.1121 = {
	hidden = yes

	immediate = {
		# Inform both parties that the duel has invalidated.
		scope:root_for_loc = {
			send_interface_toast = {	
				title = learn_language_ongoing.1121.trigger_failure
				left_icon = scope:insensitive_asshole
			}
		}
	}
}

# Outcome
learn_language_ongoing.1122 = {
	hidden = yes

	immediate = {
		if = {
			limit = {
				scope:root_for_loc = scope:sc_victor
			}
			trigger_event = { id = learn_language_ongoing.1123 days = 1 }
		}
		else = {
			trigger_event = { id = learn_language_ongoing.1124 days = 1 }
		}
	}
}

# Won
learn_language_ongoing.1123 = {
	type = character_event
	title = learn_language_ongoing.1123.t
	desc = learn_language_ongoing.1123.desc
	theme = education
	left_portrait = {
		character = root
		animation = rage
	}
	right_portrait = {
		character = scope:insensitive_asshole
		animation = pain
	}
	override_background = { reference = study }

	trigger = {

	}

	immediate = {
		
	}

	option = { # Don't you dare insult me again!
		name = learn_language_ongoing.1123.a
		
		add_prestige = major_prestige_gain
		
		scope:scheme = {
			add_scheme_modifier = {
				type = easily_read_fables_modifier
			}
		}
		
		progress_towards_rival_effect = {
			REASON = rival_insensitive_asshole
			CHARACTER = scope:insensitive_asshole
			OPINION = 0
		}
		
		ai_chance = {
			base = 100
		}
	}

	option = { # And into the dungeon you go!
		name = learn_language_ongoing.1123.b
		
		add_prestige = medium_prestige_gain
		add_dread = medium_dread_gain
		
		scope:scheme = {
			add_scheme_modifier = {
				type = easily_read_fables_modifier
			}
		}
		
		rightfully_imprison_character_effect = {
			TARGET = scope:insensitive_asshole
			IMPRISONER = root
		}
		
		progress_towards_rival_effect = {
			REASON = rival_insensitive_asshole
			CHARACTER = scope:insensitive_asshole
			OPINION = 0
		}
		
		stress_impact = {
			forgiving = massive_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = forgiving
					ai_compassion >= medium_positive_ai_value
				}
			}
		}
	}
	after = { remove_variable = animal_type }
}

# Beaten
learn_language_ongoing.1124 = {
	type = character_event
	title = learn_language_ongoing.1124.t
	desc = learn_language_ongoing.1124.desc
	theme = family
	left_portrait = {
		character = root
		animation = pain
	}
	right_portrait = {
		character = scope:insensitive_asshole
		animation = rage
	}
	override_background = { reference = study }

	trigger = {

	}

	immediate = {
		
	}

	option = { # Ouch...
		name = learn_language_ongoing.1124.a
		
		add_prestige = major_prestige_loss
		
		add_character_modifier = {
			modifier = seemingly_feeble_minded_modifier
			years = 10
		}
		
		scope:insensitive_asshole = {
			progress_towards_rival_effect = {
				REASON = rival_insensitive_asshole_corresponding
				CHARACTER = root
				OPINION = 0
			}
		}
		
		ai_chance = {
			base = 100
		}
	}
	after = { remove_variable = animal_type }
}

scripted_trigger appropriate_love_interest_trigger = {
	is_available_ai_adult = yes
	is_attracted_to_gender_of = root
	root = {
		is_attracted_to_gender_of = prev
	}
	culture = {
		has_same_culture_language = scope:target.culture
	}
}

# Attracted Spouse/Lover help you out
learn_language_ongoing.1130 = {
	type = character_event
	title = learn_language_ongoing.1130.t
	desc = learn_language_ongoing.1130.desc
	theme = education
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:lover_to_help
		animation = admiration
	}
	override_background = { reference = study }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1130 }
		}
		is_adult = yes
		OR = {
			any_relation = {
				type = lover
				appropriate_love_interest_trigger = yes
			}
			any_relation = {
				type = potential_lover
				might_cheat_on_every_partner_trigger = yes
				appropriate_love_interest_trigger = yes
			}
			any_consort = {
				appropriate_love_interest_trigger = yes
			}
		}
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1130
				value = yes
				days = 3650
			}
		}
		every_relation = {
			type = lover
			limit = {
				appropriate_love_interest_trigger = yes
			}
			add_to_list = potential_lovers_to_help
		}
		every_relation = {
			type = potential_lover
			limit = {
				might_cheat_on_every_partner_trigger = yes
				appropriate_love_interest_trigger = yes
			}
			add_to_list = potential_lovers_to_help
		}
		every_consort = {
			limit = {
				appropriate_love_interest_trigger = yes
			}
			add_to_list = potential_lovers_to_help
		}
		random_in_list = {
			list = potential_lovers_to_help
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
				modifier = {
					add = learning
					learning > 0
				}
			}
			save_scope_as = lover_to_help
			assign_quirk_effect = yes
		}
	}

	option = { # Accept help
		name = learn_language_ongoing.1130.a
		
		scope:lover_to_help = {
			duel = {
				skill = learning
				value = 6

				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}

					desc = learn_language_ongoing.1130.a.success
					root = {
						send_interface_toast = {
							title = learn_language_ongoing.1130.a.success
							left_icon = scope:lover_to_help
							
							scope:lover_to_help = {
								add_opinion = {
									target = root
									modifier = flirty_opinion
									opinion = 15
								}
							}
							
							scope:scheme = {
								add_scheme_modifier = {
									type = motivated_by_love_modifier
								}
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}

					desc = learn_language_ongoing.1130.a.failure
					root = {
						send_interface_toast = {
							title = learn_language_ongoing.1130.a.failure
							left_icon = scope:lover_to_help

							scope:scheme = {
								add_scheme_progress = {
									value = scheme_progress_loss
									multiply = 2
								}
							}
						}
					}
				}
			}
		}
		
		stress_impact = {
			lustful = massive_stress_impact_gain
			lazy = massive_stress_impact_gain
			paranoid = medium_stress_impact_gain
			stubborn = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				OR = {
					has_trait = lustful
					has_trait = lazy
					has_trait = paranoid
					has_trait = stubborn
					has_trait = arrogant
					has_trait = callous
				}
			}
		}
	}

	option = { # Tumble
		name = learn_language_ongoing.1130.b
		trigger = {
			trigger_if = {
				limit = { has_relation_potential_lover = scope:lover_to_help }
				might_cheat_on_every_partner_trigger = yes
			}
		}
		
		scope:lover_to_help = {
			add_opinion = {
				target = root
				modifier = flirty_opinion
				opinion = 20
			}
			
			had_sex_with_effect = {
				CHARACTER = root
				PREGNANCY_CHANCE = pregnancy_chance
			}
			
			progress_towards_lover_effect = {
				CHARACTER = root
				REASON = lover_written_language_poetry
				OPINION = 0
			}
		}

		stress_impact = {
			chaste = massive_stress_impact_gain
			diligent = medium_stress_impact_gain
			shy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				OR = {
					has_trait = chaste
					has_trait = diligent
					has_trait = shy
				}
			}
		}
	}

	option = { # Deny help
		name = learn_language_ongoing.1130.c
					
		scope:lover_to_help = {
			add_opinion = {
				target = root
				modifier = flattered_opinion
				opinion = 10
			}
		}
		
		stress_impact = {
			lustful = massive_stress_impact_gain
			trusting = massive_stress_impact_gain
			diligent = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				OR = {
					has_trait = lustful
					has_trait = trusting
					has_trait = diligent
					has_trait = impatient
				}
			}
		}
	}
}

scripted_trigger appropriate_close_one_to_help_trigger = {
	is_available_ai_adult = yes
	opinion = {
		target = root
		value >= 40
	}
	culture = {
		has_same_culture_language = scope:target.culture
	}
}

# Friend/family member/non-attracted spouse helps you out
learn_language_ongoing.1140 = {
	type = character_event
	title = learn_language_ongoing.1140.t
	desc = learn_language_ongoing.1140.desc
	theme = education
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:close_one_to_help
		animation = personality_rational
	}
	override_background = { reference = study }
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1140 }
		}
		is_adult = yes
		OR = {
			any_relation = {
				type = friend
				appropriate_close_one_to_help_trigger = yes
			}
			any_close_family_member = {
				appropriate_close_one_to_help_trigger = yes
			}
			any_consort = {
				NOT = {
					is_attracted_to_gender_of = root
				}
				appropriate_close_one_to_help_trigger = yes
			}
		}
	}

	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		save_scope_as = root_for_loc
		scope:scheme = {
			set_variable = {
				name = had_event_learn_language_ongoing_1140
				value = yes
				days = 3650
			}
		}
		every_relation = {
			type = friend
			limit = {
				appropriate_close_one_to_help_trigger = yes
			}
			add_to_list = potential_close_ones_to_help
		}
		every_close_family_member = {
			limit = {
				appropriate_close_one_to_help_trigger = yes
			}
			add_to_list = potential_close_ones_to_help
		}
		every_consort = {
			limit = {
				NOT = {
					is_attracted_to_gender_of = root
				}
				appropriate_close_one_to_help_trigger = yes
			}
			add_to_list = potential_close_ones_to_help
		}
		random_in_list = {
			list = potential_close_ones_to_help
			weight = {
				base = 1
				modifier = {
					add = 10
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 5
					is_of_minor_interest_to_root_trigger = yes
				}
				modifier = {
					add = learning
					learning > 0
				}
			}
			save_scope_as = close_one_to_help
			assign_quirk_effect = yes
		}
	}

	option = { # Instant progress
		name = learn_language_ongoing.1140.a
		
		scope:scheme = {
			add_scheme_progress = {
				value = scheme_progress_gain
				multiply = 2
			}
		}
		
		ai_chance = {
			base = 100
		}
	}

	option = { # Success Chance
		name = learn_language_ongoing.1140.b
		
		scope:scheme = {
			add_scheme_modifier = {
				type = helpful_assistance_modifier
			}
		}
		ai_chance = {
			base = 100
		}
	}
}

# Your dog ate your homework!
learn_language_ongoing.1200 = {
	type = character_event
	title = learn_language_ongoing.1200.t
	desc = learn_language_ongoing.1200.desc
	theme = education
	left_portrait = {
		character = root
		animation = disbelief
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}
	
	trigger = {
		is_travelling = no
		scope:scheme ?= {
			NOT = { has_variable = had_event_learn_language_ongoing_1200 }
		}
		any_owned_story = {
			type = story_cycle_pet_dog
		}
		is_available = yes
	}
	
	immediate = {
		
		## REMOVE BELOW
		#random_scheme = {
		#	limit = {
		#		scheme_type = learn_language
		#	}
		#	save_scope_as = scheme
		#	scheme_target_character = {
		#		save_scope_as = target
		#	}
		#}
		## REMOVE ABOVE
		random_owned_story = {
			type = story_cycle_pet_dog
			save_scope_as = pet_dog
		}
		set_variable = {
			name = had_event_learn_language_ongoing_1200
			value = yes
			days = 3650
		}
	}
	
	option = { # I couldn't possibly stay mad at you.
		name = learn_language_ongoing.1200.a
		trigger = {
			has_trait = compassionate
		}
		trait = compassionate
		
		scope:scheme = {
			add_scheme_progress = {
				value = scheme_progress_loss
				multiply = 2
			}
		}
		
		stress_impact = {
			base = medium_stress_impact_loss
			compassionate = medium_stress_impact_loss
			wrathful = major_stress_impact_gain
			vengeful = major_stress_impact_gain
		}
		ai_chance = {
			base = 15
			modifier = {
				factor = 4
				has_trait = compassionate
			}
		}
	}
	
	option = { # Let's go outside instead.
		name = learn_language_ongoing.1200.b
		
		scope:scheme = {
			add_scheme_progress = {
				value = scheme_progress_loss
				multiply = 2
			}
		}
		
		ai_chance = {
			base = 10
		}
	}
	
	option = { # Bad dog!
		name = learn_language_ongoing.1200.c
		
		add_prestige = medium_prestige_loss
		
		stress_impact = {
			base = medium_stress_impact_gain
			forgiving = major_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
		}
	}
}

learn_language_ongoing.1300 = {
	type = character_event
	title = learn_language_ongoing.1300.t
	desc = learn_language_ongoing.1300.desc
	theme = education
	override_background = {
		reference = terrain_travel
	}
	left_portrait = {
		character = root
		animation = personality_content
	}
	right_portrait = {
		character = scope:interlocutor
		animation = happiness
	}

	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	cooldown = { years = 1 }
	
	trigger = {
		is_travelling = yes 
		any_pool_character = {
			province = root.location 
			NOR = {
				this = scope:target
				has_relation_rival = root
			}
			is_available_ai_adult = yes
			culture = {
				has_same_culture_language = scope:target.culture
			}
		}
		exists = current_travel_plan.next_destination_province
	}
	
	immediate = {
		random_pool_character = {
			province = root.location
			limit = {
				NOR = {
					this = scope:target
					has_relation_rival = root
				}
				is_available_ai_adult = yes
				culture = {
					has_same_culture_language = scope:target.culture
				}
			}
			save_scope_as = interlocutor
		}
		current_travel_plan = {
			next_destination_province = { save_scope_as = next_destination }
		}
	}

	option = { # Have a lovely conversation
		name = learn_language_ongoing.1300.a
		flavor = learn_language_ongoing.1300.a.flavor
		scope:scheme = {
			add_scheme_progress = {
				value = scheme_progress_gain
				multiply = 2
			}
		}
		stress_impact = {
			gregarious = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 50
		}
	}
	
	option = { # Try to engage in a debate
		name = learn_language_ongoing.1300.b
		flavor = learn_language_ongoing.1300.b.flavor
		duel = {
			skill = learning
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -35
				}
				desc = learn_language_ongoing.1300.b.success
				send_interface_toast = {
					title = learn_language_ongoing.1300.b.success
					left_icon = root
					right_icon = scope:interlocutor
					scope:scheme = {
						add_scheme_progress = {
							value = scheme_progress_gain
							multiply = 4
						}
					}
					scope:interlocutor.culture = {
						change_cultural_acceptance = {
							target = root.culture 
							value = minor_cultural_acceptance_gain
							desc = learn_lang_cult_acceptance_gain_debate
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -35
				}
				desc = learn_language_ongoing.1300.b.failure
				send_interface_toast = {
					title = learn_language_ongoing.1300.b.failure
					left_icon = root
					right_icon = scope:interlocutor
					scope:scheme = {
						add_scheme_progress = {
							value = scheme_progress_loss
							multiply = 2
						}
					}
				}
			}
		}
		
		stress_impact = {
			shy = miniscule_stress_impact_gain
			ambitious = minor_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 20
		}
	}

	option = { # Join my entourage
		name = learn_language_ongoing.1300.c
		current_travel_plan = { add_companion = scope:interlocutor }
		if = {
			limit = {
				NOT = {
					scope:interlocutor = {
						is_courtier_of = root
					}
				}
			}
			add_courtier = scope:interlocutor
		}
		scope:scheme = {
			add_scheme_modifier = {
				type = interlocutor_entourage_member
			}
		}
		stress_impact = {
			gregarious = miniscule_stress_impact_loss
			trusting = miniscule_stress_impact_loss
			paranoid = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 30
			modifier = {
				has_trait = trusting
				add = 30
			}
		}
	}
}
