##############################
# Colony Events
##############################

namespace = colony_mod

# Note that the following Modifier Colony events are fired from 'colony_mod.161', via 'on_colony_1_year_old'

carrier_event = { #Irradiated
	id = colony_mod.1
	title = "colony_mod.1.name"
	desc = {
		trigger = { owner = { is_machine_empire = no } }
		text = "colony_mod.1.desc"
	}
	desc = {
		trigger = { owner = { is_machine_empire = yes } }
		text = "colony_mod.1.desc_mach"
	}
	picture = GFX_evt_alien_city
	show_sound = event_air_raid_siren
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "irradiated_planet"
		NOR = { 
			has_carrier_flag = irradiated_colony_flag
			is_planet_class = pc_ark
		}
		pop_amount > 0
	}

	immediate = {
		set_carrier_flag = irradiated_colony_flag
	}

	is_triggered_only = yes

	option = {
		name = colony_mod.1.a
		custom_tooltip = irradiated_planet_tooltip
		hidden_effect = {
			random_list = {
				20 = { carrier_event = { id = colony_mod.6 days = 40 random = 20 } }
				20 = { carrier_event = { id = colony_mod.7 days = 40 random = 20 } }
				20 = { carrier_event = { id = colony_mod.8 days = 40 random = 20 } }
				40 = { carrier_event = { id = colony_mod.9 days = 40 random = 20 } }
			}
		}
	}
}

carrier_event = {
	id = colony_mod.6
	title = "colony_mod.6.name"
	desc = "colony_mod.6.desc"
	picture = GFX_evt_atmospheric_entry
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony_mod.6.a #physics
		add_deposit = d_ancient_bombardment_craters
	}
}

carrier_event = {
	id = colony_mod.7
	title = "colony_mod.7.name"
	desc = "colony_mod.7.desc"
	picture = GFX_evt_ground_combat
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony_mod.7.a #eng
		add_deposit = d_ancient_battlefield
	}
}

carrier_event = {
	id = colony_mod.8
	title = "colony_mod.8.name"
	desc = {
		text = "colony_mod.8.desc"
		trigger = {
			owner = {
				NOR = {
					has_government = gov_machine_terminator
					has_civic = civic_fanatic_purifiers
				}
			}
		}
	}
	desc = {
		text = "colony_mod.8.desc_mach"
		trigger = {
			owner = {
				OR = {
					has_civic = civic_fanatic_purifiers
					has_government = gov_machine_terminator
				}
			}
		}
	}
	picture = GFX_evt_nuclear_explosion
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony_mod.8.a #soc
		add_deposit = d_irradiated_ruins
	}
}

carrier_event = {
	id = colony_mod.9
	title = "colony_mod.9.name"
	desc = "colony_mod.9.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony_mod.9.a #modifier
		add_modifier = {
			modifier = "planet_uncertain_past"
			days = -1
		}
	}
}

carrier_event = { #titanic life
	id = colony_mod.2
	title = "colony_mod.2.name"
	desc = "colony_mod.2.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_air_raid_siren
	location = ROOT
	trackable = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "titanic_life"
		NOR = {
			has_carrier_flag = titanic_life_colony_flag
			is_planet_class = pc_volcanic
			is_planet_class = pc_ark
		}
		pop_amount > 0
	}

	immediate = {
		set_carrier_flag = titanic_life_colony_flag
	}

	is_triggered_only = yes

	option = {
		name = colony_mod.2.a# yes
		# study them, may have bad outcome, such as a hostile unit spawning
		enable_special_project = {
			name = "titanic_life_study_normal"
			location = this
			owner = root
		}
	}

	option = {
		name = colony_mod.2.b# no
		#no effect, don't bother them
	}

	option = {
		name = colony_mod.2.c
		trigger = {
			owner = { is_xenophile = yes #nice, for xenophiles
			}
		}
		# study them, bad outcome less likely but takes longer.
		# Remove blockers in success result
		enable_special_project = {
			name = "titanic_life_study_nice"
			location = this
			owner = root
		}
		hidden_effect = {
			set_carrier_flag = nice_titan_study
		}
	}

	option = {
		name = colony_mod.2.d
		trigger = {
			owner = {
				OR = {
					is_xenophobe = yes
					is_hive_empire = yes
				} #mean, for xenophobe
			}
		}
		# study them, takes less time but you will likely get a bad effect too
		# huge food output increase
		enable_special_project = {
			name = "titanic_life_study_mean"
			location = this
			owner = root
		}
		if = {
			limit = {
				owner = {
					is_hive_empire = yes
				}
			}
			if = {
				limit = {
					owner = {
						NOT = {
							has_origin = origin_evolutionary_predators
						}
					}
				}
				add_modifier = {
					modifier = "eat_the_titans_hive"
					days = -1
				}
			}
			else = {
				add_modifier = {
					modifier = "eat_the_titans_evopred_hive"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				owner = {
					NOT = {
						has_origin = origin_evolutionary_predators
					}
				}
			}
			add_modifier = {
				modifier = "eat_the_titans"
				days = -1
			}
		}
		else = {
			add_modifier = {
				modifier = "eat_the_titans_evopred"
				days = -1
			}
		}
	}

}

carrier_event = {
	id = colony_mod.101
	title = "colony_mod.101.name"
	desc = "colony_mod.101.desc"
	picture = GFX_evt_alien_cavemen
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		trigger = {
			NOT = {
				has_carrier_flag = nice_titan_study
			}
		}
		hidden_effect = {
			owner = { set_country_flag = titanic_life_soldiers } #Owner flag not actually needed, but could have techs or other things tie into it
			set_carrier_flag = titanic_life_can_build
		}
		custom_tooltip = titanic_recruit_tooltip
	}

	option = {
		name = EXCELLENT
		trigger = {
			has_carrier_flag = nice_titan_study
		}
		hidden_effect = {
			owner = { set_country_flag = titanic_life_soldiers } #Owner flag not actually needed, but could have techs or other things tie into it
			set_carrier_flag = titanic_life_can_build
			every_deposit = {
				limit = { is_deposit_type = d_titanic_life_blocker }
				clear_blocker = yes
			}
		}
		custom_tooltip = titanic_recruit_phile_tooltip
	}
}

carrier_event = {
	id = colony_mod.102
	title = "colony_mod.102.name"
	desc = "colony_mod.102.desc"
	picture = GFX_evt_ground_combat
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	immediate = {
		create_country = {
			name = "NAME_Titanic_Life"
			type = faction
			effect = {
				establish_communications_no_message = root.owner
			}
		}
		create_species = {
			name = "NAME_Titans"
			class = random_non_machine
			portrait = random
			traits = random
		}
		create_army = {
			name = "NAME_Enraged_Guardian"
			owner = last_created_country
			species = last_created_species
			type = "titanic_guardian_army"
		}
		create_army = {
			name = "NAME_Enraged_Titan"
			owner = last_created_country
			species = last_created_species
			type = "titanic_guardian_army"
		}
		create_army = {
			name = "NAME_Enraged_Titan"
			owner = last_created_country
			species = last_created_species
			type = "titanic_guardian_army"
		}
		set_planet_purge_type = purge_displacement
	}

	option = {
		name = TERRIBLE
		custom_tooltip = titanic_uprising_tooltip
	}
}

# Titanic Guardian Defeated - fired from on_army_killed_in_combat and on_army_killed_no_combat
# This = army owner country
# From = army
# FromFrom = opponent / planet (respectively)
country_event = {
	id = colony_mod.103
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		From = { army_type = titanic_guardian_army }
	}

	immediate = {
		From.planet = {
			clear_planet_purge_type = yes
		}
	}
}

carrier_event = {
	id = colony_mod.3 #unstable tectonics
	title = "colony_mod.3.name"
	desc = "colony_mod.3.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_air_raid_siren
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "unstable_tectonics"
		NOT = { has_modifier = "recent_quake" }
		pop_amount > 0
	}

	is_triggered_only = yes

	option = {
		name = colony_mod.3.a
		add_modifier = {
			modifier = "recent_quake"
			days = 360
		}
		custom_tooltip = quake_report_tooltip
		hidden_effect = {
			random_list = {
				33 = { carrier_event = { id = colony_mod.21 days = 10 random = 5 } }
				33 = { carrier_event = { id = colony_mod.22 days = 10 random = 5 } }
				33 = { carrier_event = { id = colony_mod.23 days = 10 random = 5 } }
			}
		}
	}
}

carrier_event = {
	id = colony_mod.21
	title = "colony_mod.21.name"
	desc = "colony_mod.21.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = WORRYING
		add_blocker = {
			type = d_deep_sinkhole
			blocked_deposit = random
		}
	}
}

carrier_event = {
	id = colony_mod.22
	title = "colony_mod.21.name"
	desc = "colony_mod.22.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = REMARKABLE
		OWNER = {
			add_monthly_resource_mult = {
				resource = minerals
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}

}

carrier_event = {
	id = colony_mod.23
	title = "colony_mod.21.name"
	desc = "colony_mod.23.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = GOOD
	#no effect
	}

}

carrier_event = {
	id = colony_mod.4 #asteroid belt
	title = "colony_mod.4.name"
	desc = "colony_mod.4.desc"
	picture = GFX_evt_asteroid_approaching_planet
	show_sound = event_air_raid_siren
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "asteroid_belt"
		NOT = { has_modifier = "recent_comet" }
		pop_amount > 0
	}

	is_triggered_only = yes

	option = {
		name = colony_mod.4.a
		add_modifier = {
			modifier = "recent_comet"
			days = 1800
		}
	}

}

carrier_event = {
	id = colony_mod.5
	title = "colony_mod.5.name"
	desc = "colony_mod.5.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_air_raid_siren
	location = ROOT
	trackable = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		owner = { NOT = { has_ethic = ethic_gestalt_consciousness } }
		has_modifier = "atmospheric_hallucinogen"
		NOT = { has_carrier_flag = atmospheric_hallucinogen_colony_flag }
		pop_amount > 0
	}

	immediate = {
		set_carrier_flag = atmospheric_hallucinogen_colony_flag
	}

	is_triggered_only = yes

	option = {
		name = colony_mod.5.a
		enable_special_project = {
			name = "hallucinogen_removal"
			location = this
			owner = root
		}
	}

	option = {
		name = colony_mod.5.b
		owner = {
			add_resource = { unity = -200 }
		}
	}

}

carrier_event = {
	id = colony_mod.10 #success
	title = "colony_mod.10.name"
	desc = "colony_mod.10.desc"
	picture = GFX_evt_atmospheric_entry
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = GOOD
		remove_modifier = "atmospheric_hallucinogen"
	}

}

carrier_event = {
	id = colony_mod.11 #failure
	title = "colony_mod.11.name"
	desc = "colony_mod.11.desc"
	picture = GFX_evt_atmospheric_entry
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = MARVELOUS
		hidden_effect = {
			remove_modifier = "atmospheric_hallucinogen"
			add_modifier = {
				modifier = "atmospheric_hallucinogen_good"
				days = -1
			}
		}
		custom_tooltip = hallucinogen_update_tooltip
	}

}

#carrier_event = {
#	id = colony_mod.12 #asteroid_impacts
#	title = "colony_mod.12.name"
#	desc = {
#		text = "colony_mod.12.desc"
#		trigger = { NOT = { owner = { has_ethic = ethic_gestalt_consciousness } } }
#	}
#	desc = {
#		text = colony_mod.12.desc_gestalt
#		trigger = { owner = { has_ethic = ethic_gestalt_consciousness } }
#	}
#	picture = GFX_evt_asteroid_approaching_planet
#	show_sound = event_air_raid_siren
#	location = ROOT
#	trackable = yes
#
#	pre_triggers = {
#		has_owner = yes
#		is_homeworld = no
#		original_owner = yes
#		is_ai = no
#		has_ground_combat = no
#		is_capital = no
#	}
#
#	trigger = {
#		NOT = { has_carrier_flag = asteroid_defences_colony_flag }
#		has_modifier = "asteroid_impacts"
#		NOT = { has_modifier = "recent_impact" }
#		pop_amount > 100
#	}
#
#	is_triggered_only = yes
#
#	option = {
#		name = colony_mod.12.a #eh
#		if = {
#			limit = { NOT = { owner = { has_ethic = ethic_gestalt_consciousness } } }
#			add_modifier = {
#				modifier = "recent_impact"
#				days = 1800
#			}
#		}
#		add_planet_devastation = 20
#	}
#	option = {
#		name = colony_mod.12.b #help
#		enable_special_project = {
#			name = "impact_defence_system"
#			location = this
#			owner = root
#		}
#		if = {
#			limit = { NOT = { owner = { has_ethic = ethic_gestalt_consciousness } } }
#			add_modifier = {
#				modifier = "recent_impact"
#				days = 1800
#			}
#		}
#		add_planet_devastation = 20
#	}
#}

#carrier_event = {
#	id = colony_mod.13 #impact_defence_system
#	title = "colony_mod.13.name"
#	desc = "colony_mod.13.desc"
#	picture = GFX_evt_atmospheric_entry
#	show_sound = event_air_raid_siren
#	location = ROOT
#
#	is_triggered_only = yes
#
#	option = {
#		name = SPLENDID
#		hidden_effect = {
#			set_carrier_flag = asteroid_defences_colony_flag
#		}
#	}
#
#}

#carrier_event = {
#	id = colony_mod.14 #asteroid_impacts - good
#	title = "colony_mod.14.name"
#	desc = "colony_mod.14.desc"
#	picture = GFX_evt_asteroid_approaching_planet
#	show_sound = event_air_raid_siren
#	location = ROOT
#	trackable = yes
#
#	pre_triggers = {
#		has_owner = yes
#		is_homeworld = no
#		original_owner = yes
#		is_ai = no
#		has_ground_combat = no
#		is_capital = no
#	}
#
#	trigger = {
#		NOT = { has_carrier_flag = asteroid_defences_colony_flag }
#		has_modifier = "asteroid_impacts"
#		pop_amount > 100
#		NOR = {
#			has_modifier = "recent_impact"
#			has_deposit = d_impact_crater
#		}
#	}
#
#	is_triggered_only = yes
#
#	option = {
#		name = colony_mod.14.b #help
#		enable_special_project = {
#			name = "impact_defence_system"
#			location = this
#			owner = root
#		}
#		add_modifier = {
#			modifier = "recent_impact"
#			days = 1800
#		}
#		custom_tooltip = good_impact_tooltip
#		hidden_effect = {
#			add_deposit = d_impact_crater
#		}
#	}
#	option = {
#		name = colony_mod.14.a
#		add_modifier = {
#			modifier = "recent_impact"
#			days = 1800
#		}
#		custom_tooltip = good_impact_tooltip
#		hidden_effect = {
#			add_deposit = d_impact_crater
#		}
#	}
#}

carrier_event = { #strong magnetic field good
	id = colony_mod.16
	title = "colony_mod.16.name"
	desc = "colony_mod.16.desc"
	picture = GFX_evt_alien_city
	show_sound = event_air_raid_siren
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "strong_magnetic_field"
		NOT = { has_modifier = "magnetic_research_boost" }
		NOT = { has_modifier = "magnetic_disruption" }
		NOT = { has_carrier_flag = magnetic_mystery_solved }
		pop_amount > 0
	}

	immediate = {
		OWNER = {
			change_variable = { #check_variable
				which = "magnetic_planet_research"
				value = 1
			}
		}
	}

	is_triggered_only = yes

	option = {
		name = FASCINATING
		#Idea to revisit: research bonus/increase flag - after a number, say 5, of these events a new special project is enabled to make the effect permanent
		add_modifier = {
			modifier = "magnetic_research_boost"
			days = 1800
		}
		OWNER = {
			if = {
				limit = {
					check_variable = {which = magnetic_planet_research value = 3}
				}
				enable_special_project = {
					name = "MAGNETIC_PLANET_RESEARCH_PROJECT"
					location = root
					owner = this
				}
			}
		}
	}
}

carrier_event = { #strong magnetic field bad
	id = colony_mod.17
	title = "colony_mod.17.name"
	desc = "colony_mod.17.desc"
	picture = GFX_evt_alien_city
	show_sound = event_air_raid_siren
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "strong_magnetic_field"
		NOT = { has_modifier = "magnetic_research_boost" }
		NOT = { has_modifier = "magnetic_disruption" }
		NOT = { has_carrier_flag = magnetic_mystery_solved }
		pop_amount > 0
	}

	immediate = {
		OWNER = {
			change_variable = { #check_variable
				which = "magnetic_planet_research"
				value = 1
			}
		}
	}

	is_triggered_only = yes

	option = {
		name = UNFORTUNATE
		#research penalty/unhappiness
		add_modifier = {
			modifier = "magnetic_disruption"
			days = 1800
		}
		OWNER = {
			if = {
				limit = {
					check_variable = {which = magnetic_planet_research value = 3}
				}
				enable_special_project = {
					name = "MAGNETIC_PLANET_RESEARCH_PROJECT"
					location = root
					owner = this
				}
			}
		}
	}
}

carrier_event = {
	id = colony_mod.18
	title = "colony_mod.18.name"
	desc = "colony_mod.18.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony_mod.18.a #modifier
		set_carrier_flag = magnetic_mystery_solved
		add_modifier = {
			modifier = "magnetic_research_boost"
			days = -1
		}
	}
}

#Setup event to add Titanic life blockers to planets with the modifier
#Bit of a hack as it is not possible in system initializers
#Slight spam as it will happen along with the "First discovery" event the first time you survey a Titanic life planet, but can't be helped easily
event = {
	id = colony_mod.100
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		every_galaxy_planet = {
			limit = {
				has_modifier = titanic_life
			}
			add_deposit = d_titanic_life_blocker
		}
	}
}

#Gatekeeper - Colony Events
carrier_event = {
	id = colony_mod.161
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			AND = {
				has_modifier = strong_magnetic_field
				NOT = { has_carrier_flag = magnetic_mystery_solved }
			}
			has_modifier = asteroid_impacts
			has_modifier = irradiated_planet
			has_modifier = titanic_life
			has_modifier = unstable_tectonics
			has_modifier = asteroid_belt
			has_modifier = atmospheric_hallucinogen
		}
		owner = { is_wilderness_empire = no }
	}

	immediate = {
		if = {
			limit = {
				has_modifier = strong_magnetic_field
				has_modifier = "strong_magnetic_field"
				NOT = { has_modifier = "magnetic_research_boost" }
				NOT = { has_modifier = "magnetic_disruption" }
				has_ground_combat = no
				pop_amount > 0
			}
			random_list = {
				50 = { carrier_event = { id = colony_mod.16 days = 30 random = 90 } }
				50 = { carrier_event = { id = colony_mod.17 days = 30 random = 90 } }
			}
			break = yes
		}
		#if = {
		#	limit = {
		#		has_modifier = asteroid_impacts
		#		NOT = { has_carrier_flag = asteroid_defences_colony_flag }
		#		pop_amount > 100
		#		NOT = { has_modifier = "recent_impact" }
		#	}
		#	random_list = {
		#		50 = { carrier_event = { id = colony_mod.12 days = 30 random = 90 } }
		#		50 = { carrier_event = { id = colony_mod.14 days = 30 random = 90 } }
		#	}
		#	break = yes
		#}

		if = {
			limit = {
				has_modifier = irradiated_planet
				NOT = { has_carrier_flag = irradiated_colony_flag }
			}
			carrier_event = { id = colony_mod.1 days = 30 random = 90 }
			break = yes
		}

		if = {
			limit = {
				has_modifier = titanic_life
				NOT = { has_carrier_flag = titanic_life_colony_flag }
			}
			if = {
				limit = {
					owner = { has_origin = origin_primal_calling }
				}
				carrier_event = { id = grand_archive.1010 days = 30 random = 90 }
				break = yes
			}
			else_if = {
				limit = {
					NOT = { owner = { has_ethic = ethic_gestalt_consciousness } }
				}
				carrier_event = { id = colony_mod.2 days = 30 random = 90 }
				break = yes
			}
		}

		if = {
			limit = {
				has_modifier = unstable_tectonics
				NOT = { has_modifier = recent_quake }
			}
			carrier_event = { id = colony_mod.3 days = 30 random = 90 }
			break = yes
		}

		if = {
			limit = {
				has_modifier = "asteroid_belt"
				NOR = {
					has_modifier = "recent_comet"
					owner = { has_ethic = ethic_gestalt_consciousness }
				}
			}
			carrier_event = { id = colony_mod.4 days = 30 random = 90 }
			break = yes
		}

		if = {
			limit = {
				has_modifier = atmospheric_hallucinogen
				NOR = {
					has_carrier_flag = atmospheric_hallucinogen_colony_flag
					owner = { has_ethic = ethic_gestalt_consciousness }
				}
			}
			carrier_event = { id = colony_mod.5 days = 30 random = 90 }
			break = yes
		}
	}
}

carrier_event = { # Rogue moon
	id = colony.3001
	title = "colony.3001.name"
	desc = "colony.3001.desc"
	picture = GFX_evt_asteroid_approaching_planet
	location = ROOT
	trackable = yes

	trigger = {
		has_owner = yes
		original_owner = yes
		is_homeworld = no
		owner = {
			is_ai = no
			NOR = {
				has_country_flag = roguemoon_country
				is_wilderness_empire = yes
			}
		}
		is_capital = no
		has_ground_combat = no
		is_occupied_flag = no
		pop_amount > 0
		NOR = {
			is_planet_class = pc_habitat
			is_planet_class = pc_ringworld_habitable
			is_planet_class = pc_shattered_ring_habitable
			has_carrier_flag = colony_event
		}
		has_moon = yes
		any_moon = {
			habitable_planet = no
			NOT = { is_planet_class = pc_habitat }
		}
	}

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = roguemoon_event
		set_carrier_flag = colony_event
		owner = { set_country_flag = roguemoon_country }
		random_moon = {
			limit = {
				habitable_planet = no
			}
			save_event_target_as = roguemoon
		}
	}

	option = {
		name = CURIOUS
		enable_special_project = {
			name = "ROGUEMOON_PROJECT"
			location = this
			owner = root
		}
	}
}

carrier_event = { #rogue moonbase
	id = colony.3002
	title = "colony.3002.name"
	desc = "colony.3002.desc"
	picture = GFX_evt_alien_ruins
	location = ROOT

	is_triggered_only = yes

	option = {
		name = ASTOUNDING
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					has_tech_option = tech_mine_dark_matter
				}
				add_tech_progress = {
					tech = tech_mine_dark_matter
					progress = 0.5
				}
			}
			else = {
				add_research_option = tech_mine_dark_matter
				add_tech_progress = {
					tech = tech_mine_dark_matter
					progress = 0.25
				}
			}
		}
		event_target:roguemoon = {
			add_deposit = d_dark_matter_deposit_1
		}
	}
}

carrier_event = { #dimensional moon
	id = colony.3003
	title = "colony.3003.name"
	desc = "colony.3003.desc"
	picture = GFX_evt_alien_ruins
	location = ROOT

	is_triggered_only = yes

	option = {
		name = FASCINATING
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					has_tech_option = tech_jump_drive_1
				}
				add_tech_progress = {
					tech = tech_jump_drive_1
					progress = 0.15
				}
			}
			else = {
				add_research_option = tech_jump_drive_1
				add_tech_progress = {
					tech = tech_jump_drive_1
					progress = 0.1
				}
			}
		}
	}
}

carrier_event = { #Dimensional portal
	id = colony.3005
	title = "colony.3005.name"
	desc = "colony.3005.desc"
	picture = GFX_evt_wormhole
	location = ROOT
	situation = from #only does something if from is actually a situation
	trackable = yes

	trigger = {
		has_owner = yes
		original_owner = yes
		is_homeworld = no
		owner = {
			is_ai = no
			is_wilderness_empire = no
			NOT = { has_country_flag = dportal_country }
		}
		is_capital = no
		has_ground_combat = no
		is_occupied_flag = no
		pop_amount > 0
		NOR = {
			is_planet_class = pc_habitat
			is_planet_class = pc_ringworld_habitable
			is_planet_class = pc_shattered_ring_habitable
			has_carrier_flag = colony_event
		}
	}

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = dportal_event
		set_carrier_flag = colony_event
		owner = { set_country_flag = dportal_country }

	}

	option = {
		name = INTRIGUING
		enable_special_project = {
			name = "DPORTAL_PROJECT"
			location = this
			owner = root
		}
		add_deposit = d_portal_research_zone
	}
}

carrier_event = { #hell
	id = colony.3006
	title = "colony.3006.name"
	desc = {
		text = colony.3006.knight.desc
		trigger = {
			owner = { has_origin = origin_toxic_knights }
		}
	}
	desc = {
		text = colony.3006.spir.desc
		trigger = {
			owner = {
				is_spiritualist = yes
				NOT = { has_origin = origin_toxic_knights }
			}
		}
	}
	desc = {
		text = colony.3006.desc
		trigger = {
			owner = {
				is_spiritualist = no
				NOT = { has_origin = origin_toxic_knights }
			}
		}
	}
	picture = GFX_evt_space_funeral
	location = ROOT

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = dportal_hell
	}

	option = {
		trigger = {
		owner = {
				is_spiritualist = no
			}
		}
		name = colony.3006.science
		enable_special_project = {
			name = "DPORTAL_PROJECT_SCIENCE"
			location = this
			owner = root
		}
	}

	option = {
		name = colony.3006.psi.prayer
		trigger = {
			owner = {
				is_spiritualist = yes
				has_technology = tech_psionic_theory
			}
		}
		enable_special_project = {
			name = "DPORTAL_PROJECT_PSI_PRAYER"
			location = this
			owner = root
		}
	}
	option = {
		name = colony.3006.prayer
		trigger = {
			owner = {
				is_spiritualist = yes
				NOT = {	has_technology = tech_psionic_theory }
			}
		}
		enable_special_project = {
			name = "DPORTAL_PROJECT_PRAYER"
			location = this
			owner = root
		}
	}

	option = {
		name = colony.3006.rocks
		trigger = {
			owner = {
				is_spiritualist = no
				has_civic = civic_feudal_realm
			}
		}
		enable_special_project = {
			name = "DPORTAL_PROJECT_ROCKS"
			location = this
			owner = root
		}
	}

	option = {
		name = colony.3006.knights
		trigger = {
			owner = {
				has_origin = origin_toxic_knights
			}
		}
		hidden_effect = {
			owner = {
				create_leader = {
					class = commander
					species = owner_main_species
					name = random
					traits = {
						0 = leader_trait_chosen
						1 = leader_trait_butcher
					}
				}
				last_created_leader = {
					exile_leader_as = doomslayer_knight
					save_event_target_as = doomslayer_knight
					set_immortal = yes
					save_global_event_target_as = doomslayer_knight@prev
				}
			}
			reroll_random = yes
			random_list = {
				15 = { }
				25 = {
					modifier = {
						factor = 0
						blocks_disruptive_gameplay = yes
					}
					carrier_event = { id = colony.3050 days = 3600 random = 900 } # Daemonic Incursion
				}
				20 = { carrier_event = { id = colony.3060 days = 3600 random = 900 } } # Quest Complete
				40 = { carrier_event = { id = colony.3055 days = 3600 random = 900 } } # Daemon Refugees
			}
		}
	}

	option = {
		name = colony.3006.keep
		add_deposit = d_portal_research_zone
		custom_tooltip = portal_zone_tooltip
	}
}

carrier_event = { #science
	id = colony.3010
	title = "colony.3010.name"
	desc = "colony.3010.desc"
	picture = GFX_evt_news_room
	location = ROOT

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					has_tech_option = tech_power_plant_4
				}
				add_tech_progress = {
					tech = tech_power_plant_4
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					has_technology = tech_power_plant_3
				}
				add_research_option = tech_power_plant_4
				add_tech_progress = {
					tech = tech_power_plant_4
					progress = 0.25
				}
			}
			else_if = {
				limit = {
					has_tech_option = tech_power_plant_3
				}
				add_tech_progress = {
					tech = tech_power_plant_3
					progress = 0.5
				}
			}
			else = {
				add_research_option = tech_power_plant_3
				add_tech_progress = {
					tech = tech_power_plant_3
					progress = 0.25
				}
			}
		}
		custom_tooltip = portal_closed_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			remove_carrier_flag = dportal_hell
		}
	}
}

carrier_event = { #prayer
	id = colony.3011
	title = "colony.3010.name"
	desc = {
		text = colony.3011.psi.desc
		trigger = {
			owner = {
				has_technology = tech_psionic_theory
				is_robot_empire = no
			}
		}
	}
	desc = {
		text = colony.3011.psi_robot.desc
		trigger = {
			owner = {
				has_technology = tech_psionic_theory
				is_robot_empire = yes
			}
		}
	}
	desc = {
		text = colony.3011.desc
		trigger = {
			owner = {
				NOT = { has_technology = tech_psionic_theory }
			}
		}
	}
	picture = GFX_evt_news_room
	location = ROOT

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					NOT = { has_tech_option = tech_psionic_theory }
				}
				add_research_option = tech_psionic_theory
				add_tech_progress = {
					tech = tech_psionic_theory
					progress = 0.8
				}
			}

			add_research_option = tech_psionic_barrier
			add_tech_progress = {
				tech = tech_psionic_barrier
				progress = 0.5
			}
		}
		custom_tooltip = portal_closed_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			remove_carrier_flag = dportal_hell
		}
	}
}

carrier_event = { #rocks
	id = colony.3012
	title = "colony.3010.name"
	desc = "colony.3012.desc"
	picture = GFX_evt_news_room
	location = ROOT

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					has_tech_option = tech_mining_3
				}
				add_tech_progress = {
					tech = tech_mining_3
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					has_technology = tech_mining_2
				}
				add_research_option = tech_mining_3
				add_tech_progress = {
					tech = tech_mining_3
					progress = 0.25
				}
			}
			else_if = {
				limit = {
					has_tech_option = tech_mining_2
				}
				add_tech_progress = {
					tech = tech_mining_2
					progress = 0.5
				}
			}
			else = {
				add_research_option = tech_mining_2
				add_tech_progress = {
					tech = tech_mining_2
					progress = 0.25
				}
			}
		}
		custom_tooltip = portal_closed_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			remove_carrier_flag = dportal_hell
		}
	}
}

carrier_event = { #energy
	id = colony.3007
	title = "colony.3007.name"
	desc = "colony.3007.desc"
	picture = GFX_evt_star_white
	location = ROOT

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = dportal_energy
	}

	option = {
		name = FASCINATING
		set_carrier_flag = dportal_energy
		owner = {
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			if = {
				limit = {
					has_tech_option = tech_plasma_3
				}
				add_tech_progress = {
					tech = tech_plasma_3
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					has_technology = tech_plasma_2
				}
				add_research_option = tech_plasma_3
				add_tech_progress = {
					tech = tech_plasma_3
					progress = 0.25
				}
			}
			else_if = {
				limit = {
					has_tech_option = tech_plasma_2
				}
				add_tech_progress = {
					tech = tech_plasma_2
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					has_technology = tech_plasma_1
				}
				add_research_option = tech_plasma_2
				add_tech_progress = {
					tech = tech_plasma_2
					progress = 0.25
				}
			}
			else_if = {
				limit = {
					has_tech_option = tech_plasma_1
				}
				add_tech_progress = {
					tech = tech_plasma_1
					progress = 0.5
				}
			}
			else = {
				add_research_option = tech_plasma_1
				add_tech_progress = {
					tech = tech_plasma_1
					progress = 0.25
				}
			}
		}
		custom_tooltip = portal_energy_tooltip
	}
}

carrier_event = { #null void
	id = colony.3008
	title = "colony.3008.name"
	desc = "colony.3008.desc"
	picture = GFX_evt_shrouded_planet
	location = ROOT

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = dportal_void
	}

	option = {
		name = FASCINATING

		owner = {
			add_research_option = null_void_beam
				add_tech_progress = {
					tech = null_void_beam
					progress = 0.5
				}
		}
		custom_tooltip = portal_void_tooltip
		hidden_effect = {
			carrier_event = { id = colony.3040 days = 1825 random = 1825 }
		}
	}
}

carrier_event = { #Probe the Void
	id = colony.3040
	title = "colony.3040.name"
	desc = "colony.3040.desc"
	picture = GFX_evt_wormhole
	location = ROOT
	trackable = yes

	trigger = {
		has_owner = yes
		original_owner = yes
	}

	is_triggered_only = yes

	option = {
		name = INTRIGUING
		enable_special_project = {
			name = "NULLVOID_PROJECT"
			location = this
			owner = root
		}
	}
}

carrier_event = { #increase production
	id = colony.3041
	title = "colony.3041.name"
	desc = "colony.3041.desc"
	picture = GFX_evt_shrouded_planet
	location = ROOT
	trackable = yes

	trigger = {
		has_owner = yes
		original_owner = yes
	}

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		custom_tooltip = portal_void_tooltip2
		set_carrier_flag = dportal_void2
	}
}

carrier_event = { #mirror
	id = colony.3009
	title = "colony.3009.name"
	desc = "colony.3009.desc"
	picture = GFX_evt_galactic_senate

	is_triggered_only = yes

	option = {
		name = colony.3009.a.robot
		exclusive_trigger = { owner = { is_machine_empire = yes } }
		hidden_effect = {
			carrier_event = { id = colony.3020 }
		}
	}
	option = {
		name = colony.3009.a
		hidden_effect = {
			carrier_event = { id = colony.3020 }
		}
	}

}

carrier_event = { #message 1
	id = colony.3020
	title = "colony.3020.name"
	desc = {
		text = colony.3020.desc
		trigger = {
			owner = { is_machine_empire = no }
		}
	}
	desc = {
		text = colony.3020.desc.robot
		trigger = {
			owner = { is_machine_empire = yes }
		}
	}

	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = root.owner.leader
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}

	option = {
		name = colony.3020.a
		hidden_effect = {
			carrier_event = { id = colony.3021 }
		}
	}
	option = {
		name = colony.3020.a.robot
		exclusive_trigger = { owner = { is_machine_empire = yes } }
		hidden_effect = {
			carrier_event = { id = colony.3021 }
		}
	}
}

carrier_event = { #message 2
	id = colony.3021
	title = "colony.3020.name"
	desc = {
		text = colony.3021.desc
		trigger = {
			owner = { is_machine_empire = no }
		}
	}
	desc = {
		text = colony.3021.desc.robot
		trigger = {
			owner = { is_machine_empire = yes }
		}
	}

	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = root.owner.leader
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}

	option = {
		name = colony.3021.a #talk more
		trigger = { owner = { is_machine_empire = no } }
		hidden_effect = {
			carrier_event = { id = colony.3022 }
		}
	}

	option = {
		name = colony.3021.b #just trade
		trigger = { owner = { is_machine_empire = no } }
		response_text = mirror_trade_reply
		set_carrier_flag = dportal_trader
		hidden_effect = {
			add_modifier = {
				modifier = "dportal_trade_normal"
				days = -1
			}
			owner = {
				set_country_flag = dportal_trader
			}
		}
	}
	option = {
		name = colony.3021.a.robot #talk more
		trigger = { owner = { is_machine_empire = yes } }
		hidden_effect = {
			carrier_event = { id = colony.3022 }
		}
	}

	option = {
		name = colony.3021.b.robot #just trade
		trigger = { owner = { is_machine_empire = yes } }
		response_text = mirror_trade_reply.robot
		set_carrier_flag = dportal_trader
		hidden_effect = {
			add_modifier = {
				modifier = "dportal_trade_normal"
				days = -1
			}
			owner = {
				set_country_flag = dportal_trader
			}
		}
	}
}

carrier_event = { #message 3
	id = colony.3022
	title = "colony.3020.name"
	desc = {
		text = colony.3022.desc
		trigger = {
			 owner = { is_machine_empire = no }
		}
	}
	desc = {
		text = colony.3022.desc.robot
		trigger = {
			 owner = { is_machine_empire = yes }
		}
	}

	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = root.owner.leader
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}

	option = {
		name = colony.3022.a
		hidden_effect = {
			carrier_event = { id = colony.3023 }
		}
	}
	option = {
		name = colony.3022.a.robot
		exclusive_trigger = { owner = { is_machine_empire = yes } }
		hidden_effect = {
			carrier_event = { id = colony.3023 }
		}
	}

}

carrier_event = { #message 4
	id = colony.3023
	title = "colony.3020.name"
	desc = {
		text = colony.3023.desc
		trigger = {
			 owner = { is_machine_empire = no }
		}
	}
	desc = {
		text = colony.3023.desc.robot
		trigger = {
			 owner = { is_machine_empire = yes }
		}
	}

	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = root.owner.leader
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}

	option = {
		name = colony.3023.a
		hidden_effect = {
			carrier_event = { id = colony.3024 }
		}
	}
	option = {
		name = colony.3023.a.robot
		exclusive_trigger = { owner = { is_machine_empire = yes } }
		hidden_effect = {
			carrier_event = { id = colony.3024 }
		}
	}
}

carrier_event = { #message 5
	id = colony.3024
	title = "colony.3020.name"
	desc = {
		text = colony.3024.desc
		trigger = {
			 owner = { is_machine_empire = no }
		}
	}
	desc = {
		text = colony.3024.desc.robot
		trigger = {
			 owner = { is_machine_empire = yes }
		}
	}

	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = root.owner.leader
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}

	option = {
		name = colony.3024.a #trade
		response_text = mirror_trade_reply2
		set_carrier_flag = dportal_trader
		hidden_effect = {
			add_modifier = {
				modifier = "dportal_trade_normal"
				days = -1
			}
			owner = {
				set_country_flag = dportal_trader
			}
		}
	}
	option = {
		name = colony.3024.a.robot #trade
		exclusive_trigger = { owner = { is_machine_empire = yes } }
		response_text = mirror_trade_reply2.robot
		set_carrier_flag = dportal_trader
		hidden_effect = {
			add_modifier = {
				modifier = "dportal_trade_normal"
				days = -1
			}
			owner = {
				set_country_flag = dportal_trader
			}
		}
	}
}

event = {
	id = colony.3029
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_playable_country = {
			has_country_flag = dportal_trader
		}
	}

	immediate = {
		random_playable_country = {
			limit = { has_country_flag = dportal_trader }
			country_event = { id = colony.3030 }
		}
	}
}

country_event = { #Mirror portal followup events
	id = colony.3030

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_country_flag = dportal_trader
		any_owned_planet = {
			has_carrier_flag = dportal_trader
		}
		NOT = { has_country_flag = dportal_empire_crisis_flag }
	}

	immediate = {
		random_owned_planet = {
			limit = {
				has_carrier_flag = dportal_trader
			}
			save_event_target_as = dportal_trade_planet
		}
		event_target:dportal_trade_planet = {
			if = {
				limit = {
					has_modifier = dportal_trade_normal
				}
				random_list = {
					60 = { } #no effect
					10 = { carrier_event = { id = colony.3031 }} #trade goes up
					10 = { carrier_event = { id = colony.3032 }} #trade goes down
				}
			}
			else_if = {
				limit = {
					has_modifier = dportal_trade_low
				}
				random_list = {
					20 = { } #no effect
					20 = { carrier_event = { id = colony.3031 }} #trade goes up
					10 = { carrier_event = { id = colony.3032 }} #trade goes down
				}
			}
			else_if = {
				limit = {
					has_modifier = dportal_trade_high
				}
				random_list = {
					30 = {} #no effect
					10 = { carrier_event = { id = colony.3031 }} #trade goes up
					20 = { carrier_event = { id = colony.3032 }} #trade goes down
				}
			}

		}

	}

}

carrier_event = { #trade up
	id = colony.3031
	title = "colony.3031.name"
	desc = "colony.3031.desc"
	picture = GFX_evt_wormhole
	location = ROOT
	auto_opens = no
	notification_event_icon = "GFX_message_diplomatic_contact"
	is_triggered_only = yes

	immediate = {
	}

	option = {
		name = EXCELLENT
		if = {
			limit = {
				NOT = { has_modifier = dportal_trade_high }
			}
			if = {
				limit = {
					owner = { is_gestalt = no }
				}
				custom_tooltip = dportal_trade_increases_tooltip
			}
			else = {
				custom_tooltip = dportal_trade_increases_gestalt_tooltip
			}
		}
		if = {
			limit = {
				has_modifier = dportal_trade_low
			}
			hidden_effect = {
				remove_modifier = dportal_trade_low
				add_modifier = {
					modifier = "dportal_trade_normal"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_normal
			}
			hidden_effect = {
				remove_modifier = dportal_trade_normal
				add_modifier = {
					modifier = "dportal_trade_high"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_high
			}
			owner = {
				add_monthly_resource_mult = {
					resource = consumer_goods
					value = 6
					min = 100
				}
				add_monthly_resource_mult = {
					resource = volatile_motes
					value = 3
					min = 50
				}
				add_monthly_resource_mult = {
					resource = exotic_gases
					value = 3
					min = 50
				}
				add_monthly_resource_mult = {
					resource = rare_crystals
					value = 3
					min = 50
				}
			}
		}
	}
}

carrier_event = { #trade down
	id = colony.3032
	title = "colony.3032.name"
	desc = "colony.3032.desc"
	picture = GFX_evt_wormhole
	location = ROOT

	is_triggered_only = yes

	immediate = {
	}

	option = {
		name = colony.3032.a.robot
		exclusive_trigger = { owner = { is_machine_empire = yes } }
		if = {
			limit = {
				NAND = {
					has_modifier = dportal_trade_low
					owner = {
						check_variable = {
							which = dportal_empire_crisis
							value < 5
						}
					}
				}
			}
			custom_tooltip = dportal_trade_reduces_gestalt_tooltip
		}
		if = {
			limit = {
				has_modifier = dportal_trade_high
			}
			hidden_effect = {
				remove_modifier = dportal_trade_high
				add_modifier = {
					modifier = "dportal_trade_normal"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_normal
			}
			hidden_effect = {
				remove_modifier = dportal_trade_normal
				add_modifier = {
					modifier = "dportal_trade_low"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_low
				owner = {
					check_variable = {
						which = dportal_empire_crisis
						value < 5
					}
				}
			}
			owner = {
				hidden_effect = {
					change_variable = {
						which = dportal_empire_crisis
						value = 1
					}
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_low
				owner = {
					check_variable = {
							which = dportal_empire_crisis
							value >= 5
					}
				}
			}
			add_modifier = {
				modifier = "dportal_trade_crisis"
				days = -1
			}
			hidden_effect = {
				remove_modifier = dportal_trade_low
				carrier_event = { id = colony.3033 days = 1825 random = 1825 }
				owner = { set_country_flag = dportal_empire_crisis_flag }
			}
		}
	}
	option = {
		name = colony.3032.a
		if = {
			limit = {
				NAND = {
					has_modifier = dportal_trade_low
					owner = {
						check_variable = {
							which = dportal_empire_crisis
							value < 5
						}
					}
				}
			}
			if = {
				limit = {
					owner = { is_gestalt = no }
				}
				custom_tooltip = dportal_trade_reduces_tooltip
			}
			else = {
				custom_tooltip = dportal_trade_reduces_gestalt_tooltip
			}
		}
		if = {
			limit = {
				has_modifier = dportal_trade_high
			}
			hidden_effect = {
				remove_modifier = dportal_trade_high
				add_modifier = {
					modifier = "dportal_trade_normal"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_normal
			}
			hidden_effect = {
				remove_modifier = dportal_trade_normal
				add_modifier = {
					modifier = "dportal_trade_low"
					days = -1
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_low
				owner = {
					check_variable = {
							which = dportal_empire_crisis
							value < 5
					}
				}
			}
			owner = {
				hidden_effect = {
					change_variable = {
						which = dportal_empire_crisis
						value = 1
					}
				}
			}
		}
		else_if = {
			limit = {
				has_modifier = dportal_trade_low
				owner = {
					check_variable = {
							which = dportal_empire_crisis
							value >= 5
					}
				}
			}
			add_modifier = {
				modifier = "dportal_trade_crisis"
				days = -1
			}
			hidden_effect = {
				remove_modifier = dportal_trade_low
				carrier_event = { id = colony.3033 days = 1825 random = 1825 }
				owner = { set_country_flag = dportal_empire_crisis_flag }
			}
		}
	}
}

carrier_event = { #the end of dportal_empire
	id = colony.3033
	title = "colony.3033.name"
	desc = {
		text = colony.3033.desc
		trigger = {
			 owner = { is_machine_empire = no }
		}
	}
	desc = {
		text = colony.3033.desc.robot
		trigger = {
			 owner = { is_machine_empire = yes }
		}
	}
	picture = GFX_evt_wormhole
	location = ROOT
	diplomatic = yes

	picture_event_data = {
		room = no_video_feed_room
	}

	is_triggered_only = yes

	immediate = {

	}

	option = {
		name = colony.3033.a
		trigger = { owner = { is_machine_empire = no } }
		is_dialog_only = yes
		response_text = colony.3033.reply
	}
	option = {
		name = colony.3033.b
		trigger = { owner = { is_machine_empire = no } }
		is_dialog_only = yes
		response_text = colony.3033.reply
	}
	option = {
		name = colony.3033.c
		trigger = { owner = { is_machine_empire = no } }
		is_dialog_only = yes
		response_text = colony.3033.reply
	}

	option = {
		name = colony.3033.d
		trigger = { owner = { is_machine_empire = no } }
		hidden_effect = {
			remove_modifier = dportal_trade_crisis
		}
	}
	option = {
		name = colony.3033.a.robot
		trigger = { owner = { is_machine_empire = yes } }
		is_dialog_only = yes
		response_text = colony.3033.reply
	}
	option = {
		name = colony.3033.d.robot
		trigger = { owner = { is_machine_empire = yes } }
		hidden_effect = {
			remove_modifier = dportal_trade_crisis
		}
	}
}

#Knight Doom Slayer

carrier_event = { #Corrupted Knight
	id = colony.3050
	title = "colony.3050.name"
	desc = "colony.3050.desc"
	picture = GFX_evt_open_revolt
	location = ROOT

	is_triggered_only = yes

	fire_only_once = yes

	option = {
		name = colony.3050.a
		custom_tooltip = portal_closed_tooltip
		custom_tooltip = demonic_armies_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			remove_carrier_flag = dportal_hell
			save_global_event_target_as = demonic_incursion_planet
			create_country = {
				name = "NAME_Demonic_Creatures"
				type = faction
				effect = {
					establish_communications_no_message = root.owner
					save_global_event_target_as = demonic_incursion_armies
				}
			}
			create_army = {
				name = "NAME_Deformed_Creatures"
				owner = last_created_country
				type = "mutant_army"
			}
			create_army = {
				name = "NAME_Twisted_Beasts"
				owner = last_created_country
				type = "mutant_army"
			}
			create_army = {
				name = "NAME_Mutated_Horrors"
				owner = last_created_country
				type = "mutant_army"
				leader = event_target:doomslayer_knight
			}
		}
	}
}

# This = country, planet owner
# From = country, attack leader
# FromFrom = planet
country_event = {
	id = colony.3051
	title = "colony.3051.name"
	desc = "colony.3051.desc"
	picture = GFX_evt_open_revolt
	location = ROOT

	is_triggered_only = yes

	trigger = {
		exists = event_target:demonic_incursion_armies
		from = { is_same_empire = event_target:demonic_incursion_armies }
	}

	immediate = {

		# Exile the Corrupted Knight
		event_target:doomslayer_knight@root = {
			exile_leader_as = doomslayer_knight
			save_event_target_as = doomslayer_knight
		}

		# Create the demonic incursion species and country
		create_demon_species_effect = yes
		create_country = {
			name = "NAME_Demon_Incursion"
			adjective = "NAME_Demon_Refugees"
			authority = auth_dictatorial
			ignore_initial_colony_error = yes
			civics = {
				civic = civic_fanatic_purifiers
				civic = civic_scavengers
			}
			species = last_created_species
			ethos = {
				ethic = ethic_fanatic_xenophobe
				ethic = ethic_militarist
			}
			flag = {
				icon = {
					category = "toxoid"
					file = "toxoid_03.dds"
				}
				background = {
					category = "backgrounds"
					file = "flag_BG_24.dds"
				}
				colors = {
					"shadow_purple"
					"black"
					"null"
					"null"
				}
			}
			type = default
			effect = {
				save_global_event_target_as = demonic_incursion_country
				species = {
					save_global_event_target_as = demonic_incursion_species
				}
				establish_communications_no_message = root

				# Corrupted Knight becomes their leader
				set_leader = doomslayer_knight
				event_target:doomslayer_knight@root  = {
					set_skill = 5
					add_trait = {
						trait = trait_ruler_warlike
					}
					remove_trait = leader_trait_butcher
				}

				set_origin = origin_demonic_incursion
				force_add_civic = civic_psionic_sovereign

				##Copy technology
				copy_techs_from = {
					target = root
					except = {
						# Horizon Signal
						tech_akx_worm_1
						tech_akx_worm_2
						tech_akx_worm_3
					}
				}
				IF = {
					limit = {
						from = {
							has_technology = tech_maulers
						}
					}
					give_technology = { tech = tech_corvettes }
					give_technology = { tech = tech_torpedoes_1 }
				}
				IF = {
					limit = {
						root = {
							has_technology = tech_weavers
						}
					}
					give_technology = { tech = tech_destroyers }
				}
				IF = {
					limit = {
						root = {
							has_technology = tech_stingers
						}
					}
					give_technology = { tech = tech_battleships }
				}
				IF = {
					limit = {
						root = {
							has_technology = tech_harbingers
						}
					}
					give_technology = { tech = tech_cruisers }
				}

				##Add resources
				add_resource = { minerals = 10000 }
				add_resource = { energy = 10000 }
				add_resource = { food = 3000 }
				add_resource = { consumer_goods = 3000 }
				add_resource = { alloys = 7000 }
				add_resource = { influence = 1000 }
				add_resource = { unity = 27000 }

				##Create fleets
				set_variable = {
					which = num_demon_fleets
					value = trigger:max_naval_capacity
				}

				divide_variable = {
					which = num_demon_fleets
					value = 90
				}

				ceiling_variable = num_demon_fleets

				while = {
					count = num_demon_fleets
					add_resource = { energy = 1000 } # Give some energy to pay for ship upkeep
					create_fleet = {
						effect = {
							set_owner = event_target:demonic_incursion_country
							create_ship = {
								name = random
								design = "NAME_Ancestral_Glory"
								graphical_culture = "pirate_01"
							}
							while = {
								count = 24
								create_ship = {
									name = random
									design = "NAME_Outrider"
									graphical_culture = "pirate_01"
								}
							}
							while = {
								count = 12
								create_ship = {
									name = random
									design = "NAME_Lancer"
									graphical_culture = "pirate_01"
								}
							}
							while = {
								count = 6
								create_ship = {
									name = random
									design = "NAME_Void_Champion"
									graphical_culture = "pirate_01"
								}
							}
							set_location = {
								target = event_target:demonic_incursion_planet
								distance = 10
								angle = random
							}
						}
					}
				}
			}
		}

		fromfrom = {
			set_owner = event_target:demonic_incursion_country
			set_capital = yes
			while = {
				count = 28
				create_pop_group = {
					species = event_target:demonic_incursion_species
				}
			}

			# Reformat the planet
			remove_all_districts = yes
			remove_all_buildings = yes
			generate_start_buildings_and_districts = yes
			remove_building = building_commercial_zone
			add_building = building_holo_theatres

			event_target:demonic_incursion_armies = {
				every_owned_army = {
					remove_army = yes
				}
			}

			# Flip control of the solar system
			solar_system = {
				if = {
					limit = { exists = starbase }
					starbase = {
						if = {
							limit = {
								is_owned_by = root
							}
							set_owner = event_target:demonic_incursion_country
							if = {
								limit = { has_starbase_size = starbase_outpost }
								set_starbase_size = starbase_starport
								set_starbase_module = {
									slot = 1
									module = shipyard
								}
								set_starbase_module = {
									slot = 2
									module = shipyard
								}
							}
							else_if = {
								limit = {
									NOT = { has_starbase_module = shipyard }
								}
								set_starbase_module = {
									slot = 1
									module = shipyard
								}
								set_starbase_module = {
									slot = 2
									module = shipyard
								}
							}
						}
					}
				}
				else = {
					create_starbase = {
						size = starbase_starport
						module = shipyard
						module = shipyard
						owner = event_target:demonic_incursion_country
					}
				}
				add_claims = {
					who = root
					show_notification = no
				}
				every_system_planet = {
					limit = {
						is_colony = yes
						NOT = { is_same_value = event_target:demonic_incursion_planet }
						is_owned_by = root
					}
					set_owner = event_target:demonic_incursion_country
				}
				every_fleet_in_system = {
					limit = { is_owned_by = root }
					set_mia = mia_return_home
				}
			}
		}
	}

	option = {
		name = colony.3051.a
		custom_tooltip = demonic_incursion_tooltip
	}

	option = {
		name = colony.3051.b
		custom_tooltip = demonic_takeover_tooltip
		hidden_effect = {
			event_target:demonic_incursion_country = { set_player = root }
		}
	}

	after = {
		hidden_effect = {
			fromfrom = {
				remove_deposit = d_portal_research_zone
			}
		}
	}
}

carrier_event = { #Demonic Refugees
	id = colony.3055
	title = "colony.3055.name"
	desc = "colony.3055.desc"
	picture = GFX_evt_cover_blown
	location = ROOT

	is_triggered_only = yes

	option = { #Kill the demons!
		name = colony.3055.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = 12
				min = @tier3unitymin
				max = @tier3unitymax
			}
		}
		custom_tooltip = portal_closed_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			remove_carrier_flag = dportal_hell
		}
	}

	option = { #Welcome the refugees
		name = colony.3055.b
		custom_tooltip = portal_closed_tooltip
		custom_tooltip = demon_refugees_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			owner = {
				create_demon_species_effect = yes
			}
			while = {
				count = 4
				create_pop_group = {
					species = last_created_species
				}
			}
		}
	}
}

carrier_event = { #Quest Complete!
	id = colony.3060
	title = "colony.3060.name"
	desc = "colony.3060.desc"
	picture = GFX_evt_zro_3
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony.3060.a
		hidden_effect = {
			set_carrier_flag = dportal_closed
			remove_carrier_flag = dportal_hell
		}
		owner = {
			add_modifier = {
				modifier = doomslayer_quest_complete
				days = -1
			}
		}
	}
}


##############################
#
# Colony Events
# by Joachim
#
##############################

namespace = colony

carrier_event = { # The Lonely Bot welcomes new colonists on the planet
	id = colony.5000
	title = colony.5000.name
	desc = colony.5000.desc
	picture = GFX_evt_alien_ruins

	location = ROOT

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		has_deposit = d_hab_lonely_bot_deposit
	}

	option = {
		name = colony.5000.a
		add_modifier = {
			modifier = the_lonely_bot_welcome
			years = 10
		}
		hidden_effect = {
			carrier_event = {
				id = colony.5005
				days = 3600
				random = 1800
			}
		}
	}
}

carrier_event = { # The Lonely Bot's factory is starting to fall apart - Project start event
	id = colony.5005
	title = colony.5005.name
	desc = colony.5005.desc
	picture = GFX_evt_alien_ruins

	location = ROOT

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		original_owner = yes
		is_ai = no
	}

	trigger = {
		has_deposit = d_hab_lonely_bot_deposit
	}

	option = {
		name = colony.5005.a
		enable_special_project = {
			name = "LONELY_BOT_PROJECT"
			location = this
			owner = root.owner
		}
	}
}

carrier_event = { # Failure to restore the Lonely Bot's factory
	id = colony.5006
	title = colony.5006.name
	desc = colony.5006.desc
	picture = GFX_evt_alien_ruins

	location = ROOT

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		original_owner = yes
		is_ai = no
	}

	trigger = {
		has_deposit = d_hab_lonely_bot_deposit
	}

	option = {
		name = colony.5006.a
		remove_deposit = d_hab_lonely_bot_deposit
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = 3
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}
}

carrier_event = { # Successfully restores the Lonely Bot's factory
	id = colony.5010
	title = colony.5010.name
	desc = colony.5010.desc
	picture = GFX_evt_alien_ruins

	location = ROOT

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		original_owner = yes
		is_ai = no
	}

	trigger = {
		has_deposit = d_hab_lonely_bot_deposit
	}

	immediate = {
		hidden_effect = {
			remove_deposit = d_hab_lonely_bot_deposit
			add_deposit = d_hab_lonely_bot_deposit_2
		}
	}

	option = {
		name = colony.5010.a
		custom_tooltip = colony.5010.tt
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = 5
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.5015
				days = 3600
				random = 7200
			}
		}
	}
}

carrier_event = { # The missing Lonely Bot - Project start event
	id = colony.5015
	title = colony.5015.name
	desc = colony.5015.desc
	picture = GFX_evt_alien_ruins

	location = ROOT

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		original_owner = yes
		is_ai = no
	}

	trigger = {
		has_deposit = d_hab_lonely_bot_deposit_2
	}

	option = {
		name = colony.5015.a
		enable_special_project = {
			name = "LONELY_BOT_MISSING_PROJECT"
			location = this
			owner = root.owner
		}
	}
}

carrier_event = { # Choosing between Lonely Bot and instant resources
	id = colony.5020
	title = colony.5020.name
	desc = colony.5020.desc
	picture = GFX_evt_alien_ruins

	location = ROOT

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		original_owner = yes
		is_ai = no
	}

	trigger = {
		has_deposit = d_hab_lonely_bot_deposit_2
	}

	option = {
		name = colony.5020.a
		hidden_effect = {
			remove_deposit = d_hab_lonely_bot_deposit_2
			add_deposit = d_hab_lonely_bot_deposit_3
		}
		custom_tooltip = colony.5020.tt
	}

	option = {
		name = colony.5020.b
		if = {
			limit = {
				has_deposit = d_hab_lonely_bot_deposit_2
			}
			remove_deposit = d_hab_lonely_bot_deposit_2
		}
		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_administrative_ai }
					can_research_technology = tech_administrative_ai
				}
				add_research_option = tech_administrative_ai
				add_tech_progress = {
					tech = tech_administrative_ai
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					has_technology = tech_administrative_ai
					NOT = { has_technology = tech_self_aware_logic }
					can_research_technology = tech_self_aware_logic
				}
				add_research_option = tech_self_aware_logic
				add_tech_progress = {
					tech = tech_self_aware_logic
					progress = 0.5
				}
			}
			else_if = {
				limit = {
					has_technology = tech_self_aware_logic
					NOT = { has_technology = tech_sapient_ai }
					can_research_technology = tech_sapient_ai
				}
				add_research_option = tech_sapient_ai
				add_tech_progress = {
					tech = tech_sapient_ai
					progress = 0.5
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = engineering_research
					value = @tier2researchreward
					min = @tier2researchmin
					max = @tier2researchmax
				}
			}
			give_specimen = { key = destroyed_mascot_of_colony targets = { root } }
		}
	}
}


############################
#
# Colony Events
# Written by Douglas Furen
#
############################

namespace = colony

### FERAL OVERLOAD
carrier_event = {
	id = colony.8001
	title = "colony.8001.name"
	desc = "colony.8001.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_planetary_riot
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		owner = {
			NOT = {
				has_ethic = ethic_gestalt_consciousness
				has_country_flag = feral_overload_flag
			}
		}
		OR = {
			is_planet_class = pc_arid
			is_planet_class = pc_alpine
			is_planet_class = pc_tundra
			is_planet_class = pc_continental
			is_planet_class = pc_ocean
			is_planet_class = pc_tropical

		}
		pop_amount > 0
	}

	immediate = {
		owner = {
			set_country_flag = feral_overload_flag
		}
		set_carrier_flag = colony_event
	}

	is_triggered_only = yes

	option = {
		name = colony.8001.a
		add_modifier = {
			modifier = feral_overload_00
			days = -1
		}
		hidden_effect = {
			carrier_event = { id = colony.8002 days = 40 random = 20 }
		}
	}
}

carrier_event = {
	id = colony.8002
	title = "colony.8002.name"
	desc = "colony.8002.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_planetary_riot
	location = ROOT

	immediate = {
		remove_modifier = feral_overload_00
	}

	is_triggered_only = yes

	option = {
		name = colony.8002.a
		add_modifier = {
			modifier = feral_overload_01
			days = -1
		}
		hidden_effect = {
			carrier_event = { id = colony.8003 days = 40 random = 20 }
		}
	}
}

carrier_event = {
	id = colony.8003
	title = "colony.8003.name"
	desc = "colony.8003.desc"
	picture = GFX_evt_burning_settlement
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	immediate = {
		begin_event_chain = {
			event_chain = "feral_overload_chain"
			target = ROOT
		}
		hidden_effect = {
			if = {
				limit = {
					sapient_pop_amount > 3900
				}
				while = {
					count = 10
					random_owned_pop_group = {
						kill_single_pop = yes
					}
				}
			}
			else_if = {
				limit = {
					sapient_pop_amount > 2900
				}
				while = {
					count = 7
					random_owned_pop_group = {
						kill_single_pop = yes
					}
				}
			}
			else_if = {
				limit = {
					sapient_pop_amount > 2000
				}
				while = {
					count = 5
					random_owned_pop_group = {
						kill_single_pop = yes
					}
				}
			}
			else_if = {
				limit = {
					sapient_pop_amount > 1000
				}
				while = {
					count = 3
					random_owned_pop_group = {
						kill_single_pop = yes
					}
				}
			}
			else_if = {
				limit = {
					sapient_pop_amount > 300
				}
				random_owned_pop_group = {
					kill_single_pop = yes
				}
			}
			else = {
			}
		}
		add_planet_devastation = 50
	}

	option = {
		name = colony.8003.a
		enable_special_project = {
			name = "INVESTIGATE_CAVE_SHROOM_PROJECT"
			location = this
			owner = root
		}
	}
}

### Choose how to respond to Cave Shrooms
carrier_event = {
	id = colony.8004
	title = "colony.8004.name"
	desc = "colony.8004.desc"
	picture = GFX_evt_gray_goo
	show_sound = event_laboratory_sound
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony.8004.a
		enable_special_project = {
			name = "UTILIZE_CAVE_SHROOM_PROJECT"
			location = this
			owner = root
		}
	}

	option = {
		name = colony.8004.b
		enable_special_project = {
			name = "EXTERMINATE_CAVE_SHROOM_PROJECT"
			location = this
			owner = root
		}
	}
}

### Special Project: Utilize Cave Shrooms
carrier_event = {
	id = colony.8005
	title = "colony.8005.name"
	desc = "colony.8005.desc"
	picture = GFX_evt_animal_wildlife
	show_sound = event_laboratory_sound
	location = ROOT

	is_triggered_only = yes

	immediate = {
		remove_modifier = feral_overload_01
	}

	after = {
		remove_carrier_flag = colony_event
	}

	option = {
		name = colony.8005.a
		add_deposit = d_spore_vents
		add_modifier = {
			modifier = feral_overload_02
			days = -1
		}
		owner = { end_event_chain = feral_overload_chain }
	}
}

### Special Project: Exterminate Cave Shrooms
carrier_event = {
	id = colony.8006
	title = "colony.8006.name"
	desc = "colony.8006.desc"
	picture = GFX_evt_archaeologists_escaping
	show_sound = event_laboratory_sound
	location = ROOT

	is_triggered_only = yes

	immediate = {
		remove_modifier = feral_overload_01
	}

	after = {
		remove_carrier_flag = colony_event
	}

	option = {
		name = colony.8006.a
		add_deposit = d_cave_shroom_veins
		owner = { end_event_chain = feral_overload_chain }
	}
}


############################
#
# Colony Events
# Written by Gemma Thomson
#
############################

namespace = colony_fed

carrier_event = {
	id = colony_fed.100
	title = colony_fed.100.name
	desc = colony_fed.100.desc
	picture = GFX_evt_mining_operations
	show_sound = event_construction
	location = root

	is_triggered_only = yes

	trigger = {
		has_owner = yes
		is_homeworld = no
		is_capital = no
		owner = { is_ai = no }
		has_ground_combat = no
		is_occupied_flag = no
		NOR = {
			has_carrier_flag = colony_event
			is_planet_class = pc_habitat
			is_planet_class = pc_ringworld_habitable
			is_planet_class = pc_shattered_ring_habitable
			is_planet_class = pc_ark
		}
		owner = {
			NOR = {
				has_country_flag = bluelotus
				is_wilderness_empire = yes
			}
		}
		pop_amount > 0
		any_owned_pop_job = {
			OR = {
				has_job_type = miner
				has_job_type = mining_drone
			}
		}
	}

	immediate = {
		set_carrier_flag = colony_event
		owner = { set_country_flag = bluelotus }
	}

	option = {
		name = CURIOUS
		add_deposit = d_impossiblecorrie
		hidden_effect = {
			carrier_event = {
				id = colony_fed.105
				days = 45
			}
		}
	}
}

carrier_event = {
	id = colony_fed.105
	title = colony_fed.105.name
	desc = {
		trigger = {
			owner = { is_gestalt = no }
		}
		text = colony_fed.105.desc
	}
	desc = {
		trigger = {
			owner = { is_gestalt = yes }
		}
		text = colony_fed.105.gestalt.desc
	}
	picture = GFX_evt_strategic_resources
	show_sound = event_construction
	location = root

	is_triggered_only = yes

	option = { #Gestalt embrace option
		name = colony_fed.105.a
		trigger = {
			owner = { is_gestalt = yes }
		}
		add_deposit = d_bluelotus
		hidden_effect = {
			carrier_event = {
				id = colony_fed.110
				days = 40
			}
		}
	}

	option = { #Embrace option
		name = colony_fed.105.b
		trigger = {
			owner = { is_gestalt = no }
		}
		owner = { add_resource = { energy = -420 } }
		add_deposit = d_bluelotus
		hidden_effect = {
			carrier_event = {
				id = colony_fed.110
				days = 55
			}
		}
	}

	option = { #Cease
		name = colony_fed.105.c
		trigger = {
			owner = { is_gestalt = no }
		}
		hidden_effect = {
			carrier_event = {
				id = colony_fed.106
				days = 40
			}
		}
	}

	option = { #Gestalt purge
		name = colony_fed.105.d
		trigger = {
			owner = { is_gestalt = yes }
		}
		random_owned_pop_job = {
			limit = {
				has_job_type = fabricator
			}
			kill_assigned_pop_amount = {
				amount = @building_static_jobs_low
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony_fed.107
				days = 50
			}
		}
	}
}

#The facility is disrupted, leaving only a small amount of alloys
carrier_event = {
	id = colony_fed.106
	title = colony_fed.106.name
	desc = colony_fed.106.desc
	picture = GFX_evt_gray_goo
	show_sound = event_structural_collapse
	location = root

	is_triggered_only = yes

	option = {
		name = UNFORTUNATE
		remove_deposit = d_bluelotus #Also removes job
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}
}

#The rogue drone is purged, ending the project
carrier_event = {
	id = colony_fed.107
	title = colony_fed.107.name
	desc = colony_fed.107.desc
	picture = GFX_evt_gray_goo
	show_sound = event_structural_collapse
	location = root

	is_triggered_only = yes

	option = {
		name = GOOD
		remove_deposit = d_bluelotus #Also removes job
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
	}
}

#A special project is created in order to scale-up the lab's production
carrier_event = {
	id = colony_fed.110
	title = colony_fed.110.name
	desc = {
		trigger = {
			owner = { is_gestalt = no }
		}
		text = colony_fed.110.desc
	}
	desc = {
		trigger = {
			owner = { is_gestalt = yes }
		}
		text = colony_fed.110.gestalt.desc
	}
	picture = GFX_evt_strategic_resources
	show_sound = event_default
	location = root

	is_triggered_only = yes

	option = {
		name = OK
		enable_special_project = {
			name = "BLUELOTUS_SCALE_PROJECT"
			location = this
			owner = root.owner
		}
	}
}

#The special project fails, causing a small collapse
carrier_event = {
	id = colony_fed.111
	title = colony_fed.111.name
	desc = colony_fed.111.desc
	picture = GFX_evt_debris
	show_sound = event_structural_collapse
	location = root

	is_triggered_only = yes

	option = {
		name = colony_fed.111.a
		add_deposit = d_ruin_bluelotus
		random_owned_pop_job = {
			limit = {
				OR = {
					has_job_type = foundry
					has_job_type = fabricator
				}
			}
			kill_assigned_pop_amount = {
				amount = @building_static_jobs_low
			}
		}
	}
}

#The lab is reformed, and starts improving alloy production carrier-wide
carrier_event = {
	id = colony_fed.115
	title = colony_fed.115.name
	desc = colony_fed.115.desc
	picture = GFX_evt_strategic_resources
	show_sound = event_laboratory_sound
	location = root

	is_triggered_only = yes

	option = {
		name = colony_fed.115.a
		remove_deposit = d_bluelotus
		add_deposit = d_bluelotus2
		hidden_effect = {
			random = {
				chance = 50
				carrier_event = {
					id = colony_fed.120
					days = 1800
					random = 360
				}
			}
		}
	}
}

#The lab converts itself and its surroundings into a vast alloy deposit
carrier_event = {
	id = colony_fed.120
	title = colony_fed.120.name
	desc = colony_fed.120.desc
	picture = GFX_evt_gray_goo
	show_sound = event_super_explosion
	location = root

	is_triggered_only = yes

	immediate = {
		random_owned_pop_job = {
			limit = {
				OR = {
					has_job_type = foundry
					has_job_type = fabricator
				}
			}
			kill_assigned_pop_amount = {
				amount = @building_static_jobs
			}
		}
	}

	option = {
		name = UNFORTUNATE
		remove_deposit = d_bluelotus2
		remove_deposit = d_impossiblecorrie
		add_deposit = d_crater_bluelotus
	}
}

### Nemma by Victor Haeggman

#Nemma World
carrier_event = {
	id = colony.9000
	title = "colony.9000.name"
	desc = "colony.9000.desc"
	picture = GFX_evt_continental
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		pop_amount > 0
		OR = {
			is_planet_class = pc_continental
			is_planet_class = pc_ocean
		}
		NOR = {
			any_country = { has_country_flag = turtle_world_spawned }
			has_carrier_flag = colony_event
			owner = { is_wilderness_empire = yes }
		}
	}

	immediate = {
		set_carrier_flag = turtle_world_colony
		set_carrier_flag = colony_event
		owner = {
			set_country_flag = turtle_world_spawned
			begin_event_chain = {
				event_chain = nemma_world_chain
				target = this
			}
		}
	}

	option = {
		name = {
			trigger = {
				owner = { NOT = { species_portrait = rep14 } }
			}
			text = "colony.9000.a"
		}
		name = {
			trigger = {
				owner = { species_portrait = rep14 }
			}
			text = "colony.9000.a.turtle"
		}
		owner = {
			tooltip = {
				begin_event_chain = {
					event_chain = nemma_world_chain
					target = this
				}
			}
		}
		add_modifier = {
			modifier = "turtle_world_modifier"
			days = -1
		}

		if = {
			limit = { owner = { has_origin = origin_evolutionary_predators } }
			add_modifier = {
				modifier = "turtle_world_modifier_evopred"
				days = -1
			}
		}

		hidden_effect = {
			carrier_event = {
				id = colony.9005 days = 700 random = 30
			}
		}
	}
}

carrier_event = {
	id = colony.9005
	title = "colony.9005.name"
	desc = {
		trigger = { owner = { is_gestalt = no } }
		text = "colony.9005.desc"
	}
	desc = {
		trigger = { owner = { is_gestalt = yes } }
		text = "colony.9005.desc.gestalt"
	}
	picture = GFX_evt_unspeakable_horror
	show_sound = event_space_amoeba
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	option = {#Yes investigate the Nemmas
		name = colony.9005.a
		enable_special_project = {
			name = "study_turtle_world_project"
			location = this
			owner = root
		}
	}
	option = {#Leave the Nemmas alone
		name = {
			trigger = { owner = { is_gestalt = no } }
			text = "colony.9005.b"
		}
		name = {
			trigger = { owner = { is_gestalt = yes } }
			text = "colony.9005.b.gestalt"
		}
		owner = {
			end_event_chain = nemma_world_chain
		}
		remove_modifier = "turtle_world_modifier"
		add_modifier = {
			modifier = "turtle_world_modifier_alone"
			days = -1
		}
	}
}

carrier_event = {
	id = colony.9010
	title = "colony.9010.name"
	desc = "colony.9010.desc"
	picture = GFX_evt_board_meeting
	show_sound = event_administrative_work
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	option = {
		name = colony.9010.a
		trigger = {
			owner = {
				NOR = {
					is_xenophobe = yes
					is_homicidal = yes
					AND = {
						is_machine_empire = yes
						NOT = { has_civic = civic_machine_servitor }
					}
				}

			}
		}
		enable_special_project = {
			name = "breed_turtle_world_project"
			location = this
			owner = root
		}
	}

	option = {
		name = colony.9010.b
		trigger = {
			owner = {
				NOR = {
					is_egalitarian = yes
					has_civic = civic_hive_empath
					AND = {
						is_machine_empire = yes
						NOT = { has_civic = civic_machine_assimilator }
					}
				}
			}
		}
		enable_special_project = {
			name = "enslave_turtle_world_project"
			location = this
			owner = root
		}
	}
	option = {
		name = colony.9010.c
		trigger = {
			owner = {
				NOR = {
					is_xenophile = yes
					has_civic = civic_hive_empath
					has_civic = civic_machine_servitor
				}
			}
		}
		enable_special_project = {
			name = "mine_turtle_world_project"
			location = this
			owner = root
		}
	}
	option = {
		name = colony.9010.d
		trigger = {
			owner = { is_homicidal = yes }
		}
		enable_special_project = {
			name = "kill_turtle_world_project"
			location = this
			owner = root
		}
	}
}

#Commence the Nemma breeding!
carrier_event = {
	id = colony.9015
	title = "colony.9015.name"
	desc = "colony.9015.desc"
	picture = GFX_evt_alien_planet
	show_sound = event_default
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	immediate = {
		set_variable = {
			which = turtle_amount
			value = 0
		}
	}

	option = {
		name = colony.9015.a
		hidden_effect = {
			carrier_event = {
				id = colony.9020 days = 3600 random = 100
			}
		}
	}
}

#Successful breeding!
carrier_event = {
	id = colony.9020
	title = "colony.9020.name"
	desc = {
		trigger = {
			check_variable = {
				which = turtle_amount
				value = 5
			}
		}
		text = "colony.9020.desc.full"
	}
	desc = {
		trigger = {
			check_variable = {
				which = turtle_amount
				value < 5
			}
		}
		text = "colony.9020.desc"
	}
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	immediate = {
		add_deposit = d_house_turtle
		change_variable = {
			which = turtle_amount
			value = 1
		}
	}

	option = {
		name = colony.9020.a
		trigger = {
			check_variable = {
				which = turtle_amount
				value < 6
			}
		}
		hidden_effect = {
			random_list = {
				2 = {
					carrier_event = {
						id = colony.9020 days = 3600 random = 100
					}
				}

				1 = {
					carrier_event = {
						id = colony.9025 days = 3600 random = 100
					}
					modifier = {
						factor = turtle_amount
						is_variable_set = turtle_amount
					}
				}
			}
		}
	}
	option = {
		name = {
			trigger = { owner = { is_gestalt = no } }
			text = "colony.9020.b"
		}
		name = {
			trigger = { owner = { is_gestalt = yes } }
			text = "colony.9020.b.gestalt"
		}
		trigger = {
			check_variable = {
				which = turtle_amount
				value = 6
			}
		}
		owner = {
			end_event_chain = nemma_world_chain
		}
	}
}

#Failed breeding!
carrier_event = {
	id = colony.9025
	title = "colony.9025.name"
	desc = "colony.9025.desc"
	picture = GFX_evt_clocks
	show_sound = event_laboratory_sound
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	option = {
		name = colony.9025.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		hidden_effect = {
			random_list = {
				3 = {
					carrier_event = {
						id = colony.9020 days = 3600 random = 100
					}
					change_variable = {
						which = turtle_amount
						value = 1
					}
				}
				1 = {
					carrier_event = {
						id = colony.9025 days = 3600 random = 100
					}
					modifier = {
						factor = turtle_amount
						is_variable_set = turtle_amount
					}
				}
			}
		}
	}
}

#Commence the Nemma enslavement!
carrier_event = {
	id = colony.9030
	title = "colony.9030.name"
	desc = "colony.9030.desc"
	picture = GFX_evt_genetic_modification
	show_sound = event_laboratory_sound
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	option = {
		name = colony.9030.a
		add_modifier = {
			modifier = "turtle_world_slaves_modifier"
			days = -1
		}
		hidden_effect = {
			remove_modifier = "turtle_world_modifier"
			if = {
				limit = {
					owner = {
						NOR = {
							has_ethic = ethic_gestalt_consciousness
							is_authoritarian = yes
						}
					}
				}
				carrier_event = {
					id = colony.9035 days = 1000 random = 50
				}
			}
		}
	}
}

#Free the Nemma!
carrier_event = {
	id = colony.9035
	title = "colony.9035.name"
	desc = "colony.9035.desc"
	picture = GFX_evt_burning_settlement
	show_sound = event_planetary_riot
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	option = {
		name = colony.9035.a
		remove_modifier = turtle_world_slaves_modifier
		add_modifier = {
			modifier = "turtle_world_modifier"
			days = -1
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9015 days = 2000 random = 100
			}
		}
	}
	option = {
		name = colony.9035.b
		owner = {
			end_event_chain = nemma_world_chain
		}
		add_modifier = {
			modifier = "embraced_turtle_slavery_modifier"
			days = -1
		}
	}
}

#Commence the Nemma mining!
carrier_event = {
	id = colony.9040
	title = "colony.9040.name"
	desc = "colony.9040.desc"
	picture = GFX_evt_drilling_for_gas
	show_sound = event_construction
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		owner = {
			end_event_chain = nemma_world_chain
		}
		add_deposit = d_turtle_miner
	}
}

#Commence the eating of the dead Nemma!
carrier_event = {
	id = colony.9045
	title = "colony.9045.name"
	desc = "colony.9045.desc"
	picture = GFX_evt_ocean
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	event_chain = nemma_world_chain

	is_triggered_only = yes

	immediate = {
		owner = {
			add_resource = { minerals = 3000 }
			add_resource = { food = 3000 }
		}
	}

	option = {
		exclusive_trigger = {
			owner = {
				has_civic = civic_hive_devouring_swarm
				NOT = { has_origin = origin_evolutionary_predators }
			}
		}
		name = PREY
	}

	option = {
		exclusive_trigger = {
			owner = { has_civic = civic_machine_terminator }
		}
		name = E_DOW_PROPOSE_03
	}

	option = {
		exclusive_trigger = {
			owner = { has_origin = origin_evolutionary_predators }
		}
		name = DELICIOUS
		owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = large TYPE = reptilian } }
	}

	option = {
		name = colony.9045.a
	}

	after = {
		remove_modifier = "turtle_world_modifier"
		add_deposit = d_turtle_corpse
		owner = {
			end_event_chain = nemma_world_chain
		}
	}
}

############################
#
# Colony Events: "Insidious Ophidians"
#
# Designed by Brian Campbell
#
############################
#
#carrier_event = {
#	id = colony.8099
#	title = colony.8099.name
#	desc = colony.8099.desc
#	picture = GFX_evt_alien_nature
#	show_sound = event_air_raid_siren
#	location = ROOT
#
#	pre_triggers = {
#		has_owner = yes
#		is_homeworld = no
#		original_owner = yes
#		is_ai = no
#		has_ground_combat = no
#		is_capital = no
#	}
#
#	trigger = {
#		habitable_planet = yes
#		owner = {
#			NOR = {
#				has_ethic = ethic_gestalt_consciousness
#				has_country_flag = snake_infestation_fired
#			}
#		}
#		NOR = {
#			has_carrier_flag = colony_event
#			has_carrier_flag = snake_infestation_fired
#		}
#		pop_amount > 0
#	}
#
#	is_triggered_only = yes
#
#	immediate = {
#		set_carrier_flag = snake_infestation_fired
#		set_carrier_flag = colony_event
#		owner = { set_country_flag = snake_infestation_fired }
#	}
#
#	option = {
#		name = colony.8099.a
#		hidden_effect = {
#			carrier_event = { id = colony.9100 days = 200 random = 200 }
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9100
#	title = colony.9100.name
#	desc = colony.9100.desc
#	picture = GFX_evt_alien_nature
#	show_sound = event_air_raid_siren
#	location = ROOT
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = colony.9100.a
#		enable_special_project = {
#			name = SNEK_SCIENCE_PROJECT
#			location = this
#			owner = root.owner
#		}
#	}
#
#	option = {
#		name = colony.9100.b
#		enable_special_project = {
#			name = SNEK_WAR_PROJECT
#			location = this
#			owner = root.owner
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9101
#	title = "PROJECT_COMPLETE"
#	desc = "colony.9101.desc"
#	picture = GFX_evt_alien_nature
#	show_sound = event_alien_nature
#	location = ROOT
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = UNDERSTOOD
#		add_modifier = {
#			modifier = energy_poor
#			months = 120
#		}
#		hidden_effect = {
#			carrier_event = { id = colony.9103 days = 200 random = 200 }
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9102
#	title = "PROJECT_COMPLETE"
#	desc = "colony.9102.desc"
#	picture = GFX_evt_alien_planet
#	show_sound = event_alien_nature
#	location = ROOT
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = UNDERSTOOD
#		add_modifier = {
#			modifier = snake_infestation
#			days = 200
#		}
#		hidden_effect = {
#			carrier_event = { id = colony.9103 days = 200 random = 200 }
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9103
#	title = colony.9103.name
#	desc = {
#		trigger = { has_carrier_flag = snake_peace }
#		text = "colony.9103.desc.science"
#	}
#	desc = {
#		trigger = { has_carrier_flag = snake_war }
#		text = "colony.9103.desc.soldier"
#	}
#	picture = GFX_evt_alien_nature
#	show_sound = event_air_raid_siren
#	location = ROOT
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = colony.9103.a
#		add_modifier = {
#			modifier = energy_poor
#			days = 200
#		}
#		hidden_effect = {
#			carrier_event = { id = colony.9104 days = 200 random = 200 }
#		}
#	}
#
#	option = {
#		name = colony.9103.b
#		if = {
#			limit = {
#				has_modifier = snake_infestation
#			}
#			remove_modifier = snake_infestation
#		}
#		add_modifier = {
#			modifier = snake_infestation
#			days = 200
#		}
#		hidden_effect = {
#			carrier_event = { id = colony.9104 days = 200 random = 200 }
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9104
#	title = colony.9104.name
#	desc = {
#		trigger = { has_carrier_flag = snake_peace }
#		text = "colony.9104.desc.science"
#	}
#	desc = {
#		trigger = { has_carrier_flag = snake_war }
#		text = "colony.9104.desc.soldier"
#	}
#	picture = GFX_evt_alien_nature
#	show_sound = event_swarm
#	location = ROOT
#	trackable = yes
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#		pop_amount > 0
#	}
#
#	option = {
#		name = colony.9104.a
#		add_modifier = {
#			modifier = "mining_equipment_offline"
#			days = 240
#		}
#		hidden_effect = {
#			carrier_event = { id = colony.9106 days = 200 random = 200 }
#		}
#	}
#
#	option = {
#		name = colony.9104.b
#		if = {
#			limit = {
#				has_modifier = snake_infestation
#			}
#			remove_modifier = snake_infestation
#		}
#		add_modifier = {
#			modifier = snake_infestation
#			days = 200
#		}
#		hidden_effect = {
#			carrier_event = { id = colony.9106 days = 200 random = 200 }
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9106
#	title = colony.9106.name
#	desc = {
#		trigger = { has_carrier_flag = snake_war }
#		text = "colony.9106.desc"
#	}
#	desc = colony.9106.desc
#	desc = {
#		trigger = { has_carrier_flag = snake_peace }
#		text = "colony.9106.desc.science"
#	}
#	picture = GFX_evt_alien_nature
#	show_sound = event_swarm
#	location = ROOT
#	trackable = yes
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = colony.9106.a
#		# custom_tooltip = colony.9016.a.tooltip
#		owner = {
#			add_monthly_resource_mult = {
#			resource = minerals
#			value = @tier1materialreward
#			min = @tier1materialmin
#			max = @tier1materialmax
#		}
#	}
#	hidden_effect = {
#		carrier_event = {
#			id = colony.9107
#			days = 200
#			random = 200
#			}
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9107
#	title = colony.9107.name
#	desc = colony.9107.desc
#	picture = GFX_evt_alien_nature
#	show_sound = event_swarm
#	location = ROOT
#	trackable = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	is_triggered_only = yes
#
#	immediate = {
#	}
#
#	option = {
#		name = colony.9107.a
#		custom_tooltip = colony.9107.a.tooltip
#		hidden_effect = {
#			carrier_event = { id = colony.9108 days = 40	random = 20 }
#		}
#	}
#
#	option = {
#		name = colony.9107.b
#		custom_tooltip = colony.9107.b.tooltip
#		hidden_effect = {
#			carrier_event = { id = colony.9109 days = 40	random = 20	}
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9108
#	title = colony.9108.name
#	desc = colony.9108.desc
#	picture = GFX_evt_alien_nature
#	show_sound = event_swarm
#	location = ROOT
#	trackable = yes
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = colony.9108.a
#		if = {
#			limit = {
#				has_modifier = "mining_equipment_offline"
#			}
#			remove_modifier = "mining_equipment_offline"
#		}
#		if = {
#			limit = {
#				has_modifier = snake_infestation
#			}
#			remove_modifier = snake_infestation
#		}
#	}
#}
#
#carrier_event = {
#	id = colony.9109
#	title = colony.9109.name
#	desc = colony.9109.desc
#	picture = GFX_evt_alien_nature
#	show_sound = event_swarm
#	location = ROOT
#	trackable = yes
#
#	is_triggered_only = yes
#
#	trigger = {
#		original_owner = yes
#	}
#
#	option = {
#		name = colony.9109.a
#		if = {
#			limit = {
#				has_modifier = energy_poor
#			}
#			remove_modifier = energy_poor
#		}
#		if = {
#			limit = {
#				has_modifier = snake_infestation
#			}
#			remove_modifier = snake_infestation
#		}
#	}
#}

### Greed is Bad by Hadrien Buytaers

#We found more minerals
carrier_event = {
	id = colony.9050
	title = "colony.9050.name"
	desc = "colony.9050.desc"
	picture = GFX_evt_mining_operations
	show_sound = event_scanner
	location = ROOT
	trackable = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		habitable_planet = yes
		NOR = {
			has_global_flag = crystal_colony
			has_carrier_flag = colony_event
			has_modifier = mineral_rich
			has_modifier = ultra_rich
			has_modifier = mineral_poor
			owner = { is_wilderness_empire = yes }
		}
	}

	is_triggered_only = yes

	immediate = {
		set_global_flag = crystal_colony
		set_carrier_flag = colony_event
	}
	#Opt: Start digging
	option = {
		name = colony.9050.a
		add_deposit = d_ore_rich_caverns
	}
	#Opt: Probe for more
	option = {
		name = colony.9050.b
		allow = {
			owner = {
				resource_stockpile_compare = { resource = energy value >= 1000 }
			}
		}
		owner = {
			add_resource = { energy = -1000 }
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9055 days = 90 random = 20
			}
		}
	}
}

#Deep Veins
carrier_event = {
	id = colony.9055
	title = "colony.9055.name"
	desc = "colony.9055.desc"
	picture = GFX_evt_mining_operations
	show_sound = event_scanner
	location = ROOT

	is_triggered_only = yes
	#Opt: Start Digging
	option = {
		name = colony.9055.a
		add_modifier = {
			modifier = mineral_rich
			days = -1
		}
	}
	#Opt: More? (non subterranean)
	option = {
		name = colony.9055.b
		trigger = {
			owner = {
				NOR = {
					is_subterranean_empire = yes
					has_origin = origin_cosmic_dawn
				}
			}
		}
		allow = {
			owner = {
				resource_stockpile_compare = { resource = energy value >= 1500 }
			}
		}
		owner = {
			add_resource = { energy = -1500 }
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9060 days = 120 random = 20
			}
		}
	}
	#Opt: Keep probing (subterranean)
	option = {
		name = colony.9055.b
		trigger = {
			owner = {
				OR = {
					is_subterranean_empire = yes
					has_origin = origin_cosmic_dawn
				}
			}
		}
		allow = {
			owner = {
				resource_stockpile_compare = { resource = energy value >= 1500 }
			}
		}
		owner = {
			add_resource = { energy = -1500 }
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9065 days = 90 random = 20
			}
		}
	}
}

#Too Deep For Us
carrier_event = {
	id = colony.9060
	title = "colony.9060.name"
	desc = "colony.9060.desc"
	picture = GFX_evt_mining_operations
	show_sound = event_drilling
	location = ROOT

	is_triggered_only = yes
	#Opt: Start Digging
	option = {
		name = colony.9060.a
		add_deposit = d_ore_rich_caverns
		add_modifier = {
			modifier = ultra_rich
			days = -1
		}
	}
}

#More Ore
carrier_event = {
	id = colony.9065
	title = "colony.9065.name"
	desc = "colony.9065.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_drilling
	location = ROOT

	is_triggered_only = yes
	#Opt: Start Digging
	option = {
		name = colony.9065.a
		add_deposit = d_ore_rich_caverns
		add_modifier = {
			modifier = mineral_rich
			days = -1
		}
	}
	#Opt: More?!
	option = {
		name = colony.9065.b
		allow = {
			owner = {
				resource_stockpile_compare = { resource = energy value >= 2000 }
			}
		}
		owner = {
			add_resource = { energy = -2000 }
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9070 days = 90 random = 20
			}
		}
	}
}

#Fiery Crystals
carrier_event = {
	id = colony.9070
	title = "colony.9070.name"
	desc = "colony.9070.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_drilling
	location = ROOT

	is_triggered_only = yes
	#Opt: Start Digging
	option = {
		name = colony.9070.a
		add_deposit = d_crystalline_caverns
		add_modifier = {
			modifier = ultra_rich
			days = -1
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9085 days = 3000 random = 600
			}
		}
	}
	#Opt: MORE?!
	option = {
		name = colony.9070.b
		allow = {
			owner = {
				resource_stockpile_compare = { resource = energy value >= 2500 }
			}
		}
		owner = {
			add_resource = { energy = -2500 }
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9075 days = 90 random = 20
			}
		}
	}
}

#TOO MANY CRYSTALS
carrier_event = {
	id = colony.9075
	title = "colony.9075.name"
	desc = {
		trigger = {
			owner = { has_modifier = pacified_crystals }
		}
		text = colony.9075.desc.a
	}
	desc = "colony.9075.desc.b"
	picture = GFX_evt_crystal_kraken
	show_sound = evn_ove_crystal_kraken
	location = ROOT

	is_triggered_only = yes
	#Opt: We dug too deep
	option = {
		name = BATTLESTATIONS
		add_deposit = d_ore_rich_caverns
		add_deposit = d_crystalline_caverns
		add_deposit = d_crystalline_caverns
		add_modifier = {
			modifier = ultra_rich
			days = -1
		}
		#Spawn Crystal Kraken
		hidden_effect = {
			set_planet_purge_type = purge_normal
			root = {
				save_global_event_target_as = crystal_kraken_planet
			}
			create_country = {
				name = "NAME_Crystal_Kraken"
				type = faction
				flag = {
					icon = {
						category = "aquatic"
						file = "aquatic_04.dds"
					}
					background = {
						category = "backgrounds"
						file = "00_solid.dds"
					}
					colors = {
						"light_orange"
						"light_orange"
						"null"
						"null"
					}
				}
				effect = {
					establish_communications_no_message = root.owner
					save_global_event_target_as = crystal_kraken
				}
			}
		}
		create_army = {
			name = "NAME_Crystal_Kraken"
			owner = event_target:crystal_kraken
			type = "crystal_kraken_army"
		}
	}
}

#Crystal Kraken Defeat trigger
# from An army has been killed in ground combat
# This = owner
# From = army
# FromFrom = opponent
# FromFromFrom = colony
country_event = {
	id = colony.9080
	location = ROOT

	hide_window = yes

	is_triggered_only = yes

	trigger = {
		From = { army_type = crystal_kraken_army }
	}

	immediate = {
		fromfromfrom = { save_event_target_as = crystal_kraken_planet }
		fromfrom = {
			country_event = {
				id = colony.9081 days = 1
			}
			if = {
				limit = {
					is_subterranean_empire = yes
				}
				set_country_flag = underlord_achievement
			}
		}
	}
}

#Crystal Kraken Defeated
country_event = {
	id = colony.9081
	title = "colony.9080.name"
	desc = "colony.9080.desc"
	picture = GFX_evt_victorious_army
	show_sound = event_celebration
	location = ROOT

	is_triggered_only = yes

	#Opt: Victory!
	option = {
		name = colony.9080.a
		event_target:crystal_kraken_planet = {
			add_deposit = d_crystal_kraken_body
			hidden_effect = {
				clear_planet_purge_type = yes
				remove_modifier = "crystal_kraken"
				every_owned_pop_group = {
					remove_pop_group_flag = event_purge
				}
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = 120
				min = 240
				max = 99999
			}
		}
	}
}

# This = country
# From = army
#Crystal Kraken destroyed by other means
country_event = {
	id = colony.9082
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		from = { army_type = crystal_kraken_army }
	}

	immediate = {
		from.planet = {
			add_deposit = d_crystal_kraken_body_bombed
			hidden_effect = {
				clear_planet_purge_type = yes
				remove_modifier = "crystal_kraken"
				every_owned_pop_group = {
					remove_pop_group_flag = event_purge
				}
			}
		}
	}
}

#Too Deep?
carrier_event = {
	id = colony.9085
	title = "colony.9085.name"
	desc = "colony.9085.desc"
	picture = GFX_evt_in_the_dark
	show_sound = event_drilling
	location = ROOT

	is_triggered_only = yes
	#Opt: It's fine
	option = {
		name = colony.9085.a
		hidden_effect = {
			carrier_event = {
				id = colony.9090 days = 1000 random = 200
			}
		}
	}
	#Opt: Restrict Digging Operations
	option = {
		name = colony.9085.b
		remove_modifier = ultra_rich
		remove_deposit = d_crystalline_caverns
	}
}

#RELEASE THE CRYSTAL KRAKEN
carrier_event = {
	id = colony.9090
	title = "colony.9075.name"
	desc = {
		trigger = {
			owner = { has_modifier = pacified_crystals }
		}
		text = colony.9075.desc.a
	}
	desc = "colony.9075.desc.b"
	picture = GFX_evt_crystal_kraken
	show_sound = evn_ove_crystal_kraken
	location = ROOT

	is_triggered_only = yes
	#Opt: We did dig too deep
	option = {
		name = BATTLESTATIONS
		#Spawn Crystal Kraken
		hidden_effect = {
			set_planet_purge_type = purge_normal
			create_country = {
				name = "NAME_Crystal_Kraken"
				type = faction
				flag = {
					icon = {
						category = "special"
						file = "unknown.dds"
					}
					background = {
						category = "aquatic"
						file = "aquatic_04.dds"
					}
					colors = {
						"light_orange"
						"light_orange"
						"null"
						"null"
					}
				}
				effect = {
					establish_communications_no_message = root.owner
					save_global_event_target_as = crystal_kraken
				}
			}
		}
		create_army = {
			name = "NAME_Crystal_Kraken"
			owner = event_target:crystal_kraken
			type = "crystal_kraken_army"
		}
	}
}

#Kraken destroys colony
carrier_event = {
	id = colony.9095
	location = ROOT

	hide_window = yes

	is_triggered_only = yes

	trigger = {
		exists = event_target:crystal_kraken
		FromFrom = { is_same_empire = event_target:crystal_kraken }
	}

	immediate = {
		while = {
			limit = {
				pop_amount > 100
			}
			random_owned_pop_group = {
				kill_single_pop = yes
			}
		}
		clear_planet_purge_type = yes
		add_modifier = {
			modifier = "crystal_kraken"
			days = -1
		}
		FromFrom = {
			set_policy = {
				policy = purge
				option = purge_not_allowed
			}
			set_policy = {
				policy = population_controls
				option = population_controls_not_allowed
			}
		}
	}
}

########################################
# Colony Event: "Ancient Manufactorium"
########################################

carrier_event = { # starting event - finding the ancient vaults
	id = colony.9200
	title = "colony.9200.name"
	desc = "colony.9200.desc"
	picture = GFX_evt_discovered_hidden_door
	show_sound = event_wind_ruins
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		habitable_planet = yes
		NOR = {
			owner = { has_country_flag = ancient_manufactorium }
			owner = { is_wilderness_empire = yes }
			has_carrier_flag = colony_event
			is_planet_class = pc_habitat
			is_planet_class = pc_ringworld_habitable
			is_planet_class = pc_shattered_ring_habitable
			is_planet_class = pc_ark
		}
	}

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = colony_event
		owner = { set_country_flag = ancient_manufactorium }
	}

	option = { # find your way into the vault
		name = colony.9200.a
		custom_tooltip = colony.9200.a.desc
		hidden_effect = {
			carrier_event = {
				id = colony.9201
				days = 30
				random = 30
			}
		}
	}
}

carrier_event = { # entry result
	id = colony.9201
	title = "colony.9201.name"
	desc = "colony.9201.desc"
	picture = GFX_evt_hidden_door
	show_sound = event_wind_ruins
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9201.a
		custom_tooltip = colony.9201.a.desc
		add_deposit = d_ancient_manufactorium_vaultexploration
		hidden_effect = {
			carrier_event = {
				id = colony.9210
				days = 180
				random = 360
			}
		}
	}
	option = { # opt out
		name = colony.9201.b
		custom_tooltip = colony.9201.b.desc
		remove_deposit = d_ancient_manufactorium_vaultexploration
		hidden_effect = {
			carrier_event = {
				id = colony.9202
				days = 60
				random = 60
			}
		}
	}
}

carrier_event = { # opting out - explosion, add crater
	id = colony.9202
	title = "colony.9202.name"
	desc = "colony.9202.desc"
	picture = GFX_evt_nuclear_explosion
	show_sound = event_ship_explosion
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # add weak deposit - end the chain
		name = colony.9202.a
		add_deposit = d_ancient_manufactorium_crater
	}
}

carrier_event = { # first problem - pop death potential
	id = colony.9210
	title = "colony.9210.name"
	desc = "colony.9210.desc"
	picture = GFX_evt_engineering_bay
	show_sound = event_screams
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual
		name = colony.9210.a
		custom_tooltip = colony.9210.a.desc
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9211
				days = 180
				random = 360
			}
		}
	}
	option = { # egalitarian
		name = colony.9210.b
		custom_tooltip = colony.9210.b.desc
		trigger = {
			owner = {
				is_egalitarian = yes
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9212
				days = 120
				random = 180
			}
		}
	}
	option = { # authoritarian
		name = colony.9210.c
		custom_tooltip = colony.9210.c.desc
		trigger = {
			owner = {
				is_authoritarian = yes
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9213
				days = 120
				random = 180
			}
		}
	}
	option = { # gestalt - pop dies
		name = colony.9210.d
		custom_tooltip = colony.9210.d.desc
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9214
				days = 100
				random = 100
			}
		}
	}
}

carrier_event = { # first problem - casual result - pop died, bad modifier
	id = colony.9211
	title = "colony.9211.name"
	desc = "colony.9211.desc"
	picture = GFX_evt_emergency_workers
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9211.a
		random_owned_pop_group = {
			kill_single_pop = yes
		}
		owner = {
			add_modifier = {
				modifier = media_coverage_negative_medium
				days = 360
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9220
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # first problem - egalitarian result - pop rescued, bad modifier
	id = colony.9212
	title = "colony.9212.name"
	desc = "colony.9212.desc"
	picture = GFX_evt_emergency_workers
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9212.a
		owner = {
			add_modifier = {
				modifier = media_coverage_negative_low
				days = 360
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9220
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # first problem - authoritarian result - pop died, no modifier
	id = colony.9213
	title = "colony.9213.name"
	desc = "colony.9213.desc"
	picture = GFX_evt_emergency_workers
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9213.a
		random_owned_pop_group = {
			kill_single_pop = yes
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9220
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # first problem - gestalt result - pop died, no modifier
	id = colony.9214
	title = "colony.9214.name"
	desc = "colony.9214.desc"
	picture = GFX_evt_emergency_workers
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9214.a
		random_owned_pop_group = {
			kill_single_pop = yes
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9220
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # first opportunity - might add unity to the pop job
	id = colony.9220
	title = "colony.9220.name"
	desc = "colony.9220.desc"
	picture = GFX_evt_ancient_records
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual - opportunity wasted
		name = colony.9220.a
		custom_tooltip = colony.9220.a.desc
		hidden_effect = {
			carrier_event = {
				id = colony.9230
				days = 360
				random = 360
			}
		}
	}
	option = { # masterful crafters + unity output
		name = colony.9220.b
		custom_tooltip = colony.9220.b.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_corporate_crafters
					has_civic = civic_crafters
				}
			}
		}
		set_carrier_flag = manufactorium_crafters
		hidden_effect = {
			carrier_event = {
				id = colony.9230
				days = 360
				random = 360
			}
		}
	}
	option = { # subterranean + unity output
		name = colony.9220.c
		custom_tooltip = colony.9220.c.desc
		trigger = {
			owner = {
				is_subterranean_empire = yes
			}
		}
		set_carrier_flag = manufactorium_subterranean
		hidden_effect = {
			carrier_event = {
				id = colony.9230
				days = 360
				random = 360
			}
		}
	}
	option = { # subterranean AND masterful crafters + unity output
		name = colony.9220.d
		custom_tooltip = colony.9220.d.desc
		trigger = {
			owner = {
				OR = {
					AND = {
						has_civic = civic_crafters
						is_subterranean_empire = yes
					}
					AND = {
						has_civic = civic_corporate_crafters
						is_subterranean_empire = yes
					}
				}
			}
		}
		set_carrier_flag = manufactorium_dwarven_craft
		hidden_effect = {
			carrier_event = {
				id = colony.9230
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # second problem - earthquake - more upkeep or less production in the end of the chain
	id = colony.9230
	title = "colony.9230.name"
	desc = "colony.9230.desc"
	picture = GFX_evt_collapsing_roof
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual1 - more upkeep
		name = colony.9230.a
		set_carrier_flag = manufactorium_earthquake_upkeep
		hidden_effect = {
			carrier_event = {
				id = colony.9231
				days = 36
				random = 36
			}
		}
	}
	option = { # casual2 - produce less
		name = colony.9230.b
		set_carrier_flag = manufactorium_earthquake_production
		hidden_effect = {
			carrier_event = {
				id = colony.9232
				days = 36
				random = 36
			}
		}
	}
	option = { # managed to maintain everything intactc - bad thing averted
		name = colony.9230.c
		trigger = {
			owner = {
				OR = {
					has_civic = civic_functional_architecture
					has_civic = civic_machine_builder
				}
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9233
				days = 36
				random = 36
			}
		}
	}
	option = { # managed to maintain everything intactc - bad thing averted
		name = colony.9230.d
		trigger = {
			owner = {
				has_civic = civic_hive_divided_attention
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9234
				days = 36
				random = 36
			}
		}
	}
}

carrier_event = { # second problem - eatherquake - more upkeep
	id = colony.9231
	title = "colony.9231.name"
	desc = "colony.9231.desc"
	picture = GFX_evt_collapsing_roof
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9231.a
		hidden_effect = {
			carrier_event = {
				id = colony.9240
				days = 720
				random = 360
			}
		}
	}
}

carrier_event = { # second problem - eatherquake - less produce
	id = colony.9232
	title = "colony.9232.name"
	desc = "colony.9232.desc"
	picture = GFX_evt_collapsing_roof
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9232.a
		hidden_effect = {
			carrier_event = {
				id = colony.9240
				days = 720
				random = 360
			}
		}
	}
}

carrier_event = { # second problem - eatherquake (building civics) - bad outcome averted
	id = colony.9233
	title = "colony.9233.name"
	desc = "colony.9233.desc"
	picture = GFX_evt_collapsing_roof
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9233.a
		hidden_effect = {
			carrier_event = {
				id = colony.9240
				days = 720
				random = 360
			}
		}
	}
}

carrier_event = { # second problem - eatherquake (divided attention civic) - bad outcome averted
	id = colony.9234
	title = "colony.9234.name"
	desc = "colony.9234.desc"
	picture = GFX_evt_collapsing_roof
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9234.a
		hidden_effect = {
			carrier_event = {
				id = colony.9240
				days = 720
				random = 360
			}
		}
	}
}

carrier_event = { # third problem - guardians - potential pop death or less produce
	id = colony.9240
	title = "colony.9240.name"
	desc = "colony.9240.desc"
	picture = GFX_evt_generator_powerup
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual1 - pop death
		name = colony.9240.a
		custom_tooltip = colony.9240.a.desc
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9241
				days = 60
				random = 60
			}
		}
	}
	option = { # casual2 - less produce
		name = colony.9240.b
		custom_tooltip = colony.9240.b.desc
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		set_carrier_flag = manufactorium_guardians_produce
		hidden_effect = {
			carrier_event = {
				id = colony.9242
				days = 30
				random = 30
			}
		}
	}
	option = { # spiritualist ethic - managed to avert the bad situation
		name = colony.9240.c
		custom_tooltip = colony.9240.c.desc
		trigger = {
			owner = {
				is_spiritualist = yes
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9243
				days = 180
				random = 360
			}
		}
	}
	option = { # meritocracy civic - managed to avert the bad situation
		name = colony.9240.d
		custom_tooltip = colony.9240.d.desc
		trigger = {
			owner = {
				has_civic = civic_meritocracy
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9244
				days = 180
				random = 360
			}
		}
	}
	option = { #gestalt - managed to avert the bad situation
		name = colony.9240.e
		custom_tooltip = colony.9240.e.desc
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9245
				days = 60
				random = 60
			}
		}
	}
}

carrier_event = { # third problem - casual 1 pop death
	id = colony.9241
	title = "colony.9241.name"
	desc = "colony.9241.desc"
	picture = GFX_evt_generator_powerup
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = CURSES
		random_owned_pop_group = {
			kill_single_pop = yes
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9250
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # third problem - casual 1 lowered production
	id = colony.9242
	title = "colony.9242.name"
	desc = "colony.9242.desc"
	picture = GFX_evt_generator_powerup
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = CURSES
		hidden_effect = {
			carrier_event = {
				id = colony.9250
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # third problem - spiritualist averted
	id = colony.9243
	title = "colony.9243.name"
	desc = "colony.9243.desc"
	picture = GFX_evt_generator_powerup
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9243.a
		hidden_effect = {
			carrier_event = {
				id = colony.9250
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # third problem - meritocracy averted
	id = colony.9244
	title = "colony.9244.name"
	desc = "colony.9244.desc"
	picture = GFX_evt_generator_powerup
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9244.a
		hidden_effect = {
			carrier_event = {
				id = colony.9250
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # third problem - gestalt averted
	id = colony.9245
	title = "colony.9245.name"
	desc = "colony.9245.desc"
	picture = GFX_evt_generator_powerup
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9245.a
		hidden_effect = {
			carrier_event = {
				id = colony.9250
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # second opportunity - project starting
	id = colony.9250
	title = "colony.9250.name"
	desc = "colony.9250.desc"
	picture = GFX_evt_black_market
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual - opportunity wasted - start the project
		name = colony.9250.a
		custom_tooltip = colony.9250.a.desc
		enable_special_project = {
			name = ANCIENT_MANUFACTORIUM_PROJECT
			location = this
			owner = root.owner
		}
	}
	option = { # technocracy +1 engineering research job output - start the project
		name = colony.9250.b
		custom_tooltip = colony.9250.b.desc
		trigger = {
			owner = {
				has_civic = civic_technocracy
			}
		}
		set_carrier_flag = manufactorium_engineering
		enable_special_project = {
			name = ANCIENT_MANUFACTORIUM_PROJECT
			location = this
			owner = root.owner
		}
	}
	option = { # philosopher king +1 society research job output - start the project
		name = colony.9250.c
		custom_tooltip = colony.9250.c.desc
		trigger = {
			owner = {
				has_civic = civic_philosopher_king
			}
		}
		set_carrier_flag = manufactorium_society
		enable_special_project = {
			name = ANCIENT_MANUFACTORIUM_PROJECT
			location = this
			owner = root.owner
		}
	}
	option = { # natural neural network +1 society research job output - start the project
		name = colony.9250.d
		custom_tooltip = colony.9250.d.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_hive_natural_neural_network
					has_civic = civic_hive_empath
				}
			}
		}
		set_carrier_flag = manufactorium_society
		enable_special_project = {
			name = ANCIENT_MANUFACTORIUM_PROJECT
			location = this
			owner = root.owner
		}
	}
	option = { # introspective +1 engineering research job output - start the project
		name = colony.9250.e
		custom_tooltip = colony.9250.e.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_machine_introspective
					has_civic = civic_machine_predictive_analysis
				}
			}
		}
		set_carrier_flag = manufactorium_engineering
		enable_special_project = {
			name = ANCIENT_MANUFACTORIUM_PROJECT
			location = this
			owner = root.owner
		}
	}
	option = { # oputing out - no special project, instead gain scrapyard - ending the chain
		name = colony.9250.f
		custom_tooltip = colony.9250.f.desc
		remove_deposit = d_ancient_manufactorium_vaultexploration
		add_deposit = d_ancient_manufactorium_scrapyard
	}
}

carrier_event = { # special project finished
	id = colony.9251
	title = "colony.9251.name"
	desc = "colony.9251.desc"
	picture = GFX_evt_black_market
	show_sound = event_construction
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # proceed
		name = colony.9251.a
		hidden_effect = {
			carrier_event = {
				id = colony.9260
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # fourth problem - working conditions - bad modifier to pop happiness or lowered production
	id = colony.9260
	title = "colony.9260.name"
	desc = "colony.9260.desc"
	picture = GFX_evt_board_meeting
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual1 - bad outcome, lowered happiness
		name = colony.9260.a
		custom_tooltip = colony.9260.a.desc
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		set_carrier_flag = manufactorium_work_happiness
		hidden_effect = {
			carrier_event = {
				id = colony.9270
				days = 360
				random = 360
			}
		}
	}
	option = { # casual2 - bad outcome, lowered production
		name = colony.9260.b
		custom_tooltip = colony.9260.b.desc
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		set_carrier_flag = manufactorium_work_production
		hidden_effect = {
			carrier_event = {
				id = colony.9270
				days = 360
				random = 360
			}
		}
	}
	option = { # slaver guilds - bad outcome averted
		name = colony.9260.c
		custom_tooltip = colony.9260.c.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_slaver_guilds
					has_civic = civic_indentured_assets
				}
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9270
				days = 360
				random = 360
			}
		}
	}
	option = { # shared burdens - bad outcome averted
		name = colony.9260.d
		custom_tooltip = colony.9260.d.desc
		trigger = {
			owner = {
				has_civic = civic_shared_burden
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9270
				days = 360
				random = 360
			}
		}
	}
	option = { # gestalt - bad outcome only - increased amenities usage
		name = colony.9260.e
		custom_tooltip = colony.9260.e.desc
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
		set_carrier_flag = manufactorium_work_gestalt
		hidden_effect = {
			carrier_event = {
				id = colony.9270
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # third opportunity - green care - can lower the upkeep or increase production
	id = colony.9270
	title = "colony.9270.name"
	desc = "colony.9270.desc"
	picture = GFX_evt_decryption
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual - opportunity random
		name = colony.9270.a
		custom_tooltip = colony.9270.a.desc
		hidden_effect = {
			random_list = {
				34 = {
					set_carrier_flag = manufactorium_random_good
				}
				66 = {
				}
			}
			carrier_event = {
				id = colony.9280
				days = 360
				random = 360
			}
		}
	}
	option = { # Environmentalist - lowered upkeep
		name = colony.9270.b
		custom_tooltip = colony.9270.b.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_environmentalist
					has_civic = civic_machine_zero_waste_protocols
					has_civic = civic_hive_ascetic
				}
			}
		}
		set_carrier_flag = manufactorium_environmentalists
		hidden_effect = {
			carrier_event = {
				id = colony.9280
				days = 360
				random = 360
			}
		}
	}
	option = { # Barbaric Despoilers - increased production
		name = colony.9270.c
		custom_tooltip = colony.9270.c.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_barbaric_despoilers
					has_civic = civic_fanatic_purifiers
					has_civic = civic_machine_terminator
					has_civic = civic_hive_devouring_swarm
				}
			}
		}
		set_carrier_flag = manufactorium_despoilers
		hidden_effect = {
			carrier_event = {
				id = colony.9280
				days = 360
				random = 360
			}
		}
	}
}

carrier_event = { # fourth opportunity/problem - can increase production by increasing upkeep
	id = colony.9280
	title = "colony.9280.name"
	desc = "colony.9280.desc"
	picture = GFX_evt_sapient_AI
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # dont use the opportunity
		name = colony.9280.a
		custom_tooltip = colony.9280.a.desc
		hidden_effect = {
			carrier_event = {
				id = colony.9290
				days = 60
				random = 60
			}
		}
	}
	option = { # use the opportunity - upkeep + production
		name = colony.9280.b
		custom_tooltip = colony.9280.b.desc
		hidden_effect = {
			random_list = {
				34 = {
					set_carrier_flag = manufactorium_took_opportunity
				}
				26 = {
					set_carrier_flag = manufactorium_took_opportunity_bad
				}
				40 = {
				}
			}
			carrier_event = {
				id = colony.9290
				days = 180
				random = 360
			}
		}
	}
	option = { # Catalytic Processing - increase production, add food upkeep (better than casual 1:2 ratio)
		name = colony.9280.c
		custom_tooltip = colony.9280.c.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_catalytic_processing
					has_civic = civic_hive_catalytic_processing
					has_civic = civic_machine_catalytic_processing
					has_civic = civic_corporate_catalytic_processing
					has_origin = origin_tree_of_life
				}
			}
		}
		set_carrier_flag = manufactorium_catalytic
		hidden_effect = {
			carrier_event = {
				id = colony.9290
				days = 180
				random = 360
			}
		}
	}
	option = { # remnants origin - upgrades casual option from taking the opportunity
		name = colony.9280.d
		custom_tooltip = colony.9280.d.desc
		trigger = {
			owner = {
				has_origin = origin_remnants
			}
		}
		set_carrier_flag = manufactorium_remnants
		hidden_effect = {
			carrier_event = {
				id = colony.9290
				days = 180
				random = 360
			}
		}
	}
}

carrier_event = { # Ending - grand opening and the last opportunity
	id = colony.9290
	title = "colony.9290.name"
	desc = "colony.9290.desc"
	picture = GFX_evt_announcement
	show_sound = event_celebration
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	is_triggered_only = yes

	immediate = {
	}

	option = { # casual - timed happiness boost
		name = colony.9290.a
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		owner = {
			add_modifier = {
				modifier = media_coverage_positive_medium
				days = 720
			}
		}
		remove_deposit = d_ancient_manufactorium_vaultexploration
		add_deposit = d_ancient_manufactorium_working
	}
	option = { # memorialists civic - adding 1 death/drone chronicler job
		name = colony.9290.b
		custom_tooltip = colony.9290.b.desc
		trigger = {
			owner = {
				OR = {
					has_civic = civic_memorialist
					has_civic = civic_machine_memorialist
					has_civic = civic_hive_memorialist
				}
			}
		}
		set_carrier_flag = manufactorium_memorialists
		remove_deposit = d_ancient_manufactorium_vaultexploration
		add_deposit = d_ancient_manufactorium_working
	}
	option = { # aristocratic elite - adding 1 noble job
		name = colony.9290.c
		custom_tooltip = colony.9290.c.desc
		trigger = {
			owner = {
				has_civic = civic_aristocratic_elite
			}
		}
		set_carrier_flag = manufactorium_aristocrats
		remove_deposit = d_ancient_manufactorium_vaultexploration
		add_deposit = d_ancient_manufactorium_working
	}
	option = { # free traders - adding 1 executive job
		name = colony.9290.d
		custom_tooltip = colony.9290.d.desc
		trigger = {
			owner = {
				is_megacorp = yes
				is_worker_coop_empire = no
			}
		}
		set_carrier_flag = manufactorium_traders
		remove_deposit = d_ancient_manufactorium_vaultexploration
		add_deposit = d_ancient_manufactorium_working
	}
	option = { # casual - gestalt, nothing
		name = colony.9290.e
		trigger = {
			owner = {
				is_gestalt = yes
			}
		}
		remove_deposit = d_ancient_manufactorium_vaultexploration
		add_deposit = d_ancient_manufactorium_working
	}
}

### Metallic Puddles
carrier_event = {
	id = colony.9295
	title = "colony.9295.name"
	desc = "colony.9295.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		owner = {
			is_machine_empire = no
			is_wilderness_empire = no
		}
		pop_amount > 0
		OR = {
			is_planet_class = pc_continental
			is_planet_class = pc_tropical
			is_planet_class = pc_savannah
		}
		NOR = {
			has_global_flag = metallic_puddles_global
			has_carrier_flag = colony_event
		}
	}

	is_triggered_only = yes

	immediate = {
		set_global_flag = metallic_puddles_global
		set_carrier_flag = colony_event
	}

	option = {
		name = colony.9295.a
		hidden_effect = {
			carrier_event = { id = colony.9296 days = 35 random = 40 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}
	option = {
		name = colony.9295.b
		hidden_effect = {
			carrier_event = { id = colony.9299 days = 35 random = 40 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}
}

### Silver Slime
carrier_event = {
	id = colony.9296
	title = "colony.9296.name"
	desc = "colony.9296.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	is_triggered_only = yes

	option = {
		name = colony.9296.a
		hidden_effect = {
			carrier_event = { id = colony.9297 days = 35 random = 40 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}
}

### Disappearing Puddles
carrier_event = {
	id = colony.9297
	title = "colony.9297.name"
	desc = "colony.9297.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	is_triggered_only = yes

	option = {
		name = colony.9297.a
		hidden_effect = {
			carrier_event = { id = colony.9298 days = 35 random = 40 }
		}
	}
}

### Return of the Silver Slime
carrier_event = {
	id = colony.9298
	title = "colony.9298.name"
	desc = "colony.9298.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	is_triggered_only = yes

	option = {
		name = colony.9298.a
		hidden_effect = {
			carrier_event = { id = colony.9300 days = 35 random = 40 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
}

### Elusive Viscosity
carrier_event = {
	id = colony.9299
	title = "colony.9299.name"
	desc = "colony.9299.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	is_triggered_only = yes

	option = {
		name = colony.9299.a
		hidden_effect = {
			carrier_event = { id = colony.9300 days = 35 random = 40 }
		}
	}
}

### Elementary, Dear Leader!
carrier_event = {
	id = colony.9300
	title = "colony.9300.name"
	desc = "colony.9300.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes
	is_triggered_only = yes

	option = {
		name = colony.9300.a
		enable_special_project = {
			name = "FASCINATING_METEOROLOGY_PROJECT"
			location = this
			owner = root
		}
	}
}

### Invaluable Insight
carrier_event = {
	id = colony.9301
	title = "colony.9301.name"
	desc = "colony.9301.desc"
	picture = GFX_evt_alien_nature
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.9301.a
		owner = {
			add_monthly_resource_mult = {
				resource = food
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		add_deposit = d_metallic_puddles
	}
}

#Junkyard Orbit
carrier_event = {
	id = colony.9310
	title = colony.9310.name
	desc = colony.9310.desc
	picture = GFX_evt_early_space_age
	show_sound = event_galactic_market
	location = root

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		owner = {
			NOR = {
				has_country_flag = colony_junkyard_orbit
				is_wilderness_empire = yes
			}
		}
		pop_amount > 0
		NOT = {
			has_carrier_flag = colony_event
		}
		is_artificial = no

	}

	immediate = {
		set_carrier_flag = colony_event
		owner = { set_country_flag = colony_junkyard_orbit }
	}

	is_triggered_only = yes

	option = {
		name = colony.9310.a
		custom_tooltip = colony.9310.a.tooltip
		add_blocker = {
			type = d_sprawling_landfill_blocker
			blocked_deposit = random
		}
		hidden_effect = {
			carrier_event = { id = colony.9315 days = 360 random = 20 }
		}
	}
}
carrier_event = {
	id = colony.9315
	title = colony.9315.name
	desc = colony.9315.desc
	picture = GFX_evt_debris
	show_sound = event_air_raid_siren
	location = root
	is_triggered_only = yes

	trigger = {
		has_deposit = d_sprawling_landfill_blocker
	}

	option = {
		name = colony.9315.a
		custom_tooltip = colony.9315.a.tooltip
		add_deposit = d_astrogarbage_collector
		add_modifier = {
			modifier = "trash_rings"
			days = -1
		}
		enable_special_project = {
			name = "orbital_cleanup"
			location = this
			owner = root
		}
	}

	option = {
		name = colony.9315.b
		custom_tooltip = colony.9315.b.tooltip
		add_modifier = {
			modifier = "trash_rings"
			days = -1
		}
		hidden_effect = {
			random_list = {
				60 = { carrier_event = { id = colony.9325 days = 180 random = 20 } }
				40 = { carrier_event = { id = colony.9330 days = 180 random = 20 } }
			}
		}
	}

	option = {
		name = colony.9315.c
		custom_tooltip = colony.9315.c.tooltip
		trigger = {
			OR = {
				owner.species = {
					has_trait = trait_conservational
				}
				owner = {
					species = { NOT = { has_trait = trait_conservational } }
					OR = {
						has_valid_civic = civic_environmentalist
						has_valid_civic = civic_idyllic_bloom
						has_valid_civic = civic_scavengers
						has_valid_civic = civic_eager_explorers
						has_valid_civic = civic_corporate_scavengers
						has_valid_civic = civic_hive_stargazers
						has_valid_civic = civic_machine_zero_waste_protocols
					}
				}
			}
		}
		add_deposit = d_astrogarbage_collector
		add_modifier = {
			modifier = "trash_rings"
			days = -1
		}
		enable_special_project = {
			name = "orbital_cleanup_intense"
			location = this
			owner = root
		}
	}
}

carrier_event = {
	id = colony.9320
	title = colony.9320.name
	desc = colony.9320.desc
	picture = GFX_evt_diplomatic_visit
	show_sound = event_coronation
	location = root
	is_triggered_only = yes

	option = {
		name = colony.9320.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
		remove_modifier = "trash_rings"
	}
}

carrier_event = {
	id = colony.9325
	title = colony.9325.name
	desc = colony.9325.desc
	picture = GFX_evt_space_debris
	show_sound = event_burning_city
	location = root
	is_triggered_only = yes

	option = {
		name = colony.9325.a
		add_modifier = {
			modifier = "ground_locked"
			years = 5
		}
	}
}

carrier_event = {
	id = colony.9330
	title = colony.9330.name
	desc = colony.9330.desc
	picture = GFX_evt_slingshot_stars
	show_sound = event_conversation
	location = root
	is_triggered_only = yes

	option = {
		name = colony.9330.a
		add_modifier = {
			modifier = "shooting_stars"
			years = 5
		}
		remove_modifier = "trash_rings"
	}
}

carrier_event = {
	id = colony.9335
	title = colony.9335.name
	desc = colony.9335.desc
	picture = GFX_evt_diplomatic_visit
	show_sound = event_coronation
	location = root
	is_triggered_only = yes

	option = {
		name = colony.9335.a
		add_modifier = {
			modifier = "clear_skies"
			years = 5
		}
		remove_modifier = "trash_rings"
	}
}

### MYRMEKU
carrier_event = { # Myrmeku Activity
	id = colony.9350
	title = colony.9350.name
	desc = colony.9350.desc
	picture = GFX_evt_animal_wildlife
	show_sound = event_scanner
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		owner = {
			is_robot_empire = yes
		}
		NOR = {
			has_planet_flag = nuked_planet_anomalies_disabled
			has_carrier_flag = colony_event
			is_planet_class = pc_nuked
			is_artificial = yes
			has_global_flag = myrmeku
		}
	}
	immediate = {
		owner = {
			set_country_flag = myrmeku_flag@root
			begin_event_chain = {
				event_chain = myrmeku_chain
				target = this
			}
		}
		set_carrier_flag = colony_event # Prevent other colony event chains
		set_carrier_flag = myrmeku_planet # Checked if planet changes owner
		set_global_flag = myrmeku # Prevent others from getting the same chain
		save_global_event_target_as = myrmeku_planet
	}
	option = {
		name = ACKNOWLEDGED
		owner = {
			tooltip = {
				begin_event_chain = {
					event_chain = myrmeku_chain
					target = this
				}
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9355 days = 180 random = 30
			}
		}
	}
	option = {
		name = colony.9350.a.mem_vault
		trigger = {
			owner = {
				is_memory_vault_empire = yes
			}
		}
		owner = {
			tooltip = {
				begin_event_chain = {
					event_chain = myrmeku_chain
					target = this
				}
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9355 days = 180 random = 30
			}
		}
	}
	option = {
		name = colony.9350.a.exp_prot
		trigger = {
			owner = {
				OR = {
					has_civic = civic_machine_exploration_protocol
					has_civic = civic_environmentalist
				}

			}
		}
		owner = {
			tooltip = {
				begin_event_chain = {
					event_chain = myrmeku_chain
					target = this
				}
			}
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9355 days = 180 random = 30
			}
		}
	}
}

carrier_event = { # Colonists Attacked
	id = colony.9355
	title = colony.9355.name
	desc = colony.9355.desc
	picture = GFX_evt_animal_wildlife
	show_sound = event_swarm
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		NOT = {
			is_planet_class = pc_nuked
		}
		owner = {
			has_country_flag = myrmeku_flag@root
		}
	}
	immediate = {
		add_modifier = {
			modifier = "planet_myrmeku_attacks"
			days = -1
		}
	}
	option = {
		name = colony.9355.a
		hidden_effect = {
			carrier_event = {
				id = colony.9360 days = 120 random = 30
			}
		}
		tooltip = {
			add_modifier = {
				modifier = "planet_myrmeku_attacks"
				days = -1
			}
		}
	}
}

carrier_event = { # Memory Eaters
	id = colony.9360
	title = colony.9360.name
	desc = colony.9360.desc
	picture = GFX_evt_infested
	show_sound = event_swarm
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		NOT = {
			is_planet_class = pc_nuked
		}
		owner = {
			has_country_flag = myrmeku_flag@root
		}
	}
	option = { # Hermetic Seal
		name = colony.9360.a
		custom_tooltip = colony.9360.a.tt
		hidden_effect = {
			remove_modifier = "planet_myrmeku_attacks"
			add_modifier = {
				modifier = "planet_myrmeku_seal_colony"
				days = -1
			}
			carrier_event = {
				id = colony.9365 days = 720 random = 30
			}
		}
	}
	option = { # The Upgrades Do Nothing
		name = colony.9360.b
		custom_tooltip = colony.9360.b.tt
		hidden_effect = {
			remove_modifier = "planet_myrmeku_attacks"
			add_modifier = {
				modifier = "planet_myrmeku_upgrade_robots"
				days = -1
			}
			carrier_event = {
				id = colony.9365 days = 180 random = 30
			}
		}
	}
	option = { # Pest Control
		name = colony.9360.c
		custom_tooltip = colony.9360.c.tt
		hidden_effect = {
			remove_modifier = "planet_myrmeku_attacks"
			add_modifier = {
				modifier = "planet_myrmeku_pest_control"
				days = -1
			}
			set_carrier_flag = "myrmeku_pest_control"
			carrier_event = {
				id = colony.9365 days = 180 random = 30
			}
		}
	}
	option = { # The Harvest
		name = colony.9360.d.org_repro
		custom_tooltip = colony.9360.d.tt
		trigger = {
			owner = {
				is_catalytic_empire = yes
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		hidden_effect = {
			remove_modifier = "planet_myrmeku_attacks"
			add_modifier = {
				modifier = "planet_myrmeku_pest_control"
				days = -1
			}
			set_carrier_flag = "myrmeku_harvest"
			carrier_event = {
				id = colony.9365 days = 360 random = 30
			}
		}
	}
	option = { # Nuclear Option
		name = colony.9360.e.purifier
		custom_tooltip = colony.9360.e.tt
		trigger = {
			owner = {
				has_civic = civic_machine_terminator
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9370 days = 30
			}
		}
	}
}

# Four similar events in one:
#  Hermetic Seal
#  The Upgrades Do Nothing
#  Pest Control
#  The Harvest
carrier_event = {
	id = colony.9365
	title = colony.9365.desc
	desc = {
		trigger = {
			has_modifier = "planet_myrmeku_seal_colony"
		}
		text = colony.9365.desc.seal_colony
	}
	desc = {
		trigger = {
			has_modifier = "planet_myrmeku_upgrade_robots"
		}
		text = colony.9365.desc.upgrade_robots
	}
	desc = {
		trigger = {
			has_modifier = "planet_myrmeku_pest_control"
			has_carrier_flag = "myrmeku_pest_control"
		}
		text = colony.9365.desc.pest_control
	}
	desc = {
		trigger = {
			has_modifier = "planet_myrmeku_pest_control"
			has_carrier_flag = "myrmeku_harvest"
		}
		text = colony.9365.desc.harvest
	}
	picture = GFX_evt_infested
	show_sound = event_swarm
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		NOT = {
			is_planet_class = pc_nuked
		}
		owner = {
			has_country_flag = myrmeku_flag@root
		}
	}
	option = {
		name = colony.9365.a
		if = {
			limit = {
				has_modifier = "planet_myrmeku_pest_control"
				pop_amount > 100
			}
			random_owned_pop_group = {
				limit = {
					is_robot_pop_group = yes
				}
				kill_single_pop = yes
			}
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9375 days = 90 random = 15
			}
		}
	}
}

carrier_event = { # Nuclear Option
	id = colony.9370
	title = colony.9370.name
	desc = colony.9370.desc
	picture = GFX_evt_nuclear_explosion
	show_sound = event_super_explosion
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		NOT = {
			is_planet_class = pc_nuked
		}
		owner = {
			has_country_flag = myrmeku_flag@root
		}
	}
	option = {
		name = colony.9370.a
		hidden_effect = {
			change_pc = pc_nuked
			set_planet_flag = nuked_planet_anomalies_disabled
			reroll_deposits = yes
			tomb_world_modifier_cleanup = yes
			owner = {
				remove_country_flag = myrmeku_flag@root
			}
		}
		owner = {
			end_event_chain = myrmeku_chain
		}
	}
}

carrier_event = { # Analysis Subroutine Proposal
	id = colony.9375
	title = colony.9375.name
	desc = colony.9375.desc
	picture = GFX_evt_infested
	show_sound = event_swarm
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		NOT = {
			is_planet_class = pc_nuked
		}
		owner = {
			has_country_flag = myrmeku_flag@root
		}
	}
	option = { # Resource Diversion
		name = colony.9375.a

		custom_tooltip = colony.9375.a.tt
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		hidden_effect = {
			# Only one of the following modifiers will be present depending on player choices
			remove_modifier = "planet_myrmeku_seal_colony"
			remove_modifier = "planet_myrmeku_upgrade_robots"
			remove_modifier = "planet_myrmeku_pest_control"
			add_modifier = {
				modifier = "planet_myrmeku_lured"
				days = -1
			}
			owner = {
				remove_country_flag = myrmeku_flag@root
			}
		}
		owner = {
			end_event_chain = myrmeku_chain
		}
	}
	option = { # Special Research Project
		name = colony.9375.b
		enable_special_project = {
			name = MYRMEKU_STUDY_PROJECT
			location = this
			owner = root.owner
		}
	}
}

carrier_event = { # Powerful Results
	id = colony.9380
	title = colony.9380.name
	desc = colony.9380.desc
	picture = GFX_evt_infested
	show_sound = event_energy_field
	location = ROOT
	trackable = yes
	event_chain = myrmeku_chain

	is_triggered_only = yes

	trigger = {
		NOT = {
			is_planet_class = pc_nuked
		}
		owner = {
			has_country_flag = myrmeku_flag@root
		}
	}
	immediate = {
		add_deposit = d_myrmeku_power_farms
		# Only one of the following modifiers will be present depending on player choices
		remove_modifier = "planet_myrmeku_seal_colony"
		remove_modifier = "planet_myrmeku_upgrade_robots"
		remove_modifier = "planet_myrmeku_pest_control"
	}
	option = {
		name = colony.9380.a
		tooltip = {
			add_deposit = d_myrmeku_power_farms
		}
		hidden_effect = {
			owner = {
				remove_country_flag = myrmeku_flag@root
			}
		}
		custom_tooltip = t # Adds a blank line between the tooltips
		owner = {
			end_event_chain = myrmeku_chain
		}
	}
}

# Clean up ongoing planet modifiers if planet changes owner.
# If the previous owner has finished the special project in
# the Myrmeku event chain, the deposit stays.
# Called from on_action: on_colony_transfer
carrier_event = {
	id = colony.9385
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_carrier_flag = myrmeku_planet
	}
	immediate = {
		# Only one of the following modifiers will be present depending on player choices
		remove_modifier = "planet_myrmeku_attacks"
		remove_modifier = "planet_myrmeku_seal_colony"
		remove_modifier = "planet_myrmeku_upgrade_robots"
		remove_modifier = "planet_myrmeku_pest_control"
		remove_modifier = "planet_myrmeku_lured"
		remove_carrier_flag = myrmeku_planet
		fromfrom = {
			remove_country_flag = myrmeku_flag@root
		}
	}
}

################################
#
# Negative Mass
# by Victor Haeggman
#
################################

# Prologue
# via 'DPORTAL_PROJECT', part of the 'Rogue Moon' chain beginning at colony.3001
carrier_event = {
	id = colony.9800
	title = "colony.9800.name"
	desc = "colony.9800.desc"
	picture = GFX_evt_news_room
	location = ROOT

	is_triggered_only = yes

	immediate = {
		set_global_flag = b_world_intrudes
	}

	option = {
		name = DISCONCERTING
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		custom_tooltip = portal_closed_tooltip
		hidden_effect = {
			set_carrier_flag = dportal_closed
			owner = {
				country_event = { id = colony.9805 days = 900 random = 100 }
			}
		}
	}
}

country_event = {
	id = colony.9805
	title = "colony.9805.name"
	desc = colony.9805.desc
	is_triggered_only = yes

	picture = GFX_evt_physics_research
	show_sound = event_laboratory_sound

	option = {
		name = colony.9805.a
		hidden_effect = {
			country_event = { id = colony.9810 days = 200 random = 30 }
		}
	}
	option = {
		name = colony.9805.b
		hidden_effect = {
			country_event = { id = colony.9810 days = 150 random = 30 }
		}
	}
}

#Negative Mass start
country_event = {
	id = colony.9810
	title = "colony.9810.name"
	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9810.desc.robot"
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9810.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9810.desc"
	}
	picture = GFX_evt_announcement
	show_sound = event_mystic_reveal
	event_chain = negative_mass

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				is_gestalt = no
				any_owned_leader = {
					is_head_of_research = yes
				}
			}
			random_owned_leader = {
				limit = {
					is_head_of_research = yes
				}
				save_event_target_as = target_physicist
			}
			clone_leader = {
				target = event_target:target_physicist
				effect = {
					save_global_event_target_as = cloned_physicist
					exile_leader_as = cloned_physicist
				}
			}
		}
		else = {
			random_owned_leader = {
				weights = {
					base = 1
					modifier = {
						factor = 100
						leader_class = scientist
					}
					modifier = {
						factor = 0
						is_councilor = yes
						has_ethic = ethic_gestalt_consciousness
					}
				}
				save_event_target_as = target_physicist
			}
			clone_leader = {
				target = event_target:target_physicist
				effect = {
					save_global_event_target_as = cloned_physicist
					exile_leader_as = cloned_physicist
				}
			}
		}
		begin_event_chain = {
			event_chain = negative_mass
			target = root
		}
	}

	option = {
		name = FASCINATING
		add_modifier = { modifier =  harvesting_negative_mass days = -1 }
		tooltip = {
			begin_event_chain = {
				event_chain = negative_mass
				target = root
			}
		}
		hidden_effect = {
			country_event = { id = colony.9815 days = 360 random = 360 }
		}
	}
}

#Gateway appears
country_event = {
	id = colony.9815
	title = "colony.9815.name"
	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9815.desc.robot"
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9815.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9815.desc"
	}
	picture = GFX_evt_wormhole
	show_sound = event_red_alert
	event_chain = negative_mass

	is_triggered_only = yes

	immediate = {
		create_ambient_object = {
			type = "extradimensional_2"
			location = capital_scope.star
			use_3d_location = yes
			entity_offset = { min = 80 max = 80 }
			entity_offset_angle = { min = 180 max = 180 }
			entity_offset_height = { min = 0 max = 0 }
			entity_scale_to_size = yes
			scale = 0.001
		}

		last_created_ambient_object = {
			save_global_event_target_as = b_world_portal
			set_ambient_object_flag = b_world_portal
		}
	}
	option = {
		name = BATTLESTATIONS
		create_country = {
			name = NAME_Portal_Invaders
			type = faction
			effect = {
				establish_communications_no_message = root
				save_global_event_target_as = b_world_country
				create_fleet = {
					name = "NAME_Familiar_Fleet"
					effect = {
						set_owner = prev
						set_fleet_flag = B_world_fleet
						create_ship = {
							name = random
							design = "NAME_B_World_Corvette"
							graphical_culture = root
						}
						create_ship = {
							name = random
							design = last_created_design
							graphical_culture = root
						}
						create_ship = {
							name = random
							design = last_created_design
							graphical_culture = root
						}
						create_ship = {
							name = random
							design = last_created_design
							graphical_culture = root
						}
						create_ship = {
							name = random
							design = last_created_design
							graphical_culture = root
						}
						create_ship = {
							name = random
							design = last_created_design
							graphical_culture = root
						}
						set_location = {
							target = event_target:b_world_portal
							distance = 100
							angle = 260
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 999
					}
				}
				set_relation_flag = {
					who = root
					flag = B_world_relation
				}
				set_faction_hostility = { set_hostile = yes }
			}
		}
	}
}

#An old code
country_event = {
	id = colony.9820
	title = "colony.9820.name"
	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9820.desc.robot"
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9820.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9820.desc"
	}
	show_sound = event_sensor_ping
	picture = GFX_evt_exploding_ship
	auto_opens = yes
	trackable = yes
	location = fromfrom
	fire_only_once = yes
	event_chain = negative_mass

	is_triggered_only = yes

	trigger = {
		exists = from
		FROM = {
			has_relation_flag = {
				who = ROOT
				flag = B_world_relation
			}
		}
	}
	option = {
		trigger = { is_machine_empire = no }
		name = ONSCREEN
		hidden_effect = {
			country_event = { id = colony.9821 }
		}
	}
	option = {
		trigger = { is_machine_empire = yes }
		name = colony.9820.a.robot
		hidden_effect = {
			country_event = { id = colony.9821 }
		}
	}
}

#First communication
country_event = {
	id = colony.9821
	title = colony.9821.name
	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9821.desc.robot"
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9821.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9821.desc"
	}
	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = event_target:cloned_physicist
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}

	option = {
		name = colony.9821.a
		response_text = colony.9821.a.response
		trigger = { is_regular_empire = yes }
		is_dialog_only = yes
	}
	option = {
		name = colony.9821.a.robot
		response_text = colony.9821.a.response.robot
		trigger = { is_machine_empire = yes }
		is_dialog_only = yes
	}
	option = {
		name = colony.9821.a
		response_text = colony.9821.a.response.hive
		trigger = { is_hive_empire = yes }
		is_dialog_only = yes
	}
	option = {
		name = colony.9821.b
		trigger = { is_regular_empire = yes }
		response_text = colony.9821.b.response
		is_dialog_only = yes
	}
	option = {
		name = colony.9821.b.robot
		trigger = { is_machine_empire = yes }
		response_text = colony.9821.b.response.robot
		is_dialog_only = yes
	}
	option = {
		name = colony.9821.b
		response_text = colony.9821.b.response.hive
		trigger = { is_hive_empire = yes }
		is_dialog_only = yes
	}
	option = {
		trigger = { is_machine_empire = no }
		name = colony.9821.c
		hidden_effect = {
			country_event = { id = colony.9822 }
		}
	}
	option = {
		trigger = { is_machine_empire = yes }
		name = colony.9821.c.robot
		hidden_effect = {
			country_event = { id = colony.9822 }
		}
	}
}

#Second communication
country_event = {
	id = colony.9822
	title = colony.9821.name
	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9822.desc.robot"
		}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9822.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9822.desc"
	}
	is_triggered_only = yes

	diplomatic = yes

	picture_event_data = {
		portrait = event_target:cloned_physicist
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}
	option = {
		trigger = { is_regular_empire = yes }
		name = colony.9822.a
		hidden_effect = {
			country_event = { id = colony.9840 days = 360 random = 20 }
		}
	}
	option = {
		trigger = { is_machine_empire = yes }
		name = colony.9822.a.robot
		hidden_effect = {
			country_event = { id = colony.9840 days = 360 random = 20 }
		}
	}
	option = {
		trigger = { is_hive_empire = yes }
		name = colony.9822.a.hive
		hidden_effect = {
			country_event = { id = colony.9840 days = 360 random = 20 }
		}
	}
}

#The summit
country_event = {
	id = colony.9840
	title = "colony.9840.name"

	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9840.desc.robot"
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9840.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9840.desc"
	}
	picture = GFX_evt_board_meeting
	show_sound = event_conversation
	event_chain = negative_mass

	is_triggered_only = yes

	#Study
	option = {
		name = colony.9840.a
		custom_tooltip = colony.9840.a.tooltip
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier4researchreward
				min = @tier4researchmin
				max = @tier4researchmax
			}
		}
		start_situation = {
			type = situation_negative_mass
			target = home_planet
			effect = {
				set_situation_approach = approach_observe_nmass
			}
		}
	}
	#Loot them
	option = {
		name = {
			trigger = {
				is_xenophobe = no
				NOR = {
					has_valid_civic = civic_hive_devouring_swarm
				 	has_valid_civic = civic_machine_terminator
				}
			}
			text = colony.9840.b
		}
		name = {
			trigger = {
				is_xenophobe = yes
			}
			text = colony.9840.b.phobe
		}
		name = {
			trigger = {
				has_valid_civic = civic_hive_devouring_swarm
			}
			text = colony.9840.b.swarm
		}
		name = {
			trigger = {
				has_valid_civic = civic_machine_terminator
			}
			text = colony.9840.b.exterminator
		}
		custom_tooltip = colony.9840.b.tooltip
		owner = {
			add_monthly_resource_mult = {
				resource = minerals
				value = @tier4materialreward
				min = @tier4materialmin
				max = @tier4materialmax
			}
			add_monthly_resource_mult = {
				resource = energy
				value = @tier4materialreward
				min = @tier4materialmin
				max = @tier4materialmax
			}
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier4materialreward
				min = @tier4materialmin
				max = @tier4materialmax
			}
		}
		start_situation = {
			type = situation_negative_mass
			target = home_planet
			effect = {
				set_situation_approach = approach_plunder_nmass
			}
		}
	}

	option = { #Save them
		name = {
			trigger = { is_machine_empire = yes }
			text = colony.9840.c.exterminator
		}
		name = {
			trigger = { is_hive_empire = yes }
			text = colony.9840.c.swarm
		}
		name = {
			trigger = {
				is_xenophobe = yes
			}
			text = colony.9840.c.phobe
		}
		name = {
			trigger = {
				is_xenophobe = no
				is_gestalt = no
			}
			text = colony.9840.c
		}
		custom_tooltip = colony.9840.c.tooltip
		owner = {
			add_monthly_resource_mult = {
				resource = influence
				value = @tier2influencereward
				min = @tier2influencemin
				max = @tier2influencemax
			}
		}
		start_situation = {
			type = situation_negative_mass
			target = home_planet
			effect = {
				set_situation_flag = willing_to_help
				set_situation_approach = approach_save_b_world
			}
		}
		hidden_effect = {
			capital_scope = {
				while = {
					count = 6
					create_pop_group = {
						species = root.species
						effect = { save_event_target_as = b_worlder_pop_group }
					}
					event_target:b_worlder_pop_group = { set_pop_group_flag = b_worlder }
				}
				every_owned_pop_group = {
					limit = {
						has_pop_group_flag = b_worlder
					}
					if = {
						limit = { is_robot_pop_group = yes }
						modify_species = {
							species = this
							add_trait = trait_robot_notofthisworld
						}
					}
					else = {
						modify_species = {
							species = this
							add_trait = trait_notofthisworld
						}
					}
				}
			}
		}
	}

	#Save Planet
	option = {
		name = colony.9840.d
		custom_tooltip = colony.9840.d.tooltip
		start_situation = {
			type = situation_negative_mass
			target = home_planet
			effect = {
				set_situation_flag = willing_to_help
				set_situation_approach = approach_save_b_world
			}
		}
	}
}

#Sucessfuly bring planet into your reality
country_event = {
	id = colony.9850
	title = "colony.9850.name"
	desc = {
		trigger = { is_machine_empire = yes }
		text = "colony.9850.desc.robot"
	}
	desc = {
		trigger = { is_hive_empire = yes }
		text = "colony.9850.desc.hive"
	}
	desc = {
		trigger = { is_regular_empire = yes }
		text = "colony.9850.desc"
	}
	picture = GFX_evt_atmospheric_entry
	show_sound = event_activating_unknown_technology
	event_chain = negative_mass

	is_triggered_only = yes

	immediate = {
		set_country_flag = b_world_spawned
		if = {
			limit = {
				OR  = {
					has_origin = origin_ocean_paradise
					has_origin = origin_ocean_machines
				}
			}
			home_planet = {
				solar_system = {
					spawn_planet = {
						class = pc_ocean
						location = root.home_planet
						orbit_angle_offset = 180
						size = 30
						init_effect = {
							set_name = {
								key = NAME_B_Planet
								variable_string = "[Root.GetHomeWorldName]"
							}
							clear_planet_modifiers = yes
							save_event_target_as = b_planet
							set_owner = root
							set_controller = root
							prevent_anomaly = yes
							clear_blockers = yes
							set_planet_entity = {
								entity = "ocean_paradise_planet_01_entity"
							}
							generate_start_deposits_and_blockers = yes
							remove_all_buildings = yes
							set_carrier_flag = colony_event
							colony = {
								generate_start_buildings_and_districts = yes
							}
						}
					}
					every_ambient_object = {
						limit = { has_ambient_object_flag = b_world_portal }
						destroy_ambient_object = this
					}
				}
			}
		}
		else_if = {
			limit = {
				has_origin = origin_life_seeded
			}
			home_planet = {
				solar_system = {
					spawn_planet = {
						class = pc_gaia
						location = root.home_planet
						orbit_distance_offset = 2
						orbit_angle_offset = 180
						size = 30
						init_effect = {
							set_name = {
								key = NAME_B_Planet
								variable_string = "[Root.GetHomeWorldName]"
							}
							clear_planet_modifiers = yes
							save_event_target_as = b_planet
							set_owner = root
							set_controller = root
							prevent_anomaly = yes
							clear_blockers = yes
							generate_start_deposits_and_blockers = yes
							remove_all_buildings = yes
							set_carrier_flag = colony_event
							colony = {
								generate_start_buildings_and_districts = yes
							}
						}
					}
					every_ambient_object = {
						limit = { has_ambient_object_flag = b_world_portal }
						destroy_ambient_object = this
					}
				}
			}
		}
		else_if = {
			limit = {
				is_apocalyptic_empire = yes
			}
			home_planet = {
				solar_system = {
					spawn_planet = {
						class = pc_nuked
						location = root.home_planet
						orbit_distance_offset = 2
						orbit_angle_offset = 180
						size = 20
						init_effect = {
							set_name = {
								key = NAME_B_Planet
								variable_string = "[Root.GetHomeWorldName]"
							}
							clear_planet_modifiers = yes
							save_event_target_as = b_planet
							set_owner = root
							set_controller = root
							prevent_anomaly = yes
							clear_blockers = yes
							generate_start_deposits_and_blockers = yes
							remove_all_buildings = yes
							set_carrier_flag = colony_event
							colony = {
								generate_start_buildings_and_districts = yes
							}
						}
					}
					every_ambient_object = {
						limit = { has_ambient_object_flag = b_world_portal }
						destroy_ambient_object = this
					}
				}
			}
		}
		else = {
			home_planet = {
				solar_system = {
					spawn_planet = {
						class = pc_ocean
						location = root.home_planet
						orbit_distance_offset = 2
						orbit_angle_offset = 180
						size = 18
						init_effect = {
							set_name = {
								key = NAME_B_Planet
								variable_string = "[Root.GetHomeWorldName]"
							}
							clear_planet_modifiers = yes
							save_event_target_as = b_planet
							set_owner = root
							set_controller = root
							prevent_anomaly = yes
							clear_deposits = yes
							remove_all_buildings = yes
							colony = {
								generate_start_buildings_and_districts = yes
							}
							set_carrier_flag = colony_event
							change_pc = root.owner_species
							if = {
								limit = {
									root.home_planet = {
										has_planet_flag = planet_earth
									}
								}
								generate_earth_deposits_and_blockers = yes
								set_earth_entity = yes
							}
							else = {
								generate_start_deposits_and_blockers = yes
							}
						}
					}
					every_ambient_object = {
						limit = { has_ambient_object_flag = b_world_portal }
						destroy_ambient_object = this
					}
				}
			}
		}
		event_target:b_planet = {
			while = {
				count = 18
				create_pop_group = {
					species = root.species
					effect = { save_event_target_as = b_worlder_pop_group }
				}
				event_target:b_worlder_pop_group = { set_pop_group_flag = b_worlder }
			}
			every_owned_pop_group = {
				limit = {
					has_pop_group_flag = b_worlder
				}
				if = {
					limit = { is_robot_pop_group = yes }
					modify_species = {
						species = this
						add_trait = trait_robot_notofthisworld
					}
				}
				else = {
					modify_species = {
						species = this
						add_trait = trait_notofthisworld
					}
				}
			}
			add_modifier = {
				modifier = b_world_saved
				days = 3600
			}
		}
	}
	option = {
		name = colony.9850.a
		end_event_chain = negative_mass
		remove_modifier = "harvesting_negative_mass"
		random_situation = {
			limit = { is_situation_type = situation_negative_mass }
			destroy_situation = this
		}
	}
}

#Fail or choose not to bring planet into your reality
country_event = {
	id = colony.9851
	title = "colony.9851.name"
	desc = "colony.9851.desc"
	picture = GFX_evt_star_white
	show_sound = event_screams
	event_chain = negative_mass

	is_triggered_only = yes

	immediate = {
		event_target:b_world_portal = {
			destroy_ambient_object = this
		}
	}

	option = {
		name = colony.9851.a
		end_event_chain = negative_mass
		remove_modifier = "harvesting_negative_mass"
		random_situation = {
			limit = { is_situation_type = situation_negative_mass }
			destroy_situation = this
		}
	}
}

situation_event = {
	id = colony.9855
	title = colony.9855.name
	desc = colony.9855.desc
	is_triggered_only = yes
	picture = GFX_evt_busy_spaceport
	show_sound = event_ghost_town
	situation = this
	trigger = {
		current_situation_approach = approach_save_b_world
		owner = { is_gestalt = no }
	}
	option = {
		name = colony.9855.a
		add_situation_progress = 20
		target = { add_modifier = { modifier = appeased_populace days = 1800 } }
	}
	option = {
		allow = {
			owner = { is_egalitarian = no }
		}
		name = colony.9855.b
		target = { add_modifier = { modifier = angered_populace days = 1800 } }
	}
	option = {
		name = colony.9855.c
		add_situation_progress = 5
	}
}

situation_event = {
	id = colony.9860
	title = colony.9860.name
	desc = colony.9860.desc
	is_triggered_only = yes
	picture = GFX_evt_ancient_artifact
	show_sound = event_administrative_work
	situation = this

	trigger = {
		current_situation_approach = approach_save_b_world
		owner = { is_gestalt = no }
	}

	option = {
		allow = {
			owner = {
				OR = {
					NOR = {
						has_valid_civic = civic_barbaric_despoilers
						has_ascension_perk = ap_nihilistic_acquisition
					}
					root.target = {
						has_modifier = multiple_stolen_great_works
					}
				}
			}
		}
		name = colony.9860.a
		owner = { add_resource = { unity = -150 } }
	}
	option = {
		name = {
			trigger = { NOT = { target = { has_modifier = stolen_great_work } } }
			text = colony.9860.b
		}
		name = {
			trigger = { target = { has_modifier = stolen_great_work } }
			text = colony.9860.c
		}
		add_situation_progress = 20
		target = {
			if = {
				limit = { has_modifier = stolen_great_work }
				remove_modifier = stolen_great_work
				add_modifier = { modifier = multiple_stolen_great_works days = -1 }
				add_situation_progress = 25
			}
			else = {
				add_modifier = { modifier = stolen_great_work days = -1 }
			}
		}
		hidden_effect = {
			situation_event = { id = colony.9860 days = 120 }
		}
	}
}

situation_event = {
	id = colony.9865
	hide_window = yes
	is_triggered_only = yes
	situation = this

	immediate = {
		set_variable = {
			which = situation_age
			value = 0
		}
		situation_event = { id = colony.9866 days = 360 }
	}
}

situation_event = {
	id = colony.9866
	hide_window = yes
	is_triggered_only = yes
	situation = this

	immediate = {
		change_variable = {
			which = situation_age
			value = 1
		}
		situation_event = { id = colony.9866 days = 360 }
	}
}

situation_event = {
	id = colony.9870
	title = colony.9870.name
	situation = this
	desc = {
		trigger = { current_situation_approach = approach_save_b_world }
		text = colony.9870.desc.helped
	}
	desc = {
		trigger = { NOT = { current_situation_approach = approach_save_b_world } }
		text = colony.9870.desc.ignored
	}
	is_triggered_only = yes
	picture = GFX_evt_star_white
	show_sound = event_red_alert

	trigger = {
		NOT = {
			situation_progress >= 100
		}
	}

	option = { #Redouble efforts
		trigger = {
			current_situation_approach = approach_save_b_world
		}
		name = colony.9870.a
		custom_tooltip = colony.9870.a.tooltip
		set_situation_flag = redoubled_efforts
	}
	option = { #Everything is fine
		name = colony.9870.b
	}
	option = { #Regret
		name = colony.9870.c
		trigger = {
			NOT = { current_situation_approach = approach_save_b_world }
		}
		set_situation_flag = willing_to_help
		set_situation_approach = approach_save_b_world
		custom_tooltip = colony.9870.a.tooltip
		set_situation_flag = redoubled_efforts
	}
}

situation_event = { #Offloading Optimization
	id = colony.9875
	title = colony.9875.name
	desc = colony.9875.desc
	is_triggered_only = yes
	situation = this
	picture =  {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		picture = GFX_evt_hive_mind
	}
	picture =  {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		picture = GFX_evt_machine_sapience
	}
	show_sound = event_administrative_work

	trigger = {
		current_situation_approach = approach_save_b_world
		owner = { is_gestalt = yes }
	}

	option = {
		name = {
			trigger = {
				owner = { is_machine_empire = yes }
			}
			text = colony.9875.a.machine
		}
		name = {
			trigger = {
				owner = { is_hive_empire = yes }
			}
			text = colony.9875.a.hive
		}
		owner = {
			add_modifier = { modifier = offloaded_optimization days = -1 }
		}
		add_situation_progress = 20
	}
	option = {
		name = colony.9875.b
		add_situation_progress = -5
	}
}

situation_event = {#Desperate Drones
	id = colony.9880
	title = colony.9880.name
	desc = colony.9880.desc
	is_triggered_only = yes
	situation = this
	picture =  {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		picture = GFX_evt_hive_mind
	}
	picture =  {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		picture = GFX_evt_machine_sapience
	}
	show_sound = event_administrative_work

	trigger = {
		current_situation_approach = approach_save_b_world
		owner = { is_gestalt = yes }
	}
	immediate = {
		owner = { set_country_flag = b_world_invasion }
		create_country = {
			name = "NAME_Dominated_Drones"
			type = faction
			effect = {
				establish_communications_no_message = root
				save_global_event_target_as = dominated_drones
				set_relation_flag = {
					who = root
					flag = B_world_relation
				}
				set_faction_hostility = { set_hostile = yes }
			}
		}
	}
	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = colony.9880.a.machine
		custom_tooltip = colony.9880.a.tt
		hidden_effect = {
			target = {
				create_army = {
					name = "NAME_controlled_army"
					species = root.owner.species
					owner = event_target:dominated_drones
					type = "robotic_army"
				}
				if = {
					limit = {
						owner = {
							has_modifier = offloaded_optimization
						}
					}
					while = {
						count = 2
						create_army = {
							name = "NAME_controlled_army"
							species = root.owner.species
							owner = event_target:dominated_drones
							type = "robotic_army"
						}
					}
				}
				random_owned_pop_group = {
					kill_single_pop = yes
				}
			}
		}
		add_situation_progress = 20
	}

	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}

		name = colony.9880.a.hive
		custom_tooltip = colony.9880.a.tt
		hidden_effect = {
			target = {
				create_army = {
					name = "NAME_controlled_army"
					species = root.owner.species
					owner = event_target:dominated_drones
					type = "assault_army"
				}
				if = {
					limit = {
						owner = {
							has_modifier = offloaded_optimization
						}
					}
					while = {
						count = 2
						create_army = {
							name = "NAME_controlled_army"
							species = root.owner.species
							owner = event_target:dominated_drones
							type = "assault_army"
						}
					}
				}
				random_owned_pop_group = {
					kill_single_pop = yes
				}
			}
		}
		add_situation_progress = 20
	}

	option = {
		trigger = {
			owner = { is_hive_empire = yes }
		}
		name = colony.9880.b
		add_situation_progress = 15
		owner = { set_country_flag = calmed_b_world }
		hidden_effect = {
			target = {
				create_army = {
					name = "NAME_controlled_army"
					species = root.owner.species
					owner = event_target:dominated_drones
					type = "assault_army"
				}
				if = {
					limit = {
						owner = {
							has_modifier = offloaded_optimization
						}
					}
					while = {
						count = 2
						create_army = {
							name = "NAME_controlled_army"
							species = root.owner.species
							owner = event_target:dominated_drones
							type = "assault_army"
						}
					}
				}
			}
		}
	}

	option = {
		trigger = {
			owner = { is_machine_empire = yes }
		}
		name = colony.9880.b
		add_situation_progress = 15
		owner = { set_country_flag = calmed_b_world }
		hidden_effect = {
			target = {
				create_army = {
					name = "NAME_controlled_army"
					species = root.owner.species
					owner = event_target:dominated_drones
					type = "robotic_army"
				}
				if = {
					limit = {
						owner = {
							has_modifier = offloaded_optimization
						}
					}
					while = {
						count = 2
						create_army = {
							name = "NAME_controlled_army"
							species = root.owner.species
							owner = event_target:dominated_drones
							type = "robotic_army"
						}
					}
				}
			}
		}
	}


	after = {
		if = {
			limit = {
				owner = {
					is_machine_empire = yes
					NOT = {
						has_country_flag = calmed_b_world
					}
				}
			}
			target = {
				while = {
					count = 4
					create_army = {
						species = root.owner.species
						owner = root.owner
						type = "robotic_army"
					}
				}
			}
		}
		else_if = {
			limit = {
				owner = {
					is_hive_empire = yes
					NOT = {
						has_country_flag = calmed_b_world
					}
				}
			}
			target = {
				while = {
					count = 4
					create_army = {
						species = root.owner.species
						owner = root.owner
						type = "assault_army"
					}
				}
			}
		}
	}
}

country_event = {
	id = colony.9885
	title = colony.9821.name
	desc = {
		trigger = { is_hive_empire = yes }
		text = colony.9885.desc.hive
	}
	desc = {
		trigger = { is_machine_empire = yes }
		text = colony.9885.desc.machine
	}
	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = root.ruler
		planet_background = root.owner
		graphical_culture = root.owner
		city_level = root.owner
		room = root.owner
	}
	trigger = {
		has_country_flag = b_world_invasion
		from = {
			is_same_value = event_target:dominated_drones
		}
	}
	immediate = {
		remove_country_flag = b_world_invasion
	}
	option = {
		trigger = {
			is_hive_empire = yes
		}
		name = colony.9885.a.hive
		custom_tooltip = colony.9885.a.hive.tooltip
	}
	option = {
		trigger = {
			is_machine_empire = yes
		}
		name = colony.9885.a.machine
		custom_tooltip = colony.9885.a.machine.tooltip
	}
	option = {
		trigger = {
			is_hive_empire = yes
			has_country_flag = calmed_b_world
		}
		name = colony.9885.b.hive
		random_situation = {
			limit = {
				is_situation_type = situation_negative_mass
			}
			add_situation_progress = -15
		}
	}
	option = {
		trigger = {
			is_machine_empire = yes
			has_country_flag = calmed_b_world
		}
		name = colony.9885.b.machine
		random_situation = {
			limit = {
				is_situation_type = situation_negative_mass
			}
			add_situation_progress = -15
		}
	}
}

country_event = {
	id = colony.9889
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		from = {
			has_country_flag = b_world_invasion
		}
		is_same_value = event_target:dominated_drones
	}

	immediate = {
		from = {
			country_event = {
				id = colony.9890
				days = 0
				scopes = {
					fromfrom = fromfrom
					from = root
				}
			}
		}
	}
}

country_event = {
	id = colony.9890
	title = colony.9890.name
	desc = colony.9890.desc
	picture = GFX_evt_victorious_army
	is_triggered_only = yes

	trigger = {
		has_country_flag = b_world_invasion
		from = {
			is_same_value = event_target:dominated_drones
		}
	}
	immediate = {
		remove_country_flag = b_world_invasion
		random_situation = {
			limit = {
				is_situation_type = situation_negative_mass
			}
			set_situation_flag = cant_change
			set_situation_approach = approach_save_b_world
		}
	}

	option = {
		name = colony.9890.a
		hidden_effect = {
			event_target:dominated_drones = {
				every_owned_army = {
					remove_army = yes
				}
			}
		}
		fromfrom = {
			set_controller = root
		}
		remove_modifier = offloaded_optimization
		random_situation = {
			limit = {
				is_situation_type = situation_negative_mass
			}
			add_situation_progress = 15
		}
	}
}

#Removes 'Sprawling Slums' blockers from popless planets

carrier_event = {
	id = colony.9895
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		every_deposit = {
			limit = {
				is_deposit_type = d_decrepit_dwellings
			}
			clear_blocker = yes
		}
	}
}

################
# Stasis Prison
################

#Missed The Morning Check In
#this = Planet
carrier_event = {
	id = colony.9900
	title = "colony.9900.name"
	desc = "colony.9900.desc"
	picture = GFX_evt_worrying_signal
	show_sound = event_planetary_riot
	location = ROOT
	trackable = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		pop_amount > 400
		is_moon = no
		has_moon = yes
		is_artificial = no
		NOT = { has_global_flag = dimensional_prison_colony }
		owner = { is_wilderness_empire = no }
	}

	is_triggered_only = yes

	immediate = {
		set_carrier_flag = colony_event
		set_global_flag = dimensional_prison_colony
	}

	option = {
		name = colony.9900.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 500
				}
			}
		}
		owner = {
			add_resource = {
				energy = -500
			}
		}
		custom_tooltip = colony.9900.a.tooltip
		add_modifier = {
			modifier = "reassured_tracking"
			days = -1
		}
		hidden_effect = {
			carrier_event = { id = colony.9905
				days = 180
				random = 180
			}
			random_owned_pop_group = {
				kill_single_pop = yes
			}
		}
	}

	option = {
		name = colony.9900.b
		custom_tooltip = colony.9900.b.tooltip
		add_modifier = {
			modifier = "collective_autophobia"
			days = -1
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9905
				days = 360
				random = 360
			}
			random_owned_pop_group = {
				kill_single_pop = yes
			}
		}
	}
}

#Lucky Scan
#this = Planet
carrier_event = {
	id = colony.9905
	title = "colony.9905.name"
	desc = {
		trigger = {
			has_modifier = reassured_tracking
		}
		text = colony.9905.desc.a
	}
	desc = {
		trigger = {
			has_modifier = collective_autophobia
		}
		text = colony.9905.desc.b
	}
	picture = GFX_evt_ongoing_disaster
	show_sound = event_laboratory_sound
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.9905.a
		custom_tooltip = colony.9905.a.tooltip
		enable_special_project = {
			name = STASIS_PRISON_PROJECT
		}
		hidden_effect = {
			random_owned_pop_group = {
				kill_single_pop = yes
			}
		}
	}
}

#Holding Pattern
#this = Planet
carrier_event = {
	id = colony.9910
	title = "colony.9910.name"
	desc = "colony.9910.desc"
	picture = GFX_evt_ancient_databank
	show_sound = event_mystic_reveal
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.9910.a
		hidden_effect = {
			carrier_event = {
				id = colony.9915
				days = 60
				random = 60
			}
		}
	}
}

#Escape From The Moon
#this = Planet
carrier_event = {
	id = colony.9915
	title = "colony.9915.name"
	desc = "colony.9915.desc"
	picture = GFX_evt_happy_reunion
	show_sound = event_conversation
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	immediate = {
		while = {
			count = 2
			create_pop_group = {
				species = owner_main_species
			}
		}
		remove_modifier = reassured_tracking
		remove_modifier = collective_autophobia
	}

	option = {
		name = colony.9915.a
		custom_tooltip = colony.9915.a.tooltip
		add_deposit = d_stasis_prison
	}

	option = {
		name = colony.9915.b
		trigger = {
			owner = {
				is_gestalt = no
			}
		}
		custom_tooltip = colony.9915.b.tooltip
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
		hidden_effect = {
			random_list = {
				25 = {
					modifier = {
						add = -15
						owner = {
							is_xenophile = yes
						}
					}
					modifier = {
						add = 15
						owner = {
							is_xenophobe = yes
						}
					}
					carrier_event = { id = colony.9920 days = 60 random = 60 }
				}
				50 = {
					carrier_event = { id = colony.9925 days = 60 random = 60 }
				}
				25 = {
					modifier = {
						add = 15
						owner = {
							is_xenophile = yes
						}
					}
					modifier = {
						add = -15
						owner = {
							is_xenophobe = yes
						}
					}
					carrier_event = { id = colony.9930 days = 60 random = 60 }
				}
			}
		}
	}

	option = {
		name = colony.9915.c
		trigger = {
			owner = {
				OR = {
					is_pacifist = yes
					is_egalitarian = yes
					has_civic = civic_police_state
				}
			}
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = minerals
					value >= 1000
				}
			}
		}
		owner = {
			add_resource = {
				minerals = 1000
			}
		}
		add_deposit = d_prisoner_intergration
		custom_tooltip = colony.9915.c.tooltip
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = {
					trait = trait_unruly
					trait = trait_communal
				}
				homeworld = root
				effect = {
					if = {
						limit = {
							is_species_class = LITHOID
						}
						change_species_characteristics = {
							add_trait = trait_lithoid
						}
					}
					else_if = {
						limit = {
							is_species_class = INF
						}
						change_species_characteristics = {
							add_trait = trait_infernal
						}
					}
					else = {
						change_species_characteristics = {
							add_trait = trait_organic
						}
					}
				}
			}
			while = {
				count = 2
				create_pop_group = {
					species = last_created_species
				}
			}
		}
	}

	option = {
		name = colony.9915.d
		trigger = {
			owner = {
				has_civic = civic_hive_devouring_swarm
				country_uses_food = yes
			}
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = minerals
					value >= 1000
				}
			}
		}
		owner = {
			add_resource = {
				minerals = -1000
			}
		}
		add_deposit = d_meals_in_pods
		custom_tooltip = colony.9915.d.tooltip
		if = {
			limit = { owner = { has_origin = origin_evolutionary_predators } }
			owner = { give_evolutionary_predator_situation_progress_and_dna = { AMOUNT = medium } }
		}
	}
}

#Hardened Criminals
#this = Planet
carrier_event = {
	id = colony.9920
	title = "colony.9920.name"
	desc = "colony.9920.desc"
	picture = GFX_evt_dark_alley
	show_sound = event_whispering
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.9920.a
		add_modifier = {
			modifier = freed_stasis_criminals
			days = 1800
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = {
					trait = trait_unruly
					trait = trait_communal
				}
				homeworld = root
			}
			while = {
				count = 4
				create_pop_group = {
					species = last_created_species
				}
			}
		}
	}
}

#Mixed Bag
#this = Planet
carrier_event = {
	id = colony.9925
	title = "colony.9925.name"
	desc = "colony.9925.desc"
	picture = GFX_evt_grand_speech
	show_sound = event_celebration
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.9925.a
		add_modifier = {
			modifier = freed_stasis_criminals
			days = 1800
		}
		add_modifier = {
			modifier = freed_stasis_dissidents
			days = -1
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = {
					trait = trait_unruly
					trait = trait_communal
				}
				homeworld = root
			}
			while = {
				count = 4
				create_pop_group = {
					species = last_created_species
				}
			}
		}
	}
}

#Friendly Prisoners
#this = Planet
carrier_event = {
	id = colony.9930
	title = "colony.9930.name"
	desc = "colony.9930.desc"
	picture = GFX_evt_grand_speech
	show_sound = event_celebration
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.9930.a
		add_modifier = {
			modifier = freed_stasis_dissidents
			days = -1
		}
		hidden_effect = {
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = {
					trait = trait_unruly
					trait = trait_communal
				}
				homeworld = root
			}
			while = {
				count = 4
				create_pop_group = {
					species = last_created_species
				}
			}
		}
	}
}

######################
# STRATOSPHERIC VENTS
######################

#Stratospheric Vents
carrier_event = {
	id = colony.9950
	title = "colony.9950.name"
	desc = "colony.9950.desc"
	picture = GFX_evt_alien_nature
	show_sound = evn_ove_tiyanki_family
	location = ROOT
	trackable = yes
	event_chain = stratovent_world_chain

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		has_modifier = "stratovents"
		pop_amount > 0
		NOR = {
			has_carrier_flag = colony_event
			has_carrier_flag = stratovent_world_colony
			owner = { has_country_flag = stratovents_event_started }
			owner = { has_ethic = ethic_gestalt_consciousness } #Static modifiers and gestalt don't mix easily, have to check later (PDT?) how this could be added
		}
		OR = {
			owner = { has_communications = event_target:tiyanki_garrison_country }
			owner = { has_communications = event_target:tiyanki_country }
		}
	}

	immediate = {
		set_carrier_flag = colony_event
		set_carrier_flag = stratovent_world_colony
		owner = {
			set_country_flag = stratovents_event_started
			begin_event_chain = {
				event_chain = stratovent_world_chain
				target = this
			}
		}
	}

	option = {#Investigate the vents
		name = "colony.9950.a"
		owner = {
			tooltip = {
				begin_event_chain = {
					event_chain = stratovent_world_chain
					target = this
				}
			}
		}
		enable_special_project = {
			name = "STRATOVENTS_PROJECT"
			location = this
			owner = root.owner
		}
	}

	option = {#ignore the vents
		name = "colony.9950.b"
		hidden_effect = {
			owner = {
				end_event_chain = stratovent_world_chain
			}
		}
	}
}

#Use vents for tourism or refining
carrier_event = {
	id = colony.9955
	title = "colony.9955.name"
	desc = "colony.9955.desc"
	picture = GFX_evt_alien_planet
	show_sound = evn_ove_tiyanki_family
	location = ROOT
	trackable = yes
	event_chain = stratovent_world_chain

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			remove_modifier = "stratovents"
		}
	}

	option = {#TOURISM
		name = colony.9955.a
		trigger ={
			owner = {
				NOT = {
					has_ethic = ethic_gestalt_consciousness
				}
			}
		}
		add_modifier = {
			modifier = "stratovent_world_modifier_tourism"
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9960 days = 700 random = 100
			}
		}
	}
	option = {#REFINING
		name = colony.9955.b
		trigger ={
			owner = {
				NOT = {
					has_civic = civic_environmentalist
				}
			}
		}
		add_modifier = {
			modifier = "stratovent_world_modifier_refining"
		}
		hidden_effect = {
			carrier_event = {
				id = colony.9965 days = 700 random = 100
			}
		}
	}
}

#Build viewing platforms
carrier_event = {
	id = colony.9960
	title = "colony.9960.name"
	desc = "colony.9960.desc"
	picture = GFX_evt_tiyanki_observation
	show_sound = event_construction
	location = ROOT
	trackable = yes
	event_chain = stratovent_world_chain

	is_triggered_only = yes



	option = {#BUILD
		name = colony.9960.a
		allow = {
			owner = {
				resource_stockpile_compare = { resource = alloys value >= 200 }
			}
		}
		remove_modifier = "stratovent_world_modifier_tourism"
		add_modifier = {
			modifier = "stratovent_world_modifier_tourism_boost"
		}
		owner = {
			add_resource = {
				alloys = -200
			}
		}
	}
	option = {#IGNORE
		name = colony.9960.b
	}

	after = {
		owner = {
			end_event_chain = stratovent_world_chain
		}
	}
}

#Expand the vents with explosives
carrier_event = {
	id = colony.9965
	title = "colony.9965.name"
	desc = "colony.9965.desc"
	picture = GFX_evt_undertaker
	show_sound = event_scanner
	location = ROOT
	trackable = yes
	event_chain = stratovent_world_chain

	is_triggered_only = yes

	option = {#AUTHORIZE USE OF EXPLOSIVES
		name = colony.9965.a
		hidden_effect = {
			random_list = { #50/50 chance for outcome
				50 = { carrier_event = { id = colony.9970 } } #Vents expanded, more eGas
				50 = { carrier_event = { id = colony.9975 } } #Some vents collapsed, minerals
			}
		}

	}
	option = {#LEAVE THE VENTS BE
		name = colony.9965.b
		owner = {
			end_event_chain = stratovent_world_chain
		}
	}
	option = {#AUTHORIZE EXPLOSIVES (MINING GUILDS)
		name = colony.9965.c
		trigger = {
			owner = {
					has_civic = civic_mining_guilds
				}
			}
		hidden_effect = {
			random_list = { #75/25 chance for outcome
				75 = { carrier_event = { id = colony.9970 } }#Vents expanded, more eGas
				25 = { carrier_event = { id = colony.9975 } }#Some vents collapsed, minerals
			}
		}
	}
}

#EXPLOSIVE USE: SUCCESS
carrier_event = {
	id = colony.9970
	title = "colony.9970.name"
	desc = "colony.9970.desc"
	picture = GFX_evt_mining_operations
	show_sound = event_construction
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		add_planet_devastation = 10
		owner = {
			end_event_chain = stratovent_world_chain
		}
		hidden_effect = {
			remove_modifier = "stratovent_world_modifier_refining"
			add_modifier = {
				modifier = "stratovent_world_modifier_refining_upg"
			}
		}
	}
}

#EXPLOSIVE USE: FAILURE
carrier_event = {
	id = colony.9975
	title = "colony.9975.name"
	desc = "colony.9975.desc"
	picture = GFX_evt_night_raid
	show_sound = event_collapsing_ruins
	location = ROOT
	trackable = yes
	event_chain = stratovent_world_chain

	is_triggered_only = yes

	option = {
		name = UNFORTUNATE
		add_planet_devastation = 20
		owner = {
			end_event_chain = stratovent_world_chain
		}
		hidden_effect = {
			remove_modifier = "stratovent_world_modifier_refining"
			add_modifier = {
				modifier = "stratovent_world_modifier_refining_minerals"
			}
		}
	}
}

#################
# Glacial Crisis
#################

#this = Planet
carrier_event = {
	id = colony.7229
	location = ROOT
	hide_window = yes

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_capital = no
	}

	trigger = {
		OR = {
			is_planet_class = pc_alpine
			is_planet_class = pc_tundra
			is_planet_class = pc_arctic
		}
		owner = {
			NOR = {
				has_country_flag = melting_planet
				has_ascension_perk = ap_mastery_of_nature
				is_wilderness_empire = yes
			}
		}
	}

	immediate  = {
		owner = {
			set_country_flag = melting_planet
		}
		set_carrier_flag = colony_event
		hidden_effect = {
			carrier_event = { id = colony.7230 days = 3600 }
		}
	}
}

carrier_event = {
	id = colony.7230
	title = "colony.7230.name"
	desc = "colony.7230.desc"
	picture = GFX_evt_outpost
	show_sound = event_laboratory_sound
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	pre_triggers = {
		has_owner = yes
		has_ground_combat = no
		is_capital = no
	}

	trigger = {
		owner = {
			NOT = { has_ascension_perk = ap_mastery_of_nature }
		}
		OR = {
			is_planet_class = pc_alpine
			is_planet_class = pc_tundra
			is_planet_class = pc_arctic
		}
	}

	immediate  = {
		save_event_target_as = flooding_planet
	}

	option = {
		name = colony.7230.a
		custom_tooltip = "colony.7230.a.tooltip"
		owner = {
			enable_special_project = {
				name = "MELTING_RESEARCH_PROJECT"
				location = root
				owner = root.owner
			}
		}
	}
	option = {
		name = colony.7230.b
		hidden_effect = {
			carrier_event = { id = colony.7245 days = 360 random = 80 }
		}
	}
}

carrier_event = {
	id = colony.7235
	title = "colony.7235.name"
	desc = "colony.7235.desc"
	picture = GFX_evt_frozen
	show_sound = event_collapsing_ruins
	location = FROM
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.7235.a
		add_modifier = {
			modifier = "active_melting"
			days = -1
		}
		add_modifier = {
			modifier = "halted_production"
			days = -1
		}
		hidden_effect = {
			carrier_event = { id = colony.7240 days = 360 random = 60 }
		}
	}
	option = {
		name = colony.7235.b
		custom_tooltip = "colony.7235.b.tooltip"
		add_modifier = {
			modifier = "boosted_melting"
			days = 720
		}
		hidden_effect = {
			carrier_event = { id = colony.7265 days = 720 }
		}
	}
}

carrier_event = {
	id = colony.7240
	title = "colony.7240.name"
	desc = "colony.7240.desc"
	picture = GFX_evt_decryption
	show_sound = event_bad_omen
	location = FROM
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.7240.a
		add_blocker = {
			type = d_floodplains
			blocked_deposit = random
		}
		hidden_effect = { carrier_event = { id = colony.7247 days = 360 random = 60 } }
	}

	option = {
		name = colony.7240.b
		trigger = {
			owner = { has_valid_civic = civic_environmentalist }
		}
		add_blocker = {
			type = d_floodplains
			blocked_deposit = random
		}
		custom_tooltip = "colony.7240.b.tooltip"
		remove_modifier = "halted_production"
		add_modifier = {
			modifier = "ecological_emergency"
			days = -1
		}
		owner = {
			enable_special_project = {
				name = "PLANET_MELTDOWN_PROJECT"
				location = root
				owner = root.owner
			}
		}
	}
}

carrier_event = {
	id = colony.7245
	title = "colony.7245.name"
	desc = "colony.7245.desc"
	picture = GFX_evt_ongoing_disaster
	show_sound = event_yellow_alert
	location = event_target:flooding_planet
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.7245.a
		add_blocker = {
			type = d_floodplains
			blocked_deposit = random
		}
		owner = {
			random_owned_pop_group = {
				kill_single_pop = yes
			}
		}
		hidden_effect = {
			carrier_event = { id = colony.7247 days = 360 random = 60 }
		}
	}
}

carrier_event = {
	id = colony.7247
	title = "colony.7247.name"
	desc = "colony.7247.desc"
	picture = GFX_evt_tundra
	show_sound = event_mystic_reveal
	location = event_target:flooding_planet
	trackable = yes

	is_triggered_only = yes

	immediate = {
		remove_modifier = active_melting
		remove_modifier = halted_production
	}

	option = {
		name = colony.7247.a
		add_deposit = d_ore_rich_caverns
		hidden_effect = {
			random_list = {
				60 = { carrier_event = { id = colony.7250 days = 240 random = 60 } }
				40 = { carrier_event = { id = colony.7255 days = 240 random = 60 } }
			}
		}
	}
	option = {
		name = colony.7247.b
		custom_tooltip = "colony.7247.b.tooltip"
		owner = {
			owner = {
				add_monthly_resource_mult = {
					resource = unity
					value = @tier2unityreward
					min = @tier2unitymin
					max = @tier2unitymax
				}
			}
		}
	}
}

carrier_event = {
	id = colony.7250
	title = "colony.7250.name"
	desc = "colony.7250.desc"
	picture = GFX_evt_disease_outbreak
	show_sound = event_swarm
	location = event_target:flooding_planet
	trackable = yes

	is_triggered_only = yes

	trigger =  {
		owner =  {
			is_machine_empire = no
		}
	}

	option = {
		name = colony.7250.a
		random_owned_pop_group = {
			kill_single_pop = yes
		}
		add_modifier = {
			modifier = "cruel_actions"
			days = 360
		}
	}
	option = {
		name = colony.7250.b
		add_modifier = {
			modifier = "ancient_plague"
			days = 720
		}
	}
}

carrier_event = {
	id = colony.7255
	title = "colony.7255.name"
	desc = "colony.7255.desc"
	picture = GFX_evt_crystal_mining
	show_sound = event_mystic_reveal
	location = event_target:flooding_planet
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.7255.a
		add_deposit = d_crystalline_glacier
	}
}

carrier_event = {
	id = colony.7260
	title = "colony.7260.name"
	desc = "colony.7260.desc"
	picture = GFX_evt_icelocked_settlement
	show_sound = event_mystic_reveal
	location = event_target:flooding_planet
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.7260.a
		remove_modifier = active_melting
		remove_modifier = ecological_emergency
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier4unityreward
				min = @tier4unitymin
				max = @tier4unitymax
			}
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
	}
}

carrier_event = {
	id = colony.7265
	title = "colony.7265.name"
	desc = "colony.7265.desc"
	picture = GFX_evt_underwater_ruins
	show_sound = event_mystic_reveal
	location = event_target:flooding_planet
	trackable = yes

	is_triggered_only = yes

	trigger = {
		OR = {
			is_planet_class = pc_tundra
			is_planet_class = pc_alpine
			is_planet_class = pc_arctic
		}
	}

	option = {
		name = colony.7265.a
		remove_modifier = active_melting
		add_deposit = d_mineral_seabed
		change_pc = pc_ocean
		IF =  {
			limit = {
				owner_main_species = {
					has_aquatic_trait = yes
				}
			}
			owner = {
				add_monthly_resource_mult = {
					resource = unity
					value = @tier3unityreward
					min = @tier3unitymin
					max = @tier3unitymax
				}
			}
		}
	}
}

#Rapid Desertification
# Originates from 'RAPID_DESERTIFICATION_CAT'
country_event = {
	id = colony.7160
	title = "colony.7160.name"
	desc = "colony.7160.desc"
	picture = GFX_evt_arena
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	trigger = {
		NOT = {
			any_owned_planet = {
				has_carrier_flag = rampant_desertlings
			}
		}
	}
	immediate = {
		set_country_flag = friendly_desertlings
	}

	option = {
		name = colony.7160.a
		add_modifier = {
			modifier = "national_pets"
			years = 5
		}
	}
}

carrier_event = {
	id = colony.7165
	title = "colony.7165.name"
	desc = "colony.7165.desc"
	picture = GFX_evt_unidentified_monster
	show_sound = event_swarm
	trackable = yes
	location = ROOT

	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = {
				has_country_flag = friendly_desertlings
			}
			OR = {
				any_owned_planet = { has_carrier_flag = desertling_fauna }
				any_owned_species = { has_trait = trait_presapient_unintelligent }
			}
		}
		NOT = {
			has_carrier_flag = colony_event_mid
		}
	}

	immediate = {
		owner = {
			random_owned_planet = {
				limit = {
					NOT = {
						has_carrier_flag = rampant_desertlings
					}
					pop_amount > 100
					OR = {
						has_carrier_flag = desertling_fauna
						any_owned_pop_group = { has_trait = trait_presapient_unintelligent }
					}
				}
			set_carrier_flag = rampant_desertlings
			set_carrier_flag = desertling_target
			set_carrier_flag = colony_event_mid
			}
		}
	}

	option = {
		name = colony.7165.a
		owner = {
			random_owned_planet = {
				limit = {
					has_carrier_flag = desertling_target
				}
				add_deposit = d_desertling_infestation
			}
		}
			hidden_effect = {
				random_list = {
					50 = { carrier_event = { id = colony.7170 days = 180 random = 60 } }
					50 = { carrier_event = { id = colony.7175 days = 180 random = 60 } }
				}
		}
	}

	option = {
		name = colony.7165.b
		allow = {
			owner =  {
				resource_stockpile_compare = {
					resource = energy
					value > 500
				}
			}
		}
		owner = {
			add_resource = { energy = 1000 }
		}
		owner = {
			random_owned_planet = {
				limit = {
					has_carrier_flag = desertling_target
				}
				add_deposit = d_alien_sanctuary
				remove_carrier_flag = desertling_target
			}
		}
	}
}

carrier_event = {
	id = colony.7166
	title = "colony.7165.name"
	desc = "colony.7165.desc"
	picture = GFX_evt_unidentified_monster
	show_sound = event_swarm
	trackable = yes
	location = event_target:rampant_desertlings

	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = {
				has_country_flag = friendly_desertlings
			}
		}
	}

	immediate = {
		set_carrier_flag = rampant_desertlings
		set_carrier_flag = desertling_target
	}

	option = {
		name = colony.7165.a
		add_deposit = d_desertling_infestation
		hidden_effect = {
			random_list = {
				50 = { carrier_event = { id = colony.7170 days = 180 random = 60 } }
				50 = {  carrier_event = { id = colony.7175 days = 180 random = 60 } }
			}
		}
	}

	option = {
		name = colony.7165.b
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value > 500
				}
			}
		}
		owner = {
			add_resource = { energy = 1000 }
		}
		add_deposit = d_alien_sanctuary
	}
}

carrier_event = {
	id = colony.7170
	title = "colony.7170.name"
	desc = "colony.7170.desc"
	picture = GFX_evt_archaeology_camp
	show_sound = event_ground_battle
	trackable = yes
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony.7170.a
		owner = {
			add_resource = {
				food = 1000
			}
		}
		owner = {
			random_owned_planet = {
				limit = {
					has_carrier_flag = desertling_target
				}
				remove_carrier_flag = desertling_target
			}
		}
	}
}

carrier_event = {
	id = colony.7175
	title = "colony.7175.name"
	desc = "colony.7175.desc"
	picture = GFX_evt_undertaker
	show_sound = event_swarm
	trackable = yes
	location = ROOT

	is_triggered_only = yes

	option = {
		name = colony.7175.a
		owner = {
			random_owned_planet = {
				limit = {
					has_carrier_flag = desertling_target
				}
				add_modifier = {
					modifier = "alien_infestation"
					years = 5
				}
				remove_carrier_flag = desertling_target
			}
		}
	}

	option = {
		name = colony.7175.b
		custom_tooltip = colony.7175.b.tooltip
		owner = {
			random_owned_planet = {
				limit = {
					has_carrier_flag = desertling_target
				}
				add_modifier = {
					modifier = "rodent_war"
					days = 360
				}
			}
		}
		hidden_effect = { carrier_event = { id = colony.7180 days = 360 } }
	}
}

carrier_event = {
	id = colony.7180
	hide_window = yes
	is_triggered_only = yes
	location = ROOT

	immediate = {
		owner = {
			random_owned_planet = {
				limit = {
					has_carrier_flag = desertling_target
				}

				remove_deposit = d_desertling_infestation
				remove_carrier_flag = desertling_target
			}
		}
	}
}

# Eruption Planet Event for Obsidian Lakes
carrier_event = {
	id = colony_mod.30
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_modifier = obsidian_lakes
	}

	immediate = {
		if = {
			limit = {
				NOT = { has_modifier = recent_eruption }
			}

			carrier_event = { id = colony_mod.31 random = 31 }
		}
	}
}

carrier_event = {
	id = colony_mod.31
	title = "colony_mod.31.name"
	desc = "colony_mod.31.desc"
	picture = GFX_evt_molten
	show_sound = event_air_raid_siren
	location = ROOT

	pre_triggers = {
		has_owner = yes
		is_ai = no
		is_capital = no
		is_homeworld = no
		has_ground_combat = no
	}

	trigger = {
		has_modifier = "obsidian_lakes"
		NOT = { has_modifier = "recent_eruption" }
	}

	is_triggered_only = yes

	option = {
		name = colony_mod.31.a
		add_modifier = {
			modifier = "recent_eruption"
			days = 360
		}

		custom_tooltip = eruption_report_tooltip

		hidden_effect = {
			random_list = {
				33 = { carrier_event = { id = colony_mod.32 days = 10 random = 5 } }
				33 = { carrier_event = { id = colony_mod.33 days = 10 random = 5 } }
				33 = { carrier_event = { id = colony_mod.34 days = 10 random = 5 } }
			}
		}
	}
}

carrier_event = {
	id = colony_mod.32
	title = "colony_mod.32.name"
	desc = "colony_mod.32.desc"
	picture = GFX_evt_molten
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	immediate = {
		add_planet_devastation = 12
	}

	option = {
		name = WORRYING

		tooltip = {
			add_planet_devastation = 12
		}

		add_blocker = {
			type = d_active_volcano
			blocked_deposit = random
		}
	}
}

carrier_event = {
	id = colony_mod.33
	title = "colony_mod.32.name"
	desc = "colony_mod.33.desc"
	picture = GFX_evt_molten
	show_sound = event_air_raid_siren
	location = ROOT

	is_triggered_only = yes

	option = {
		name = REMARKABLE
		OWNER = {
			add_resource = {
				rare_crystals = 100
			}
		}
	}
}

carrier_event = {
	id = colony_mod.34
	title = "colony_mod.32.name"
	desc = "colony_mod.34.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_default
	location = ROOT

	is_triggered_only = yes

	option = {
		name = GOOD
		# no effect
	}
}

## A Court of Blossoms
carrier_event = {
	id = colony.10000
	title = "colony.10000.name"
	desc = "colony.10000.desc"
	picture = GFX_evt_alien_wildlife
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	pre_triggers = {
		has_owner = yes
		is_homeworld = no
		original_owner = yes
		is_ai = no
		has_ground_combat = no
		is_capital = no
		is_occupied_flag = no
	}

	trigger = {
		owner = {
			is_individual_machine = no
			is_gestalt = no
			is_xenophobe = no
			is_homicidal = no
			NOT = { species_portrait = humanoid_hp_01 }
		}
		pop_amount > 0
		OR = {
			is_planet_class = pc_continental
			is_planet_class = pc_tropical
			is_planet_class = pc_savannah
		}
		OR = {
			has_any_capped_planet_farming_district = yes
		}
		NOR = {
			has_global_flag = court_of_blossoms
			has_carrier_flag = colony_event
		}
	}

	is_triggered_only = yes

	immediate = {
		owner = {
			set_global_flag = court_of_blossoms
		}
		set_carrier_flag = colony_event
	}
	option = { #investigating further
		name = colony.10000.a
		hidden_effect = {
			carrier_event = { id = colony.10005 days = 15 random = 10 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 100
				}
			}
		}
		owner = {
			add_resource = {
				energy = -100
			}
		}
	}
	option = { #ignore
		name = colony.10000.b
		hidden_effect = {
			carrier_event = { id = colony.10010 days = 35 random = 40 }
		}
	}
}

## A Dead Monster
carrier_event = {
	id = colony.10005
	title = "colony.10005.name"
	desc = "colony.10005.desc"
	picture = GFX_evt_astral_rift_tropical_habitat
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	immediate = {
		owner = {
			create_species = {
				name = NAME_anathari
				plural = NAME_anathari_plural
				class = HUM
				portrait = humanoid_hp_01
				traits = random
				homeworld = root
				effect = {
					save_global_event_target_as = species_tamperion
				}
			}
			create_leader = {
				class = commander
				species = event_target:species_tamperion
				name = NAME_Tamperion
			}
			last_created_leader = {
				exile_leader_as = tamperion
				save_event_target_as = tamperion
			}
		}
	}
	option = {
		name = colony.10005.a
		hidden_effect = {
			carrier_event = { id = colony.10015 days = 120 random = 40 }
		}
	}
}

## Continued Disappearances
carrier_event = {
	id = colony.10010
	title = "colony.10010.name"
	desc = "colony.10010.desc"
	picture = GFX_evt_liquid_darkness
	show_sound = event_alien_nature
	location = ROOT

	is_triggered_only = yes

	option = { #investigating further
		name = colony.10010.a
		hidden_effect = {
			carrier_event = { id = colony.10005 days = 35 random = 40 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 150
				}
			}
		}
		owner = {
			add_resource = {
				energy = -150
			}
		}
	}

	option = { #Getting either a good or bad final ending
		name = colony.10010.b
		hidden_effect = {
			random_list = { #60/40 chance for outcome, higher chance of bad ending because player chose to ignore
				60 = { carrier_event = { id = colony.10090 days = 90 random = 50 } } #Bad ending
				40 = { carrier_event = { id = colony.10095 days = 90 random = 50 } } #Good ending
			}
		}
	}
}

#Talking to King Tamperion first time
carrier_event = {
	id = colony.10015
	title = "colony.10015.name"
	desc = "colony.10015.desc"
	diplomatic = yes
	diplomatic_title = BLANK_STRING
	picture_event_data = {
		portrait = event_target:tamperion
		room = wilderness_room
		planet_background = root
	}

	is_triggered_only = yes

	option = {
		name = colony.10015.a.question
		is_dialog_only = yes
		response_text = colony.10015.a.answer
	}
	option = {
		name = colony.10015.b.question
		is_dialog_only = yes
		response_text = colony.10015.b.answer
	}
	option = {
		name = colony.10015.c.question
		is_dialog_only = yes
		response_text = colony.10015.c.answer
	}
	option = { #Sending colonist to learn
		name = colony.10015.a
		hidden_effect = {
			carrier_event = { id = colony.10016 }
		}
	}
	option = { #Do not send anyone
		name = colony.10015.b
		hidden_effect = {
			carrier_event = { id = colony.10017 }
		}
	}
}

#Tamperion approves
carrier_event = {
	id = colony.10016
	title = "colony.10016.name"
	desc = "colony.10016.desc"
	diplomatic = yes
	diplomatic_title = BLANK_STRING
	picture_event_data = {
		portrait = event_target:tamperion
		room = wilderness_room
		planet_background = root
	}

	is_triggered_only = yes

	option = {
		name = colony.10016.a
		hidden_effect = {
			carrier_event = { id = colony.10025 days = 150 random = 40 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

#Tamperion disapproves
carrier_event = {
	id = colony.10017
	title = "colony.10017.name"
	desc = "colony.10017.desc"
	diplomatic = yes
	diplomatic_title = BLANK_STRING
	picture_event_data = {
		portrait = event_target:tamperion
		room = wilderness_room
		planet_background = root
	}

	is_triggered_only = yes

	option = {
		name = colony.10017.a
		hidden_effect = {
			carrier_event = { id = colony.10020 days = 150 random = 40 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

## Tamperion attacks
carrier_event = {
	id = colony.10020
	title = "colony.10020.name"
	desc = "colony.10020.desc"
	picture = GFX_evt_aggressive_flora
	show_sound = event_super_explosion
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	immediate = {
		every_owned_pop_group = {
			kill_pop_group = {
				pop_group = this
				percentage = 0.10
			}
		}
	}

	option = {
		name = colony.10020.a
		custom_tooltip = tamperion_kills_pops_tt
		hidden_effect = {
			random_list = { #60/40 chance for outcome, slightly higher chance of bad ending because player breaks the law of Anathari
				60 = { carrier_event = { id = colony.10090 days = 90 random = 50 } } #Bad ending
				40 = { carrier_event = { id = colony.10095 days = 90 random = 50 } } #Good ending
			}
		}
	}
}

## Sending colonist
carrier_event = {
	id = colony.10025
	title = "colony.10025.name"
	desc = "colony.10025.desc"
	picture = GFX_evt_habitat
	show_sound = event_ship_thrusters
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10025.a
		hidden_effect = {
			carrier_event = { id = colony.10026 days = 15 random = 5 }
		}
	}
}

#Talking to King Tamperion second time
carrier_event = {
	id = colony.10026
	title = "colony.10026.name"
	desc = "colony.10026.desc"
	diplomatic = yes
	diplomatic_title = BLANK_STRING
	picture_event_data = {
		portrait = event_target:tamperion
		room = wilderness_room
		planet_background = root
	}

	is_triggered_only = yes

	option = {
		name = colony.10026.a.question
		is_dialog_only = yes
		response_text = colony.10026.a.answer
	}

	option = {
		name = colony.10026.b.question
		is_dialog_only = yes
		response_text = colony.10026.b.answer
	}

	option = {
		name = colony.10026.c.question
		is_dialog_only = yes
		response_text = colony.10026.c.answer
	}

	option = { #Issue special project
		name = colony.10026.a
		enable_special_project = {
			name = "A_CRYPTIC_ESSENCE_PROJECT"
			location = this
			owner = root
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}

	option = { #Distrust Tamperion
		name = colony.10026.b
		hidden_effect = {
			carrier_event = { id = colony.10027 }
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}
}

## A Seedling of Doubt
carrier_event = {
	id = colony.10027
	title = "colony.10027.name"
	desc = "colony.10027.desc"
	picture = GFX_evt_alien_planet
	show_sound = event_custodian_greeting
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = { #Issue special project with higher cost
		name = colony.10027.a
		enable_special_project = {
			name = "THE_CRYPTIC_ESSENCE_PROJECT"
			location = this
			owner = root
		}
	}
	option = {
		name = colony.10027.b
		hidden_effect = {
			carrier_event = { id = colony.10030 days = 5 random = 10 }
		}
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 250
				}
			}
		}
		owner = {
			add_resource = {
				energy = -250
			}
		}
	}
}

## Colonists attack Tamperion
carrier_event = {
	id = colony.10030
	title = "colony.10030.name"
	desc = "colony.10030.desc"
	picture = GFX_evt_big_landing_ship
	show_sound = event_super_explosion
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10030.a
		custom_tooltip = tamperion_kills_pops_tt
		hidden_effect = {
			every_owned_pop_group = {
				kill_pop_group = {
					pop_group = this
					percentage = 0.10
				}
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = food
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
		hidden_effect = {
			random_list = { #50/50 chance for outcome
				50 = { carrier_event = { id = colony.10090 days = 90 random = 50 } } #Bad ending
				50 = { carrier_event = { id = colony.10095 days = 90 random = 50 } } #Good ending
			}
		}
	}
}


## The Dark Immortal
carrier_event = {
	id = colony.10035
	title = "colony.10035.name"
	desc = "colony.10035.desc"
	picture = GFX_evt_conclave
	show_sound = relic_activation_the_galatron
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10035.a
		custom_tooltip = colony.10035.a.tt
		hidden_effect = {
			carrier_event = { id = colony.10040 days = 15 random = 20 }
		}
	}
	option = {
		name = colony.10035.b
		hidden_effect = {
			carrier_event = { id = colony.10086 days = 15 random = 20 }
		}
	}
}

## Trial of Bravery
carrier_event = {
	id = colony.10040
	title = "colony.10040.name"
	desc = "colony.10040.desc"
	picture = GFX_evt_hidden_door
	show_sound = relic_activation_scales_of_the_worm
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10040.a
		trigger = {
			owner = { is_militarist = no }
		}
		hidden_effect = {
			random_list = {
				70 = { carrier_event = { id = colony.10045 days = 1 random = 3 } } #Success
				30 = { carrier_event = { id = colony.10047 days = 1 random = 3 } } #Failure
			}
		}
	}
	option = {
		name = colony.10040.a.militarist
		trigger = {
			owner = { is_militarist = yes }
		}
		hidden_effect = {
			random_list = {
				95 = { carrier_event = { id = colony.10045 days = 1 random = 3 } } #Success
				5 = { carrier_event = { id = colony.10047 days = 1 random = 3 } } #Failure
			}
		}
	}
	option = {
		name = colony.10040.b
		hidden_effect = {
			random_list = {
				70 = { carrier_event = { id = colony.10046 days = 1 random = 3 } } #Success
				30 = { carrier_event = { id = colony.10047 days = 1 random = 3 } } #Failure
			}
		}
	}
}


## Succeeding the trial of bravery by trying to kill it
carrier_event = {
	id = colony.10045
	title = "colony.10045.name"
	desc = "colony.10045.desc"
	picture = GFX_evt_hidden_door
	show_sound = relic_activation_scales_of_the_worm
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10045.a
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = consumer_goods
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		custom_tooltip = colony.10045.a.tt
		hidden_effect = {
			carrier_event = { id = colony.10050 days = 10 random = 20 }
		}
	}
}

## Succeeding the trial of bravery by trying to trick
carrier_event = {
	id = colony.10046
	title = "colony.10046.name"
	desc = "colony.10046.desc"
	picture = GFX_evt_hidden_door
	show_sound = relic_activation_scales_of_the_worm
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10045.a
		owner = {
			add_monthly_resource_mult = {
				resource = alloys
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = consumer_goods
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		custom_tooltip = colony.10045.a.tt
		hidden_effect = {
			carrier_event = { id = colony.10050 days = 30 random = 20 }
		}
	}
}

## Failing the Trial of Bravery
carrier_event = {
	id = colony.10047
	title = "colony.10047.name"
	desc = "colony.10047.desc"
	picture = GFX_evt_hidden_door
	show_sound = event_screams
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10047.a
		hidden_effect = {
			carrier_event = { id = colony.10085 days = 10 random = 20 }
		}
	}
}

## The Trial of Wisdom
carrier_event = {
	id = colony.10050
	title = "colony.10050.name"
	desc = "colony.10050.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_sensor_ping
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = { #failure
		name = colony.10050.a
		hidden_effect = {
			carrier_event = { id = colony.10055 days = 10 random = 20 }
		}
	}
	option = { #success
		name = colony.10050.b
		hidden_effect = {
			carrier_event = { id = colony.10060 days = 10 random = 20 }
		}
	}
}

## Failing the Trial of Wisdom
carrier_event = {
	id = colony.10055
	title = "colony.10055.name"
	desc = "colony.10055.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_sensor_ping
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10047.a
		hidden_effect = {
			carrier_event = { id = colony.10085 days = 10 random = 20 }
		}
	}
}

## Succeeding the Trial of Wisdom
carrier_event = {
	id = colony.10060
	title = "colony.10060.name"
	desc = "colony.10060.desc"
	picture = GFX_evt_ancient_records
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10060.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		custom_tooltip = colony.10060.a.tt
		hidden_effect = {
			carrier_event = { id = colony.10065 days = 10 random = 20 }
		}
	}
}

## The Trial of Sacrifice
carrier_event = {
	id = colony.10065
	title = "colony.10065.name"
	desc = "colony.10065.desc"
	picture = GFX_evt_necrophage
	show_sound = relic_activation_blade_of_the_huntress
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = { #success
		name = colony.10065.a
		hidden_effect = {
			carrier_event = { id = colony.10070 days = 10 random = 20 }
		}
	}
	option = { #failure
		name = colony.10065.b
		hidden_effect = {
			carrier_event = { id = colony.10075 days = 10 random = 20 }
		}
	}
}

## Succeeding the Trial of Sacrifice
carrier_event = {
	id = colony.10070
	title = "colony.10070.name"
	desc = "colony.10070.desc"
	picture = GFX_evt_necrophage
	show_sound = relic_activation_blade_of_the_huntress
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10070.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
		hidden_effect = {
			carrier_event = { id = colony.10080 days = 5 random = 10 }
		}
	}
}

## Failing the Trial of Sacrifice
carrier_event = {
	id = colony.10075
	title = "colony.10075.name"
	desc = "colony.10075.desc"
	picture = GFX_evt_necrophage
	show_sound = event_structural_collapse
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10047.a
		hidden_effect = {
			carrier_event = { id = colony.10085 days = 5 random = 10 }
		}
	}
}

## Best ending, succeeding all trials
carrier_event = {
	id = colony.10080
	title = "colony.10080.name"
	desc = "colony.10080.desc"
	picture = GFX_evt_treasure_pile
	show_sound = relic_activation_miniature_galaxy
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10080.a
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier3unityreward
				min = @tier3unitymin
				max = @tier3unitymax
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = physics_research
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		hidden_effect = {
			carrier_event = { id = colony.10081 days = 90 random = 40 }
		}
	}

	option = {
		name = colony.10080.b
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
		hidden_effect = {
			carrier_event = { id = colony.10082 days = 90 random = 40 }
		}
	}
}

## A grandiose success
carrier_event = {
	id = colony.10081
	title = "colony.10081.name"
	desc = "colony.10081.desc"
	picture = GFX_evt_treasure_pile
	show_sound = relic_activation_miniature_galaxy
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10081.a
		add_modifier = {
			modifier = happy_anathari days = -1
		}
		create_pop_group = {
			species = event_target:species_tamperion
			size = 500
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier3unityreward
				min = @tier3unitymin
				max = @tier3unitymax
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}

## A Rain of Golden Petals
carrier_event = {
	id = colony.10082
	title = "colony.10082.name"
	desc = "colony.10082.desc"
	picture = GFX_evt_in_the_dark
	show_sound = relic_activation_miniature_galaxy
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10082.a
	}
}

## Failing at least one of the trials
carrier_event = {
	id = colony.10085
	title = "colony.10085.name"
	desc = "colony.10085.desc"
	picture = GFX_evt_colony_settlement
	show_sound = event_structural_collapse
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = { #attacking the dark immortal
		name = colony.10085.a
		allow = {
			owner = {
				resource_stockpile_compare = {
					resource = energy
					value >= 1000
				}
			}
		}
		hidden_effect = {
			carrier_event = { id = colony.10086 days = 90 random = 40 }
		}
		owner = {
			add_resource = {
				energy = -1000
			}
		}
	}
	option = { #becoming thralls
		name = colony.10085.b
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier4unityreward
				min = @tier4unitymin
				max = @tier4unitymax
			}
		}
		hidden_effect = {
			carrier_event = { id = colony.10087 days = 90 random = 40 }
		}
	}
	option = { #retreat back to colony
		name = colony.10085.c
		hidden_effect = {
			random_list = { #chances of getting a good ending is higher since the player has at least tried to help the Anathari
				30 = { carrier_event = { id = colony.10090 days = 90 random = 50 } } #Bad ending
				70 = { carrier_event = { id = colony.10095 days = 90 random = 50 } } #Good ending
			}
		}
	}
}

## War is the only answer
carrier_event = {
	id = colony.10086
	title = "colony.10086.name"
	desc = "colony.10086.desc"
	picture = GFX_evt_interior_battle
	show_sound = relic_activation_miniature_galaxy
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10086.a
		create_pop_group = {
			species = event_target:species_tamperion
			size = 500
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
	}
}

## The way of the thralls
carrier_event = {
	id = colony.10087
	title = "colony.10087.name"
	desc = "colony.10087.desc"
	picture = GFX_evt_necromancy
	show_sound = relic_activation_miniature_galaxy
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	option = {
		name = colony.10087.a
			add_planet_devastation = 50
			add_modifier = { modifier = dark_immortal_control days = -1 }
	}
}


## Bad final ending, 50% of population is being killed
carrier_event = {
	id = colony.10090
	title = "colony.10090.name"
	desc = "colony.10090.desc"
	picture = GFX_evt_burning_settlement
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	immediate = {
		add_planet_devastation = 50
		every_owned_pop_group = {
			kill_pop_group = {
				pop_group = this
				percentage = 0.50
			}
		}
	}


	option = {
		name = colony.10090.a
		custom_tooltip = dark_immortal_kills_pops_tt
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
	}
}

## Good final ending
carrier_event = {
	id = colony.10095
	title = "colony.10095.name"
	desc = "colony.10095.desc"
	picture = GFX_evt_scanning_remains
	show_sound = event_alien_nature
	location = ROOT
	trackable = yes

	is_triggered_only = yes

	immediate = {
		add_planet_devastation = 10
	}

	option = {
		name = colony.10095.a
		tooltip = {
			add_planet_devastation = 10
		}
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier2unityreward
				min = @tier2unitymin
				max = @tier2unitymax
			}
		}
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		add_modifier = { modifier = remnants_of_court_of_blossoms days = -1 }
	}
}
