@base_moon_distance = 10

### FALLEN EMPIRE HOME SYSTEMS

# Home System I
fallen_1 = {
	usage = fallen_empire_init
	class = "rl_standard_stars"
	flags = { ancient_wonders_system }
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 1 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	planet = {
		name = "NAME_Great_Nexus"
		orbit_distance = 15
		class = pc_city
		orbit_angle = { min = 90 max = 270 }
		size = 20
		deposit_blockers = none
		modifiers = none
		has_ring = no

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 1 max = 1 }
			name = "NAME_Wanderer"
			class = pc_barren
			size = 8
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}

		init_effect = {
			create_cluster = {
				id = fe1_cluster
				radius = 120
				center = this.solar_system
			}

			set_planet_flag = fallen_empire_world
			set_planet_flag = fallen_empire_capital
			prevent_anomaly = yes
			set_owner = root
			set_controller = root
			set_capital = yes
			clear_deposits = yes
			while = {
				count = 7
				add_district = district_arcology_housing
			}
			while = {
				count = 4
				add_district = district_arcology_urban_1
			}
			while = {
				count = 4
				add_district = district_arcology_urban_2
			}
			while = {
				count = 4
				add_district = district_arcology_urban_3
			}
			while = {
				count = 94
				create_pop_group = {
					species = owner_main_species
				}
			}

			add_zone = {
				district = district_arcology_housing
				zone = zone_urban
			}
			add_zone = {
				district = district_arcology_housing
				zone = zone_urban
			}
			add_zone = {
				district = district_arcology_urban_1
				zone = zone_research_physics_arcology
			}
			add_zone = {
				district = district_arcology_urban_2
				zone = zone_research_society_arcology
			}
			add_zone = {
				district = district_arcology_urban_3
				zone = zone_research_engineering_arcology
			}

			root = {
				set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
					cooldown = no
				}
				set_policy = {
					policy = robot_pop_policy
					option = robot_pops_allowed
					cooldown = no
				}
			}
			root = { create_fe_servant_robots = yes }
			last_created_species = { save_event_target_as = fe_servants }
			while = {
				count = 94
				create_pop_group = {
					species = event_target:fe_servants
				}
			}
			create_fallen_empire_starting_navy = yes
			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "robotic_army"
				}
			}
			# Central City
			add_building = building_ancient_palace
			add_building = building_institute
			add_building = building_fe_market_2
			add_building = building_fe_stronghold
			add_building = building_fe_security_2
			add_building = building_dimensional_fabricator

			# Urban Expansion
			add_building = {
				zone = zone_urban
				building = building_dimensional_fabricator
			}
			add_building = {
				zone = zone_urban
				building = building_nano_forge
			}
			add_building = {
				zone = zone_urban
				building = building_affluence_center
			}
			# Urban Expansion
			add_building = {
				zone = zone_urban
				building = building_fe_dome
			}
			add_building = {
				zone = zone_urban
				building = building_nourishment_center
			}
			add_building = {
				zone = zone_urban
				building = building_class_4_singularity
			}
			# Physics Labs
			add_building = {
				zone = zone_research_physics_arcology
				building = building_physics_lab_3
			}
			add_building = {
				zone = zone_research_physics_arcology
				building = building_research_upkeep_1
			}
			# Engineering Labs
			add_building = {
				zone = zone_research_engineering_arcology
				building = building_engineering_facility_3
			}
			# Biology Labs
			add_building = {
				zone = zone_research_society_arcology
				building = building_biolab_3
			}
			add_building = {
				zone = zone_research_society_arcology
				building = building_research_efficiency_1
			}
		}
	}


	planet = {
		count = { min = 1 max = 1 }
		orbit_distance = 25
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 1 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 10
		}
	}


	planet = {
		count = { min = 1 max = 1 }
		orbit_distance = 35
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 2 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 10
		}
	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_1_2"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_2"
	}

	init_effect = {
		create_fe_home_citadel = yes
	}
}

fallen_1_2 = {
	usage = fallen_empire_init
	class = "rl_standard_stars"
	flags = { ancient_wonders_system }
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 120
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 40

	planet = {
		count = { min = 1 max = 1 }
		orbit_distance = 15
		class = pc_molten
		size = { min = 8 max = 16 }
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		name = "NAME_The_Archives"
		orbit_distance = 20
		class = pc_gaia
		orbit_angle = { min = 90 max = 270 }
		size = 15
		deposit_blockers = none
		modifiers = none
		has_ring = no

		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_MATERIALIST_Citadel_3"
			}
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = root
			set_controller = root

			inline_script = {
				script =  game_start/districts_standard_setup
				CITY = 12
				GENERATOR = 2
				MINING = 0
				FARMING = 0
			}

			add_zone = {
				district = district_city
				zone = zone_research_unity
			}
			add_zone = {
				district = district_city
				zone = zone_urban
			}
			while = {
				count = 35
				create_pop_group = {
					species = owner_main_species
				}
			}
			while = {
				count = 35
				create_pop_group = {
					species = event_target:fe_servants
				}
			}
			add_building = building_ancient_palace
			add_building = building_master_archive
			add_building = building_fe_stronghold
			add_building = building_fe_dome
			add_building = building_nourishment_center
			add_building = building_fe_market_2
			add_building = building_affluence_center
			add_building = building_dimensional_fabricator
			add_building = building_nano_forge

			add_building = {
				zone = zone_energy
				building = building_class_4_singularity
			}
			add_building = {
				zone = zone_energy
				building = building_energy_nexus
			}
			add_building = {
				zone = zone_research_unity
				building = building_fe_lab_2
			}
			add_building = {
				zone = zone_research_unity
				building = building_fe_administration_2
			}
		}
	}

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 1 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		create_fe_citadel = yes
	}
}

# Home System II
fallen_2 = {
	usage = fallen_empire_init
	class = "rl_standard_stars"
	flags = { ancient_wonders_system }
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 1 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		name = "NAME_Celestial_Throne"
		orbit_distance = 20
		class = pc_gaia
		orbit_angle = { min = 90 max = 270 }
		size = 30
		deposit_blockers = none
		modifiers = none

		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_SPIRITUALIST_Citadel_3"
			}
			create_cluster = {
				id = fe2_cluster
				radius = 140
				center = this.solar_system
			}

			set_planet_flag = fallen_empire_world
			set_planet_flag = fallen_empire_capital
			prevent_anomaly = yes
			set_owner = root
			set_controller = root
			set_capital = yes

			inline_script = {
				script =  game_start/districts_standard_setup
				CITY = 16
				GENERATOR = 2
				MINING = 6
				FARMING = 6
			}

			while = {
				count = 115
				create_pop_group = {
					species = owner_main_species
				}
			}
			create_fallen_empire_starting_navy = yes
			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "psionic_army"
				}
			}

			add_zone = {
				district = district_city
				zone = zone_unity_spiritualist
			}
			add_zone = {
				district = district_city
				zone = zone_fortress
			}
			inline_script = "game_start/fe_buildings_rural"

			add_building = building_ancient_palace
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_dimensional_fabricator
			add_building = building_fe_market_2
			add_building = building_nano_forge

			add_building = {
				zone = zone_unity_spiritualist
				building = building_fe_temple_2
			}
			add_building = {
				zone = zone_unity_spiritualist
				building = building_citadel_of_faith
			}
			add_building = {
				zone = zone_unity_spiritualist
				building = building_sacred_nexus
			}
			add_building = {
				zone = zone_fortress
				building = building_fe_stronghold
			}
			add_building = {
				zone = zone_fortress
				building = building_planetary_shield_generator
			}
		}

		change_orbit = @base_moon_distance

		moon = {
			name = "NAME_The_Mistake"
			class = "pc_broken"
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
			modifiers = none

			init_effect = { prevent_anomaly = yes }
		}
	}

	planet = {
		name = "NAME_Sky_Temple"
		orbit_distance = 30
		class = pc_gaia
		orbit_angle = { min = 90 max = 270 }
		size = 22
		deposit_blockers = none
		modifiers = none

		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_SPIRITUALIST_Citadel_3"
			}
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = root
			set_controller = root

			inline_script = {
				script =  game_start/districts_standard_setup
				CITY = 12
				GENERATOR = 2
				MINING = 5
				FARMING = 5
			}

			while = {
				count = 68
				create_pop_group = {
					species = owner_main_species
				}
			}

			add_zone = {
				district = district_city
				zone = zone_unity_spiritualist
			}
			add_zone = {
				district = district_city
				zone = zone_foundry
			}
			inline_script = "game_start/fe_buildings_rural"

			add_building = building_ancient_palace
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_stronghold
			add_building = building_fe_market_2

			add_building = {
				zone = zone_unity_spiritualist
				building = building_empyrean_shrine
			}
			add_building = {
				zone = zone_unity_spiritualist
				building = building_holotemple
			}
			add_building = {
				zone = zone_unity_spiritualist
				building = building_temple
			}

			add_building = {
				zone = zone_foundry
				building = building_nano_forge
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
		}
	}

	planet = {
		count = { min = 2 max = 4 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_2"
	}
	neighbor_system = {
		distance = { min = 30 max = 100 }
		initializer = "fallen_holy_01"
	}
	neighbor_system = {
		distance = { min = 50 max = 150 }
		initializer = "fallen_holy_02"
	}
	neighbor_system = {
		distance = { min = 80 max = 200 }
		initializer = "fallen_holy_03"
	}
	neighbor_system = {
		distance = { min = 120 max = 250 }
		initializer = "fallen_holy_04"
	}
	neighbor_system = {
		spawn_chance = 25
		distance = { min = 0 max = 30 }
		initializer = "fallen_shrouded"
	}

	init_effect = {
		create_fe_home_citadel = yes
	}
}

# Home System III
fallen_3 = {
	usage = fallen_empire_init
	class = "rl_standard_stars"
	flags = { ancient_wonders_system }
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 1 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	planet = {
		name = "NAME_Sky_Father"
		class = "pc_gas_giant"
		orbit_distance = 60
		orbit_angle = 200
		size = 30
		has_ring = no

		change_orbit = @base_moon_distance

		moon = {
			name = "NAME_Cradle"
			class = "pc_gaia"
			size = 20
			orbit_distance = 5
			orbit_angle = 20
			deposit_blockers = none
			modifiers = none

			init_effect = {

				create_cluster = {
					id = fe3_cluster
					radius = 120
					center = this.solar_system
				}

				set_planet_flag = fallen_empire_world
				set_planet_flag = fallen_empire_capital
				prevent_anomaly = yes
				set_owner = root
				set_controller = root
				set_capital = yes

				inline_script = {
					script =  game_start/districts_standard_setup
					CITY = 14
					GENERATOR = 2
					MINING = 2
					FARMING = 2
				}
				while = {
					count = 52
					create_pop_group = {
						species = owner_main_species
					}
				}
				root = {
					set_policy = {
						policy = artificial_intelligence_policy
						option = ai_outlawed
						cooldown = no
					}
					set_policy = {
						policy = robot_pop_policy
						option = robot_pops_allowed
						cooldown = no
					}
				}
				root = { create_fe_servant_robots = yes }
				last_created_species = { save_event_target_as = fe_servants }
				while = {
					count = 52
					create_pop_group = {
						species = event_target:fe_servants
					}
				}
				create_fallen_empire_starting_navy = yes

				while = {
					count = 20
					create_army = {
						name = random
						owner = root
						species = root
						type = "gene_warrior_army"
					}
				}

				add_zone = {
					district = district_city
					zone = zone_industrial
				}
				add_zone = {
					district = district_city
					zone = zone_fortress
				}
				inline_script = "game_start/fe_buildings_rural"

				add_building = building_ancient_palace
				add_building = building_fe_dome
				add_building = building_fe_administration_2
				add_building = building_fe_security_2
				add_building =building_fe_market_2

				add_building = {
					zone = zone_industrial
					building = building_nano_forge
				}
				add_building = {
					zone = zone_industrial
					building = building_affluence_center
				}
				add_building = {
					zone = zone_industrial
					building = building_dimensional_fabricator
				}
				add_building = {
					zone = zone_fortress
					building = building_fe_stronghold
				}
				add_building = {
					zone = zone_fortress
					building = building_planetary_shield_generator
				}
			}
		}

		moon = {
			name = "NAME_Sister"
			class = "pc_broken"
			size = 13
			orbit_distance = 5
			orbit_angle = 50

			init_effect = { prevent_anomaly = yes }
		}

		moon = {
			name = "NAME_Brother"
			class = "pc_gaia"
			size = 10
			orbit_distance = 8
			orbit_angle = 10
			deposit_blockers = none
			modifiers = none

			init_effect = {
				set_planet_flag = fallen_empire_world
				prevent_anomaly = yes
				set_owner = root
				set_controller = root

				while = {
					count = 9
					add_district = district_city
				}
				while = {
					count = 18
					create_pop_group = {
						species = owner_main_species
					}
				}
				while = {
					count = 18
					create_pop_group = {
						species = event_target:fe_servants
					}
				}

				add_zone = {
					district = district_city
					zone = zone_foundry
				}
				add_zone = {
					district = district_city
					zone = zone_fortress
				}

				add_building = building_ancient_palace
				add_building = building_affluence_center
				add_building = building_fe_market_2

				add_building = {
					zone = zone_foundry
					building = building_nano_forge
				}
				add_building = {
					zone = zone_foundry
					building = building_dimensional_fabricator
				}
				add_building = {
					zone = zone_foundry
					building = building_dimensional_fabricator
				}
				add_building = {
					zone = zone_fortress
					building = building_fe_stronghold
				}
				add_building = {
					zone = zone_fortress
					building = building_planetary_shield_generator
				}
			}
		}

		moon = {
			name = "NAME_Mother"
			class = "pc_gaia"
			size = 14
			orbit_distance = 5
			orbit_angle = 190
			deposit_blockers = none
			modifiers = none

			init_effect = {
				set_planet_flag = fallen_empire_world
				prevent_anomaly = yes
				set_owner = root
				set_controller = root

				inline_script = {
					script =  game_start/districts_standard_setup
					CITY = 8
					GENERATOR = 2
					MINING = 2
					FARMING = 2
				}
				while = {
					count = 27
					create_pop_group = {
						species = owner_main_species
					}
				}
				while = {
					count = 27
					create_pop_group = {
						species = event_target:fe_servants
					}
				}
				add_zone = {
					district = district_city
					zone = zone_urban
				}
				add_zone = {
					district = district_city
					zone = zone_factory
				}
				inline_script = "game_start/fe_buildings_rural"

				add_building = building_ancient_palace
				add_building = building_fe_stronghold
				add_building = building_fe_dome

				add_building = {
					zone = zone_urban
					building = building_fe_market_2
				}
				add_building = {
					zone = zone_urban
					building = building_fe_clinic_2
				}
				add_building = {
					zone = zone_urban
					building = building_dimensional_fabricator
				}
				add_building = {
					zone = zone_factory
					building = building_affluence_center
				}
			}
		}
	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_xeno_zoo"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_2"
	}

	init_effect = {
		create_fe_home_citadel = yes
	}
}

# Home System IV
fallen_4 = {
	usage = fallen_empire_init
	class = "rl_standard_stars"
	flags = { ancient_wonders_system }
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 0 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	planet = {
		count = { min = 0 max = 3 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		name = "NAME_The_Core"
		orbit_distance = 20
		class = pc_gaia
		orbit_angle = { min = 90 max = 270 }
		size = 25
		deposit_blockers = none
		modifiers = none
		has_ring = no

		init_effect = {
			create_cluster = {
				id = fe4_cluster
				radius = 100
				center = this.solar_system
			}

			set_planet_flag = fallen_empire_world
			set_planet_flag = fallen_empire_capital
			set_planet_flag = xenophobe_fe_capital
			prevent_anomaly = yes
			set_owner = root
			set_controller = root
			set_capital = yes

			inline_script = {
				script =  game_start/districts_standard_setup
				CITY = 19
				GENERATOR = 2
				MINING = 2
				FARMING = 2
			}
			while = {
				count = 62
				create_pop_group = {
					species = owner_main_species
				}
			}
			root = { create_fe_servant_species = yes }
			last_created_species = { save_event_target_as = fe_servants }
			while = {
				count = 62
				create_pop_group = {
					species = event_target:fe_servants
				}
			}
			create_fallen_empire_starting_navy = yes

			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "xenomorph_army"
				}
			}

			add_zone = {
				district = district_city
				zone = zone_foundry
			}
			add_zone = {
				district = district_city
				zone = zone_fortress
			}
			inline_script = "game_start/fe_buildings_rural"

			add_building = building_ancient_palace
			add_building = building_affluence_center
			add_building = building_fe_security_2

			add_building = {
				zone = zone_foundry
				building = building_nano_forge
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
			add_building = {
				zone = zone_fortress
				building = building_fe_stronghold
			}
			add_building = {
				zone = zone_fortress
				building = building_planetary_shield_generator
			}
		}

		moon = {
			name = "NAME_Boundary"
			class = "pc_gaia"
			size = 14
			orbit_distance = 14
			orbit_angle = 10
			deposit_blockers = none
			modifiers = none

			init_effect = {
				set_planet_flag = fallen_empire_world
				prevent_anomaly = yes
				set_owner = root
				set_controller = root

				inline_script = {
					script =  game_start/districts_standard_setup
					CITY = 8
					GENERATOR = 2
					MINING = 2
					FARMING = 2
				}
				while = {
					count = 33
					create_pop_group = {
						species = owner_main_species
					}
				}
				while = {
					count = 33
					create_pop_group = {
						species = event_target:fe_servants
					}
				}
				add_zone = {
					district = district_city
					zone = zone_foundry
				}
				add_zone = {
					district = district_city
					zone = zone_fortress
				}
				inline_script = "game_start/fe_buildings_rural"

				add_building = building_ancient_palace
				add_building = building_affluence_center
				add_building = building_fe_security_2
				add_building = building_fe_administration_2

				add_building = {
					zone = zone_foundry
					building = building_nano_forge
				}
				add_building = {
					zone = zone_foundry
					building = building_dimensional_fabricator
				}
				add_building = {
					zone = zone_fortress
					building = building_fe_stronghold
				}
				add_building = {
					zone = zone_fortress
					building = building_planetary_shield_generator
				}
			}
		}
	}

	planet = {
		count = { min = 2 max = 4 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_orbitals_2"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_shielded_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_shielded_2"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_shielded_3"
	}

	init_effect = {
		create_fe_home_citadel = yes
	}
}

### STANDARD FALLEN EMPIRE SYSTEMS

fallen_col_1 = {
	class = "rl_standard_stars"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 1 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	change_orbit = 10

	planet = {
		count = 1
		orbit_distance = 20
		home_planet = yes
		class = ideal_planet_class
		orbit_angle = { min = 90 max = 270 }
		size = 16
		deposit_blockers = none
		modifiers = none

		init_effect = {
			if = {
				limit = { root = { is_fallen_empire_spiritualist = no } }
				create_fe_fringe_colony = yes
			}
			else = { create_fe_spiritualist_fringe_colony = yes }
		}

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 2 max = 4 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		create_fe_citadel = yes
	}
}

fallen_col_2 = {
	class = "rl_standard_stars"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 115
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 60

	planet = {
		count = 1
		home_planet = yes
		class = ideal_planet_class
		orbit_distance = 0
		orbit_angle = { min = 90 max = 270 }
		size = { min = 16 max = 16 }
		deposit_blockers = none
		modifiers = none

		init_effect = {
			if = {
				limit = { root = { is_fallen_empire_spiritualist = no } }
				create_fe_fringe_colony = yes
			}
			else = { create_fe_spiritualist_fringe_colony = yes }
		}

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = 2
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	change_orbit = 15

	planet = {
		count = { min = 2 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 110 }
	}

	planet = {
		count = { min = 2 max = 4 }
		orbit_distance = 25
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		create_fe_citadel = yes
	}
}


fallen_orbitals_1 = {
	class = "rl_standard_stars"

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 45

	planet = {
		count = { min = 2 max = 10 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		random_system_planet = {
			limit = {
				is_ideal_planet_class = {
					who = ROOT
					status = yes
				}
				is_colony = no
			}
			if = {
				limit = { root = { is_fallen_empire_spiritualist = no } }
				create_fe_fringe_colony = yes
			}
			else = { create_fe_spiritualist_fringe_colony = yes }
		}

		if = {
			limit = {
				any_system_planet = {
					is_owned_by = root
				}
			}
			create_fe_citadel = yes
			else = {
				create_fe_outpost = yes
			}
		}

	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_col_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_col_2"
	}
}

fallen_orbitals_2 = {
	class = "rl_standard_stars"

	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 95
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 30

	planet = {
		count = 2
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 25

	planet = {
		count = { min = 1 max = 4 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = { min = 2 max = 5 }
		orbit_distance = 25
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		random_system_planet = {
			limit = {
				is_ideal_planet_class = {
					who = ROOT
					status = yes
				}
				is_colony = no
			}
			if = {
				limit = { root = { is_fallen_empire_spiritualist = no } }
				create_fe_fringe_colony = yes
			}
			else = { create_fe_spiritualist_fringe_colony = yes }
		}

		if = {
			limit = {
				any_system_planet = {
					is_owned_by = root
				}
			}
			create_fe_citadel = yes
		}
		else = {
			create_fe_outpost = yes
		}
	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_col_1"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_col_2"
	}
}

### SPECIAL FALLEN EMPIRE SYSTEMS


# Shrouded Planet
fallen_shrouded = {
	class = sc_black_hole
	flags = { fallen_shrouded }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 35

	planet = {
		count = 1
		orbit_distance = 15
		class = pc_barren_cold
		size = 15
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = 1
		orbit_distance = 30
		class = pc_shrouded
		name = "NAME_Apostasy"
		orbit_angle = { min = 90 max = 270 }
		size = 22
		modifiers = none
	}

	planet = {
		count = 1
		orbit_distance = 40
		size = 12
		class = pc_frozen
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = 1
		orbit_distance = 25
		class = pc_frozen
		orbit_angle = { min = 90 max = 270 }
		size = 25
		change_orbit = @base_moon_distance

		moon = {
			count = 1
			class = pc_barren_cold
			size = 7
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}

	}

	init_effect = {
		every_system_planet = {
			clear_deposits = yes
		}

		create_fe_outpost = yes
	}
}


# Shielded Planet 1
fallen_shielded_1 = {
	class = "rl_standard_stars"
	flags = { fallen_shielded_1 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 35

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 15
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = 1
		orbit_distance = 20
		class = rl_habitable_normal
		orbit_angle = { min = 90 max = 270 }
		size = 16
		modifiers = none
		flags = { fallen_shield_world }

		init_effect = {
			prevent_anomaly = yes
			change_pc = {
				class = pc_shielded
				inherit_entity = yes
			}
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_XENOPHOBE_Citadel_3"
			}
		}

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 25
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 1 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 0 max = 1 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		create_fe_outpost = yes
	}
}

# Shielded Planet 2
fallen_shielded_2 = {
	class = "rl_standard_stars"
	flags = { fallen_shielded_2 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 35

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 15
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = 1
		orbit_distance = 20
		class = rl_habitable_normal
		orbit_angle = { min = 90 max = 270 }
		size = 16
		modifiers = none
		flags = { fallen_shield_world }

		init_effect = {
			prevent_anomaly = yes
			change_pc = {
				class = pc_shielded
				inherit_entity = yes
			}
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_XENOPHOBE_Citadel_3"
			}
		}

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 25
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 1 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 0 max = 1 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		create_fe_outpost = yes
	}
}

# Shielded Planet 3
fallen_shielded_3 = {
	class = "rl_standard_stars"

	flags = { fallen_shielded_3 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 35

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 15
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = 1
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
		size = 16
		modifiers = none
		flags = { fallen_shield_world }

		init_effect = {
			prevent_anomaly = yes
			change_pc = {
				class = pc_shielded
				inherit_entity = yes
			}
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_XENOPHOBE_Citadel_3"
			}
		}

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 25
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 1 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 0 max = 1 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		create_fe_outpost = yes
	}
}

# Fallen Empire's Holy World 1
fallen_holy_01 = {
	class = "rl_standard_stars"

	flags = { holy_system_1 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 45

	planet = {
		count = 1
		orbit_distance = 30
		class = "pc_gaia"
		orbit_angle = { min = 90 max = 270 }
		size = 18
		name = "NAME_Walled_Garden"
		deposit_blockers = none
		flags = { holy_world_1 }

		init_effect = {
			prevent_anomaly = yes
			add_modifier = {
				modifier = "holy_planet"
				days = -1
			}
			create_ambient_object = {
				type = consecrated_planet_stage_3_object
				location = this

				use_3d_location = yes
				entity_scale_to_size = yes
			}
		}
	}

	planet = {
		count = { min = 2 max = 10 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		random_list = { # 30% chance outpost is "broken"
			30 = {
				random_system_planet = {
					limit = { is_star = yes }
					create_broken_fe_outpost = yes
				}
			}
			70 = {}
		}
	}
}

# Fallen Empire's Holy World 2
fallen_holy_02 = {
	class = "rl_standard_stars"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 95
	}

	flags = { holy_system_2 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 30

	planet = {
		count = 2
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 25

	planet = {
		count = { min = 1 max = 4 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		count = 1
		orbit_distance = 25
		class = "pc_gaia"
		orbit_angle = { min = 90 max = 270 }
		size = 14
		name = "NAME_Emerald_Mausoleum"
		deposit_blockers = none
		flags = { holy_world_2 }

		init_effect = {
			prevent_anomaly = yes
			add_modifier = {
				modifier = "holy_planet"
				days = -1
			}
			create_ambient_object = {
				type = consecrated_planet_stage_3_object
				location = this

				use_3d_location = yes
				entity_scale_to_size = yes
			}
		}
	}

	planet = {
		count = { min = 2 max = 5 }
		orbit_distance = 30
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		random_list = { # 30% chance outpost is "broken"
			30 = {
				random_system_planet = {
					limit = { is_star = yes }
					create_broken_fe_outpost = yes
				}
			}
			70 = {}
		}
	}
}

# Fallen Empire's Holy World 3
fallen_holy_03 = {
	class = "rl_standard_stars"

	flags = { holy_system_3 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 45

	planet = {
		count = 1
		orbit_distance = 10
		class = "pc_gaia"
		name = "NAME_Pristine_Jewel"
		deposit_blockers = none
		orbit_angle = { min = 90 max = 270 }
		flags = { holy_world_3 }
		size = 10

		init_effect = {
			prevent_anomaly = yes
			add_modifier = {
				modifier = "holy_planet"
				days = -1
			}
			create_ambient_object = {
				type = consecrated_planet_stage_3_object
				location = this

				use_3d_location = yes
				entity_scale_to_size = yes
			}
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 60
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }
		size = 25

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 1 max = 4 }
			size = { min = 8 max = 20 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 6
		}
	}

	change_orbit = 20

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		random_list = { # 30% chance outpost is "broken"
			30 = {
				random_system_planet = {
					limit = { is_star = yes }
					create_broken_fe_outpost = yes
				}
			}
			70 = {}
		}
	}
}

# Fallen Empire's Holy World 4
fallen_holy_04 = {
	class = "rl_standard_stars"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 120
	}

	flags = { holy_system_4 }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 150

	planet = {
		count = 1
		orbit_distance = 10
		class = "pc_gaia"
		name = "NAME_Prophets_Retreat"
		deposit_blockers = none
		orbit_angle = { min = 90 max = 270 }
		flags = { holy_world_4 }
		size = 25

		init_effect = {
			prevent_anomaly = yes
			add_modifier = {
				modifier = "holy_planet"
				days = -1
			}
			create_ambient_object = {
				type = consecrated_planet_stage_3_object
				location = this

				use_3d_location = yes
				entity_scale_to_size = yes
			}
		}
	}

	change_orbit = -110

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 110

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 40
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		random_list = { # 30% chance outpost is "broken"
			30 = {
				random_system_planet = {
					limit = { is_star = yes }
					create_broken_fe_outpost = yes
				}
			}
			70 = {}
		}
	}
}

# Fallen Empire Xeno Zoo
fallen_xeno_zoo = {
	class = "rl_standard_stars"
	flags = { ancient_wonders_system }
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 80
	}

	flags = { fe_xeno_zoo }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 70

	planet = {
		count = 1
		orbit_distance = 15
		class = "pc_gaia"
		name = "NAME_The_Preserve"
		orbit_angle = { min = 90 max = 270 }
		size = 20

		orbit_angle = 60
		orbit_distance = 0
		deposit_blockers = none
		modifiers = none

		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_XENOPHILE_Citadel_3"
			}
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = ROOT
			if = {
				limit = {
					NOT = { has_deposit = d_alien_pets_deposit }
				}
				add_deposit = d_alien_pets_deposit
			}
			set_carrier_flag = fe_the_preserve

			add_building = building_fe_xeno_zoo
			add_building = building_xeno_zoo

			add_zone = {
				district = district_city
				zone = zone_research_society
			}
			add_zone = {
				district = district_city
				zone = zone_research_society
			}
			add_building = {
				zone = zone_research_society
				building = building_xeno_zoo
			}

			while = {
				count = 6
				create_pop_group = {
					species = owner_main_species
				}
			}

			while = {
				count = 5
				create_species = {
					name = random
					class = random_non_machine
					portrait = random
					traits = random
				}
				create_pop_group = {
					species = last_created_species
				}
			}
		}
	}

	change_orbit = -45

	planet = {
		count = { min = 1 max = 1 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
	}

	init_effect = {
		create_fe_citadel = yes
	}
}

# Home System - Machine
fallen_machine = {
	usage = fallen_empire_init
	name = "NAME_Alpha_Refuge"
	class = "rl_standard_stars"

	flags = { ring_world_built ancient_wonders_system }

	init_effect = {
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = -90
			orbit_distance = 45
		}

		create_fe_citadel = yes
	}

	planet = {
		class = star
		orbit_distance = 0
		orbit_angle = 0
	}

	change_orbit = 45

	planet = {
		class = "pc_ringworld_tech"
		name = "NAME_Circuit_I"
		orbit_angle = -30
		orbit_distance = 0
	}

	planet = {
		class = "pc_ringworld_seam"
		name = "NAME_Superstructure_I"
		orbit_angle = 30
		orbit_distance = 0
		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_MACHINE_Citadel_3"
			}
		}
	}

	planet = {
		class = "pc_ringworld_habitable"
		name = "NAME_Alpha_Complex"
		orbit_angle = 30
		orbit_distance = 0
		deposit_blockers = none
		modifiers = none

		init_effect = {

			create_cluster = {
				id = fe_mach_cluster
				radius = 80
				center = this.solar_system
			}

			set_planet_flag = fallen_empire_world
			set_planet_flag = fallen_empire_capital
			prevent_anomaly = yes
			set_owner = root
			set_controller = root
			set_capital = yes

			while = {
				count = 3
				add_district = district_rw_nexus
			}

			while = {
				count = 4
				add_district = district_rw_urban_1
			}
			while = {
				count = 2
				add_district = district_rw_urban_2
			}

			add_zone = {
				district = district_rw_urban_1
				zone = zone_energy_ring_world
			}
			add_zone = {
				district = district_rw_urban_2
				zone = zone_food_ring_world
			}

			while = {
				count = 105
				create_pop_group = {
					species = owner_main_species
				}
			}
			create_fallen_empire_starting_navy = yes

			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "machine_assault_2"
				}
			}

			add_building = building_ancient_control_center
			add_building = building_fe_assembly_2
			add_building = building_ancient_cryo_chamber
			add_building = building_fe_stronghold
			add_building = building_fe_administration_machine_2
			add_building = building_fe_lab_2
			add_building = building_nano_forge
			add_building = building_dimensional_fabricator

			add_building = {
				zone = zone_energy_ring_world
				building = building_class_4_singularity
			}
			add_building = {
				zone = zone_energy_ring_world
				building = building_energy_nexus
			}
			add_building = {
				zone = zone_food_ring_world
				building = building_nourishment_center
			}
			add_building = {
				zone = zone_food_ring_world
				building = building_food_processing_center
			}
		}
	}

	planet = {
		class = "pc_ringworld_tech"
		name = "NAME_Circuit_II"
		orbit_angle = 30
		orbit_distance = 0
	}

	planet = {
		class = "pc_ringworld_seam"
		name = "NAME_Superstructure_II"
		orbit_angle = 30
		orbit_distance = 0
		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_MACHINE_Citadel_3"
			}
		}
	}

	planet = {
		class = "pc_ringworld_habitable"
		name = "NAME_Production_Unit"
		orbit_angle = 30
		orbit_distance = 0
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = ROOT

			while = {
				count = 7
				add_district = district_rw_nexus
			}
			while = {
				count = 1
				add_district = district_rw_urban_1
			}
			while = {
				count = 50
				create_pop_group = {
					species = owner_main_species
				}
			}

			add_zone = {
				district = district_rw_nexus
				zone = zone_foundry
				zone_slot = 1
				replace = yes
			}
			add_zone = {
				district = district_rw_nexus
				zone = zone_foundry
				zone_slot = 2
				replace = yes
			}
			add_zone = {
				district = district_rw_urban_1
				zone = zone_trade_ring_world
			}

			add_building = building_ancient_control_center
			add_building = building_fe_administration_machine_2
			add_building = building_fe_assembly_2

			add_building = {
				zone = zone_foundry
				building = building_nano_forge
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
			add_building = {
				zone = zone_foundry
				building = building_dimensional_fabricator
			}
		}
	}

	planet = {
		class = "pc_ringworld_tech"
		name = "NAME_Circuit_III"
		orbit_angle = 30
		orbit_distance = 0
	}

	planet = {
		class = "pc_ringworld_seam"
		name = "NAME_Superstructure_III"
		orbit_angle = 30
		orbit_distance = 0
		init_effect = {
			create_fe_dsc = {
				OWNER = root
				DESIGN = "NAME_FE_MACHINE_Citadel_3"
			}
		}
	}

	planet = {
		class = "pc_ringworld_habitable"
		name = "NAME_Processing_Unit"
		orbit_angle = 30
		orbit_distance = 0
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = ROOT

			while = {
				count = 1
				add_district = district_rw_nexus
			}
			while = {
				count = 5
				add_district = district_rw_urban_1
			}
			while = {
				count = 3
				add_district = district_rw_urban_2
			}

			while = {
				count = 22
				create_pop_group = {
					species = owner_main_species
				}
			}
			add_zone = {
				district = district_rw_urban_1
				zone = zone_energy_ring_world
			}
			add_zone = {
				district = district_rw_urban_2
				zone = zone_trade_ring_world
			}
			add_building = building_ancient_control_center
			add_building = building_fe_assembly_2
			add_building = building_fe_administration_machine_2

			add_building = {
				zone = zone_trade_ring_world
				building = building_fe_market_2
			}

			add_building = {
				zone = zone_energy_ring_world
				building = building_class_4_singularity
			}
			add_building = {
				zone = zone_energy_ring_world
				building = building_energy_nexus
			}
		}
	}

	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_machine_2"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_machine_3"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_machine_4"
	}
	neighbor_system = {
		distance = { min = 0 max = 50 }
		initializer = "fallen_machine_5"
	}
}

fallen_machine_2 = {
	class = "rl_standard_stars"
	name = "NAME_Beta_Refuge"

	planet = {
		class = star
		orbit_distance = 0

		init_effect = {
			while = {
				count = 4
				create_ambient_object = {
					type = "large_debris_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 2
				create_ambient_object = {
					type = "medium_debris_01_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 2
				create_ambient_object = {
					type = "medium_debris_02_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			create_ambient_object = {
				type = "small_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 45
					angle = random
				}
			}
		}
	}

	change_orbit = 45

	init_effect = {
		every_system_planet = {
			clear_deposits = yes
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 0
			orbit_distance = 45
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 180
			orbit_distance = 45
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 270
			orbit_distance = 45
		}

		while = {
			count = 3
			create_ambient_object = {
				type = "large_debris_object"
				location = solar_system
			}
		}
		while = {
			count = 2
			create_ambient_object = {
				type = "medium_debris_01_object"
				location = solar_system
			}
		}
		while = {
			count = 2
			create_ambient_object = {
				type = "medium_debris_02_object"
				location = solar_system
			}
		}
		create_ambient_object = {
			type = "small_debris_object"
			location = solar_system
		}

		create_fe_outpost = yes
	}

	planet = {
		class = "pc_shattered_ring_habitable"
		name = "NAME_Data_Corrupted"
		orbit_angle = 240
		orbit_distance = 0
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = ROOT

			while = {
				count = 10
				create_pop_group = {
					species = owner_main_species
				}
			}

			while = {
				count = 2
				add_district = district_nexus
			}
			while = {
				count = 15
				add_district = district_mining
			}
			add_zone = {
				district = district_mining
				zone = zone_minerals
			}

			add_building = building_ancient_control_center
			add_building = {
				zone = zone_minerals
				building = building_fe_mine_2
			}
			add_building = {
				zone = zone_minerals
				building = building_mineral_purification_hub
			}

			add_deposit = d_segment_rubble_1
			add_deposit = d_segment_rubble_2
			add_deposit = d_segment_rubble_3
			add_deposit = d_segment_rubble_4
		}
	}
	planet = {
		class = "pc_ringworld_seam_damaged"
		name = "NAME_Ring_Section"
		orbit_angle = -30
		orbit_distance = 0
	}
	planet = {
		class = "pc_ringworld_seam_damaged"
		name = "NAME_Ring_Section"
		orbit_angle = 60
		orbit_distance = 0
	}
}


fallen_machine_3 = {
	class = "rl_standard_stars"
	name = "NAME_Gamma_Refuge"

	planet = {
		class = star
		orbit_distance = 0

		init_effect = {

			while = {
				count = 4
				create_ambient_object = {
					type = "large_debris_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 2
				create_ambient_object = {
					type = "medium_debris_01_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 2
				create_ambient_object = {
					type = "medium_debris_02_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			create_ambient_object = {
				type = "small_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 45
					angle = random
				}
			}
		}
	}

	change_orbit = 45

	init_effect = {
		every_system_planet = {
			clear_deposits = yes
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 0
			orbit_distance = 45
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 90
			orbit_distance = 45
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 180
			orbit_distance = 45
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 270
			orbit_distance = 45
		}

		while = {
			count = 3
			create_ambient_object = {
				type = "large_debris_object"
				location = solar_system
			}
		}
		while = {
			count = 2
			create_ambient_object = {
				type = "medium_debris_01_object"
				location = solar_system
			}
		}
		while = {
			count = 2
			create_ambient_object = {
				type = "medium_debris_02_object"
				location = solar_system
			}
		}
		create_ambient_object = {
			type = "small_debris_object"
			location = solar_system
		}

		create_fe_outpost = yes
	}

	change_orbit = 45
}

fallen_machine_4 = {
	class = "rl_standard_stars"
	name = "NAME_Delta_Refuge"

	planet = {
		class = star
		orbit_distance = 0

		init_effect = {
			while = {
				count = 15
				create_ambient_object = {
					type = "large_debris_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 25
				create_ambient_object = {
					type = "medium_debris_01_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 25
				create_ambient_object = {
					type = "medium_debris_02_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 30
				create_ambient_object = {
					type = "small_debris_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
		}
	}

	change_orbit = 45

	init_effect = {
		every_system_planet = {
			clear_deposits = yes
		}
		while = {
			count = 15
			create_ambient_object = {
				type = "large_debris_object"
				location = solar_system
			}
		}
		while = {
			count = 25
			create_ambient_object = {
				type = "medium_debris_01_object"
				location = solar_system
			}
		}
		while = {
			count = 25
			create_ambient_object = {
				type = "medium_debris_02_object"
				location = solar_system
			}
		}
		while = {
			count = 30
			create_ambient_object = {
				type = "small_debris_object"
				location = solar_system
			}
		}

		create_fe_outpost = yes
	}
}

# Custodian Nexus
fallen_machine_5 = {
	class = sc_black_hole

	name = "NAME_Custodian_Nexus"

	planet = {
		class = star
		orbit_distance = 0

		init_effect = {
			while = {
				count = 30
				create_ambient_object = {
					type = "large_debris_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 50
				create_ambient_object = {
					type = "medium_debris_01_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 50
				create_ambient_object = {
					type = "medium_debris_02_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
			while = {
				count = 100
				create_ambient_object = {
					type = "small_debris_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 45
						angle = random
					}
				}
			}
		}
	}

	change_orbit = 45

	init_effect = {
		every_system_planet = {
			clear_deposits = yes
		}
		while = {
			count = 30
			create_ambient_object = {
				type = "large_debris_object"
				location = solar_system
			}
		}
		while = {
			count = 50
			create_ambient_object = {
				type = "medium_debris_01_object"
				location = solar_system
			}
		}
		while = {
			count = 50
			create_ambient_object = {
				type = "medium_debris_02_object"
				location = solar_system
			}
		}
		while = {
			count = 100
			create_ambient_object = {
				type = "small_debris_object"
				location = solar_system
			}
		}

		create_fe_outpost = yes
	}
}

# Home System - Hive - Last Thought

fallen_hive_last_thought = {
	class = "sc_binary_7"
	name = "NAME_Last_Thought"
	asteroid_belt = {
		type = space_fauna_belt
		radius = 130
	}
	asteroid_belt = {
		type = space_fauna_belt
		radius = 245
	}

	flags = { last_thought_system }

	planet = {
		count = 1
		class = star
		orbit_distance = 50
		orbit_angle = 30
		size = { min = 15 max = 20 }
		has_ring = no
		init_effect = {
			create_cluster = {
				id = fe_hive_cluster
				radius = 80
				center = this.solar_system
			}
			create_country = {
				name = "NAME_Primal_Mind"
				type = primal_mind
				flag = {
					icon = {
						category= "plantoid"
						file= "plantoid_07.dds"
					}
					background = {
						category= "backgrounds"
						file= "flag_BG_39.dds"
					}
					colors = {
						"dark_red"
						"intense_orange"
						"black"
						"null"
					}
				}
				effect = {
					save_global_event_target_as = fallen_empire_hive_forgotten
					every_country = {
						limit = {
							is_fallen_empire = yes
							is_hive_empire = yes
						}
						set_faction_hostility = {
							set_hostile = no
							set_friendly = yes
							target = event_target:fallen_empire_hive_forgotten
						}
					}
				}
			}
			if = {
				limit = {
					has_leviathans = yes
				}
				create_fleet = {
					name = "NAME_Primal_Wrath"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						create_ship = {
							design = "NAME_Great_Dragon"
						}
						set_location = {
							target = prev
							distance = 20
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
					}
				}
			}
			else = {
				create_fleet = {
					name = "NAME_Primal_Swarm"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						while = {
							count = 12
							create_ship = {
								name = ""
								design = "NAME_Large_Space_Organism_Zebra"
							}
						}
						while = {
							count = 6
							create_ship = {
								name = ""
								design = "NAME_Small_Space_Organism_Zebra"
							}
						}
						while = {
							count = 2
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
						}
						set_location = {
							target = prev
							distance = 12
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
					}
				}
			}
		}
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 180
		size = { min = 10 max = 15 }
		has_ring = no
		flags = { forgotten_patrol_target_2 }

		init_effect = {
			create_fleet = {
				name = "NAME_Primal_Swarm"
				effect = {
					set_owner = event_target:fallen_empire_hive_forgotten
					while = {
						count = 12
						create_ship = {
							name = ""
							design = "NAME_Large_Space_Organism_Zebra"
						}
					}
					while = {
						count = 6
						create_ship = {
							name = ""
							design = "NAME_Small_Space_Organism_Zebra"
						}
					}
					while = {
						count = 2
						create_ship = {
							design = "NAME_Tiyanki_Cow"
						}
						create_ship = {
							design = "NAME_Tiyanki_Bull"
						}
						create_ship = {
							design = "NAME_Tiyanki_Cow"
						}
						create_ship = {
							design = "NAME_Tiyanki_Bull"
						}
						create_ship = {
							design = "NAME_Tiyanki_Calf"
						}
						create_ship = {
							design = "NAME_Tiyanki_Calf"
						}
						create_ship = {
							design = "NAME_Tiyanki_Hatchling"
						}
						create_ship = {
							design = "NAME_Tiyanki_Hatchling"
						}
					}
					set_location = {
						target = prev
						distance = 12
						angle = 0
					}
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 200
					queue_actions = {
						repeat = {
							find_closest_planet = {
								trigger = {
									id = forgot.patrol.1
									has_planet_flag = forgotten_patrol_target_1
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 120
									}
								}
							}
							find_closest_planet  = {
								trigger = {
									id = forgot.patrol.2
									has_planet_flag = forgotten_patrol_target_2
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 120
									}
								}
							}
							find_closest_planet  = {
								trigger = {
									id = forgot.patrol.3
									has_planet_flag = forgotten_patrol_target_3
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 120
									}
								}
							}
						}
					}
				}
			}
		}
	}

	planet = {
		count = 1
		orbit_distance = -49
		class = "pc_infested"
		size = 45
		flags = { forgotten_patrol_target_B }
		init_effect = {
			clear_deposits = yes
			while = {
				count = 10
				create_ambient_object = {
					type = "small_dead_tiyanki_object"
					entity_offset_height = { min = -0 max = -25 }
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 5
						angle = random
					}
				}
			}
			create_ambient_object = {
				type = "elderly_tiyanki_dead_object_no_name"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = random
				}
			}
			create_archaeological_site = last_thought_site
		}
	}

	change_orbit = 75

	planet = {
		count = { min = 1 max = 1 }
		orbit_distance = 25
		class = pc_gas_giant
		orbit_angle = 230

		flags = { forgotten_patrol_target_C }

		change_orbit = @base_moon_distance

		init_effect = {
			if = {
				limit = {
					has_grand_archive_dlc = yes
				}
				create_fleet = {
					name = "NAME_Primal_Pack"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Nymph"
						}
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Nymph"
						}
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Nymph"
						}
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Nymph"
						}
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Juvenile"
						}
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Juvenile"
						}
						create_ship = {
							name = ""
							design = "NAME_Voidworms_Mature"
						}
						create_ship = {
							name = ""
							design = "NAME_Cutholoids_Hatchling"
						}
						create_ship = {
							name = ""
							design = "NAME_Cutholoids_Hatchling"
						}
						create_ship = {
							name = ""
							design = "NAME_Cutholoids_Juvenile"
						}
						set_location = {
							target = prev
							distance = 12
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
						queue_actions = {
							repeat = {
								find_closest_planet = {
									trigger = {
										id = forgot.patrol.A
										has_planet_flag = forgotten_patrol_target_A
									}
									found_planet = {
										move_to = this
										orbit_planet = this
										wait = {
											duration = 120
										}
									}
								}
								find_closest_planet  = {
									trigger = {
										id = forgot.patrol.B
										has_planet_flag = forgotten_patrol_target_B
									}
									found_planet = {
										move_to = this
										orbit_planet = this
										wait = {
											duration = 120
										}
									}
								}
								find_closest_planet  = {
									trigger = {
										id = forgot.patrol.C
										has_planet_flag = forgotten_patrol_target_C
									}
									found_planet = {
										move_to = this
										orbit_planet = this
										wait = {
											duration = 120
										}
									}
								}
							}
						}
					}
				}
			}
			else = {
				create_fleet = {
					name = "NAME_Primal_Swarm"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						while = {
							count = 12
							create_ship = {
								name = ""
								design = "NAME_Large_Space_Organism_Zebra"
							}
						}
						while = {
							count = 6
							create_ship = {
								name = ""
								design = "NAME_Small_Space_Organism_Zebra"
							}
						}
						while = {
							count = 2
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
						}
						set_location = {
							target = prev
							distance = 12
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
						queue_actions = {
							repeat = {
								find_closest_planet = {
									trigger = {
										id = forgot.patrol.Aa
										has_planet_flag = forgotten_patrol_target_A
									}
									found_planet = {
										move_to = this
										orbit_planet = this
										wait = {
											duration = 120
										}
									}
								}
								find_closest_planet  = {
									trigger = {
										id = forgot.patrol.Ba
										has_planet_flag = forgotten_patrol_target_B
									}
									found_planet = {
										move_to = this
										orbit_planet = this
										wait = {
											duration = 120
										}
									}
								}
								find_closest_planet  = {
									trigger = {
										id = forgot.patrol.Ca
										has_planet_flag = forgotten_patrol_target_C
									}
									found_planet = {
										move_to = this
										orbit_planet = this
										wait = {
											duration = 120
										}
									}
								}
							}
						}
					}
				}
			}
		}

		moon = {
			count = { min = 1 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 10
		}
	}

	change_orbit = 50

	planet = {
		count = 1
		orbit_distance = 20
		size = 18
		class = pc_frozen
		flags = { forgotten_patrol_target_1 }
		orbit_angle = { min = 90 max = 270 }
		init_effect = {
			if = {
				limit = {
					has_aquatics = yes
				}
				create_fleet = {
					name = "NAME_Primal_Thirst"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						create_ship = {
							design = "NAME_Sky_Dragon"
						}
						set_location = {
							target = prev
							distance = 20
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
					}
				}
			}
			else = {
				create_fleet = {
					name = "NAME_Primal_Swarm"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						while = {
							count = 12
							create_ship = {
								name = ""
								design = "NAME_Large_Space_Organism_Zebra"
							}
						}
						while = {
							count = 6
							create_ship = {
								name = ""
								design = "NAME_Small_Space_Organism_Zebra"
							}
						}
						while = {
							count = 2
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
						}
						set_location = {
							target = prev
							distance = 12
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
					}
				}
			}
		}
	}

	planet = {
		count = 1
		orbit_distance = 25
		size = 12
		class = pc_toxic
		flags = { forgotten_patrol_target_A }
		orbit_angle = { min = 90 max = 270 }

		init_effect = {
			if = {
				limit = {
					has_toxoids = yes
				}
				create_fleet = {
					name = "NAME_Primal_Hunger"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						create_ship = {
							design = "NAME_Acidic_Demigod"
						}
						set_location = {
							target = prev
							distance = 20
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
					}
				}
			}
			else = {
				create_fleet = {
					name = "NAME_Primal_Swarm"
					effect = {
						set_owner = event_target:fallen_empire_hive_forgotten
						while = {
							count = 12
							create_ship = {
								name = ""
								design = "NAME_Large_Space_Organism_Zebra"
							}
						}
						while = {
							count = 6
							create_ship = {
								name = ""
								design = "NAME_Small_Space_Organism_Zebra"
							}
						}
						while = {
							count = 2
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Cow"
							}
							create_ship = {
								design = "NAME_Tiyanki_Bull"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Calf"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
							create_ship = {
								design = "NAME_Tiyanki_Hatchling"
							}
						}
						set_location = {
							target = prev
							distance = 12
							angle = 0
						}
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 200
					}
				}
			}
		}
	}

	planet = {
		count = 1
		orbit_distance = 25
		size = 25
		class = pc_shattered
		flags = { forgotten_patrol_target_3 }
		orbit_angle = { min = 90 max = 270 }
		moon = {
			count = { min = 1 max = 2 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 10
		}

		init_effect = {
			create_fleet = {
				name = "NAME_Primal_Swarm"
				effect = {
					set_owner = event_target:fallen_empire_hive_forgotten
					while = {
						count = 12
						create_ship = {
							name = ""
							design = "NAME_Large_Space_Organism_Zebra"
						}
					}
					while = {
						count = 6
						create_ship = {
							name = ""
							design = "NAME_Small_Space_Organism_Zebra"
						}
					}
					while = {
						count = 2
						create_ship = {
							design = "NAME_Tiyanki_Cow"
						}
						create_ship = {
							design = "NAME_Tiyanki_Bull"
						}
						create_ship = {
							design = "NAME_Tiyanki_Cow"
						}
						create_ship = {
							design = "NAME_Tiyanki_Bull"
						}
						create_ship = {
							design = "NAME_Tiyanki_Calf"
						}
						create_ship = {
							design = "NAME_Tiyanki_Calf"
						}
						create_ship = {
							design = "NAME_Tiyanki_Hatchling"
						}
						create_ship = {
							design = "NAME_Tiyanki_Hatchling"
						}
					}
					set_location = {
						target = prev
						distance = 12
						angle = 0
					}
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 200
					queue_actions = {
						repeat = {
							find_closest_planet = {
								trigger = {
									id = forgot.patrol.I
									has_planet_flag = forgotten_patrol_target_B
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 120
									}
								}
							}
							find_closest_planet  = {
								trigger = {
									id = forgot.patrol.II
									has_planet_flag = forgotten_patrol_target_1
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 120
									}
								}
							}
							find_closest_planet  = {
								trigger = {
									id = forgot.patrol.III
									has_planet_flag = forgotten_patrol_target_3
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 120
									}
								}
							}
						}
					}
				}
			}
		}
	}

	init_effect = {
		every_system_planet = {
			clear_deposits = yes
			prevent_anomaly = yes
		}
		create_random_fe_fragment = yes
		last_created_country = {
			set_country_flag = second_hive_fe_fragment
		}
		create_random_fe_fragment = yes
		last_created_country = {
			set_country_flag = third_hive_fe_fragment
		}
		save_global_event_target_as = last_thought_system
	}

	mandatory_neighbors = yes
	neighbor_system = {
		trigger = { exists = event_target:fallen_empire_hive_war }
		distance = { min = 10 max = 40 }
		hyperlane_jumps = { min = 1 max = 10 }
		min_orientation_angle = 0
		max_orientation_angle = 120
		initializer = "fallen_hive_war"
	}
	neighbor_system = {
		trigger = { exists = event_target:fallen_empire_hive_growth }
		distance = { min = 10 max = 40 }
		hyperlane_jumps = { min = 1 max = 10 }
		min_orientation_angle = 120
		max_orientation_angle = 240
		initializer = "fallen_hive_growth"
	}
	neighbor_system = {
		trigger = { exists = event_target:fallen_empire_hive_control }
		distance = { min = 10 max = 40 }
		hyperlane_jumps = { min = 1 max = 10 }
		min_orientation_angle = 240
		max_orientation_angle = 360
		initializer = "fallen_hive_control"
	}
}

fallen_hive_war = {
	usage = fallen_empire_init
	class = "rl_standard_stars"
	init_effect = {
		create_hive_fe_citadel = { FRAGMENT = war }
		if = {
			limit = {
				NOT = {
					has_hyperlane_to = event_target:last_thought_system
				}
			}
			add_hyperlane = { from = this to = event_target:last_thought_system }
		}
	}

	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 135
	}

	flags = { fallen_hive_capital ancient_wonders_system }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = 1
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		name = "NAME_Redoubt"
		orbit_distance = 20
		class = pc_hive
		orbit_angle = { min = 90 max = 270 }
		size = 30
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_redoubt
			set_carrier_flag = fallen_hive_redoubt
			set_planet_flag = fallen_empire_capital
			set_owner = event_target:fallen_empire_hive_war
			prevent_anomaly = yes
			set_capital = yes

			while = {
				count = 16
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_market_2
			add_building = building_fe_security_2

			add_zone = {
				district = district_hive
				zone = zone_spawning
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool

			add_zone = {
				district = district_hive
				zone = zone_foundry
				zone_slot = 2
				replace = yes
			}
			add_building = building_nano_forge
			add_building = building_dimensional_fabricator

			while = {
				count = 3
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_1
				}
			}
			add_zone = {
				district = district_hive_1
				zone = zone_fortress_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_stronghold
			add_building = building_fortress
			add_building = building_fortress
			while = {
				count = 6
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_2 #farming
				}
			}
			add_zone = {
				district = district_hive_2
				zone = zone_energy_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_class_4_singularity
			add_building = building_energy_nexus

			while = {
				count = 4
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_3
				}
			}
			add_zone = {
				district = district_hive_3
				zone = zone_fortress_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_planetary_shield_generator
			create_pop_group = {
				species = owner_main_species
				size = 21500
			}
			create_fallen_empire_starting_navy = yes
			while = {
				count = 60
				create_army = {
					name = random
					owner = root
					species = root
					type = "clone_army"
				}
			}
		}

		change_orbit = @base_moon_distance

		moon = {
			class = "pc_barren"
			orbit_angle = { min = 90 max = 270 }
			size = 11
			orbit_distance = 7
			modifiers = none
			flags = { war_citadel_site }
			init_effect = {
				create_fe_dsc = {
					OWNER = event_target:fallen_empire_hive_war
					DESIGN = "NAME_HIVE_Citadel_3"
				}
			}
		}

		moon = {
			class = "pc_barren_cold"
			orbit_angle = { min = 90 max = 270 }
			size = 9
			orbit_distance = 7
			modifiers = none
			flags = { war_citadel_site }
			init_effect = {
				create_fe_dsc = {
					OWNER = event_target:fallen_empire_hive_war
					DESIGN = "NAME_HIVE_Citadel_3"
				}
			}
		}
	}

	change_orbit = 30

	planet = {
		count = { min = 2 max = 4 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 2 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	mandatory_neighbors = yes
	neighbor_system = {
		distance = { min = 10 max = 30 }
		hyperlane_jumps = { min = 1 max = 10 }
		initializer = "fallen_hive_war_2"
	}
	neighbor_system = {
		distance = { min = 10 max = 30 }
		hyperlane_jumps = { min = 1 max = 10 }
		initializer = "fallen_hive_war_3"
	}
}

fallen_hive_war_2 = {
	class = "rl_standard_stars"

	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 100
	}
	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 1 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	planet = {
		name = "NAME_Trial_of_Survival"
		count = 1
		orbit_distance = 25
		class = pc_nuked
		orbit_angle = { min = 90 max = 270 }
		size = 25
		deposit_blockers = none
		modifiers = none
		init_effect = {
			while = {
				count = 15
				add_blocker = { type = d_lethal_ecosphere_blocker }
			}
			add_modifier = { modifier = death_world days = -1 }
		}

		change_orbit = @base_moon_distance

		moon = {
			count = 1
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	change_orbit = 25

	planet = {
		count = { min = 1 max = 3 }
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 40 max = 100 }
	}

	change_orbit = 25

	planet = {
		name = "NAME_Chance_of_Glory"
		orbit_distance = 20
		class = pc_hive
		orbit_angle = { min = 90 max = 270 }
		size = 27
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_glory
			set_carrier_flag = fallen_hive_glory
			set_owner = event_target:fallen_empire_hive_war
			prevent_anomaly = yes

			while = {
				count = 14
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_market_2
			add_building = building_fe_security_2
			add_building = building_planetary_shield_generator

			add_zone = {
				district = district_hive
				zone = zone_spawning
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool
			add_zone = {
				district = district_hive
				zone = zone_foundry
				zone_slot = 2
				replace = yes
			}
			add_building = building_nano_forge
			add_building = building_dimensional_fabricator
			while = {
				count = 3
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_1
				}
			}
			add_zone = {
				district = district_hive_1
				zone = zone_fortress_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_stronghold
			add_building = building_fortress
			add_building = building_fortress
			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_2 #farming
				}
			}
			add_zone = {
				district = district_hive_2
				zone = zone_minerals_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_mine_2
			add_building = building_mineral_purification_hub
			while = {
				count = 4
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_3
				}
			}
			add_zone = {
				district = district_hive_3
				zone = zone_fortress_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fortress
			add_building = building_fortress
			add_building = building_fortress
			create_pop_group = {
				species = owner_main_species
				size = 19000
			}
			while = {
				count = 60
				create_army = {
					name = random
					owner = root
					species = root
					type = "clone_army"
				}
			}
		}
	}

	change_orbit = 15

	planet = {
		count = { min = 2 max = 3 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		create_starbase = {
			size = "starbase_outpost"
			owner = event_target:fallen_empire_hive_war
			effect = {
				while = {
					count = 2
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

fallen_hive_war_3 = {
	class = "sc_binary_3"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 60
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 25
		orbit_angle = 1
		size = { min = 25 max = 30 }
		has_ring = no
	}
	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 180
		size = { min = 15 max = 10 }
		has_ring = no
	}

	change_orbit = 40

	planet = {
		class = "pc_gas_giant"
		orbit_angle = 130
		size = 35
		change_orbit = @base_moon_distance

		moon = {
			class = "pc_barren"
			orbit_angle = { min = 90 max = 270 }
			size = 11
			orbit_distance = 7
			modifiers = none
			flags = { war_citadel_site }
			init_effect = {
				create_fe_dsc = {
					OWNER = event_target:fallen_empire_hive_war
					DESIGN = "NAME_HIVE_Citadel_3"
				}
			}
		}

		moon = {
			class = "pc_barren_cold"
			orbit_angle = { min = 90 max = 270 }
			size = 9
			orbit_distance = 7
			modifiers = none
			flags = { war_citadel_site }
			init_effect = {
				create_fe_dsc = {
					OWNER = event_target:fallen_empire_hive_war
					DESIGN = "NAME_HIVE_Citadel_3"
				}
			}
		}
	}

	planet = {
		class = "pc_gas_giant"
		orbit_distance = 10
		orbit_angle = -40
		size = 30
		change_orbit = @base_moon_distance

		moon = {
			class = "pc_barren"
			orbit_angle = { min = 90 max = 270 }
			size = 11
			orbit_distance = 7
			modifiers = none
			flags = { war_citadel_site }
			init_effect = {
				create_fe_dsc = {
					OWNER = event_target:fallen_empire_hive_war
					DESIGN = "NAME_HIVE_Citadel_3"
				}
			}
		}
	}

	planet = {
		class = "pc_shattered"
		orbit_distance = 10
		orbit_angle = 180
		size = 10
		has_ring = no
		init_effect = {
			create_ambient_object = {
				type = "large_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "medium_debris_01_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "medium_debris_02_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "small_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			save_event_target_as = assembly_target
			prevent_anomaly = yes
		}
	}

	planet = {
		class = "pc_shattered"
		orbit_distance = 15
		orbit_angle = -30
		size = 18
		has_ring = no
		init_effect = {
			create_ambient_object = {
				type = "large_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "medium_debris_01_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "medium_debris_02_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "small_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			prevent_anomaly = yes
		}
	}

	planet = {
		class = "pc_shattered_2"
		orbit_distance = 15
		orbit_angle = 50
		size = 22
		has_ring = yes
		init_effect = {
			create_ambient_object = {
				type = "large_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "medium_debris_01_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "medium_debris_02_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "small_debris_object"
				entity_offset_height = { min = -0 max = -25 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			prevent_anomaly = yes
		}
	}

	init_effect = {
		spawn_megastructure = {
			type = "interstellar_assembly_ruined"
			planet = event_target:assembly_target

			init_effect = {
				create_ambient_object = {
					type = "large_debris_object"
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 20
						angle = 20
					}
				}
				create_ambient_object = {
					type = "large_debris_object"
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 20
						angle = 150
					}
				}
				create_ambient_object = {
					type = "medium_debris_01_object"
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 35
						angle = 90
					}
				}
				create_ambient_object = {
					type = "medium_debris_02_object"
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 3
						angle = 270
					}
				}
			}
		}
		create_starbase = {
			size = "starbase_outpost"
			owner = event_target:fallen_empire_hive_war
			effect = {
				while = {
					count = 2
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

fallen_hive_growth = {
	class = "rl_standard_stars"

	flags = { fallen_hive_capital ancient_wonders_system }
	init_effect = {
		create_hive_fe_citadel = { FRAGMENT = growth }
		if = {
			limit = {
				NOT = {
					has_hyperlane_to = event_target:last_thought_system
				}
			}
			add_hyperlane = { from = this to = event_target:last_thought_system }
		}
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		name = "NAME_Slumbering_Creche"
		orbit_distance = 20
		class = pc_hive
		orbit_angle = { min = 90 max = 270 }
		size = 30
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_creche
			set_carrier_flag = fallen_hive_creche
			set_planet_flag = fallen_empire_capital
			set_owner = event_target:fallen_empire_hive_growth
			prevent_anomaly = yes
			set_capital = yes

			while = {
				count = 11
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_stronghold
			add_building = building_fe_market_2
			add_building = building_fe_security_2

			add_zone = {
				district = district_hive
				zone = zone_research
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_lab_2
			# add_building = building_fe_lab_2
			# add_building = building_fe_lab_2
			add_zone = {
				district = district_hive
				zone = zone_unity
				zone_slot = 2
				replace = yes
			}
			add_building = building_fe_administration_hive_2
			# add_building = building_fe_administration_hive_2
			# add_building = building_fe_administration_hive_2
			while = {
				count = 6
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_1
				}
			}
			add_zone = {
				district = district_hive_1
				zone = zone_spawning_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool
			while = {
				count = 8
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_2 #farming
				}
			}
			add_zone = {
				district = district_hive_2
				zone = zone_spawning_hive
				zone_slot = 0
				replace = yes
			}
			while = {
				count = 4
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_3
				}
			}
			add_zone = {
				district = district_hive_3
				zone = zone_spawning_hive
				zone_slot = 0
				replace = yes
			}

			create_pop_group = {
				species = owner_main_species
				size = 21500
			}
			create_fallen_empire_starting_navy = yes
			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "clone_army"
				}
			}
		}

		change_orbit = @base_moon_distance

		moon = {
			name = "NAME_Dormant_Nursery"
			class = "pc_hive"
			orbit_angle = { min = 90 max = 270 }
			size = 7
			orbit_distance = 5
			modifiers = none

			init_effect = {
				set_planet_flag = fallen_empire_world
				set_global_flag = fallen_hive_nursery
				set_carrier_flag = fallen_hive_nursery
				set_planet_flag = fallen_empire_capital
				set_owner = event_target:fallen_empire_hive_growth
				prevent_anomaly = yes

				while = {
					count = 2
					add_district = district_hive
				}
				add_building = building_ancient_hive_capital
				add_building = building_fe_dome
				add_building = building_fe_dome
				add_building = building_fe_market_2
				add_building = building_fe_stronghold
				add_building = building_fe_security_2

				add_zone = {
					district = district_hive
					zone = zone_research
					zone_slot = 1
					replace = yes
				}
				add_building = building_fe_lab_2

				add_zone = {
					district = district_hive
					zone = zone_unity
					zone_slot = 2
					replace = yes
				}
				add_building = building_fe_administration_hive_2
				while = {
					count = 1
					add_district_and_planet_size_if_needed_effect = {
						district = district_hive_1
					}
				}
				add_zone = {
					district = district_hive_1
					zone = zone_spawning_hive
					zone_slot = 0
					replace = yes
				}
				add_building = building_fe_clinic_2
				add_building = building_spawning_pool

				while = {
					count = 1
					add_district_and_planet_size_if_needed_effect = {
						district = district_hive_2 #farming
					}
				}
				add_zone = {
					district = district_hive_2
					zone = zone_spawning_hive
					zone_slot = 0
					replace = yes
				}
				while = {
					count = 2
					add_district_and_planet_size_if_needed_effect = {
						district = district_hive_3
					}
				}
				add_zone = {
					district = district_hive_3
					zone = zone_spawning_hive
					zone_slot = 0
					replace = yes
				}

				create_pop_group = {
					species = owner_main_species
					size = 17200
				}
				while = {
					count = 20
					create_army = {
						name = random
						owner = root
						species = root
						type = "clone_army"
					}
				}
			}
		}
	}

	planet = {
		name = "NAME_Abeyant_Nidus"
		orbit_distance = 30
		class = pc_hive
		orbit_angle = 50
		size = 22
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_nidus
			set_carrier_flag = fallen_hive_nidus
			prevent_anomaly = yes
			set_owner = event_target:fallen_empire_hive_growth

			while = {
				count = 3
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_stronghold
			add_building = building_fe_market_2
			add_building = building_fe_security_2

			add_zone = {
				district = district_hive
				zone = zone_research_unity
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_lab_2
			add_building = building_fe_administration_hive_2

			add_zone = {
				district = district_hive
				zone = zone_spawning
				zone_slot = 2
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool
			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_1
				}
			}
			add_zone = {
				district = district_hive_1
				zone = zone_food_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_nourishment_center
			add_building = building_food_processing_center
			while = {
				count = 6
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_2 #farming
				}
			}
			add_zone = {
				district = district_hive_2
				zone = zone_food_hive
				zone_slot = 0
				replace = yes
			}

			while = {
				count = 7
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_3
				}
			}
			add_zone = {
				district = district_hive_3
				zone = zone_food_hive
				zone_slot = 0
				replace = yes
			}

			create_pop_group = {
				species = owner_main_species
				size = 19800
			}
			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "clone_army"
				}
			}
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = 10
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_4
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = 10
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_5
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = 320
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_3
		}
	}

	planet = {
		count = { min = 2 max = 4 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	mandatory_neighbors = yes
	neighbor_system = {
		distance = { min = 10 max = 30 }
		hyperlane_jumps = { min = 1 max = 10 }
		initializer = "fallen_hive_growth_2"
	}
	neighbor_system = {
		distance = { min = 10 max = 30 }
		hyperlane_jumps = { min = 1 max = 10 }
		initializer = "fallen_hive_growth_3"
	}
}

fallen_hive_growth_2 = {
	class = "rl_standard_stars"

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 20

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = pc_molten
		orbit_angle = { min = 90 max = 270 }
		size = { min = 5 max = 9 }
	}

	planet = {
		class = "pc_barren"
		orbit_distance = 25
		orbit_angle = 60
		size = 16
		has_ring = no

		init_effect = {
			add_modifier = {
				modifier = "terraforming_candidate"
				days = -1
			}
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 30
		orbit_angle = -210
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_4
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = -95
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_5
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = 285
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_3
		}
	}

	planet = {
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = -80
		init_effect = {
			prevent_anomaly = yes
			add_deposit = d_food_5
		}
	}

	planet = {
		name = "NAME_Dozing_Tiller"
		orbit_distance = 20
		class = pc_hive
		orbit_angle = { min = 90 max = 270 }
		size = 20
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_tiller
			set_carrier_flag = fallen_hive_tiller
			set_owner = event_target:fallen_empire_hive_growth
			prevent_anomaly = yes

			while = {
				count = 1
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_market_2
			add_building = building_fe_stronghold
			add_building = building_fe_security_2

			add_zone = {
				district = district_hive
				zone = zone_research_unity
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_lab_2
			add_building = building_fe_administration_hive_2
			add_zone = {
				district = district_hive
				zone = zone_spawning
				zone_slot = 2
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool
			while = {
				count = 4
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_1
				}
			}
			add_zone = {
				district = district_hive_1
				zone = zone_food_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_nourishment_center
			add_building = building_food_processing_center

			while = {
				count = 6
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_2 #farming
				}
			}
			add_zone = {
				district = district_hive_2
				zone = zone_food_hive
				zone_slot = 0
				replace = yes
			}

			while = {
				count = 8
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_3
				}
			}
			add_zone = {
				district = district_hive_3
				zone = zone_food_hive
				zone_slot = 0
				replace = yes
			}

			create_pop_group = {
				species = owner_main_species
				size = 18800
			}
		}
	}

	planet = {
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }
		size = 45

		change_orbit = 25

		moon = {
			class = pc_barren_cold
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
			size = 22
			init_effect = {
				add_modifier = {
					modifier = "terraforming_candidate"
					days = -1
				}
			}
		}
	}

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 1 max = 2 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}
	init_effect = {
		create_starbase = {
			size = "starbase_outpost"
			owner = event_target:fallen_empire_hive_growth
			effect = {
				while = {
					count = 2
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

fallen_hive_growth_3 = {
	class = "rl_standard_stars"

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 20

	planet = {
		count = { min = 0 max = 2 }
		orbit_distance = 20
		class = pc_molten
		orbit_angle = { min = 90 max = 270 }
		size = { min = 5 max = 9 }
	}

	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 20
		class = random_non_colonizable
		orbit_angle = { min = 90 max = 270 }
		size = { min = 5 max = 9 }
	}


	planet = {
		class = "pc_toxic"
		orbit_distance = 25
		orbit_angle = 60
		size = 16
		has_ring = no

		init_effect = {
			add_modifier = {
				modifier = "toxic_terraforming_candidate"
				days = -1
			}
		}

		moon = {
			count = { min = 0 max = 1 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	planet = {
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }
		size = 45

		change_orbit = 25


		moon = {
			count = { min = 1 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}

		moon = {
			class = pc_frozen
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
			size = 22
			init_effect = {
				add_modifier = {
					modifier = "frozen_terraforming_candidate"
					days = -1
				}
			}
		}
	}

	planet = {
		count = { min = 0 max = 1 }
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 3 }
			class = random_non_colonizable
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}

	init_effect = {
		create_starbase = {
			size = "starbase_outpost"
			owner = event_target:fallen_empire_hive_growth
			effect = {
				while = {
					count = 2
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

fallen_hive_control = {
	class = "rl_standard_stars"

	flags = { fallen_hive_capital ancient_wonders_system }
	init_effect = {
		create_hive_fe_citadel = { FRAGMENT = control }
		if = {
			limit = {
				NOT = {
					has_hyperlane_to = event_target:last_thought_system
				}
			}
			add_hyperlane = { from = this to = event_target:last_thought_system }
		}
	}

	asteroid_belt = {
		type = icy_asteroid_belt
		radius = 90
	}

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 50

	planet = {
		name = "NAME_Harvester_001"
		orbit_distance = 20
		class = pc_hive
		orbit_angle = 0
		size = 25
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_harvester_001
			set_carrier_flag = fallen_hive_harvester_001
			set_planet_flag = fallen_empire_capital
			set_owner = event_target:fallen_empire_hive_control
			prevent_anomaly = yes
			set_capital = yes

			while = {
				count = 9
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_security_2
			add_building = building_fe_stronghold

			add_zone = {
				district = district_hive
				zone = zone_unity
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_administration_hive_2

			add_zone = {
				district = district_hive
				zone = zone_trade
				zone_slot = 2
				replace = yes
			}
			add_building = building_fe_market_2

			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_1
				}
			}
			add_zone = {
				district = district_hive_1
				zone = zone_spawning_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool
			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_2 #farming
				}
			}
			add_zone = {
				district = district_hive_2
				zone = zone_minerals_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_mine_2
			add_building = building_mineral_purification_hub
			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_hive_3
				}
			}
			add_zone = {
				district = district_hive_3
				zone = zone_energy_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_class_4_singularity
			add_building = building_energy_nexus

			create_pop_group = {
				species = owner_main_species
				size = 24000
			}
			create_fallen_empire_starting_navy = yes
			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "clone_army"
				}
			}
		}
	}

	planet = {
		count = 3
		size = 27
		orbit_distance = 0
		class = random_non_colonizable
		orbit_angle = 45
	}

	planet = {
		name = "NAME_Harvester_002"
		orbit_distance = 0
		class = pc_hive
		orbit_angle = 45
		size = 28
		deposit_blockers = none
		modifiers = none

		init_effect = {
			set_planet_flag = fallen_empire_world
			set_global_flag = fallen_hive_harvester_002
			set_carrier_flag = fallen_hive_harvester_002
			prevent_anomaly = yes
			set_owner = event_target:fallen_empire_hive_control

			while = {
				count = 6
				add_district = district_hive
			}
			add_building = building_ancient_hive_capital
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_security_2
			add_building = building_fe_stronghold

			add_zone = {
				district = district_hive
				zone = zone_unity
				zone_slot = 1
				replace = yes
			}
			add_building = building_fe_administration_hive_2

			add_zone = {
				district = district_hive
				zone = zone_trade
				zone_slot = 2
				replace = yes
			}
			add_building = building_fe_market_2

			while = {
				count = 7
				add_district = district_hive_1
			}
			add_zone = {
				district = district_hive_1
				zone = zone_spawning_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_fe_clinic_2
			add_building = building_spawning_pool
			while = {
				count = 7
				add_district = district_hive_2
			}
			add_zone = {
				district = district_hive_2
				zone = zone_energy_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_class_4_singularity
			add_building = building_energy_nexus
			while = {
				count = 7
				add_district = district_hive_3
			}
			add_zone = {
				district = district_hive_3
				zone = zone_foundry_hive
				zone_slot = 0
				replace = yes
			}
			add_building = building_dimensional_fabricator
			add_building = building_dimensional_fabricator
			add_building = building_dimensional_fabricator

			create_pop_group = {
				species = owner_main_species
				size = 20800
			}
			while = {
				count = 20
				create_army = {
					name = random
					owner = root
					species = root
					type = "clone_army"
				}
			}
		}
	}

	planet = {
		count = 3
		size = 27
		orbit_distance = 0
		class = random_non_colonizable
		orbit_angle = 45
	}

	mandatory_neighbors = yes
	neighbor_system = {
		distance = { min = 10 max = 30 }
		hyperlane_jumps = { min = 1 max = 10 }
		initializer = "fallen_hive_control_2"
	}
	neighbor_system = {
		distance = { min = 10 max = 30 }
		hyperlane_jumps = { min = 1 max = 10 }
		initializer = "fallen_hive_control_3"
	}
}

fallen_hive_control_2 = {
	class = sc_trinary_1

	planet = {
		count = 1
		class = pc_g_star
		orbit_distance = 0
		orbit_angle = 0
		size = 24

		planet = {
			class = pc_barren
			size = 20
			orbit_distance = 35
			orbit_angle = 0
			init_effect = {
				prevent_anomaly = yes
			}
			moon = {
				class = pc_molten
				size = 7
				orbit_angle = 180
				orbit_distance = 10
			}
		}

		planet = {
			class = pc_toxic
			size = 13
			orbit_distance = 20
			orbit_angle = 180
			init_effect = {
				prevent_anomaly = yes
			}
		}

		planet = {
			class = pc_gas_giant
			size = 35
			orbit_distance = 25
			orbit_angle = 270
			init_effect = {
				prevent_anomaly = yes
			}
			moon = {
				class = pc_barren
				size = 9
				orbit_angle = 90
				orbit_distance = 25
			}
			moon = {
				name = "NAME_Harvester_713"
				orbit_distance = 20
				class = pc_hive
				orbit_angle = 180
				size = 20
				deposit_blockers = none
				modifiers = none

				init_effect = {
					set_planet_flag = fallen_empire_world
					set_global_flag = fallen_hive_harvester_713
					set_carrier_flag = fallen_hive_harvester_713
					set_owner = event_target:fallen_empire_hive_control
					prevent_anomaly = yes

					while = {
						count = 4
						add_district = district_hive
					}
					add_building = building_ancient_hive_capital
					add_building = building_fe_dome
					add_building = building_fe_dome
					add_building = building_fe_security_2
					add_building = building_class_4_singularity

					add_zone = {
						district = district_hive
						zone = zone_unity
						zone_slot = 1
						replace = yes
					}
					add_building = building_fe_administration_hive_2

					add_zone = {
						district = district_hive
						zone = zone_foundry
						zone_slot = 2
						replace = yes
					}
					add_building = building_dimensional_fabricator
					add_building = building_dimensional_fabricator
					add_building = building_nano_forge
					while = {
						count = 5
						add_district_and_planet_size_if_needed_effect = {
							district = district_hive_1
						}
					}
					add_zone = {
						district = district_hive_1
						zone = zone_spawning_hive
						zone_slot = 0
						replace = yes
					}
					add_building = building_fe_clinic_2
					add_building = building_spawning_pool
					while = {
						count = 5
						add_district_and_planet_size_if_needed_effect = {
							district = district_hive_2
						}
					}
					add_zone = {
						district = district_hive_2
						zone = zone_foundry_hive
						zone_slot = 0
						replace = yes
					}
					add_building = building_nano_forge

					while = {
						count = 5
						add_district_and_planet_size_if_needed_effect = {
							district = district_hive_3
						}
					}
					add_zone = {
						district = district_hive_3
						zone = zone_foundry_hive
						zone_slot = 0
						replace = yes
					}
					add_building = building_dimensional_fabricator
					add_building = building_dimensional_fabricator
					add_building = building_dimensional_fabricator

					create_pop_group = {
						species = owner_main_species
						size = 19200
					}
				}
			}
		}
	}

	planet = {
		count = 1
		class = pc_k_star
		orbit_distance = 160
		orbit_angle = 250
		size = 24

		planet = {
			class = pc_barren_cold
			size = 20
			orbit_distance = 35
			orbit_angle = 250
			init_effect = {
				prevent_anomaly = yes
			}
			moon = {
				class = pc_barren_cold
				size = 7
				orbit_angle = -160
				orbit_distance = 10
			}
		}
		planet = {
			class = pc_toxic
			size = 13
			orbit_distance = 20
			orbit_angle = 180
			init_effect = {
				prevent_anomaly = yes
			}
		}
		planet = {
			class = pc_gas_giant
			size = 35
			orbit_distance = 25
			orbit_angle = 90
			init_effect = {
				prevent_anomaly = yes
			}
			moon = {
				class = pc_barren
				size = 9
				orbit_angle = 90
				orbit_distance = 25
			}
			moon = {
				name = NAME_Harvester_714
				class = pc_shattered
				size = 20
				orbit_angle = 180
				orbit_distance = 20
			}
		}
	}

	planet = {
		count = 1
		class = pc_m_star
		orbit_distance = 0
		orbit_angle = 130
		size = 24

		planet = {
			class = pc_barren_cold
			size = 20
			orbit_distance = 35
			orbit_angle = 130
			init_effect = {
				prevent_anomaly = yes
			}
			moon = {
				class = pc_barren_cold
				size = 7
				orbit_angle = -130
				orbit_distance = 10
			}
		}
		planet = {
			class = pc_toxic
			size = 13
			orbit_distance = 20
			orbit_angle = 180
			init_effect = {
				prevent_anomaly = yes
			}
		}
		planet = {
			class = pc_gas_giant
			size = 35
			orbit_distance = 25
			orbit_angle = 90
			init_effect = {
				prevent_anomaly = yes
			}
			moon = {
				class = pc_barren
				size = 9
				orbit_angle = 90
				orbit_distance = 25
			}
			moon = {
				name = NAME_Harvester_715
				class = pc_shattered_2
				size = 20
				orbit_angle = 180
				orbit_distance = 20
			}
		}
	}

	init_effect = {
		create_starbase = {
			size = "starbase_outpost"
			owner = event_target:fallen_empire_hive_control
			effect = {
				while = {
					count = 2
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

fallen_hive_control_3 = {
	class = "rl_standard_stars"
	name = NAME_Pillath

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
	}

	change_orbit = 60

	planet = {
		name = NAME_Ordris
		orbit_distance = 20
		class = pc_gas_giant
		orbit_angle = 120
		size = 62
		init_effect = {
			prevent_anomaly = yes
		}
		moon = {
			name = NAME_Gethalis
			class = pc_gas_giant
			size = 50
			orbit_angle = { min = 110 max = 130 }
			orbit_distance = 65
			moon = {
				name = NAME_Awasres
				class = random_non_colonizable
				size = 30
				orbit_angle = { min = 110 max = 130 }
				orbit_distance = 40
				moon = {
					name = NAME_Destuka
					class = random_non_colonizable
					size = 25
					orbit_angle = { min = 110 max = 130 }
					orbit_distance = 30
					moon = {
						name = NAME_Iituka
						class = random_non_colonizable
						size = 18
						orbit_angle = { min = 110 max = 130 }
						orbit_distance = 20
						moon = {
							name = NAME_Waorli
							class = random_non_colonizable
							size = 14
							orbit_angle = { min = 110 max = 130 }
							orbit_distance = 20
							moon = {
								name = NAME_Peethika
								class = random_non_colonizable
								size = 9
								orbit_angle = { min = 110 max = 130 }
								orbit_distance = 20
								moon = {
									name = NAME_Nukapol
									class = random_non_colonizable
									size = 5
									orbit_angle = { min = 110 max = 130 }
									orbit_distance = 10
								}
							}
						}
					}
				}
			}
		}
	}

	planet = {
		name = NAME_Complianc
		orbit_distance = 0
		class = pc_gas_giant
		orbit_angle = 120
		size = 62
		init_effect = {
			prevent_anomaly = yes
		}
		moon = {
			name = NAME_Opelaz
			class = pc_gas_giant
			size = 50
			orbit_angle = { min = 230 max = 270 }
			orbit_distance = 65
			moon = {
				name = NAME_Cheppep
				class = random_non_colonizable
				size = 30
				orbit_angle = { min = 230 max = 270 }
				orbit_distance = 40
				moon = {
					name = NAME_Fanopa
					class = random_non_colonizable
					size = 25
					orbit_angle = { min = 230 max = 270 }
					orbit_distance = 30
					moon = {
						name = NAME_Ootagi
						class = random_non_colonizable
						size = 18
						orbit_angle = { min = 230 max = 270 }
						orbit_distance = 20
						moon = {
							name = NAME_Pethai
							class = random_non_colonizable
							size = 14
							orbit_angle = { min = 230 max = 270 }
							orbit_distance = 20
							moon = {
								name = NAME_Xulpai
								class = random_non_colonizable
								size = 9
								orbit_angle = { min = 230 max = 270 }
								orbit_distance = 20
								moon = {
									name = NAME_Stekila
									class = random_non_colonizable
									size = 5
									orbit_angle = { min = 230 max = 270 }
									orbit_distance = 10
								}
							}
						}
					}
				}
			}
		}
	}
	planet = {
		name = NAME_Stabbith
		orbit_distance = 0
		class = pc_gas_giant
		orbit_angle = 120
		size = 62
		init_effect = {
			prevent_anomaly = yes
		}
		moon = {
			name = NAME_Begito
			class = pc_gas_giant
			size = 50
			orbit_angle = { min = 10 max = 30 }
			orbit_distance = 65
			moon = {
				name = NAME_Nelxo
				class = random_non_colonizable
				size = 30
				orbit_angle = { min = 10 max = 30 }
				orbit_distance = 40
				moon = {
					name = NAME_Susigup
					class = random_non_colonizable
					size = 25
					orbit_angle = { min = 10 max = 30 }
					orbit_distance = 30
					moon = {
						name = NAME_Lukeste
						class = random_non_colonizable
						size = 18
						orbit_angle = { min = 10 max = 30 }
						orbit_distance = 20
						moon = {
							name = NAME_Yaanguy
							class = random_non_colonizable
							size = 14
							orbit_angle = { min = 10 max = 30 }
							orbit_distance = 20
							moon = {
								name = NAME_Numalu
								class = random_non_colonizable
								size = 9
								orbit_angle = { min = 10 max = 30 }
								orbit_distance = 20
								moon = {
									name = NAME_Uxitro
									class = random_non_colonizable
									size = 5
									orbit_angle = { min = 10 max = 30 }
									orbit_distance = 10
								}
							}
						}
					}
				}
			}
		}
	}


	init_effect = {
		create_starbase = {
			size = "starbase_outpost"
			owner = event_target:fallen_empire_hive_control
			effect = {
				while = {
					count = 2
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}
