﻿namespace = language_events

# Forget a language when above the soft-cap
language_events.0001 = {
	type = character_event
	title = language_events.0001.t
	desc = language_events.0001.desc
	theme = learning
	left_portrait = {
		character = root
		animation = boredom
	}
	
	trigger = {
		num_of_known_languages > language_soft_cap
		any_culture_global = {
			save_temporary_scope_as = culture_check
			root = {
				knows_language_of_culture = scope:culture_check
				culture = {
					NOT = {
						has_same_culture_language = scope:culture_check
					}
				}
			}
		}
	}
	
	cooldown = {
		years = 3
	}

	weight_multiplier = {
		base = 1
		modifier = {
			num_of_known_languages > language_soft_cap
			add = language_soft_cap_modifier_value
		}
	}

	immediate = {
		random_culture_global = {
			limit = {
				save_temporary_scope_as = culture_check
				root = {
					knows_language_of_culture = scope:culture_check
					culture = {
						NOT = {
							has_same_culture_language = scope:culture_check
						}
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 9
					root.culture = {
						NOT = {
							has_same_culture_heritage = prev
						}
					}
				}
			}
			save_scope_as = language_to_forget
		}
	}

	option = {
		name = language_events.0001.a
			
		unlearn_language_of_culture = scope:language_to_forget
		
		stress_impact = {
			lazy = major_stress_impact_loss
			diligent = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = language_events.0001.b
		
		stress_impact = {
			base = massive_stress_impact_gain
			lazy = massive_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}
}

scripted_trigger vassal_speaking_other_language_trigger = {
	is_available_ai_adult = yes
	primary_title.tier >= tier_county	
	opinion = {
		target = root
		value >= low_positive_opinion
	}
	NOR = {
		has_trait = arbitrary
		has_trait = arrogant
		has_trait = callous
		has_trait = sadistic
		has_relation_rival = root
		culture = {
			has_same_culture_language = root.culture
		}
	}
	root = {
		knows_language_of_culture = prev.culture
	}
	any_sub_realm_county = {
		count >= 3 # Must have a tangible representation of the culture in their realm
		culture = prev.culture
	}
}

# Vassal who speak the language lauds your efforts
language_events.0002 = {
	type = character_event
	title = language_events.0002.t
	desc = language_events.0002.desc
	theme = learning
	
	override_background = { reference = market }
	
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:vassal_speaking_other_language
		animation = throne_room_applaud_1
	}
	
	trigger = {
		is_landed = yes
		is_available_at_peace_adult = yes
		OR = {
			primary_title.tier >= tier_kingdom
			top_liege = this
		}
		any_vassal = { vassal_speaking_other_language_trigger = yes }
	}
	
	cooldown = {
		years = 20
	}

	immediate = {
		random_vassal = {
			limit = { vassal_speaking_other_language_trigger = yes }
			weight = {
				base = 1
				modifier = {
					add = 100
					has_relation_potential_friend = 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 = vassal_speaking_other_language
		}
	}

	option = {
		name = language_events.0002.a
		
		scope:vassal_speaking_other_language = {
			progress_towards_friend_effect = {
				REASON = friend_recognized_by_liege
				CHARACTER = root
				OPINION = 0
			}
			culture = {
				change_cultural_acceptance = {
					target = root.culture
					value = 5
					desc = cultural_acceptance_gain_event
				}
			}
		}
		
		stress_impact = {
			greedy = major_stress_impact_loss
			callous = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = language_events.0002.b
		
		flavor = language_events.0002.b.tt
		
		add_treasury_or_gold = gold_per_culture_county_in_subrealm
		
		scope:vassal_speaking_other_language = {
			progress_towards_rival_effect = {
				CHARACTER = root
				REASON = rival_language_bullied
				OPINION = -20
			}
			culture = {
				change_cultural_acceptance = {
					target = root.culture
					value = -5
					desc = cultural_acceptance_gain_event
				}
			}
		}
		
		stress_impact = {
			generous = massive_stress_impact_gain
			just = major_stress_impact_gain
			content = major_stress_impact_gain
			honest = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}

		ai_chance = {
			base = 0
			modifier = {
				has_trait = greedy
				add = 100
			}
			modifier = {
				gold < 0
				add = 100
			}
		}
	}
}

# Forget a language when above the soft-cap; Owl nightmare
language_events.0010 = {
	type = character_event
	title = language_events.0010.t
	desc = language_events.0010.desc
	theme = learning
	left_portrait = {
		character = root
		animation = shock
	}

	cooldown = {
		years = 3
	}
	
	trigger = {
		num_of_known_languages > language_soft_cap
		any_culture_global = {
			save_temporary_scope_as = culture_check
			root = {
				knows_language_of_culture = scope:culture_check
				culture = {
					NOT = {
						has_same_culture_language = scope:culture_check
					}
				}
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			num_of_known_languages > language_soft_cap
			add = language_soft_cap_modifier_value
		}
	}

	immediate = {
		random_culture_global = {
			limit = {
				save_temporary_scope_as = culture_check
				root = {
					knows_language_of_culture = scope:culture_check
					culture = {
						NOT = {
							has_same_culture_language = scope:culture_check
						}
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 9
					root.culture = {
						NOT = {
							has_same_culture_heritage = prev
						}
					}
				}
			}
			save_scope_as = language_to_forget
		}
	}

	# Forget
	option = {
		name = language_events.0010.a
			
		unlearn_language_of_culture = scope:language_to_forget
		
		stress_impact = {
			lazy = major_stress_impact_loss
			diligent = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
		}
	}

	# Stress
	option = {
		name = language_events.0010.b
		
		stress_impact = {
			base = massive_stress_impact_gain
			lazy = massive_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}
