############################################
# Hemalurgy Event Chain
# The dark art of stealing powers through metal spikes
############################################

namespace = mistborn_hemalurgy

# ============================================================
# HEMALURGIC SPIKE CREATION
# Triggered by commission_hemalurgic_spike_decision
# The schemer targets a courtier with Allomantic abilities
# ============================================================
mistborn_hemalurgy.0001 = {
	type = character_event
	title = mistborn_hemalurgy.0001.t
	desc = mistborn_hemalurgy.0001.desc
	theme = skulduggery

	left_portrait = {
		character = root
		animation = scheme
	}

	trigger = {
		has_trait = trait_knows_hemalurgy
	}

	immediate = {
		# Find an Allomancer target in court
		random_courtier = {
			limit = {
				OR = {
					has_trait = trait_misting_coinshot
					has_trait = trait_misting_lurcher
					has_trait = trait_misting_thug
					has_trait = trait_misting_tineye
					has_trait = trait_misting_soother
					has_trait = trait_misting_rioter
					has_trait = trait_misting_smoker
					has_trait = trait_misting_seeker
					has_trait = trait_misting_augur
					has_trait = trait_misting_oracle
				}
			}
			save_scope_as = hemalurgy_victim
		}
	}

	# Option A: Proceed with the spike - kill the victim, steal their power
	option = {
		name = mistborn_hemalurgy.0001.a
		trigger = {
			exists = scope:hemalurgy_victim
		}
		add_stress = 50
		add_tyranny = 20
		stress_impact = {
			compassionate = 60
			just = 40
			callous = -20
			sadistic = -30
		}

		# Determine which hemalurgic trait to gain based on victim's power
		scope:hemalurgy_victim = {
			if = {
				limit = { has_trait = trait_misting_coinshot }
				root = { add_trait = trait_hemalurgic_steel }
			}
			else_if = {
				limit = {
					OR = {
						has_trait = trait_misting_thug
						has_trait = trait_misting_lurcher
					}
				}
				root = { add_trait = trait_hemalurgic_pewter }
			}
			else_if = {
				limit = {
					OR = {
						has_trait = trait_misting_seeker
						has_trait = trait_misting_smoker
					}
				}
				root = { add_trait = trait_hemalurgic_bronze }
			}
			else_if = {
				limit = { has_trait = trait_misting_oracle }
				root = { add_trait = trait_hemalurgic_atium }
			}
			else = {
				# Generic hemalurgic benefit for other metals
				root = { add_trait = trait_hemalurgic_steel }
			}

			# The victim dies
			death = {
				death_reason = death_murder
				killer = root
			}
		}

		# Add the hemalurgist trait if not already present
		if = {
			limit = { NOT = { has_trait = trait_hemalurgist } }
			add_trait = trait_hemalurgist
		}

		# Lord Ruler attention for practicing the forbidden art
		if = {
			limit = { has_variable = lord_ruler_attention }
			change_variable = {
				name = lord_ruler_attention
				add = 15
			}
		}
		else = {
			set_variable = {
				name = lord_ruler_attention
				value = 15
			}
		}

		ai_chance = {
			base = 60
			modifier = {
				add = 20
				has_trait = ambitious
			}
		}
	}

	# Option B: Abandon the plan - too dangerous
	option = {
		name = mistborn_hemalurgy.0001.b
		add_stress = 15
		add_piety = 20
		ai_chance = {
			base = 40
			modifier = {
				add = 30
				has_trait = craven
			}
		}
	}
}
