#######################
# Events - BioGenesis #
#######################

namespace = bio

# Hidden Situation Trigger Event
country_event = {
	id = bio.1

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_biogenesis_dlc = yes
	}

	immediate = {
		if = {
			limit = {
				is_hive_empire = no
			}
			start_situation = {
				type = genetic_ascension_situation
				target = root
			}
		}
		else = {
			start_situation = {
				type = genetic_ascension_situation_hive
				target = root
			}
		}
	}
}

# Event Gatekeeper - Non-Hive Mind
# Fires a random event for the current situation approach
situation_event = {
	id = bio.2

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			has_situation_flag = bio_2_blocked
		}
		OR = {
			AND = {
				situation_progress >= @[ biomorphosis_start_value + ( biomorphosis_stage_1_end - biomorphosis_start_value ) * 1 / 3 ]
				situation_progress < @[ biomorphosis_start_value + ( biomorphosis_stage_1_end - biomorphosis_start_value ) * 1 / 2 ]
			}
			AND = {
				situation_progress >= @[ biomorphosis_stage_1_end + ( biomorphosis_stage_2_end - biomorphosis_stage_1_end ) * 1 / 3 ]
				situation_progress < @[ biomorphosis_stage_1_end + ( biomorphosis_stage_2_end - biomorphosis_stage_1_end ) * 1 / 2 ]
			}
			AND = {
				situation_progress >= @[ biomorphosis_stage_2_end + ( biomorphosis_end_value - biomorphosis_stage_2_end ) * 1 / 3 ]
				situation_progress < @[ biomorphosis_stage_2_end + ( biomorphosis_end_value - biomorphosis_stage_2_end ) * 1 / 2 ]
			}
		}
	}

	immediate = {
		set_situation_flag = bio_2_blocked
		remove_situation_flag = bio_3_blocked
		if = {
			limit = {
				owner = {
					is_hive_empire = yes
				}
			}
			switch = {
				trigger = current_situation_approach
				genetic_ascension_approach_purity = {
					fire_on_action = { on_action = on_genetic_ascension_hive_approach_purity_events_list }
				}
				genetic_ascension_approach_cloning = {
					fire_on_action = { on_action = on_genetic_ascension_hive_approach_cloning_events_list }
				}
				genetic_ascension_approach_mutation = {
					fire_on_action = { on_action = on_genetic_ascension_hive_approach_mutation_events_list }
				}
			}
		}
		else = {
			switch = {
				trigger = current_situation_approach
				genetic_ascension_approach_purity = {
					fire_on_action = { on_action = on_genetic_ascension_approach_purity_events_list }
				}
				genetic_ascension_approach_cloning = {
					fire_on_action = { on_action = on_genetic_ascension_approach_cloning_events_list }
				}
				genetic_ascension_approach_mutation = {
					fire_on_action = { on_action = on_genetic_ascension_approach_mutation_events_list }
				}
			}
		}
	}
}

# Fires a random event for the situation determined by the current and any previously selected approaches
situation_event = {
	id = bio.3

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_biogenesis_dlc = yes
		NOT = {
			has_situation_flag = bio_3_blocked
		}
		OR = {
			AND = {
				situation_progress >= @[ biomorphosis_start_value + ( biomorphosis_stage_1_end - biomorphosis_start_value ) * 2 / 3 ]
				situation_progress < @[ biomorphosis_start_value + ( biomorphosis_stage_1_end - biomorphosis_start_value ) * 5 / 6 ]
			}
			AND = {
				situation_progress >= @[ biomorphosis_stage_1_end + ( biomorphosis_stage_2_end - biomorphosis_stage_1_end ) * 2 / 3 ]
				situation_progress < @[ biomorphosis_stage_1_end + ( biomorphosis_stage_2_end - biomorphosis_stage_1_end ) * 5 / 6 ]
			}
			AND = {
				situation_progress >= @[ biomorphosis_stage_2_end + ( biomorphosis_end_value - biomorphosis_stage_2_end ) * 2 / 3 ]
				situation_progress < @[ biomorphosis_stage_2_end + ( biomorphosis_end_value - biomorphosis_stage_2_end ) * 5 / 6 ]
			}
		}
	}

	immediate = {
		set_situation_flag = bio_3_blocked
		remove_situation_flag = bio_2_blocked
		if = {
			limit = {
				owner = {
					is_hive_empire = yes
				}
			}
			fire_on_action = { on_action = on_genetic_ascension_hive_events_list }
		}
		else = {
			fire_on_action = { on_action = on_genetic_ascension_events_list }
		}
	}
}

# Regular Empire Genetic Ascension
# Situation Stage One Event

situation_event = {
	id = bio.5
	title = bio.5.name
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = yes } }
		text = bio.5.desc.no_options
	}
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = no } }
		text = bio.5.desc.has_options
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.5.a
		trigger = {
			NOR = {
				has_situation_flag = cloning_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_purity
		owner = {
			give_purity_unlocks_effect = yes
		}
	}
	option = {
		name = bio.5.b
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
			}
		}
		set_situation_approach = genetic_ascension_approach_cloning
		owner = {
			give_cloning_unlocks_effect = yes
		}
	}
	option = {
		name = bio.5.c
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = cloning_approach_selected
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_mutation
		owner = {
			give_mutation_unlocks_effect = yes
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
		custom_tooltip = genomic_facility_needed_tt
		hidden_effect = {
			owner = {
				if = {
					limit = {
						any_planet_within_border = {
							has_planet_flag = fotd_seperatist_planet@root
							owner = {
								has_country_flag = fotd_seperatist_country@root
							}
						}
					}
					country_event = { id = origin.6115 days = 5 random = 2 }
				}
			}
		}
	}
}

# Situation Stage Two Event

situation_event = {
	id = bio.10
	title = bio.10.name
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = yes } }
		text = bio.10.desc.no_options
	}
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = no } }
		text = bio.10.desc.has_options
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		remove_situation_flag = purity_approach_selected
		remove_situation_flag = cloning_approach_selected
		remove_situation_flag = mutation_approach_selected
		owner = {
			if = {
				limit = {
					NOT = {
						has_technology = tech_gene_tailoring
					}
				}
				add_tech_progress = {
					tech = tech_gene_tailoring
					progress = 0.33
				}
			}
		}
	}

	option = {
		name = bio.10.a
		trigger = {
			NOR = {
				has_situation_flag = cloning_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_purity
		owner = {
			give_purity_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.10.b
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
			}
		}
		set_situation_approach = genetic_ascension_approach_cloning
		owner = {
			give_cloning_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.10.c
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = cloning_approach_selected
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_mutation
		owner = {
			give_mutation_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
		owner = {
			if = {
				limit = {
					NOT = {
						has_technology = tech_gene_tailoring
					}
				}
				tooltip = {
					add_tech_progress = {
						tech = tech_gene_tailoring
						progress = 0.33
					}
				}
			}
		}
	}
}

# Situation Stage Three Event

situation_event = {
	id = bio.15
	title = bio.15.name
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = yes } }
		text = bio.15.desc.no_options
	}
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = no } }
		text = bio.15.desc.has_options
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		remove_situation_flag = purity_approach_selected
		remove_situation_flag = cloning_approach_selected
		remove_situation_flag = mutation_approach_selected
	}

	option = {
		name = bio.15.a
		trigger = {
			NOR = {
				has_situation_flag = cloning_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_purity
		owner = {
			give_purity_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.15.b
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
			}
		}
		set_situation_approach = genetic_ascension_approach_cloning
		owner = {
			give_cloning_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.15.c
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = cloning_approach_selected
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_mutation
		owner = {
			give_mutation_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

# Situation Completion Event

situation_event = {
	id = bio.20
	title = bio.20.name
	desc = {
		trigger = {
			owner = { NOT = { has_origin = origin_evolutionary_predators } }
		}
		text = bio.20.desc
	}
	desc = {
		trigger = {
			owner = { has_origin = origin_evolutionary_predators }
		}
		text = bio.20.desc.evopred
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.20.a
		trigger = {
			NOT = { owner = { has_origin = origin_evolutionary_predators } }
		}
		allow = {
			custom_tooltip = {
				fail_text = no_purity_unlock_tt
				owner = {
					has_country_flag = purity_unlock_level_1
				}
			}
		}
		if = {
			limit = {
				owner = { num_tradition_categories < @max_tradition_trees }
			}
			owner = {
				set_country_flag = purity_tradition_unlocked
				add_tradition = tr_purity_adopt # Purity Tree
			}
			custom_tooltip = purity_tradition_unlocked
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.20.b
		trigger = {
			NOT = { owner = { has_origin = origin_evolutionary_predators } }
		}
		allow = {
			custom_tooltip = {
				fail_text = no_cloning_unlock_tt
				owner = {
					has_country_flag = cloning_unlock_level_1
				}
			}
		}
		if = {
			limit = {
				owner = { num_tradition_categories < @max_tradition_trees }
			}
			owner = {
				set_country_flag = cloning_tradition_unlocked
				add_tradition = tr_cloning_adopt # Cloning Tree
			}
			custom_tooltip = cloning_tradition_unlocked
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.20.c
		allow = {
			custom_tooltip = {
				fail_text = no_mutation_unlock_tt
				owner = {
					has_country_flag = mutation_unlock_level_1
				}
			}
		}
		if = {
			limit = {
				owner = { num_tradition_categories < @max_tradition_trees }
			}
			owner = {
				set_country_flag = mutation_tradition_unlocked
				add_tradition = tr_mutation_adopt # Mutation Tree
			}
			custom_tooltip = mutation_tradition_unlocked
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		destroy_situation = this
		remove_situation_flag = situation_biogenesis_pause
	}
}

# Hive Genetic Ascension Situation
# Hive Situation Stage One Event

situation_event = {
	id = bio.25
	title = bio.25.name
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = yes } }
		text = bio.25.desc.no_options
	}
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = no } }
		text = bio.25.desc.has_options
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.25.a
		trigger = {
			NOR = {
				has_situation_flag = cloning_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_purity
		owner = {
			give_purity_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.25.b
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_origin = origin_wilderness }
			}
		}
		set_situation_approach = genetic_ascension_approach_cloning
		owner = {
			give_cloning_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.25.c
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = cloning_approach_selected
				owner = { has_country_flag = clone_army_full_potential }
				owner = { has_origin = origin_wilderness }
			}
		}
		set_situation_approach = genetic_ascension_approach_mutation
		owner = {
			give_mutation_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
		if = {
			limit = {
				owner = { is_wilderness_empire = no }
			}
			custom_tooltip = genomic_facility_needed_tt
		}
	}
}

# Hive Situation Stage Two Event

situation_event = {
	id = bio.30
	title = bio.30.name
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = yes } }
		text = bio.30.desc.no_options
	}
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = no } }
		text = bio.30.desc.has_options
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		remove_situation_flag = purity_approach_selected
		remove_situation_flag = cloning_approach_selected
		remove_situation_flag = mutation_approach_selected
		owner = {
			if = {
				limit = {
					NOT = {
						has_technology = tech_gene_tailoring
					}
				}
				add_tech_progress = {
					tech = tech_gene_tailoring
					progress = 0.33
				}
			}
		}
	}

	option = {
		name = bio.30.a
		trigger = {
			NOR = {
				has_situation_flag = cloning_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_purity
		owner = {
			give_purity_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.30.b
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_origin = origin_wilderness }
			}
		}
		set_situation_approach = genetic_ascension_approach_cloning
		owner = {
			give_cloning_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.30.c
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = cloning_approach_selected
				owner = { has_country_flag = clone_army_full_potential }
				owner = { has_origin = origin_wilderness }
			}
		}
		set_situation_approach = genetic_ascension_approach_mutation
		owner = {
			give_mutation_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
		owner = {
			if = {
				limit = {
					NOT = {
						has_technology = tech_gene_tailoring
					}
				}
				tooltip = {
					add_tech_progress = {
						tech = tech_gene_tailoring
						progress = 0.33
					}
				}
			}
		}
	}
}

# Hive Situation Stage 3 Event

situation_event = {
	id = bio.35
	title = bio.35.name
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = yes } }
		text = bio.35.desc.no_options
	}
	desc = {
		trigger = { owner = { has_one_genetic_ascension_choice = no } }
		text = bio.35.desc.has_options
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		remove_situation_flag = purity_approach_selected
		remove_situation_flag = cloning_approach_selected
		remove_situation_flag = mutation_approach_selected
	}

	option = {
		name = bio.35.a
		trigger = {
			NOR = {
				has_situation_flag = cloning_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_country_flag = clone_army_full_potential }
			}
		}
		set_situation_approach = genetic_ascension_approach_purity
		owner = {
			give_purity_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.35.b
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = mutation_approach_selected
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_origin = origin_wilderness }
			}
		}
		set_situation_approach = genetic_ascension_approach_cloning
		owner = {
			give_cloning_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.35.c
		trigger = {
			NOR = {
				has_situation_flag = purity_approach_selected
				has_situation_flag = cloning_approach_selected
				owner = { has_country_flag = clone_army_full_potential }
				owner = { has_origin = origin_wilderness }
			}
		}
		set_situation_approach = genetic_ascension_approach_mutation
		owner = {
			give_mutation_unlocks_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

# Hive Situation Completion Event

situation_event = {
	id = bio.40
	title = bio.40.name
	desc = {
		trigger = {
			owner = { NOT = { has_origin = origin_evolutionary_predators } }
		}
		text = bio.40.desc
	}
	desc = {
		trigger = {
			owner = { has_origin = origin_evolutionary_predators }
		}
		text = bio.40.desc.evopred
	}
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.40.a
		trigger = {
			NOT = { owner = { has_origin = origin_evolutionary_predators } }
		}
		allow = {
			custom_tooltip = {
				fail_text = no_purity_unlock_tt
				owner = {
					has_country_flag = purity_unlock_level_1
				}
			}
		}
		if = {
			limit = {
				owner = { num_tradition_categories < @max_tradition_trees }
			}
			owner = {
				set_country_flag = purity_tradition_unlocked
				add_tradition = tr_purity_adopt # Mutation Tree
			}
			custom_tooltip = purity_tradition_unlocked
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.40.b
		trigger = {
			NOR = {
				owner = { has_origin = origin_evolutionary_predators }
				owner = { has_origin = origin_wilderness }
			}
		}
		allow = {
			custom_tooltip = {
				fail_text = no_cloning_unlock_tt
				owner = {
					has_country_flag = cloning_unlock_level_1
				}
			}
		}
		if = {
			limit = {
				owner = { num_tradition_categories < @max_tradition_trees }
			}
			owner = {
				set_country_flag = cloning_tradition_unlocked
				add_tradition = tr_cloning_adopt # Cloning Tree
			}
			custom_tooltip = cloning_tradition_unlocked
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.40.c
		trigger = {
			NOT = { owner = { has_origin = origin_wilderness } }
		}
		allow = {
			custom_tooltip = {
				fail_text = no_mutation_unlock_tt
				owner = {
					has_country_flag = mutation_unlock_level_1
				}
			}
		}
		if = {
			limit = {
				owner = { num_tradition_categories < @max_tradition_trees }
			}
			owner = {
				set_country_flag = mutation_tradition_unlocked
				add_tradition = tr_mutation_adopt # Mutation Tree
			}
			custom_tooltip = mutation_tradition_unlocked
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		destroy_situation = this
		remove_situation_flag = situation_biogenesis_pause
	}
}

# Random Situation Events for Regular Empires

situation_event = {
	id = bio.50
	title = "bio.50.name"
	desc = "bio.50.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_50_fire }
		situation_progress >= 20
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_50_fire
	}

	option = {
		name = bio.50.a
		owner = {
			add_modifier = {
				modifier = supremacy_denied
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	option = {
		name = bio.50.b
		owner = {
			add_modifier = {
				modifier = augment_appreciation
				days = 1800
			}
			hidden_effect = {
				every_owned_species = {
					limit = {
						OR = {
							is_archetype = PRESAPIENT
							is_archetype = BIOLOGICAL
							is_archetype = LITHOID
						}
					}
					set_species_traits_purity_count_variable = yes
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner_species = {
					OR = {
						is_archetype = PRESAPIENT
						is_archetype = BIOLOGICAL
						is_archetype = LITHOID
					}
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.55
	title = "bio.55.name"
	desc = "bio.55.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_55_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_55_fire
	}

	option = {
		name = bio.55.a
		owner = {
			add_modifier = {
				modifier = superior_individuals
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	option = {
		name = bio.55.b
		owner = {
			add_modifier = {
				modifier = conscious_evolution
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.60
	title = "bio.60.name"
	desc = "bio.60.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_60_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_60_fire
	}

	option = {
		name = bio.60.a
		owner = {
			add_modifier = {
				modifier = welfare_state
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.60.b
		owner = {
			add_modifier = {
				modifier = selective_survival
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.65
	title = "bio.65.name"
	desc = "bio.65.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_65_fire }
		current_stage = stage_3
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_65_fire
	}

	option = {
		name = bio.65.a
		owner = {
			add_modifier = {
				modifier = maverick_citizens
				days = 1800
			}
		}
		hidden_effect = {
			situation_event = {
				id = bio.66
				days = 80
				random = 60
			}
			owner = {
				set_country_flag = maverick_citizens_flag
				country_event = {
					id = bio.68
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.65.b
		owner = {
			add_modifier = {
				modifier = super_powered
				days = 1800
			}
		}
		hidden_effect = {
			situation_event = {
				id = bio.67
				days = 80
				random = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.66
	title = "bio.66.name"
	desc = "bio.66.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.66.a
		owner = {
			add_modifier = {
				modifier = super_troopers
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_militarist = yes
				}
			}
		}
	}

	option = {
		name = bio.66.b
		owner = {
			add_modifier = {
				modifier = watch_the_watchers
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.67
	title = "bio.67.name"
	desc = "bio.67.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.67.a
		owner = {
			add_modifier = {
				modifier = hero_council
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.67.b
		owner = {
			add_modifier = {
				modifier = hero_restrictions
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

country_event = {
	id = bio.68
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		owner = {
			remove_country_flag = maverick_citizens_flag
		}
	}
}

situation_event = {
	id = bio.70
	title = "bio.70.name"
	desc = "bio.70.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		owner = {
			NOR = {
				has_origin = origin_legendary_leader
				has_origin = origin_clone_army
			}
		}
		NOT = {
			has_situation_flag = biogenesis_70_fire
		}
		situation_progress >= 20
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_70_fire
		owner = {
			random_owned_leader = {
				limit = {
					AND = {
						NOT = { has_leader_flag = renowned_leader }
						is_ruler = no
						species = {
							is_robotic = no
						}
					}
				}
				save_event_target_as = two_for_one_leader
			}
		}
	}

	option = {
		name = bio.70.a
		event_target:two_for_one_leader = {
			add_trait = {
				trait = leader_trait_has_backup_clone
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.70.b
		owner = {
			add_modifier = {
				modifier = deceitful_dismissal
				days = 1800
			}
			event_target:two_for_one_leader = {
				kill_leader = { show_notification = yes }
			}
			refresh_leader_pool = yes
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.75
	title = "bio.75.name"
	desc = "bio.75.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_origin = origin_clone_army }
		}
		NOT = {
			has_situation_flag = biogenesis_75_fire
		}
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_75_fire
	}

	option = {
		name = bio.75.a
		owner = {
			add_modifier = {
				modifier = harvesting_halt
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.75.b
		owner = {
			add_modifier = {
				modifier = clone_drivers
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.80
	title = "bio.80.name"
	desc = "bio.80.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_80_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_80_fire
	}

	option = {
		name = bio.80.a
		owner = {
			add_modifier = {
				modifier = effective_surveillance
				days = 1800
			}
			if = {
				limit = {
					NOT = { has_technology = tech_living_state }
				}
				give_tech_option_or_progress_effect = {
					TECH = tech_living_state
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier2researchreward
					min = @tier2researchmin
					max = @tier2researchmax
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	option = {
		name = bio.80.b
		owner = {
			add_modifier = {
				modifier = decriminalized_society
				days = 1800
			}
			if = {
				limit = {
					NOT = { has_technology = tech_artificial_moral_codes }
				}
				give_tech_option_or_progress_effect = {
					TECH = tech_artificial_moral_codes
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier2researchreward
					min = @tier2researchmin
					max = @tier2researchmax
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_materialist = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.85
	title = "bio.85.name"
	desc = "bio.85.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_85_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_85_fire
	}

	option = {
		name = bio.85.a
		owner = {
			add_modifier = {
				modifier = mass_euthanasia
				days = 1800
			}
		}
		hidden_effect = {
			situation_event = {
				id = bio.86
				days = 80
				random = 60
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.85.b
		custom_tooltip = bio.85.b.tt
		owner = {
			add_modifier = {
				modifier = duplicated_inheritance
				days = 1800
			}
			capital_scope = {
				create_army = {
					name = duplicated_inheritance_armies
					owner = root
					type = "clone_army"
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_militarist = yes
				}
			}
		}
	}

	option = {
		name = bio.85.c
		custom_tooltip = bio.85.c.tt
		owner = {
			capital_scope = {
				create_pop_group = {
					species = owner.owner_main_species
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.86
	title = "bio.86.name"
	desc = "bio.86.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.86.a
		owner = {
			add_modifier = {
				modifier = ethical_cloning
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_materialist = yes
				}
			}
		}
	}

	option = {
		name = bio.86.b
		custom_tooltip = bio.86.b.tt
		owner = {
			capital_scope = {
				while = {
					count = 3
					create_army = {
						name = random
						owner = ROOT
						species = owner_main_species
						type = "assault_army"
					}
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.90
	title = "bio.90.name"
	desc = "bio.90.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_90_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_90_fire
	}

	option = {
		name = bio.90.a
		owner = {
			capital_scope = {
				add_modifier = {
					modifier = mutant_crackdown
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_militarist = yes
				}
			}
		}
	}

	option = {
		name = bio.90.b
		owner = {
			add_modifier = {
				modifier = mutant_enclaves
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.95
	title = "bio.95.name"
	desc = "bio.95.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_95_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_95_fire
	}

	option = {
		name = bio.95.a
		owner = {
			add_modifier = {
				modifier = embracing_change
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
		add_situation_progress = 50
	}

	option = {
		name = bio.95.b
		owner = {
			add_modifier = {
				modifier = biological_limitations
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.100
	title = "bio.100.name"
	desc = "bio.100.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		# Only works for a planet with enough Pops
		owner = {
			any_owned_planet = {
				count_owned_pop_amount = {
					count >= 800
					limit = {
						is_sapient = yes
						is_robot_pop_group = no
					}
				}
			}
		}
		NOT = { has_situation_flag = biogenesis_100_fire }
		owner = {
			NOT = {
				has_origin = origin_evolutionary_predators
			}
		}
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_100_fire
	}

	option = {
		name = bio.100.a
		custom_tooltip = bio.100.a.tt
		owner = {
			add_modifier = {
				modifier = societal_diversification
				days = 1800
			}
			# Pick a planet with regular Pops
			random_owned_planet = {
				limit = {
					# Gatekeeper so we don't pick a planet with too few Pops
					count_owned_pop_amount = {
						count >= 800
						limit = {
							is_sapient = yes
							is_robot_pop_group = no
						}
					}
				}
				# Saving in case we need to reference the planet again
				save_event_target_as = encourage_diversity_planet
				# Pick a Pop Group
				weighted_random_owned_pop_group = {
					limit = {
						is_sapient = yes
						is_robot_pop_group = no
					}
					# Create a new species in this group
					create_species = {
						is_mod = yes
						name = this
						plural = this
						class = this
						portrait = this
						traits = this
						can_be_modified = this
						homeworld = this
						namelist = this
						gender = this
						# The species (currently empty) will get a random trait
						effect = {
							random_list = {
								1 = {
									modifier = {
										factor = 0
										has_trait = trait_bioadaptability
									}
									modify_species = {
										species = this
										change_scoped_species = no
										add_trait = trait_bioadaptability
										add_traits_at_start_of_list = yes
										effect = { save_event_target_as = target_species }
									}
								}
								1 = {
									modifier = {
										factor = 0
										has_trait = trait_social_pheromones
									}
									modify_species = {
										species = this
										change_scoped_species = no
										add_trait = trait_social_pheromones
										add_traits_at_start_of_list = yes
										effect = { save_event_target_as = target_species }
									}
								}
								1 = {
									modifier = {
										factor = 0
										has_trait = trait_limited_regeneration
									}
									modify_species = {
										species = this
										change_scoped_species = no
										add_trait = trait_limited_regeneration
										add_traits_at_start_of_list = yes
										effect = { save_event_target_as = target_species }
									}
								}
							}
						}
					}
					# Create a new species of mutants and save them
					save_event_target_as = source_pop_group
					prev = {
						create_pop_group = {
							pop_group = event_target:source_pop_group
							# Create a new Pop Group with the species we just created
							species = event_target:target_species
							size = 0
							# Transfer 400 Pops into our mutated species
							effect = {
								transfer_pop_amount = {
									source = event_target:source_pop_group
									target = this
									amount = 400
								}
								save_event_target_as = new_pop_group
							}
						}
					}
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.100.b
		owner = {
			add_modifier = {
				modifier = standardized_biology
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.105
	title = "bio.105.name"
	desc = "bio.105.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_105_fire }
		current_stage = stage_3
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_105_fire
	}

	option = {
		name = bio.105.a
		owner = {
			add_modifier = {
				modifier = blob_neutralized
				days = 1800
			}
			if = {
				limit = {
					owner = {
						is_lithoid_empire = no
					}
				}
				owner = {
					add_resource = {
						food = 500
					}
				}
			}
			else = {
				owner = {
					add_resource = {
						minerals = 500
					}
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_xenophobe = yes
				}
			}
		}
	}

	option = {
		name = bio.105.b
		owner = {
			add_modifier = {
				modifier = globule_research
				days = 1800
			}
			capital_scope = {
				weighted_random_owned_pop_group = {
					limit = {
						is_organic_species = yes
					}
					kill_single_pop = yes
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_materialist = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

# Random Situation Events for Hive Empires

situation_event = {
	id = bio.110
	title = "bio.110.name"
	desc = "bio.110.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_110_fire }
		situation_progress >= 20
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_110_fire
	}

	option = {
		name = bio.110.a
		owner = {
			add_modifier = {
				modifier = energetic_manipulation
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.110.b
		owner = {
			add_modifier = {
				modifier = defensive_focus
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_militarist = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.115
	title = "bio.115.name"
	desc = "bio.115.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_115_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = purity_approach_selected
		target = {
			is_wilderness_empire = no
		}
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_115_fire
	}

	option = {
		name = bio.115.a
		owner = {
			capital_scope = {
				create_pop_group = {
					species = owner.owner_main_species
				}
			}
		}
		if = {
			limit = {
				owner = {
					is_lithoid_empire = no
				}
			}
			owner = {
				add_resource = {
					energy = 100
					food = 1000
				}
			}
		}
		else = {
			owner = {
				add_resource = {
					energy = 100
					minerals = 1000
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 3
				owner = {
					is_materialist = yes
				}
			}
		}
	}

	option = {
		name = bio.115.b
		owner = {
			add_modifier = {
				modifier = grunt_retention
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.120
	title = "bio.120.name"
	desc = "bio.120.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_120_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_120_fire
	}

	option = {
		name = bio.120.a
		owner = {
			add_modifier = {
				modifier = assured_longevity
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.120.b
		owner = {
			if = {
				limit = {
					is_wilderness_empire = yes
				}
				add_modifier = {
					modifier = hyper_charged_wilderness
					days = 1800
				}
			}
			else = {
				add_modifier = {
					modifier = hyper_charged
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.125
	title = "bio.125.name"
	desc = "bio.125.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_125_fire }
		current_stage = stage_3
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_125_fire
	}

	option = {
		name = bio.125.a
		owner = {
			add_modifier = {
				modifier = vitality_conservation
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.125.b
		owner = {
			add_modifier = {
				modifier = accelerated_growth
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.130
	title = "bio.130.name"
	desc = "bio.130.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_130_fire }
		situation_progress >= 20
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_130_fire
	}

	option = {
		name = bio.130.a
		owner = {
			add_modifier = {
				modifier = interference_perseverance
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.130.b
		owner = {
			random_owned_leader = {
				limit = {
					is_councilor = yes
					leader_class = official
				}
				if = {
					limit = {
						NOT = {
							has_trait_tier1or2 = {
								TRAIT = trait_ruler_feedback_loop
							}
						}
					}
					add_trait = {
						trait = trait_ruler_feedback_loop
					}
				}
				else_if = {
					limit = {
						has_trait = trait_ruler_feedback_loop
					}
					add_trait = {
						trait = trait_ruler_feedback_loop_2
					}
				}
				else = {
					add_experience = 200
				}
			}
			while = {
				count = 3
				weighted_random_owned_pop_group = {
					limit = {
						is_organic_species = yes
					}
					kill_single_pop = yes
				}
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.135
	title = "bio.135.name"
	desc = "bio.135.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_135_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_135_fire
	}

	option = {
		name = bio.135.a
		owner = {
			add_modifier = {
				modifier = tandem_workers
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.135.b
		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_space_science_3 }
				}
				give_tech_option_or_progress_effect = {
					TECH = tech_space_science_3
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = physics_research
					value = @tier3researchreward
					min = @tier3researchmin
					max = @tier3researchmax
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.140
	title = "bio.140.name"
	desc = "bio.140.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_140_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_140_fire
	}

	option = {
		name = bio.140.a
		owner = {
			add_modifier = {
				modifier = mandated_integration
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	option = {
		name = bio.140.b
		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_autonomous_agents }
				}
				give_tech_option_or_progress_effect = {
					TECH = tech_autonomous_agents
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier2researchreward
					min = @tier2researchmin
					max = @tier2researchmax
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.145
	title = "bio.145.name"
	desc = "bio.145.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_145_fire }
		current_stage = stage_3
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_145_fire
	}

	option = {
		name = bio.145.a
		owner = {
			add_modifier = {
				modifier = methodic_procreation
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.145.b
		owner = {
			add_modifier = {
				modifier = genetic_diversification
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.150
	title = "bio.150.name"
	desc = "bio.150.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_150_fire }
		situation_progress >= 20
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_150_fire
	}

	option = {
		name = bio.150.a
		owner = {
			add_modifier = {
				modifier = hive_spa_day
				days = -1
			}
		}
		hidden_effect = {
			situation_event = {
				id = bio.151
				days = 360
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_egalitarian = yes
				}
			}
		}
	}

	option = {
		name = bio.150.b
		owner = {
			add_modifier = {
				modifier = cousin_of_death
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_authoritarian = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.151
	title = "bio.151.name"
	desc = "bio.151.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_celebration
	situation = this
	is_triggered_only = yes

	immediate = {
		set_situation_flag = situation_biogenesis_pause
	}

	option = {
		name = bio.151.a
		owner = {
			remove_modifier = hive_spa_day
			add_modifier = {
				modifier = positively_glowing
				days = 1440
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}


situation_event = {
	id = bio.155
	title = "bio.155.name"
	desc = "bio.155.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_155_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_155_fire
	}

	option = {
		name = bio.155.a
		owner = {
			add_modifier = {
				modifier = multi_functionality
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.155.b
		owner = {
			add_modifier = {
				modifier = optimized_workforce
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.160
	title = "bio.160.name"
	desc = "bio.160.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_160_fire }
		OR = {
			current_stage = stage_2
			current_stage = stage_3
		}
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_160_fire
	}

	option = {
		name = bio.160.a
		owner = {
			if = {
				limit = {
					NOT = { has_technology = tech_embodied_dynamism }
				}
				give_tech_option_or_progress_effect = {
					TECH = tech_embodied_dynamism
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier2researchreward
					min = @tier2researchmin
					max = @tier2researchmax
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.160.b
		owner = {
			if = {
				limit = {
					NOR = {
						has_technology = tech_node_culling_1
						has_technology = tech_node_culling_2
					}
				}
				give_tech_option_or_progress_effect = {
					TECH = tech_node_culling_1
				}
			}
			else_if = {
				limit = {
					has_technology = tech_node_culling_1
					NOT = {
						has_technology = tech_node_culling_2
					}
				}
				add_tech_option_or_research_effect = {
					TECH = tech_node_culling_2
					PROGRESS = 0.25
					CATEGORY = society_research
				}
			}
			else = {
				add_monthly_resource_mult = {
					resource = society_research
					value = @tier2researchreward
					min = @tier2researchmin
					max = @tier2researchmax
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.165
	title = "bio.165.name"
	desc = "bio.165.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_165_fire }
		current_stage = stage_3
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_165_fire
	}

	option = {
		name = bio.165.a
		owner = {
			add_modifier = {
				modifier = change_is_growth
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_materialist = yes
				}
			}
		}
	}

	option = {
		name = bio.165.b
		owner = {
			add_modifier = {
				modifier = maintain_the_essence
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				owner = {
					is_spiritualist = yes
				}
			}
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}


# ADVANCED GOVERNMENT EVENTS
# PURITY

country_event = {
	id = bio.170
	title = bio.170.name
	desc = bio.170.desc
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	is_triggered_only = yes

	option = {
		name = bio.170.a
		owner = {
			hidden_effect = {
				set_country_flag = bio_purity
				advanced_authority_refresh = yes
			}
		}
		custom_tooltip = bio.170.a.tt
		hidden_effect = {
			every_owned_species = {
				limit = {
					OR = {
						is_archetype = PRESAPIENT
						is_archetype = BIOLOGICAL
						is_archetype = LITHOID
					}
				}
				set_species_traits_purity_count_variable = yes
			}
			if = {
				limit = {
					is_imperial_authority = yes
				}
				every_owned_leader = {
					limit = {
						is_same_species = root.ruler
					}
					add_trait = {
						trait = trait_imperial_heir
						show_message = no
					}
				}
				every_pool_leader = {
					limit = {
						is_same_species = root.ruler
					}
					add_trait = {
						trait = trait_imperial_heir
						show_message = no
					}
				}
			}
			else_if = {
				limit = {
					is_hive_empire = no
					is_megacorp = no
				}
				every_owned_leader = {
					limit = {
						species = {
							is_robotic_species = no
						}
						NOT = { has_trait = trait_leader_genetic_purist }
					}
					give_trait_no_notify_ignore_autocracy_restriction = {
						TRAIT = trait_leader_genetic_purist
					}
				}
				every_pool_leader = {
					limit = {
						species = {
							is_robotic_species = no
						}
						NOT = { has_trait = trait_leader_genetic_purist }
					}
					give_trait_no_notify_ignore_autocracy_restriction = {
						TRAIT = trait_leader_genetic_purist
					}
				}
			}
		}
	}

	option = {
		name = bio.170.b
	}

	after = {
		hidden_effect = {
			if = {
				limit = {
					any_planet_within_border = {
						has_planet_flag = fotd_seperatist_planet@root
						owner = {
							has_country_flag = fotd_seperatist_country@root
						}
					}
				}
				country_event = { id = origin.6120 days = 5 random = 2 }
			}
		}
	}
}

# Executed just as country is changing its government, after the new one is applied
# THIS = country
country_event = {
	id = bio.171
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_purity_authority = yes
	}

	immediate = {
		if = {
			limit = {
				is_imperial_authority = yes
			}
			every_owned_leader = {
				limit = {
					species = {
						is_same_species = root.ruler
					}
					NOT = { has_trait = trait_imperial_heir }
				}
				give_trait_no_notify_ignore_autocracy_restriction = {
					TRAIT = trait_imperial_heir
				}
			}
		}
		else_if = {
			limit = {
				is_hive_empire = no
				is_megacorp = no
			}
			every_owned_leader = {
				limit = {
					species = {
						is_robotic_species = no
					}
					NOT = { has_trait = trait_leader_genetic_purist }
				}
				give_trait_no_notify_ignore_autocracy_restriction = {
					TRAIT = trait_leader_genetic_purist
				}
			}
		}
	}
}

# Executed just as country is changing its government, after the new one is applied
# THIS = country
country_event = {
	id = bio.172
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			is_purity_authority = no
			AND = {
				is_purity_authority = yes
				is_imperial_authority = yes
			}
		}
		any_owned_leader = {
			has_trait = trait_leader_genetic_purist
		}
	}

	immediate = {
		every_owned_leader = {
			limit = {
				species = {
					is_robotic_species = no
				}
				has_trait = trait_leader_genetic_purist
			}
			remove_trait = trait_leader_genetic_purist
		}
	}
}

# CLONING

country_event = {
	id = bio.175
	title = bio.175.name
	desc = bio.175.desc
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	is_triggered_only = yes

	option = {
		name = bio.175.a
		custom_tooltip = bio.175.a.tt
		if = {
			limit = {
				owner = {
					has_cloning_biochemical_composure_tradition = yes
				}
			}
			custom_tooltip = cloning_biochemical_composure_tradition_swap_tt
		}
		owner = {
			hidden_effect = {
				set_country_flag = bio_cloning
				advanced_authority_refresh = yes
				give_backup_clones_effect = yes
			}
		}
	}

	option = {
		name = bio.175.b
	}

	after = {
		hidden_effect = {
			if = {
				limit = {
					any_planet_within_border = {
						has_planet_flag = fotd_seperatist_planet@root
						owner = {
							has_country_flag = fotd_seperatist_country@root
						}
					}
				}
				country_event = { id = origin.6120 days = 5 random = 2 }
			}
		}
	}
}

# MUTATION

country_event = {
	id = bio.180
	title = bio.180.name
	desc = bio.180.desc
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_alien_nature
	is_triggered_only = yes

	option = {
		name = bio.180.a
		custom_tooltip = bio.180.a.tt
		owner = {
			hidden_effect = {
				set_country_flag = bio_mutation
				if = {
					limit = {
						has_origin = origin_evolutionary_predators
						is_democratic_authority = yes
					}
					country_event = { id = bio.1075 }
				}
				else_if = {
					limit = {
						has_origin = origin_evolutionary_predators
						is_dictatorial_authority = yes
					}
					ruler = {
						add_trait = {
							trait = trait_ruler_apex_predator
						}
					}
				}
				else_if = {
					limit = {
						has_origin = origin_evolutionary_predators
						is_oligarchic_authority= yes
					}
					every_owned_leader = {
						limit = {
							is_councilor = yes
							is_organic_species = yes
						}
						set_immortal = yes
						set_leader_flag = evopred_oligarch_immortal
					}
				}
				if = {
					limit = {
						has_origin = origin_evolutionary_predators
					}
					every_owned_species = {
						limit = {
							OR = {
								is_archetype = PRESAPIENT
								is_archetype = BIOLOGICAL
								is_archetype = LITHOID
							}
						}
						set_species_traits_evopred_count_variable = yes
					}
					if = {
						limit = {
							is_dictatorial_authority = yes
						}
						set_ruler_title_male = apex_predator_male
						set_ruler_title_female = apex_predator_female
					}
					if = {
						limit = {
							is_imperial_authority = yes
						}
						set_ruler_title_male = "eternal_ancestor_male"
						set_ruler_title_female = "eternal_ancestor_female"
					}
				}
				if = {
					limit = {
						has_mutation_environmental_integration_tradition = yes
					}
					custom_tooltip = empowered_environmental_integration_tradition_tt
				}
				advanced_authority_refresh = yes
			}
		}
	}

	option = {
		name = bio.180.b
	}

	after = {
		hidden_effect = {
			if = {
				limit = {
					any_planet_within_border = {
						has_planet_flag = fotd_seperatist_planet@root
						owner = {
							has_country_flag = fotd_seperatist_country@root
						}
					}
				}
				country_event = { id = origin.6120 days = 5 random = 2 }
			}
		}
	}
}

# PURITY (HIVE VERSION)

country_event = {
	id = bio.185
	title = bio.185.name
	desc = bio.185.desc
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	is_triggered_only = yes

	option = {
		name = bio.185.a
		custom_tooltip = bio.185.a.tt
		owner = {
			hidden_effect = {
				set_country_flag = bio_purity
				advanced_authority_refresh = yes
			}
		}
	}

	option = {
		name = bio.185.b
	}
}

# CLONING (HIVE VERSION)

country_event = {
	id = bio.190
	title = bio.190.name
	desc = bio.190.desc
	picture = GFX_evt_genetic_modification
	show_sound = event_alien_nature
	is_triggered_only = yes

	option = {
		name = bio.190.a
		custom_tooltip = bio.190.a.tt
		if = {
			limit = {
				owner = {
					has_cloning_biochemical_composure_tradition = yes
				}
			}
			custom_tooltip = cloning_biochemical_composure_tradition_swap_tt
		}
		owner = {
			hidden_effect = {
				set_country_flag = bio_cloning
				advanced_authority_refresh = yes
			}
		}
	}

	option = {
		name = bio.190.b
	}
}

# MUTATION (HIVE VERSION)

country_event = {
	id = bio.195
	title = bio.195.name
	desc = bio.195.desc
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_alien_nature
	is_triggered_only = yes

	option = {
		name = bio.195.a
		owner = {
			custom_tooltip = bio.195.a.tt
			hidden_effect = {
				set_country_flag = bio_mutation
				advanced_authority_refresh = yes
				if = {
					limit = {
						has_origin = origin_evolutionary_predators
					}
					country_event = { id = bio.1105 }
					every_owned_species = {
						limit = {
							OR = {
								is_archetype = PRESAPIENT
								is_archetype = BIOLOGICAL
								is_archetype = LITHOID
							}
						}
						set_species_traits_evopred_count_variable = yes
					}
				}
				if = {
					limit = {
						has_mutation_environmental_integration_tradition = yes
					}
					custom_tooltip = empowered_environmental_integration_tradition_tt
				}
			}
		}
	}

	option = {
		name = bio.195.b
	}
}

### ADDITIONAL RANDOM EVENTS
## NON-HIVE
# PURITY

situation_event = {
	id = bio.200
	title = "bio.200.name"
	desc = "bio.200.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_200_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_200_fire
	}

	option = {
		name = bio.200.a
		owner = {
			add_modifier = {
				modifier = artistic_integrity
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.200.b
		owner = {
			add_modifier = {
				modifier = logic_first
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.200.c
		owner = {
			add_modifier = {
				modifier = practical_application
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.210
	title = "bio.210.name"
	desc = "bio.210.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_210_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_210_fire
	}

	option = {
		name = bio.210.a
		owner = {
			add_modifier = {
				modifier = crack_downs
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
		add_situation_progress = 50
	}

	option = {
		name = bio.210.b
		owner = {
			add_modifier = {
				modifier = performative_reformation
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.215
	title = "bio.215.name"
	desc = "bio.215.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_215_fire }
		has_situation_flag = purity_approach_selected
		owner = {
			is_nomadic = no
			NOT = {
				has_origin = origin_lost_colony
			}
			any_owned_planet = {
				is_homeworld = yes
			}
		}
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_215_fire
	}

	option = {
		name = bio.215.a
		owner = {
			add_modifier = {
				modifier = ancestral_inheritance
				days = 1800
			}
			capital_scope = {
				add_deposit = d_underground_vault
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.215.b
		owner = {
			add_modifier = {
				modifier = buried_secrets
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.220
	title = "bio.220.name"
	desc = "bio.220.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_220_fire }
		has_situation_flag = purity_approach_selected
		owner = {
			any_owned_leader = {
				is_ruler = no
				is_heir = no
				leader_class = scientist
			}
		}
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_220_fire
		owner = {
			random_owned_leader = {
				limit = {
					is_ruler = no
					is_heir = no
					leader_class = scientist
				}
				save_event_target_as = rogue_geneticist
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.220.a
		custom_tooltip = bio.220.a.tt
		trigger = {
			owner = {
				is_authoritarian = no
			}
		}
		owner = {
			add_modifier = {
				modifier = specimen_study
				days = 1800
			}
			refresh_leader_pool = yes
		}
		hidden_effect = {
			event_target:rogue_geneticist = {
				kill_leader = { show_notification = no }
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.220.b
		trigger = {
			owner = {
				is_authoritarian = yes
			}
		}
		event_target:rogue_geneticist = {
			kill_leader = { show_notification = yes }
		}
		owner = {
			add_modifier = {
				modifier = specimen_study
				days = 1800
			}
			refresh_leader_pool = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.220.c
		event_target:rogue_geneticist = {
			add_expertise_trait_effect = {
				TRAIT = leader_trait_expertise_biology
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.225
	title = "bio.225.name"
	desc = "bio.225.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_225_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_225_fire
	}

	option = {
		name = bio.225.a
		owner = {
			add_modifier = {
				modifier = purity_tests
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.225.b
		owner = {
			random_owned_leader = {
				limit = {
					is_ruler = no
					is_heir = no
					leader_class = official
				}
				kill_leader = { show_notification = yes }
			}
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
			hidden_effect = {
				refresh_leader_pool = yes
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

### ADDITIONAL RANDOM EVENTS
## NON-HIVE
# CLONING

situation_event = {
	id = bio.230
	title = "bio.230.name"
	desc = "bio.230.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_origin = origin_clone_army }
		}
		NOT = {
			has_situation_flag = biogenesis_230_fire
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_230_fire
	}

	option = {
		name = bio.230.a
		owner = {
			add_modifier = {
				modifier = clone_rights
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.230.b
		owner = {
			add_modifier = {
				modifier = class_system
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.235
	title = "bio.235.name"
	desc = "bio.235.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_235_fire }
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_235_fire
	}

	option = {
		name = bio.235.a
		custom_tooltip = bio.235.a.tt
		hidden_effect = {
			set_timed_situation_flag = {
				flag = biomorphosis_stalled
				months = 12
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.235.b
		owner = {
			add_modifier = {
				modifier = swift_recovery
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.240
	title = "bio.240.name"
	desc = "bio.240.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_origin = origin_clone_army }
		}
		NOT = {
			has_situation_flag = biogenesis_240_fire
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_240_fire
	}

	option = {
		name = bio.240.a
		owner = {
			add_modifier = {
				modifier = well_adjusted
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.240.b
		custom_tooltip = bio.240.b.tt
		owner = {
			add_modifier = {
				modifier = strict_discipline
				days = 1800
			}
		}
		hidden_effect = {
			owner = {
				every_owned_leader = {
					limit = {
						is_same_species = prev.species
					}
					add_experience = 200
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.250
	title = "bio.250.name"
	desc = "bio.250.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		owner = {
			NOT = { has_origin = origin_clone_army }
			is_nomadic = no
		}
		NOT = {
			has_situation_flag = biogenesis_250_fire
		}
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_250_fire
	}

	option = {
		name = bio.250.a
		owner = {
			add_modifier = {
				modifier = infinite_growth
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.250.b
		owner = {
			add_modifier = {
				modifier = clone_colonies
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

### ADDITIONAL RANDOM EVENTS
## NON-HIVE
# MUTATION

situation_event = {
	id = bio.260
	title = "bio.260.name"
	desc = "bio.260.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_260_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_260_fire
	}

	option = {
		name = bio.260.a
		owner = {
			add_modifier = {
				modifier = mutant_studies
				days = 1800
			}
		}
		hidden_effect = {
			every_country = {
				limit = {
					is_spiritualist = yes
					NOT = { is_same_value = root.owner }
				}
				add_opinion_modifier = { who = root modifier = opinion_heretical_research }
			}
		}
		custom_tooltip = bio_260_opinion_tt
		ai_chance = {
			factor = 1
		}
		add_situation_progress = 50
	}

	option = {
		name = bio.260.b
		custom_tooltip = bio.260.b.tt
		owner = {
			weighted_random_owned_pop_group = {
				limit = {
					is_organic_species = yes
				}
				kill_single_pop = yes
			}
		}
		hidden_effect = {
			owner = {
				every_owned_leader = {
					limit = {
						is_authoritarian = yes
						NOT = {
							has_trait = leader_trait_eager
						}
					}
					add_trait = {
						trait = leader_trait_eager
					}
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.265
	title = "bio.265.name"
	desc = "bio.265.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_265_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_265_fire
	}

	option = {
		name = bio.265.a
		owner = {
			add_modifier = {
				modifier = aspirational_striving
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.265.b
		custom_tooltip = bio.265.b.tt
		owner = {
			add_modifier = {
				modifier = militaristic_fortitude
				days = 1800
			}
			capital_scope = {
				while = {
					count = 6
					create_army = {
						name = random
						owner = root
						type = "gene_warrior_army"
					}
				}
			}
		}
		hidden_effect = {
			every_country = {
				limit = { is_militarist = yes }
				add_opinion_modifier = { who = root modifier = opinion_militant_values }
			}
		}
		custom_tooltip = bio_265_opinion_tt
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.265.c
		owner = {
			add_modifier = {
				modifier = replicated_success
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
		add_situation_progress = 50
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.270
	title = "bio.270.name"
	desc = "bio.270.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_270_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_270_fire
	}

	option = {
		name = bio.270.a
		owner = {
			add_modifier = {
				modifier = sewer_sweep
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.270.b
		owner = {
			add_tech_option_or_research_effect = {
				TECH = tech_mine_exotic_gases
				PROGRESS = 0.25
				CATEGORY = society_research
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.280
	title = "bio.280.name"
	desc = "bio.280.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_280_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_280_fire
	}

	option = {
		name = bio.280.a
		owner = {
			add_tech_option_or_research_effect = {
				TECH = tech_neuroregeneration
				PROGRESS = 0.1
				CATEGORY = society_research
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.280.b
		owner = {
			add_modifier = {
				modifier = weaponized_plague
				days = 1800
			}
		}
		owner = {
			random_owned_leader = {
				limit = {
					is_head_of_research = yes
				}
				add_or_level_up_veteran_trait_effect = {
					TRAIT = leader_trait_maniacal
				}
				add_experience = 500
			}
			random_owned_leader = {
				limit = {
					leader_class = commander
					NOT = {
						has_trait = leader_trait_butcher
					}
				}
				add_trait = {
					trait = leader_trait_butcher
				}
			}
		}
		hidden_effect = {
			every_country = {
				limit = { is_materialist = yes }
				add_opinion_modifier = { who = root modifier = opinion_plague_spreaders }
			}
		}
		custom_tooltip = bio_280_opinion_tt
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

### ADDITIONAL RANDOM EVENTS
## NON-HIVE
# THESE CAN HAPPEN FOR ANY PATH

situation_event = {
	id = bio.295
	title = "bio.295.name"
	desc = "bio.295.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_295_fire }
		situation_progress >= 5
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_295_fire
	}

	option = {
		name = bio.295.a
		owner = {
			add_modifier = {
				modifier = biohacker_haven
				days = 1800
			}
		}
		hidden_effect = {
			every_country = {
				limit = { is_egalitarian = yes }
				add_opinion_modifier = { who = root modifier = opinion_bodily_autonomy  }
			}
		}
		custom_tooltip = bio_295_opinion_tt
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.295.b
		owner = {
			add_modifier = {
				modifier = limited_autonomy
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.300
	title = "bio.300.name"
	desc = "bio.300.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_300_fire }
		situation_progress >= 5
		owner = {
			any_owned_leader = {
				is_ruler = no
				is_heir = no
				leader_class = scientist
				NOR = {
					has_trait = leader_trait_spark_of_genius
					has_trait = leader_trait_spark_of_genius_2
				}
			}
		}
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_300_fire
		owner = {
			random_owned_leader = {
				limit = {
					is_ruler = no
					is_heir = no
					leader_class = scientist
					NOR = {
						has_trait = leader_trait_spark_of_genius
						has_trait = leader_trait_spark_of_genius_2
					}
				}
				save_event_target_as = genius_geneticist
			}
		}
	}

	option = {
		name = bio.300.a
		event_target:genius_geneticist = {
			add_trait = {
				trait = leader_trait_spark_of_genius
			}
			add_experience = 250
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.300.b
		trigger = {
			owner = {
				is_authoritarian = yes
			}
		}
		owner = {
			add_modifier = {
				modifier = proactive_management
				days = 1800
			}
			refresh_leader_pool = yes
		}
		event_target:genius_geneticist = {
			kill_leader = {
				show_notification = yes
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.300.c
		trigger = {
			owner = {
				is_authoritarian = no
			}
		}
		owner = {
			add_modifier = {
				modifier = proactive_management
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}


### ADDITIONAL RANDOM EVENTS
## HIVE
# PURITY

situation_event = {
	id = bio.310
	title = "bio.310.name"
	desc = "bio.310.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_310_fire }
		has_situation_flag = purity_approach_selected
		owner = {
			any_owned_pop_group = {
				is_same_species = prev.species
				pop_group_size > 100
			}
		}
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_310_fire
	}

	option = {
		name = bio.310.a
		owner = {
			while = {
				count = 1
				weighted_random_owned_pop_group = {
					limit = {
						is_same_species = prev.species
						pop_group_size > 100
					}
					kill_single_pop = yes
				}
			}
			add_modifier = {
				modifier = biological_corrections
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.310.b
		owner = {
			if = {
				limit = {
					is_wilderness_empire = yes
				}
				add_modifier = {
					modifier = cellular_degradation_wilderness
					days = 1800
				}
			}
			else = {
				add_modifier = {
					modifier = cellular_degradation
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.315
	title = "bio.315.name"
	desc = "bio.315.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_315_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_315_fire
	}

	option = {
		name = bio.315.a
		owner = {
			add_modifier = {
				modifier = resilient_hive
				days = -1
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.315.b
		owner = {
			add_modifier = {
				modifier = cognizant_hive
				days = -1
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.325
	title = "bio.325.name"
	desc = "bio.325.desc"
	desc = {
		text = "bio.325.desc.wilderness"
		exclusive_trigger = {
			target = {
				is_wilderness_empire = yes
			}
		}
	}
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_325_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_325_fire
	}

	option = {
		name = bio.325.a
		owner = {
			add_modifier = {
				modifier = pristine_lineage
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.325.b
		owner = {
			if = {
				limit ={

					is_wilderness_empire = yes
				}
				add_modifier = {
					modifier = breed_for_growth_wilderness
					days = 1800
				}
			}
			else = {
				add_modifier = {
					modifier = breed_for_growth
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.330
	title = "bio.330.name"
	desc = "bio.330.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_330_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_330_fire
	}

	option = {
		name = bio.330.a
		owner = {
			add_modifier = {
				modifier = relentless_focus
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.330.b
		owner = {
			add_modifier = {
				modifier = infrastructural_bolstering
				days = 1800
			}
			random_owned_leader = {
				limit = {
					is_councilor = yes
					leader_class = official
				}
				add_or_level_up_veteran_trait_effect = {
					TRAIT = trait_ruler_architectural_sense
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.335
	title = "bio.335.name"
	desc = "bio.335.desc"
	picture = GFX_evt_genetic_ascension_purity
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_335_fire }
		has_situation_flag = purity_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_335_fire
	}

	option = {
		name = bio.335.a
		owner = {
			if = {
				limit = {
					is_wilderness_empire = yes
				}
				add_modifier = {
					modifier = anomaly_purging_wilderness
					days = 1800
				}
			}
			else ={
				add_modifier = {
					modifier = anomaly_purging
					days = 1800
				}
			}
		}
		hidden_effect = {
			every_country = {
				limit = { values_others = yes }
				add_opinion_modifier = { who = root modifier = opinion_population_purging }
			}
		}
		custom_tooltip = bio_335_opinion_tt
		ai_chance = {
			factor = 1
		}
		add_situation_progress = 50
	}

	option = {
		name = bio.335.b
		owner = {
			if = {
				limit = {
					is_wilderness_empire = yes
				}
				add_modifier = {
					modifier = rigorous_examination_wilderness
					days = 1800
				}
			}
			else = {
				add_modifier = {
					modifier = rigorous_examination
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

### ADDITIONAL RANDOM EVENTS
## HIVE
# CLONING

situation_event = {
	id = bio.340
	title = "bio.340.name"
	desc = "bio.340.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_340_fire }
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_340_fire
	}

	option = {
		name = bio.340.a
		owner = {
			add_modifier = {
				modifier = population_relocation
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.340.b
		owner = {
			add_modifier = {
				modifier = factotum_reserves
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.350
	title = "bio.350.name"
	desc = "bio.350.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_350_fire }
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_350_fire
	}

	option = {
		name = bio.350.a
		custom_tooltip = bio.350.a.tt
		hidden_effect = {
			owner.capital_scope = {
				create_pop_group = {
					species = owner_main_species
					effect = {
						save_event_target_as = last_created_pop_group
					}
				}
				event_target:last_created_pop_group = {
					modify_species = {
						species = owner_main_species
						add_trait = trait_presapient_forcefully_devolved
						effect = {
							change_species_characteristics = {
								sapient = no
							}
						}
					}
				}
			}
		}
		owner = {
			add_modifier = {
				modifier = simple_minds
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.350.b
		owner = {
			add_modifier = {
				modifier = the_new_batch
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.365
	title = "bio.365.name"
	desc = "bio.365.desc"
	picture = GFX_evt_genetic_ascention_cloning
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_365_fire }
		has_situation_flag = cloning_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_365_fire
	}

	option = {
		name = bio.365.a
		owner = {
			add_modifier = {
				modifier = metaphysical_hive
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.365.b
		owner = {
			add_modifier = {
				modifier = metaphysics_rejected
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

### ADDITIONAL RANDOM EVENTS
## HIVE
# MUTATION

situation_event = {
	id = bio.375
	title = "bio.375.name"
	desc = "bio.375.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_375_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_375_fire
	}

	option = {
		name = bio.375.a
		owner = {
			add_modifier = {
				modifier = boosted_neurology
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.375.b
		owner = {
			add_modifier = {
				modifier = balanced_advancement
				days = 1800
			}
			random_owned_leader = {
				limit = {
					is_councilor = yes
					leader_class = official
				}
				if = {
					limit = {
						NOT = {
							has_trait = leader_trait_principled
						}
					}
					add_trait = {
						trait = leader_trait_principled
					}
				}
				else_if = {
					limit = {
						has_trait = leader_trait_principled
					}
					add_trait = {
						trait = leader_trait_principled_2
					}
				}
				else = {
					add_experience = 200
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.380
	title = "bio.380.name"
	desc = "bio.380.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_380_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_380_fire
	}

	option = {
		name = bio.380.a
		owner = {
			add_modifier = {
				modifier = decisive_meditation
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.380.b
		owner = {
			add_modifier = {
				modifier = fury_embracing
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.385
	title = "bio.385.name"
	desc = "bio.385.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_385_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_385_fire
	}

	option = {
		name = bio.385.a
		owner = {
			add_modifier = {
				modifier = meteorological_adaptations
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.385.b
		owner = {
			add_modifier = {
				modifier = uncomfortable_drones
				days = 1800
			}
			give_next_terraforming_tech_option_effect = yes
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.390
	title = "bio.390.name"
	desc = "bio.390.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_390_fire }
		has_situation_flag = mutation_approach_selected
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_390_fire
	}

	option = {
		name = bio.390.a
		owner = {
			add_modifier = {
				modifier = body_builders
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.390.b
		owner = {
			add_modifier = {
				modifier = deep_thinkers
				days = 1800
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

### ADDITIONAL RANDOM EVENTS
## HIVE
# THESE CAN HAPPEN FOR ANY PATH

situation_event = {
	id = bio.405
	title = "bio.405.name"
	desc = "bio.405.desc"
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_405_fire }
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_405_fire
	}

	option = {
		name = bio.405.a
		owner = {
			add_modifier = {
				modifier = decisive_termination
				days = 1800
			}
			weighted_random_owned_pop_group = {
				limit = { is_same_species = prev.species }
				kill_single_pop = yes
			}
		}
		hidden_effect = {
			every_country = {
				limit = { values_others = yes }
				add_opinion_modifier = { who = root modifier = opinion_population_purging }
			}
		}
		custom_tooltip = bio_335_opinion_tt
		ai_chance = {
			factor = 1
		}
	}

	option = {
		name = bio.405.b
		owner = {
			if = {
				limit = {
					is_wilderness_empire = yes
				}
				add_modifier = {
					modifier = survival_study_wilderness
					days = 1800
				}
			}
			else = {
				add_modifier = {
					modifier = survival_study
					days = 1800
				}
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

situation_event = {
	id = bio.410
	title = "bio.410.name"
	desc = "bio.410.desc"
	desc = {
		text = "bio.410.desc.wilderness"
		exclusive_trigger = {
			target = {
				is_wilderness_empire = yes
			}
		}
	}
	picture = GFX_evt_genetic_ascension_mutation
	show_sound = event_laboratory_sound
	situation = this
	is_triggered_only = yes

	trigger = {
		NOT = { has_situation_flag = biogenesis_410_fire }
	}

	immediate = {
		set_situation_flag = situation_biogenesis_pause
		set_situation_flag = biogenesis_410_fire
	}

	option = {
		name = bio.410.a
		owner = {
			add_modifier = {
				modifier = uncorrected_blunders
				days = 720
			}
		}
		ai_chance = {
			factor = 1
		}
		add_situation_progress = 50
	}

	option = {
		name = bio.410.b
		custom_tooltip = bio.410.b.tt
		hidden_effect = {
			set_timed_situation_flag = {
				flag = biomorphosis_stalled
				months = 12
			}
		}
		ai_chance = {
			factor = 1
		}
	}

	after = {
		remove_situation_flag = situation_biogenesis_pause
	}
}

# Familiar Face on leader assigned portrait swap
leader_event = {
	id = bio.500
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		exists = owner
		owner = {
			has_valid_civic = civic_hive_familiar_face
		}
		species = {
			has_trait = trait_hive_mind
		}
		OR = {
			leader_class = envoy
			leader_class = official
		}
		OR = {
			AND = {
				exists = envoy_location_country
				NOT = { has_envoy_task = { task = first_contact } }
			}
			is_assigned_to_federation = yes
			is_assigned_to_galcom = yes
		}
	}

	immediate = {
		if = {
			limit = {
				exists = envoy_location_country
				envoy_location_country.species = {
					NOR = {
						is_archetype = MACHINE
						is_archetype = ROBOT
					}
				}
			}
			change_leader_portrait = envoy_location_country.species
			set_leader_flag = familiar_face_changed
		}
		else_if = {
			limit = {
				is_assigned_to_federation = yes
				owner = {
					any_federation_ally = {
						species = {
							NOR = {
								is_archetype = MACHINE
								is_archetype = ROBOT
							}
						}
					}
				}
			}
			owner = {
				random_federation_ally = {
					limit = {
						species = {
							NOR = {
								is_archetype = MACHINE
								is_archetype = ROBOT
							}
						}
					}
					root = {
						change_leader_portrait = prev.species
						set_leader_flag = familiar_face_changed
					}
				}
			}
		}
		else_if = {
			limit = {
				any_galcom_member = {
					species = {
						NOR = {
							is_archetype = MACHINE
							is_archetype = ROBOT
						}
					}
				}
			}
			random_galcom_member = {
				limit = {
					species = {
						NOR = {
							is_archetype = MACHINE
							is_archetype = ROBOT
						}
					}
				}
				root = {
					change_leader_portrait = prev.species
					set_leader_flag = familiar_face_changed
				}
			}
		}
	}
}

# Familiar Face on leader unassigned portrait swap
leader_event = {
	id = bio.505
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		OR = {
			leader_class = envoy
			leader_class = official
		}
		has_leader_flag = familiar_face_changed
	}

	immediate = {
		remove_leader_flag = familiar_face_changed
		change_leader_portrait = species
	}
}

# Aeronautic Adaptation - Bioship fleet enters orbit of a non hostile planet
fleet_event = {
	id = bio.600
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		controller = {
			has_valid_civic = civic_hive_aerospace_adaptation
		}
		any_owned_ship = {
			is_ship_category = bio_ship
		}
		from.controller = {
			NOT = { is_hostile = root.controller }
		}
	}

	immediate = {
		every_owned_ship = {
			limit = {
				is_ship_category = bio_ship
				NOT = { has_modifier = aa_ship_upkeep_friendly }
			}
			add_modifier = {
				modifier = aa_ship_upkeep_friendly
				days = -1
			}
		}

		from = {
			recalculate_aeronautic_adaptation_planet_modifier = yes
		}
	}
}

fleet_event = {
	id = bio.605
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		controller = {
			has_valid_civic = civic_hive_aerospace_adaptation
		}
		any_owned_ship = {
			is_ship_category = bio_ship
		}
		controller = {
			NOT = { is_hostile = root.controller }
		}
	}

	immediate = {
		every_owned_ship = {
			limit = {
				is_ship_category = bio_ship
				has_modifier = aa_ship_upkeep_friendly
			}
			remove_modifier = aa_ship_upkeep_friendly
		}
		from = {
			recalculate_aeronautic_adaptation_planet_modifier = yes
		}
	}
}

# Aeronautic Adaptation - Bioship fleet enters orbit of a hostile planet
fleet_event = {
	id = bio.610
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		controller = {
			has_valid_civic = civic_hive_aerospace_adaptation
		}
		any_owned_ship = {
			is_ship_category = bio_ship
		}
		from.controller = {
			is_hostile = root.controller
		}
	}

	immediate = {
		every_owned_ship = {
			limit = {
				is_ship_category = bio_ship
				NOT = { has_modifier = aa_ship_upkeep_bombing }
			}
			add_modifier = {
				modifier = aa_ship_upkeep_bombing
				days = -1
			}
		}
	}
}

fleet_event = {
	id = bio.615
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		controller = {
			has_valid_civic = civic_hive_aerospace_adaptation
		}
		any_owned_ship = {
			is_ship_category = bio_ship
		}
		OR = {
			from.controller? = {
				is_hostile = root.controller
			}
			any_owned_ship = {
				has_modifier = aa_ship_upkeep_bombing
			}
		}
	}

	immediate = {
		every_owned_ship = {
			limit = {
				is_ship_category = bio_ship
				has_modifier = aa_ship_upkeep_bombing
			}
			remove_modifier = aa_ship_upkeep_bombing
		}
	}
}

# on_ship_enter_fleet/on_ship_leave_fleet
fleet_event = {
	id = bio.620
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		OR = {
			NOT = { exists = from }
			from = { is_ship_category = bio_ship }
		}
		exists = orbit.controller
		controller = { has_valid_civic = civic_hive_aerospace_adaptation }
		orbit = {
			is_scope_type = planet
			is_colony = yes
			controller = { NOT = { is_hostile = prevprev.controller } }
		}
	}

	immediate = {
		orbit = {
			recalculate_aeronautic_adaptation_planet_modifier = yes
		}
	}
}

country_event = { # Update Shared Genetics modifiers from on_yearly_country and on_modification_complete
	id = bio.700
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_valid_civic = civic_hive_shared_genetics
	}

	immediate = {
		add_modifier = {
			modifier = shared_genetics_fire_rate
			days = -1
			mult = value:count_negative_traits_from_country
		}
		add_modifier = {
			modifier = shared_genetics_hull
			days = -1
			mult = value:count_positive_traits_from_country
		}
	}
}

#An army has been killed in ground combat
# This = owner
# From = army
# FromFrom = opponent
# FromFromFrom = planet
country_event = {
	id = bio.750

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = from.species
		from = {
			species = {
				has_trait = trait_acidic_vascularity
			}
		}
	}

	immediate = {
		fromfromfrom = {
			if = { #Checking if the army was defending or attacking
				limit = {
					owner = { is_same_value = root }
				}
				random_ground_combat_attacker = {
					damage_army = 250
				}
			}
			else = {
				random_ground_combat_defender = {
					damage_army = 250
				}
			}
		}
	}
}

# A pop has finished growing
# This = Planet scope
# From = Country
# FromFrom = Pop
carrier_event = {
	id = bio.755
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		sapient_pop_amount > 100
		fromfrom = {
			is_sapient = yes
			has_trait = trait_nascent_stage
			check_variable = {
				which = local_pop_amount
				value > 0
			}
		}
	}

	immediate = {
		# Only the pops that just grew become Pre-Sapient. Demoting the whole group would
		# undo the maturation that returns them to the adult species.
		fromfrom = {
			save_event_target_as = nascent_grown_pop_group
			modify_species = {
				species = species
				add_trait = trait_presapient_stage
				inherit_parent_rights = yes
				sapient = no
				change_scoped_species = no
				effect = {
					save_event_target_as = nascent_presapient_species
				}
			}
		}
		create_pop_group = {
			pop_group = event_target:nascent_grown_pop_group
			species = event_target:nascent_presapient_species
			size = 0
			# Without a category the whole colony is re-bucketed, which empties the source
			# group before the transfer can read it.
			category = pre_sapients
			effect = {
				transfer_pop_amount = {
					source = event_target:nascent_grown_pop_group
					target = this
					amount = root.local_pop_amount
				}
			}
		}
	}
}

pop_group_event = {
	id = bio.751
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		from = {
			sapient_pop_amount < 1
			any_owned_pop_group = {
				has_trait = trait_nascent_stage
			}
		}
	}

	immediate = {
		from = {
			every_owned_pop_group = {
				resettle_pop_group = {
					POP_GROUP = this
					PLANET = root.planet
					PERCENTAGE = 1
				}
			}
		}
	}
}

# Executed just before on_leader_death if show_notification = yes (default)
# This = Country
# From = Leader
country_event = {
	id = bio.765
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		from = {
			species = { has_trait = trait_spare_organs }
			NOR = {
				has_trait = trait_leader_second_chanced
				leader_backup_clone_can_activate = yes
				leader_class = envoy
			}
			is_pool_leader = no
		}
	}

	immediate = {
		from = {
			set_leader_flag = leader_got_a_second_chance
		}
		clone_leader = {
			target = from
			effect = {
				give_trait_no_notify_ignore_autocracy_restriction = {
					TRAIT = trait_leader_second_chanced
				}
				remove_trait = leader_trait_backup_clone
				set_years_served = from
				restore_leader_location = yes		# TODO AUG-48742 Replace with code support
			}
		}
		from = {
			set_leader_flag = leader_death_events_blocked
		}
	}
}

#An army has been killed in ground combat
# This = owner
# From = army
# FromFrom = opponent
# FromFromFrom = planet
country_event = {
	id = bio.770

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = from.species
		from = {
			species = {
				has_trait = trait_spare_organs
			}
			NOR = {
				army_type = defense_army
				has_army_flag = had_second_chance
			}
		}
	}

	immediate = {
		random_list = {
			4 = { }
			1 = {
				fromfromfrom = {
					create_army = {
						owner = root
						type = assault_army
						species = root.from.species
					}
				}
				last_created_army = { set_army_flag = had_second_chance }
			}
		}
	}
}

# Prepare Invasion Operation

espionage_operation_event = {
	id = bio.800
	title = bio.800.name
	espionage_operation = yes
	desc = bio.800.desc
	picture = GFX_evt_spy_network
	show_sound = event_default
	is_triggered_only = yes

	option = { name = ACKNOWLEDGED }
}

# Target identified
espionage_operation_event = {
	id = bio.805
	title = bio.805.name
	desc = bio.805.desc
	espionage_operation = yes
	picture = GFX_evt_acquire_asset
	show_sound = event_default
	is_triggered_only = yes

	option = { name = GOOD }
}

# Result
espionage_operation_event = {
	id = bio.810
	title = bio.810.name
	desc = bio.810.desc
	espionage_operation = yes
	picture = GFX_evt_hive_mind
	show_sound = event_default
	is_triggered_only = yes

	option = {
		name = LAUNCH_OPERATION
		hidden_effect = {
			owner = {
				country_event = { id = bio.815 days = 1 }
			}
		}
	}

	after = {
		set_espionage_operation_progress_locked = no
	}
}
# Finalé | from = operation
country_event = {
	id = bio.815
	title = bio.815.name
	desc = bio.815.desc
	picture = GFX_evt_salute
	location = from.target.capital_scope
	show_sound = event_nem_asset_acquired_positive
	is_triggered_only = yes

	option = {
		name = bio.815.a
		custom_tooltip = bio.815.reminder
		hidden_effect = {
			from.target = {
				set_timed_country_flag = { flag = infiltrated_bodysnatcher_0@root years = 10 }
			}
		}
	}

	option = {
		allow = {
			custom_tooltip = {
				fail_text = bio.815.tt
				check_variable_arithmetic = {
					which = value:available_pops_for_bodysnatcher
					value >= 100
				}
			}
		}
		name = bio.815.b
		custom_tooltip = bio.815.b.tt
		hidden_effect = {
			weighted_random_owned_pop_group = {
				limit = {
					pop_group_size >= 100
					from.target = {
						any_owned_species = {
							is_same_species = prevprev
							is_organic_species = yes
						}
					}
				}
				kill_single_pop = yes
			}
			from.target = {
				set_timed_country_flag = { flag = infiltrated_bodysnatcher_1@root years = 10 }
			}
		}
	}

	option = {
		allow = {
			custom_tooltip = {
				fail_text = bio.815.tt
				check_variable_arithmetic = {
					which = value:available_pops_for_bodysnatcher
					value >= 300
				}
			}
		}
		name = bio.815.c
		custom_tooltip = bio.815.c.tt
		hidden_effect = {
			while = {
				count = 3
				weighted_random_owned_pop_group = {
					limit = {
						pop_group_size >= 100
						from.target = {
							any_owned_species = {
								is_same_species = prevprev
								is_organic_species = yes
							}
						}
					}
					kill_single_pop = yes
				}
			}
			from.target = {
				set_timed_country_flag = { flag = infiltrated_bodysnatcher_3@root years = 10 }
			}
		}
	}

	option = {
		allow = {
			custom_tooltip = {
				fail_text = bio.815.tt
				check_variable_arithmetic = {
					which = value:available_pops_for_bodysnatcher
					value >= 500
				}
			}
		}
		name = bio.815.d
		custom_tooltip = bio.815.d.tt
		hidden_effect = {
			while = {
				count = 5
				weighted_random_owned_pop_group = {
					limit = {
						pop_group_size >= 100
						from.target = {
							any_owned_species = {
								is_same_species = prevprev
								is_organic_species = yes
							}
						}
					}
					kill_single_pop = yes
				}
			}
			from.target = {
				set_timed_country_flag = { flag = infiltrated_bodysnatcher_5@root years = 10 }
			}
		}
	}

	option = {
		allow = {
			custom_tooltip = {
				fail_text = bio.815.tt
				check_variable_arithmetic = {
					which = value:available_pops_for_bodysnatcher
					value >= 2000
				}
			}
		}
		name = bio.815.e
		custom_tooltip = bio.815.e.tt
		hidden_effect = {
			while = {
				count = 20
				weighted_random_owned_pop_group = {
					limit = {
						pop_group_size >= 100
						from.target = {
							any_owned_species = {
								is_same_species = prevprev
								is_organic_species = yes
							}
						}
					}
					kill_single_pop = yes
				}
			}
			from.target = {
				set_timed_country_flag = { flag = infiltrated_bodysnatcher_20@root years = 10 }
			}
		}
	}

	after = {
		hidden_effect = {
			owner = {
				if = {
					limit = {
						NOT = { has_country_flag = operation_complete_bodysnatcher_prepare_invasion }
					}
					change_variable = {
						which = tinker_tailor_soldier_blorg_achievement_count
						value = 1
					}
					set_country_flag = operation_complete_bodysnatcher_prepare_invasion
				}
			}
		}
		from.spynetwork = {
			add_spy_network_level_on_success_effect = { VALUE = -80 }
		}
		destroy_espionage_operation = from
	}
}

# A war is beginning, executed for every country in the war.
# Root = Country
# From = War
country_event = {
	id = bio.819
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			AND = {
				has_valid_civic = civic_hive_bodysnatcher
				from = {
					attacker = { # We only want this effect to happen if you are the primary attacker and the target is the primary defender
						is_same_value = root
					}
					defender = {
						OR = {
							has_country_flag = infiltrated_bodysnatcher_0@root
							has_country_flag = infiltrated_bodysnatcher_1@root
							has_country_flag = infiltrated_bodysnatcher_3@root
							has_country_flag = infiltrated_bodysnatcher_5@root
							has_country_flag = infiltrated_bodysnatcher_20@root
						}
					}
				}
			}
			AND = {
				from.attacker = { # We only want this effect to happen if you are the primary attacker and the target is the primary defender
					is_same_value = root
				}
				OR = {
					has_country_flag = infiltrated_bodysnatcher_0@from.defender
					has_country_flag = infiltrated_bodysnatcher_1@from.defender
					has_country_flag = infiltrated_bodysnatcher_3@from.defender
					has_country_flag = infiltrated_bodysnatcher_5@from.defender
					has_country_flag = infiltrated_bodysnatcher_20@from.defender
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				has_valid_civic = civic_hive_bodysnatcher
				from = {
					attacker = { # We only want this effect to happen if you are the primary attacker and the target is the primary defender
						is_same_value = root
					}
					defender = {
						OR = {
							has_country_flag = infiltrated_bodysnatcher_0@root
							has_country_flag = infiltrated_bodysnatcher_1@root
							has_country_flag = infiltrated_bodysnatcher_3@root
							has_country_flag = infiltrated_bodysnatcher_5@root
							has_country_flag = infiltrated_bodysnatcher_20@root
						}
					}
				}
			}
			save_event_target_as = snatcher_country
			from.defender = { save_event_target_as = snatched_country }
		}
		else = {
			save_event_target_as = snatched_country
			from.defender = { save_event_target_as = snatcher_country }
		}
		event_target:snatcher_country = { country_event = { id = bio.820 } }
	}
}

country_event = {
	id = bio.820
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				any_neighbor_country = {
					is_same_value = event_target:snatched_country
				}
			}
			event_target:snatched_country = {
				random_system_within_border = {
					limit = {
						any_country_neighbor_to_system = {
							is_same_value = root
						}
					}
					save_event_target_as = closest_system
				}
			}
		}
		else = {
			event_target:snatched_country = {
				random_system_within_border = {
					weights = {
						base = 1
						modifier = {
							add = 100
							distance_to_empire = {
								who = root
								distance = 2
								use_bypasses = yes
								type = hyperlane
							}
						}
						modifier = {
							add = 20
							distance_to_empire = {
								who = root
								distance = 3
								use_bypasses = yes
								type = hyperlane
							}
						}
						modifier = {
							add = 10
							distance_to_empire = {
								who = root
								distance = 4
								use_bypasses = yes
								type = hyperlane
							}
						}
						modifier = {
							add = 5
							distance_to_empire = {
								who = root
								distance = 5
								use_bypasses = yes
								type = hyperlane
							}
						}
						modifier = {
							add = 1
							distance_to_empire = {
								who = root
								distance = 10
								use_bypasses = yes
								type = hyperlane
							}
						}
					}
					save_event_target_as = closest_system
				}
			}
		}
		event_target:snatched_country = {
			switch = {
				trigger = has_country_flag
				infiltrated_bodysnatcher_0@root = {
					while = {
						count = value:five_percent_systems
						set_bodysnatcher_flags = yes
					}
				}
				infiltrated_bodysnatcher_1@root = {
					while = {
						count = value:ten_percent_systems
						set_bodysnatcher_flags = yes
					}
				}
				infiltrated_bodysnatcher_3@root = {
					while = {
						count = value:fifteen_percent_systems
						set_bodysnatcher_flags = yes
					}
				}
				infiltrated_bodysnatcher_5@root = {
					while = {
						count = value:twentyfive_percent_systems
						set_bodysnatcher_flags = yes
					}
				}
				infiltrated_bodysnatcher_20@root = {
					while = {
						count = value:fifty_percent_systems
						set_bodysnatcher_flags = yes
					}
				}
			}
			every_system_within_border = {
				limit = {
					has_star_flag = bodysnatched_by@root
				}
				starbase.fleet = {
					set_controller = root
				}
				every_system_planet_colony = {
					while = {
						count = 5
						create_army = {
							name = "NAME_Bodysnatchers"
							owner = root
							species = event_target:snatched_country
							type = "assault_army"
						}
					}
				}
			}
			country_event = { id = bio.825 days = 2 }
		}
	}
}

country_event = {
	id = bio.825
	title = "bio.825.name"
	desc = {
		trigger = {
			OR = {
				has_country_flag = infiltrated_bodysnatcher_0@from
				has_country_flag = infiltrated_bodysnatcher_1@from
				has_country_flag = infiltrated_bodysnatcher_3@from
				has_country_flag = infiltrated_bodysnatcher_5@from
			}
		}
		text = bio.825.desc.small
	}
	desc = {
		trigger = {
			has_country_flag = infiltrated_bodysnatcher_20@from
		}
		text = bio.825.desc.large
	}
	picture = GFX_evt_vivisection
	show_sound = event_red_alert
	is_triggered_only = yes

	option = {
		name = BATTLESTATIONS
	}

	after = {
		remove_country_flag = infiltrated_bodysnatcher_0@from
		remove_country_flag = infiltrated_bodysnatcher_1@from
		remove_country_flag = infiltrated_bodysnatcher_3@from
		remove_country_flag = infiltrated_bodysnatcher_5@from
		remove_country_flag = infiltrated_bodysnatcher_20@from
	}
}

# 900 - Smuggle Pops operation
espionage_operation_event = {
	id = bio.900
	title = bio.900.name
	espionage_operation = yes
	desc = bio.900.desc
	picture = GFX_evt_spy_network
	show_sound = event_default
	is_triggered_only = yes

	option = { name = ACKNOWLEDGED }
}

espionage_operation_event = {
	id = bio.905
	title = bio.905.name
	espionage_operation = yes
	desc = bio.905.desc
	picture = GFX_evt_conclave
	show_sound = event_default
	is_triggered_only = yes

	option = { name = EXCELLENT }
}

espionage_operation_event = {
	id = bio.910
	title = bio.910.name
	espionage_operation = yes
	desc = bio.910.desc
	picture = GFX_evt_conclave
	show_sound = event_default
	is_triggered_only = yes

	option = {
		name = LAUNCH_OPERATION
		hidden_effect = {
			owner = {
				country_event = { id = bio.915 days = 1 }
			}
		}
	}

	after = {
		set_espionage_operation_progress_locked = no
	}
}

#915 - Smuggle pop outcome
#from = operation
country_event = {
	id = bio.915
	title = bio.915.name
	desc = {
		trigger = {
			check_variable = {
				which = smuggle_pops_amount
				value <= 4
			}
			NOT = {
				any_owned_planet = {
					is_planet_class = pc_cosmogenesis_world
				}
			}
		}
		text = bio.915.desc
	}
	desc = {
		trigger = {
			check_variable = {
				which = smuggle_pops_amount
				value > 4
			}
			NOT = {
				any_owned_planet = {
					is_planet_class = pc_cosmogenesis_world
				}
			}
		}
		text = bio.915.desc.detected
	}
	desc = {
		trigger = {
			check_variable = {
				which = smuggle_pops_amount
				value <= 4
			}
			any_owned_planet = {
				is_planet_class = pc_cosmogenesis_world
			}
		}
		text = bio.915.desc.cosmogenesis
	}
	desc = {
		trigger = {
			check_variable = {
				which = smuggle_pops_amount
				value > 4
			}
			any_owned_planet = {
				is_planet_class = pc_cosmogenesis_world
			}
		}
		text = bio.915.desc.cosmogenesis.detected
	}
	picture = {
		trigger = {
			NOT = {
				any_owned_planet = {
					is_planet_class = pc_cosmogenesis_world
				}
			}
		}
		picture = GFX_evt_salute
	}
	picture = {
		trigger = {
			any_owned_planet = {
				is_planet_class = pc_cosmogenesis_world
			}
		}
		picture = GFX_evt_synaptic_lathe
	}
	location = from.target.capital_scope
	show_sound = event_nem_asset_acquired_positive
	is_triggered_only = yes

	immediate = {
		set_variable_to_random_value = {
			which = smuggle_pops_amount
			min = 1
			max = 2
		}
		from.target = {
			if = {
				limit = {
					empire_size >= 100
					empire_size <= 499
				}
				root = {
					change_variable = {
						which = smuggle_pops_amount
						value = 1
					}
				}
			}
			else_if = {
				limit = {
					empire_size >= 500
					empire_size <= 999
				}
				root = {
					change_variable = {
						which = smuggle_pops_amount
						value = 2
					}
				}
			}
			else_if = {
				limit = {
					empire_size >= 1000
				}
				root = {
					change_variable = {
						which = smuggle_pops_amount
						value = 3
					}
				}
			}
		}
		if = {
			limit = {
				has_valid_civic = civic_hive_bodysnatcher
			}
			change_variable = {
				which = smuggle_pops_amount
				value = 2
			}
		}
	}

	option = { #regular
		name = bio.915.a
		custom_tooltip = bio.915.tt
		hidden_effect = {
			while = {
				count = smuggle_pops_amount
				from.target = {
					random_owned_pop_group = {
						limit = {
							can_be_smuggled = yes
						}
						weights = {
							base = 5
							modifier = {
								is_enslaved = yes
								factor = 5
							}
							modifier = {
								happiness <= 0.3
								factor = 5
							}
							modifier = {
								is_unemployed = yes
								factor = 2
							}
							modifier = { #Get them out of there!
								is_being_purged = yes
								factor = 100
							}
							modifier = {
								is_elite_category = yes
								factor = 0.1
							}
						}
						root = {
							random_owned_planet = {
								weights = {
									base = 1
									modifier = {
										add = 5
										habitability = { who = prevprev value > 0.8 }
									}
									modifier = {
										add = 3
										habitability = { who = prevprev value > 0.5 }
									}
									modifier = {
										add = 5
										free_housing >= 10000
									}
									modifier = {
										factor = 0.1
										habitability = { who = prevprev value < 0.3 }
									}
									modifier = {
										factor = 0.1
										free_housing < 1000
									}
									modifier = {
										add = 1000
										is_planet_class = pc_cosmogenesis_world
									}
								}
								save_event_target_as = target_planet
							}
						}
						resettle_pop_group = {
							POP_GROUP = this
							PLANET = event_target:target_planet
							AMOUNT = 100
						}
						if = {
							limit = {
								species = {
									is_same_species = root
								}
								OR = {
									is_enslaved = yes
									is_being_purged = yes
								}
							}
							root = {
								set_country_flag = smugglers_of_hope_achievement
							}
						}
					}
				}
			}
		}
	}

	option = { #Regular own pops
		name = bio.915.b
		custom_tooltip = bio.915.tt
		trigger = {
			from.target = {
				count_owned_pop_amount = {
					limit = {
						is_same_species = root
					}
					count > 100
				}
			}
		}
		hidden_effect = {
			while = {
				count = smuggle_pops_amount
				from.target = {
					random_owned_pop_group = {
						limit = {
							is_same_species = root
							can_be_smuggled = yes
						}
						weights = {
							base = 5
							modifier = {
								is_enslaved = yes
								factor = 5
							}
							modifier = {
								happiness <= 0.3
								factor = 5
							}
							modifier = {
								is_unemployed = yes
								factor = 2
							}
							modifier = { #Get them out of there!
								is_being_purged = yes
								factor = 100
							}
							modifier = { #Get our people out of there
								is_same_species = root.species
								factor = 1000
							}
							modifier = {
								is_elite_category = yes
								factor = 0.1
							}
						}
						root = {
							random_owned_planet = {
								weights = {
									base = 1
									modifier = {
										add = 5
										habitability = { who = prevprev value > 0.8 }
									}
									modifier = {
										add = 3
										habitability = { who = prevprev value > 0.5 }
									}
									modifier = {
										add = 5
										free_housing >= 10000
									}
									modifier = {
										factor = 0.1
										habitability = { who = prevprev value < 0.3 }
									}
									modifier = {
										factor = 0.1
										free_housing < 1000
									}
									modifier = {
										add = 1000
										is_planet_class = pc_cosmogenesis_world
									}
								}
								save_event_target_as = target_planet
							}
						}
						resettle_pop_group = {
							POP_GROUP = this
							PLANET = event_target:target_planet
							AMOUNT = 100
						}
						if = {
							limit = {
								OR = {
									is_enslaved = yes
									is_being_purged = yes
								}
							}
							root = {
								set_country_flag = smugglers_of_hope_achievement
							}
						}
					}
				}
			}
		}
	}

	option = { #Burn Asset for more
		name = bio.915.c
		custom_tooltip = bio.915.asset.tt
		icon = {
			icon = GFX_espionage_asset_icon
			text = ESPIONAGE_OPERATION_ASSET_EVENT_OPTION
		}
		trigger = {
			from = { has_espionage_asset_government = yes }
		}

		hidden_effect = {
			multiply_variable = {
				which = smuggle_pops_amount
				value = 2
			}
			while = {
				count = smuggle_pops_amount
				from.target = {
					random_owned_pop_group = {
						limit = {
							can_be_smuggled = yes
						}
						weights = {
							base = 5
							modifier = {
								is_enslaved = yes
								factor = 5
							}
							modifier = {
								happiness <= 0.3
								factor = 5
							}
							modifier = {
								is_unemployed = yes
								factor = 2
							}
							modifier = { #Get them out of there!
								is_being_purged = yes
								factor = 100
							}
							modifier = {
								is_elite_category = yes
								factor = 0.1
							}
						}
						root = {
							random_owned_planet = {
								weights = {
									base = 1
									modifier = {
										add = 5
										habitability = { who = prevprev value > 0.8 }
									}
									modifier = {
										add = 3
										habitability = { who = prevprev value > 0.5 }
									}
									modifier = {
										add = 5
										free_housing >= 10000
									}
									modifier = {
										factor = 0.1
										habitability = { who = prevprev value < 0.3 }
									}
									modifier = {
										factor = 0.1
										free_housing < 1000
									}
									modifier = {
										add = 1000
										is_planet_class = pc_cosmogenesis_world
									}
								}
								save_event_target_as = target_planet
							}
						}
						resettle_pop_group = {
							POP_GROUP = this
							PLANET = event_target:target_planet
							AMOUNT = 100
						}
						if = {
							limit = {
								species = {
									is_same_species = root
								}
								OR = {
									is_enslaved = yes
									is_being_purged = yes
								}
							}
							root = {
								set_country_flag = smugglers_of_hope_achievement
							}
						}
					}
				}
			}
		}

		from = { destroy_espionage_asset_government = yes }
	}

	option = { #Burn Asset for more
		name = bio.915.d
		custom_tooltip = bio.915.asset.tt
		trigger = {
			from.target = {
				count_owned_pop_amount = {
					limit = {
						is_same_species = root
					}
					count > 100
				}
			}
			from = { has_espionage_asset_government = yes }
		}
		icon = {
			icon = GFX_espionage_asset_icon
			text = ESPIONAGE_OPERATION_ASSET_EVENT_OPTION
		}

		hidden_effect = {
			multiply_variable = {
				which = smuggle_pops_amount
				value = 2
			}
			while = {
				count = smuggle_pops_amount
				from.target = {
					random_owned_pop_group = {
						limit = {
							can_be_smuggled = yes
							is_same_species = root
						}
						weights = {
							base = 5
							modifier = {
								is_enslaved = yes
								factor = 5
							}
							modifier = {
								happiness <= 0.3
								factor = 5
							}
							modifier = {
								is_unemployed = yes
								factor = 2
							}
							modifier = { #Get them out of there!
								is_being_purged = yes
								factor = 100
							}
							modifier = { #Get our people out of there
								is_same_species = root.species
								factor = 1000
							}
							modifier = {
								is_elite_category = yes
								factor = 0.1
							}
						}
						root = {
							random_owned_planet = {
								weights = {
									base = 1
									modifier = {
										add = 5
										habitability = { who = prevprev value > 0.8 }
									}
									modifier = {
										add = 3
										habitability = { who = prevprev value > 0.5 }
									}
									modifier = {
										add = 5
										free_housing >= 10000
									}
									modifier = {
										factor = 0.1
										habitability = { who = prevprev value < 0.3 }
									}
									modifier = {
										factor = 0.1
										free_housing < 1000
									}
									modifier = {
										add = 1000
										is_planet_class = pc_cosmogenesis_world
									}
								}
								save_event_target_as = target_planet
							}
						}
						resettle_pop_group = {
							POP_GROUP = this
							PLANET = event_target:target_planet
							AMOUNT = 100
						}
						if = {
							limit = {
								OR = {
									is_enslaved = yes
									is_being_purged = yes
								}
							}
							root = {
								set_country_flag = smugglers_of_hope_achievement
							}
						}
					}
				}
			}
		}

		from = { destroy_espionage_asset_government = yes }
	}


	after = {
		hidden_effect = {
			owner = {
				if = {
					limit = {
						NOT = { has_country_flag = operation_complete_smuggle_pops_prepare_invasion }
					}
					change_variable = {
						which = tinker_tailor_soldier_blorg_achievement_count
						value = 1
					}
					set_country_flag = operation_complete_smuggle_pops_prepare_invasion
				}
			}
			if = {
				limit = {
					check_variable = { #If 500 or more pops were stolen lets inform the victim.
						which = smuggle_pops_amount
						value > 4
					}
				}
				from.target = {
					create_message = {
						type = MESSAGE_POPS_SMUGGLED
						localization = MESSAGE_POPS_SMUGGLED_DESC
						days = 30
						target = root.capital_scope
						variable = {
							type = name
							localization = COUNTRY
							scope = root
						}
					}
					add_opinion_modifier = {
						who = root
						modifier = opinion_smuggled_pops
					}
				}
			}
		}
		from.spynetwork = {
			add_spy_network_level_on_success_effect = { VALUE = -50 }
		}
		destroy_espionage_operation = from
	}
}

#######################
 # Fallen Hive Empire #
 # id = bio.3000-3500 #
 # by Victor Haeggman #
 ######################

 # A fleet has entered a system | See also: on_fleet_auto_move_arrival
 # Scope = Fleet
 # From = System
 fleet_event = {
	id = bio.3000
	title = bio.3000.name
	desc = bio.3000.desc
	location = from

	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war.capital_scope
		graphical_culture = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war
	}

	trigger = {
		from = { has_star_flag = last_thought_system }
		is_cloaked = no
		exists = owner
		owner = {
			is_country_type = default
			NOT = { has_country_flag = warned_about_last_thought }
			NOT = {
				is_at_war_with = event_target:fallen_empire_hive_war
			}
		}
		any_country = {
			has_country_flag = fallen_empire_hive_war #checking for all the fallen empires to make sure that they can make good on their threats
		}
		any_country = {
			has_country_flag = fallen_empire_hive_growth
		}
		any_country = {
			has_country_flag = fallen_empire_hive_control
		}
	}

	immediate = {
		owner = {
			set_country_flag = warned_about_last_thought
		}
	}

	option = {
		name = bio.3000.a #Oh we will leave sorry about that
		set_mia = mia_return_home
		ai_chance = { factor = 1000 }
	}

	option = {
		name = bio.3000.b #It's fighting time
		hidden_effect = {
			fleet_event = { id = bio.3005 scopes = { from = from } } #Reusing the "you entered the system a second time"
		}
		ai_chance = { factor = 0 }
	}
 }

 # A fleet has entered a system | See also: on_fleet_auto_move_arrival
 # Scope = Fleet
 # From = System
 fleet_event = {
	id = bio.3005
	title = bio.3005.name
	desc = bio.3005.desc
	location = from

	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war.capital_scope
		graphical_culture = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war
	}

	trigger = {
		from = { has_star_flag = last_thought_system }
		is_cloaked = no
		exists = owner
		owner = {
			is_country_type = default
			has_country_flag = warned_about_last_thought
			NOR = {
				has_country_flag = pending_hive_fe_demand
				has_country_flag = recent_entered_last_thought
			}
			NOR = {
				is_at_war_with = event_target:fallen_empire_hive_war
				is_at_war_with = event_target:fallen_empire_hive_growth
				is_at_war_with = event_target:fallen_empire_hive_control
			}
		}
		any_country = {
			has_country_flag = fallen_empire_hive_war #checking for all the fallen empires to make sure that they can make good on their threats
		}
		any_country = {
			has_country_flag = fallen_empire_hive_growth
		}
		any_country = {
			has_country_flag = fallen_empire_hive_control
		}
	}

	immediate = {
		owner = {
			set_country_flag = pending_hive_fe_demand
			set_timed_country_flag = { flag = recent_entered_last_thought days = 180 }
		} # Ensuring that multiple fleets don't make the same event fire
	}

	option = {
		name = bio.3005.a #Ah that was a bad idea
		set_mia = mia_return_home
		owner = {
			remove_country_flag = pending_hive_fe_demand
		}
		ai_chance = { factor = 1000 }
	}

	option = {
		name = bio.3005.b #It's fighting time
		custom_tooltip = fallen_empire_refuse_tooltip
		hidden_effect = {
			event_target:fallen_empire_hive_war = { add_opinion_modifier = { who = root.owner modifier = opinion_refused_fallen_empire_demand } }
			event_target:fallen_empire_hive_growth = { add_opinion_modifier = { who = root.owner modifier = opinion_refused_fallen_empire_demand } }
			event_target:fallen_empire_hive_control = { add_opinion_modifier = { who = root.owner modifier = opinion_refused_fallen_empire_demand } }
			owner = {
				remove_country_flag = pending_hive_fe_demand
			}
		}
		event_target:fallen_empire_hive_forgotten = {
			set_hostile = root.owner
			establish_communications_no_message = root.owner
		}
		ai_chance = { factor = 0 }
	}
 }

 country_event = {
	id = bio.3010
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		exists = event_target:last_thought_system
		event_target:last_thought_system = {
			exists = starbase
		}
	}

	immediate = {
		event_target:last_thought_system = {
			starbase = { fleet = { destroy_fleet = this } }
		}
	}
 }

# Hive Fallen Empire Events
country_event = {
	id = bio.3100
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no

		exists = event_target:fallen_empire_hive_war
		event_target:fallen_empire_hive_war = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }
	}

	immediate = {
		event_target:fallen_empire_hive_war = { #Saving this here so that some of the common tooltips work
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id =  bio.3105 }
	}
}

country_event = {
	id = bio.3105
	title = bio.3105.name
	desc = bio.3105.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war
		graphical_culture = event_target:fallen_empire_hive_war
		city_level = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war.ruler
	}

	immediate = {
		if = {
			limit = {
				NOT = {
					is_variable_set = war_experimental_count
				}
			}
			set_variable = {
				which = war_experimental_count
				value = 1
			}
		}
		if = { # First we spawn the fleet in the system you have your biggest fleet
			limit = {
				any_owned_fleet = {
					is_ship_class = shipclass_military
				}
			}
			ordered_controlled_fleet = {
				limit = {
					is_ship_class = shipclass_military
				}
				position = 0
				order_by = trigger:fleet_power
				solar_system = {
					save_event_target_as = target_system
				}
			}
		}
		else_if = { # If not then we spawn it in the system you control closest to the FE
			limit = {
				is_nomadic = no
			}
			event_target:fallen_empire_hive_war = {
				capital_scope.solar_system = {
					closest_system = {
						limit = {
							exists = space_owner
							space_owner = {
								is_same_empire = root
							}
						}
						save_event_target_as = target_system
					}
				}
			}
		}
		else = { # If you are nomadic I guess we spawn them near your capital.
			capital_scope.solar_system = {
				save_event_target_as = target_system
			}
		}
	}

	option = {
		name = BATTLESTATIONS
		custom_tooltip = bio.3105.a.tooltip
	}

	option = {
		exclusive_trigger = {
			is_militarist = yes
		}
		name = bio.3105.militarist
		custom_tooltip = bio.3105.a.tooltip
	}

	option = {
		name = bio.3105.b
		custom_tooltip = bio.3105.a.tooltip
	}

	after = {
		hidden_effect = {
			change_variable = {
				which = war_experimental_count
				value = 1
			}
			create_country = {
				name = "NAME_New_Breed"
				type = faction
				flag = {
					icon = {
						category = "toxoid"
						file = "toxoid_04.dds"
					}
					background = {
						category = "backgrounds"
						file = "00_solid.dds"
					}
					colors = {
						"dark_red"
						"dark_blue"
						"null"
						"null"
					}
				}
				effect = {
					add_modifier = {
						modifier = war_experimental_scaling_modifier
						days = -1
						multiplier = root.value:war_experimental_ship_scaling
					}
					set_faction_hostility = {
						target = root.owner
						set_hostile = yes
					}
					every_playable_country = {
						establish_communications_no_message = prev
					}
					create_fleet = {
						name = "NAME_Experimental_Ship"
						settings = {
							spawn_debris = no
						}
						effect = {
							set_owner = prev
							if = {
								limit = {
									root = {
										NOT = { has_country_flag = beat_FE_experiment_ship }
									}
								}
								create_ship = {
									name = "NAME_Experimental_Ship"
									design = NAME_HIVE_FE_Large_Mauler_Swarm
									graphical_culture = biogenesis_01_fallen_empire
								}
							}
							else = {
								create_ship = {
									name = "NAME_Experimental_Ship"
									design = NAME_HIVE_FE_Large_Harbinger
									graphical_culture = biogenesis_01_fallen_empire
								}
							}
							set_location = {
								target = event_target:target_system
								distance = 100
								angle = 90
								direction = in_system
							}
							set_fleet_stance = passive
							set_aggro_range_measure_from = self
							set_aggro_range = 350
							create_ambient_object = {
								type = horror_spawn_object
								scale = 1
								location = this
								entity_scale_to_size = yes
								play_animation_once = yes
								duration = 10
							}
							save_event_target_as = experimental_fleet
						}
					}
					set_country_flag = experimental_fleet_fighter
					set_relation_flag = {
						who = root
						flag = experimental_fleet_fighter
					}
				}
			}
			country_event = { id = bio.3110 days = 360 random = 360 }
		}
	}
}

country_event = {
	id = bio.3110
	title = bio.3110.name
	desc = bio.3110.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war
		graphical_culture = event_target:fallen_empire_hive_war
		city_level = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war.ruler
	}

	trigger = {
		exists = event_target:experimental_fleet
	}

	option = {
		name = bio.3110.a
		custom_tooltip = fallen_machine_empire_unhappy_task_tooltip
		hidden_effect = {
			event_target:FallenEmpireTaskOrigin = {
			add_opinion_modifier = { who = root.owner modifier = opinion_failed_fallen_empire_task } }
			destroy_fleet = event_target:experimental_fleet
		}
	}

	abort_trigger = {
		NOT = { exists = event_target:experimental_fleet } #If you manage to kill it after the event fires we make it go away
	}
}

country_event = {
	id = bio.3115
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_country_flag = experimental_fleet_fighter
	}

	immediate = {
		random_country = {
			limit = {
				reverse_has_relation_flag = {
					who = root
					flag = experimental_fleet_fighter
				}
			}
			event_target:fallen_empire_hive_war = {
				save_event_target_as = FallenEmpireTaskOrigin
			}
			country_event = { id = bio.3120 }
		}
	}
}

country_event = {
	id = bio.3120
	title = bio.3120.name
	desc = bio.3120.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war
		graphical_culture = event_target:fallen_empire_hive_war
		city_level = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war.ruler
	}

	option = {
		name = DISCONCERTING
		custom_tooltip = fallen_machine_empire_happy_task_tooltip
		hidden_effect = {
			event_target:fallen_empire_hive_war = {
				add_opinion_modifier = { who = root modifier = opinion_completed_fallen_empire_task }
				increase_fe_influence = yes
			}
			set_country_flag = beat_FE_experiment_ship
		}
	}
}

country_event = {
	id = bio.3125
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no
		NOR = {
			has_country_flag = tasked_with_war
			has_country_flag = beat_unfortuante_country
			has_country_flag = tasked_with_peace
		}
		any_neighbor_country = {
			is_country_type = default
			has_communications = root
			NOR = {
				has_defensive_pact = root
				is_in_federation_with = root
				has_non_aggression_pact = root
				is_subject = yes
				any_owned_planet = {
					has_branch_office = root
				}
			}
		}
		exists = event_target:fallen_empire_hive_war
		event_target:fallen_empire_hive_war = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }
	}

	immediate = {
		event_target:fallen_empire_hive_war = { #Saving this here so that some of the common tooltips work
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id =  bio.3130 }
	}
}

country_event = {
	id = bio.3130
	title = bio.3130.name
	desc = {
		trigger = {
			has_truce = event_target:unfortunate_country
		}
		text = bio.3130.desc.truce
	}
	desc = {
		trigger = {
			NOT = { has_truce = event_target:unfortunate_country }
		}
		text = bio.3130.desc.notruce
	}
	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war
		graphical_culture = event_target:fallen_empire_hive_war
		city_level = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war.ruler
	}

	immediate = {
		random_neighbor_country = {
			limit = {
				is_country_type = default
				has_communications = root
				NOR = {
					has_defensive_pact = root
					is_in_federation_with = root
					has_non_aggression_pact = root
					is_subject = yes
					any_owned_planet = {
						has_branch_office = root
					}
				}
			}
			weights = {
				base = 10
				modifier = { #More likely to target someone you have a truce with cus that's funny
					factor = 2
					has_truce = root
				}
				modifier = { #If you are not going to be an even fight why give you this task?
					factor = 0.1
					NOT = {
						relative_power = {
							who = root
							category = fleet
							value = equivalent
						}
					}
				}
			}
			save_event_target_as = unfortunate_country
			set_country_flag = targeted_by_fe_hive_war_task
			set_relation_flag = {
				who = root
				flag = targeted_by_fe_hive_war_task
			}
		}
		set_timed_country_flag = { flag = tasked_with_war days = 6400 }
	}

	option = {
		name = bio.3130.a
	}

	option = {
		exclusive_trigger = { is_pacifist = yes }
		name = bio.3130.a.pacifist
	}

	option = {
		exclusive_trigger = {
			OR = {
				is_militarist = yes
				is_homicidal = yes
			}
		}
		name = bio.3130.a.militarist
	}

	after = {
		if = {
			limit = {
				event_target:unfortunate_country = {
					has_truce = root
				}
			}
			end_truce = event_target:unfortunate_country
		}
		hidden_effect = {
			country_event = { id = bio.3135 days = 3600 }
		}
	}
}

country_event = {
	id = bio.3135
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			has_country_flag = beat_unfortuante_country
		}
	}

	immediate = {
		if = {
			limit = {
				is_at_war_with = event_target:unfortunate_country
			}
			country_event = { id = bio.3135 days = 360 } # Lets see if the war is over next year.
		}
		else = {
			create_mad_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_war }
			event_target:unfortunate_country = {
				remove_country_flag = targeted_by_fe_hive_war_task
			}
		}
	}
}

# A war has been won
# Root = Winner Warleader
# From = Loser Warleader
# FromFrom = War
country_event = {
	id = bio.3140
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		from = {
			reverse_has_relation_flag = {
				who = root
				flag = targeted_by_fe_hive_war_task
			}
		}
	}

	immediate = {
		create_happy_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_war }
		set_timed_country_flag = { flag = beat_unfortuante_country days = 3600 }
		from = {
			remove_country_flag = targeted_by_fe_hive_war_task
		}
	}
}

country_event = {
	id = bio.3145
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		NOR = {
			has_country_flag = tasked_with_peace
			has_country_flag = recently_tasked_with_peace
			has_country_flag = tasked_with_war
		}
		exists = event_target:fallen_empire_hive_war
		event_target:fallen_empire_hive_war = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }
	}

	immediate = {
		event_target:fallen_empire_hive_war = { #Saving this here so that some of the common tooltips work
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id =  bio.3150 }
	}
}

country_event = {
	id = bio.3150
	title = bio.3150.name
	desc = bio.3150.desc
	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_war
		planet_background = event_target:fallen_empire_hive_war
		graphical_culture = event_target:fallen_empire_hive_war
		city_level = event_target:fallen_empire_hive_war
		room = event_target:fallen_empire_hive_war.ruler
	}

	option = {
		name = LUDICROUS
	}
	option = {
		exclusive_trigger = {
			OR = {
				is_militarist = yes
				is_unfriendly = yes
			}
		}
		name = bio.3150.a.mean
	}
	option = {
		exclusive_trigger = {
			is_pacifist = yes
		}
		name = bio.3150.a.pacifist
	}

	after = {
		hidden_effect = {
			set_timed_country_flag = { flag = tasked_with_peace days = 3601 }
			country_event = { id = bio.3155 days = 3600 }
		}
	}
}

country_event = {
	id = bio.3155
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_country_flag = tasked_with_peace
	}

	immediate = {
		create_happy_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_war }
		set_timed_country_flag = { flag = recently_tasked_with_peace days = 7200 } # We will give you a break from peace
	}
}

# A war is beginning, executed for every country in the war.
# Root = Country
# From = War
country_event = {
	id = bio.3160
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_country_flag = tasked_with_peace
	}
	immediate = {
		create_mad_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_war }
		remove_country_flag = tasked_with_peace
		set_timed_country_flag = { flag = recently_tasked_with_peace days = 3600 } # We will give you a break from peace
	}
}

# Growth Tasks
country_event = {
	id = bio.3200
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no
		count_planet_within_border = {
			count > 2
			limit = {
				habitable_planet_not_urban = yes
				pop_amount > 1000
				NOT = { has_carrier_flag = had_growth_fe_modifier }
			}
		}

		exists = event_target:fallen_empire_hive_growth
		event_target:fallen_empire_hive_growth = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }
	}

	immediate = {
		event_target:fallen_empire_hive_growth = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id = bio.3205 }
	}
}

country_event = {
	id = bio.3205
	title = bio.3205.name
	desc = bio.3205.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_growth
		planet_background = event_target:fallen_empire_hive_growth
		graphical_culture = event_target:fallen_empire_hive_growth
		city_level = event_target:fallen_empire_hive_growth
		room = event_target:fallen_empire_hive_growth.ruler
	}

	immediate = {
		if = { #If we have a rival we save that, else we just grab a random country
			limit = {
				num_rivals > 1
			}
			random_playable_country = {
				limit = {
					is_rival = root
				}
				save_event_target_as = targetrivalname
			}
		}
		else = {
			random_country = {
				limit = {
					NOR = {
						is_same_empire = root
						is_same_empire = event_target:fallen_empire_hive_growth
					}
					has_communications = root
				}
				save_event_target_as = targetrivalname
			}
		}
		random_owned_planet = {
			limit = {
				habitable_planet_not_urban = yes
				pop_amount > 1000
				NOT = { has_carrier_flag = had_growth_fe_modifier }
			}
			save_event_target_as = target_planet
		}
		random_owned_planet = {
			limit = {
				habitable_planet_not_urban = yes
				pop_amount > 1000
				NOR = {
					has_carrier_flag = had_growth_fe_modifier
					is_same_value = event_target:target_planet
				}
			}
			save_event_target_as = alternate_planet
		}
	}

	option = {
		trigger = {
			is_planetscaper_empire = no
		}
		allow = {
			NOT = { has_valid_civic = civic_environmentalist }
		}
		name = bio.3205.a
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			event_target:target_planet = { carrier_event = { id = bio.3210 days = 360 random = 360 } }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = { #Seperate event just to make sure that we get the civic icon in the option
		trigger = {
			is_planetscaper_empire = yes
		}
		name = bio.3205.a.planetscaper
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			event_target:target_planet = { carrier_event = { id = bio.3210 days = 360 random = 360 } }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = {
			is_planetscaper_empire = no
			exists = event_target:alternate_planet
		}
		allow = {
			NOT = { has_valid_civic = civic_environmentalist }
		}
		name = bio.3205.b
		ai_chance = {
			factor = 100
		}

		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			event_target:alternate_planet = { carrier_event = { id = bio.3210 days = 360 random = 360 } }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = {
			is_planetscaper_empire = yes
			exists = event_target:alternate_planet
		}
		name = bio.3205.b.planetscaper
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			event_target:alternate_planet = { carrier_event = { id = bio.3210 days = 360 random = 360 } }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = {
			NOT = { has_valid_civic = civic_environmentalist }
		}
		name = bio.3205.c
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_unhappy_tooltip

		hidden_effect = { event_target:fallen_empire_hive_growth = { add_opinion_modifier = { who = root modifier = opinion_refused_fallen_empire_request } } }
	}
	option = {
		trigger = {
			has_valid_civic = civic_environmentalist
		}
		name = bio.3205.c.environmentalist
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_unhappy_tooltip

		hidden_effect = { event_target:fallen_empire_hive_growth = { add_opinion_modifier = { who = root modifier = opinion_refused_fallen_empire_request } } }
	}
}

carrier_event = {
	id = bio.3210
	title = bio.3210.name
	desc = {
		trigger = { has_carrier_flag = fe_radio_bugs }
		text = bio.3210.desc.radio_bugs
		show_sound = event_radio_chatter_02
	}
	desc = {
		trigger = { has_carrier_flag = fe_world_of_thought }
		text = bio.3210.desc.world_of_thought
		show_sound = par_notification_ethics_generic
	}
	desc = {
		trigger = { has_carrier_flag = fe_world_alight }
		text = bio.3210.desc.world_alight
		show_sound = par_notification_ethics_generic
	}

	picture = {
		trigger = {
			has_carrier_flag = fe_radio_bugs
		}
		picture = GFX_evt_crimson_crawlers
	}
	picture = {
		trigger = {
			has_carrier_flag = fe_world_of_thought
		}
		picture = GFX_evt_smear_campaign
	}
	picture = {
		trigger = {
			has_carrier_flag = fe_world_alight
		}
		picture = GFX_evt_astral_rift_whiteout_2
	}

	is_triggered_only = yes
	location = this
	immediate = {
		set_carrier_flag = had_growth_fe_modifier
		random_list = {
			10 = {
				set_carrier_flag = fe_radio_bugs
				add_modifier = { modifier = radio_bugs }
			}
			10 = {
				set_carrier_flag = fe_world_of_thought
			}
			10 = {
				set_carrier_flag = fe_world_alight
				add_modifier = { modifier = world_alight }
			}
		}
	}

	option = {
		trigger = { has_carrier_flag = fe_radio_bugs }
		name = bio.3210.radio_bugs.accept
		tooltip = { add_modifier = { modifier = radio_bugs } }
	}

	option = {
		trigger = {
			has_carrier_flag = fe_radio_bugs
			NOT = { owner = { has_valid_civic = civic_machine_ota_updates } }
		}
		name = bio.3210.radio_bugs.purge
		custom_tooltip = fallen_machine_empire_unhappy_task_tooltip
		hidden_effect = { event_target:FallenEmpireTaskOrigin = { add_opinion_modifier = { who = root.owner modifier = opinion_failed_fallen_empire_task } } } #Harsher opinion modifier because you told them you would and then didn't.
		remove_modifier = radio_bugs
	}
	option = {
		trigger = {
			has_carrier_flag = fe_radio_bugs
			owner = { has_valid_civic = civic_machine_ota_updates }
		}
		name = bio.3210.radio_bugs.purgeota
		custom_tooltip = fallen_machine_empire_unhappy_task_tooltip
		hidden_effect = { event_target:FallenEmpireTaskOrigin = { add_opinion_modifier = { who = root.owner modifier = opinion_failed_fallen_empire_task } } }
		remove_modifier = radio_bugs
	}

	option = {
		trigger = {
			has_carrier_flag = fe_world_of_thought
			owner = { is_homicidal = no }
		}
		name = bio.3210.world_of_thought
		custom_tooltip = bio.3210.world_of_thought.tt
		hidden_effect = {
			generate_new_species_and_pop = { TARGET = root AMOUNT = 2 TRAIT = trait_uplifted }
			generate_new_species_and_pop = { TARGET = root AMOUNT = 1 TRAIT = trait_uplifted }
			generate_new_species_and_pop = { TARGET = root AMOUNT = 1 TRAIT = trait_uplifted }
			generate_new_species_and_pop = { TARGET = root AMOUNT = 1 TRAIT = trait_uplifted }
		}
	}

	option = {
		trigger = {
			has_carrier_flag = fe_world_of_thought
			owner = { is_homicidal = yes }
		}
		name = bio.3210.world_of_thought.homicidal
		custom_tooltip = bio.3210.world_of_thought.tt
		hidden_effect = {
			generate_new_species_and_pop = { TARGET = root AMOUNT = 2 TRAIT = trait_uplifted }
			generate_new_species_and_pop = { TARGET = root AMOUNT = 1 TRAIT = trait_uplifted }
			generate_new_species_and_pop = { TARGET = root AMOUNT = 1 TRAIT = trait_uplifted }
			generate_new_species_and_pop = { TARGET = root AMOUNT = 1 TRAIT = trait_uplifted }
		}
	}

	option = {
		trigger = {
			has_carrier_flag = fe_world_alight
		}
		name = bio.3210.world_alight.accept
		tooltip = { add_modifier = { modifier = world_alight } }
	}
	option = {
		trigger = {
			has_carrier_flag = fe_world_alight
		}
		name = bio.3210.world_alight.reject
		custom_tooltip = fallen_machine_empire_unhappy_task_tooltip
		hidden_effect = { event_target:FallenEmpireTaskOrigin = { add_opinion_modifier = { who = root.owner modifier = opinion_failed_fallen_empire_task } } }
		remove_modifier = world_alight
	}
}

country_event = {
	id = bio.3215
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no
		has_organic_pops = yes
		is_wilderness_empire = no

		exists = event_target:fallen_empire_hive_growth
		event_target:fallen_empire_hive_growth = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }
	}

	immediate = {
		event_target:fallen_empire_hive_growth = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id = bio.3220 }
	}
}

country_event = {
	id = bio.3220
	title = bio.3220.name
	desc = bio.3220.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_growth
		planet_background = event_target:fallen_empire_hive_growth
		graphical_culture = event_target:fallen_empire_hive_growth
		city_level = event_target:fallen_empire_hive_growth
		room = event_target:fallen_empire_hive_growth.ruler
	}

	immediate = {
		weighted_random_owned_pop_group = {
			limit = {
				species = {
					OR = {
						is_archetype = BIOLOGICAL
						is_archetype = LITHOID
					}
				}
			}
			species = { save_event_target_as = boring_species }
		}
		while = {
			count = 3
			generate_boring_species_choices = yes
		}
	}

	option = {
		trigger = { has_country_flag = boring_humanoid_choice }
		name = bio.3220.humanoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = humanoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_mammalian_choice }
		name = bio.3220.mammalian
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = mammalian NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_reptilian_choice }
		name = bio.3220.reptilian
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = reptilian NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_avian_choice }
		name = bio.3220.avian
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = avian NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_arthropoid_choice }
		name = bio.3220.arthropoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = arthropoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_molluscoid_choice }
		name = bio.3220.molluscoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = molluscoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_fungoid_choice }
		name = bio.3220.fungoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = fungoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_plantoid_choice }
		name = bio.3220.plantoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = plantoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_lithoid_choice }
		name = bio.3220.lithoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = lithoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_necroid_choice }
		name = bio.3220.necroid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = necroid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_aquatic_choice }
		name = bio.3220.aquatic
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = aquatic NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_toxoid_choice }
		name = bio.3220.toxoid
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = toxoid NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_infernal_choice }
		name = bio.3220.infernal
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = infernal NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		trigger = { has_country_flag = boring_psionic_choice }
		name = bio.3220.psionic
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			add_random_trait_by_tag = { SPECIES = event_target:boring_species TAG = psionic NOTTAG = special }
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = { #EvoPred get situation progress if they get the event
		exclusive_trigger = {
			has_origin = origin_evolutionary_predators
			event_target:boring_species = { is_same_species = root.species }
		}
		name = bio.3220.evopred
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_happy_tooltip
		custom_tooltip = bio.3220.tt

		hidden_effect = {
			hidden_effect = {
				random_situation = {
					limit = {
						is_situation_type = evolutionary_predators_situation
					}
					add_situation_progress = value:evopred_50
				}
			}
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
			}
		}
	}
	option = {
		name = bio.3220.b
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_unhappy_tooltip

		hidden_effect = { event_target:fallen_empire_hive_growth = { add_opinion_modifier = { who = root modifier = opinion_refused_fallen_empire_request } } }
	}

	after = {
		hidden_effect = {
			remove_country_flag = boring_humanoid_choice
			remove_country_flag = boring_mammalian_choice
			remove_country_flag = boring_reptilian_choice
			remove_country_flag = boring_avian_choice
			remove_country_flag = boring_arthropoid_choice
			remove_country_flag = boring_molluscoid_choice
			remove_country_flag = boring_fungoid_choice
			remove_country_flag = boring_plantoid_choice
			remove_country_flag = boring_lithoid_choice
			remove_country_flag = boring_necroid_choice
			remove_country_flag = boring_aquatic_choice
			remove_country_flag = boring_toxoid_choice
			remove_country_flag = boring_infernal_choice
		}
	}
}

country_event = {
	id = bio.3225
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no
		has_organic_pops = yes
		any_owned_pop_group = {
			has_interesting_species_trait = yes
		}

		exists = event_target:fallen_empire_hive_growth
		event_target:fallen_empire_hive_growth = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }
	}

	immediate = {
		event_target:fallen_empire_hive_growth = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		weighted_random_owned_pop_group = {
			limit = {
				has_interesting_species_trait = yes
			}
			species = {
				save_event_target_as = interesting_species
			}
		}
		event_target:fallen_empire_hive_growth = {
			save_event_target_as = FallenEmpireTaskOrigin
			species = {
				if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_cave_dweller
						}
						NOT = {
							has_trait = trait_cave_dweller
						}
					}
					set_species_flag = trait_cave_dweller
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_survivor
						}
						NOT = {
							has_trait = trait_survivor
						}
					}
					set_species_flag = trait_survivor
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_stargazer
						}
						NOT = {
							has_trait = trait_stargazer
						}
					}
					set_species_flag = trait_stargazer
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_storm_touched
						}
						NOT = {
							has_trait = trait_storm_touched
						}
					}
					set_species_flag = trait_storm_touched
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_bioadaptability
						}
						NOT = {
							has_trait = trait_bioadaptability
						}
					}
					set_species_flag = trait_bioadaptability
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_social_pheromones
						}
						NOT = {
							has_trait = trait_social_pheromones
						}
					}
					set_species_flag = trait_social_pheromones
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_limited_regeneration
						}
						NOT = {
							has_trait = trait_limited_regeneration
						}
					}
					set_species_flag = trait_limited_regeneration
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_enigmatic_intelligence
						}
						NOT = {
							has_trait = trait_enigmatic_intelligence
						}
					}
					set_species_flag = trait_enigmatic_intelligence
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_brainslug
						}
						NOT = {
							has_trait = trait_brainslug
						}
					}
					set_species_flag = trait_brainslug
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_plasmic
						}
						NOT = {
							has_trait = trait_plasmic
						}
					}
					set_species_flag = trait_plasmic
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_storm_fused
						}
						NOT = {
							has_trait = trait_storm_fused
						}
					}
					set_species_flag = trait_storm_fused
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_drake_scaled
						}
						NOT = {
							has_trait = trait_drake_scaled
						}
					}
					set_species_flag = trait_drake_scaled
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_tiyanki
						}
						NOT = {
							has_trait = trait_tiyanki
						}
					}
					set_species_flag = trait_tiyanki
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_voidling
						}
						NOT = {
							has_trait = trait_voidling
						}
					}
					set_species_flag = trait_voidling
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_notofthisworld
						}
						NOT = {
							has_trait = trait_notofthisworld
						}
					}
					set_species_flag = trait_notofthisworld
				}
				else_if = {
					limit = {
						event_target:interesting_species = {
							has_trait = trait_exd
						}
						NOT = {
							has_trait = trait_exd
						}
					}
					set_species_flag = trait_exd
				}
			}
		}
		country_event = { id = bio.3230 }
	}
}

country_event = {
	id = bio.3230
	title = bio.3230.name
	desc = bio.3230.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_growth
		planet_background = event_target:fallen_empire_hive_growth
		graphical_culture = event_target:fallen_empire_hive_growth
		city_level = event_target:fallen_empire_hive_growth
		room = event_target:fallen_empire_hive_growth.ruler
	}

	option = {
		name = bio.3230.a
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_happy_tooltip

		hidden_effect = {
			event_target:fallen_empire_hive_growth = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes

				species = {
					switch = {
						trigger = has_species_flag
						trait_cave_dweller = {
							change_species_characteristics = {
								add_trait = trait_cave_dweller
								add_traits_at_start_of_list = yes
							}
						}
						trait_survivor = {
							change_species_characteristics = {
								add_trait = trait_survivor
								add_traits_at_start_of_list = yes
							}
						}
						trait_enigmatic_intelligence = {
							change_species_characteristics = {
								add_trait = trait_enigmatic_intelligence
								add_traits_at_start_of_list = no
							}
						}
						trait_bioadaptability = {
							change_species_characteristics = {
								add_trait = trait_bioadaptability
								add_traits_at_start_of_list = no
							}
						}
						trait_social_pheromones = {
							change_species_characteristics = {
								add_trait = trait_social_pheromones
								add_traits_at_start_of_list = no
							}
						}
						trait_limited_regeneration = {
							change_species_characteristics = {
								add_trait = trait_limited_regeneration
								add_traits_at_start_of_list = no
							}
						}
						trait_stargazer = {
							change_species_characteristics = {
								add_trait = trait_stargazer
								add_traits_at_start_of_list = yes
							}
						}
						trait_brainslug = {
							change_species_characteristics = {
								add_trait = trait_brainslug
								add_traits_at_start_of_list = no
							}
						}
						trait_plasmic = {
							change_species_characteristics = {
								add_trait = trait_plasmic
								add_traits_at_start_of_list = no
							}
						}
						trait_storm_fused = {
							change_species_characteristics = {
								add_trait = trait_storm_fused
								add_traits_at_start_of_list = no
							}
						}
						trait_storm_touched = {
							change_species_characteristics = {
								add_trait = trait_storm_touched
								add_traits_at_start_of_list = no
							}
						}
						trait_drake_scaled = {
							change_species_characteristics = {
								add_trait = trait_drake_scaled
								add_traits_at_start_of_list = no
							}
						}
						trait_tiyanki = {
							change_species_characteristics = {
								add_trait = trait_tiyanki
								add_traits_at_start_of_list = no
							}
						}
						trait_voidling = {
							change_species_characteristics = {
								add_trait = trait_voidling
								add_traits_at_start_of_list = no
							}
						}
						trait_notofthisworld = {
							change_species_characteristics = {
								add_trait = trait_notofthisworld
								add_traits_at_start_of_list = no
							}
						}
						trait_exd = {
							change_species_characteristics = {
								add_trait = trait_exd
								add_traits_at_start_of_list = yes
							}
						}
					}
				}
			}
		}
	}

	option = {
		name = bio.3230.b
		ai_chance = {
			factor = 10
		}
		custom_tooltip = fallen_empire_unhappy_tooltip

		hidden_effect = { event_target:fallen_empire_hive_growth = { add_opinion_modifier = { who = root modifier = opinion_refused_fallen_empire_request } } }
	}

	after = {
		event_target:fallen_empire_hive_growth.species = {
			remove_species_flag = trait_cave_dweller
			remove_species_flag = trait_survivor
			remove_species_flag = trait_enigmatic_intelligence
			remove_species_flag = trait_bioadaptability
			remove_species_flag = trait_social_pheromones
			remove_species_flag = trait_limited_regeneration
			remove_species_flag = trait_stargazer
			remove_species_flag = trait_brainslug
			remove_species_flag = trait_plasmic
			remove_species_flag = trait_storm_fused
			remove_species_flag = trait_storm_touched
			remove_species_flag = trait_drake_scaled
			remove_species_flag = trait_tiyanki
			remove_species_flag = trait_voidling
			remove_species_flag = trait_notofthisworld
			remove_species_flag = trait_exd
		}
	}
}

#country_event = {
#	id = bio.3235
#	hide_window = yes
#	is_triggered_only = yes
#
#	trigger = {
#		is_ai = no
#		is_country_type = default
#		is_at_war = no
#		country_uses_food = yes
#
#		exists = event_target:fallen_empire_hive_growth
#		event_target:fallen_empire_hive_growth = {
#			is_country_type = fallen_empire
#			is_at_war = no
#			fleet_power > 60000
#			has_communications = root
#		}
#
#		any_system_within_border = {
#			star = {
#				distance_to_empire = {
#					who = event_target:fallen_empire_hive_growth
#					distance < 10
#					use_bypass = no
#					type = hyperlane
#				}
#			}
#		}
#	}
#
#	immediate = {
#		event_target:fallen_empire_hive_growth = {
#			save_event_target_as = FallenEmpireTaskOrigin
#		}
#		random_system_within_border = {
#			limit = {
#				star = {
#					distance_to_empire = {
#						who = event_target:fallen_empire_hive_growth
#						distance < 10
#						use_bypass = no
#						type = hyperlane
#					}
#				}
#			}
#			save_event_target_as = eternal_harvest_system
#		}
#		country_event = { id = bio.3240 }
#	}
#}

# Control Tasks
country_event = {
	id = bio.3300
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no

		exists = event_target:fallen_empire_hive_control
		event_target:fallen_empire_hive_control = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}

		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }

		any_owned_pop_group = { #First we check that the fallen empire doesn't already own this species
			is_organic_species = yes
			NOT = {
				event_target:fallen_empire_hive_control = {
					any_owned_species = {
						is_same_species = prevprev
					}
				}
			}
		}
	}

	immediate = {
		event_target:fallen_empire_hive_control = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id = bio.3305 }
	}
}

country_event = {
	id = bio.3305
	title = bio.3305.name
	desc = bio.3305.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	immediate = {
		weighted_random_owned_pop_group = {
			limit = {
				pop_group_size > 1
				species = { is_organic_species = yes }
				NOT = {
					event_target:fallen_empire_hive_control = {
						any_owned_species = {
							is_same_species = prevprev
						}
					}
				}
			}
			save_event_target_as = target_pop
		}
	}

	option = {
		name = bio.3305.a
		ai_chance = {
			factor = 100
		}
		custom_tooltip = fallen_empire_happy_tooltip
		custom_tooltip = bio.3305.a.tooltip

		hidden_effect = {
			event_target:fallen_empire_hive_control = {
				add_opinion_modifier = { who = root modifier = opinion_accepted_fallen_empire_request }
				increase_fe_influence = yes
				create_leader = {
					class = official
					species = event_target:target_pop
					name = random
					skill = 1
				}
				last_created_leader = {
					save_event_target_as = target_leader_fe_control
					exile_leader_as = target_leader_fe_control
				}
				resettle_pop_group = {
					POP_GROUP = event_target:target_pop
					PLANET = capital_scope
					AMOUNT = 1
				}
				event_target:fallen_empire_hive_control.capital_scope = {
					while = {
						count = 4
						create_pop_group = { species = event_target:target_pop }
					}
				}
			}
			random_list = {
				1 = {
					modifier = {
						factor = 0
						event_target:target_pop = { NOT = { is_same_species = root.species } }
					}
					country_event = { id = bio.3310 days = 360 random = 360 }
				}
				1 = {
					country_event = { id = bio.3315 days = 360 random = 360 }
				}
				3 = {}
			}
		}
	}
	option = {
		name = bio.3305.b
		ai_chance = {
			factor = 10
		}
		custom_tooltip = fallen_empire_unhappy_tooltip
		hidden_effect = {
			event_target:fallen_empire_hive_control = {
				add_opinion_modifier = {
					who = root
					modifier = opinion_refused_fallen_empire_request
				}
			}
		}
	}
}

country_event = {
	id = bio.3310
	title = TRANSMISSION
	desc = bio.3310.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:target_leader_fe_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	option = {
		name = UNNERVING
	}

	option = {
		name = bio.3310.familiar_face
		exclusive_trigger = { has_valid_civic = civic_hive_familiar_face }
	}
}

country_event = {
	id = bio.3315
	title = TRANSMISSION
	desc = bio.3315.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:target_leader_fe_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	option = {
		name = bio.3315.a
		custom_tooltip = bio.3315.tooltip
		hidden_effect = {
			random_list = {
				1 = {
					grant_random_fe_building = yes
				}
				1 = {
					custom_tooltip = fallen_empire_maybe_unhappy_tooltip
					hidden_effect = {
						event_target:fallen_empire_hive_control = {
							add_opinion_modifier = { who = root modifier = opinion_refused_fallen_empire_request }
						}
					}
				}
			}
		}
	}

	option = {
		name = bio.3315.b
	}
}

country_event = {
	id = bio.3320
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_ai = no
		is_country_type = default
		is_at_war = no
		is_galactic_community_member = yes
		galactic_community_rank <= 5 # If you are in the top 5 then you can get this event

		exists = event_target:fallen_empire_hive_control
		event_target:fallen_empire_hive_control = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
	}

	immediate = {
		set_country_flag = pending_fe_hive_control_galcom_event
	}
}

country_event = {
	id = bio.3325
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		exists = event_target:fallen_empire_hive_control
		event_target:fallen_empire_hive_control = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
		}
		any_galcom_member = {
			has_country_flag = pending_fe_hive_control_galcom_event
		}
	}

	immediate = {
		every_galcom_member = {
			limit = {
				has_country_flag = pending_fe_hive_control_galcom_event
			}
			country_event = { id = bio.3330 }
		}
	}
}

country_event = {
	id = bio.3330
	title = bio.3330.name
	desc = bio.3330.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	immediate = {
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		remove_country_flag = pending_fe_hive_control_galcom_event
		random_list = {
			1 = {
				set_country_flag = should_fail_resolution
			}
			1 = {
				set_country_flag = should_pass_resolution
			}
		}
	}

	option = {
		name = bio.3330.a
		if = {
			limit = {
				has_country_flag = should_fail_resolution
			}
			add_modifier = {
				modifier = fe_political_opposition
			}
		}
		else = {
			add_modifier = {
				modifier = fe_political_support
			}
		}
	}

	option = {
		exclusive_trigger = {
			has_tradition = tr_politics_adopt
		}
		name = bio.3330.b
	}
}

#A resolution has passed
country_event = {
	id = bio.3335
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		any_playable_country = {
			OR = {
				has_country_flag = should_fail_resolution
				has_country_flag = should_pass_resolution
			}
		}
	}

	immediate = {
		every_playable_country = {
			limit = {
				OR = {
					has_country_flag = should_fail_resolution
					has_country_flag = should_pass_resolution
				}
			}
			if = {
				limit = { has_country_flag = should_fail_resolution }
				create_mad_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_control }
				remove_country_flag = should_fail_resolution
				remove_modifier = fe_political_opposition
			}
			else = {
				create_happy_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_control }
				remove_country_flag = should_pass_resolution
				remove_modifier = fe_political_support
			}

		}
	}
}

#A resolution has failed
country_event = {
	id = bio.3340
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		any_playable_country = {
			OR = {
				has_country_flag = should_fail_resolution
				has_country_flag = should_pass_resolution
			}
		}
	}

	immediate = {
		every_playable_country = {
			limit = {
				OR = {
					has_country_flag = should_fail_resolution
					has_country_flag = should_pass_resolution
				}
			}
			if = {
				limit = { has_country_flag = should_pass_resolution }
				create_mad_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_control }
				remove_country_flag = should_pass_resolution
				remove_modifier = fe_political_support
			}
			else = {
				create_happy_hive_fe_task_message = { FALLEN_EMPIRE = event_target:fallen_empire_hive_control }
				remove_country_flag = should_fail_resolution
				remove_modifier = fe_political_opposition
			}

		}
	}
}

country_event = {
	id = bio.3345
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		years_passed > 20
		is_ai = no
		is_country_type = default
		is_at_war = no
		NOT = { has_country_flag = recently_cleaned_borders }

		exists = event_target:fallen_empire_hive_control
		event_target:fallen_empire_hive_control = {
			is_country_type = fallen_empire
			is_at_war = no
			fleet_power > 60000
			has_communications = root
		}
		NOT = { has_country_flag = hive_fallen_empire_event_cooldown }

		any_system_within_border = { # We are looking to see if we can't find a system that the control fragment finds ugly
			NOR = {
				any_bypass = {# First we get rid of any with a bypass so it doesn't get mad at wormholes or terminal egress
					NOT = {
						is_bypass_type = relay_bypass
					}
					solar_system = {
						is_same_value = prevprev
						exists = space_owner
						space_owner = {
							is_same_value = root
						}
					}
				}
				any_system_planet = { # And we wont make you give up a colony
					exists = owner
					owner = {
						is_same_empire = root
					}
				}
			}
			count_neighbor_system = { # Then we look for systems that border 2 or more systems that you don't own
				count >= 3
				limit = {
					OR = {
						AND = {
							exists = starbase.owner
							starbase.owner = {
								NOT = { is_same_value = root }
							}
						}
						NOT = { exists = starbase.owner }
					}
				}
			}
			NOT = { # But we will not flag it if the system is connected to 2 or more of your own systems
				count_neighbor_system = {
					count >= 2
					limit = {
						exists = starbase.owner
						starbase.owner = {
							is_same_value = root
						}
					}
				}
			}
		}
	}

	immediate = {
		event_target:fallen_empire_hive_control = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		set_timed_country_flag = { flag = hive_fallen_empire_event_cooldown days = 2560 }
		country_event = { id = bio.3350 }
	}
}

country_event = {
	id = bio.3350
	title = bio.3350.name
	desc = bio.3350.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	immediate = {
		random_system_within_border = { # We are looking to see if we can't find a system that the control fragment finds ugly
			limit = {
				NOR = {
					any_bypass = {# First we get rid of any with a bypass so it doesn't get mad at wormholes or terminal egress
						NOT = {
							is_bypass_type = relay_bypass
						}
						solar_system = {
							is_same_value = prevprev
							exists = owner
							space_owner = {
								is_same_value = root
							}
						}
					}
					any_system_planet = { # And we wont make you give up a colony
						exists = owner
						owner = {
							is_same_empire = root
						}
					}
				}
				count_neighbor_system = { # Then we look for systems that border 2 or more systems that you don't own
					count >= 3
					limit = {
						OR = {
							AND = {
								exists = starbase.owner
								starbase.owner = {
									NOT = { is_same_value = root }
								}
							}
							NOT = { exists = starbase.owner }
						}
					}
				}
				NOT = { # But we will not flag it if the system is connected to 2 or more of your own systems
					count_neighbor_system = {
						count >= 2
						limit = {
							exists = starbase.owner
							starbase.owner = {
								is_same_value = root
							}
						}
					}
				}
			}
			save_event_target_as = offending_system
		}
	}

	option = {
		name = bio.3350.a
		custom_tooltip = bio.3350.tt
	}

	option = {
		exclusive_trigger = {
			OR = {
				is_eager_explorer_empire = yes
				has_origin = origin_fruitful
				has_origin = origin_star_slingshot
			}
		}
		name = bio.3350.bordergore
		custom_tooltip = bio.3350.tt
	}

	after = {
		hidden_effect = {
			country_event = { id = bio.3355 days = 360 random = 360 }
			set_country_flag = tasked_with_removing@event_target:offending_system
		}
	}
}

country_event = {
	id = bio.3355
	title = bio.3355.name
	desc = bio.3355.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	trigger = {
		event_target:offending_system = {
			exists = space_owner
			space_owner = {
				is_same_value = root
			}
		}
	}

	option = {
		name = OOPS
		custom_tooltip = fallen_empire_unhappy_tooltip
		hidden_effect = {
			event_target:fallen_empire_hive_control = {
				add_opinion_modifier = { who = root modifier = opinion_angered_fallen_machine_empire }
				remove_opinion_modifier = { who = root modifier = opinion_completed_fallen_empire_task }
				if = {
					limit = {
						root = {
							has_country_flag = recently_cleaned_borders
						}
					}
					decrease_fe_influence = yes
				}
			}
			remove_country_flag = tasked_with_removing@event_target:offending_system
		}
	}
}

country_event = {
	id = bio.3360
	title = bio.3360.name
	desc = bio.3360.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}

	option = {
		name = ACKNOWLEDGED
		custom_tooltip = fallen_empire_happy_tooltip
		hidden_effect = {
			event_target:fallen_empire_hive_control = {
				add_opinion_modifier = { who = root modifier = opinion_completed_fallen_empire_task }
				increase_fe_influence = yes
			}
		}

		remove_country_flag = tasked_with_removing@fromfrom
		set_timed_country_flag = { flag = tasked_with_removing@fromfrom days = 1800 } #You need to not rebuild there for 5 years
		set_timed_country_flag = { flag = recently_cleaned_borders days = 3600 }
	}
}

# No longer owns the offending system
country_event = {
	id = bio.3365

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_country_flag = tasked_with_removing@from
	}

	immediate = {
		event_target:fallen_empire_hive_control = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		country_event = { id = bio.3360 }
	}
}

# Regained control of the offending system within 5 years of the original event
country_event = {
	id = bio.3370

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_country_flag = tasked_with_removing@from
	}

	immediate = {
		from = { save_event_target_as = offending_system }
		event_target:fallen_empire_hive_control = {
			save_event_target_as = FallenEmpireTaskOrigin
		}
		country_event = { id = bio.3355 }
	}
}

# Post awakening events

# Control
country_event = {
	id = bio.3400
	title = bio.3400.name
	desc = {
		trigger = {
			is_galactic_community_formed = no
		}
		text = bio.3400.desc.nogalcom
	}
	desc = {
		trigger = {
			is_galactic_community_formed = yes
		}
		text = bio.3400.desc.galcom
	}

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}
	is_triggered_only = yes

	option = {
		name = VIEWSCREEN_OFF
	}
}

country_event = {
	id = bio.3405
	title = bio.3405.name
	desc = bio.3405.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		portrait = event_target:fallen_empire_hive_control
		planet_background = event_target:fallen_empire_hive_control
		graphical_culture = event_target:fallen_empire_hive_control
		city_level = event_target:fallen_empire_hive_control
		room = event_target:fallen_empire_hive_control.ruler
	}
	is_triggered_only = yes

	trigger = {
		from = {
			has_country_flag = fallen_empire_hive_control
			is_galactic_emperor = no
			is_at_war = no
		}
	}

	option = {
		name = bio.3405.a
		event_target:fallen_empire_hive_control = {
			declare_war = {
				target = root
				name = "NAME_Appeal_the_Veto"
				attacker_war_goal = "wg_ae_domination"
			}
		}
	}
}

#3450 Story Dig Site
fleet_event = {
	id = bio.3450
	title = "bio.3450.name"
	desc = "bio.3450.desc"
	picture = GFX_evt_necrophage
	show_sound = evn_ove_scientific_experiments

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	option = {
		name = INCREDIBLE
		small_artifact_reward = yes
		if = {
			limit = {
				owner = {
					has_ascension_perk = ap_behemoths
				}
			}
			owner = {
				add_resource = {
					feral_insight = 1000
				}
			}
		}
	}

	after = {
		from = { set_site_progress_locked = no }
	}
}

fleet_event = {
	id = bio.3455
	title = "bio.3455.name"
	desc = "bio.3455.desc"
	picture = GFX_evt_necrophage
	show_sound = evn_ove_scientific_experiments

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	option = {
		name = UNDERSTOOD
		small_artifact_reward = yes
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 6
				min = 1000
				max = 10000
			}
			if = {
				limit = {
					has_ascension_perk = ap_behemoths
				}
				add_resource = {
					feral_insight = 1000
				}
			}
		}
	}

	after = {
		from = { set_site_progress_locked = no }
	}
}

fleet_event = {
	id = bio.3460
	title = "bio.3460.name"
	desc = "bio.3460.desc"
	picture = GFX_evt_necrophage
	show_sound = evn_ove_scientific_experiments

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	option = {
		name = DISCONCERTING

		medium_artifact_reward = yes
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 8
				min = 1000
				max = 12000
			}
			if = {
				limit = {
					has_ascension_perk = ap_behemoths
				}
				add_resource = {
					feral_insight = 1000
				}
			}
		}
	}

	after = {
		from = { set_site_progress_locked = no }
	}
}

fleet_event = {
	id = bio.3465
	title = "bio.3465.name"
	desc = "bio.3465.desc"
	picture = GFX_evt_necrophage
	show_sound = evn_ove_scientific_experiments

	archaeology = yes
	is_triggered_only = yes

	immediate = {
		from = { set_site_progress_locked = yes }
	}

	option = {
		name = {
			text = DISTURBING
			trigger = {
				owner = { NOT = { has_ascension_perk = ap_behemoths } }
			}
		}
		name = {
			text = FOOLS
			trigger = {
				owner = { has_ascension_perk = ap_behemoths }
			}
		}

		large_artifact_reward = yes
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 18
				min = 1000
				max = 100000
			}
			if = {
				limit = {
					has_ascension_perk = ap_behemoths
				}
				add_resource = {
					feral_insight = 3000
				}
			}
		}
		event_target:fallen_empire_hive_forgotten = {
			set_hostile = root.owner
			establish_communications_no_message = root.owner
		}
	}

	after = {
		from = { set_site_progress_locked = no }
	}
}

#########################################
# Additional Events for Ascension Paths #
# id = bio.5000 - 6000					#
#########################################


# Executed just before on_leader_death if show_notification = yes (default)
# This = Country
# From = Leader
country_event = {
	id = bio.5000
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		from = {
			is_pool_leader = no
			leader_backup_clone_can_activate = yes
		}
	}

	immediate = {
		random_owned_planet = {
			limit = {
				planet_has_cloning_facility = yes
			}
			save_event_target_as = clone_background_planet
		}
		create_backup_clone = yes
		from = {
			set_leader_flag = leader_death_events_blocked
		}
	}
}

# Fired by on_five_year_pulse_country
# This = Country
# Gatekeeper event for reissuing backup clones
country_event = {
	id = bio.5001
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_cloning_biochemical_composure_tradition = yes
		is_cloning_authority = yes
	}

	immediate = {
		every_owned_leader = {
			limit = {
				is_gestalt_node = no
				is_robotic_species = no
				NOR = {
					has_trait = leader_trait_has_backup_clone
					has_leader_flag = ignore_country_clone_pulse
				}
			}
			leader_event = {
				id = bio.5002
				days = 180
				random = 180
			}
		}
		every_pool_leader = {
			limit = {
				is_robotic_species = no
				NOR = {
					has_trait = leader_trait_has_backup_clone
					has_leader_flag = ignore_country_clone_pulse
				}
			}
			leader_event = {
				id = bio.5002
				days = 180
				random = 180
			}
		}
	}
}

leader_event = {
	id = bio.5002
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		NOT = {
			has_trait = leader_trait_has_backup_clone
		}
		exists = owner
		owner = {
			has_cloning_biochemical_composure_tradition = yes
			is_cloning_authority = yes
		}
	}

	immediate = {
		set_leader_flag = ignore_country_clone_pulse
		random_list = {
			1 = {		# 33% chance to gain a backup clone
				add_trait = {
					trait = leader_trait_has_backup_clone
				}
			}
			2 = {		# 67% chance to reroll in 3-5 years
				leader_event = {
					id = bio.5002
					days = 1080
					random = 720
				}
			}
		}
	}
}

# Assign Purity Authority variables

# Triggered by on_uplift_completion
# Scope = planet_event
# This = planet scope
# From = uplifted species (pre-modification)
carrier_event = {
	id = bio.5105
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = owner
		owner = {
			is_purity_authority = yes
		}
		from = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
			NOT = {
				is_variable_set = species_traits_purity_count
			}
		}
	}

	immediate = {
		carrier_event = { id = bio.5106 days = 5 }
	}
}

# Also triggered by on_colony_transfer
carrier_event = {
	id = bio.5106
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = owner
		owner = {
			is_purity_authority = yes
		}
		any_owned_species = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
			NOT = {
				is_variable_set = species_traits_purity_count
			}
		}
	}

	immediate = {
		every_owned_species = {
			limit = {
				NOT = {
					is_variable_set = species_traits_purity_count
				}
			}
			set_species_traits_purity_count_variable = yes
		}
	}
}

# Triggered by on_modification_complete
# This = Country
# From = Species ( Post Modification )
country_event = {
	id = bio.5107
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		is_purity_authority = yes
		from = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
		}
	}

	immediate = {
		from = {
			set_species_traits_purity_count_variable = yes
		}
	}
}

# Triggered by on_monthly_pulse_country
country_event = {
	id = bio.5108
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		is_purity_authority = yes
		any_owned_species = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
			NOT = {
				is_variable_set = species_traits_purity_count
			}
		}
	}

	immediate = {
		every_owned_species = {
			limit = {
				NOT = {
					is_variable_set = species_traits_purity_count
				}
			}
			set_species_traits_purity_count_variable = yes
		}
	}
}

# Assign EvoPred  variables

# Triggered by on_uplift_completion
# Scope = planet_event
# This = planet scope
# From = uplifted species (pre-modification)
carrier_event = {
	id = bio.5115
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = owner
		owner = {
			has_origin = origin_evolutionary_predators
			is_mutation_authority = yes
		}
		from = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
			NOT = {
				is_variable_set = species_traits_evopred_count
			}
		}
	}

	immediate = {
		carrier_event = { id = bio.5116 days = 5 }
	}
}

# Also triggered by on_colony_transfer
carrier_event = {
	id = bio.5116
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		exists = owner
		owner = {
			has_origin = origin_evolutionary_predators
			is_mutation_authority = yes
		}
		any_owned_species = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
			NOT = {
				is_variable_set = species_traits_evopred_count
			}
		}
	}

	immediate = {
		every_owned_species = {
			limit = {
				NOT = {
					is_variable_set = species_traits_evopred_count
				}
			}
			set_species_traits_evopred_count_variable = yes
		}
	}
}

# Triggered by on_modification_complete
# This = Country
# From = Species ( Post Modification )
country_event = {
	id = bio.5117
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_origin = origin_evolutionary_predators
		is_mutation_authority = yes
		from = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
		}
	}

	immediate = {
		from = {
			set_species_traits_evopred_count_variable = yes
		}
	}
}

# Triggered by on_monthly_pulse_country
country_event = {
	id = bio.5118
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		has_origin = origin_evolutionary_predators
		is_mutation_authority = yes
		any_owned_species = {
			OR = {
				is_archetype = PRESAPIENT
				is_archetype = BIOLOGICAL
				is_archetype = LITHOID
			}
			NOT = {
				is_variable_set = species_traits_evopred_count
			}
		}
	}

	immediate = {
		every_owned_species = {
			limit = {
				NOT = {
					is_variable_set = species_traits_evopred_count
				}
			}
			set_species_traits_evopred_count_variable = yes
		}
	}
}
