﻿namespace = historical_artifacts
# Generation of historical artifacts #

#Historical artifacts generator at game start
historical_artifacts.0023 = {
	scope = none
	hidden = yes

	immediate = {
		# Seeded Court Artifacts
		if = {
			limit = { has_dlc_feature = royal_court } 
			# All starting courts will have a dynasty banner
			every_character_with_royal_court = {
				save_scope_as = banner_ruler
				# House Banner
				set_variable = banner_from_house
				set_variable = startup_banner
				create_artifact_wall_banner_effect = {
					OWNER = scope:banner_ruler
					CREATOR = scope:banner_ruler
					TARGET = scope:banner_ruler.house
				}
				# Dynasty Banner
				If = { 
					limit = {
						OR = {
							this = dynasty.dynast # Dynasty Head
							any_parent = { # Parent landless Dynasty Head
								employer = prev
								dynasty = prev.dynasty
								this = dynasty.dynast
							}
						}
					}
					set_variable = banner_from_dynasty
					set_variable = startup_banner
					create_artifact_wall_banner_effect = {
						OWNER = scope:banner_ruler
						CREATOR = scope:banner_ruler
						TARGET = scope:banner_ruler.dynasty
					}
				}
			}
			# Court Artifacts: Christianity
			while = {
				count = 6
				random_character_with_royal_court = {
					limit = {
						OR = {
							faith.religion = religion:eastern_orthodox_religion 
							faith.religion = religion:catholic_religion 
							faith.religion = religion:protestant_religion
						}
						NOT = { has_character_flag = seeded_relic }
					}
					create_artifact_pedestal_christian_relic_effect_hist = { OWNER = this }
					add_character_flag = {
						flag = seeded_relic
						days = 1
					}
				}
			}
			# Court Artifacts: Islam
			while = {
				count = 6
				random_character_with_royal_court = {
					limit = {
						faith.religion = religion:islam_religion
						NOT = { has_character_flag = seeded_relic }
					}
					create_artifact_pedestal_islamic_relic_effect_hist = { OWNER = this }
					add_character_flag = {
						flag = seeded_relic
						days = 1
					}
				}
			}
			# Court Artifacts: Buddhism
			while = {
				count = 12
				random_character_with_royal_court = {
					limit = {
						faith.religion = religion:buddhism_religion
						NOT = { has_character_flag = seeded_relic }
					}
					create_artifact_pedestal_buddhism_relic_effect_hist = { OWNER = this }
					add_character_flag = {
						flag = seeded_relic
						days = 1
					}
				}
			}
			# Court Artifacts: Hinduism
			while = {
				count = 2
				random_character_with_royal_court = {
					limit = {
						faith.religion = religion:hinduism_religion
						NOT = { has_character_flag = seeded_relic }
					}
					create_artifact_pedestal_branch_relic_hinduism_effect = { OWNER = this }
					add_character_flag = {
						flag = seeded_relic
						days = 1
					}
				}
			}
			# Court Artifacts: Norse Paganism
			faith:folketro = {
				while = {
					count = 2
					random_faith_ruler = {
						limit = {
							highest_held_title_tier >= tier_county
							NOT = { has_character_flag = seeded_relic }
						}
						create_artifact_pedestal_branch_relic_germanic_effect = { OWNER = this }
						add_character_flag = {
							flag = seeded_relic
							days = 1
						}
					}
				}
			}
#			# Court Artifacts: Roog Sene
#			faith:west_african_roog_pagan = {
#				random_faith_ruler = {
#					limit = { highest_held_title_tier >= tier_county }
#					create_artifact_pedestal_branch_relic_boog_effect = { OWNER = this }
#				}
#			}
			# Court Artifacts: Slavic
			faith:chernobozhye = {
				random_faith_ruler = {
					limit = { highest_held_title_tier >= tier_county }
					create_artifact_pedestal_branch_relic_slavic_effect = { OWNER = this }
				}
			}
		}
#		# Historical Artifacts
#		## We do these per-artefact rather than per-title so that they can be easily reshuffled if desired.
#		## Crowns
#		### Iron Crown of Lombardy
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:e_hre.holder
#			}
#			title:e_hre.holder = {
#				create_artifact_pedestal_crown_iron_effect = { OWNER = this }
#			}
#		}
#		### Reichskrone
#		if = {
#			limit = {
#				current_date > 1000.1.1
#				exists = title:e_hre.holder
#			}
#			title:e_hre.holder = {
#				create_artifact_reichskrone_effect = { OWNER = this }
#			}
#		}
#		### Essen Crown
#		if = {
#			limit = {
#				current_date > 1000.1.1
#				exists = title:e_hre.holder
#			}
#			title:e_hre.holder = {
#				create_artifact_essen_crown_effect = { OWNER = this }
#			}
#		}
#		### Nikephoros' Crown
#		if = {
#			limit = {
#				current_date >= 1000.1.1
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_nikephoros_crown_effect = { OWNER = this }
#			}
#		}
#		### Monomachus Crown
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 1000.1.1
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_monomachus_crown_effect = { OWNER = this }
#			}
#		}
#		### Crown of Justinian
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_pedestal_justinian_effect = { OWNER = this }
#			}
#		}
#		### al-Taj
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_al_taj_crown_effect = { OWNER = this }
#			}
#		}
#		### Papal Tiara
#		if = {
#			limit = { exists = title:k_papal_state.holder }
#			title:k_papal_state.holder = {
#				create_artifact_papal_tiara_effect = { OWNER = this }
#			}
#		}
#		### Visigothic Votive Crowns
#		if = {
#			limit = { has_fp2_dlc_trigger = yes }
#			every_county_in_region = {
#				region = world_europe_west_iberia
#				holder = { add_to_list = potential_votive_crown_holders_list }
#			}
#			while = {
#				count = 5
#				random_in_list = {
#					list = potential_votive_crown_holders_list
#					limit = {
#						NOT = { has_character_flag = seeded_relic }
#					}
#					create_artifact_fp2_votive_crowns_effect = { OWNER = this }
#					add_character_flag = {
#						flag = seeded_relic
#						days = 1
#					}
#				}
#			}
#		}
#		## Clothes
#		### Robe of Kassapa
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:k_pagan.holder
#			}
#			title:k_pagan.holder = {
#				create_artifact_robe_kassapa_effect = { OWNER = this }
#			}
#		}
#		### Mantle of the Prophet
#		if = {
#			limit = { exists = title:d_sunni.holder }
#			title:d_sunni.holder = {
#				create_artifact_mantle_of_the_prophet_effect = { OWNER = this }
#			}
#		}
#		## Other Regalia
#		### Qadib al-Mulk
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_qadib_al_mulk_effect = { OWNER = this }
#			}
#		}
#		### Chalice of Dona Urraca
#		if = {
#			limit = {
#				# It's likely that Urraca paid for her eponymous chalice using money she earnt from the titles her father pre-bequeathed to her, so it was probably made some time *after* 1066 (since she only got the lands in 1065, shortly before her father died), buuuuuut it's really mean to not let her have it at game start, so we give it to her in 1066.
#				current_date >= 1066.1.1
#				has_fp2_dlc_trigger = yes
#				exists = character:108501
#				character:108501 = { is_alive = yes }
#			}
#			create_artifact_goblet_chalice_of_dona_urraca = { OWNER = character:108501 }
#		}
#		## Thrones
#		### Throne of Scone (featuring Stone)
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:k_scotland.holder
#			}
#			title:k_scotland.holder = {
#				create_artifact_throne_scone_effect = { OWNER = this }
#			}
#		}
#		### Throne of Charlemagne
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:e_hre.holder
#			}
#			title:e_hre.holder = {
#				create_artifact_throne_charlemagne_effect = { OWNER = this }
#			}
#		}
#		### Throne of Solomon (the Byzantine one)
#		if = {
#			limit = {
#				has_ep3_dlc_trigger = yes
#				exists = title:e_byzantium.holder
#				current_date >= 940.1.1
#			}
#			title:e_byzantium.holder = {
#				create_artifact_byz_throne_effect = { OWNER = this }
#			}
#		}
#		## Furniture
#		### Pentapyrgion
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_sculpture_cabinet_pentapyrgion_effect = { OWNER = this }
#			}
#		}
#		### Bells of Santiago
#		if = {
#			# If we're before Almanzor's raid, then the bells go to c_santiago's holder.
#			limit = {
#				has_fp2_dlc_trigger = yes
#				current_date < 997.1.1
#			}
#			title:c_santiago.holder = {
#				create_artifact_various_bells_santiago = { OWNER = this }
#				# The bells haven't been changed at all.
#				scope:newly_created_artifact = {
#					set_variable = {
#						name = artefact_santiago_bells
#						value = 0
#					}
#				}
#			}
#		}
#		### (Former) Bells of Santiago
#		#### These aren't actually furniture, but we keep 'em here so they're next to the regular bells, which *are*.
#		if = {
#			# If we're after Almanzor's raid, then the bells go to c_toledo's holder.
#			limit = {
#				has_fp2_dlc_trigger = yes
#				current_date >= 997.1.1
#				current_date <= 1178.1.1
#			}
#			title:c_toledo.holder = {
#				create_artifact_various_aquamanile_santiago = { OWNER = this }
#				# The bells have been morphed once.
#				scope:newly_created_artifact = {
#					set_variable = {
#						name = artefact_santiago_bells
#						value = 1
#					}
#				}
#			}
#		}
#		if = {
#			# If we're after Almanzor's raid, then the bells go to c_toledo's holder.
#			limit = {
#				has_fp2_dlc_trigger = yes
#				current_date >= 1178.1.1
#			}
#			title:c_cordoba.holder = {
#				create_artifact_various_aquamanile_santiago = { OWNER = this }
#				# The bells have been morphed once.
#				scope:newly_created_artifact = {
#					set_variable = {
#						name = artefact_santiago_bells
#						value = 1
#					}
#				}
#			}
#		}
#		## Weapons (including decoratives)
#		### Curtana
#		#### Not the *actual* Curtana, but at least occasionally traced as Edward the Confessor's sword (and then ascribed an even more mythic origin from there).
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 1042.8.6
#				exists = title:k_england.holder
#			}
#			title:k_england.holder = {
#				create_artifact_curtana_effect = { OWNER = this }
#			}
#		}
#		### Sword of Atilla 
#		#### Associated with the Arpads, but "discovered"/passed out of their possession around or after 1063. They maintain a house claim on it.
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 1064.1.1
#				exists = title:d_upper_bavaria.holder
#			}
#			title:d_upper_bavaria.holder = {
#				create_artifact_wall_sword_attila_effect = { OWNER = this }
#				dynasty:708 = {
#					random_dynasty_member = {
#						house = { add_house_artifact_claim = scope:newly_created_artifact }
#					}
#				}
#			}
#		}
#		### al-Sayf al-Khass
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_al_sayf_al_khass_effect = { OWNER = this }
#			}
#		}
#		### Staff of Kakusandha
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:k_pagan.holder
#			}
#			title:k_pagan.holder = {
#				create_artifact_staff_kakusandha_effect = { OWNER = this }
#			}
#		}
		### "Excalibur"
		every_county_in_region = {
			region = world_europe_west_britannia
			holder = {
				# We exclude kings'n'emperors so the Excaliburs scatter a little better.
				if = {
					limit = {
						OR = {
							faith.religion = religion:eastern_orthodox_religion 
							faith.religion = religion:catholic_religion 
							faith.religion = religion:protestant_religion
						}
						highest_held_title_tier <= tier_duchy
					}
					add_to_list = potential_excalibur_holders_list
				}
			}
		}
		every_county_in_region = {
			region = world_europe_west_francia
			holder = {
				# We exclude kings'n'emperors so the Excaliburs scatter a little better.
				if = {
					limit = {
						OR = {
							faith.religion = religion:eastern_orthodox_religion 
							faith.religion = religion:catholic_religion 
							faith.religion = religion:protestant_religion
						}
						highest_held_title_tier <= tier_duchy
					}
					add_to_list = potential_excalibur_holders_list
				}
			}
		}
		if = {
			limit = {
				any_in_list = { list = potential_excalibur_holders_list }
			}
			while = {
				count = 6
				random_in_list = {
					list = potential_excalibur_holders_list
					limit = {
						NOT = { has_character_flag = seeded_relic }
					}
					weight = {
						# Weight up Arthurian heartlands.
						## We don't weigh 'em up _too_ much, because there's quite a few rulers in this region.
						modifier = {
							add = 10
							capital_province = { geographical_region = dlc_ep1_arthurian_heartlands_region }
						}
					}
					create_artifact_excalibur_effect = { OWNER = this }
					add_character_flag = {
						flag = seeded_relic
						days = 1
					}
				}
			}
		}
#		if = { #this isn't working for some reason, need to fix later
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:d_nf_solomonid
#			}
#			title:d_nf_solomonid = {
#				create_artifact_excalibur_effect = { OWNER = this }
#			}
#		}
#		### Spear of the Prophet
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:d_sunni.holder
#			}
#			title:d_sunni.holder = {
#				create_artifact_spear_of_the_prophet_effect = { OWNER = this }
#			}
#		}
#		### Banke no Hoken ~785
#		if = { # Chrysanthemum Throne
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 867.1.1
#				exists = title:k_chrysanthemum_throne.holder
#			}
#			title:k_chrysanthemum_throne.holder = {
#				create_artifact_pedestal_sakanoue_sword_effect = { OWNER = this }
#			}
#		}
#		### Higekiri ~950
#		if = { # Seiwa
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_minamoto_seiwa.holder
#			}
#			title:c_nf_minamoto_seiwa.holder = {
#				create_artifact_higekiri_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Kawachi
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_minamoto_kawachi.holder
#			}
#			title:c_nf_minamoto_kawachi.holder = {
#				create_artifact_higekiri_sword_effect = { OWNER = this }
#			}
#		}
#		### Hizamaru ~950
#		if = { # Kawachi
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_minamoto_kawachi.holder
#			}
#			title:c_nf_minamoto_kawachi.holder = {
#				create_artifact_hizamaru_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Yoshitsune
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:d_laamp_yoshitsune.holder
#			}
#			title:d_laamp_yoshitsune.holder = {
#				create_artifact_hizamaru_sword_effect = { OWNER = this }
#			}
#		}
#		### Dojigiri ~880
#		if = { # Uona
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_fujiwara_uona.holder
#			}
#			title:c_nf_fujiwara_uona.holder = {
#				create_artifact_dojigiri_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Oshu
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_fujiwara_oshu.holder
#			}
#			title:c_nf_fujiwara_oshu.holder = {
#				create_artifact_dojigiri_sword_effect = { OWNER = this }
#			}
#		}
#		### Mikazuki Munechika ~980
#		if = {  # Kan'in
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_fujiwara_kanin.holder
#			}
#			title:c_nf_fujiwara_kanin.holder = {
#				create_artifact_mikazuki_munechika_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Tokudaiji
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_fujiwara_ashikaga.holder
#			}
#			title:c_nf_fujiwara_ashikaga.holder = {
#				create_artifact_mikazuki_munechika_sword_effect = { OWNER = this }
#			}
#		}
#		### Ōtenta ~1082
#		if = { # Kiso
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_minamoto_kiso.holder
#			}
#			title:c_nf_minamoto_kiso.holder = {
#				create_artifact_odenta_sword_effect = { OWNER = this }
#			}
#		}
#		### Hamayumi ~1145
#		if = { # Chrysanthemum Throne
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 1178.1.1
#				exists = title:k_chrysanthemum_throne.holder
#			}
#			title:k_chrysanthemum_throne.holder = {
#				create_artifact_pedestal_hamayumi_bow_effect = { OWNER = this }
#			}
#		}
#		### Shichishitō <500
#		if = { # Chrysanthemum Throne
#			limit = {
#				current_date >= 867.1.1
#				exists = title:k_chrysanthemum_throne.holder
#			}
#			title:k_chrysanthemum_throne.holder = {
#				create_artifact_pedestal_seven_branched_sword_effect = { OWNER = this }
#			}
#		}
#		### Gyerim-ro dagger ~867
#		if = { # Silla
#			limit = {
#				current_date = 867.1.1 # Only 867
#				exists = title:k_silla.holder
#			}
#			title:k_silla.holder = {
#				create_artifact_pedestal_gyerimro_dagger_effect = { OWNER = this }
#			}
#		}
#		### Nukemaru ~1120
#		if = { # Taira
#			limit = {
#				current_date >= 1178.1.1
#				exists = title:c_nf_taira_kanmu.holder
#			}
#			title:c_nf_taira_kanmu.holder = {
#				create_artifact_nukemaru_sword_effect = { OWNER = this }
#			}
#		}
#		### Kogarasumaru ~945
#		if = { # Taira
#			limit = {
#				current_date >= 1066.9.15
#				exists = title:c_nf_taira_kanmu.holder
#			}
#			title:c_nf_taira_kanmu.holder = {
#				create_artifact_kogarasumaru_sword_effect = { OWNER = this }
#			}
#		}
#		## Armor
#		### Karakawa ~800
#		if = { # Taira
#			limit = {
#				current_date >= 867.1.1
#				exists = title:c_nf_taira_kanmu.holder
#			}
#			title:c_nf_taira_kanmu.holder = {
#				create_artifact_karakawa_armor_effect = { OWNER = this }
#			}
#		}
#		## Books, Scrolls, & Other Recorded Nerdery
#		### Konagamana
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:k_pagan.holder
#			}
#			title:k_pagan.holder = {
#				create_artifact_konagamana_effect = { OWNER = this }
#			}
#		}
#		### Vinaya Pitaka
#		random_character_with_royal_court = {
#			limit = { faith = faith:theravada }
#			create_artifact_vinaya_pitaka_effect = { OWNER = this }
#		}
#		### Sutta Pitaka
#		random_character_with_royal_court = {
#			limit = { faith = faith:theravada }
#			create_artifact_sutta_pitaka_effect = { OWNER = this }
#		}
#		### Abhidhamma Pitaka
#		random_character_with_royal_court = {
#			limit = { faith = faith:theravada }
#			create_artifact_abhidhamma_pitaka_effect = { OWNER = this }
#		}
#		## Banners
#		### Banner of Kaviani
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				# Only generated in the earlier bookmarks.
#				current_date < 1000.1.1
#				exists = title:k_makran.holder
#			}
#			title:k_makran.holder = {
#				create_artifact_wall_banner_kaviani_effect = { OWNER = this }
#			}
#		}
#		### Banner of Edessa
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_wall_banner_edessa_effect = { OWNER = this }
#			}
#		}
#		### Banner of Thankfulness
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_wall_banner_thankfulness_effect = { OWNER = this }
#			}
#		}
#		## Misc
#		### Head of St. Edmund
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				# Date of earliest likely canonisation.
#				current_date >= 924.1.1
#				exists = title:k_england.holder
#			}
#			title:k_england.holder = {
#				create_artifact_edmund_head_effect = { OWNER = this }
#			}
#		}
#		### al-Dawat
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_al_dawat_effect = { OWNER = this }
#			}
#		}
#		### al-Hafir
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_al_hafir_effect = { OWNER = this }
#			}
#		}		if = { #this isn't working for some reason, need to fix later
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:d_nf_solomonid
#			}
#			title:d_nf_solomonid = {
#				create_artifact_excalibur_effect = { OWNER = this }
#			}
#		}
#		### Spear of the Prophet
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:d_sunni.holder
#			}
#			title:d_sunni.holder = {
#				create_artifact_spear_of_the_prophet_effect = { OWNER = this }
#			}
#		}
#		### Banke no Hoken ~785
#		if = { # Chrysanthemum Throne
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 867.1.1
#				exists = title:k_chrysanthemum_throne.holder
#			}
#			title:k_chrysanthemum_throne.holder = {
#				create_artifact_pedestal_sakanoue_sword_effect = { OWNER = this }
#			}
#		}
#		### Higekiri ~950
#		if = { # Seiwa
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_minamoto_seiwa.holder
#			}
#			title:c_nf_minamoto_seiwa.holder = {
#				create_artifact_higekiri_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Kawachi
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_minamoto_kawachi.holder
#			}
#			title:c_nf_minamoto_kawachi.holder = {
#				create_artifact_higekiri_sword_effect = { OWNER = this }
#			}
#		}
#		### Hizamaru ~950
#		if = { # Kawachi
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_minamoto_kawachi.holder
#			}
#			title:c_nf_minamoto_kawachi.holder = {
#				create_artifact_hizamaru_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Yoshitsune
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:d_laamp_yoshitsune.holder
#			}
#			title:d_laamp_yoshitsune.holder = {
#				create_artifact_hizamaru_sword_effect = { OWNER = this }
#			}
#		}
#		### Dojigiri ~880
#		if = { # Uona
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_fujiwara_uona.holder
#			}
#			title:c_nf_fujiwara_uona.holder = {
#				create_artifact_dojigiri_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Oshu
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_fujiwara_oshu.holder
#			}
#			title:c_nf_fujiwara_oshu.holder = {
#				create_artifact_dojigiri_sword_effect = { OWNER = this }
#			}
#		}
#		### Mikazuki Munechika ~980
#		if = {  # Kan'in
#			limit = {
#				current_date = 1066.9.15
#				exists = title:c_nf_fujiwara_kanin.holder
#			}
#			title:c_nf_fujiwara_kanin.holder = {
#				create_artifact_mikazuki_munechika_sword_effect = { OWNER = this }
#			}
#		}
#		else_if = { # Tokudaiji
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_fujiwara_ashikaga.holder
#			}
#			title:c_nf_fujiwara_ashikaga.holder = {
#				create_artifact_mikazuki_munechika_sword_effect = { OWNER = this }
#			}
#		}
#		### Ōtenta ~1082
#		if = { # Kiso
#			limit = {
#				current_date >= 1178.10.1
#				exists = title:c_nf_minamoto_kiso.holder
#			}
#			title:c_nf_minamoto_kiso.holder = {
#				create_artifact_odenta_sword_effect = { OWNER = this }
#			}
#		}
#		### Hamayumi ~1145
#		if = { # Chrysanthemum Throne
#			limit = {
#				has_dlc_feature = royal_court
#				current_date >= 1178.1.1
#				exists = title:k_chrysanthemum_throne.holder
#			}
#			title:k_chrysanthemum_throne.holder = {
#				create_artifact_pedestal_hamayumi_bow_effect = { OWNER = this }
#			}
#		}
#		### Shichishitō <500
#		if = { # Chrysanthemum Throne
#			limit = {
#				current_date >= 867.1.1
#				exists = title:k_chrysanthemum_throne.holder
#			}
#			title:k_chrysanthemum_throne.holder = {
#				create_artifact_pedestal_seven_branched_sword_effect = { OWNER = this }
#			}
#		}
#		### Gyerim-ro dagger ~867
#		if = { # Silla
#			limit = {
#				current_date = 867.1.1 # Only 867
#				exists = title:k_silla.holder
#			}
#			title:k_silla.holder = {
#				create_artifact_pedestal_gyerimro_dagger_effect = { OWNER = this }
#			}
#		}
#		### Nukemaru ~1120
#		if = { # Taira
#			limit = {
#				current_date >= 1178.1.1
#				exists = title:c_nf_taira_kanmu.holder
#			}
#			title:c_nf_taira_kanmu.holder = {
#				create_artifact_nukemaru_sword_effect = { OWNER = this }
#			}
#		}
#		### Kogarasumaru ~945
#		if = { # Taira
#			limit = {
#				current_date >= 1066.9.15
#				exists = title:c_nf_taira_kanmu.holder
#			}
#			title:c_nf_taira_kanmu.holder = {
#				create_artifact_kogarasumaru_sword_effect = { OWNER = this }
#			}
#		}
#		## Armor
#		### Karakawa ~800
#		if = { # Taira
#			limit = {
#				current_date >= 867.1.1
#				exists = title:c_nf_taira_kanmu.holder
#			}
#			title:c_nf_taira_kanmu.holder = {
#				create_artifact_karakawa_armor_effect = { OWNER = this }
#			}
#		}
#		## Books, Scrolls, & Other Recorded Nerdery
#		### Konagamana
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:k_pagan.holder
#			}
#			title:k_pagan.holder = {
#				create_artifact_konagamana_effect = { OWNER = this }
#			}
#		}
#		### Vinaya Pitaka
#		random_character_with_royal_court = {
#			limit = { faith = faith:theravada }
#			create_artifact_vinaya_pitaka_effect = { OWNER = this }
#		}
#		### Sutta Pitaka
#		random_character_with_royal_court = {
#			limit = { faith = faith:theravada }
#			create_artifact_sutta_pitaka_effect = { OWNER = this }
#		}
#		### Abhidhamma Pitaka
#		random_character_with_royal_court = {
#			limit = { faith = faith:theravada }
#			create_artifact_abhidhamma_pitaka_effect = { OWNER = this }
#		}
#		## Banners
#		### Banner of Kaviani
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				# Only generated in the earlier bookmarks.
#				current_date < 1000.1.1
#				exists = title:k_makran.holder
#			}
#			title:k_makran.holder = {
#				create_artifact_wall_banner_kaviani_effect = { OWNER = this }
#			}
#		}
#		### Banner of Edessa
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_wall_banner_edessa_effect = { OWNER = this }
#			}
#		}
#		### Banner of Thankfulness
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_wall_banner_thankfulness_effect = { OWNER = this }
#			}
#		}
#		## Misc
#		### Head of St. Edmund
#		if = {
#			limit = {
#				has_dlc_feature = royal_court
#				# Date of earliest likely canonisation.
#				current_date >= 924.1.1
#				exists = title:k_england.holder
#			}
#			title:k_england.holder = {
#				create_artifact_edmund_head_effect = { OWNER = this }
#			}
#		}
#		### al-Dawat
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_al_dawat_effect = { OWNER = this }
#			}
#		}
#		### al-Hafir
#		if = {
#			limit = {
#				# Establishment of the Fatimid Caliphate.
#				current_date >= 910.1.15
#				has_dlc_feature = royal_court
#				exists = title:d_shiite.holder
#			}
#			title:d_shiite.holder = {
#				create_artifact_al_hafir_effect = { OWNER = this }
#			}
#		}
		### Skull Cap of Charlemagne
		if = {
			limit = {
				has_dlc_feature = royal_court
				exists = title:k_france.holder
			}
			title:k_france.holder = {
				create_artifact_skull_cap_charlemagne_effect = { OWNER = this }
			}
		}
#		### Sassanian Sword
#		if = {
#			limit = {
#				# Only generated in the earlier bookmarks.
#				current_date < 900.1.1
#				has_dlc_feature = legacy_of_persia
#				exists = title:c_mazandaran
#			}
#			title:c_mazandaran.holder = {
#				create_artifact_illustrious_sassanian_sword_effect = { OWNER = this }
#			}
#		}
#		### Incense Burner Sculpture
#		if = {
#			limit = {
#				# Only generated in the earlier bookmarks.
#				current_date < 900.1.1
#				has_dlc_feature = legacy_of_persia
#				exists = title:k_khorasan
#			}
#			title:k_khorasan.holder = {
#				create_artifact = {
#					name = fp3_incense_burner_sculpture
#					description = fp3_incense_burner_sculpture_desc
#					visuals = fp3_incense_burner_sculpture
#					type = sculpture
#					wealth = 80
#					quality = 80
#					modifier = artifact_negate_health_penalty_add_2_modifier
#					modifier = artifact_stress_gain_3_modifier
#					modifier = artifact_attraction_opinion_2_modifier
#					modifier = artifact_court_grandeur_baseline_add_3_modifier
#					history = { type = created_before_history }
#				}
#			}
#		}
#		### Oxus Bracelet
#		if = {
#			limit = {
#				# Only generated in the earlier bookmarks.
#				current_date < 900.1.1
#				has_dlc_feature = legacy_of_persia
#				exists = title:k_transoxiana
#			}
#			title:k_transoxiana.holder = {
#				create_artifact_oxus_bracelet_effect = { 
#					OWNER = this
#				}
#			}
#		}
#		### Persian Drinking Vessel
#		if = {
#			limit = {
#				# Only generated in the earlier bookmarks.
#				current_date < 900.1.1
#				has_dlc_feature = legacy_of_persia
#				exists = title:k_makran
#			}
#			title:k_makran.holder = {
#				create_artifact = {
#					name = fp3_ancient_drinking_vessel
#					description = fp3_ancient_drinking_vessel_desc
#					visuals = persian_drinking_vessel
#					type = goblet
#					wealth = 80
#					quality = 80
#					modifier = artifact_negate_health_penalty_add_2_modifier
#					modifier = artifact_stress_gain_3_modifier
#					modifier = artifact_monthly_prestige_5_modifier
#					modifier = artifact_court_grandeur_baseline_add_3_modifier
#				}
#			}
#		}
#		### Statue of Constantine the Great
#		### Statue of Roman Woman
#		### Four Tetrarchs Statue
#		### Hydraulic Organ
#		if = {
#			limit = {
#				has_ep3_dlc_trigger = yes
#				exists = title:e_byzantium.holder
#			}
#			title:e_byzantium.holder = {
#				create_artifact_statue_constantine_effect = { OWNER = this }
#				create_artifact_statue_roman_woman_effect = { OWNER = this }
#				create_artifact_statue_four_tetrarchs_effect = { OWNER = this }
#				create_artifact_hydraulic_organ_effect = { OWNER = this }
#			}
#		}
#		### Tree automa
#		if = {
#			limit = {
#				has_ep3_dlc_trigger = yes
#				exists = title:e_byzantium.holder
#				current_date >= 940.1.1
#			}
#			title:e_byzantium.holder = {
#				create_artifact_tree_automa_effect = { OWNER = this }
#			}
#		}
		### Spread some Orthodox icons
		every_county_in_region = {
			region = world_europe_east
			holder = {
				if = {
					limit = {
						faith.religion = religion:eastern_orthodox_religion
					}
					add_to_list = potential_icons_holders_list
				}
			}
		}
		every_county_in_region = {
			region = world_asia_minor
			holder = {
				if = {
					limit = {
						faith.religion = religion:eastern_orthodox_religion
					}
					add_to_list = potential_icons_holders_list
				}
			}
		}
		every_county_in_region = {
			region = world_europe_south_east
			holder = {
				if = {
					limit = {
						faith.religion = religion:eastern_orthodox_religion
					}
					add_to_list = potential_icons_holders_list
				}
			}
		}
		every_county_in_region = {
			region = world_europe_south_italy
			holder = {
				if = {
					limit = {
						faith.religion = religion:eastern_orthodox_religion
					}
					add_to_list = potential_icons_holders_list
				}
			}
		}
		if = {
			limit = {
				any_in_list = { list = potential_icons_holders_list }
			}
			while = {
				count = 4
				random_in_list = {
					list = potential_icons_holders_list
					limit = {
						NOT = { has_character_flag = seeded_relic }
					}
					create_artifact_trinket_icon_ancient_effect = { OWNER = this }
					add_character_flag = {
						flag = seeded_relic
						days = 1
					}
				}
			}
		}
#		#Imperial Seals
#		every_character_with_royal_court = {
#			limit = {
#				has_tgp_dlc_trigger = yes
#				is_independent_ruler = yes
#				government_allows = merit
#			}
#			create_artifact_dynastic_imperial_seal_effect = {
#				OWNER = this
#				SMITH = this
#			}
#		}
#		title:k_chrysanthemum_throne.holder ?= {
#			create_artifact_dynastic_imperial_seal_effect = {
#				OWNER = this
#				SMITH = this
#			}
#		}
#		#Heirloom Seal
#		#Only in 867
#		if = {
#			limit = {
#				has_tgp_dlc_trigger = yes
#				exists = title:h_china.holder
#				current_date <= 940.1.1
#			}
#			title:h_china.holder = {
#				create_artifact_heirloom_seal_effect = {
#					OWNER = this
#				}
#			}
#		}
#		#Armillary Sphere
#		if = {
#			limit = {
#				has_tgp_dlc_trigger = yes
#			}
#			title:h_china.holder = {
#				create_artifact_chinese_armillary_sphere_effect = {
#					OWNER = this
#				}
#			}
#		}
#		#Eight-Fold Chest
#		if = {
#			limit = {
#				has_tgp_dlc_trigger = yes
#			}
#			title:h_china.holder = {
#				create_artifact_eight_fold_chest_effect = {
#					OWNER = this
#				}
#			}
#		}
#		#Complete Military Classics
#		if = {
#			limit = {
#				has_tgp_dlc_trigger = yes
#				current_date > 1150.1.1 #Needs to be long past creation date for this to make sense
#			}
#			title:h_china.holder = {
#				create_artifact_military_classics_effect = {
#					OWNER = this
#				}
#			}
#		}
#		#Green Stone Amitabha Buddha Statue
#		if = {
#			limit = {
#				has_tgp_dlc_trigger = yes
#				current_date >= 1066.5.1
#			}
#			title:k_viet.holder = {
#				create_artifact_statue_viet_green_amitabha_buddha_effect = {
#					OWNER = this
#				}
#			}
#		}
	}
}


#Save a memorable battle as potential topic for artifacts
historical_artifacts.0100 = {
	hidden = yes
	scope = combat_side

	trigger = {
		# Check to ensure all needed scopes are valid
		exists = combat.location
		exists = side_primary_participant
		exists = enemy_side.side_primary_participant

		# Check if this battle was important enough to be memorialized
		calc_true_if = {
			amount >= 2
			any_in_list = {
				list = slain_combatants
				OR = {
					this = root.enemy_side.side_primary_participant
					is_heir_of = root.enemy_side.side_primary_participant
				}
			}
			any_in_list = {
				list = prisoners_of_war
				OR = {
					this = root.enemy_side.side_primary_participant
					is_heir_of = root.enemy_side.side_primary_participant
				}
			}
			troops_ratio <= 0.5
			num_enemies_killed >= 10000
			AND = {
				percent_enemies_killed >= 75
				combat = {
					num_total_troops >= 20000
				}
			}
			combat = {
				OR = {
					num_total_troops >= 30000
					warscore_value >= 25
				}
			}
		}
	}

	immediate = {
		side_primary_participant = {
			if = {
				limit = {
					exists = var:epic_battle_location
				}
				remove_variable = epic_battle_location
			}
			if = {
				limit = {
					exists = var:epic_loser
				}
				remove_variable = epic_loser
			}
			set_variable = {
				name = epic_battle_location
				value = root.combat.location
				years = 5
			}
			set_variable = {
				name = epic_loser
				value = root.enemy_side.side_primary_participant
				years = 5
			}
		}
	}
}
