﻿# Historical Artifacts Creation #

set_armor_artifact_type_effect = {
	save_temporary_scope_value_as = {
		name = allow_no_type_option
		value = $NO_TYPE$
	}
	# Historically many of these types of armor were used in some combination, but to give a clearer portrayal to the player we have to simplify it a bit
	hidden_effect = {
		$BASE_SCOPE$ = {
			#The type has been decided in events, when the character got inspired, or now. Let's save it! (might still leave it up to the sponsor if allow_no_type_option = yes!)
			if = {
				limit = {
					NOT = { exists = var:artifact_armor_type }
				}
				random_list = { #What do they want to forge?
					50 = { #Fairly common everywhere
						artifact_armor_type_mail_modifier = yes
						set_variable = {
							name = artifact_armor_type
							value = flag:armor_type_mail
						}
					}
					1 = { #Expensive
						artifact_armor_type_plate_modifier = yes
						set_variable = {
							name = artifact_armor_type
							value = flag:armor_type_plate
						}
						modifier = {
							factor = 0
							culture = {
								NOT = { has_innovation = innovation_plate_armor }
							}
						}
						modifier = {
							factor = 300
							culture = {
								current_date > 1200.1.1
							}
						}
					}
					50 = { #Fairly common everywhere
						artifact_armor_type_scale_modifier = yes
						set_variable = {
							name = artifact_armor_type
							value = flag:armor_type_scale
						}
					}
					5 = { #Expensive
						artifact_armor_type_lamellar_modifier = yes
						set_variable = {
							name = artifact_armor_type
							value = flag:armor_type_lamellar
						}
					}
					5 = {
						artifact_armor_type_laminar_modifier = yes
						set_variable = {
							name = artifact_armor_type
							value = flag:armor_type_laminar
						}
					}
					0 = {
						artifact_armor_type_brigandine_modifier = yes
						set_variable = {
							name = artifact_armor_type
							value = flag:armor_type_brigandine
						}
					}
					50 = { #They don't care and you can decide!
						trigger = {
							scope:allow_no_type_option = yes
						}
						modifier = {
							add = 30
							has_personality_submissive_trigger = yes
						}
						modifier = {
							add = 9916 # ~1% chance of being predetermined if comissioning from a local artisan.
							has_character_flag = local_artisan
						}
						ai_value_modifier = {
							ai_boldness = -0.25
							ai_energy = -0.25
						}
					}
				}
			}
		}
	}
}

create_artifact_pedestal_christian_relic_effect_hist = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	get_artifact_quality_effect = yes
	get_artifact_wealth_effect = yes

	# Identify which relic it is
	random_list = {
		10 = {
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:nail
			}
		}
		10 = {
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:thorn
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = christian_sandals
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:sandals
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = christian_girdle
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:girdle
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = christian_lance
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:lance
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						count > 5
						has_variable = christian_skull
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:skull
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						count > 5
						has_variable = christian_arm
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:arm
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = christian_loincloth
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:loincloth
			}
		}
		10 = {
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:cross
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = christian_crown
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:crown
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = christian_veil
					}
				}
			}
			save_scope_value_as = {
				name = christian_relic_name
				value = flag:veronica
			}
		}
	}

	# Create the artifact
	if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:lance
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_spear_destiny_name
			description = artifact_pedestal_spear_destiny
			type = pedestal
			template = christian_artifact_template
			visuals = pedestal_longinus
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
			decaying = no
		}
	}
	else_if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:veronica
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = veronica
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:crown
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = crown_christian
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:loincloth
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = loincloth_of_jesus
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:girdle
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = girdle_of_jesus
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:sandals
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = sandals_of_jesus
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:christian_relic_name
			scope:christian_relic_name = flag:skull
		}
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = human_skull
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else = {
		create_artifact = {
			name = artifact_pedestal_reliquary_christian_name
			description = artifact_pedestal_reliquary_christian_description
			type = pedestal
			wealth = scope:wealth
			quality = scope:quality
			template = christian_artifact_template
			visuals = reliquary
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:christian
		}
		if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:veronica
			}
			set_variable = christian_veil
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:crown
			}
			set_variable = christian_crown
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:loincloth
			}
			set_variable = christian_loincloth
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:lance
			}
			set_variable = christian_lance
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:arm
			}
			set_variable = christian_arm
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:sandals
			}
			set_variable = christian_sandals
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:girdle
			}
			set_variable = christian_girdle
		}
		else_if = {
			limit = {
				exists = scope:christian_relic_name
				scope:christian_relic_name = flag:skull
			}
			set_variable = christian_skull
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		add_artifact_modifier = artifact_monthly_prestige_penalty_modifier #overwrite default creation modifier
		save_scope_as = epic
	}
}

create_artifact_pedestal_islamic_relic_effect_hist = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	get_artifact_quality_effect = yes
	get_artifact_wealth_effect = yes

	# Identify which relic it is
	random_list = {
		10 = {
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:hair
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = islam_cloak
					}
				}
			}
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:cloak
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = islam_hand
					}
				}
			}
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:hand
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = islam_keys
					}
				}
			}
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:keys
			}
		}
		10 = {
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:tooth
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = islam_seal
					}
				}
			}
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:seal
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = islam_banner
					}
				}
			}
			save_scope_value_as = {
				name = islam_relic_name
				value = flag:banner
			}
		}
	}

	# Create the artifact
	if = {
		limit = {
			exists = scope:islam_relic_name
			scope:islam_relic_name = flag:banner
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_banner_islam_name
			description = artifact_banner_islam_description
			type = wall_big
			template = islam_artifact_template
			visuals = banner_islam
			visuals_source = title:d_shiite #Caliphate
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:islam_relic_name
			scope:islam_relic_name = flag:cloak
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_islam_name
			description = artifact_pedestal_reliquary_islam_description
			type = pedestal
			template = islam_artifact_template
			visuals = cloak_muhammad
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:islam_relic_name
			scope:islam_relic_name = flag:hand
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_islam_name
			description = artifact_pedestal_reliquary_islam_description
			type = pedestal
			template = islam_artifact_template
			visuals = hand_islam
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:islam_relic_name
			scope:islam_relic_name = flag:keys
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_islam_name
			description = artifact_pedestal_reliquary_islam_description
			type = pedestal
			template = islam_artifact_template
			visuals = keys_kaaba
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:islam_relic_name
			scope:islam_relic_name = flag:seal
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_islam_name
			description = artifact_pedestal_reliquary_islam_description
			type = pedestal
			template = islam_artifact_template
			visuals = seal_muhammad
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}	
	else = {
		create_artifact = {	
			name = artifact_pedestal_reliquary_islam_name
			description = artifact_pedestal_reliquary_islam_description
			type = pedestal
			template = islam_artifact_template
			visuals = reliquary
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:islamic
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		add_artifact_modifier = artifact_monthly_prestige_penalty_modifier #overwrite default creation modifier
		if = {
			limit = {
				exists = scope:islam_relic_name
				scope:islam_relic_name = flag:cloak
			}
			set_variable = islam_cloak
		}
		else_if = {
			limit = {
				exists = scope:islam_relic_name
				scope:islam_relic_name = flag:seal
			}
			set_variable = islam_seal
		}
		else_if = {
			limit = {
				exists = scope:islam_relic_name
				scope:islam_relic_name = flag:keys
			}
			set_variable = islam_keys
		}
		else_if = {
			limit = {
				exists = scope:islam_relic_name
				scope:islam_relic_name = flag:hand
			}
			set_variable = islam_hand
		}
		else_if = {
			limit = {
				exists = scope:islam_relic_name
				scope:islam_relic_name = flag:banner
			}
			set_variable = islam_banner
		}
		add_scaled_artifact_modifier_devotion_effect = yes
		save_scope_as = epic
	}
}

create_artifact_pedestal_buddhism_relic_effect_hist = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	get_artifact_quality_effect = yes
	get_artifact_wealth_effect = yes

	# Identify which relic it is
	random_list = {
		10 = {
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:tooth
			}
		}
		10 = {
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:bone
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = buddhism_robe
					}
				}
			}
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:robe
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = buddhism_bowl
					}
				}
			}
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:bowl
			}
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = buddhism_tongue
					}
				}
			}
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:tongue
			}
		}
		10 = {
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:hair
			}
		}
		10 = {
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:sarira
			}
		}
		10 = {
			save_scope_value_as = {
				name = buddhism_relic_name
				value = flag:bo
			}
		}
	}

	# Create the artifact
	if = {
		limit = {
			exists = scope:buddhism_relic_name
			scope:buddhism_relic_name = flag:robe
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_buddhism_name
			description = artifact_pedestal_reliquary_buddhism_description
			type = pedestal
			template = buddhism_artifact_template
			visuals = robe_buddha
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	if = {
		limit = {
			exists = scope:buddhism_relic_name
			scope:buddhism_relic_name = flag:bowl
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_buddhism_name
			description = artifact_pedestal_reliquary_buddhism_description
			type = pedestal
			template = buddhism_artifact_template
			visuals = bowl_buddha
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	if = {
		limit = {
			exists = scope:buddhism_relic_name
			scope:buddhism_relic_name = flag:tongue
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_buddhism_name
			description = artifact_pedestal_reliquary_buddhism_description
			type = pedestal
			template = buddhism_artifact_template
			visuals = tongue_buddha
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else_if = {
		limit = {
			exists = scope:buddhism_relic_name
			scope:buddhism_relic_name = flag:tooth
		}
		set_artifact_rarity_illustrious = yes
		create_artifact = {	
			name = artifact_pedestal_reliquary_buddhism_name
			description = artifact_pedestal_reliquary_buddhism_description
			type = pedestal
			template = buddhism_artifact_template
			visuals = buddha_tooth
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}
	else = {
		create_artifact = {	
			name = artifact_pedestal_reliquary_buddhism_name
			description = artifact_pedestal_reliquary_buddhism_description
			type = pedestal
			template = buddhism_artifact_template
			visuals = pedestal_buddhism_relic
			wealth = scope:wealth
			quality = scope:quality
			history = {
				type = created_before_history
			}
			modifier = artifact_placeholder_modifier
			save_scope_as = newly_created_artifact
		}
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:buddhism
		}
		if = {
			limit = {
				exists = scope:buddhism_relic_name
				scope:buddhism_relic_name = flag:tongue
			}
			set_variable = buddhism_tongue
		}
		else_if = {
			limit = {
				exists = scope:buddhism_relic_name
				scope:buddhism_relic_name = flag:bowl
			}
			set_variable = buddhism_bowl
		}
		else_if = {
			limit = {
				exists = scope:buddhism_relic_name
				scope:buddhism_relic_name = flag:robe
			}
			set_variable = buddhism_robe
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		add_artifact_modifier = artifact_monthly_prestige_penalty_modifier #overwrite default creation modifier
		save_scope_as = epic
	}
}

create_artifact_pedestal_branch_relic_zoroastr_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	# Identify which relic it is
	random_list = {
		10 = {
			save_scope_value_as = {
				name = branch_name
				value = flag:haoma
			}
		}
		10 = {
			save_scope_value_as = {
				name = branch_name
				value = flag:cypress
			}
		}
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_branch_name
		description = artifact_pedestal_branch_description
		type = pedestal
		visuals = pedestal_branch_relic_zoroastr
		wealth = scope:wealth
		quality = scope:quality
		template = branch_zoroastr_template
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:zoroastr
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		add_artifact_modifier = artifact_monthly_prestige_penalty_modifier #overwrite default creation modifier
		save_scope_as = epic
	}
}

create_artifact_pedestal_branch_relic_germanic_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	# Identify which relic it is
	random_list = {
		10 = {
			save_scope_value_as = {
				name = branch_name
				value = flag:thor
			}
		}
		10 = {
			save_scope_value_as = {
				name = branch_name
				value = flag:uppsala
			}
		}
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_branch_name
		description = artifact_pedestal_branch_description
		type = pedestal
		template = branch_germanic_template
		visuals = pedestal_branch_relic_germanic
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:germanic
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		save_scope_as = epic
	}
}

create_artifact_pedestal_branch_relic_slavic_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	save_scope_value_as = {
		name = branch_name
		value = flag:alatyr
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_branch_name
		description = artifact_pedestal_branch_description
		type = pedestal
		template = branch_slavic_template
		visuals = pedestal_branch_relic_slavic
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:slavic
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		save_scope_as = epic
	}
}

create_artifact_pedestal_branch_relic_boog_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	save_scope_value_as = {
		name = branch_name
		value = flag:somb
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_branch_name
		description = artifact_pedestal_branch_description
		type = pedestal
		template = branch_boog_template
		visuals = pedestal_branch_relic_boog
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:boog
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		add_artifact_modifier = artifact_monthly_prestige_penalty_modifier #overwrite default creation modifier
		save_scope_as = epic
	}
}

create_artifact_pedestal_branch_relic_hinduism_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	save_scope_value_as = {
		name = branch_name
		value = flag:kalpavriksha
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_branch_name
		description = artifact_pedestal_branch_description
		type = pedestal
		template = branch_hinduism_template
		visuals = pedestal_branch_relic_hinduism
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:hinduism
		}
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		save_scope_as = epic
	}
}

create_artifact_pedestal_branch_relic_general_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	save_scope_value_as = {
		name = branch_name
		value = flag:general
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_branch_name
		description = artifact_pedestal_branch_description
		type = pedestal
		template = branch_general_template
		visuals = pedestal_branch_relic_hinduism
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = {	#This is needed to determine what religion the branch will work for.
			name = relic_religion
			value = $RELIGION$
		}
		set_variable = { name = historical_unique_artifact value = yes }
		add_scaled_artifact_modifier_piety_effect = yes
		add_scaled_artifact_modifier_grandeur_small_effect = yes
		if = {
			limit = {
				OR = {
					rarity = famed
					rarity = illustrious
				}
			}
			add_2_scaled_artifact_modifier_devotion_effect = yes
			
		}
		else = {
			add_scaled_artifact_modifier_devotion_effect = yes
		}
		save_scope_as = epic
	}
}

#Common Artifacts

create_artifact_excalibur_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_common = yes

	# Create the artifact
	create_artifact = {
		name = excalibur_name
		description = excalibur_description
		type = pedestal
		visuals = excalibur
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = excalibur_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = excalibur
		save_scope_as = epic
	}
}

create_artifact_edmund_head_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = edmund_head_name
		description = edmund_head_description
		type = pedestal
		visuals = head
		wealth = scope:wealth
		quality = scope:quality
		template = christian_relic_template
		history = {
			type = created
			date = 869.11.20
			recipient = character:163064 #Eadmund the Martyr
			location = province:1520 #Blything
		}
		modifier = edmund_head_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = edmund_head
		add_scaled_artifact_modifier_devotion_effect = yes
		set_variable = {
			name = relic
			value = flag:christian
		}
		save_scope_as = epic
		add_artifact_history = {
			type = given
			date = 946.5.27
			recipient = character:33350 # Æthelstan
		}
		add_artifact_title_history = {
			target = title:k_england
			date = 955.11.24
		}
	}
}

create_artifact_makarakundala_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection

	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_makarakundala_name
		description = artifact_makarakundala_description
		type = pedestal
		visuals = makarakundala
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = makarakundala_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = makarakundala
		add_scaled_artifact_modifier_devotion_effect = yes
		save_scope_as = epic
	}
}

#Masterwork Artifacts

create_artifact_ibeji_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_ibeji_name
		description = artifact_ibeji_description
		template = general_unique_template
		type = pedestal
		visuals = ibeji
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = ibeji_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = ibeji
		add_scaled_artifact_modifier_devotion_effect = yes
		save_scope_as = epic
	}
}

create_artifact_chinese_caligraphy_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {
		type = pedestal
		visuals = scroll
		wealth = scope:wealth
		template = general_unique_template
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = caligraphy_modifier
		save_scope_as = newly_created_artifact
		name = artifact_chinese_caligraphy_name
		description = artifact_chinese_caligraphy_description
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = chinese_caligraphy
		add_2_scaled_artifact_modifier_rulership_effect = yes
		save_scope_as = epic
	}
}

create_artifact_throne_charlemagne_effect = { #Create at start
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_throne_charlemagne_name
		description = artifact_throne_charlemagne_description
		type = throne_special
		visuals = throne_charlemagne
		wealth = scope:wealth
		quality = scope:quality
		template = throne_charlemagne_template
		history = {
			type = created
			date = 800.12.25
			recipient = character:6392 #Karl I the Great
			location = province:2092 #Aachen
		}
		modifier = throne_charlemagne_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = charlamagne_throne
		# k_lotharingia history copied manually because it is destroyed before 1066
		add_artifact_history = {
			type = inherited
			date = 814.1.2
			recipient = character:90095 #Louis I
		}
		add_artifact_history = {
			type = inherited
			date = 817.1.1
			recipient = character:30227 #Lothair I
		}
		add_artifact_title_history = {
			target = title:e_hre
			date = 973.5.7
		}
		add_scaled_artifact_modifier_majesty_effect = yes
		add_scaled_artifact_modifier_rulership_effect = yes
		save_scope_as = epic
		save_scope_value_as = {
			name = throne
			value = yes
		}
	}
}

create_artifact_throne_solomon_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_throne_solomon_name
		description = artifact_throne_solomon_description
		type = throne_special
		visuals = throne_solomon
		wealth = scope:wealth
		quality = scope:quality
		template = throne_solomon_template
		history = {
			type = created_before_history
		}
		modifier = throne_solomon_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = throne_of_solomon
		save_scope_as = epic
		add_scaled_artifact_modifier_majesty_effect = yes
		add_scaled_artifact_modifier_rulership_effect = yes
		add_scaled_artifact_modifier_devotion_effect = yes
		save_scope_value_as = {
			name = throne
			value = yes
		}
	}
}

create_artifact_throne_scone_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_throne_stone_scone_name
		description = artifact_throne_stone_scone
		type = throne_special
		visuals = throne_scone
		wealth = scope:wealth
		quality = scope:quality
		template = throne_scone_template
		history = {
			type = created
			date = 841.6.1
			recipient = character:6018 #Kenneth mac Ailpín
			location = province:1742 #Scone
		}
		modifier = throne_scone_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = throne_scone
		save_scope_as = epic
		add_scaled_artifact_modifier_rulership_effect = yes
		save_scope_value_as = {
			name = throne
			value = yes
		}
		add_artifact_title_history = {
			target = title:k_scotland
			date = 858.1.1
		}
	}
}

create_artifact_wall_banner_kaviani_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_wall_banner_kaviani_name
		description = artifact_wall_banner_kaviani
		type = wall_big
		template = kaviani_template
		visuals = banner
		visuals_source = dynasty:jamshid
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = banner_kaviani_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = banner_kaviani
		save_scope_as = epic
	}
}

create_artifact_sculpture_cabinet_pentapyrgion_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_sculpture_cabinet_pentapyrgion_name
		description = artifact_sculpture_cabinet_pentapyrgion_description
		type = sculpture
		visuals = sculpture_cabinet_pentapyrgion
		template = pentapyrgion_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 839.6.1
			recipient = character:70491 #Theophilos
			location = province:496 #Constantinople
		}
		modifier = pentapyrgion_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		add_artifact_title_history = {
			target = title:e_byzantium
			date = 842.1.20
		}
		save_scope_value_as = {
			name = cupboard
			value = yes
		}
	}
}

create_artifact_monomachus_crown_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = monomachus_crown_name
		description = monomachus_crown_description
		template = general_unique_template
		type = helmet
		visuals = pedestal_justinian
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 1042.6.11
			recipient = character:1726 #Konstantinos IX
			location = province:496 #Constantinople
		}
		modifier = monomachus_crown_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		save_scope_as = epic
		add_artifact_title_history = {
			target = title:e_byzantium
			date = 1055.1.11
		}
	}
}

create_artifact_ruyi_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_ruyi_name
		description = artifact_ruyi_description
		type = pedestal
		visuals = ruyi
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = ruyi_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = ruyi
		save_scope_as = epic
	}
}

create_artifact_jewelled_danda_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_jewelled_danda_name
		description = artifact_jewelled_danda_description
		type = regalia_simple
		visuals = a_arp_jeweled_danda
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = jewelled_danda_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		add_2_scaled_artifact_modifier_rulership_effect = yes
		add_scaled_artifact_modifier_scholarship_effect = yes
		set_variable = danda
		save_scope_as = epic
	}
}

create_artifact_khanda_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_khanda_name
		description = artifact_khanda_description
		template = branch_hinduism_template
		type = pedestal
		visuals = wall_khanda_sword
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = khanda_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = khanda
		set_variable = {
			name = relic
			value = flag:hinduism
		}
		save_scope_as = epic
	}
}

create_artifact_dagger_of_rostam_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_dagger_of_rostam_name
		description = artifact_dagger_of_rostam_description
		type = pedestal
		visuals = a_arp_dagger_of_rostam
		template = general_unique_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = rustam_dagger_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = dagger_of_rostam
		save_scope_as = epic
	}
}

create_artifact_ascalon_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_spear_of_ascalon_name
		description = artifact_spear_of_ascalon_description
		type = pedestal
		visuals = a_arp_ascalon
		template = general_unique_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = spear_ascalon_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = ascalon
		set_variable = {
			name = relic
			value = flag:christian
		}
		save_scope_as = epic
	}
}

create_artifact_zomorrodnegar_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_zomorrodnegar_name
		description = artifact_zomorrodnegar_description
		type = pedestal
		visuals = a_arp_shamshir_e_zomorrodnegar
		template = general_unique_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = zomorrodnegar_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = zomorrodnegar
		save_scope_as = epic
	}
}

create_artifact_kaves_apron_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_kaves_apron_name
		description = artifact_kaves_apron_description
		type = wall_big
		visuals = a_arp_kaves_apron
		visuals_source = dynasty:jamshid
		template = general_unique_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = kaves_apron_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = kaves_apron
		save_scope_as = epic
	}
}

create_artifact_muhammads_epistles_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {
		type = pedestal
		visuals = scroll
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
		template = islam_artifact_template
		name = artifact_muhammads_epistles_name
		description = artifact_muhammads_epistles_description
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = muhammads_epistles
		add_scaled_artifact_modifier_devotion_effect = yes
		add_scaled_artifact_modifier_combat_effect = yes
		set_variable = {
			name = relic
			value = flag:islamic
		}
		save_scope_as = epic
	}
}

create_artifact_aruval_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_aruval_name
		description = artifact_aruval_description
		type = pedestal
		visuals = a_arp_ancient_aruval
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		template = branch_hinduism_template
		modifier = aruval_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = aruval
		set_variable = {
			name = relic
			value = flag:hinduism
		}
		save_scope_as = epic
	}
}

create_artifact_navaratna_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_navaratna_name
		description = artifact_navaratna_description
		visuals = a_arp_navaratna
		type = necklace
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = navaratna_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = navaratna
		get_artifact_feature_references_effect = yes
		save_scope_as = epic
	}
}

create_artifact_pedestal_ikenga_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_ikenga_name
		description = artifact_ikenga_description
		type = pedestal
		visuals = a_arp_ikenga
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = ikenga_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = ikenga
		save_scope_as = epic
	}
}

create_artifact_afarganyu_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = afarganyu_name
		description = artifact_afarganyu_description
		template = branch_zoroastr_template
		type = urn
		visuals = a_arp_afarganyu
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = afarganyu_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:zoroastr
		}
		save_scope_as = epic
	}
}

create_artifact_siddhachakra_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_masterwork = yes

	# Create the artifact
	create_artifact = {	
		name = siddhachakra_name
		description = artifact_siddhachakra_description
		template = jainism_artifact_template
		type = pedestal
		visuals = a_arp_siddhachakra
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = siddhachakra_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:jainism
		}
		save_scope_as = epic
	}
}

create_artifact_staff_kakusandha_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_staff_kakusandha
		description = artifact_staff_kakusandha_desc
		type = pedestal
		visuals = a_arp_staff_of_kakusandha
		wealth = scope:wealth
		quality = scope:quality
		template = buddhism_artifact_template
		history = {
			type = created_before_history
		}
		modifier = kakusandha_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = staff_kakusandha
		set_variable = {
			name = relic
			value = flag:buddhism
		}
		save_scope_as = epic
	}
}

create_artifact_konagamana_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = water_filter_konagamana
		description = water_filter_konagamana_desc
		type = pedestal
		visuals = a_arp_water_filter_of_konagamana
		wealth = scope:wealth
		quality = scope:quality
		template = buddhism_artifact_template
		history = {
			type = created_before_history
		}
		modifier = konagamana_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = konagamana
		set_variable = {
			name = relic
			value = flag:buddhism
		}
		save_scope_as = epic
	}
}

create_artifact_robe_kassapa_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = robe_kassapa
		description = robe_kassapa_desc
		template = buddhism_artifact_template
		type = pedestal
		visuals = a_arp_piece_of_kassapas_robe
		wealth = scope:wealth
		quality = scope:quality
		template = buddhism_artifact_template
		history = {
			type = created_before_history
		}
		modifier = kassapa_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = kassapa
		set_variable = {
			name = relic
			value = flag:buddhism
		}
		save_scope_as = epic
	}
}

#Famed Artifacts

create_artifact_reichskrone_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = reichskrone_name
		description = reichskrone_description
		type = helmet
		visuals = hre_crown
		wealth = scope:wealth
		quality = scope:quality
		template = reichskrone_template
		history = {
			type = created
			date = 962.1.1
			recipient = character:1282 #Otto I
			location = province:2092 #Aachen
		}
		modifier = reichskrone_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = artifact_succession_title
			value = title:e_hre
		}
		add_artifact_title_history = {
			target = title:e_hre
			date = 962.1.1
		}
		set_variable = {
			name = reichskrone
			value = yes
		}
		save_scope_as = epic
	}
}

create_artifact_cintamani_hindu_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_cintamani_name
		description = artifact_cintamani_hindu_description
		type = pedestal
		visuals = a_arp_cintamani_stone
		wealth = scope:wealth
		quality = scope:quality
		template = branch_hinduism_template
		history = {
			type = created_before_history
		}
		modifier = cintamani_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = cintamani_hindu
		set_variable = {
			name = relic
			value = flag:hinduism
		}
	}
}

create_artifact_cintamani_buddhist_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_cintamani_name
		description = artifact_cintamani_buddhist_description
		type = pedestal
		visuals = a_arp_cintamani_stone
		wealth = scope:wealth
		quality = scope:quality
		template = buddhism_artifact_template
		history = {
			type = created_before_history
		}
		modifier = cintamani_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = cintamani_buddhist
		set_variable = {
			name = relic
			value = flag:buddhism
		}
	}
}

create_artifact_wall_banner_edessa_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_wall_big_edessa_name
		description = artifact_wall_big_edessa
		type = pedestal
		visuals = reliquary
		wealth = scope:wealth
		quality = scope:quality
		template = edessa_template
		history = {
			type = created_before_history
			location = province:4869 #Edessa
		}
		modifier = banner_of_edessa_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = banner_edessa
		set_variable = {
			name = relic
			value = flag:christian
		}
		save_scope_as = epic
	}
}

create_artifact_wall_cid_sword_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {
		name = artifact_wall_cid_sword_name
		description = artifact_wall_el_cids_sword
		type = pedestal
		visuals = wall_cid_sword
		wealth = scope:wealth
		quality = scope:quality
		template = tizona_template
		history = {
			type = created_before_history
		}
		modifier = tizona_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		add_artifact_history = {
			type = won_in_duel
			date = 1097.1.1
			recipient = character:107590 #El Cid
		}
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = sword_cid
		save_scope_as = epic
	}
}

create_artifact_wall_muhammad_sword_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Identify which sword it is
	random_list = {
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_aladb
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:aladb
			}
			set_variable = sword_muhammad_aladb
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_almathur
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:almathur
			}
			set_variable = sword_muhammad_almathur
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_arrasub
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:arrasub
			}
			set_variable = sword_muhammad_arrasub
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_albattar
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:albattar
			}
			set_variable = sword_muhammad_albattar
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_haft
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:haft
			}
			set_variable = sword_muhammad_haft
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_qali
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:qali
			}
			set_variable = sword_muhammad_qali
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_dhu
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:dhu
			}
			set_variable = sword_muhammad_dhu
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_mikhdham
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:mikhdham
			}
			set_variable = sword_muhammad_mikhdham
		}
		10 = {
			trigger = {
				NOT = {
					any_artifact = {
						has_variable = sword_muhammad_alqadib
					}
				}
			}
			save_scope_value_as = {
				name = muhammad_sword_name
				value = flag:alqadib
			}
			set_variable = sword_muhammad_alqadib
		}
	}

	# Create the artifact
	create_artifact = {	
		name = artifact_wall_sword_muhammad_name
		description = artifact_wall_sword_muhammad
		type = pedestal
		visuals = wall_muhammad_sword
		wealth = scope:wealth
		quality = scope:quality
		template = muhammad_sword_template
		history = {
			type = created_before_history
		}
		modifier = muhammed_sword_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = sword_of_muhammad
		save_scope_as = muhammad_sword
		set_variable = {
			name = relic
			value = flag:islamic
		}
		random_list = {
			pick = 2
			unique = yes
			10 = {
				add_artifact_modifier = muhammed_sword_1_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_2_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_3_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_4_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_5_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_6_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_7_modifier
			}
			10 = {
				add_artifact_modifier = muhammed_sword_8_modifier
			}
		}
	}
	if = {
		limit = {
			scope:muhammad_sword_name = flag:aladb
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = given
				date = 624.3.13
				recipient = character:33922 #Muhammad the Prophet
			}
		}
	}
	if = {
		limit = {
			scope:muhammad_sword_name = flag:almathur
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = inherited
				date = 570.6.1
				recipient = character:33922 #Muhammad the Prophet
			}
		}
	}
	if = {
		limit = {
			scope:muhammad_sword_name = flag:arrasub
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = inherited
				date = 570.6.1
				recipient = character:33922 #Muhammad the Prophet
			}
		}
	}
	if = {
		limit = {
			OR = {
				scope:muhammad_sword_name = flag:albattar
				scope:muhammad_sword_name = flag:haft
				scope:muhammad_sword_name = flag:qali
			}
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = conquest
				date = 622.5.1
				recipient = character:33922 #Muhammad the Prophet
				location = province:718
			}
		}
	}
	if = {
		limit = {
			scope:muhammad_sword_name = flag:dhu
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = conquest
				date = 624.3.13
				recipient = character:33922 #Muhammad the Prophet
				location = province:6210 #Al-Jar
			}
		}
	}
	if = {
		limit = {
			scope:muhammad_sword_name = flag:mikhdham
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = given
				date = 610.1.1
				recipient = character:33922 #Muhammad the Prophet
			}
		}
	}
	if = {
		limit = {
			scope:muhammad_sword_name = flag:alqadib
		}
		scope:muhammad_sword = {
			add_artifact_history = {
				type = given
				date = 610.1.1
				recipient = character:33922 #Muhammad the Prophet
			}
		}
	}
	scope:muhammad_sword = {
		save_scope_as = epic
	}
}

create_artifact_sword_mmaagha_kamalu_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_mmaagha_kamalu_name
		description = artifact_mmaagha_kamalu_description
		type = pedestal
		visuals = sword_court
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = mmaagha_kamalu_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = mmaagha_kamalu
		save_scope_as = epic
	}
}

create_artifact_bronze_head_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_bronze_head_name
		description = artifact_bronze_head_description
		type = pedestal
		visuals = a_arp_bronze_head
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = bronze_head_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = bronze_head
		save_scope_as = epic
	}
}

create_artifact_crystal_carving_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_crystal_carving_name
		description = artifact_crystal_carving_description
		type = pedestal
		visuals = a_arp_crystal_carving
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = crystal_carving_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = crystal_carving
		save_scope_as = epic
	}
}

create_artifact_wall_sword_attila_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_wall_sword_attila_name
		description = artifact_wall_sword_attila_description
		type = pedestal
		template = attila_template
		visuals = wall_sword_attila
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = attila_sword_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = sword_attila
		save_scope_as = epic
	}
}

create_artifact_pedestal_great_diamond_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_great_diamond_name
		description = artifact_pedestal_great_diamond_description
		type = pedestal
		template = general_unique_template
		visuals = a_arp_great_diamond
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = great_diamond_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = great_diamond
		save_scope_as = epic
	}
}

create_artifact_pedestal_al_jabal_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_al_jabal_name
		description = artifact_pedestal_al_jabal_description
		type = pedestal
		visuals = a_arp_al_jabal
		template = general_unique_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = al_jabal_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = al_jabal
		save_scope_as = epic
	}
}

create_artifact_pedestal_al_yatima_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_al_yatima_name
		description = artifact_pedestal_al_yatima_description
		type = pedestal
		visuals = a_arp_al_yatima
		template = general_unique_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = al_yatima_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = al_yatima
		save_scope_as = epic
	}
}

create_artifact_pedestal_cup_jamshid_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_jamshid_name
		description = artifact_pedestal_cup_jamshid
		type = pedestal
		template = cup_jamshid_template
		visuals = pedestal_cup_jamshid
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = cup_jamshid_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = cup_jamshid
		save_scope_as = epic
	}
}

create_artifact_pedestal_crown_iron_effect = { #Create at start
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_crown_iron_name
		description = artifact_pedestal_crown_iron
		type = pedestal
		template = crown_iron_template
		visuals = pedestal_crown_iron
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 313.2.1
			recipient = character:70523 #Konstantinos I the Great
			location = province:496 #Constantinople
		}
		modifier = iron_crown_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = iron_crown
		add_artifact_history = {
			type = given
			date = 600.1.1
			actor = character:7893
			recipient = character:190171
			location = province:2475
		}
		add_artifact_history = {
			type = given
			date = 774.7.10
			recipient = character:6392
			location = province:2475
		}
		add_artifact_history = {
			type = given
			date = 781.1.1
			recipient = character:6394
			location = province:2475
		}
		add_artifact_history = {
			type = inherited
			date = 810.1.1
			recipient = character:6396
			location = province:2475
		}
		add_artifact_history = {
			type = inherited
			date = 818.4.17
			recipient = character:90095
			location = province:2475
		}
		add_artifact_history = {
			type = inherited
			date = 887.1.1
			recipient = character:71901
			location = province:2475
		}
		# k_italy history copied manually because it is destroyed before 1066
		add_artifact_history = {
			type = inherited
			date = 896.1.1
			recipient = character:167969 #Liutfrido
		}
		add_artifact_history = {
			type = inherited
			date = 905.3.1
			recipient = character:167970 #Gotofredo
		}
		add_artifact_history = {
			type = inherited
			date = 910.8.4
			recipient = character:167971 #Gausberto
		}
		add_artifact_history = {
			type = inherited
			date = 940.1.1
			recipient = character:167972 #Uberto
		}
		add_artifact_history = {
			type = inherited
			date = 941.11.1
			recipient = character:167973 #Adalberto
		}
		add_artifact_history = {
			type = inherited
			date = 967.1.1
			recipient = character:7727 #Aleramo Aleramicci
		}
		add_artifact_history = {
			type = inherited
			date = 991.1.1
			recipient = character:7728 #Ottone I
		}
		add_artifact_history = {
			type = inherited
			date = 991.6.1
			recipient = character:7729 #Guglielmo I
		}
		add_artifact_history = {
			type = inherited
			date = 941.11.1
			recipient = character:167973 #Adalberto
		}
		add_artifact_title_history = {
			target = title:e_hre
			date = 1039.2.4
		}
		save_scope_as = epic
	}
}

create_artifact_nikephoros_crown_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = nikephoros_crown_name
		description = nikephoros_crown_description
		type = pedestal
		visuals = pedestal_justinian
		template = justinian_template #Same as Justinian
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 963.7.2
			recipient = character:1712 #Nikephoros Phokas
			location = province:496 #Constantinople
		}
		modifier = nikephoros_crown_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = artifact_succession_title
			value = title:e_byzantium
		}
		add_artifact_title_history = {
			target = title:e_byzantium
			date = 969.12.10
		}
	}
}

create_artifact_pedestal_shankha_conch_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_shankha_conch_name
		description = artifact_shankha_conch_description
		template = branch_hinduism_template
		type = pedestal
		visuals = a_arp_shanka_conch
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = shankha_conch_modifier
		save_scope_as = newly_created_artifact
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = conch
		set_variable = {
			name = relic
			value = flag:hinduism
		}
		save_scope_as = epic
	}
}

create_artifact_skull_cap_charlemagne_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = skull_cap_charlemagne_name
		description = skull_cap_charlemagne_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_skull_cap_of_charlemagne
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = skull_cap_charlemagne_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
	}
}

create_artifact_essen_crown_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = essen_crown_name
		description = essen_crown_description
		type = pedestal
		wealth = scope:wealth
		quality = scope:quality
		visuals = a_arp_al_kinderkrone
		template = general_unique_template
		history = {
			type = created
			date = 983.1.1
			recipient = character:1288 #Otto III
			location = province:2677 #Essen
		}
		modifier = essen_crown_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		add_artifact_title_history = {
			target = title:e_hre
			date = 1002.1.23
		}
		set_variable = {
			name = artifact_succession_title
			value = title:e_hre
		}
	}
}

create_artifact_dhammapada_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {
		name = dhammapada_name
		description = dhammapada_description
		type = book
		visuals = a_arp_dhammapada
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = dhammapada_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = dhammapada
		save_scope_as = epic
	}
}

create_artifact_vinaya_pitaka_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = vinaya_pitaka_name
		description = vinaya_pitaka_description
		type = book
		visuals = a_arp_vinaya_pitaka
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = vinaya_pitaka_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = vinaya_pitaka
		save_scope_as = epic
	}
}

create_artifact_sutta_pitaka_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = sutta_pitaka_name
		description = sutta_pitaka_description
		type = book
		visuals = a_arp_sutta_pitaka
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = sutta_pitaka_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = sutta_pitaka
		save_scope_as = epic
	}
}

create_artifact_abhidhamma_pitaka_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = abhidhamma_pitaka_name
		description = abhidhamma_pitaka_description
		type = book
		visuals = a_arp_abhidhamma_pitaka
		wealth = scope:wealth
		quality = scope:quality
		template = general_unique_template
		history = {
			type = created_before_history
		}
		modifier = abhidhamma_pitaka_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = abhidhamma
		save_scope_as = epic
	}
}

create_artifact_qadib_al_mulk_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = qadib_al_mulk_name
		description = qadib_al_mulk_description
		template = general_unique_template
		type = regalia
		visuals = a_arp_qadib_al_mulk
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			date = 670.1.1 #To order entries correctly
		}
		modifier = qadib_al_mulk_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = qadib_al_mulk
		save_scope_as = epic
		set_variable = {
			name = artifact_succession_title
			value = title:d_shiite #Caliphate
		}
		add_artifact_title_history = {
			target = title:d_shiite #Caliphate
			date = 881.1.1
		}
	}
}

create_artifact_al_dawat_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = al_dawat_name
		description = al_dawat_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_al_dawat
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			date = 670.1.1 #To order entries correctly
		}
		modifier = al_dawat_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = al_dawat
		set_variable = {
			name = artifact_succession_title
			value = title:d_shiite #Caliphate
		}
		save_scope_as = epic
		add_artifact_title_history = {
			target = title:d_shiite #Caliphate
			date = 881.1.1
		}
	}
}

create_artifact_al_hafir_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = al_hafir_name
		description = al_hafir_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_al_hafir
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			date = 670.1.1 #To order entries correctly
		}
		modifier = al_hafir_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = al_hafir
		set_variable = {
			name = artifact_succession_title
			value = title:d_shiite #Caliphate
		}
		save_scope_as = epic
		add_artifact_title_history = {
			target = title:d_shiite #Caliphate
			date = 881.1.1
		}
	}
}

create_artifact_al_sayf_al_khass_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = al_sayf_al_khass_name
		description = al_sayf_al_khass_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_al_sayf_al_khass
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			date = 670.1.1 #To order entries correctly
		}
		modifier = al_sayf_al_khass_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = al_sayf_al_khass
		save_scope_as = epic
		set_variable = {
			name = artifact_succession_title
			value = title:d_shiite #Caliphate
		}
		add_artifact_title_history = {
			target = title:d_shiite #Caliphate
			date = 881.1.1
		}
	}
}

create_artifact_durendal_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {
		name = artifact_durendal_name
		description = artifact_durendal_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_durandal
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = durendal_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = durendal
		save_scope_as = epic
	}
}

create_artifact_nagelring_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {
		name = artifact_nagelring_name
		description = artifact_nagelring_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_nagelring
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = nagelring_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = nagelring
		save_scope_as = epic
	}
}

create_artifact_szczerbiec_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_szczerbiec_name
		description = artifact_szczerbiec_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_szczerbiec
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = szczerbiec_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = szczerbiec
		save_scope_as = epic
	}
}

create_artifact_kladenets_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {
		name = artifact_kladenets_name
		description = artifact_kladenets_description
		template = general_unique_template
		type = pedestal
		visuals = sword_court
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = kladenets_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = kladenets
		save_scope_as = epic
	}
}

create_artifact_legbiter_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_legbiter_name
		description = artifact_legbiter_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_legbiter
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = legbiter_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = legbiter
		save_scope_as = epic
	}
}

create_artifact_quernbiter_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_quernbiter_name
		description = artifact_quernbiter_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_quern_biter
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = quernbiter_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = quernbiter
		save_scope_as = epic
	}
}

create_artifact_dragvandil_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_dragvandil_name
		description = artifact_dragvandil_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_dragvandil
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = dragvandil_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = dragvandil
		save_scope_as = epic
	}
}

create_artifact_curtana_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_curtana_name
		description = artifact_curtana_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_curtana
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 1042.6.9
			recipient = character:114 #Eadward the Confessor
			location = province:1527 #Lunden
		}
		modifier = curtana_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = curtana
		save_scope_as = epic
		add_artifact_title_history = {
			target = title:k_england
			date = 1066.1.5
		}
	}
}

create_colada_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {
		name = artifact_colada_name
		description = artifact_colada_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_colada
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = colada_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = colada
		save_scope_as = epic
	}
}

create_artifact_angelicas_ring_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_ring_angelica_name
		description = artifact_ring_angelica_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_angelicas_ring
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = angelicas_ring_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = angelica_ring
		save_scope_as = epic
	}
}

create_artifact_olifant_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_olifant_name
		description = artifact_olifant_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_olifant
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = olifant_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = olifant
		add_artifact_modifier = artifact_courtier_and_guest_opinion_4_modifier
		add_artifact_modifier = artifact_court_grandeur_baseline_add_3_modifier
		save_scope_as = epic
	}
}

create_artifact_aram_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_aram_name
		description = artifact_aram_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_aram
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = aram_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = aram
		save_scope_as = epic
	}
}

create_artifact_sledovik_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_sledovik_name
		description = artifact_sledovik_description
		visuals = rock
		type = pedestal
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		template = relic_finno_ugric_template
		modifier = sledovik_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:finno_ugric_religion
		}
		add_artifact_modifier = artifact_court_grandeur_baseline_add_2_modifier
		save_scope_as = epic
	}
}

create_artifact_kantele_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_famed = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_kantele_name
		description = artifact_kantele_description
		visuals = a_arp_davids_harp
		type = pedestal
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		template = relic_finno_ugric_template
		modifier = kantele_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = kantele
		set_variable = {
			name = relic
			value = flag:finno_ugric_religion
		}
		save_scope_as = epic
	}
}

#Illustrious Artifacts

create_artifact_pedestal_david_harp_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_david_harp_name
		description = artifact_pedestal_david_harp
		type = pedestal
		template = david_harp_template
		visuals = a_arp_davids_harp
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			location = province:5965 #Jerusalem
		}
		modifier = david_harp_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = david_harp
		save_scope_as = epic
	}
}

create_artifact_joyeuse_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_joyeuse_name
		description = artifact_joyeuse_description
		template = general_unique_template
		type = pedestal
		visuals = joyeuse
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = joyeuse_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = joyeuse
		save_scope_as = epic
	}
}

create_artifact_papal_tiara_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = papal_tiara_name
		description = papal_tiara_description
		template = papal_tiara_template
		type = helmet
		visuals = pope_tiara
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 800.1.1
			recipient = character:7862 #Leo III - fictitious date, probably somewhere between the 8th and 9th centuries
			location = province:2575 #Rome
		}
		modifier = artifact_monthly_piety_4_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:christian
		}
		set_variable = {
			name = artifact_succession_title
			value = title:k_papal_state
		}
		set_variable = {
			name = pope_hat
			value = yes
		}
		add_artifact_title_history = {
			target = title:k_papal_state
			date = 816.6.12
		}
		add_artifact_modifier = artifact_monthly_learning_lifestyle_xp_2_modifier
	}
}

create_artifact_sculpture_ark_of_covenant_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		name = artifact_sculpture_ark_of_covenant_name
		description = artifact_sculpture_ark_of_covenant_description
		type = sculpture
		template = ark_covenant_template
		visuals = sculpture_ark_of_covenant
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = ark_of_covenant_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = ark_of_the_covenant
		save_scope_as = epic
		save_scope_value_as = {
			name = ark_covenant
			value = yes
		}
	}
}

create_artifact_pedestal_koh_i_noor_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_koh_i_noor_name
		description = artifact_pedestal_koh_i_noor_description
		template = general_unique_template
		type = pedestal
		visuals = a_arp_great_diamond
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = koh_i_noor
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = koh_i_noor
		save_scope_as = epic
	}
}

create_artifact_al_taj_crown_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }

	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = al_taj_crown_name
		description = al_taj_crown_description
		template = general_unique_template
		type = helmet
		visuals = al_taj_crown
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			date = 670.1.1 #To order entries correctly
		}
		modifier = al_taj_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = al_taj
		save_scope_as = epic
		set_variable = {
			name = artifact_succession_title
			value = title:d_shiite #Caliphate
		}
		add_artifact_title_history = {
			target = title:d_shiite #Caliphate
			date = 881.1.1
		}
	}
}

create_artifact_wall_banner_thankfulness_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_wall_banner_thankfulness_name
		description = artifact_wall_banner_thankfulness_description
		template = banner_thankfulness
		type = wall_big
		visuals = banner_islam
		visuals_source = title:d_sunni
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
			date = 670.1.1 #To order entries correctly
		}
		modifier = banner_thankfulness
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = banner_thankfulness
		save_scope_as = epic
		set_variable = {
			name = artifact_succession_title
			value = title:d_shiite #Caliphate
		}
		add_artifact_title_history = {
			target = title:d_shiite #Caliphate
			date = 881.1.1
		}
	}
}

create_artifact_arms_of_alexander_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_arms_of_alex_name
		description = artifact_arms_of_alex_description
		template = general_unique_template
		type = pedestal
		visuals = pedestal_alexander_armor
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = alexander_the_great_armor_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = arms_of_alex
		save_scope_as = epic
	}
}

create_artifact_turquoise_throne_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		type = throne_special
		template = general_unique_template
		visuals = throne_turquoise
		wealth = scope:wealth
		quality = scope:quality
		name = turquoise_throne_name
		description = turquoise_throne_description
		history = {
			type = created_before_history
		}
		modifier = turquoise_throne_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = turquoise_throne
		save_scope_as = epic
	}
}

create_artifact_peacock_throne_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {
		type = throne_special
		template = general_unique_template
		visuals = throne_peacock
		wealth = scope:wealth
		quality = scope:quality
		name = peacock_throne_name
		description = peacock_throne_description
		history = {
			type = created_before_history
		}
		modifier = peacock_throne_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = peacock_throne
		save_scope_as = epic
	}
}

create_artifact_spear_of_the_prophet_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_spear_of_the_prophet_name
		description = artifact_spear_of_the_prophet_description
		type = pedestal
		visuals = spear_court
		template = islam_artifact_template
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = spear_prophet_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = spear_of_the_prophet
		save_scope_as = epic
		set_variable = {
			name = artifact_succession_title
			value = title:d_sunni
		}
	}
}

create_artifact_mantle_of_the_prophet_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_mantle_of_the_prophet_islam_name
		description = artifact_mantle_of_the_prophet_description
		template = islam_artifact_template
		type = regalia_simple
		visuals = a_arp_mantle_prophet
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = mantle_prophet_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = {
			name = relic
			value = flag:islamic
		}
		set_variable = mantle_of_prophet
		save_scope_as = epic
		set_variable = {
			name = artifact_succession_title
			value = title:d_sunni
		}
	}
}

create_artifact_sculpture_babr_e_bayan_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_sculpture_armor_babr_name
		description = artifact_sculpture_armor_babr
		type = sculpture
		template = babr_template
		visuals = sculpture_babr_e_bayan
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = babr_e_bayan_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = babr_e_bayan
		save_scope_as = epic
	}	
}

create_artifact_pedestal_justinian_effect = {
	# Get the character the artifact is being made for.
	$OWNER$ = { save_scope_as = owner }
	# Not really used, but if we don't set the scopes we get errors in the feature selection
	set_artifact_rarity_illustrious = yes

	# Create the artifact
	create_artifact = {	
		name = artifact_pedestal_crown_justinian_name
		description = artifact_pedestal_crown_justinian
		type = pedestal
		template = justinian_template
		visuals = pedestal_justinian
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 527.4.1
			recipient = character:70512 #Justinian the Great
			location = province:496 #Constantinople
		}
		modifier = justinian_crown_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

	scope:newly_created_artifact = {
		set_variable = { name = historical_unique_artifact value = yes }
		set_variable = crown_of_justinian
		add_artifact_title_history = {
			target = title:e_byzantium
			date = 565.11.14
		}
		save_scope_as = epic
	}	
}

generate_trinket_effect = {
	$TRINKET_RECEIVER$ = { save_scope_as = trinket_receiver }
	$TRINKET_GIVER$ = { save_scope_as = trinket_giver }
	scope:trinket_receiver = {
		set_variable = {
			name = grab_all_trinkets
			value = flag:$GRAB_ALL_TRINKETS$
		}
	}
	random_list = {
		#BAD
		##Bad 01
		###Gilded Rat's Tail
		80 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						###Let's not get trash if we outwitted the merchant
						AND = {
							has_character_flag = used_in_stewardship_general.2001
							NOT = { has_character_flag = free_outcome_stewardship_general.2001 }
						}
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###We didn't choose the CHEAP option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = expensive_option_stewardship_general.2001
						has_character_flag = helpful_option_stewardship_general.2001
					}
				}
				add = -25
			}
			###We have extremely high stewardship skill
			modifier = {
				scope:trinket_receiver = { has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001 }
				add = -25
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				type = miscellaneous
				visuals = ring
				modifier = artifact_monthly_prestige_penalty_modifier
				modifier = artifact_child_opinion_1_modifier
				save_scope_as = new_trinket
				wealth = 5
				quality = 5
				max_durability = 10
				generate_history = no
			}
			scope:new_trinket = {
				flag_as_trash_artifact = yes
				#The AI probably shouldn't want this bad trinket
				flag_as_unwanted_artifact = yes
			}
		}
		##Bad 02
		###Quail's Eggshell 'Gem'
		80 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						###Let's not get trash if we outwitted the merchant
						AND = {
							has_character_flag = used_in_stewardship_general.2001
							NOT = { has_character_flag = free_outcome_stewardship_general.2001 }
						}
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###We didn't choose the CHEAP option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = expensive_option_stewardship_general.2001
						has_character_flag = helpful_option_stewardship_general.2001
					}
				}
				add = -25
			}
			###We have extremely high stewardship skill
			modifier = {
				scope:trinket_receiver = { has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001 }
				add = -25
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = quail_eggshell_gem
				description = quail_eggshell_gem.desc
				type = miscellaneous
				visuals = diamond
				modifier = artifact_monthly_prestige_penalty_modifier
				modifier = artifact_fertility_gain_1_modifier
				save_scope_as = new_trinket
				wealth = 5
				quality = 5
				max_durability = 10
				generate_history = no
			}
			scope:new_trinket = {
				flag_as_trash_artifact = yes
				#The AI probably shouldn't want this bad trinket
				flag_as_unwanted_artifact = yes
			}
		}
		##Bad 03
		###Sanctified 'Stained' Glass Shard
		80 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						###Let's not get trash if we outwitted the merchant
						AND = {
							has_character_flag = used_in_stewardship_general.2001
							NOT = { has_character_flag = free_outcome_stewardship_general.2001 }
						}
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###We didn't choose the CHEAP option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = expensive_option_stewardship_general.2001
						has_character_flag = helpful_option_stewardship_general.2001
					}
				}
				add = -25
			}
			###We have extremely high stewardship skill
			modifier = {
				scope:trinket_receiver = { has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001 }
				add = -25
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = stained_glass_shard
				description = stained_glass_shard.desc
				type = miscellaneous
				visuals = pocket_pouch
				modifier = desecrated_artifact_modifier
				modifier = artifact_dread_gain_mult_1_modifier
				save_scope_as = new_trinket
				wealth = 5
				quality = 5
				wealth = 5
				quality = 5
				max_durability = 10
				generate_history = no
			}
			scope:new_trinket = {
				flag_as_trash_artifact = yes
				#The AI probably shouldn't want this bad trinket
				flag_as_unwanted_artifact = yes
			}
		}
		##Bad 04
		###Xylospongium
		80 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						###Let's not get trash if we outwitted the merchant
						AND = {
							has_character_flag = used_in_stewardship_general.2001
							NOT = { has_character_flag = free_outcome_stewardship_general.2001 }
						}
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###We didn't choose the CHEAP option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = expensive_option_stewardship_general.2001
						has_character_flag = helpful_option_stewardship_general.2001
					}
				}
				add = -25
			}
			###We have extremely high stewardship skill
			modifier = {
				scope:trinket_receiver = { has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001 }
				add = -25
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = xylospongium
				description = xylospongium.desc
				type = miscellaneous
				visuals = pocket_basic_case
				modifier = artifact_health_penalty_1_modifier
				modifier = artifact_child_opinion_2_modifier
				save_scope_as = new_trinket
				wealth = 5
				quality = 5
				wealth = 5
				quality = 5
				max_durability = 10
				generate_history = no
			}
			scope:new_trinket = {
				flag_as_trash_artifact = yes
				#The AI probably shouldn't want this bad trinket
				flag_as_unwanted_artifact = yes
			}
		}
		#COMMON
		##Common 01
		###St David's Morsel
		45 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###More likely if we have our chaplain to help and chose the helpful option
			modifier = {
				scope:trinket_receiver = { 
					has_character_flag = helpful_option_stewardship_general.2001
					has_character_flag = has_helpful_chaplain_stewardship_general.2001
				}
				add = 20
			}
			###Less likely if we already have a morsel
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = st_davids_morsel_trinket } 
				}
				add = -40
			}
			##^^Add more/other trigger flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = st_davids_morsel
				description = st_davids_morsel.desc
				type = miscellaneous
				visuals = pocket_fancy_case
				modifier = artifact_clergy_opinion_1_modifier
				modifier = artifact_zealot_vassal_opinion_2_modifier
				save_scope_as = new_trinket
				wealth = 15
				quality = 15
				max_durability = 30
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = st_davids_morsel_trinket
				flag_as_trash_artifact = yes
			}
		}
		##Common 02
		###Platypus Figurine
		35 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					##If we don't already have a platypus figurine in our inventory
					NOT = { 
						any_character_artifact = { has_variable = platypus_trinket } 
					}
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						###stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = platypus_figurine
				description = platypus_figurine.desc
				type = miscellaneous
				visuals = pocket_figurine
				modifier = artifact_stress_gain_2_modifier
				modifier = artifact_scheme_resistance_add_2_modifier
				save_scope_as = new_trinket
				wealth = 25
				quality = 25
				max_durability = 30
				history = {
					type = created_before_history
				}
			}
			scope:new_trinket = {
				set_variable = platypus_trinket
			}
		}
		##Common 03
		###Terracotta Toy Fowl
		55 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##Add more/other trigger flags below
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###Less likely if we have our steward to help and chose the helpful option
			modifier = {
				scope:trinket_receiver = { 
					has_character_flag = helpful_option_stewardship_general.2001
					has_character_flag = has_helpful_steward_stewardship_general.2001
				}
				add = -25
			}
			###Less likely if we already have a Terracotta Toy Fowl
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = terracotta_toy_fowl_trinket } 
				}
				add = -50
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = terracotta_toy_fowl
				description = terracotta_toy_fowl.desc
				type = miscellaneous
				visuals = pocket_figurine
				modifier = artifact_monthly_prestige_1_modifier
				modifier = artifact_learning_1_modifier
				save_scope_as = new_trinket
				wealth = 15
				quality = 15
				max_durability = 30
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = terracotta_toy_fowl_trinket
				flag_as_trash_artifact = yes
			}
		}
		##Common 04
		###Potsherd
		65 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##Add more/other trigger flags below
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###More likely if we have our chaplain to help and chose the helpful option
			modifier = {
				scope:trinket_receiver = { 
					has_character_flag = helpful_option_stewardship_general.2001
					has_character_flag = has_helpful_chaplain_stewardship_general.2001
				}
				add = 20
			}
			###Less likely if we already have a Potsherd
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = potsherd_trinket } 
				}
				add = -60
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			faith = {
				random_holy_site = { save_scope_as = trinket_holy_site }
			}
			create_artifact = {
				name = stewardship_general.2001.artifact.potsherd_holy
				description = stewardship_general.2001.artifact.potsherd_holy.desc
				type = miscellaneous
				visuals = a_arp_potsherd
				modifier = artifact_clergy_opinion_1_modifier
				modifier = artifact_zealot_vassal_opinion_2_modifier
				save_scope_as = new_trinket
				wealth = 15
				quality = 15
				max_durability = 30
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = potsherd_trinket
				flag_as_trash_artifact = yes
			}
		}
		##Common 05
		###Small Bell Beaker
		45 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###Less likely if we have extremely high stewardship or took the helpful councillor option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = helpful_option_stewardship_general.2001
						has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001
					}
				}
				add = -25
			}
			###Less likely if we already have a Small Bell Beaker
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = small_bell_beaker_trinket } 
				}
				add = -40
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = small_bell_beaker
				description = small_bell_beaker.desc
				type = miscellaneous
				visuals = pocket_goblet
				modifier = artifact_monthly_prestige_1_modifier
				modifier = artifact_learning_1_modifier
				save_scope_as = new_trinket
				wealth = 15
				quality = 15
				max_durability = 30
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = small_bell_beaker_trinket
				flag_as_trash_artifact = yes
			}
		}
		##Common 06
		###Serpentine Budai
		45 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###Less likely if we have extremely high stewardship or took the helpful councillor option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = helpful_option_stewardship_general.2001
						has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001
					}
				}
				add = -25
			}
			###Less likely if we already have a Serpentine Budai
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = serpentine_budai_trinket } 
				}
				add = -40
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = serpentine_budai
				description = serpentine_budai.desc
				type = miscellaneous
				visuals = pocket_figurine
				modifier = artifact_stress_gain_1_modifier
				modifier = artifact_different_faith_opinion_4_modifier
				save_scope_as = new_trinket
				wealth = 15
				quality = 15
				max_durability = 30
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = serpentine_budai_trinket
				flag_as_trash_artifact = yes
			}
		}
		#UNCOMMON
		##Uncommon 01
		###<HornedMythicalCreature>'s Horn
		40 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###More likely if we have our steward to help and chose the helpful option
			modifier = { 
				scope:trinket_receiver = { 
					has_character_flag = helpful_option_stewardship_general.2001
					has_character_flag = has_helpful_steward_stewardship_general.2001
				}
				add = 30
			}
			###Less likely if we already have a Mythical Horn
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = mythical_horn_trinket } 
				}
				add = -35
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			set_up_horned_mythical_creature_effect = yes
			create_artifact = {
				name = mythical_creature_horn
				description = mythical_creature_horn.desc
				type = miscellaneous
				visuals = a_arp_horn
				modifier = artifact_fertility_gain_2_modifier
				modifier = artifact_spouse_opinion_add_2_modifier
				save_scope_as = new_trinket
				wealth = 45
				quality = 45
				max_durability = 60
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = mythical_horn_trinket
			}
		}
		##Uncommon 02
		###<Adjective> <RegionalMythicalCreature> Figurine
		40 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			###Less likely if we already have a Mythical Figurine
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = mythical_creature_figurine_trinket } 
				}
				add = -35
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			###For localization
			if = {
				limit = { exists = location }
				location = { save_scope_as = target_location }
			}
			else = {
				#You should not end up here, something is wrong
				random_province = {
					save_scope_as = target_location
				}
			}
			set_up_trinket_adjective_effect = yes
			#set_up_regional_mythical_creature_effect = { LOCATION = scope:target_location }
			set_up_regional_mythical_creature_effect = yes
			create_artifact = {
				name = mythical_creature_figurine
				description = mythical_creature_figurine.desc
				type = miscellaneous
				visuals = a_arp_mythical_creature
				modifier = artifact_monthly_learning_lifestyle_xp_1_modifier
				modifier = artifact_learning_1_modifier
				modifier = artifact_health_gain_1_modifier
				save_scope_as = new_trinket
				wealth = 45
				quality = 45
				max_durability = 60
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = mythical_creature_figurine_trinket
			}
		}
		##Uncommon 03
		###St David's Taper
		30 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					##If we don't already have a St David's Taper in our inventory
					NOT = { 
						any_character_artifact = { has_variable = st_davids_taper_trinket } 
					}
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						AND = {
							###Only if we have our chaplain to help and chose the helpful option
							has_character_flag = has_helpful_chaplain_stewardship_general.2001
							has_character_flag = helpful_option_stewardship_general.2001
						}
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = st_davids_taper
				description = st_davids_taper.desc
				type = miscellaneous
				visuals = a_arp_davids_taper
				modifier = artifact_monthly_piety_1_modifier
				modifier = artifact_health_gain_1_modifier
				modifier = artifact_zealot_vassal_opinion_2_modifier
				save_scope_as = new_trinket
				wealth = 45
				quality = 45
				max_durability = 60
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = st_davids_taper_trinket
			}
		}
		##Uncommon 04
		###Marble Stick of J'Ira
		30 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					##If we don't already have a Jira poking stick in our inventory
					NOT = { 
						any_character_artifact = { has_variable = jira_stick_trinket } 
					}
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			modifier = {
				scope:trinket_receiver = { has_character_flag = less_than_decent_learning_stewardship_general.2001 }
				add = 30
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = jira_stick
				description = jira_stick.desc
				type = miscellaneous
				visuals = regalia
				modifier = artifact_monthly_learning_lifestyle_xp_1_modifier
				modifier = artifact_learning_1_modifier
				modifier = artifact_prowess_2_modifier
				save_scope_as = new_trinket
				wealth = 45
				quality = 45
				max_durability = 60
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = jira_stick_trinket
			}
		}
		##Uncommon 05
		###Lucky <ROOT.Culture> Coin
		40 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###More likely if we have extremely high stewardship or took the expensive option
			modifier = {
				scope:trinket_receiver = {
					OR = {
						has_character_flag = expensive_option_stewardship_general.2001
						has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001
					}
				}
				add = 25
			}
			###More likely if we have our steward to help and chose the helpful option
			modifier = { 
				scope:trinket_receiver = { 
					has_character_flag = helpful_option_stewardship_general.2001
					has_character_flag = has_helpful_steward_stewardship_general.2001
				}
				add = 30
			}
			###Less likely if we already have a lucky coin
			modifier = { 
				scope:trinket_receiver = { 
					any_character_artifact = { has_variable = lucky_coin_trinket } 
				}
				add = -35
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			###For localization
			if = {
				limit = { exists = location }
				location = { save_scope_as = target_location }
			}
			else = {
				#You should not end up here, something is wrong
			}
			create_artifact = {
				name = lucky_coin
				description = lucky_coin.desc
				type = miscellaneous
				visuals = medallion
				modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
				modifier = artifact_domain_tax_mult_2_modifier
				modifier = artifact_stewardship_per_stress_level_1_modifier
				save_scope_as = new_trinket
				wealth = 45
				quality = 45
				max_durability = 60
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = lucky_coin_trinket
			}
		}
		##Uncommon 06
		###Lavender Jade Pendant
		40 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					##If we don't already have a Lavender Jade Pendant in our inventory
					NOT = { 
						any_character_artifact = { has_variable = lavender_jade_pendant_trinket } 
					}
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						has_character_flag = used_in_stewardship_general.2001
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = lavender_jade_pendant
				description = lavender_jade_pendant.desc
				type = miscellaneous
				visuals = necklace
				modifier = artifact_monthly_piety_2_modifier
				modifier = artifact_monthly_piety_from_buildings_mult_3_modifier
				save_scope_as = new_trinket
				wealth = 45
				quality = 45
				max_durability = 60
				generate_history = no
			}
			scope:new_trinket = {
				set_variable = lavender_jade_pendant_trinket
			}
		}
		#RARE - 1/35 with no modifiers
		##Rare 01
		###Old Signet Ring
		20 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					##If we don't already have the Ring of Sekhmet in our inventory
					NOT = { 
						any_character_artifact = { has_variable = sekhmet_ring_trinket } 
					}
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						###If we have extremely high stewardship skill
						has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016

						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##stewardship_general.2001
			###Less likely if we took the cheap option
			modifier = { 
				scope:trinket_receiver = { 
					has_character_flag = cheap_option_stewardship_general.2001
				}
				add = -25
			}
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = sekhmet_ring
				description = sekhmet_ring.desc
				type = miscellaneous
				visuals = ring
				modifier = artifact_monthly_prestige_2_modifier
				modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
				modifier = artifact_stewardship_1_modifier
				modifier = artifact_monthly_dynasty_prestige_3_modifier
				save_scope_as = new_trinket
				wealth = 65
				quality = 65
				history = {
					type = created_before_history
				}
			}
			scope:new_trinket = {
				set_variable = sekhmet_ring_trinket
			}
		}
		##Rare 02
		###Ancient Scarab Brooch
		20 = {
			#TRIGGERS
			trigger = { 
				scope:trinket_receiver = {
					##If we don't already have the Ancient Scarab Brooch in our inventory
					NOT = { 
						any_character_artifact = { has_variable = ancient_scarab_brooch_trinket } 
					}
					OR = {
						##If we are flagged to grab all trinkets
						AND = { 
							exists = var:grab_all_trinkets
							var:grab_all_trinkets = flag:yes
						}
						##stewardship_general.2001
						###If we have extremely high stewardship skill, took the expensive option or had a helpful councillor
						has_character_flag = has_extremely_high_stewardship_skill_stewardship_general.2001
						has_character_flag = expensive_option_stewardship_general.2001
						AND = {
							has_character_flag = has_helpful_chaplain_stewardship_general.2001
							has_character_flag = helpful_option_stewardship_general.2001
						}
						##feast_default.1016
						has_character_flag = used_in_feast_default.1016
						
						###bp1_yearly.1021
						has_character_flag = 1021_token
					
						##^^Add more/other trigger flags above^^##
					}
				}
			}
			#MODIFIERS
			##^^Add more/other modifier flags above^^##
			#DO NOT edit this part##
			create_artifact = {
				name = scarab_brooch
				description = scarab_brooch.desc
				type = miscellaneous
				visuals = brooch
				modifier = artifact_health_gain_2_modifier
				modifier = artifact_fertility_gain_2_modifier
				modifier = artifact_negate_health_penalty_add_2_modifier
				modifier = artifact_prowess_3_modifier
				save_scope_as = new_trinket
				wealth = 65
				quality = 65
				history = {
					type = created_before_history
				}
			}
			scope:new_trinket = {
				set_variable = ancient_scarab_brooch_trinket
			}
		}
	}
	if = { 
		limit = { exists = scope:new_trinket }

		scope:new_trinket = {
			#Check what our history is
			save_scope_value_as = {
				name = artifact_history
				value = flag:$HISTORY_TYPE$
			}
			##Given to scope:trinket_receiver
			if = {
				limit = {
					exists = scope:artifact_history
					scope:artifact_history = flag:given_unknown
				}
				add_artifact_history = {
					type = given
					actor = scope:trinket_receiver 		#Having the receiver in both generates the CoA on the right-hand side of the entry
					recipient = scope:trinket_receiver
				}
			}
			##Given to scope:trinket_receiver (scope:trinket_giver is the left-hand portrait)
			else_if = {
				limit = {
					exists = scope:artifact_history
					scope:artifact_history = flag:given
				}
				add_artifact_history = {
					type = given
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
				}
			}
			##Discovered by scope:trinket_giver for scope:trinket_receiver at scope:trinket_giver.location
			else_if = {
				limit = {
					exists = scope:artifact_history
					scope:artifact_history = flag:discovered
				}
				add_artifact_history = {
					type = discovered
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
					location = scope:trinket_giver.location
				}
			}
			##Stolen by scope:trinket_receiver (scope:trinket_receiver's Coat of Arms is the right-hand portrait)
			else_if = {
				limit = {
					exists = scope:artifact_history
					scope:artifact_history = flag:stolen_unknown
				}
				add_artifact_history = {
					type = stolen
					actor = scope:trinket_receiver
					recipient = scope:trinket_receiver
				}
			}
			##Stolen by scope:trinket_receiver (scope:trinket_giver is the right-hand portrait)
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:stolen 
				}
				add_artifact_history = {
					type = stolen
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
				}
			}
			##Created by an unknown benefactor for scope:trinket_receiver at scope:trinket_receiver.location
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:created_unknown
				}
				add_artifact_history = {
					type = created
					recipient = scope:trinket_receiver
					location = scope:trinket_receiver.location
				}
			}
			##Created by scope:trinket_giver for scope:trinket_receiver at scope:trinket_receiver.location
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:created
				}
				add_artifact_history = {
					type = created
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
					location = scope:trinket_receiver.location
				}
			}
			##Inherited by scope:trinket_receiver
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:inherited_unknown
				}
				add_artifact_history = {
					type = inherited
					actor = scope:trinket_receiver
					recipient = scope:trinket_receiver
				}
			}
			#Inherited by scope:trinket_receiver
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:inherited
				}
				add_artifact_history = {
					type = inherited
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
				}
			}
			##Reforged by scope:trinket_receiver in scope:trinket_receiver.location
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:reforged
				}
				add_artifact_history = {
					type = reforged
					recipient = scope:trinket_receiver
					location = scope:trinket_receiver.location
				}
			}
			##Conquered by scope:trinket_receiver in a war against scope:trinket_giver
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:conquest
				}
				add_artifact_history = {
					type = conquest
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
				}
			}
			##Conquered by scope:trinket_receiver after the siege of scope:trinket_giver.location
			else_if = {
				limit = { 
					exists = scope:artifact_history
					scope:artifact_history = flag:taken_in_siege
				}
				add_artifact_history = {
					type = taken_in_siege
					actor = scope:trinket_giver
					recipient = scope:trinket_receiver
					location = scope:trinket_giver.location
				}
			}
			##TODO_CD_FGK Taken in battle
			##TODO_CD_FGK Won in duel
		}
	}
	#Clean up the grab all flag, in case it was used
	scope:trinket_receiver = {
		remove_variable = grab_all_trinkets
	}
	#Clean up trinket variables
	if = {
		limit = { exists = var:horned_mythical_creature }
		remove_variable = horned_mythical_creature
	}
	if = {
		limit = { exists = var:regional_mythical_creature_trinket }
		remove_variable = regional_mythical_creature_trinket
	}
	if = {
		limit = { exists = var:trinket_adjective_followup }
		remove_variable = trinket_adjective_followup
	}
}