﻿create_artifact_golden_legend_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_golden_legend_name
		description = artifact_golden_legend_description
		template = golden_legend_template
		type = book
		visuals = golden_legend
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created
			date = 1264.1.1 #The golden legend was written around 1264.
                  actor = character:jacobus_de_voragine #Jacobus de Voragine
			location = province:2466 #Genoa
		}
		modifier = golden_legend_modifier
		save_scope_as = newly_created_artifact
		decaying = no
	}

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

holy_stuff_golden_legend_scripted_effect = {
	## Create Merchant
	scope:legenda_aurea_target = {
		if = {
			limit = {
				any_character_to_title_neighboring_and_across_water_county = {
					NOT = {
						culture = { this = scope:legenda_aurea_target.culture }
					}
					OR = {
						faith = { religion_tag = christianity_religion }
					}
				}
			}
			random_character_to_title_neighboring_and_across_water_county = {
				limit = {
					NOT = {
						culture = { this = scope:legenda_aurea_target.culture }
					}
					OR = {
						faith = { religion_tag = christianity_religion }
					}
				}
				save_scope_as = merchant_county
			}
		}
		else = {
			random_county = {
				limit = {
					NOT = {
						culture = { this = scope:legenda_aurea_target.culture }
					}
					OR = {
						faith = { religion_tag = christianity_religion }
					}
				}
				save_scope_as = merchant_county
			}
		}
	}
}
