﻿######################################
# Standard actions for random events #
######################################

learning_lifestyle_progress_pulse = { # Fires 4 times per year
	trigger = {
		OR = {
			is_adult = yes
			is_ai = no
			has_lifestyle = learning_lifestyle
		}
		is_landed = yes # Lifestyle events inherently assume you have one. Non-landed rulers shouldn't get lifestyle events, even if they still have a lifestyle.
		exists = capital_province # Because in rare situations landed AI rulers can end up without a capital.
		trigger_if = {
			limit = {
				is_ai = no
			}
			has_had_focus_for_days > 30
		}
		NOR = {
			has_character_flag = had_recent_lifestyle_ongoing_event
			# Must not currently be in a learning event chain.
			has_character_flag = is_in_learning_special_event
		}
	}

	first_valid_on_action = {
		learning_lifestyle_ongoing_events # General event pool
		learning_lifestyle_unavailable_events # Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
	}
}

#Ongoing events and story cycles
learning_lifestyle_ongoing_events = {
	trigger = {
		is_available = yes
	}

	random_on_action = {
		chance_to_happen = 10 # Roughly one event every 18 months

		80 = learning_lifestyle_common_events
		15 = learning_lifestyle_uncommon_events
		5 = learning_lifestyle_rare_events		
	}
}

# Characters get a Common event roughly once every 24 months (2 years). Most lifestyle events should be Common events.
learning_lifestyle_common_events = {
	random_events = {
		# Scholarship Events
		100 = learning_scholarship.1101 #Learn to read
		100 = learning_scholarship.1401 #Acquire a reading stone
		100 = learning_scholarship.3001 #Brass orb experiments

		# Medicine Events
		100 = learning_medicine.2010 #Improve the skills of your court physician
		100 = learning_medicine.2020 #Fertility treatment
		100 = learning_medicine.2030 #Healthy coping mechanism: becoming a confider
		100 = learning_medicine.2040 #Healthy coping mechanism: journaller or athletic
		100 = learning_medicine.2050 #Helping healing hand (medicine friend)
		100 = learning_medicine_special.2110 #A vassal (or your liege) wants to eat some hashish while visiting your capital

		# Theology Events
		100 = learning_theology.1301 #Realm priest asks for books
		100 = learning_theology.2020 #Flatter your court chaplain with some bible verses
		100 = learning_theology.3002 #Research on the age of the world
		100 = learning_theology.3003 #Look at the stars
		100 = learning_theology.3011 #Worship in the same church (theology friend)
		100 = learning_theology.3021 #Send fan mail to religious head
		100 = learning_theology.3031 # Deal with province of different faith
	}
}

# Characters get an Uncommon event roughly once every 120 months (10 years). Longer event chains and lucrative opporunities should be Uncommon events.
learning_lifestyle_uncommon_events = {
	random_events = {
		100 = learning_medicine.2001 #Become a herbalist (a pool character, friend or courtier must have the herbalist trait)
		100 = learning_scholarship_special.2001 #Translate a book (player only)
		100 = learning_medicine_special.1001 #Study human cadavers
		100 = learning_medicine_special.2100 #Eat a hallucinogenic fish
		100 = learning_theology.3041 # Start learning about mysticism
		50 = learning_theology_special.1001 # Find old text
	}
	fallback = learning_lifestyle_common_events
}

# Characters get a Rare event roughly once every 360 months (30 years). Character-defining events and easter egg events should be Rare events.
learning_lifestyle_rare_events = {
	random_events = {
		100 = learning_theology_special.1101 #Learned scholar come to your court
		100 = learning_scholarship_special.3001 #Transmute lead to gold?
		100 = learning_scholarship.1201 #Automaton songbird
		50 = lifestyle_nicknames.0009 # Learning nickname for someone who's arrogant
		50 = lifestyle_nicknames.0010 # Learning nickname when the character is humble
	}
	fallback = learning_lifestyle_uncommon_events
}

# Special event pool for unavailable characters (imprisoned, commanding an army, infirm, etc.)
learning_lifestyle_unavailable_events = {
	trigger = {
		is_available = no
	}

	random_events = {
 		# WARNING: All events in this pool *MUST* have custom is_available triggers defined.
 		# Otherwise we can wind up with weird things like imprisoned characters having a strategy discussion with their army commanders out on the campaign trail.
 		chance_to_happen = 10

	}
}

####################
# Event On-Actions
####################

book_translation_story_events = {
	trigger = {
		any_owned_story = {
			story_type = book_translation_story
		}
	}
	random_events = {
		100 = learning_scholarship_special.2011
		100 = learning_scholarship_special.2012
		100 = learning_scholarship_special.2013
		100 = learning_scholarship_special.2014
		100 = learning_scholarship_special.2015
		30 = learning_scholarship_special.2016
		100 = learning_scholarship_special.2017
	}
}


# Mystic Communion side-effects
mystic_communion_side_effect_events = {
	random_events = {
		100 = mystic_lifestyle.1001 # Your Court Chaplain disapproves
		100 = mystic_lifestyle.1002 # The Religious Head disapproves (Kings and Emperors only)
		100 = mystic_lifestyle.1003 # A Zealous vassal disapproves
		100 = mystic_lifestyle.1004 # Reputaiton - negative
		100 = mystic_lifestyle.1005 # A zealous vassal approves
		100 = mystic_lifestyle.1006 # Reputation - positive
		100 = mystic_lifestyle.1007 # Become ill
		100 = mystic_lifestyle.1008 # Recover from illness
		100 = mystic_lifestyle.1009 # A fellow Mystic likes what you do
		1 = mystic_lifestyle.0001 # Regular outcome (fallback)
	}
}