namespace = fix_historical_artifacts

fix_historical_artifacts.0001 = {
    scope = none
	hidden = yes

    immediate = {
		### Extant artifacts of the Holy Roman Empire
		# Iron Crown of Lombardy for Louis the Younger, King of Italy
		if = {
			limit = {
				has_dlc_feature = royal_court
				exists = title:k_italy.holder
				game_start_date = 867.1.1
			}
			title:k_italy.holder = {
				create_artifact_pedestal_crown_iron_effect = { OWNER = this }
			}
		}
		# Throne of Charlemagne for Louis the Younger, titular Carolingian Emperor
		if = {
			limit = {
				has_dlc_feature = royal_court
				exists = title:k_italy.holder
				game_start_date = 867.1.1
			}
			title:k_italy.holder = {
				create_artifact_throne_charlemagne_effect = { OWNER = this }
			}
		}
		
		### Head of St. Edmund, held by the soon-to-be decapitated Duke Edmund
		if = {
			limit = {
				has_dlc_feature = royal_court
				exists = title:d_norfolk.holder
				game_start_date = 867.1.1
			}
			title:d_norfolk.holder = {
				create_artifact_edmund_head_effect = { OWNER = this }
			}
		}
		
		### Sword of God, held by Almos Arpad
		if = {
			limit = {
				has_dlc_feature = royal_court
				exists = title:d_yedisan.holder
				game_start_date = 867.1.1
			}
			title:d_yedisan.holder = {
				create_artifact_wall_sword_attila_effect = { OWNER = this }
			}
		}
		
		### Automata of Leo the Mathematician, active in 867
		# Byzantine Throne of Solomon
		if = {
			limit = {
				has_ep3_dlc_trigger = yes
				exists = title:e_byzantium.holder
				game_start_date = 867.1.1
			}
			title:e_byzantium.holder = {
				create_artifact_byz_throne_effect = { OWNER = this }
			}
		}
		# Tree Automata
		if = {
			limit = {
				has_ep3_dlc_trigger = yes
				exists = title:e_byzantium.holder
				game_start_date = 867.1.1
			}
			title:e_byzantium.holder = {
				create_artifact_tree_automa_effect = { OWNER = this }
			}
		}
		
		### Byzantine crowns
		# Monomachus Crown, held by Basileios I, ancestor of Zoe and Theodora (and starting emperor)
		if = {
			limit = {
				has_dlc_feature = royal_court
				exists = title:e_byzantium.holder
				game_start_date = 867.1.1
			}
			title:e_byzantium.holder = {
				create_artifact_monomachus_crown_effect = { OWNER = this }
			}
		}
		# Nikephoros' Crown, held by Nikephoros Phokas the Elder
		if = {
			limit = {
				game_start_date = 867.1.1
			}
			character:41316 = {
				create_artifact_nikephoros_crown_effect = { OWNER = this }
			}
		}
		
		### Fatimid Caliphate artifacts, held by Egypt outside of 1066
		## Less for historicity, more for gameplay
		# al-Taj al-Sharif
		if = {
			limit = {
				NOT = { game_start_date = 1066.9.15 }
				exists = title:k_egypt.holder
			}
			title:k_egypt.holder = {
				create_artifact_al_taj_crown_effect = { OWNER = this }
			}
		}
		# Qadib al-Mulk
		if = {
			limit = {
				NOT = { game_start_date = 1066.9.15 }
				exists = title:k_egypt.holder
			}
			title:k_egypt.holder = {
				create_artifact_qadib_al_mulk_effect = { OWNER = this }
			}
		}
		# al-Sayf al-Khass
		if = {
			limit = {
				has_dlc_feature = royal_court
				NOT = { game_start_date = 1066.9.15 }
				exists = title:k_egypt.holder
			}
			title:k_egypt.holder = {
				create_artifact_al_sayf_al_khass_effect = { OWNER = this }
			}
		}
		# al-Dawat
		if = {
			limit = {
				has_dlc_feature = royal_court
				NOT = { game_start_date = 1066.9.15 }
				exists = title:k_egypt.holder
			}
			title:k_egypt.holder = {
				create_artifact_al_dawat_effect = { OWNER = this }
			}
		}
		# al-Hafir
		if = {
			limit = {
				has_dlc_feature = royal_court
				NOT = { game_start_date = 1066.9.15 }
				exists = title:k_egypt.holder
			}
			title:k_egypt.holder = {
				create_artifact_al_hafir_effect = { OWNER = this }
			}
		}
		# Banner of Thankfulness
		if = {
			limit = {
				has_dlc_feature = royal_court
				NOT = { game_start_date = 1066.9.15 }
				exists = title:k_egypt.holder
			}
			title:k_egypt.holder = {
				create_artifact_wall_banner_thankfulness_effect = { OWNER = this }
			}
		}
    }
}