﻿###########################
# Oxus Bracelet

create_artifact_oxus_bracelet_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_oxus_bracelet_name
		description = artifact_oxus_bracelet_description
		type = pedestal
		visuals = oxus_bracelet
		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:adventurer }
	#	create_artifact = {
	#		name = artifact_necklace_name
	#		description = placeholder #properly set later
	#		visuals = necklace
	#		type = necklace
	#		modifier = artifact_placeholder_modifier
	#		wealth = scope:wealth
	#		quality = scope:quality
	#		save_scope_as = newly_created_artifact
	#		history = {
	#			location = scope:location.title_province
	#			actor = scope:adventurer
	#			recipient = root
	#			type = given
	#		}
	#	}
	#}
	#else = {
	#	create_artifact = {
	#		name = artifact_necklace_name
	#		creator = scope:owner
	#		description = placeholder #properly set later
	#		visuals = necklace
	#		type = necklace
	#		modifier = artifact_placeholder_modifier
	#		wealth = scope:wealth
	#		quality = scope:quality
	#		save_scope_as = newly_created_artifact
	#	}
	#}

	hidden_effect_new_object = {
		scope:newly_created_artifact = {
			remove_artifact_modifier = artifact_placeholder_modifier

			# Set some Prestige and Grandeur
			add_scaled_artifact_modifier_prestige_effect = yes
			add_scaled_artifact_modifier_grandeur_small_effect = yes

			# Let's add a random secondary effect
			random_list = {
				35 = {
					add_scaled_artifact_modifier_majesty_effect = yes
				}
				35 = {
					add_scaled_artifact_modifier_dynasty_prestige_effect = yes
				}
				15 = {
					add_2_scaled_artifact_modifier_majesty_effect = yes
				}
				15 = {
					add_scaled_artifact_modifier_attractiveness_effect = yes
				}
			}
		}
	}
}

###########################
# Persian Drinking Vessel

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

	hidden_effect_new_object = {
		# Get artifact quality, wealth, and materials
		get_artifact_quality_effect = yes
		get_artifact_wealth_effect = yes

		# Create the artifact
		scope:owner = {
			if = {
				limit = { exists = scope:adventurer }
				create_artifact = {
					name = artifact_goblet_name
					description = placeholder
					visuals = persian_drinking_vessel
					type = goblet
					modifier = artifact_placeholder_modifier
					wealth = scope:wealth
					quality = scope:quality
					save_scope_as = newly_created_artifact
					history = {
						location = scope:location.title_province
						actor = scope:adventurer
						recipient = root
						type = discovered
					}
				}
			}
			else = {
				create_artifact = {
					name = artifact_goblet_name
					creator = scope:goldsmith
					description = placeholder
					visuals = persian_drinking_vessel
					type = goblet
					wealth = scope:wealth
					quality = scope:quality
					modifier = artifact_placeholder_modifier
					save_scope_as = newly_created_artifact
				}
			}
		}
		scope:newly_created_artifact = {
			set_artifact_description = artifact_goblet_description

			# Set grandeur
			add_scaled_artifact_modifier_grandeur_small_effect = yes

			# Let's add another random effect
			random_list = {
				10 = {
					add_scaled_artifact_modifier_minor_prestige_effect = yes
				}
				10 = {
					add_scaled_artifact_modifier_majesty_effect = yes
				}
				30 = {
					trigger = { rarity = common }
					# Common goblets have a chance to not get any extra modifiers
				}
			}
			remove_artifact_modifier = artifact_placeholder_modifier
		}
	}
}

###########################
# Incense Burner Sculpture

create_artifact_fp3_incense_burner_sculpture_effect_base = {
	create_artifact = {
		name = fp3_incense_burner_sculpture
		# Description will be regenerated in the post-creation effects, since we need to nab materials.
		description = placeholder
		type = $TYPE$
		visuals = fp3_incense_burner_sculpture
		wealth = scope:wealth
		quality = scope:quality
		modifier = artifact_negate_health_penalty_add_2_modifier
		save_scope_as = newly_created_artifact
	}
}

create_artifact_fp3_incense_burner_sculpture_effect = {
	# Set up general scopes.
	$OWNER$ = { save_scope_as = owner }
	$SMITH$ = { save_scope_as = maker }
	# Begin creating.
	hidden_effect_new_object = {
		# Get artifact quality, wealth, and materials.
		get_artifact_quality_effect = yes
		get_artifact_wealth_effect = yes
		# Create the artifact.
		scope:owner = {
			if = {
				limit = { has_royal_court = yes }
				create_artifact_fp3_incense_burner_sculpture_effect_base = { TYPE = sculpture }
			}
			else = {
				create_artifact_fp3_incense_burner_sculpture_effect_base = { TYPE = miscellaneous_when_not_court }
			}
		}
		scope:newly_created_artifact = {
			# Flag this as something that can be reforged for free, if relevant.
			if = {
				limit = {
					$OWNER$ = { has_royal_court = no }
				}
				set_variable = {
					name = dlc_potential_court_artefact
					value = yes
				}
			}
			set_artifact_feature_group = goblet_material
			set_artifact_feature_group = decoration_material_inlay
			set_artifact_description = fp3_incense_burner_sculpture_desc
			# Let's add modifiers!
			## Illustrious gets to be very swanky.
			if = {
				limit = { rarity = illustrious }
				add_scaled_artifact_modifier_prestige_effect = yes
				add_scaled_artifact_modifier_grandeur_small_effect = yes
				add_scaled_artifact_modifier_stress_gain_effect = yes
				add_scaled_artifact_modifier_attractiveness_effect = yes
			}
			## Famed
			else_if = {
				limit = { rarity = famed }
				add_scaled_artifact_modifier_prestige_effect = yes
				add_scaled_artifact_modifier_grandeur_small_effect = yes
				add_scaled_artifact_modifier_stress_gain_effect = yes
			}
			## Masterwork
			else_if = {
				limit = { rarity = masterwork }
				add_scaled_artifact_modifier_prestige_effect = yes
				add_scaled_artifact_modifier_stress_gain_effect = yes
			}
			## Common
			else_if = {
				limit = { rarity = common }
				add_scaled_artifact_modifier_stress_gain_effect = yes
			}
		}
	}
}


###########################
# Sassanian Sword

create_artifact_sassanian_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

	random_list = {
		1 = { set_artifact_rarity_masterwork = yes }
		3 = { set_artifact_rarity_famed = yes }
		2 = { set_artifact_rarity_illustrious = yes }
	}

	# Create the artifact
	create_artifact = {
		name = artifact_sassanian_sword_name
		description = artifact_sassanian_sword_description
		type = regalia
		template = regalia_template
		visuals = sassanian_sword
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	hidden_effect_new_object = {
		scope:newly_created_artifact = {
			# Prestige modifier is scaled based on the Wealth of the artifact (opulence).
			add_scaled_artifact_modifier_minor_prestige_effect = yes
			
			# Add a combat-related modifiers, 2 of them if it's famed.
			if = {
				limit = {
					rarity = famed
				}
				add_2_scaled_artifact_modifier_combat_effect = yes
			}
			else = {
				add_scaled_artifact_modifier_combat_effect = yes
			}

			# Add a Majesty-related modifier based on the Quality of the artifact.
			if = {
				limit = { # Add a second Majesty-related modifier for high rarity artifacts.
					OR = {
						rarity = famed
						rarity = illustrious
					}
				}
				add_2_scaled_artifact_modifier_majesty_effect = yes
			}
			else = {
				add_scaled_artifact_modifier_majesty_effect = yes
			}

			add_scaled_artifact_modifier_attractiveness_effect = yes

			set_variable = {
				name = quality
				value = scope:quality
			}
			set_variable = {
				name = wealth
				value = scope:wealth
			}
		}
	}
}

create_artifact_illustrious_sassanian_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_illustrious = yes
	
	# Create the artifact
	create_artifact = {
		name = artifact_sassanian_sword_name
		description = artifact_sassanian_sword_description
		type = regalia
		template = regalia_template
		visuals = sassanian_sword
		wealth = scope:wealth
		quality = scope:quality
		history = {
			type = created_before_history
		}
		modifier = artifact_placeholder_modifier
		save_scope_as = newly_created_artifact
	}

	hidden_effect_new_object = {
		scope:newly_created_artifact = {
			# Prestige modifier is scaled based on the Wealth of the artifact (opulence).
			set_variable = sassanian_sword
			add_scaled_artifact_modifier_minor_prestige_effect = yes
			add_2_scaled_artifact_modifier_combat_effect = yes
			add_2_scaled_artifact_modifier_majesty_effect = yes
			add_scaled_artifact_modifier_attractiveness_effect = yes

			set_variable = {
				name = quality
				value = scope:quality
			}
			set_variable = {
				name = wealth
				value = scope:wealth
			}
		}
	}
}

###########################
# Ancient Drinking Vessel

create_artifact_fp3_ancient_drinking_vessel_effect_base = {
	create_artifact = {
		name = fp3_ancient_drinking_vessel
		description = placeholder
		visuals = persian_drinking_vessel
		type = $TYPE$
		wealth = scope:wealth
		quality = scope:quality
		#decaying = no
		modifier = artifact_negate_health_penalty_add_2_modifier
		save_scope_as = newly_created_artifact
		history = { type = created_before_history }
	}
}

create_artifact_fp3_ancient_drinking_vessel_effect = {
	# Set up general scopes.
	$OWNER$ = { save_scope_as = owner }
	# Begin creating.
	hidden_effect_new_object = {
		random_list = {
			1 = { set_artifact_rarity_illustrious = yes }
			2 = { set_artifact_rarity_famed = yes }
			3 = { set_artifact_rarity_masterwork = yes }
			1 = { set_artifact_rarity_common = yes }
		}
		# Create the artifact.
		scope:owner = {
			if = {
				limit = { has_royal_court = yes }
				create_artifact_fp3_ancient_drinking_vessel_effect_base = { TYPE = goblet }
			}
			else = {
				create_artifact_fp3_ancient_drinking_vessel_effect_base = { TYPE = miscellaneous_when_not_court }
			}
		}
		scope:newly_created_artifact = {
			set_artifact_description = fp3_ancient_drinking_vessel_desc
			# Flag this as something that can be reforged for free, if relevant.
			if = {
				limit = {
					$OWNER$ = { has_royal_court = no }
				}
				set_variable = {
					name = dlc_potential_court_artefact
					value = yes
				}
			}

			# Let's add modifiers!
			## Illustrious gets to be very swanky.
			if = {
				limit = { rarity = illustrious }
				add_scaled_artifact_modifier_prestige_effect = yes
				add_scaled_artifact_modifier_stress_gain_effect = yes
				add_scaled_artifact_modifier_attractiveness_effect = yes
			}
			## Famed
			else_if = {
				limit = { rarity = famed }
				add_scaled_artifact_modifier_prestige_effect = yes
				add_scaled_artifact_modifier_stress_gain_effect = yes
			}
			## Masterwork
			else_if = {
				limit = { rarity = masterwork }
				add_scaled_artifact_modifier_prestige_effect = yes
				add_scaled_artifact_modifier_stress_gain_effect = yes
			}
			## Common
			else_if = {
				limit = { rarity = common }
				add_scaled_artifact_modifier_stress_gain_effect = yes
			}
		}
	}
}
