﻿namespace = ek_historical_artifacts
# Generation of Elder Kings historical artifacts #

# Elder Kings historical artifacts generator at game start
ek_historical_artifacts.0001 = {
	scope = none
	hidden = yes

	immediate = {
		#### FOR INVENTORY ARTIFACTS ####
		random_ruler = {									### CROWN OF VERITY
			limit = { has_title = title:e_eastern_skyrim }
			create_artifact_crown_verity_effect = { OWNER = this }
			add_character_modifier = verity_worthy
		}
		random_ruler = {									### MACE OF AEVAR STONE-SINGER
			limit = { has_title = title:d_snowfallow }
			create_artifact_mace_aevar_effect = { OWNER = this }
		}
		random_ruler = {									### DIADEM OF DIAGNA
			limit = { has_title = title:e_hammerfell }
			create_artifact_diadem_diagna_effect = { OWNER = this }
		}
		random_ruler = {									### SKULl OF BEELA KAR
			limit = { has_title = title:c_norg_tzel }
			create_artifact_golden_skull_beela_kaar_effect = { OWNER = this }
		}
		random_ruler = {									### ORICHALC SCALPEL
			limit = { has_title = title:c_cumberland }
			create_artifact_orichalc_scalpel_effect = { OWNER = this }
		}
		random_ruler = {									### BLACK IRON
			limit = { has_title = title:d_camlorn }
			create_artifact_black_iron_effect = { OWNER = this }
		}
		random_ruler = {									### VELOTH'S JUDGEMENT
			limit = { has_title = title:e_tribunal_temple }
			create_artifact_veloths_judgement_effect = { OWNER = this }
		}
		random_ruler = {									### ROOTMENDER'S STAFF
			limit = { has_title = title:c_root_whisper }
			create_artifact_staff_rootmender_effect = { OWNER = this }
		}
		random_ruler = {									### WUUTHRAD
			limit = { has_title = title:c_blackbriar }
			create_artifact_wuuthrad_effect = { OWNER = this }
		}
		random_ruler = {									### JEWELED CROWN OF ANTON
			limit = { has_title = title:k_daggerfall }
			create_artifact_crown_anton_effect = { OWNER = this }
		}
		random_ruler = {									### CROWN OF SHORNHELM
			limit = { has_title = title:k_shornhelm }
			create_artifact_crown_shornhelm_effect = { OWNER = this }
		}
		random_ruler = {									### RING OF RID-THAR-RI'DATTA
			limit = { has_title = title:e_elsweyr }
			create_artifact_ring_mane_effect = { OWNER = this }
		}
		random_ruler = {									### MALGOTH'S BOW
			limit = { has_title = title:c_diss }
			create_artifact_bow_malgoth_effect = { OWNER = this SET_BOW_TYPE = flag:no }
		}
		# Handled through history now to avoid a random error
		#character:crypt_of_hearts_1000 = {					### EBONY BLADE
		#	create_artifact_ebony_blade_effect = { OWNER = this }
		#}
		character:volkihar_1000 = {							### HARKON'S SWORD
			create_artifact_harkons_sword_effect = { OWNER = this }
		}
		random_ruler = {									### HISTORY OF HISTORIES
			limit = { has_title = title:e_hammerfell }
			create_artifact_history_of_histories_effect = { OWNER = this }
		}
		random_ruler = {									### DRAGONSWORD OF LAINLYN
			limit = { has_title = title:c_lainlyn }
			create_artifact_dragonsword_of_lainlyn_effect = { OWNER = this }
		}
		character:fyr_100 = {								### DAEDRIC ARMOR
			create_artifact_dremora_armor_effect = { OWNER = this }
		}
		random_ruler = {									### PRINCE'S WOE
			limit = {
				culture = culture:yokudan
				government_has_flag = government_is_autocracy
			}
			create_artifact_princes_woe_effect = { OWNER = this }
		}
		character:saraj_1000 = {							### RITUAL DAGGER OF THE FOAL
			create_artifact_dagger_foal_effect = { OWNER = this }
		}
		random_ruler = {									### IVORY BOW
			limit = { has_title = title:d_bergama }
			create_artifact_bow_ivory_effect = { OWNER = this SET_BOW_TYPE = flag:no }
		}
		random_ruler = {									### DIRENNI DELEGATION OF RIVENSPIRE
			limit = { has_title = title:k_shornhelm }
			create_artifact_book_delegation_effect = { OWNER = this }
		}
		random_ruler = {									### BRETONNICK NATALITIE
			limit = { has_title = title:d_phrygias }
			create_artifact_book_bretonnick_effect = { OWNER = this }
		}
		random_ruler = {									### GESTE OF DAENIA
			limit = { has_title = title:d_daenia }
			create_artifact_book_daenia_effect = { OWNER = this }
		}
		random_ruler = {									### MADSTONE OF THE AHEMMUSA
			limit = { has_title = title:d_bitter_coast }
			create_artifact_amulet_ahemmusa_effect = { OWNER = this }
		}
		random_ruler = {									### TEETH OF THE URSHILAKU
			limit = { has_title = title:d_valenvaryon }
			create_artifact_amulet_urshilaku_effect = { OWNER = this }
		}
		random_ruler = {									### THONG OF ZAINAB
			limit = { has_title = title:d_southern_grazelands }
			create_artifact_amulet_zainab_effect = { OWNER = this }
		}
		random_ruler = {									### ARMOR OF JOILE
			limit = { has_title = title:k_daggerfall }
			create_artifact_armor_joile_effect = { OWNER = this }
		}
		random_ruler = {									### GUTWRENCHER
			limit = { has_title = title:d_frostbreak }
			create_artifact_gutwrencher_effect = { OWNER = this }
		}
		random_ruler = {									### TREVA'S MAMMOTH HORN
			limit = { has_title = title:c_treva }
			create_artifact_mammoth_horn_effect = { OWNER = this }
		}
		character:volkihar_1000 = {							### BLOODSTONE CHALICE
			create_artifact_bloodstone_chalice_effect = { OWNER = this }
		}
		character:caerinor_1000 = {							### BLADE OF CASSIMORAN
			create_artifact_blade_cassimoran_effect = { OWNER = this }
		}
		character:seles_100 = {	### BLACK JINX
			create_artifact_black_jinx_effect = { OWNER = this }
		}
		if = { #Gambolpuddy
			limit = {
				current_date >= 3370.1.1
				exists = character:baro_100
				character:baro_100 = { is_alive = yes }
			}
			character:baro_100 = { create_gambolpuddy_effect = { OWNER = this } }
		}
		random_ruler = {									### DEATHBRAND'S ARMOR
			limit = { has_title = title:d_ghost_fleet }
			create_artifact_armor_deathbrand_effect = { OWNER = this }
		}
		random_ruler = {									### DEATHBRAND'S HELMET
			limit = { has_title = title:d_ghost_fleet }
			create_artifact_helmet_deathbrand_effect = { OWNER = this }
		}
		random_ruler = {									### DEATHBRAND'S SWORDS
			limit = { has_title = title:d_ghost_fleet }
			create_artifact_swords_deathbrand_effect = { OWNER = this }
		}
		###########################
		#### Daedric Champions ####
		###########################
		if = { ### EBONY MAIL
			limit = {
				exists = character:indoril_ivulan
				character:indoril_ivulan = { is_alive = yes }
			}
			character:indoril_ivulan = {
				create_artifact_ebony_mail_effect = { OWNER = this }
			}
		}
		if = { #Azura's Star
			limit = {
				exists = character:vastarie_1000
				character:vastarie_1000 = { is_alive = yes }
			}
			character:vastarie_1000 = {
				create_artifact_azuras_star_effect = { OWNER = this }
			}
		}
		if = { #Molag Bal's Mace
			limit = {
				current_date >= 3447.1.1
				exists = character:rulanyil_101
				character:rulanyil_101 = { is_alive = yes }
			}
			character:rulanyil_101 = {
				create_artifact_mace_molag_bal_effect = { OWNER = this }
			}
		}
		###End of Daedric Champions
		#### FOR COURT ARTIFACTS ####
		if = {
			limit = {
				has_dlc_feature = royal_court #checks if player has Royal Court first
			}
			random_ruler = {									### SKULL OF NUMINEX
				limit = { has_title = title:k_whiterun }
				create_artifact_skull_numinex_effect = { OWNER = this }
			}
			random_ruler = {									### RUBY THRONE
				limit = { has_title = title:c_imperial_city }
				create_artifact_throne_ruby_effect = { OWNER = this }
			}
			random_ruler = {									### CAMORAN THRONE
				limit = { has_title = title:k_eldenroot }
				create_artifact_throne_camoran_effect = { OWNER = this }
			}
			random_ruler = {									### FLASK OF LILLANDRIL
				limit = { has_title = title:k_lillandril }
				create_artifact_flask_lillandril_effect = { OWNER = this }
			}
			random_ruler = {									### ANSEI MAJA'S WARD
				limit = { has_title = title:d_sentinel }
				create_artifact_ansei_ward_majah_effect = { OWNER = this }
			}
			random_ruler = {									### ANSEI RADAN'S WARD
				limit = { has_title = title:d_sentinel }
				create_artifact_ansei_ward_radan_effect = { OWNER = this }
			}
			random_ruler = {									### ANSEI HALELAH'S WARD
				limit = { has_title = title:d_sentinel }
				create_artifact_ansei_ward_halelah_effect = { OWNER = this }
			}
			random_ruler = {									### KINGMAKER'S TROVE
				limit = { has_title = title:k_daggerfall }
				create_artifact_kingmakers_trove_effect = { OWNER = this }
			}
			random_ruler = {									### MANE'S PALANQUIN
				limit = { has_title = title:e_elsweyr }
				create_artifact_throne_mane_effect = { OWNER = this }
			}
			random_ruler = {
				limit = { has_title = title:k_anequina }
				create_darloc_brae_spittoon_effect = { OWNER = this }
			}
		}
	}
}

# Judgement of Verity
ek_historical_artifacts.0002 = {
	type = character_event
	content_source = dlc_ek
	title = ek_historical_artifacts.0002.t
	desc = ek_historical_artifacts.0002.desc
	theme = crown

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	lower_right_portrait = {
		character = character:kjoric_100
	}

	# JUST... DO IT!
	option = {
		name = ek_historical_artifacts.0002.a
		random_list = {
			1 = {
				crown_verity_judgement_modifier = yes
				trigger_event = ek_historical_artifacts.0003
			}
			1 = {
				trigger_event = ek_historical_artifacts.0004
			}
		}
	}
	option = { #NO THANKS!
		name = ek_historical_artifacts.0002.b
		remove_decision_cooldown = crown_verity_decision
	}
}

ek_historical_artifacts.0003 = {
	type = character_event
	content_source = dlc_ek
	title = ek_historical_artifacts.0002.t
	desc = ek_historical_artifacts.0003.desc
	theme = crown

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	option = {
		name = ek_historical_artifacts.0003.a
		if = {
			limit = { exists = title:e_eastern_skyrim.holder }
			add_pressed_claim = title:e_eastern_skyrim
		}
		if = {
			limit = { exists = title:e_skyrim.holder }
			add_pressed_claim = title:e_skyrim
		}		
		add_character_modifier = {
			modifier = verity_worthy
		}
	}
}

ek_historical_artifacts.0004 = {
	type = character_event
	content_source = dlc_ek
	title = ek_historical_artifacts.0002.t
	desc = ek_historical_artifacts.0004.desc
	theme = crown

	left_portrait = {
		character = root
		animation = shock
	}

	option = {
		name = ek_historical_artifacts.0004.a
		add_prestige = medium_prestige_loss
		add_character_modifier = {
			modifier = verity_unworthy
			years = 1
		}
	}

	option = {
		name = ek_historical_artifacts.0004.b
		trigger = {
			OR = {
				has_focus = intrigue_skulduggery_focus
				has_focus = intrigue_intimidation_focus 
				has_trait = torturer
				has_trait = schemer
			}
		}
		trait = torturer
		trait = schemer
		add_dread = major_dread_gain
		add_character_modifier = {
			modifier = verity_worthy
		}
	}
}

# Don the Amulet of Kings
ek_historical_artifacts.0005 = {
	type = character_event
	content_source = dlc_ek
	title = ek_historical_artifacts.0005.t
	desc = ek_historical_artifacts.0005.desc
	theme = crown

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	lower_left_portrait = {
		character = character:alessian_100
	}
	lower_right_portrait = {
		character = character:reman_100
	}

	artifact = {
		target = scope:aok
		position = lower_center_portrait
		trigger = { exists = scope:aok }
	}

	immediate = {
		character:reman_100 = { save_scope_as = reman }
		character:alessian_100 = { save_scope_as = alesh }
		random_equipped_character_artifact = {
			limit = { has_artifact_modifier = aok_modifier }
			save_scope_as = aok
		}
	}

	# JUST... DO IT!
	option = {
		name = ek_historical_artifacts.0005.a
		random_list = {
			0 = {
				show_chance = no
				desc = ek_historical_artifacts.0005.a.success
				custom_tooltip = ek_historical_artifacts.0005.a.success.tt
				modifier = {
					factor = 1000
					has_trait = dragonborn
				}
				trigger_event = ek_historical_artifacts.0006
			}
			99 = {
				show_chance = no
				desc = ek_historical_artifacts.0005.a.failure
				custom_tooltip = ek_historical_artifacts.0005.a.failure.tt
				modifier = {
					factor = 0
					has_trait = dragonborn
				}
				trigger_event = ek_historical_artifacts.0007
			}
		}
	}
	option = { #NO THANKS!
		name = ek_historical_artifacts.0005.b
		remove_decision_cooldown = aok_decision
	}
}

ek_historical_artifacts.0006 = {
	type = character_event
	content_source = dlc_ek
	title = ek_historical_artifacts.0005.t
	desc = ek_historical_artifacts.0006.desc
	theme = crown

	left_portrait = {
		character = root
		animation = personality_honorable
	}

	lower_left_portrait = {
		character = character:alessian_100
	}
	lower_right_portrait = {
		character = character:reman_100
	}

	artifact = {
		target = scope:aok
		position = lower_center_portrait
		trigger = { exists = scope:aok }
	}

	immediate = {
		character:reman_100 = { save_scope_as = reman }
		character:alessian_100 = { save_scope_as = alesh }
		random_equipped_character_artifact = {
			limit = { has_artifact_modifier = aok_modifier }
			save_scope_as = aok
		}
	}

	option = {
		name = ek_historical_artifacts.0006.a
		if = {
			limit = { exists = title:e_cyrodiil.holder }
			add_pressed_claim = title:e_cyrodiil
		}
		if = {
			limit = { exists = title:e_cyrodiilic_potentate.holder }
			add_pressed_claim = title:e_cyrodiilic_potentate
		}
		if = {
			limit = { exists = title:d_imperial_isle.holder }
			add_pressed_claim = title:d_imperial_isle
		}
		if = {
			limit = { exists = title:c_imperial_city.holder }
			add_pressed_claim = title:c_imperial_city
		}
		scope:aok = {
			
			reforge_artifact = {
				type = regalia
				modifier = true_aok_modifier
				template = aok_template
			}
		}		
	}
}

ek_historical_artifacts.0007 = {
	type = character_event
	content_source = dlc_ek
	title = ek_historical_artifacts.0005.t
	desc = ek_historical_artifacts.0007.desc
	theme = crown

	left_portrait = {
		character = root
		animation = shock
	}

	option = {
		name = ek_historical_artifacts.0007.a
		add_prestige = medium_prestige_loss
	}
}