﻿# Mistborn: The Final Empire - Scripted Triggers
# Reusable triggers for checking Allomantic, Feruchemical, and cultural status

# ===== ALLOMANCY TRIGGERS =====

is_allomancer_trigger = {
	OR = {
		has_trait = trait_misting_lurcher       # Iron
		has_trait = trait_misting_coinshot      # Steel
		has_trait = trait_misting_tineye        # Tin
		has_trait = trait_misting_thug          # Pewter
		has_trait = trait_misting_rioter        # Zinc
		has_trait = trait_misting_soother       # Brass
		has_trait = trait_misting_smoker        # Copper
		has_trait = trait_misting_seeker        # Bronze
		has_trait = trait_misting_augur         # Gold
		has_trait = trait_misting_oracle        # Atium
		has_trait = trait_misting_duralumin     # Duralumin
		has_trait = trait_misting_nicroburst    # Nicrosil
		has_trait = trait_mistborn
	}
}

is_mistborn_trigger = {
	has_trait = trait_mistborn
}

has_allomantic_potential_trigger = {
	# Character has dormant Allomantic potential (has NOT snapped yet)
	OR = {
		has_trait = trait_allomantic_potential
		has_trait = trait_mistborn_potential
	}
	NOT = { is_allomancer_trigger = yes }
}

has_any_allomantic_ability_trigger = {
	# Character has any Allomantic ability — dormant potential OR active powers
	OR = {
		has_trait = trait_allomantic_potential
		has_trait = trait_mistborn_potential
		is_allomancer_trigger = yes
	}
}

# Checks for specific Allomantic metal categories
is_physical_allomancer_trigger = {
	OR = {
		has_trait = trait_misting_lurcher       # Iron - pulls metals
		has_trait = trait_misting_coinshot      # Steel - pushes metals
		has_trait = trait_misting_tineye        # Tin - enhanced senses
		has_trait = trait_misting_thug          # Pewter - enhanced body
		has_trait = trait_mistborn
	}
}

is_mental_allomancer_trigger = {
	OR = {
		has_trait = trait_misting_rioter        # Zinc - inflames emotions
		has_trait = trait_misting_soother       # Brass - dampens emotions
		has_trait = trait_misting_smoker        # Copper - hides Allomancy
		has_trait = trait_misting_seeker        # Bronze - detects Allomancy
		has_trait = trait_mistborn
	}
}

is_higher_allomancer_trigger = {
	OR = {
		has_trait = trait_misting_augur         # Gold - sees alternate past self
		has_trait = trait_misting_oracle        # Atium - sees future
		has_trait = trait_misting_duralumin     # Duralumin - enhances current burn
		has_trait = trait_misting_nicroburst    # Nicrosil - enhances others' burn
		has_trait = trait_mistborn
	}
}

# ===== FERUCHEMY TRIGGERS =====

is_feruchemist_trigger = {
	has_trait = trait_feruchemist
}

has_feruchemy_potential_trigger = {
	has_trait = trait_feruchemy_potential
}

has_any_feruchemy_trigger = {
	OR = {
		has_trait = trait_feruchemist
		has_trait = trait_feruchemy_potential
	}
}

is_full_feruchemist_trigger = {
	has_trait = trait_feruchemist # Full Feruchemists can use all metals
}

# ===== HEMALURGY TRIGGERS =====

has_hemalurgic_spike_trigger = {
	OR = {
		has_trait = trait_hemalurgist
		has_trait = trait_hemalurgic_steel
		has_trait = trait_hemalurgic_pewter
		has_trait = trait_hemalurgic_bronze
		has_trait = trait_hemalurgic_atium
		has_trait = trait_kandra
	}
}

is_kandra_trigger = {
	has_trait = trait_kandra
}

has_multiple_spikes_trigger = {
	# Character has 3+ hemalurgic spike traits — eligible for Inquisitor transformation
	calc_true_if = {
		amount >= 3
		has_trait = trait_hemalurgic_steel
		has_trait = trait_hemalurgic_pewter
		has_trait = trait_hemalurgic_bronze
		has_trait = trait_hemalurgic_atium
	}
}

# ===== INQUISITOR & KEEPER TRIGGERS =====

is_inquisitor_trigger = {
	# Character is a Steel Inquisitor (hemalurgist with multiple spikes)
	has_trait = trait_hemalurgist
	has_multiple_spikes_trigger = yes
}

is_court_inquisitor_trigger = {
	# Character is an Inquisitor assigned to a court
	has_character_flag = is_court_inquisitor
	has_character_modifier = steel_inquisitor_power
}

is_keeper_trigger = {
	# Character is a full Keeper of Terris
	has_character_flag = keeper_identity
}

is_keeper_initiate_trigger = {
	# Character is a Keeper initiate (not yet full Keeper)
	has_character_flag = keeper_initiate
	NOT = { has_character_flag = keeper_identity }
}

is_keeper_or_initiate_trigger = {
	# Character is either a full Keeper or an initiate
	OR = {
		has_character_flag = keeper_initiate
		has_character_flag = keeper_identity
	}
}

# ===== CULTURAL TRIGGERS =====

is_noble_scadrian_trigger = {
	culture = culture:noble_scadrian
}

is_skaa_trigger = {
	culture = culture:skaa
}

is_terris_trigger = {
	culture = culture:terris
}

# ===== POLITICAL TRIGGERS =====

is_great_house_trigger = {
	# Character belongs to one of the Great Noble Houses
	highest_held_title_tier >= tier_duchy
	culture = culture:noble_scadrian
}

# ===== MISC TRIGGERS =====

has_atium_trigger = {
	OR = {
		has_trait = trait_misting_oracle
		has_trait = trait_mistborn
	}
}

can_snap_trigger = {
	# Character has potential but hasn't snapped yet
	OR = {
		has_trait = trait_allomantic_potential
		has_trait = trait_mistborn_potential
	}
	NOT = { is_allomancer_trigger = yes }
	NOT = { is_mistborn_trigger = yes }
	age >= 10 # Must be old enough
}

# ===== LORD RULER TRIGGERS =====

is_lord_ruler_trigger = {
	this = character:900100
}

is_playable_scadrian_trigger = {
	NOT = { is_lord_ruler_trigger = yes }
}

# ===== GAME MODE TRIGGERS =====

is_narrative_mode_trigger = {
	has_game_rule = mistborn_game_mode_narrative_mode
}

is_sandbox_mode_trigger = {
	has_game_rule = mistborn_game_mode_sandbox_mode
}

# ===== EDUCATION GUARDIAN COMPATIBILITY TRIGGERS =====

# Allomantic Training: guardian should have Allomantic trait or education_allomantic_3+
is_good_allomantic_guardian_trigger = {
	OR = {
		is_allomancer_trigger = yes
		has_trait = trait_mistborn
		has_trait = education_allomantic_3
		has_trait = education_allomantic_4
	}
}

# Noble Court: guardian should be noble_scadrian culture
is_good_noble_court_guardian_trigger = {
	culture = culture:noble_scadrian
}

# Ministry Indoctrination: guardian should have Steel Ministry faith
is_good_ministry_guardian_trigger = {
	faith = faith:steel_ministry
}

# Skaa Survival: no requirements — life teaches
is_good_skaa_guardian_trigger = {
	always = yes
}

# Keeper Apprenticeship: guardian must be a Keeper (has keeper_identity flag)
is_good_keeper_guardian_trigger = {
	has_character_flag = keeper_identity
}
