@gaiaCost = 7500
@gaiaTime = 3600
@gaiaBiomassCost = 3500

@nukedCost = 10000
@nukedTime = 7200
@nukedBiomassCost = 5000

@highestCost = 12500
@highestTime = 9000
@highestBiomassCost = 6000

@barrenCostCheap = 5000
@barrenTimeShort = 3600
@barrenBiomassCostCheap = 2500

@barrenCostExpensive = 10000
@barrenTimeLong = 5400
@barrenBiomassCostExpensive = 5000

@barrenCostExtreme = 15000
@barrenTimeExtreme = 7200
@barrenBiomassCostExtreme = 7500

@machineCost = 10000
@machineTime = 7200
@machineBiomassCost = 8000 #Intentionally larger

@hiveCost = 10000
@hiveTime = 7200
@hiveBiomassCost = 2500 #Intentionally smaller

@lClusterCost = 1000
@lClusterBiomassCost = 2000 #Intentionally larger
@lClusterTime = 360

################
## Tomb World ##
################

################
## Gaia World ##
################

##################
## Barren World ##
##################

terraform_link = {
	from = "pc_barren"
	to = "pc_arid"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @barrenCostExtreme
			BIOMASS_COST = @barrenBiomassCostExtreme
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @barrenTimeExtreme

	potential = {
		exists = owner
		from = { has_modifier = terraforming_candidate }
		NOT = { has_global_flag = has_planetary_stations_mod }
	}

	condition = {
		has_technology = "tech_climate_restoration"
	}

	effect = {
		from = { remove_modifier = terraforming_candidate }
	}

	ai_weight = {
		weight = 5
	}
}

terraform_link = {
	from = "pc_barren_cold"
	to = "pc_tundra"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @barrenCostCheap
			BIOMASS_COST = @barrenBiomassCostCheap
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @barrenTimeShort

	potential = {
		exists = owner
		from = { has_modifier = terraforming_candidate }
		NOT = { has_global_flag = has_planetary_stations_mod }
	}

	condition = {
		has_technology = "tech_climate_restoration"
	}

	effect = {
		from = { remove_modifier = terraforming_candidate }
	}

	ai_weight = {
		weight = 5
	}
}

terraform_link = {
	from = "pc_frozen"
	to = "pc_ocean"

	resources = {
		category = terraforming_ocean

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @barrenCostCheap
			BIOMASS_COST = @barrenBiomassCostCheap
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @barrenTimeShort

	potential = {
		exists = owner
		OR  = {
			has_aquatic_trait = yes
			has_trait = trait_robot_aquatic
		}
		from = { has_modifier = frozen_terraforming_candidate }
		NOT = { has_global_flag = has_planetary_stations_mod }
	}

	condition = {
		has_ascension_perk = ap_hydrocentric
		has_technology = "tech_climate_restoration"
	}

	effect = {
		from = { remove_modifier = frozen_terraforming_candidate }
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 4
			has_aquatic_trait = yes
		}
		}
	}
}

###################
## Machine World ##
###################

terraform_link = {
	to = "pc_machine"
	from = "pc_barren"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
		from = { has_modifier = terraforming_candidate }
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 20
		#It's a barren world!
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_barren_cold"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
		from = { has_modifier = terraforming_candidate }
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 20
		#It's a barren world!
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_gaia"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	condition = {
		from = {
			OR = {
				is_owned_by = root
				NOT = { has_modifier = "holy_planet" }
			}
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_hive"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_desert"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	from = "pc_arid"
	to = "pc_machine"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_savannah"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_arctic"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_tundra"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_alpine"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_continental"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_tropical"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_machine"
	from = "pc_ocean"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_desert"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	to = "pc_arid"
	from = "pc_machine"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_savannah"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_arctic"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_tundra"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_alpine"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_continental"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_tropical"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_ocean"

	resources = {
		category = terraforming_ocean

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @machineCost
			BIOMASS_COST = @machineBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
		modifier = {
			factor = 4
			has_aquatic_trait = yes
		}
	}
}

###################
## Hive World ##
###################

terraform_link = {
	to = "pc_hive"
	from = "pc_barren"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
		from = { has_modifier = terraforming_candidate }
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 20
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_barren_cold"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
		from = { has_modifier = terraforming_candidate }
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 20
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_gaia"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	condition = {
		from = {
			OR = {
				is_owned_by = root
				NOT = { has_modifier = "holy_planet" }
			}
		}
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_machine"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_desert"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_pop_group = {
					NOT = { has_trait = trait_hive_mind }
				}
			}
		}
		modifier = {
			factor = 0
			from = {
				is_colony = no
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	from = "pc_arid"
	to = "pc_hive"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_savannah"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_arctic"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_tundra"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_alpine"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_continental"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_tropical"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_ocean"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_desert"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	to = "pc_arid"
	from = "pc_hive"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_savannah"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_arctic"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_tundra"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_alpine"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_continental"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_tropical"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_ocean"

	resources = {
		category = terraforming_ocean

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @hiveCost
			BIOMASS_COST = @hiveBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		modifier = {
			factor = 100
			is_wilderness_empire = yes
		}
	}
}

#############
# L-Cluster #
#############

terraform_link = {
	from = pc_gray_goo
	to = pc_desert

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_arid

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_savannah

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_ocean

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming_ocean

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			has_aquatic_trait = yes
		}
		modifier = {
			factor = 2
			has_trait = trait_robot_aquatic
		}
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_continental

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_tropical

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_arctic

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_alpine

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_tundra

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		exists = owner from = { has_modifier = terraforming_candidate } }
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

## Tombworlding

terraform_link = {
	from = "pc_desert"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_savannah"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_arid"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_tropical"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_ocean"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_continental"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_alpine"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_tundra"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_arctic"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_gaia"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = { #It takes real effort to destroy something so perfect
			energy = 2500
			exotic_gases = 200
			volatile_motes = 200
		}
	}

	duration = 5400

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}

	condition = {
		has_technology = tech_climate_restoration
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_barren"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = @highestCost
		}
	}

	duration = @highestTime

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
		from = { has_modifier = terraforming_candidate }
	}

	condition = {
		has_technology = tech_climate_restoration
	}

	effect = {
		from = { remove_modifier = terraforming_candidate }
	}

	ai_weight = {
		weight = 10
	}
}

################
## Toxic World ##
################

terraform_link = {
	from = "pc_toxic"
	to = "pc_arid"

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @nukedCost
			BIOMASS_COST = @nukedBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @nukedTime

	potential = {
		exists = owner
		from = { has_modifier = toxic_terraforming_candidate }
		NOT = { has_global_flag = has_planetary_stations_mod }
	}
	condition = {
		OR = {
			has_ascension_perk = ap_detox
			has_country_flag = knights_detox
		}
		has_technology = "tech_climate_restoration"
	}

	effect = {
		from = { detox_hangover = yes }
	}

	ai_weight = {
		weight = 5
	}
}

##Nanotech Links
terraform_link = {
	from = pc_nanotech
	to = pc_desert

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_arid

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_savannah

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_ocean

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming_ocean

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
		modifier = {
			factor = 2
			has_aquatic_trait = yes
		}
		modifier = {
			factor = 2
			has_trait = trait_robot_aquatic
		}
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_continental

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_tropical

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_arctic

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_alpine

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_tundra

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_gaia

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		inline_script = {
			script = terraform/triggered_costs
			ENERGY_COST = @lClusterCost
			BIOMASS_COST = @lClusterBiomassCost
		}
	}

	inline_script = {
		script = terraform/wilderness_biomass
	}

	duration = @lClusterTime

	potential = {
		has_ascension_perk = "ap_world_shaper"
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_machine

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime
	potential = {
		has_ascension_perk = ap_machine_worlds
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_hive

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime
	potential = {
		has_ascension_perk = ap_hive_worlds
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}
	ai_weight = {
		weight = 10
	}
}

# Evopred Hive World Links

terraform_link = {
	to = pc_hive
	from = pc_savannah

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_desert

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_tropical

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_arid

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_continental

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_ocean

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_tundra

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_arctic

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_alpine

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_gaia

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_relic

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_nuked

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_city

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	to = pc_hive
	from = pc_machine

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		always = no
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

# Wilderness Links
@wildernessCost = 500
@wildernessTime = 1080

terraform_link = {
	from = "pc_continental"
	to = "pc_continental"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_wet
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_ocean"
	to = "pc_ocean"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_wet
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_tropical"
	to = "pc_tropical"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_wet
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_desert"
	to = "pc_desert"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_dry
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_arid"
	to = "pc_arid"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_dry
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_savannah"
	to = "pc_savannah"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_dry
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_tundra"
	to = "pc_tundra"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_cold
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_arctic"
	to = "pc_arctic"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_cold
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_alpine"
	to = "pc_alpine"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		has_country_flag = started_cold
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

terraform_link = {
	from = "pc_gaia"
	to = "pc_gaia"

	resources = {
		category = terraforming

		cost = {
			biomass = @wildernessCost
		}
	}

	duration = @wildernessTime

	potential = {
		has_origin = origin_wilderness
		from = { is_colony = no }
	}

	ai_weight = {
		weight = 100
	}

	inline_script = {
		script = terraform/wilderness_biomass_special
	}
}

##############
## VOLCANIC ##
##############

terraform_link = {
	to = "pc_machine"
	from = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_ascension_perk = ap_machine_worlds
	}
	condition = {
		has_technology = "tech_volcanic_terraforming"
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			from = {
				any_owned_species = {
					NOR = {
						has_trait = trait_machine_unit
						has_trait = trait_mechanical
					}
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	from = "pc_barren"
	to = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = 5000
		}
	}

	duration = 3600

	potential = {
		exists = owner
		from = { has_modifier = terraforming_candidate }
		has_country_flag = allow_terraforming_into_volcanic
	}

	condition = {
		has_technology = "tech_climate_restoration"
	}

	effect = {
		from = { remove_modifier = terraforming_candidate }
	}

	ai_weight = {
		weight = 5
	}
}

terraform_link = {
	from = "pc_nuked"
	to = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = 10000
		}
	}

	duration = 7200

	potential = {
		exists = owner
		has_country_flag = allow_terraforming_into_volcanic
	}
	condition = {
		has_technology = "tech_climate_restoration"
	}

	ai_weight = {
		weight = 0
		modifier = {
			weight = 5
			should_terraform_trigger = {
				CLASS_FROM = pc_nuked
				CLASS_TO = pc_volcanic
			}
		}
	}
}

terraform_link = {
	from = "pc_machine"
	to = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = @machineCost
		}
	}

	duration = @machineTime

	potential = {
		exists = owner
		has_technology = tech_climate_restoration
		has_country_flag = allow_terraforming_into_volcanic
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_machine_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_gaia"
	to = "pc_volcanic"

	resources = {
		category = terraforming

		cost = { #It takes real effort to destroy something so perfect
			energy = 2500
			exotic_gases = 200
			volatile_motes = 200
		}
	}

	duration = 5400

	potential = {
		exists = owner
		has_country_flag = allow_terraforming_into_volcanic
	}
	condition = {
		has_technology = tech_climate_restoration
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to volcanic world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_volcanic

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		cost = {
			energy = @lClusterCost
		}
	}
	duration = 360
	potential = {
		exists = owner
		from = { has_modifier = terraforming_candidate }
		has_country_flag = allow_terraforming_into_volcanic
	}
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	to = "pc_hive"
	from = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_ascension_perk = ap_hive_worlds
	}
	condition = {
		has_technology = "tech_volcanic_terraforming"
	}

	ai_weight = {
		weight = 10
		modifier = {
			factor = 0
			NOT = { has_origin = origin_necrophage }
			from = {
				any_owned_species = {
					NOT = { has_trait = trait_hive_mind }
					is_sapient = yes
				}
			}
		}
		modifier = {
			factor = 0
			owner = {
				any_owned_planet = { is_terraforming = yes }
			}
		}
		modifier = {
			factor = 0
			owner = {
				OR = {
					has_deficit = energy
					has_deficit = minerals
					has_deficit = food
					has_deficit = consumer_goods
				}
			}
		}
	}
}

terraform_link = {
	from = "pc_toxic"
	to = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = 10000
		}
	}

	duration = 3600

	potential = {
		exists = owner
		from = { has_modifier = toxic_terraforming_candidate }
		has_country_flag = allow_terraforming_into_volcanic
	}
	condition = {
		has_ascension_perk = "ap_detox"
		has_technology = "tech_climate_restoration"
	}

	effect = {
		from  = { detox_hangover = yes }
	}

	ai_weight = {
		weight = 5
	}
}

terraform_link = {
	to = pc_hive
	from = pc_volcanic

	resources = {
		category = terraforming

		cost = {
			energy = 0
		}
	}

	duration = 3600

	condition = {
		has_technology = "tech_volcanic_terraforming"
	}

	potential = {
		exists = owner
		is_mutation_authority = yes
		is_hive_empire = yes
		has_origin = origin_evolutionary_predators
	}
}

terraform_link = {
	from = pc_nanotech
	to = pc_volcanic

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		cost = {
			energy = @lClusterCost
		}
	}
	duration = 360
	potential = {
		has_country_flag = allow_terraforming_into_volcanic
		NOT = {
			has_tradition = tr_nanotech_adopt
		}
	}

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = pc_gray_goo
	to = pc_volcanic

	condition = { has_technology = "tech_climate_restoration" }

	resources = {
		category = terraforming

		cost = {
			energy = @lClusterCost
		}
	}
	duration = 360
	potential = {
		exists = owner
		from = { has_modifier = terraforming_candidate }
		has_country_flag = allow_terraforming_into_volcanic
	}
	effect = { from = { remove_modifier = terraforming_candidate } }

	ai_weight = {
		weight = 10
	}
}

terraform_link = {
	from = "pc_hive"
	to = "pc_volcanic"

	resources = {
		category = terraforming

		cost = {
			energy = @hiveCost
		}
	}

	duration = @hiveTime

	potential = {
		exists = owner
		has_country_flag = allow_terraforming_into_volcanic
		has_technology = tech_climate_restoration
	}

	effect = {
		from = {
			reroll_deposits = yes
			clear_blockers = yes
		}
	}

	ai_weight = {
		weight = 5
		modifier = {
			factor = 0
			is_hive_empire = yes
		}
	}
}

terraform_link = {
	from = "pc_volcanic"
	to = "pc_nuked"

	resources = {
		category = terraforming

		cost = {
			energy = 1000
			exotic_gases = 100
			volatile_motes = 100
		}
	}

	duration = 3600

	potential = {
		exists = owner
		has_policy_flag = relentless_industrialists_study
		has_country_flag = relentless_industrialists_study_completed
	}
	condition = {
		has_technology = "tech_volcanic_terraforming"
	}

	ai_weight = { #If we ever enable this: make sure the AI doesn't loop (terraform to tomb world and then back). And also check ai_budgets
		weight = 0
	}
}

terraform_link = {
	from = "pc_volcanic"
	to = "pc_gaia"

	resources = {
		category = terraforming

		cost = {
			energy = @gaiaCost
		}
	}

	duration = @gaiaTime

	potential = {
		OR = {
			from = { has_carrier_flag = terraform_nucleus_transfixed }
			AND = {
				exists = owner
				has_ascension_perk = "ap_world_shaper"
			}
		}
	}

	ai_weight = {
		weight = 1
	}
}

