
on_game_start = {
	on_actions = {
		on_artifact_initialization
		on_monthly_artifacts
	}
}
on_death = {
	on_actions = {
		on_artifact_inheritance
	}
}

on_monthly_artifacts = {
	effect = {
		every_artifact_holder = { #Equips Artifacts
			limit = { is_ai = yes }
			equip_all_owned_artifacts = {} #Crudely equips all artifacts in the order defined in common/scripted_effects/artifacts_custom.txt.
		}
	}
	on_actions = {
		delay = { months = 1 }
		on_monthly_artifacts
	}
}

on_artifact_initialization = { # Can be called by the scripted effect "initialize_artifacts" 
	effect = { # Add any artifact-specific setup that you don't want to put in your on_game_start.
	# For example, in vanilla:
		listify_all_typed_artifacts_as_flags = yes
		character:1316 = { #HRE 1066 ARTIFACTS
			add_artifact = {ARTIFACT = artifact_1}
			add_artifact = {ARTIFACT = artifact_3}
		}

		character:1732 = { #BYZANTINE 1066 ARTIFACTS
			add_artifact = {ARTIFACT = artifact_2}
		}

		character:1700 = { #BYZANTINE 867 ARTIFACTS
			add_artifact = {ARTIFACT = artifact_2}
		}

		character:30228 = { #LOMBARD 867 ARTIFACTS
			add_artifact = {ARTIFACT = artifact_3}
		}
	}
}


on_artifact_inheritance = {
	effect = {
		save_temporary_scope_as = root_character
		if = {
			limit = { exists = scope:killer }
			transfer_all_artifacts = { A = root B = scope:killer }	
		}
		else_if = {
			limit = { exists = root.primary_heir }
			transfer_all_artifacts = {A = root B = root.primary_heir}
		}
		else_if = {
			limit = { exists = root.liege_or_court_owner }
			transfer_all_artifacts = {A = root B = root.liege_or_court_owner}
		}
		else = {
			transfer_all_artifacts = {A = root B = root.location.barony_controller }
		}
	}
}