#######################################
######### STRATEGIC RESOURCES #########
#######################################

#################
# Non-clustered #
#################

#Living Metal
tech_mine_living_metal = {
	cost = @tier5cost1
	area = engineering
	tier = 5
	category = { materials }
	prerequisites = { "tech_space_construction" }
	weight = @tier5weight1

	technology_swap = {
		name = tech_nomads_mine_living_metal
		inherit_icon = yes
		inherit_effects = no

		trigger = {
			is_nomadic = yes
		}

		modifier = {
			arkship_harvest_resources_sr_living_metal_produces_mult = @arkship_mining_tech_harvest_bonus
		}
	}

	weight_modifier = {
		factor = 0.5
		modifier = {
			factor = 0
			is_nomadic = no
			NOT = {
				any_planet_within_border = {
					has_deposit = d_living_metal_deposit
				}
			}
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				has_country_flag = sr_living_metal_found
			}
		}
	}

	ai_weight = {
		modifier = {
			factor = 20
			has_country_flag = dragon_breeders #so they can recruit Fledgeling Dragons
		}
	}
}

#Betharian Refining
tech_mine_betharian = {
	cost = @tier1cost2
	area = engineering
	tier = 2
	category = { materials }
	prerequisites = { "tech_space_construction" }
	weight = @tier1weight2

	weight_modifier = {
		factor = 2
		modifier = {
			factor = 0
			NOT = {
				any_owned_planet = {
					has_deposit = d_betharian_deposit
				}
			}
		}
	}

	ai_weight = {
		factor = @zone_clear_ai_tech_factor
	}
}

# ##################
# Rare Resources
# ##################

#Volatile Mote Mining
tech_mine_volatile_motes = {
	icon = tech_volatile_motes
	cost = @tier2cost1
	area = physics
	tier = 2
	category = { particles }
	prerequisites = { "tech_space_construction" }
	weight = @tier2weight1

	technology_swap = {
		name = tech_nomads_mine_volatile_motes
		inherit_icon = yes
		inherit_effects = no

		trigger = {
			is_nomadic = yes
		}

		modifier = {
			arkship_harvest_resources_volatile_motes_produces_mult = @arkship_mining_tech_harvest_bonus
		}
	}

	weight_modifier = {
		factor = 2
		modifier = {
			factor = 0
			is_nomadic = no
			NOT = {
				any_owned_planet = {
					has_volatile_motes_deposit = yes
				}
				any_planet_within_border = {
					OR = {
						has_deposit = d_volatile_motes_1
						has_deposit = d_volatile_motes_2
						has_deposit = d_volatile_motes_3
						has_deposit = d_volatile_motes_4
						has_deposit = d_volatile_motes_5
					}
				}
			}
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				has_country_flag = volatile_motes_found
			}
		}
	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor #important resource
	}
}

#Volatile Material Plants
tech_volatile_motes = {
	cost = @tier2cost1
	area = physics
	tier = 2
	category = { particles }
	prerequisites = { "tech_basic_industry" }
	weight = @tier2weight1

	technology_swap = { # Wilderness icon swap
		name = tech_wilderness_volatile_motes
		inherit_icon = no
		inherit_effects = yes
		trigger = {
			is_wilderness_empire = yes
		}
	}

	weight_modifier = {
		factor = 2
		modifier = {
			factor = 0.5
			OR = {
				any_owned_planet = {
					has_volatile_motes_deposit = yes
				}
				any_planet_within_border = {
					OR = {
						has_deposit = d_volatile_motes_1
						has_deposit = d_volatile_motes_2
						has_deposit = d_volatile_motes_3
						has_deposit = d_volatile_motes_4
						has_deposit = d_volatile_motes_5
					}
				}
			}
		}

	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor #important resource
	}
}

#Exotic Gas Extraction
tech_mine_exotic_gases = {
	icon = tech_exotic_gases
	cost = @tier2cost1
	area = engineering
	tier = 2
	category = { materials }
	prerequisites = { "tech_space_construction" }
	weight = @tier2weight1

	technology_swap = {
		name = tech_nomads_mine_exotic_gases
		inherit_icon = yes
		inherit_effects = no

		trigger = {
			is_nomadic = yes
		}

		modifier = {
			arkship_harvest_resources_exotic_gases_produces_mult = @arkship_mining_tech_harvest_bonus
		}
	}

	weight_modifier = {
		factor = 2

		modifier = {
			factor = 0
			is_nomadic = no
			NOT = {
				any_owned_planet = {
					has_exotic_gases_deposit = yes
				}
				any_planet_within_border = {
					OR = {
						has_deposit = d_exotic_gases_1
						has_deposit = d_exotic_gases_2
						has_deposit = d_exotic_gases_3
						has_deposit = d_exotic_gases_4
						has_deposit = d_exotic_gases_5
					}
				}
			}
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				has_country_flag = exotic_gases_found
			}
		}
	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor #important resource
	}
}

#Exotic Gas Refining
tech_exotic_gases = {
	cost = @tier2cost1
	area = engineering
	tier = 2
	category = { materials }
	prerequisites = { "tech_basic_industry" }
	weight = @tier2weight1

	technology_swap = { # Wilderness icon swap
		name = tech_wilderness_exotic_gases
		inherit_icon = no
		inherit_effects = yes
		trigger = {
			is_wilderness_empire = yes
		}
	}

	weight_modifier = {
		factor = 2
		modifier = {
			factor = 0.5
			OR = {
				any_owned_planet = {
					has_exotic_gases_deposit = yes
				}
				any_planet_within_border = {
					OR = {
						has_deposit = d_exotic_gases_1
						has_deposit = d_exotic_gases_2
						has_deposit = d_exotic_gases_3
						has_deposit = d_exotic_gases_4
						has_deposit = d_exotic_gases_5
					}
				}
			}
		}
	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor #important resource
	}
}

#Rare Crystal Mining
tech_mine_rare_crystals = {
	cost = @tier2cost1
	area = engineering
	tier = 2
	category = { materials }
	prerequisites = { "tech_space_construction" }
	weight = @tier2weight1

	technology_swap = {
		name = tech_nomads_mine_rare_crystals
		inherit_icon = yes
		inherit_effects = no

		trigger = {
			is_nomadic = yes
		}

		modifier = {
			arkship_harvest_resources_rare_crystals_produces_mult = @arkship_mining_tech_harvest_bonus
		}
	}

	weight_modifier = {
		factor = 2

		modifier = {
			factor = 0
			is_nomadic = no
			NOT = {
				any_owned_planet = {
					has_rare_crystals_deposit = yes
				}
				any_planet_within_border = {
					OR = {
						has_deposit = d_rare_crystals_1
						has_deposit = d_rare_crystals_2
						has_deposit = d_rare_crystals_3
						has_deposit = d_rare_crystals_4
						has_deposit = d_rare_crystals_5
					}
				}
			}
		}
		modifier = {
			factor = 0
			is_nomadic = yes
			NOT = {
				has_country_flag = rare_crystals_found
			}
		}
		modifier = {
			add = 1
			has_country_flag = tech_mine_rare_crystals_culling_boost
		}
	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor #strategic resource
	}
}

#Rare Crystal Manufacturing
tech_rare_crystals = {
	cost = @tier2cost1
	area = engineering
	tier = 2
	category = { materials }
	prerequisites = { "tech_basic_industry" }
	weight = @tier2weight1

	technology_swap = { # Wilderness icon swap
		name = tech_wilderness_rare_crystals
		inherit_icon = no
		inherit_effects = yes
		trigger = {
			is_wilderness_empire = yes
		}
	}

	weight_modifier = {
		factor = 2
		modifier = {
			factor = 0.5
			OR = {
				any_owned_planet = {
					has_rare_crystals_deposit = yes
				}
				any_planet_within_border = {
					OR = {
						has_deposit = d_rare_crystals_1
						has_deposit = d_rare_crystals_2
						has_deposit = d_rare_crystals_3
						has_deposit = d_rare_crystals_4
						has_deposit = d_rare_crystals_5
					}
				}
			}
		}

	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor
	}
}

#Zro Distillation
tech_mine_zro = {
	cost = @tier3cost2
	area = society
	tier = 3
	category = { psionics }
	is_rare = yes
	prerequisites = { "tech_sensors_3" }
	is_reverse_engineerable = no
	weight = @tier3weight2

	technology_swap = {
		name = tech_mine_zro_machine_gestalt
		inherit_icon = yes
		inherit_effects = yes
		trigger = {
			is_gestalt = yes
			is_robot_empire = yes
		}
	}

	technology_swap = {
		name = tech_mine_zro_machine_non_gestalt
		inherit_icon = yes
		inherit_effects = yes
		trigger = {
			is_gestalt = no
			is_robot_empire = yes
		}
	}

	technology_swap = {
		name = tech_mine_zro_hive
		inherit_icon = yes
		inherit_effects = yes
		trigger = {
			is_hive_empire = yes
			is_wilderness_empire = no
		}
	}

	technology_swap = {
		name = tech_mine_zro_wilderness
		inherit_icon = yes
		inherit_effects = yes
		trigger = {
			is_wilderness_empire = yes
		}
	}

	## unlock see zro ore

	weight_modifier = {
		modifier = {
			factor = 0.10
			NOR = {
				has_trait_in_council = { TRAIT = leader_trait_expertise_psionics }
				has_trait_in_council = { TRAIT = leader_trait_curator }
			}
		}
		modifier = {
			factor = 0.10
			NOT = {
				has_technology = "tech_psionic_theory"
			}
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_mine_zro
		}
		modifier = {
			factor = 2
			any_owned_pop_group = {
				is_psionic_species = yes
			}
		}
		modifier = {
			factor = 1.25
			any_owned_pop_group = {
				is_latent_psionic_species = yes
			}
			NOT = {
				any_owned_pop_group = {
					is_psionic_species = yes
				}
			}
		}
		modifier = {
			factor = 2
			has_paragon_dlc = no
			any_owned_leader = {
				has_trait = leader_trait_shroudwalker
			}
		}
		modifier = {
			factor = 2	# On top of regular bonus from trait.
			has_trait_in_council = { TRAIT = leader_trait_expertise_psionics }
		}
	}

	ai_weight = {
		factor = 2.5 # extremely rare tech (especially if you don't have psionic theory)
		modifier = {
			factor = 1.25
			has_trait_in_council = { TRAIT = leader_trait_expertise_psionics }
		}
		modifier = {
			factor = 5
			has_finished_psionic_tradition = yes
		}
	}
}

#Dark Matter Drawing
tech_mine_dark_matter = {
	cost = @tier3cost3
	area = physics
	tier = 3
	category = { field_manipulation }
	prerequisites = { "tech_sensors_4" }
	weight = @tier3weight3

	## unlock see dark matter

	technology_swap = {
		name = tech_mine_dark_matter
		inherit_icon = yes
		inherit_effects = yes
		trigger = {
			has_ascension_perk = ap_weather_control
		}
		prereqfor_desc = {
			custom = {
				title = tech_generate_gravity_storm_tt
			}
		}
		weight = {
			factor = 1
		}
	}

	weight_modifier = {
		modifier = {
			factor = 0
			NOR = {
				has_country_flag = sr_dark_matter_found
				any_system_within_border = { any_system_planet = { has_resource = { type = sr_dark_matter amount > 0 } } }
				AND = {
					is_nomadic = yes
					any_owned_nonprimary_starbase = {
						is_waystation_starbase = yes
						solar_system = {
							any_system_planet = { has_resource = { type = sr_dark_matter amount > 0 } }
						}
					}
				}
				any_relation = {
					AND = {
						is_country_type = default
						has_communications = ROOT
						has_technology = tech_mine_dark_matter
					}
				}
			}
		}
	}

	ai_weight = {
		factor = 2 #strategic resource
	}
}

# Nanite Transmutation
tech_nanite_transmutation = {
	cost = @tier2cost3
	area = engineering
	tier = 2
	category = { materials }
	weight = @tier2weight3
	is_rare = yes

	potential = {
		host_has_dlc = "Distant Stars Story Pack"
	}

	weight_modifier = {
		factor = 0.50
		modifier = {
			factor = 0
			NOR = {
				any_system_within_border = { any_system_planet = { has_resource = { type = nanites amount > 0 } } }
				AND = {
					is_nomadic = yes
					any_owned_nonprimary_starbase = {
						is_waystation_starbase = yes
						solar_system = {
							any_system_planet = { has_resource = { type = nanites amount > 0 } }
						}
					}
				}
			}
		}
		inline_script = {
			script = technologies/rare_technologies_weight_modifiers
			TECHNOLOGY = tech_nanite_transmutation
		}
	}

	ai_weight = {
		factor = @strategic_resource_ai_tech_factor #important resource

	}
}
