##########################################################################
# Ult Decisions
##########################################################################

#################
decision_ult_organic_pop_assembly = {
	owned_planets_only = yes
	icon = decision_ult_organic_pop_assembly
	
	prerequisites = {
		"tech_ult_nano_drone_enhance"
	}
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		exists = owner
		owner = { is_ai = no }
		NOT = { has_building = building_robot_assembly_plant }
		NOT = { has_modifier = ult_organic_pop_assembly }
		NOT = { has_modifier = ult_robot_pop_assembly }
	}
	
	effect = {
		add_modifier = {
			modifier = ult_organic_pop_assembly
			days = -1
		}	
	}
	
	ai_weight = {
		weight = 0
	}
}

#####
decision_ult_organic_pop_assembly_end = {
	owned_planets_only = yes
	icon = decision_ult_organic_pop_assembly_end
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		exists = owner
		has_modifier = ult_organic_pop_assembly 
	}
	
	effect = {
		root = { remove_modifier = ult_organic_pop_assembly }
	}
	
	ai_weight = {
		weight = 0
	}
}

################
decision_ult_robot_pop_assembly = {
	owned_planets_only = yes
	icon = decision_ult_robot_pop_assembly
	
	prerequisites = {
		"tech_ult_super_robot_enhance"
	}
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		exists = owner
			NOT = { has_building = building_clone_vats }
			NOT = { has_modifier = ult_organic_pop_assembly }
			NOT = { has_modifier = ult_robot_pop_assembly }
	}
	
	effect = {
		add_modifier = {
			modifier = ult_robot_pop_assembly
			days = -1
		}	
	}
	
	ai_weight = {
		weight = 0
	}
}

#####
decision_ult_robot_pop_assembly_end = {
	owned_planets_only = yes
	icon = decision_ult_robot_pop_assembly_end
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		exists = owner
		has_modifier = ult_robot_pop_assembly 
	}
	
	effect = {
		root = { remove_modifier = ult_robot_pop_assembly }
	}
	
	ai_weight = {
		weight = 0
	}
}

################
decision_ult_machine_pop_assembly = {
	owned_planets_only = yes
	icon = decision_ult_robot_pop_assembly
	
	prerequisites = {
		"tech_ult_super_machine_enhance"
	}
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		exists = owner
			NOT = { has_building = building_clone_vats }
			NOT = { has_modifier = ult_organic_pop_assembly }
			NOT = { has_modifier = ult_robot_pop_assembly }
	}
	
	effect = {
		add_modifier = {
			modifier = ult_robot_pop_assembly
			days = -1
		}	
	}
	
	ai_weight = {
		weight = 0
	}
}


#################
# Utopia Infrastructure
decision_ult_utopia_infrastructure = {
	owned_planets_only = yes
	icon = decision_ult_utopia_infrastructure
	
	prerequisites = {
		"tech_ult_paradise_homeplanet"
	}
	
	enactment_time = 360
	resources = {
		category = decisions
		cost = {
			minerals = 5000
			energy = 5000
		}
	}
	
	potential = {
		NOT = { has_modifier = penal_colony }
		NOT = { has_modifier = resort_colony }
		NOT = { has_modifier = slave_colony }
		NOT = { has_modifier = ult_utopia_infrastructure }
		NOT = { is_planet_class = pc_city }
		NOT = { is_planet_class = pc_relic }
		NOT = { is_planet_class = pc_habitat }
		NOT = { is_planet_class = pc_ringworld_habitable }
		owner = { 
			is_regular_empire = yes 
		}
	}
	
	effect = {
		add_modifier = {
			modifier = ult_utopia_infrastructure
			days = -1
		}	
		custom_tooltip = decision_ult_utopia_infrastructure_add
		add_deposit = d_ult_utopia_infrastructure
		planet_event = { id = ult_utopia_infrastructure.1 }
		hidden_effect = { validate_planet_buildings_and_districts = yes }
	}
	
	ai_weight = {
		weight = 100
	}
}

###########################
decision_ult_utopia_infrastructure_ecu = {
	owned_planets_only = yes
	icon = decision_ult_utopia_infrastructure
	
	prerequisites = {
		"tech_ult_paradise_homeplanet"
	}
	
	enactment_time = 720
	resources = {
		category = decisions
		cost = {
			minerals = 10000
			energy = 10000
		}
	}
	
	potential = {
		NOT = { has_modifier = ult_utopia_infrastructure_ecu }
		OR = {
			is_planet_class = pc_city 
			is_planet_class = pc_aquaticcity
			is_planet_class = pc_birchworld
		}
		owner = { 
			is_regular_empire = yes 
		}
	}
	
	
	effect = {
		add_modifier = {
			modifier = ult_utopia_infrastructure_ecu
			days = -1
		}	
		add_deposit = d_ult_utopia_infrastructure
		planet_event = { id = ult_utopia_infrastructure.6 }
	}
	
	ai_weight = {
		weight = 100
	}
}


###########################
decision_ult_utopia_infrastructure_hab = {
	owned_planets_only = yes
	icon = decision_ult_utopia_infrastructure_eco
	
	prerequisites = {
		"tech_ult_paradise_homeplanet"
	}
	
	enactment_time = 360
	resources = {
		category = decisions
		cost = {
			minerals = 5000
			energy = 5000
		}
	}
	
	potential = {
		NOT = { has_modifier = ult_utopia_infrastructure }
		is_planet_class = pc_habitat
		owner = { 
			is_regular_empire = yes 
		}
	}
	
	
	effect = {
		add_modifier = {
			modifier = ult_utopia_infrastructure
			days = -1
		}	
		custom_tooltip = decision_ult_utopia_infrastructure_add
		add_deposit = d_ult_utopia_infrastructure
		planet_event = { id = ult_utopia_infrastructure.2 }
	}
	
	ai_weight = {
		weight = 100
	}
}


###########################
decision_ult_utopia_infrastructure_rw = {
	owned_planets_only = yes
	icon = decision_ult_utopia_infrastructure
	
	prerequisites = {
		"tech_ult_paradise_homeplanet"
	}
	
	enactment_time = 720
	resources = {
		category = decisions
		cost = {
			minerals = 10000
			energy = 10000
		}
	}
	
	potential = {
		NOT = { has_modifier = ult_utopia_infrastructure_rw }
		is_planet_class = pc_ringworld_habitable
		owner = { 
			is_regular_empire = yes 
		}
	}
	
	
	effect = {
		add_modifier = {
			modifier = ult_utopia_infrastructure_rw
			days = -1
		}	
		custom_tooltip = decision_ult_utopia_infrastructure_add
		add_deposit = d_ult_utopia_infrastructure
		planet_event = { id = ult_utopia_infrastructure.4 }
	}
	
	ai_weight = {
		weight = 100
	}
}


################

############################
decision_ult_temporary_settlement = {
	owned_planets_only = yes
	icon = decision_ult_temporary_settlement
	
	prerequisites = {
		"tech_ult_paradise_homeplanet"
	}
	
	resources = {
		category = decisions
		cost = {
			consumer_goods = 500
			food = 2000
		}
	}
	
	potential = {
		NOT = { has_modifier = penal_colony }
		NOT = { has_modifier = resort_colony }
		NOT = { has_modifier = slave_colony }
		NOT = { has_modifier = ult_temporary_settlement }
		owner = { 
			is_regular_empire = yes 
		}
	}
	
	effect = {
		add_modifier = {
			modifier = ult_temporary_settlement
			days = 1800
		}	
	}
	
	ai_weight = {
		weight = 100
	}
}

##################
decision_abolish_ult_utopia_infrastructure = {
	owned_planets_only = yes
	icon = decision_abolish_ult_utopia_infrastructure

	enactment_time = 360
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		OR = {
			has_modifier = ult_utopia_infrastructure
			has_modifier = ult_utopia_infrastructure_ecu
			has_modifier = ult_utopia_infrastructure_hab
			has_modifier = ult_utopia_infrastructure_rw
		}
	}
	
	
	effect = {
		remove_deposit = d_ult_utopia_infrastructure
		if = {
                limit = {
                    has_modifier = ult_utopia_infrastructure
                }
                remove_modifier = ult_utopia_infrastructure
            }
            else_if = {
                limit = {
                    has_modifier = ult_utopia_infrastructure_ecu
                }
                remove_modifier = ult_utopia_infrastructure_ecu
            }
            else_if = {
                limit = {
                    has_modifier = ult_utopia_infrastructure_hab
                }
                remove_modifier = ult_utopia_infrastructure_hab
            }
            else_if = {
                limit = {
                    has_modifier = ult_utopia_infrastructure_rw
                }
                remove_modifier = ult_utopia_infrastructure_rw
            }
		hidden_effect = {
			validate_planet_buildings_and_districts = yes
		}
	}
	
	ai_weight = {
		weight = 0
	}
}




##################################################
# architecture optimize
decision_ult_architecture_optimize = {
	owned_planets_only = yes
	icon = decision_ult_architecture_optimize
	
	enactment_time = 360
	prerequisites = {
		"tech_ult_paradise_homeplanet"
	}

	resources = {
		category = decisions
		cost = {
			energy = 5000
			minerals = 5000
		}
	}
	
	potential = {
		NOT = { has_modifier = ult_architecture_optimize }
		owner = { is_gestalt = yes }
	}
	
	effect = {
		add_deposit = d_ult_gestalt_infrastructure
		add_modifier = {
			modifier = ult_architecture_optimize
			days = -1
		}	
	}
	
	ai_weight = {
		weight = 100
	}
}


###############################################
# Geological Reconstruction

decision_ult_geological_reconstruction = {
	owned_planets_only = yes
	icon = decision_ult_geological_reconstruction

	enactment_time = 360
	resources = {
		category = decisions
		cost = {
			trigger = {
				planet_size < 10
			}
			energy = 8000
			minerals = 8000
		}
		cost = {
			trigger = {
				planet_size >= 10
				planet_size < 20
			}
			energy = 4000
			minerals = 4000
		}
		cost = {
			trigger = {
				planet_size >= 20
				planet_size < 25
			}
			energy = 2000
			minerals = 2000
		}
	}
	
	abort_trigger = {
		exists = planet
		planet = {
			planet_size >= 25
		}
	}
	
	potential = {
			NOT = { is_planet_class = pc_habitat }
			NOT = { is_planet_class = pc_ringworld_habitable }
			NOT = {
		 		planet_size >= 25
			}
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
		custom_tooltip = {
			planet_size < 25
		}		
		NOT = {
		 		planet_size >= 25
			}
	}
	
	effect = {
		root = {set_planet_size = 25}
	}
	
	ai_weight = {
		weight = 100
	}
}


decision_ult_geological_reconstruction_01 = {
	owned_planets_only = yes
	icon = decision_ult_geological_reconstruction

	enactment_time = 90
	resources = {
		category = decisions
		cost = {
			energy = 500
			minerals = 500
		}
	}
	
	potential = {
			NOT = { is_planet_class = pc_habitat }
			NOT = { is_planet_class = pc_ringworld_habitable }
			NOT = {
		 		planet_size >= 25
			}
	}
	
	abort_trigger = {
		exists = planet
		planet = {
			planet_size >= 25
		}
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
		custom_tooltip = {
			planet_size < 25
		}		
		NOT = {
		 		planet_size >= 25
			}
	}
	
	effect = {
		root = {change_planet_size = 1}
	}
	
	ai_weight = {
		weight = 100
	}
}



###################################################

decision_remove_bleak_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = bleak_planet
	}
	
	prerequisites = { 
		"tech_ult_edenization"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = bleak_planet }
	}
	
	ai_weight = {
		weight = 100
	}
}

###################################
decision_remove_weak_magnetic_field_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = weak_magnetic_field
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = weak_magnetic_field }
	}
	
	ai_weight = {
		weight = 100
	}
}

##################################
decision_remove_unstable_tectonics_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = unstable_tectonics
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = unstable_tectonics }
	}
	
	ai_weight = {
		weight = 100
	}
}

#######################################
decision_remove_tidal_locked_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = tidal_locked
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = tidal_locked }
	}
	
	ai_weight = {
		weight = 100
	}
}

######################################
decision_remove_high_gravity_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = high_gravity
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = high_gravity }
	}
	
	ai_weight = {
		weight = 100
	}
}


######################################
decision_remove_mineral_poor_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = mineral_poor
	}
	
	prerequisites = { 
		"tech_ult_geological_reconstruction"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = mineral_poor }
	}
	
	ai_weight = {
		weight = 100
	}
}

######################################
decision_remove_irradiated_planet_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = irradiated_planet
	}
	
	prerequisites = { 
		"tech_ult_edenization"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = irradiated_planet }
	}
	
	ai_weight = {
		weight = 100
	}
}


######################################
decision_remove_dangerous_wildlife_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = dangerous_wildlife
	}
	
	prerequisites = { 
		"tech_ult_edenization"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = dangerous_wildlife }
	}
	
	ai_weight = {
		weight = 100
	}
}


######################################
decision_remove_hazardous_weather_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = hazardous_weather
	}
	
	prerequisites = { 
		"tech_ult_edenization"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = hazardous_weather }
	}
	
	ai_weight = {
		weight = 100
	}
}


######################################
decision_remove_predatory_plants_ult = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	enactment_time = 360

	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	potential = {
			has_modifier = predatory_plants
	}
	
	prerequisites = { 
		"tech_ult_edenization"
	}
	
	allow = {
	}
	
	effect = {
		root = { remove_modifier = predatory_plants }
	}
	
	ai_weight = {
		weight = 100
	}
}



# Gaia Shield
decision_ult_gaia_shield_activate = {
	owned_planets_only = yes
	icon = decision_ult_gaia_shield_activate
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		has_building = building_ult_gaia_shield
		NOT = { has_modifier = ult_gaia_shield_activating }
		NOT = { is_planet_class = pc_habitat }
		NOT = { is_planet_class = pc_ringworld_habitable }
	}
	
	effect = {
		root = { 
		  hidden_effect = {
		    planet_event = { id = ult_gaia_shield.1 }
	    }
		  
		  add_modifier = {
			  modifier = ult_gaia_shield_activating
			  days = -1
		  }
		}
	}
}

decision_ult_hab_gaia_shield_activate = {
	owned_planets_only = yes
	icon = decision_ult_hab_gaia_shield_activate
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		has_building = building_ult_gaia_shield
		NOT = { has_modifier = ult_gaia_shield_activating }
		is_planet_class = pc_habitat
	}
	
	effect = {
		root = { 
		  hidden_effect = {
		    planet_event = { id = ult_gaia_shield.2 }
	    }
		  
		  add_modifier = {
			  modifier = ult_gaia_shield_activating
			  days = -1
		  }
		}
	}
}

decision_ult_ring_gaia_shield_activate = {
	owned_planets_only = yes
	icon = decision_ult_ring_gaia_shield_activate
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		has_building = building_ult_gaia_shield
		NOT = { has_modifier = ult_gaia_shield_activating }
		is_planet_class = pc_ringworld_habitable
	}
	
	effect = {
		root = { 
		  hidden_effect = {
		    planet_event = { id = ult_gaia_shield.3 }
	    }
		  
		  add_modifier = {
			  modifier = ult_gaia_shield_activating
			  days = -1
		  }
		}
	}
}

decision_ult_gaia_shield_deactivate = {
	owned_planets_only = yes
	icon = decision_ult_gaia_shield_deactivate
	
	resources = {
		category = decisions
		cost = {
		}
	}
	
	potential = {
		has_modifier = ult_gaia_shield_activating
	}
	
	effect = {
		root = { 
		  remove_modifier = ult_gaia_shield_activating
		}
	}
}

##########
decision_ult_gaia_shield_rehabilitation = {
	owned_planets_only = yes
	icon = decision_ult_negetive_remove
	
	resources = {
		category = decisions
		cost = {
			energy = 1000
		}
	}
	
	allow = {
		planet_devastation > 10
	}
	
	potential = {
		has_building = building_ult_gaia_shield
		NOT = { has_modifier = ult_gaia_shield_recharging }
	}
	
	effect = {
		root = { 
		  add_planet_devastation = -30
		  add_modifier = {
			  modifier = ult_gaia_shield_recharging
			  days = 360
		  }
		}
	}
}