﻿############################################
# Mistborn: The Final Empire - Education Events
# Custom education events for 5 training tracks
############################################

namespace = mistborn_education

# ============================================================
# ALLOMANTIC TRAINING EVENTS
# ============================================================

# Push to the Limit — Guardian pushes ward to breaking point
mistborn_education.0001 = {
	type = character_event
	title = mistborn_education.0001.t
	desc = mistborn_education.0001.desc
	theme = education

	left_portrait = {
		character = root
		animation = personality_bold
	}

	right_portrait = {
		character = scope:guardian
		animation = personality_callous
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_allomantic
		age >= 10
		age <= 16
		NOT = { has_character_flag = had_allomantic_push_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:guardian = {
				OR = {
					is_allomancer_trigger = yes
					has_trait = education_allomantic_3
					has_trait = education_allomantic_4
				}
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_allomantic_push_event
			years = 3
		}
	}

	# Intensify training — risk injury, +chance of higher tier
	option = {
		name = mistborn_education.0001.a
		random_list = {
			60 = {
				# Success — ward grows stronger
				add_prowess_skill = 1
			}
			25 = {
				# Moderate — tough but no lasting benefit
				add_stress = 10
			}
			15 = {
				# Injury — training was too intense
				add_trait = wounded_1
				add_stress = 15
			}
		}
		ai_chance = {
			base = 40
		}
	}

	# Ease off — safer, less reward
	option = {
		name = mistborn_education.0001.b
		add_stress = -5
		ai_chance = {
			base = 30
		}
	}

	# Focus on fundamentals — balanced
	option = {
		name = mistborn_education.0001.c
		add_martial_skill = 1
		ai_chance = {
			base = 30
		}
	}
}

# Snapping During Training — triggers snapping event chain
mistborn_education.0002 = {
	type = character_event
	title = mistborn_education.0002.t
	desc = mistborn_education.0002.desc
	theme = education

	left_portrait = {
		character = root
		animation = pain
	}

	right_portrait = {
		character = scope:guardian
		animation = shock
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_allomantic
		age >= 14
		age <= 16
		OR = {
			has_trait = trait_allomantic_potential
			has_trait = trait_mistborn_potential
		}
		NOT = { is_allomancer_trigger = yes }
		NOT = { has_character_flag = education_snapping_attempted }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:guardian = {
				is_allomancer_trigger = yes
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = education_snapping_attempted
			years = 2
		}
	}

	# The training pushes too far — snapping may occur
	option = {
		name = mistborn_education.0002.a
		# 25% chance of triggering the snapping event chain
		random_list = {
			25 = {
				# Snapping occurs — triggers the main snapping event
				trigger_event = {
					id = mistborn_snapping.0020
					days = 1
				}
			}
			75 = {
				# No snapping — but the potential remains
				custom_tooltip = mistborn_education.0002.a.fail
				add_stress = 10
			}
		}
		ai_chance = {
			base = 100
		}
	}
}

# Metal Instinct — ward shows exceptional metal instinct
mistborn_education.0003 = {
	type = character_event
	title = mistborn_education.0003.t
	desc = mistborn_education.0003.desc
	theme = education

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:guardian
		animation = personality_content
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_allomantic
		age >= 12
		age <= 16
		NOT = { has_character_flag = had_metal_instinct_event }
		scope:guardian = {
			OR = {
				is_allomancer_trigger = yes
				has_trait = trait_mistborn
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			scope:guardian = {
				has_trait = trait_mistborn
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_metal_instinct_event
			years = 5
		}
	}

	# Nurture the instinct
	option = {
		name = mistborn_education.0003.a
		add_martial_skill = 1
		add_prowess_skill = 1
		scope:guardian = {
			add_opinion = {
				target = root
				modifier = proud_of_ward_opinion
				opinion = 10
			}
		}
		ai_chance = {
			base = 100
		}
	}
}

# ============================================================
# NOBLE COURT EDUCATION EVENTS
# ============================================================

# First Ball — ward attends their first noble ball
mistborn_education.0010 = {
	type = character_event
	title = mistborn_education.0010.t
	desc = mistborn_education.0010.desc
	theme = diplomacy

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	right_portrait = {
		character = scope:guardian
		animation = personality_content
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_noble_court
		age >= 12
		age <= 16
		NOT = { has_character_flag = had_first_ball_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			culture = culture:noble_scadrian
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_first_ball_event
			years = 5
		}
	}

	# Success — diplomacy check
	option = {
		name = mistborn_education.0010.a
		trigger = {
			diplomacy >= 5
		}
		add_diplomacy_skill = 1
		scope:guardian = {
			add_opinion = {
				target = root
				modifier = proud_of_ward_opinion
				opinion = 10
			}
		}
		ai_chance = {
			base = 60
		}
	}

	# Failure — embarrassing incident
	option = {
		name = mistborn_education.0010.b
		trigger = {
			diplomacy < 5
		}
		add_stress = 10
		ai_chance = {
			base = 40
		}
	}

	# Try your best regardless
	option = {
		name = mistborn_education.0010.c
		random_list = {
			50 = {
				add_diplomacy_skill = 1
			}
			50 = {
				add_stress = 5
			}
		}
		ai_chance = {
			base = 50
		}
	}
}

# Observe a Scheme — ward witnesses intrigue in action
mistborn_education.0011 = {
	type = character_event
	title = mistborn_education.0011.t
	desc = mistborn_education.0011.desc
	theme = intrigue

	left_portrait = {
		character = root
		animation = scheme
	}

	right_portrait = {
		character = scope:guardian
		animation = personality_cynical
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_noble_court
		age >= 13
		age <= 16
		NOT = { has_character_flag = had_observe_scheme_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:guardian = {
				intrigue >= 10
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_observe_scheme_event
			years = 4
		}
	}

	# Success — intrigue check, learns the Great Game
	option = {
		name = mistborn_education.0011.a
		trigger = {
			intrigue >= 4
		}
		add_intrigue_skill = 1
		ai_chance = {
			base = 60
		}
	}

	# Failure — caught watching, guardian intervenes
	option = {
		name = mistborn_education.0011.b
		trigger = {
			intrigue < 4
		}
		add_stress = 5
		scope:guardian = {
			add_stress = 5
		}
		ai_chance = {
			base = 40
		}
	}
}

# ============================================================
# MINISTRY INDOCTRINATION EVENTS
# ============================================================

# Canton Examination — formal assessment of doctrine knowledge
mistborn_education.0020 = {
	type = character_event
	title = mistborn_education.0020.t
	desc = mistborn_education.0020.desc
	theme = learning

	left_portrait = {
		character = root
		animation = personality_rational
	}

	trigger = {
		is_being_educated = yes
		education_focus = education_ministry
		age >= 12
		age <= 16
		NOT = { has_character_flag = had_canton_exam_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			faith = faith:steel_ministry
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_canton_exam_event
			years = 3
		}
	}

	# Success — learning check
	option = {
		name = mistborn_education.0020.a
		trigger = {
			learning >= 5
		}
		add_piety = 50
		add_learning_skill = 1
		ai_chance = {
			base = 60
		}
	}

	# Failure — extra study imposed
	option = {
		name = mistborn_education.0020.b
		trigger = {
			learning < 5
		}
		add_stress = 5
		ai_chance = {
			base = 40
		}
	}
}

# Question Doctrine — ward questions the Ministry's teachings
mistborn_education.0021 = {
	type = character_event
	title = mistborn_education.0021.t
	desc = mistborn_education.0021.desc
	theme = learning

	left_portrait = {
		character = root
		animation = personality_cynical
	}

	right_portrait = {
		character = scope:guardian
		animation = worry
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_ministry
		age >= 13
		age <= 16
		NOT = { has_character_flag = had_question_doctrine_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			has_trait = cynical
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_question_doctrine_event
			years = 4
		}
	}

	# Encourage questioning — risk heresy, +1 learning
	option = {
		name = mistborn_education.0021.a
		add_learning_skill = 1
		add_character_flag = {
			flag = questioned_ministry_doctrine
			years = 10
		}
		ai_chance = {
			base = 20
		}
	}

	# Punish doubt — +1 piety, stress
	option = {
		name = mistborn_education.0021.b
		add_piety = 50
		add_stress = 10
		ai_chance = {
			base = 40
		}
	}

	# Explain patiently — balanced
	option = {
		name = mistborn_education.0021.c
		add_piety = 25
		scope:guardian = {
			add_opinion = {
				target = root
				modifier = proud_of_ward_opinion
				opinion = 5
			}
		}
		ai_chance = {
			base = 40
		}
	}
}

# ============================================================
# SKAA SURVIVAL EVENTS
# ============================================================

# Inquisitor Patrol — close call with Steel Inquisitors
mistborn_education.0030 = {
	type = character_event
	title = mistborn_education.0030.t
	desc = mistborn_education.0030.desc
	theme = intrigue

	left_portrait = {
		character = root
		animation = fear
	}

	trigger = {
		is_being_educated = yes
		education_focus = education_skaa
		age >= 10
		age <= 16
		NOT = { has_character_flag = had_inquisitor_patrol_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.3
			culture = culture:skaa
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_inquisitor_patrol_event
			years = 3
		}
	}

	# Success — intrigue check, learn evasion
	option = {
		name = mistborn_education.0030.a
		trigger = {
			intrigue >= 4
		}
		add_intrigue_skill = 1
		ai_chance = {
			base = 60
		}
	}

	# Failure — beaten, but learn toughness
	option = {
		name = mistborn_education.0030.b
		trigger = {
			intrigue < 4
		}
		add_stress = 15
		add_prowess_skill = 1
		ai_chance = {
			base = 40
		}
	}
}

# Discover the Underground — ward finds the skaa resistance
mistborn_education.0031 = {
	type = character_event
	title = mistborn_education.0031.t
	desc = mistborn_education.0031.desc
	theme = intrigue

	left_portrait = {
		character = root
		animation = scheme
	}

	trigger = {
		is_being_educated = yes
		education_focus = education_skaa
		age >= 13
		age <= 16
		NOT = { has_character_flag = had_discover_underground_event }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			intrigue >= 6
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_discover_underground_event
			years = 5
		}
	}

	# Join the underground
	option = {
		name = mistborn_education.0031.a
		add_intrigue_skill = 1
		add_character_flag = {
			flag = skaa_underground_contact
			years = 20
		}
		ai_chance = {
			base = 40
		}
	}

	# Stay independent
	option = {
		name = mistborn_education.0031.b
		add_prowess_skill = 1
		ai_chance = {
			base = 40
		}
	}

	# Report to nobles — betrayal for noble favor
	option = {
		name = mistborn_education.0031.c
		add_prestige = 50
		add_stress = 20
		stress_impact = {
			compassionate = 30
			honest = -10
		}
		ai_chance = {
			base = 20
		}
	}
}

# ============================================================
# KEEPER APPRENTICESHIP EVENTS
# ============================================================

# Coppermind Lesson — first memory storage training
mistborn_education.0040 = {
	type = character_event
	title = mistborn_education.0040.t
	desc = mistborn_education.0040.desc
	theme = learning

	left_portrait = {
		character = root
		animation = personality_rational
	}

	right_portrait = {
		character = scope:guardian
		animation = personality_content
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_keeper
		age >= 10
		age <= 16
		NOT = { has_character_flag = had_coppermind_lesson_event }
		scope:guardian = {
			is_keeper_or_initiate_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			has_any_feruchemy_trigger = yes
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_coppermind_lesson_event
			years = 4
		}
	}

	# Success — learning check, store first memory
	option = {
		name = mistborn_education.0040.a
		trigger = {
			learning >= 5
		}
		add_learning_skill = 1
		ai_chance = {
			base = 60
		}
	}

	# Failure — headaches, retry next year
	option = {
		name = mistborn_education.0040.b
		trigger = {
			learning < 5
		}
		add_stress = 5
		ai_chance = {
			base = 40
		}
	}
}

# Ministry Investigation — Steel Ministry snooping near training site
mistborn_education.0041 = {
	type = character_event
	title = mistborn_education.0041.t
	desc = mistborn_education.0041.desc
	theme = intrigue

	left_portrait = {
		character = root
		animation = fear
	}

	right_portrait = {
		character = scope:guardian
		animation = worry
	}

	trigger = {
		is_being_educated = yes
		exists = scope:guardian
		education_focus = education_keeper
		age >= 11
		age <= 16
		NOT = { has_character_flag = had_ministry_investigation_event }
		scope:guardian = {
			is_keeper_or_initiate_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.3
			scope:guardian = {
				has_character_flag = keeper_identity
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_ministry_investigation_event
			years = 5
		}
	}

	# Hide and wait — lose training time, safe
	option = {
		name = mistborn_education.0041.a
		add_stress = 5
		ai_chance = {
			base = 40
		}
	}

	# Relocate — gold cost, safe
	option = {
		name = mistborn_education.0041.b
		remove_short_term_gold = 50
		ai_chance = {
			base = 30
		}
	}

	# Continue in secret — intrigue check, discovery risk
	option = {
		name = mistborn_education.0041.c
		random_list = {
			60 = {
				# Succeed — training continues
				modifier = {
					add = 20
					intrigue >= 8
				}
				add_intrigue_skill = 1
			}
			40 = {
				# Discovered — Ministry punishment
				modifier = {
					add = -20
					intrigue >= 8
				}
				add_stress = 30
				scope:guardian = {
					add_stress = 30
					# Ministry punishment — imprisonment risk
					add_character_flag = {
						flag = ministry_suspected_keeper
						years = 5
					}
				}
				add_character_flag = {
					flag = ministry_suspected_keeper
					years = 5
				}
			}
		}
		ai_chance = {
			base = 30
		}
	}
}
