﻿############################################
# Feruchemy Event Chain
# The art of storing attributes in metalminds
# Native to the Terris people
############################################

namespace = mistborn_feruchemy

# ============================================================
# DISCOVERING THE ART
# Fires on yearly pulse for Terris characters with dormant potential
# Feruchemy activates through practice, not trauma
# ============================================================
mistborn_feruchemy.0001 = {
	type = character_event
	title = mistborn_feruchemy.0001.t
	desc = mistborn_feruchemy.0001.desc
	theme = learning

	left_portrait = {
		character = root
		animation = personality_rational
	}

	trigger = {
		has_trait = trait_feruchemy_potential
		NOT = { has_trait = trait_feruchemist }
		age >= 14
		# Feruchemy is native to the Terris people
		OR = {
			culture = culture:terris
			any_parent = { culture = culture:terris }
		}
	}

	weight_multiplier = {
		base = 1

		# High learning makes discovery more likely
		modifier = {
			add = 0.5
			learning >= 10
		}
		modifier = {
			add = 1.0
			learning >= 16
		}

		# Being around another Feruchemist helps
		modifier = {
			add = 1.5
			any_courtier = {
				has_trait = trait_feruchemist
			}
		}

		# Terris Worldbringers preserve Feruchemical knowledge
		modifier = {
			add = 1.0
			faith = faith:terris_worldbringers
		}

		# Low base chance — the Lord Ruler's breeding programs suppress this
		modifier = {
			factor = 0.1
		}
	}

	immediate = {
		# Save any Feruchemist mentor in court
		random_courtier = {
			limit = {
				has_trait = trait_feruchemist
			}
			save_scope_as = feruchemy_mentor
		}
	}

	# Option A: Explore this strange ability
	option = {
		name = mistborn_feruchemy.0001.a
		trigger_event = {
			id = mistborn_feruchemy.0010
			days = { 30 90 }
		}
		stress_impact = {
			lazy = 10
		}
		ai_chance = {
			base = 80
			modifier = {
				add = 20
				has_trait = diligent
			}
		}
	}

	# Option B: Suppress it — too dangerous under the Lord Ruler
	option = {
		name = mistborn_feruchemy.0001.b
		add_stress = 20
		stress_impact = {
			ambitious = 20
		}
		ai_chance = {
			base = 20
			modifier = {
				add = 30
				has_trait = craven
			}
		}
	}
}

# ============================================================
# THE FIRST METALMIND
# Character creates their first metalmind and activates Feruchemy
# ============================================================
mistborn_feruchemy.0010 = {
	type = character_event
	title = mistborn_feruchemy.0010.t
	desc = mistborn_feruchemy.0010.desc
	theme = learning

	left_portrait = {
		character = root
		animation = happiness
	}

	trigger = {
		has_trait = trait_feruchemy_potential
		NOT = { has_trait = trait_feruchemist }
	}

	immediate = {
		# Nothing additional needed
	}

	# Option A: Store strength — a pewter metalmind
	option = {
		name = mistborn_feruchemy.0010.a
		remove_trait = trait_feruchemy_potential
		add_trait = trait_feruchemist
		add_character_modifier = {
			modifier = first_metalmind_strength
			years = 1
		}

		# Check for Keeper status
		if = {
			limit = {
				culture = culture:terris
				faith = faith:terris_worldbringers
			}
			add_character_modifier = keeper_of_terris
		}
		ai_chance = {
			base = 40
		}
	}

	# Option B: Store memories — a copper metalmind (the Keeper's choice)
	option = {
		name = mistborn_feruchemy.0010.b
		remove_trait = trait_feruchemy_potential
		add_trait = trait_feruchemist
		add_character_modifier = {
			modifier = first_metalmind_memories
			years = 1
		}

		# Check for Keeper status
		if = {
			limit = {
				culture = culture:terris
				faith = faith:terris_worldbringers
			}
			add_character_modifier = keeper_of_terris
		}
		ai_chance = {
			base = 40
			modifier = {
				add = 30
				faith = faith:terris_worldbringers
			}
		}
	}

	# Option C: Store health — a gold metalmind
	option = {
		name = mistborn_feruchemy.0010.opt_c
		remove_trait = trait_feruchemy_potential
		add_trait = trait_feruchemist
		add_character_modifier = {
			modifier = first_metalmind_health
			years = 1
		}

		# Check for Keeper status
		if = {
			limit = {
				culture = culture:terris
				faith = faith:terris_worldbringers
			}
			add_character_modifier = keeper_of_terris
		}
		ai_chance = {
			base = 20
		}
	}
}
