
terraform_to_desert_planet = {
	change_pc = pc_desert
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_arid_planet = {
	change_pc = pc_arid
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_continental_planet = {
	change_pc = pc_continental
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_ocean_planet = {
	change_pc = pc_ocean
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_tropical_planet = {
	change_pc = pc_tropical
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_tundra_planet = {
	change_pc = pc_tundra
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_arctic_planet = {
	change_pc = pc_arctic
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_savannah_planet = {
	change_pc = pc_savannah
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

terraform_to_alpine_planet = {
	change_pc = pc_alpine
	if = {
		limit = { has_carrier_flag = planet_earth }
		all_earth_deposit_terraform = yes
	}
	#reroll_deposits = yes
	fire_on_action = { on_action = on_real_terraforming_complete scopes = { from = this.owner } }
}

clear_temperature_terraform_passed_flags = {
	if = {
		limit = { has_situation_flag = extremely_cold_climate_passed }
		remove_situation_flag = extremely_cold_climate_passed
	}
	if = {
		limit = { has_situation_flag = cold_climate_passed }
		remove_situation_flag = cold_climate_passed
	}
	if = {
		limit = { has_situation_flag = cold_temperate_climate_passed }
		remove_situation_flag = cold_temperate_climate_passed
	}
	if = {
		limit = { has_situation_flag = temperate_continental_climate_passed }
		remove_situation_flag = temperate_continental_climate_passed
	}
	if = {
		limit = { has_situation_flag = continental_climate_passed }
		remove_situation_flag = continental_climate_passed
	}
	if = {
		limit = { has_situation_flag = moderate_climate_passed }
		remove_situation_flag = moderate_climate_passed
	}
	if = {
		limit = { has_situation_flag = warm_climate_passed }
		remove_situation_flag = warm_climate_passed
	}
	if = {
		limit = { has_situation_flag = hot_climate_passed }
		remove_situation_flag = hot_climate_passed
	}
	if = {
		limit = { has_situation_flag = extremely_hot_climate_passed }
		remove_situation_flag = extremely_hot_climate_passed
	}
}

clear_humidity_terraform_passed_flags = {
	if = {
		limit = { has_situation_flag = extremely_dry_climate_passed }
		remove_situation_flag = extremely_dry_climate_passed
	}
	if = {
		limit = { has_situation_flag = dry_climate_passed }
		remove_situation_flag = dry_climate_passed
	}
	if = {
		limit = { has_situation_flag = arid_climate_passed }
		remove_situation_flag = arid_climate_passed
	}
	if = {
		limit = { has_situation_flag = temperate_climate_passed }
		remove_situation_flag = temperate_climate_passed
	}
	if = {
		limit = { has_situation_flag = humid_continental_climate_passed }
		remove_situation_flag = humid_continental_climate_passed
	}
	if = {
		limit = { has_situation_flag = moderately_humid_climate_passed }
		remove_situation_flag = moderately_humid_climate_passed
	}
	if = {
		limit = { has_situation_flag = wet_climate_passed }
		remove_situation_flag = wet_climate_passed
	}
	if = {
		limit = { has_situation_flag = extremely_wet_climate_passed }
		remove_situation_flag = extremely_wet_climate_passed
	}
}

clear_eco_creation_passed_flags = {
	if = {
		limit = { has_situation_flag = litho_stabilization_passed }
		remove_situation_flag = litho_stabilization_passed
	}
	if = {
		limit = { has_situation_flag = air_purification_passed }
		remove_situation_flag = air_purification_passed
	}
	if = {
		limit = { has_situation_flag = simple_life_seeding_passed }
		remove_situation_flag = simple_life_seeding_passed
	}
	if = {
		limit = { has_situation_flag = climate_improvement_passed }
		remove_situation_flag = climate_improvement_passed
	}
	if = {
		limit = { has_situation_flag = biosphere_formation_passed }
		remove_situation_flag = biosphere_formation_passed
	}
}

clear_radiation_terraform_passed_flags = {
	if = {
		limit = { has_situation_flag = irradiation_environment_passed }
		remove_situation_flag = irradiation_environment_passed
	}
	if = {
		limit = { has_situation_flag = nuclear_winter_passed }
		remove_situation_flag = nuclear_winter_passed
	}
	if = {
		limit = { has_situation_flag = radioactive_contamination_passed }
		remove_situation_flag = radioactive_contamination_passed
	}
}

random_deposit_terraform_cold_to_warm = {
	
	random_deposit = {
		limit = {
			OR = {
				is_deposit_type = d_massive_glacier
				is_deposit_type = d_noxious_swamp
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_cold_to_warm_deposit = yes }
		if = {
			limit = { is_deposit_type = d_frozen_gas_lake }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_searing_desert
				}
				else = {
					add_deposit = d_rushing_waterfalls
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lichen_fields }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_forgiving_tundra }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_nutritious_mudland
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_boggy_fens
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fungal_caves }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_great_river
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lush_jungle
				}
				else = {
					add_deposit = d_fertile_lands
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_fungal_forest }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_marvelous_oasis
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_teeming_reef
				}
				else = {
					add_deposit = d_black_soil
				}
			}
			remove_deposit = yes
		}
	}
	
}

random_deposit_terraform_warm_to_hot = {

	every_deposit = {
		limit = {
			OR = {
				is_deposit_type = d_massive_glacier
				is_deposit_type = d_noxious_swamp
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_warm_to_hot_deposit = yes }
		if = {
			limit = { is_deposit_type = d_underwater_vent }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_geothermal_vent
				}
				else = {
					add_deposit = d_tempestous_mountain
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_searing_desert
				}
				else = {
					add_deposit = d_green_hills
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_nutritious_mudland
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_bountiful_plains
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_boggy_fens }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_nutritious_mudland
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_bountiful_plains
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lush_jungle
				}
				else = {
					add_deposit = d_great_river
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_teeming_reef }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_tropical_island
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_tropical_island
				}
				else = {
					add_deposit = d_black_soil
				}
			}
			remove_deposit = yes
		}
	}
}

random_deposit_terraform_hot_to_warm = {

	random_deposit = {
		limit = {
			NOT = { prev = { is_dry_climate = yes } }
			OR = {
				is_deposit_type = d_deep_sinkhole
				is_deposit_type = d_quicksand_basin
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_hot_to_warm_deposit = yes }
		if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_bountiful_plains
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_nutritious_mudland }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_bountiful_plains
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_boggy_fens
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_marvelous_oasis
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_teeming_reef
				}
				else = {
					add_deposit = d_black_soil
				}
			}
			remove_deposit = yes
		}
	}
}

random_deposit_terraform_warm_to_cold = {

	every_deposit = {
		limit = {
			OR = {
				is_deposit_type = d_dense_jungle
				is_deposit_type = d_toxic_kelp
				is_deposit_type = d_deep_sinkhole
				is_deposit_type = d_quicksand_basin
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_warm_to_cold_deposit = yes }
		if = {
			limit = { is_deposit_type = d_arid_highlands }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rushing_waterfalls }
			prev = { add_deposit = d_frozen_gas_lake }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_underwater_vent }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_geothermal_vent
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_geothermal_vent
				}
				else = {
					add_deposit = d_ore_rich_caverns
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_geothermal_vent
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_geothermal_vent
				}
				else = {
					add_deposit = d_rich_mountain
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_submerged_ore_veins }
			prev = { add_deposit = d_rich_mountain }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_veiny_cliffs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_green_hills }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_boggy_fens }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lush_jungle }
			prev = { add_deposit = d_fungal_caves }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_great_river }
			prev = { add_deposit = d_fungal_caves }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_teeming_reef }
			prev = { add_deposit = d_fungal_forest }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_marvelous_oasis }
			prev = { add_deposit = d_fungal_forest }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = { add_deposit = d_fungal_forest }
			remove_deposit = yes
		}
	}
}

random_deposit_terraform_dry_to_temperate = {

	random_deposit = {
		limit = {
			OR = {
				AND = {
					NOT = { prev = { is_hot_climate = yes } }
					OR = {
						is_deposit_type = d_deep_sinkhole
						is_deposit_type = d_quicksand_basin
					}
				}
				is_deposit_type = d_noxious_swamp
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_dry_to_temperate_deposit = yes }
		if = {
			limit = { is_deposit_type = d_arid_highlands }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = { add_deposit = d_rugged_woods }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_nutritious_mudland }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_great_river }
			prev = { add_deposit = d_fertile_lands }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_marvelous_oasis }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
	}
}

random_deposit_terraform_temperate_to_wet = {
	
	every_deposit = {
		limit = {
			OR = {
				is_deposit_type = d_deep_sinkhole
				is_deposit_type = d_quicksand_basin
				is_deposit_type = d_noxious_swamp
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_temperate_to_wet_deposit = yes }
		if = {
			limit = { is_deposit_type = d_arid_highlands }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_rushing_waterfalls
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_rich_mountain
				}
				else = {
					add_deposit = d_rushing_waterfalls
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = { add_deposit = d_green_hills }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_boggy_fens
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_forgiving_tundra }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_green_hills
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = { add_deposit = d_lush_jungle }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_teeming_reef
				}
			}
			remove_deposit = yes
		}
	}
}

random_deposit_terraform_wet_to_temperate = {

	random_deposit = {
		limit = {
			prev = { is_hot_climate = yes }
			OR = {
				is_deposit_type = d_dense_jungle
				is_deposit_type = d_toxic_kelp
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_wet_to_temperate_deposit = yes }
		if = {
			limit = { is_deposit_type = d_underwater_vent }
			prev = { add_deposit = d_geothermal_vent }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = { add_deposit = d_geothermal_vent }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lichen_fields }
			prev = { add_deposit = d_forgiving_tundra }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_green_hills }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_boggy_fens }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lush_jungle }
			prev = { add_deposit = d_fertile_lands }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_teeming_reef }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
	}
}

random_deposit_terraform_temperate_to_dry = {

	every_deposit = {
		limit = {
			OR = {
				is_deposit_type = d_dense_jungle
				is_deposit_type = d_toxic_kelp
			}
		}
		clear_blocker = yes
	}
	
	random_deposit = {
		limit = { is_temperate_to_dry_deposit = yes }
		if = {
			limit = { is_deposit_type = d_hot_springs }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_arid_highlands
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rushing_waterfalls }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_frozen_gas_lake
				}
				else = {
					add_deposit = d_searing_desert
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = { add_deposit = d_geothermal_vent }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_submerged_ore_veins }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_rich_mountain
				}
				else = {
					add_deposit = d_prosperous_mesa
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_forgiving_tundra
				}
				else = {
					add_deposit = d_nutritious_mudland
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_forgiving_tundra
				}
				else = {
					add_deposit = d_bountiful_plains
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_fungal_caves
				}
				else = {
					add_deposit = d_great_river
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_black_soil }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_fungal_forest
				}
				else = {
					add_deposit = d_marvelous_oasis
				}
			}
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_cold_to_warm = {
	
	every_deposit = {
		limit = { is_cold_to_warm_deposit = yes }
		if = {
			limit = { is_deposit_type = d_frozen_gas_lake }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_searing_desert
				}
				else = {
					add_deposit = d_rushing_waterfalls
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lichen_fields }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_forgiving_tundra }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_nutritious_mudland
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_boggy_fens
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fungal_caves }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_great_river
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lush_jungle
				}
				else = {
					add_deposit = d_fertile_lands
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_fungal_forest }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_marvelous_oasis
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_teeming_reef
				}
				else = {
					add_deposit = d_black_soil
				}
			}
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_warm_to_hot = {
	
	every_deposit = {
		limit = { is_warm_to_hot_deposit = yes }
		if = {
			limit = { is_deposit_type = d_underwater_vent }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_geothermal_vent
				}
				else = {
					add_deposit = d_tempestous_mountain
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_searing_desert
				}
				else = {
					add_deposit = d_green_hills
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_nutritious_mudland
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_bountiful_plains
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_boggy_fens }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_nutritious_mudland
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_bountiful_plains
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lush_jungle
				}
				else = {
					add_deposit = d_great_river
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_teeming_reef }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_tropical_island
				}
				else_if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_tropical_island
				}
				else = {
					add_deposit = d_black_soil
				}
			}
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_hot_to_warm = {
	
	every_deposit = {
		limit = { is_hot_to_warm_deposit = yes }
		if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_bountiful_plains
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_nutritious_mudland }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_bountiful_plains
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_boggy_fens
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_marvelous_oasis
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_teeming_reef
				}
				else = {
					add_deposit = d_black_soil
				}
			}
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_warm_to_cold = {
	
	every_deposit = {
		limit = { is_warm_to_cold_deposit = yes }
		if = {
			limit = { is_deposit_type = d_arid_highlands }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rushing_waterfalls }
			prev = { add_deposit = d_frozen_gas_lake }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_underwater_vent }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_geothermal_vent
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_geothermal_vent
				}
				else = {
					add_deposit = d_ore_rich_caverns
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = {
				if = {
					limit = { is_dry_climate = yes }
					add_deposit = d_geothermal_vent
				}
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_geothermal_vent
				}
				else = {
					add_deposit = d_rich_mountain
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_submerged_ore_veins }
			prev = { add_deposit = d_rich_mountain }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_veiny_cliffs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_green_hills }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_boggy_fens }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lush_jungle }
			prev = { add_deposit = d_fungal_caves }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = {
				if = {
					limit = { is_wet_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_forgiving_tundra
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_great_river }
			prev = { add_deposit = d_fungal_caves }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_teeming_reef }
			prev = { add_deposit = d_fungal_forest }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_marvelous_oasis }
			prev = { add_deposit = d_fungal_forest }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = { add_deposit = d_fungal_forest }
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_dry_to_temperate = {
	
	every_deposit = {
		limit = { is_dry_to_temperate_deposit = yes }
		if = {
			limit = { is_deposit_type = d_arid_highlands }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = { add_deposit = d_rugged_woods }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_nutritious_mudland }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_great_river }
			prev = { add_deposit = d_fertile_lands }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_marvelous_oasis }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_temperate_to_wet = {
	
	every_deposit = {
		limit = { is_temperate_to_wet_deposit = yes }
		if = {
			limit = { is_deposit_type = d_arid_highlands }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_hot_springs
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_searing_desert }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_rushing_waterfalls
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_rich_mountain
				}
				else = {
					add_deposit = d_rushing_waterfalls
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = { add_deposit = d_green_hills }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_green_hills
				}
				else = {
					add_deposit = d_boggy_fens
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_forgiving_tundra }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_green_hills
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = { add_deposit = d_lush_jungle }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_lichen_fields
				}
				else = {
					add_deposit = d_teeming_reef
				}
			}
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_wet_to_temperate = {
	
	every_deposit = {
		limit = { is_wet_to_temperate_deposit = yes }
		if = {
			limit = { is_deposit_type = d_underwater_vent }
			prev = { add_deposit = d_geothermal_vent }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = { add_deposit = d_geothermal_vent }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lichen_fields }
			prev = { add_deposit = d_forgiving_tundra }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_green_hills }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_boggy_fens }
			prev = {
				if = {
					limit = { is_hot_climate = yes }
					add_deposit = d_bountiful_plains
				}
				else = {
					add_deposit = d_rugged_woods
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_lush_jungle }
			prev = { add_deposit = d_fertile_lands }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_teeming_reef }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_tropical_island }
			prev = { add_deposit = d_black_soil }
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_temperate_to_dry = {
	
	every_deposit = {
		limit = { is_temperate_to_dry_deposit = yes }
		if = {
			limit = { is_deposit_type = d_hot_springs }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_mineral_fields
				}
				else = {
					add_deposit = d_arid_highlands
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rushing_waterfalls }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_frozen_gas_lake
				}
				else = {
					add_deposit = d_searing_desert
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_tempestous_mountain }
			prev = { add_deposit = d_geothermal_vent }
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_submerged_ore_veins }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_rich_mountain
				}
				else = {
					add_deposit = d_prosperous_mesa
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_bountiful_plains }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_forgiving_tundra
				}
				else = {
					add_deposit = d_nutritious_mudland
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_rugged_woods }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_forgiving_tundra
				}
				else = {
					add_deposit = d_bountiful_plains
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_fertile_lands }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_fungal_caves
				}
				else = {
					add_deposit = d_great_river
				}
			}
			remove_deposit = yes
		}
		else = {
			limit = { is_deposit_type = d_black_soil }
			prev = {
				if = {
					limit = { is_cold_climate = yes }
					add_deposit = d_fungal_forest
				}
				else = {
					add_deposit = d_marvelous_oasis
				}
			}
			remove_deposit = yes
		}
	}
}

all_deposit_terraform_to_gaia = {
	every_deposit = {
		if = {
			limit = {
				OR = {
					is_deposit_type = d_arid_highlands
					is_deposit_type = d_hot_springs
				}
			}
			prev = { add_deposit = d_buzzing_plains }
			remove_deposit = yes
		}
		else_if = {
			limit = {
				OR = {
					is_deposit_type = d_veiny_cliffs
					is_deposit_type = d_mineral_fields
				}
			}
			prev = { add_deposit = d_mineral_striations }
			remove_deposit = yes
		}
		else = {
			limit = {
				OR = {
					is_deposit_type = d_lichen_fields
					is_deposit_type = d_bountiful_plains
					is_deposit_type = d_rugged_woods
					is_deposit_type = d_green_hills
					is_deposit_type = d_forgiving_tundra
					is_deposit_type = d_boggy_fens
					is_deposit_type = d_nutritious_mudland
				}
			}
			prev = { add_deposit = d_natural_farmland }
			remove_deposit = yes
		}
	}
}

all_earth_deposit_terraform = {
	every_deposit = {
		if = {
			limit = { is_deposit_type = d_scandinavian_reclamation_sector }
			prev = {
				if = {
					limit = { is_dry = yes }
					add_deposit = d_searing_desert
				}
				else_if = {
					limit = { is_cold = yes }
					add_deposit = d_forgiving_tundra
				}
				else = {
					add_deposit = d_green_hills
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_pacific_algae_tracts }
			prev = {
				if = {
					limit = { is_dry = yes }
					add_deposit = d_tropical_island
				}
				else_if = {
					limit = { is_cold = yes }
					add_deposit = d_fungal_forest
				}
				else = {
					add_deposit = d_tropical_island
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_saharan_irrigation_project }
			prev = {
				if = {
					limit = { is_dry = yes }
					add_deposit = d_marvelous_oasis
					add_deposit = d_searing_desert
				}
				else_if = {
					limit = { is_cold = yes }
					add_deposit = d_forgiving_tundra
					add_deposit = d_forgiving_tundra
				}
				else = {
					add_deposit = d_lush_jungle
					add_deposit = d_lush_jungle
				}
			}
			remove_deposit = yes
		}
		else_if = {
			limit = { is_deposit_type = d_mesopotamian_urban_corridor }
			prev = {
				add_deposit = d_mineral_fields
				add_deposit = d_mineral_fields
				add_deposit = d_mineral_fields
			}
			remove_deposit = yes
		}
		else = {
			#Null
		}
	}
}

increase_modifier_duration_effect = {
	if = {
		limit = { has_modifier = $MODIFIER$ }
		export_modifier_duration_to_variable = {
			modifier = $MODIFIER$
			variable = modifier_remaining_duration
		}
		change_variable = { which = modifier_remaining_duration value = $DURATION$ }	
		add_modifier = { modifier = $MODIFIER$ days = 1 time_multiplier = modifier_remaining_duration }
		clear_variable = modifier_remaining_duration
	}
	else = {
		add_modifier = { modifier = $MODIFIER$ days = 1 time_multiplier = $DURATION$ }
	}
}