@minor_artifact_decision_cost = 100
@minor_artifact_decision_duration = 3600
@minor_artifact_ai_threshold = 200

artifact_arcane_deciphering = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 500
		}
	}

	ai_weight = {
		weight = 100
		modifier = {
			factor = 1.5
			has_ethic = ethic_materialist
		}
		modifier = {
			factor = 2
			has_ethic = ethic_fanatic_materialist
		}
	}

	potential = {
		has_technology = tech_arcane_deciphering
	}

	allow = {
		custom_tooltip = {
			fail_text = "requires_arcane_deciphering_no_cooldown"
			NOT = { has_modifier = arcane_deciphering_cooldown }
		}
	}

	effect = {
		custom_tooltip = artifact_arcane_deciphering_effect
		hidden_effect = {
			if = {
				limit = {
					is_ai = no
					NOT = { has_country_flag = arcana_achievement }
				}
				set_country_flag = arcana_achievement
			}
			add_modifier = {
				modifier = "arcane_deciphering_cooldown"
				days = 720
			}
			owner = {
				country_event = { id = ancrel.10000 }
			}
		}
	}
}

artifact_lgate_clue = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 1000
		}
	}

	potential = {
		has_country_flag = encountered_first_lgate
		NOT = { has_country_flag = completed_lcluster_chain }
		NOT = { has_global_flag = l_cluster_opened }
		has_distar = yes
	}

	allow = {
		NOT = { has_modifier = artifact_lgate_insight_cooldown }
	}

	effect = {
		custom_tooltip = artifact_lgate_clue_effect

		hidden_effect = {
			generate_lcluster_clue = yes

			add_modifier = {
				modifier = "artifact_lgate_insight_cooldown"
				days = 3600
			}
		}
	}
}

artifact_proclaim_religious_finding = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 100
		modifier = {
			factor = 1.5
			is_xenophile = yes
		}
		modifier = {
			factor = 0
			has_resource = { type = minor_artifacts amount < @minor_artifact_ai_threshold }
		}
	}

	potential = {
		is_spiritualist = yes
	}

	effect = {
		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}
		add_modifier = {
			modifier = "proclaim_religious_finding"
			days = @minor_artifact_decision_duration
		}
	}

	allow = {
		NOT = { has_modifier = proclaim_religious_finding }
	}
}

artifact_proclaim_superiority = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 100
		modifier = {
			factor = 0
			has_resource = { type = minor_artifacts amount < @minor_artifact_ai_threshold }
		}
		modifier = {
			factor = 0.1
			resource_stockpile_compare = {
				resource = influence
				value > 500
			}
		}
		modifier = {
			factor = 0
			resource_stockpile_compare = {
				resource = influence
				value > 800
			}
		}
	}

	potential = { is_xenophobe = yes }

	effect = {
		add_monthly_resource_mult = {
			resource = influence
			value = @tier1influencereward
			min = @tier1influencemin
			max = @tier1influencemax
		}
		add_modifier = {
			modifier = "proclaim_superiority"
			days = @minor_artifact_decision_duration
		}
	}

	allow = {
		NOT = { has_modifier = proclaim_superiority }
	}
}

artifact_celebrate_diversity = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 100
		modifier = {
			factor = 1.5
			is_xenophile = yes
		}
		modifier = {
			factor = 0.25
			is_spiritualist = yes
			is_xenophile = no
		}
		modifier = {
			factor = 0
			has_resource = { type = minor_artifacts amount < @minor_artifact_ai_threshold }
		}
	}

	potential = {
		is_gestalt = no
		is_xenophobe = no
	}

	effect = {
		add_monthly_resource_mult = {
			resource = unity
			value = @tier1unityreward
			min = @tier1unitymin
			max = @tier1unitymax
		}
		add_modifier = {
			modifier = "celebrate_diversity"
			days = @minor_artifact_decision_duration
		}
	}

	allow = {
		NOT = { has_modifier = celebrate_diversity }
	}
}

artifact_cultural_study = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		is_gestalt = no
		OR = {
			is_megacorp = no
			is_worker_coop_empire = yes
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_cultural_study_effect"
			always = no
		}
	}
}

artifact_manager_awards = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		is_megacorp = yes
		is_worker_coop_empire = no
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_manager_awards_effect"
			always = no
		}
	}
}

artifact_artifact_relays_hivemind = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		is_hive_empire = yes
		is_wilderness_empire = no
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_artifact_relays_hivemind_effect"
			always = no
		}
	}
}

artifact_artifact_relays_machine = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = { is_machine_empire = yes }

	allow = {
		custom_tooltip = {
			fail_text = "artifact_artifact_relays_machine_effect"
			always = no
		}
	}
}

artifact_sanctuary_exhibits = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = @minor_artifact_decision_cost
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = { has_civic = civic_machine_servitor }

	allow = {
		custom_tooltip = {
			fail_text = "artifact_sanctuary_exhibits_effect"
			always = no
		}
	}
}

artifact_find_military_applications = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 150
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 1.5
			is_militarist = yes
		}
		modifier = {
			factor = 2
			is_at_war = yes
		}
		modifier = {
			factor = 0
			AND = {
				is_pacifist = yes
				is_at_war = no
				has_crisis = no
			}
		}
		modifier = {
			factor = 0
			has_resource = { type = minor_artifacts amount < @minor_artifact_ai_threshold }
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_find_military_applications_no_cooldown"
			NOT = { has_modifier = artifact_find_applications_cooldown }
		}
	}

	potential = { has_technology = tech_arcane_deciphering }

	effect = {
		custom_tooltip = artifact_find_military_applications_effect

		hidden_effect = {
			add_modifier = {
				modifier = "artifact_find_applications_cooldown"
				days = 900
			}
			owner = {
				country_event = { id = ancrel.10010 }
			}
		}
	}
}

artifact_find_peaceful_applications = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 150
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0.10
			is_militarist = yes
		}
		modifier = {
			factor = 1.25
			is_pacifist = yes
		}
		modifier = {
			factor = 0.10
			is_at_war = yes
		}
		modifier = {
			factor = 0
			has_resource = { type = minor_artifacts amount < @minor_artifact_ai_threshold }
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_find_peaceful_applications_no_cooldown"
			NOT = { has_modifier = artifact_find_applications_cooldown }
		}
	}

	potential = {
		has_technology = tech_arcane_deciphering
		is_homicidal = no
	}

	effect = {
		custom_tooltip = artifact_find_peaceful_applications_effect

		hidden_effect = {
			add_modifier = {
				modifier = "artifact_find_applications_cooldown"
				days = 900
			}
			owner = {
				country_event = { id = ancrel.10020 }
			}
		}
	}
}

artifact_sell_collector = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 50
		}
	}

	ai_weight = {
		weight = 100
		modifier = {
			factor = 0
			has_resource = { type = energy amount > 5000 }
		}
		modifier = {
			factor = 0
			has_resource = { type = minor_artifacts amount < @minor_artifact_ai_threshold }
		}
	}

	potential = {
		NAND = {
			is_gestalt = yes
			is_homicidal = yes
		}
		has_grand_archive_dlc = no
	}

	effect = {
		add_resource = { energy = 500 }
		hidden_effect = {
			add_modifier = {
				modifier = "artifact_sell_cooldown"
				days = 180
			}
		}
	}
	allow = {
		NOT = { has_modifier = artifact_sell_cooldown }
		if = {
			limit = { is_gestalt = yes }
			custom_tooltip = {
				fail_text = "GALACTIC_MARKET_NOT_FOUNDED"
				has_global_flag = galactic_market_founded
			}
		}
		if = {
			limit = { is_gestalt = yes }
			custom_tooltip = {
				fail_text = "GALACTIC_MARKET_ACCESS"
				is_galactic_community_member = yes
			}
		}
	}

}

artifact_arcane_deciphering_locked = {
	potential = { NOT = { has_technology = tech_arcane_deciphering } }

	allow = {
		custom_tooltip = {
			fail_text = "artifact_action_locked_failtext"
			has_technology = tech_arcane_deciphering
		}
	}
}

artifact_find_military_applications_locked = {
	potential = { NOT = { has_technology = tech_arcane_deciphering } }

	allow = {
		custom_tooltip = {
			fail_text = "artifact_action_locked_failtext"
			has_technology = tech_arcane_deciphering
		}
	}
}

artifact_find_peaceful_applications_locked = {
	potential = {
		NOT = { has_technology = tech_arcane_deciphering }
		is_homicidal = no
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_action_locked_failtext"
			has_technology = tech_arcane_deciphering
		}
	}
}

artifact_irassian_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		 has_country_flag = irassian_world_found
		 NOT = { has_country_flag = irassian_research_started }
	}

	effect = {
		enable_special_project = {
			name = "IRASSIAN_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = irassian_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_yuht_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		 has_country_flag = yuht_world_found
		 NOT = { has_country_flag = yuht_research_started }
	}

	effect = {
		enable_special_project = {
			name = "YUHT_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = yuht_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_inetian_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		has_country_flag = completed_inetian_traders_precursor
		NOT = { has_country_flag = inetian_research_started }
		has_ancrel = yes
	}

	effect = {
		enable_special_project = {
			name = INETIAN_PROJECTS_04
			location = event_target:wm_last_storm_shelter
			owner = root
		}

		hidden_effect = {
			set_country_flag = inetian_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_adakkaria_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		has_country_flag = adakkaria_world_found
		NOT = { has_country_flag = adakkaria_research_started }
		has_ancrel = yes
	}

	effect = {
		enable_special_project = {
			name = project_adakkaria_secrets_of
			location = event_target:adSul_capital
			owner = root
		}

		hidden_effect = {
			set_country_flag = adakkaria_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_vultaum_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		 has_country_flag = vultaum_world_found
		 NOT = { has_country_flag = vultaum_research_started }
	}

	effect = {
		enable_special_project = {
			name = "VULTAUM_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = vultaum_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_cybrex_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		 has_country_flag = cybrex_world_found
		 NOT = { has_country_flag = cybrex_research_started }
	}

	effect = {
		enable_special_project = {
			name = "CYBREX_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = cybrex_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_league_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		OR = {
			has_country_flag = league_world_found
			any_owned_planet = {
				has_modifier = first_league_homeworld
			}
		}

		NOT = { has_country_flag = league_research_started }
	}

	effect = {
		enable_special_project = {
			name = "LEAGUE_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = league_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_baol_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		 has_country_flag = last_baol_system
		 NOT = { has_country_flag = baol_research_started }
	}

	effect = {
		enable_special_project = {
			name = "BAOL_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = baol_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_zroni_research = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 750
		}
	}

	ai_weight = {
		weight = 0
	}

	potential = {
		 has_country_flag = last_zroni_system
		 NOT = { has_country_flag = zroni_research_started }
	}

	effect = {
		enable_special_project = {
			name = "ZRONI_SECRETS"
			location = capital_scope
			owner = ROOT
		}

		hidden_effect = {
			set_country_flag = zroni_research_started
			country_event = { id = ancrel.10040 }
		}
	}
}

artifact_precursor_clue = {
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 500
		}
	}

	potential = {
		is_ai = no

		OR = {
			AND = {
				has_event_chain = "vultaum_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_1 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = vultaum_chain
						counter = vultaum_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "yuht_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_2 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = yuht_chain
						counter = yuht_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "first_league_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_3 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = first_league_chain
						counter = first_league_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "irassian_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_4 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = irassian_chain
						counter = irassian_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "cybrex_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_5 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = cybrex_chain
						counter = cybrex_artifacts
					}
				}
			}
		}
	}

	allow = {
		NOT = { has_modifier = artifact_precursor_insight_cooldown }
	}

	effect = {
		custom_tooltip = artifact_precursor_clue_effect

		hidden_effect = {
			owner = {
				country_event = { id = precursor.320 }
			}
			add_modifier = {
				modifier = "artifact_precursor_insight_cooldown"
				days = 1800
			}
		}
	}
}

# Shown when the empire has an active precursor investigation but cannot yet reach a
# precursor site, so artifact_precursor_clue is hidden. Tells the player what is missing
# (notably: Nomads need a Waystation in or next to a system with precursor remains).
artifact_precursor_clue_locked = {
	potential = {
		is_ai = no

		# Has an active, uncompleted precursor investigation...
		OR = {
			AND = {
				has_event_chain = "vultaum_chain"
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = vultaum_chain
						counter = vultaum_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "yuht_chain"
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = yuht_chain
						counter = yuht_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "first_league_chain"
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = first_league_chain
						counter = first_league_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "irassian_chain"
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = irassian_chain
						counter = irassian_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "cybrex_chain"
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = cybrex_chain
						counter = cybrex_artifacts
					}
				}
			}
		}

		# ...but no accessible precursor site, so artifact_precursor_clue itself is hidden.
		NOR = {
			AND = {
				has_event_chain = "vultaum_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_1 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = vultaum_chain
						counter = vultaum_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "yuht_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_2 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = yuht_chain
						counter = yuht_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "first_league_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_3 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = first_league_chain
						counter = first_league_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "irassian_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_4 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = irassian_chain
						counter = irassian_artifacts
					}
				}
			}
			AND = {
				has_event_chain = "cybrex_chain"
				has_accessible_precursor_system = { PRECURSOR_FLAG = precursor_5 }
				NOT = {
					has_completed_event_chain_counter = {
						event_chain = cybrex_chain
						counter = cybrex_artifacts
					}
				}
			}
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = "artifact_precursor_clue_locked_failtext"
			always = no
		}
	}
}

artifact_analysis = {
	sound = "ga_artifact_analysis"
	resources = {
		category = artifact_actions
		cost = {
			minor_artifacts = 1
			multiplier = value:scaled_artifact_cost|BASE|300|INCREASE|50|INCREASE_VARIABLE|artifact_analysis_usage_count|
		}
	}

	potential = {
		has_grand_archive_dlc = yes
	}

	allow = {
		if = {
			limit = {
				check_variable = { which = artifact_analysis_usage_count value >= 5 }
			}
			custom_tooltip = {
				fail_text = "artifact_analysis_max_usages_reached"
				always = no
			}
		}
		else = {
			custom_tooltip = {
				fail_text = "artifact_analysis_cannot_give_artifact"
				OR = {
					can_artifact_analysis_give_xeno_geology = yes
					can_artifact_analysis_give_aesthetic_wonder = yes
					can_artifact_analysis_give_historical_item = yes
				}
			}
		}
	}

	effect = {
		custom_tooltip = artifact_analysis_effect_tt
		hidden_effect = {
			change_variable = {
				which = artifact_analysis_usage_count
				value = 1
			}
			artifact_analysis_effect = yes
		}
	}
}
