﻿# Mistborn: The Final Empire - Scripted Effects
# Reusable effects for Allomantic activation, Lord Ruler attention, and other game mechanics

# ===== ALLOMANCY ACTIVATION =====

activate_allomancy_effect = {
	# Converts hidden allomantic_potential trait to an active Allomantic power
	# Should be triggered by a "snapping" event (near-death trauma)

	if = {
		limit = { has_trait = trait_allomantic_potential }
		remove_trait = trait_allomantic_potential

		# Determine which metal the character can burn
		# Weight heavily influenced by heritage and genetics
		random_list = {
			10 = {
				# Mistborn - extremely rare, can burn all metals
				trigger = {
					OR = {
						any_parent = { has_trait = trait_mistborn }
					}
				}
				add_trait = trait_mistborn
			}
			20 = { add_trait = trait_misting_lurcher }      # Iron
			20 = { add_trait = trait_misting_coinshot }     # Steel
			15 = { add_trait = trait_misting_tineye }       # Tin
			20 = { add_trait = trait_misting_thug }         # Pewter
			15 = { add_trait = trait_misting_rioter }       # Zinc
			15 = { add_trait = trait_misting_soother }      # Brass
			15 = { add_trait = trait_misting_smoker }       # Copper
			15 = { add_trait = trait_misting_seeker }       # Bronze
			5 = { add_trait = trait_misting_augur }         # Gold - rare
			1 = { add_trait = trait_misting_oracle }        # Atium - extremely rare
			3 = { add_trait = trait_misting_duralumin }     # Duralumin - very rare
			3 = { add_trait = trait_misting_nicroburst }    # Nicrosil - very rare
		}
	}
}

# ===== LORD RULER ATTENTION =====

increase_lord_ruler_attention_effect = {
	# The Lord Ruler and Steel Ministry take notice of the character
	# Uses the variable-based system tracked in on_actions

	if = {
		limit = {
			NOT = { has_variable = lord_ruler_attention }
		}
		set_variable = {
			name = lord_ruler_attention
			value = 0
		}
	}

	change_variable = {
		name = lord_ruler_attention
		add = 15
	}

	# Cap at 100
	if = {
		limit = {
			var:lord_ruler_attention > 100
		}
		set_variable = {
			name = lord_ruler_attention
			value = 100
		}
	}
}

decrease_lord_ruler_attention_effect = {
	# The character manages to reduce the Lord Ruler's scrutiny

	if = {
		limit = {
			has_variable = lord_ruler_attention
			var:lord_ruler_attention > 0
		}
		change_variable = {
			name = lord_ruler_attention
			add = -15
		}

		# Ensure attention doesn't go below 0
		if = {
			limit = {
				var:lord_ruler_attention < 0
			}
			set_variable = {
				name = lord_ruler_attention
				value = 0
			}
		}
	}
}

# ===== SNAPPING EFFECT =====

trigger_snapping_effect = {
	# Utility effect: triggers the snapping event chain for a character with potential.
	# The actual Misting type assignment happens in mistborn_snapping.0020's immediate block,
	# which is the single source of truth for weighted random Misting type selection.
	if = {
		limit = {
			can_snap_trigger = yes
		}
		trigger_event = {
			id = mistborn_snapping.0020
			days = 1
		}
	}
}

# ===== HEMALURGY EFFECTS =====

apply_hemalurgic_spike_effect = {
	# Apply a hemalurgic spike to grant stolen powers (at the cost of sanity)
	add_trait = trait_hemalurgist

	# Hemalurgy comes with costs
	stress_impact = {
		base = massive_stress_impact_gain
	}
}

create_steel_inquisitor_effect = {
	# Transform a character into a Steel Inquisitor via multiple hemalurgic spikes
	# Grants all hemalurgic traits and massive power
	add_trait = trait_hemalurgist
	add_trait = trait_hemalurgic_steel
	add_trait = trait_hemalurgic_pewter
	add_trait = trait_hemalurgic_bronze
	add_trait = trait_hemalurgic_atium

	# Physical transformation
	add_trait = disfigured # Spikes through the eyes
}

# ===== HOUSE AND DYNASTY EFFECTS =====

establish_great_house_effect = {
	# Elevate a noble house to Great House status
	dynasty = {
		add_dynasty_prestige = 500
	}

	add_prestige = 250
}

strip_great_house_effect = {
	# Remove Great House status (usually by Lord Ruler decree)
	dynasty = {
		add_dynasty_prestige = -500
	}

	add_prestige = -500
}

# ===== ATIUM EFFECTS =====

grant_atium_supply_effect = {
	# Character receives a supply of atium (extremely valuable)
	add_gold = 200
}

deplete_atium_supply_effect = {
	# Character's atium supply runs out
	# No-op if not holding atium
}
