﻿

low_high_wealth_cutoff = 50 # The mid-point between the minimum wealth of an artifact and the maximum wealth of an artifact. Currently minimum and maximum are 0 and 100, respectively. 

reforge_artifact_cost = {
	value = { # Base cost is the missing durability - It shouldn't matter how often, or when, you repair an artifact
			value = scope:artifact.artifact_max_durability
			subtract = scope:artifact.artifact_durability
			desc = "BASE"
	}
	if = { # Multiply base cost with artifact rarity - Except for trinkets
		limit = {
			scope:artifact = { rarity = illustrious }
		}
		multiply = {
			value = 4
			desc = reforge_artifact_durability_desc
		}
	}
	else_if = {
		limit = {
			scope:artifact = { rarity = famed }
		}
		multiply = {
			value = 3
			desc = reforge_artifact_durability_desc
		}
	}
	else_if = {
		limit = {
			scope:artifact = { rarity = masterwork }
		}
		multiply = {
			value = 2
			desc = reforge_artifact_durability_desc
		}
	}
}

# Used by AI when scoring artifacts for equipping
# Will be added to the score of
#	code calculation: quality + wealth + (rarity * NDefines::NInventory::ARTIFACT_RARITY_AI_SCORE_MULT) + Scripted Template ai_score (if artifact has a scripted template)
# The score of this will be added to the score of above
# Best artifact will be selected to be equipped, and only artifacts with scores above 0 will be equipped.
# root: character - owner of the Artifact
# scope:artifact: artifact
# scope:current_weight: is the score from the code calculation
artifact_ai_will_equip_score = {
	if = { # To prevent the AI from equipping actively detrimental artifacts
		limit = {
			exists = scope:artifact
			scope:artifact = {
				has_variable = cursed_artifact
			}
		}
		add = {
			value = -10000
		}
	}
}

# Used by AI when scoring artifacts for reforging
# Will be added to the score of
#	code calculation: quality + wealth + (rarity * NDefines::NInventory::ARTIFACT_RARITY_AI_SCORE_MULT) + Scripted Template ai_score (if artifact has a scripted template)
# The score of this will be added to the score of above
# Best artifact will be selected to be reforged, and only artifacts with scores above 0 will be reforged.
# Only artifacts that are not good enough for equipping, will be considered for reforging

# root: character - owner of the Artifact
# scope:artifact: artifact
# scope:current_weight: is the score from the code calculation
artifact_ai_will_reforge_score = {
	if = {
		limit = {
			scope:artifact = {
				artifact_slot_type = miscellaneous
			}
		}
		multiply = {
			value = 0
		}
	}
	if = {
		limit = {
			root = {
				gold < 200
			}
		}
		multiply = {
			value = 0
		}
	}
	if = {
		limit = {
			root = {
				is_at_war = yes
			}
		}
		multiply = {
			value = 0
		}
	}
}

artifact_rarity = {
	value = 1
	if = {
		limit = { rarity = common }
		add = 1
	}
	else_if = {
		limit = { rarity = masterwork }
		add = 2
	}
	else_if = {
		limit = { rarity = famed }
		add = 3
	}
	else_if = {
		limit = { rarity = illustrious }
		add = 4
	}
}

cheese_artifact_strength = {
	value = scope:cheese_artifact.artifact_max_durability
	subtract = scope:cheese_artifact.artifact_durability
	multiply = -1
}

very_low_mummy_quality = 0
low_mummy_quality = 100
medium_mummy_quality = 250
high_mummy_quality = 500
very_high_mummy_quality = 1000

mummy_quality = {
	value = 0
	# Am I a good person?
	if = {
		limit = {
			num_virtuous_traits >= 1
		}
		add = 50
	}
	if = { # 100
		limit = {
			num_virtuous_traits >= 2
		}
		add = 50
	}
	if = { # 250
		limit = {
			num_virtuous_traits >= 3
		}
		add = 250
	}
	# Am I a bad person?
	if = {
		limit = {
			num_sinful_traits >= 1
		}
		add = -25
	}
	if = { # -50
		limit = {
			num_sinful_traits >= 2
		}
		add = -25
	}
	if = { # -100
		limit = {
			num_sinful_traits >= 3
		}
		add = -50
	}
	# Am I a prestigious person?
	if = {
		limit = {
			highest_held_title_tier >= tier_county
		}
		add = 25
	}
	if = { # 50
		limit = {
			highest_held_title_tier >= tier_duchy
		}
		add = 25
	}
	if = { # 100
		limit = {
			highest_held_title_tier >= tier_kingdom
		}
		add = 50
	}
	if = { # 250
		limit = {
			highest_held_title_tier >= tier_empire
		}
		add = 150
	}
	# Am I a HoF?
	if = {
		limit = {
			primary_title = { is_head_of_faith = yes }
		}
		add = 100
	}
	# Traits that would make someone a good mummy probably
	if = {
		limit = {
			has_trait = pilgrim
			NOT = {
				faith = { has_doctrine_parameter = forbidden_from_pilgrimage }
			}
		}
		add = 25
	}
	if = {
		limit = {
			has_trait = tourney_participant
		}
		add = 25
	}
	if = { # Other lifestyles get 25
		limit = {
			any_trait_in_category = {
				category = lifestyle
				count >= 1
			}
		}
		add = 25
	}
	if = {
		limit = {
			OR = {
				has_trait = education_intrigue_5
				has_trait = education_diplomacy_5
				has_trait = education_stewardship_5
				has_trait = education_martial_5
				has_trait = education_learning_5
			}
		}
		add = 25
	}
	#Living Legend and Saints get more value
	if = {
		limit = {
			OR = {
				has_trait = legend
				has_trait = saint
			}
		}
		multiply = 1.5
	}
}
