
@distance = 50
@jumps = 3
@planet_min_size = 10
@planet_max_size = 25
@base_moon_distance = 10
@moon_min_size = 6
@moon_max_size = 10
@homeworld_min_size = 18
@homeworld_max_size = 21

### Hauer System
hauer_system_initializer = {
	name = "NAME_Hauer"
	flags = { hostile_system precursor_system }
	class = "sc_g"

	usage = misc_system_init
	usage_odds = {
		base = @spawn_system_common
		modifier = {
			factor = 0
			has_star_flag = empire_cluster
		}
	}
	max_instances = 1

	### 1
	planet = {
		name = "NAME_Aureyon"
		class = "pc_g_star"
		orbit_distance = 0
		orbit_angle = 1
		has_ring = no
	}

	### 2
	planet = {
		name = "NAME_Stykkia"
		class = random
		orbit_distance = 40
		orbit_angle = -115
		has_ring = no
	}

	### 3
	planet = {
		name = "NAME_Baage"
		class = random
		orbit_distance = 25
		orbit_angle = -20
		has_ring = no
	}

	### 4	Tannhäuser Gate
	planet = {
		name = "NAME_Piyhl"
		class = random
		orbit_distance = 32
		orbit_angle = -10
		has_ring = no

		init_effect = {
			create_drone_country = yes
			create_ambient_object = {
				type = "tannhauser_gate_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -0 max = -20 }
				location = this
			}
			last_created_ambient_object = {
				save_event_target_as = tannhauser_gate
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_fleet = {
				name = "NAME_Ancient_Mining_Drones"
				effect = {
					set_owner = event_target:drone_country
					while = {
						count = 3
						create_ship = {
							name = "NAME_Mining_Drone_C_Class"
							design = "NAME_Ancient_Mining_Drone"
						}
					}
					set_location = {
						target = event_target:tannhauser_gate
						distance = 5
						angle = random
					}
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = return_point
					set_aggro_range = 15
				}
			}
		}
	}

	### 5	Attack Ships
	planet = {
		name = "NAME_Straeng"
		class = random
		orbit_distance = 33
		orbit_angle = -160
		has_ring = no

		init_effect = {
			create_ambient_object = {
				type = "attack_ship_01_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -0 max = -20 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 20
					angle = random
				}
			}
		}
	}

	### 6
	planet = {
		name = "NAME_Bhete"
		class = random
		orbit_distance = 78
		orbit_angle = 62
		has_ring = no

		moon = {
			count = { min = 0 max = 2 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = @base_moon_distance
		}
	}

	### 7
	planet = {
		name = "NAME_Floe"
		class = random
		orbit_distance = 6
		orbit_angle = -39
		has_ring = no
	}

	### 8
	planet = {
		name = "NAME_Snaara"
		class = random
		orbit_distance = 42
		orbit_angle = 197
		has_ring = no

		change_orbit = @base_moon_distance

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

	### 9	Archaeological Site
	planet = {
		name = "NAME_Spjuuht"
		class = random
		orbit_distance = 20
		orbit_angle = -160
		has_ring = no

		init_effect = {
			if = {
				limit = { has_ancrel = yes }
				create_archaeological_site = site_lost_moments
			}
		}
	}

	### 10
	planet = {
		name = "NAME_Baelte"
		class = random
		orbit_distance = 9
		orbit_angle = 115
		has_ring = no
	}
}

### On the Shoulders of Giants CONTINUED Origin - Intercepting History Event Chain - Abandoned Station System
intercepting_history_system_initializer_01 = {
	class = "rl_standard_stars"

	usage = misc_system_init
	usage_odds = 0
	max_instances = 1

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

	change_orbit = 45

	# Inner misc. planets
	planet = {
		count = { min = 1 max = 3 }
		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
		}
	}

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

		change_orbit = @base_moon_distance

		init_effect = {
			create_ambient_object = {
				type = "large_debris_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -0 max = -20 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
			}
			create_ambient_object = {
				type = "abandoned_station_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -0 max = -10 }
				location = this
			}
			last_created_ambient_object = {
				save_global_event_target_as = benefactor_station
				set_location = {
					target = prev
					distance = 30
					angle = random
				}
			}
			create_ambient_object = {
				type = "ancient_battlefield_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -0 max = -20 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 20
					angle = random
				}
			}
		}
	}

	# Outer misc. planets
	planet = {
		count = { min = 1 max = 3 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

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

	init_effect = {
		save_global_event_target_as = benefactors_end_station
	}
}

### On the Shoulders of Giants CONTINUED Origin - Intercepting History Event Chain - Benefactor Homeworld System
intercepting_history_system_initializer_02 = {
	class = "rl_standard_stars"

	usage = misc_system_init
	usage_odds = 0
	max_instances = 1

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

	change_orbit = 45

	# Inner misc. planets
	planet = {
		count = { min = 1 max = 2 }
		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
		}
	}

	# Benefactor Homeworld planet
	planet = {
		class = "pc_continental"
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
		size = 25
		change_orbit = @base_moon_distance
		modifiers = none
		deposit_blockers = none

		init_effect = {
			prevent_anomaly = yes

			create_species = {
				name = "NAME_ThwaaPhyr"
				plural = "NAME_ThwaaPhyr"
				class = random_pre_ftl
				portrait = random
				homeworld = THIS
				traits = {
					trait = "trait_organic"
					trait = "trait_adaptive"
					trait = "trait_nomadic"
					trait = "trait_presapient_forcefully_devolved"
				}
				effect = {
#					save_global_event_target_as = primitive_benefactor_species
				}
			}
			create_early_pre_ftl_empire = yes
			setup_pre_ftl_planet = yes
			last_created_country = {
				set_country_flag = benefactor_empire
			}
			save_global_event_target_as = benefactor_planet
		}
	}

	# Outer misc. planets
	planet = {
		count = { min = 2 max = 3 }
		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 = {
		save_global_event_target_as = benefactor_homeworld
	}
}

### On the Shoulders of Giants CONTINUED Origin - Relentless Pursuit Event Chain - Abandoned Freighter Ship System
relentless_pursuit_system_initializer_01 = {
	class = "rl_standard_stars"

	usage = misc_system_init
	usage_odds = 0
	max_instances = 1

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

	change_orbit = 45

	# Inner misc. planets
	planet = {
		count = { min = 2 max = 5 }
		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
		}
	}

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

		change_orbit = @base_moon_distance

		init_effect = {
			create_ambient_object = {
				type = "old_fleet_parking_lot_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -5 max = -15 }
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 20
					angle = random
				}
			}
			create_ambient_object = {
				type = "silent_freighter_object"
				entity_offset = { min = 0 max = 20}
				entity_offset_height = { min = -0 max = -5 }
				location = this
			}
			last_created_ambient_object = {
				save_global_event_target_as = abandoned_freighter
				set_location = {
					target = prev
					distance = 30
					angle = random
				}
			}
		}
	}

	# Outer misc. planets
	planet = {
		count = { min = 2 max = 3 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

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

	init_effect = {
		save_global_event_target_as = rendezvous_with_freighter_system
	}
}

### On the Shoulders of Giants CONTINUED Origin - Relentless Pursuit Event Chain - Relentless Homeworld System
relentless_pursuit_system_initializer_02 = {
	class = "rl_standard_stars"

	usage = misc_system_init
	usage_odds = 0
	max_instances = 1

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

	change_orbit = 45

	# Inner misc. planets
	planet = {
		count = { min = 1 max = 2 }
		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
		}
	}

	# The Mind-Wipe Satellite planet
	planet = {
		count = 1
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

		init_effect = {
			create_ambient_object = {
				type = "mysterious_space_station_object"
				entity_offset = { min = 5 max = 20}
				entity_offset_height = { min = -5 max = -10 }
				location = this
			}
			last_created_ambient_object = {
				save_global_event_target_as = mindwipe_cannon
				set_location = {
					target = prev
					distance = 20
					angle = random
				}
			}
		}
	}

	# Relentless Homeworld planet
	planet = {
		class = "pc_tundra"
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
		size = 25
		change_orbit = @base_moon_distance
		modifiers = none
		deposit_blockers = none

		init_effect = {
			prevent_anomaly = yes

			create_species = {
				name = "NAME_Vemetosha"
				plural = "NAME_Vemetosha"
				class = random_pre_ftl
				portrait = random
				homeworld = THIS
				traits = {
					trait = "trait_organic"
					trait = "trait_adaptive"
					trait = "trait_nomadic"
					trait = "trait_presapient_forcefully_devolved"
				}
				effect = {
					save_global_event_target_as = primitive_relentless_species
				}
			}
			create_early_pre_ftl_empire = yes
			setup_pre_ftl_planet = yes
			last_created_country = {
				set_country_flag = relentless_empire
			}
			save_global_event_target_as = relentless_planet
		}
	}

	# Outer misc. planets
	planet = {
		count = { min = 2 max = 3 }
		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 = {
		save_global_event_target_as = relentless_homeworld
	}
}

# Void Dweller Home System
void_dweller_system = {
	class = "rl_trinary_stars"
	usage = origin
	flags = { empire_home_system }

	init_effect = {
		every_neighbor_system = {
			set_star_flag = empire_cluster
			every_neighbor_system = {
				set_star_flag = empire_cluster
			}
		}
		generate_home_system_resources = yes
	}

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

	planet = {
		count = 1
		class = star
		orbit_distance = 240
		orbit_angle = { min = 90 max = 270 }
		size = { min = 20 max = 30 }
		has_ring = no
		satellite_naming_policy = upper_case_roman_numerals

		change_orbit = 30

		planet = {
			orbit_angle = { min = 90 max = 270 }
			class = random_non_colonizable
			orbit_distance = 25
			satellite_naming_policy = lower_case_latin_letters

			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 = {
			class = pc_barren_cold
			orbit_distance = 25
			orbit_angle = { min = 90 max = 270 }
			size = { min = 16 max = 20 }
			flags = { ignore_startup_effect habitat_2_planet has_orbital }
			has_ring = yes

			init_effect = {
				set_deposit = d_minerals_4
			}
		}

		 planet = {
			orbit_angle = { min = 90 max = 270 }
			class = pc_gas_giant
			orbit_distance = 25
			satellite_naming_policy = lower_case_latin_letters
			flags = { ignore_startup_effect mining_planet }

			init_effect = {
				set_deposit = d_energy_6
			}

			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 = 1
		class = star
		orbit_distance = 0
		orbit_angle = { min = 90 max = 270 }
		size = { min = 15 max = 30 }
		has_ring = no
		satellite_naming_policy = upper_case_roman_numerals

		change_orbit = 30

		 planet = {
			orbit_angle = { min = 90 max = 270 }
			class = random_non_colonizable
			orbit_distance = 25
			satellite_naming_policy = lower_case_latin_letters

			change_orbit = @base_moon_distance

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

				init_effect = {
					set_deposit = d_minerals_2
				}
			}
		}

		 planet = {
			orbit_angle = { min = 90 max = 270 }
			class = random_non_colonizable
			orbit_distance = 25
			satellite_naming_policy = lower_case_latin_letters

			change_orbit = @base_moon_distance

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

		planet = {
			class = pc_gas_giant
			orbit_distance = 25
			orbit_angle = { min = 90 max = 270 }
			#size = { min = 16 max = 20 }
			flags = { ignore_startup_effect habitat_3_planet has_orbital }

			init_effect = {
				set_deposit = d_energy_4
			}
		}
	}

	change_orbit = -210

	planet = {
		orbit_angle = { min = 90 max = 270 }
		class = pc_molten
		orbit_distance = 15

		flags = { ignore_startup_effect mining_planet }

		init_effect = {
			set_deposit = d_energy_4
		}
	}

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

		flags = { ignore_startup_effect mining_planet }

		init_effect = {
			set_deposit = d_minerals_4
		}
	}

	planet = {
		orbit_distance = 20
		class = pc_shattered
		name = "NAME_The_Fragments"
		orbit_angle = { min = 90 max = 270 }
		size = { min = 16 max = 20 }
		flags = { ignore_startup_effect has_megastructure habitat_1_planet }

		init_effect = {
			set_deposit = d_physics_3
		}

		moon = {
			class = pc_habitat
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
			size = 6
			starting_planet = yes
			flags = { void_dweller_habitat_1 special_start_planet megastructure habitat }
			deposit_blockers = none
		}
	}

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

		change_orbit = @base_moon_distance

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

	neighbor_system = {
		trigger = { num_guaranteed_colonies >= 2 }
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "neighbor_t1"
	}
	neighbor_system = {
		trigger = { num_guaranteed_colonies >= 1 }
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "neighbor_t1_first_colony"
	}
}

# Lost Colony Parent System 1
lost_colony_1 = {
	class = "rl_starting_stars"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 50
	}

	flags = { empire_home_system lost_colony_home_system }

	usage = misc_system_init

	usage_odds = {
		base = 0
		modifier = {
			any_playable_country = {
				has_origin = origin_lost_colony
				OR = {
					is_human_species = no
					AND = {
						is_human_species = yes
						capital_scope = { has_planet_flag = planet_earth }
					}
				}
				NOT = {
					has_country_flag = parent_system_spawned
					# don't spawn if AI-generated and adv start disabled
					# see game_start.1
					AND = {
						is_ai = yes
						check_galaxy_setup_value = { setting = num_advanced_empires value < 1 }
					}
				}
			}
			NOT = { has_star_flag = empire_cluster }
			add = @spawn_system_max
		}
	}

	init_effect = {
		generate_home_system_resources = yes
	}

	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 = {
		count = 1
		orbit_distance = 20
		home_planet = yes
		class = pc_continental
		orbit_angle = { min = 90 max = 270 }
		size = { min = @homeworld_min_size max = @homeworld_max_size }
		deposit_blockers = none
		modifiers = none
		flags = { lost_colony_homeworld }

		init_effect = {
			prevent_anomaly = yes

			random_country = {
				limit = {
					has_origin = origin_lost_colony
					NOT = {
						has_country_flag = parent_system_spawned
					}
				}
				set_country_flag = parent_system_spawned
				save_event_target_as = lost_colony_child
			}

			lost_colony_generate_parent_effect = yes
			create_colony = {
				owner = event_target:lost_colony_parent
			}
			set_planet_size = 20
			generate_start_deposits_and_blockers = yes
			clear_blockers = yes
			colony = {
				generate_start_buildings_and_districts = yes
				generate_start_pops = yes
				generate_lost_colony_parent_bonus = yes
			}
			event_target:lost_colony_parent = {
				if = {
					limit = {
						event_target:lost_colony_child = {
							is_nomadic = yes
						}
					}
					event_target:lost_colony_child = { # If we are nomads we need to change both species
						species = { set_species_homeworld = prevprevprev }
					}
				}
				create_starting_leaders = yes
				set_country_flag = lost_colony_parent
				set_country_flag = special_intro_for@event_target:lost_colony_child
				set_country_flag = lost_colony_parent_of@event_target:lost_colony_child
				country_event = { id = game_start.9 }
				country_event = { id = game_start.33 days = 1 } # needs delay for system ownership to settle
				owner_species = { set_species_homeworld = prevprev }
				set_name = random # Fixes some naming issues
				log = "LOST COLONY PARENT CREATED"
			}
		}

		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 = {
		solar_system = {
			create_starbase = {
				size = starbase_starport
				module = shipyard
				building = crew_quarters
				owner = event_target:lost_colony_parent
				effect = {
					if = {
						limit = {
							event_target:lost_colony_parent = {
								is_gestalt = yes
							}
						}
						if = {
							limit = {
								event_target:lost_colony_parent = {
									has_valid_civic = civic_machine_astromining_drones
								}
							}
							set_starbase_module = {
								slot = 1
								module = astromining_bay
							}
						}
						else = {
							set_starbase_module = {
								slot = 1
								module = solar_panel_network
							}
						}
					}
					else = {
						set_starbase_module = {
							slot = 1
							module = trading_hub
						}
					}
				}
			}
		}
	}

	neighbor_system = {
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "lost_colony_neighbor_t1"
	}
	neighbor_system = {
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "lost_colony_neighbor_t1_first_colony"
	}
}

# Neighbor Tier 1
lost_colony_neighbor_t1 = {
	class = "rl_standard_stars"
	flags = { neighbor_t1 }

	init_effect = {
		every_neighbor_system = { set_star_flag = empire_cluster }
	}

	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 = 0 max = 2 }
		orbit_distance = 20
		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_distance = 5
		}
	}

	planet = {
		count = { min = 2 max = 5 }
		orbit_distance = 20
	}

	init_effect = {
		create_starbase = {
			size = starbase_outpost
			owner = event_target:lost_colony_parent
		}
	}

	neighbor_system = {
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "lost_colony_neighbor_t2_second_colony"
	}
}

# Neighbor Tier 1 First Colony
lost_colony_neighbor_t1_first_colony = {
	class = "rl_standard_stars"
	flags = { neighbor_t1_first_colony }

	init_effect = {
		every_neighbor_system = { set_star_flag = empire_cluster }
	}

	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 = 0 max = 2 }
		orbit_distance = 20

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_distance = 5
		}
	}

	planet = {
		count = 1
		orbit_distance = 25
		class = pc_continental
		modifiers = none
		anomaly = none
		orbit_angle = { min = 90 max = 270 }
		size = { min = 12 max = 18 }
		flags = { lost_colony_planet }

		init_effect = {
			create_colony = {
				owner = event_target:lost_colony_parent
			}
			colony = {
				generate_lost_colony_parent_colony_1 = yes
			}
		}
	}

	planet = {
		count = { min = 2 max = 5 }
		orbit_distance = 25

		change_orbit = @base_moon_distance

		moon = {
			count = { min = 0 max = 1 }
			orbit_distance = 5
		}
	}

	init_effect = {
		create_starbase = {
			size = starbase_outpost
			owner = event_target:lost_colony_parent
		}
	}

	neighbor_system = {
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "neighbor_t2"
	}
}

# Neighbor Tier 2 Second Colony
lost_colony_neighbor_t2_second_colony = {
	class = "rl_standard_stars"
	flags = { neighbor_t2_second_colony }

	init_effect = {
		every_neighbor_system = { set_star_flag = empire_cluster }
	}

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

	change_orbit = 25

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

	planet = {
		count = 1
		orbit_distance = 25
		class = pc_continental
		modifiers = none
		anomaly = none
		orbit_angle = { min = 90 max = 270 }
		size = { min = 14 max = 24 }
		flags = { lost_colony_planet }

		init_effect = {
			create_colony = {
				owner = event_target:lost_colony_parent
			}
			colony = {
				generate_lost_colony_parent_colony_2 = 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_angle = { min = 90 max = 270 }
		orbit_distance = 20

		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 = 0 max = 2 }
		orbit_angle = { min = 90 max = 270 }
		orbit_distance = 20
	}

	init_effect = {
		create_starbase = {
			size = starbase_outpost
			owner = event_target:lost_colony_parent
		}
	}
}

# Scion Fallen Empire (if they were turned off in options)
scion_fallen_1 = {
	class = "rl_standard_stars"
	flags = { scion_fe_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 = scion_fe1_cluster
				radius = 120
				center = this.solar_system
			}
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				extra_trait_points = 3
				allow_negative_traits = no
			}
			create_country = {
				name = random
				type = fallen_empire
				ignore_initial_colony_error = yes
				authority = auth_imperial
				civics = {
					civic = civic_lethargic_leadership
					civic = civic_empire_in_decline
				}
				species = last_created_species
				ethos = {
					ethic = ethic_fanatic_materialist
				}
				flag = random
				origin = "origin_fallen_empire"
				effect = {
					set_country_flag = fallen_empire_1
					set_graphical_culture = fallen_empire_02
					save_event_target_as = scion_fe
					add_resource = {
						minerals = 10000
						energy = 10000
						food = 1000
						influence = 500
					}
					# must initialize global designs here
					add_global_ship_design = "NAME_Enforcer"
					add_global_ship_design = "NAME_Savant"
					add_global_ship_design = "NAME_Scholar"
					add_global_ship_design = "NAME_Sage"
					add_global_ship_design = "NAME_Cloaker"
					add_global_ship_design = "NAME_Librarian"
					add_global_ship_design = "NAME_Seeker"
					add_global_ship_design = "NAME_FE_Starbase"
				}
			}
			set_planet_flag = fallen_empire_world
			set_planet_flag = fallen_empire_capital
			prevent_anomaly = yes
			set_owner = event_target:scion_fe
			set_controller = event_target:scion_fe
			set_capital = yes

			# See planet set up in common\solar_system_initializers\fallen_empire_initializers.txt
			while = {
				count = 10
				add_district = district_arcology_housing
			}
			add_zone = {
				district = district_arcology_housing
				zone = zone_urban
			}
			add_zone = {
				district = district_arcology_housing
				zone = zone_urban
			}
			while = {
				count = 3
				add_district = district_arcology_urban_1
			}
			add_zone = {
				district = district_arcology_urban_1
				zone = zone_research_physics
			}
			while = {
				count = 3
				add_district = district_arcology_urban_2
			}
			add_zone = {
				district = district_arcology_urban_2
				zone = zone_research_engineering
			}
			while = {
				count = 3
				add_district = district_arcology_urban_3
			}
			add_zone = {
				district = district_arcology_urban_3
				zone = zone_research_society
			}
			while = {
				count = 94
				create_pop_group = {
					species = owner_main_species
				}
			}
			event_target:scion_fe = {
				set_policy = {
					policy = artificial_intelligence_policy
					option = ai_servitude
					cooldown = no
				}
				set_policy = {
					policy = robot_pop_policy
					option = robot_pops_allowed
					cooldown = no
				}
				random_playable_country = {
					limit = {
						has_origin = origin_scion
						has_country_flag = scion_needs_fe
					}
					remove_country_flag = scion_needs_fe
					save_event_target_as = scion_vassal
				}
				set_country_flag = scion_master
				save_event_target_as = scion_master
				add_opinion_modifier = {
					who = event_target:scion_vassal
					modifier = opinion_scion
				}
				country_event = { id = origin.20 days = 9000 random = 9000 }
				event_target:scion_vassal = {
					establish_communications_no_message = event_target:scion_fe
					set_subject_of = {
						who = event_target:scion_fe
						preset = preset_scion
					}
					add_opinion_modifier = {
						who = event_target:scion_fe
						modifier = opinion_scion
					}
					country_event = { id = origin.10 days = 3 }
				}
			}
			event_target:scion_fe = { 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 = event_target:scion_fe
					species = event_target:scion_fe
					type = "robotic_army"
				}
			}
		}
	}


	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
		}
	}

	init_effect = {
		create_starbase = {
			size = "starbase_citadel"
			owner = event_target:scion_fe

			module = "shipyard"
			module = "shipyard"
			module = "shipyard"
			module = "starbase_hangar_bay"
			module = "starbase_laser_battery"
			module = "starbase_laser_battery"

			building = "target_uplink_computer"
			building = "defense_grid"
			building = "capital_yards"

			effect = {
				while = {
					count = 10
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

scion_fallen_2 = {
	class = "rl_standard_stars"
	flags = { scion_fe_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_cluster = {
				id = scion_fe2_cluster
				radius = 140
				center = this.solar_system
			}
			create_species = {
				name = random
				class = random_non_machine
				portrait = random
				traits = random
				extra_trait_points = 3
				allow_negative_traits = no
			}
			create_country = {
				name = random
				type = fallen_empire
				ignore_initial_colony_error = yes
				authority = auth_imperial
				civics = {
					civic = civic_lethargic_leadership
					civic = civic_empire_in_decline
				}
				species = last_created_species
				ethos = {
					ethic = ethic_fanatic_spiritualist
				}
				flag = random
				origin = "origin_fallen_empire"
				effect = {
					set_country_flag = fallen_empire_2
					set_graphical_culture = fallen_empire_01
					save_event_target_as = scion_fe
					add_resource = {
						minerals = 10000
						energy = 10000
						food = 1000
						influence = 500
					}
					# must initialize global designs here
					add_global_ship_design = "NAME_Cleanser"
					add_global_ship_design = "NAME_Eternal"
					add_global_ship_design = "NAME_Avatar"
					add_global_ship_design = "NAME_Zealot"
					add_global_ship_design = "NAME_Penitent"
					add_global_ship_design = "NAME_Faith"
					add_global_ship_design = "NAME_Pilgrim"
					add_global_ship_design = "NAME_FE_Starbase"
				}
			}


			set_planet_flag = fallen_empire_world
			set_planet_flag = fallen_empire_capital
			prevent_anomaly = yes
			set_owner = event_target:scion_fe
			set_controller = event_target:scion_fe
			set_capital = yes

			# See planet set up in common\solar_system_initializers\fallen_empire_initializers.txt
			while = {
				count = 16
				add_district = district_city
			}
			while = {
				count = 2
				add_district_and_planet_size_if_needed_effect = {
					district = district_generator
				}
			}
			add_zone = {
				district = district_generator
				zone = zone_energy
			}
			while = {
				count = 6
				add_district_and_planet_size_if_needed_effect = {
					district = district_mining
				}
			}
			add_zone = {
				district = district_mining
				zone = zone_minerals
			}
			while = {
				count = 6
				add_district_and_planet_size_if_needed_effect = {
					district = district_farming
				}
			}
			add_zone = {
				district = district_farming
				zone = zone_food
			}
			add_building = building_ancient_palace
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_fe_temple_2
			add_building = building_fe_temple_2
			add_building = building_fe_mine_2
			add_building = building_fe_stronghold
			add_building = building_fe_stronghold
			add_building = building_dimensional_fabricator
			add_building = {
				zone = zone_energy
				building = building_class_4_singularity
			}
			add_building = building_affluence_center
			add_building = building_nano_forge
			while = {
				count = 115
				create_pop_group = {
					species = owner_main_species
				}
			}
			create_fallen_empire_starting_navy = yes
			while = {
				count = 20
				create_army = {
					name = random
					owner = event_target:scion_fe
					species = event_target:scion_fe
					type = "psionic_army"
				}
			}
			random_playable_country = {
				limit = {
					has_origin = origin_scion
					has_country_flag = scion_needs_fe
				}
				remove_country_flag = scion_needs_fe
				save_event_target_as = scion_vassal
			}
			event_target:scion_fe = {
				set_country_flag = scion_master
				save_event_target_as = scion_master
				add_opinion_modifier = {
					who = event_target:scion_vassal
					modifier = opinion_scion
				}
				country_event = { id = origin.20 days = 9000 random = 9000 }
			}
			event_target:scion_vassal = {
				establish_communications_no_message = event_target:scion_fe
				set_subject_of = {
					who = event_target:scion_fe
					preset = preset_scion
				}
				add_opinion_modifier = {
					who = event_target:scion_fe
					modifier = opinion_scion
				}
				country_event = { id = origin.10 days = 3 }
			}
		}

		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 = {
			set_planet_flag = fallen_empire_world
			prevent_anomaly = yes
			set_owner = event_target:scion_fe
			set_controller = event_target:scion_fe

			# See planet set up in common\solar_system_initializers\fallen_empire_initializers.txt
			while = {
				count = 12
				add_district = district_city
			}
			while = {
				count = 2
				add_district_and_planet_size_if_needed_effect = {
					district = district_generator
				}
			}
			add_zone = {
				district = district_generator
				zone = zone_energy
			}
			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_mining
				}
			}
			add_zone = {
				district = district_mining
				zone = zone_minerals
			}
			while = {
				count = 5
				add_district_and_planet_size_if_needed_effect = {
					district = district_farming
				}
			}
			add_zone = {
				district = district_farming
				zone = zone_food
			}
			while = {
				count = 68
				create_pop_group = {
					species = owner_main_species
				}
			}
			add_building = building_ancient_palace
			add_building = building_empyrean_shrine
			add_building = building_fe_dome
			add_building = building_fe_dome
			add_building = building_dimensional_fabricator
			add_building = building_fe_stronghold
			add_building = building_fe_stronghold
			add_building = {
				zone = zone_energy
				building = building_class_4_singularity
			}
			add_building = {
				zone = zone_energy
				building = building_class_4_singularity
			}
			add_building = {
				zone = zone_energy
				building = building_class_4_singularity
			}
			add_building = building_nano_forge
			add_building = building_nano_forge
			while = {
				count = 68
				create_pop_group = {
					species = owner_main_species
				}
			}
		}
	}

	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_starbase = {
			size = "starbase_citadel"
			owner = event_target:scion_fe

			module = "shipyard"
			module = "shipyard"
			module = "shipyard"
			module = "starbase_hangar_bay"
			module = "starbase_laser_battery"
			module = "starbase_laser_battery"

			building = "target_uplink_computer"
			building = "defense_grid"
			building = "capital_yards"

			effect = {
				while = {
					count = 10
					create_fallen_empire_platform = yes
				}
			}
		}
	}
}

# Shattered Ring Origin
shattered_ring_start = {
	flags = { empire_home_system ring_world_built shattered_ring_system }
	usage = origin

	init_effect = {
		every_neighbor_system = {
			set_star_flag = empire_cluster
			every_neighbor_system = {
				set_star_flag = empire_cluster
			}
		}
		generate_home_system_resources = yes
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 0
			orbit_distance = 45
			init_effect = {
				set_megastructure_flag = guaranteed_1
			}
		}
		spawn_megastructure = {
			type = "ring_world_ruined"
			orbit_angle = 180
			orbit_distance = 45
		}
	}

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

	change_orbit = 45

	planet = {
		class = "pc_ringworld_tech"
		name = "NAME_Ring_Section"
		orbit_angle = 240
		orbit_distance = 0
	}

	planet = {
		class = "pc_ringworld_seam"
		name = "NAME_Ring_Section"
		orbit_angle = 30
		orbit_distance = 0
	}

	planet = {
		class = "pc_shattered_ring_habitable"
		orbit_angle = 30
		orbit_distance = 0
		deposit_blockers = none
		modifiers = none
		starting_planet = yes
		flags = { ignore_startup_effect megastructure }
		init_effect = {
			prevent_anomaly = yes
		}
	}

	planet = {
		class = "pc_ringworld_tech_damaged"
		name = "NAME_Ring_Section"
		orbit_angle = 120
		orbit_distance = 0
	}

	planet = {
		class = "pc_ringworld_seam_damaged"
		name = "NAME_Irreparable_Damage"
		orbit_angle = 30
		orbit_distance = 0
		flags = { ignore_startup_effect starting_mining_target starting_deposit catastrophic_damage }

		init_effect = {
			create_ambient_object = {
				type = "medium_debris_01_object"
				entity_offset_height = -15
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 0
					angle = 0
				}
				set_ambient_object_flag = interloper_damage
			}
			set_deposit = d_engineering_5
			set_planet_flag = starting_research_target
			set_planet_flag = starting_deposit
		}
	}

	planet = {
		class = "pc_shattered_2"
		name = "NAME_The_Interloper"
		orbit_distance = -5
		orbit_angle = 0
		size = 5
		has_ring = no
		flags = { ignore_startup_effect starting_mining_target starting_deposit interloper }
		init_effect = {
			set_deposit = d_minerals_10
		}
	}

	planet = {
		class = "pc_ringworld_seam_damaged"
		name = "NAME_Ring_Section"
		orbit_angle = 30
		orbit_distance = 5
	}
	neighbor_system = {
		trigger = { num_guaranteed_colonies >= 2 }
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "neighbor_t1"
	}
	neighbor_system = {
		trigger = { num_guaranteed_colonies >= 1 }
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "neighbor_t1_first_colony"
	}
}

### Mega Shipyard - Randomly spawned
mega_shipyard_init_01 = {
	class = "rl_standard_stars"
	usage = misc_system_init

	flags = { ruined_mega_shipyard_system galactic_landmark_system }

	usage_odds = {
		base = 0
		modifier = {
			host_has_dlc = "Federations"
			add = @spawn_system_extreme
		}
	}

	max_instances = 1
	scaled_spawn_chance = 2

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

	change_orbit = 35

	# Inner misc. planets
	planet = {
		count = { min = 3 max = 7 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance

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

	init_effect = {
		spawn_megastructure = {
			type = "mega_shipyard_ruined"
			planet = star

			init_effect = {
				create_ambient_object = {
					type = "large_debris_object"
					location = this
				}
				last_created_ambient_object = {
					set_location = {
						target = prev
						distance = 20
						angle = 20
					}
				}
			}
		}
	}
}

# Shallarian System with a powerful guardian
planet_with_too_many_moons_system = {
	class = "rl_standard_stars"
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 125
	}

	usage = misc_system_init
	usage_odds = {
		base = 0
		modifier = { #spawns nearby the xenophobe FE
			add = @spawn_system_verycommon
			any_country = {
				has_country_flag = fallen_empire_4
			}
			NOT = { has_star_flag = empire_cluster }
			NAND = {
				exists = owner
				owner = {
					has_country_flag = fallen_empire_4
				}
			}
			NOT = {
				any_neighbor_system = {
					exists = owner
					owner = { has_country_flag = fallen_empire_4 }
				}
			}
			any_neighbor_system = {
				any_neighbor_system = {
					exists = owner
					owner = { has_country_flag = fallen_empire_4 }
				}
			}
		}
		complex_trigger_modifier = {
			trigger = check_galaxy_setup_value
			parameters = {
			  setting = habitable_worlds_scale
			}
			mode = factor
		}
	}

	max_instances = 1
	scaled_spawn_chance = 3

	flags = { planet_with_too_many_moons_system hostile_system ancient_wonders_system }

	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = { min = 20 max = 30 }
		has_ring = no
		init_effect = {
			save_event_target_as = too_many_moons_system_star
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				effect = {
					set_location = {
						target = prev
						distance = 15
						angle = random
					}
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				effect = {
					set_location = {
						target = prev
						distance = 35
						angle = random
					}
				}
			}
			create_ambient_object = {
				type = "ancient_battlefield_02_object"
				effect = {
					set_location = {
						target = prev
						distance = 90
						angle = random
					}
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
				effect = {
					set_location = {
						target = prev
						distance = 100
						angle = random
					}
				}
			}
			while = {
				count = 2
				create_ambient_object = {
					type = "large_debris_object"
					location = this
					effect = {
						set_location = {
							target = prev
							distance = 250
							angle = random
						}
					}
				}
			}
			while = {
				count = 4
				create_ambient_object = {
					type = "medium_debris_01_object"
					location = this
					effect = {
						set_location = {
							target = prev
							distance = 190
							angle = random
						}
					}
				}
			}
			while = {
				count = 3
				create_ambient_object = {
					type = "small_debris_object"
					location = this
					effect = {
						set_location = {
							target = prev
							distance = 150
							angle = random
						}
					}
				}
			}
		}
	}
	planet = {
		orbit_distance = 70
		class = pc_shattered
		orbit_angle = 50
		size = 25
		name = "NAME_Darad"
		init_effect = {
			prevent_anomaly = yes
			clear_deposits = yes
			add_deposit = d_minerals_4
		}
	}
	planet = {
		orbit_distance = 0
		orbit_angle = 180
		size = 25
		class = pc_nuked
		has_ring = yes

		name = "NAME_Shallash"

		flags = { colony_event }

		change_orbit = @base_moon_distance

		moon = {
			name = "NAME_Shallasha"
			orbit_angle = 0
			orbit_distance = 6
			size = { min = 10 max = 16 } #bit larger than normal moons, they started off as moons of a gas giant
			class = pc_shattered_2
			init_effect = {
				prevent_anomaly = yes
			}
		}
		moon = {
			name = "NAME_Shallashb"
			orbit_angle = 60
			orbit_distance = 0
			size = { min = 12 max = 16 }
			class = pc_molten
			init_effect = {
				prevent_anomaly = yes
			}
		}
		moon = {
			name = "NAME_Shallashc"
			orbit_angle = 60
			orbit_distance = 0
			size = { min = 10 max = 16 }
			class = pc_barren
			init_effect = {
				prevent_anomaly = yes
			}
		}
		moon = {
			name = "NAME_Shallashd"
			orbit_angle = 60
			orbit_distance = 0
			size = { min = 10 max = 16 }
			class = pc_barren_cold
			init_effect = {
				prevent_anomaly = yes
			}
		}
		moon = {
			name = "NAME_Shallashe"
			orbit_angle = 60
			orbit_distance = 0
			size = { min = 10 max = 16 }
			class = pc_frozen
			init_effect = {
				prevent_anomaly = yes
			}
		}
		moon = {
			name = "NAME_Shallashf"
			orbit_angle = 60
			orbit_distance = 0
			size = { min = 10 max = 16 }
			class = pc_toxic
			init_effect = {
				prevent_anomaly = yes
			}
		}
		init_effect = {
			prevent_anomaly = yes
			set_planet_flag = planet_with_too_many_moons

			create_ambient_object = {
				type = "ancient_battlefield_02_object"
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 5
					direction = in_system
				}
			}
			create_archaeological_site = site_ruins_of_shallash
		}
	}

	change_orbit = 55
	planet = {
		count = 4
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = { min = 15 max = 345 }
		init_effect = {
			prevent_anomaly = yes
			random_list = {
				4 = { }
				2 = {
					clear_deposits = yes
					set_deposit = d_minerals_3
				}
				2 = {
					clear_deposits = yes
					set_deposit = d_minerals_4
				}
				1 = {
					clear_deposits = yes
					set_deposit = d_minerals_5
				}
				1 = {
					clear_deposits = yes
					set_deposit = d_volatile_motes_2
				}
			}
		}
	}

	change_orbit = 25

	planet = {
		count = 3
		class = pc_gas_giant
		orbit_distance = 45
		orbit_angle = { min = 35 max = 325 }
	}


	init_effect = {
		random_system_planet = {
			limit = {
				has_planet_flag = planet_with_too_many_moons
			}
			save_event_target_as = too_many_moons_planet_1
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_asteroid = no
				is_moon = no
				NOT = {
					is_same_value = event_target:too_many_moons_planet_1
				}
			}
			save_event_target_as = too_many_moons_planet_2
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_asteroid = no
				is_moon = no
				NOR = {
					is_same_value = event_target:too_many_moons_planet_1
					is_same_value = event_target:too_many_moons_planet_2
				}
			}
			save_event_target_as = too_many_moons_planet_3
		}
		random_system_planet = {
			limit = {
				is_star = yes
				NOR = {
					is_same_value = event_target:too_many_moons_planet_1
					is_same_value = event_target:too_many_moons_planet_2
					is_same_value = event_target:too_many_moons_planet_3
				}
			}
			save_event_target_as = too_many_moons_planet_4
		}
		create_country = {
			name = "NAME_Warder_of_the_Ruins"
			type = faction
			flag = {
				icon = {
					category = "pointy"
					file = "flag_pointy_21.dds"
				}
				background= {
					category = "backgrounds"
					file = "00_solid.dds"
				}
				colors={
					"black"
					"black"
					"null"
					"null"
				}
			}
			effect = {
				set_graphical_culture = fallen_empire_04
				if = {
					limit = { NOT = { has_modifier = ancient_warden_boost } }
					add_modifier = {
						modifier = ancient_warden_boost
						days = -1
					}
				}
				save_global_event_target_as = ancient_warden_country

				create_fleet = {
					name = "NAME_Warder_of_the_Ruins"
					settings = {
						spawn_debris = no
					}
					effect = {
						set_owner = event_target:ancient_warden_country
						create_ship = {
							name = "NAME_Warder_of_the_Ruins"
							design = "NAME_Warder_of_the_Ruins"
						}
						set_location = {
							target = event_target:too_many_moons_system_star
							distance = 20
							angle = random
						}
						set_fleet_flag = too_many_moons_warder
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 100
						queue_actions = {
							repeat = {
								find_closest_planet = {
									trigger = {
										id = "ruinswarder.1.trigger.1"
										is_planet = event_target:too_many_moons_planet_1
									}
									found_planet = {
										move_to = this
										orbit_planet = THIS
									}
								}
								find_closest_planet = {
									trigger = {
										id = "ruinswarder.1.trigger.2"
										is_planet = event_target:too_many_moons_planet_2
									}
									found_planet = {
										move_to = this
										orbit_planet = THIS
									}
								}
								find_closest_planet = {
									trigger = {
										id = "ruinswarder.1.trigger.3"
										is_planet = event_target:too_many_moons_planet_3
									}
									found_planet = {
										move_to = this
										orbit_planet = THIS
									}
								}
								find_closest_planet = {
									trigger = {
										id = "ruinswarder.1.trigger.4"
										is_planet = event_target:too_many_moons_planet_4
									}
									found_planet = {
										move_to = this
										orbit_planet = THIS
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

wenkwort_initializer = {
	name = "NAME_Wenkwort"
	class = "rl_starting_stars"

	usage = misc_system_init
	usage_odds = {
		base = @spawn_system_slightlycommon
		inline_script = "solar_system_initializers/initializer_modifiers_habitable_world_systems"
	}
	max_instances = 1
	flags = { wenkwort_system natural_spectacle_system }

	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 135 #Distance from system centre
	}

	planet = {
		class = star
		orbit_distance = 0
		init_effect = {
			prevent_anomaly = yes
		}
	}

	planet = {
		name = "NAME_wenkwort_prime"
		class = "pc_gaia"

		orbit_distance = 65
		orbit_angle = 45
		size = 19
		has_ring = yes
		change_orbit = 4

		anomaly = "WENKWORT_CAT"

		home_planet = no
		init_effect = {
			save_global_event_target_as = wenkwort_artem
			add_modifier = { modifier = "pm_wenkwort_gardens" days = -1 }
		}

		moon = {
			name = "NAME_wenkwort_moon"
			class = "pc_barren_cold"
			orbit_distance = 15
			size = { min = 8 max = 12 }
			init_effect = {
				prevent_anomaly = yes
				save_global_event_target_as = wenkwort_moon
			}
		}
	}

	planet = {
		name = "NAME_wenkwort_2"
		class = "pc_barren"

		orbit_distance = 45
		orbit_angle = 135
		size = { min = 18 max = 25 }
		has_ring = no

		home_planet = yes
		init_effect = {
			prevent_anomaly = yes
			clear_deposits = yes
			add_modifier = {
				modifier = "terraforming_candidate" days = -1
			}
			save_global_event_target_as = wenkwort_rellrait
		}
	}

	planet = {
		name = "NAME_wenkwort_asteroid"
		class = "pc_asteroid"

		orbit_distance = 28
		orbit_angle = -20
		size = { min = 2 max = 4 }
		has_ring = no

		home_planet = yes
		init_effect = {
			set_deposit = d_minerals_3
			save_global_event_target_as = wenkwort_truin
		}
	}

	planet = {
		name = "NAME_wenkwort_3"
		class = "pc_toxic"

		orbit_distance = 30
		orbit_angle = 35
		size = { min = 15 max = 30 }
		has_ring = no

		home_planet = no
		init_effect = {
			prevent_anomaly = yes
			save_global_event_target_as = wenkwort_toxic
		}
	}

	planet = {
		name = "NAME_wenkwort_4"
		class = "pc_gas_giant"

		orbit_distance = 30
		orbit_angle = 55
		size = { min = 25 max = 50 }
		has_ring = no
		change_orbit = 12

		home_planet = no
		init_effect = {
			prevent_anomaly = yes
			save_global_event_target_as = wenkwort_gasgiant
		}
	}
}

# Sol System - Void-Dweller Origins Edition
sol_system_void_dweller_system = {
	name = "NAME_Sol_Void_Dweller"

	class = "sc_g"
	usage = origin
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 145
	}
	asteroid_belt = {
		type = icy_asteroid_belt
		radius = 290
	}

	flags = { empire_home_system sol_system sol }

	init_effect = {
		every_neighbor_system = {
			set_star_flag = empire_cluster
			every_neighbor_system = {
				set_star_flag = empire_cluster
			}
		}
		generate_home_system_resources = yes
	}

	planet = {
		name = "NAME_Sol"
		class = "pc_g_star"
		orbit_distance = 0
		orbit_angle = 1
		size = 30
		has_ring = no
	}

	planet = {
		name = "NAME_Mercury"
		class = "pc_molten"
		orbit_distance = 40
		orbit_angle = 15
		size = 10
		has_ring = no
		init_effect = {
			set_planet_entity = {
				entity = molten_planet_mercury_entity
				atmosphere_color = hsv { 0.8 0.1 0.2 }
				atmosphere_intensity = 0.1
				atmosphere_width = 1.0
			}
		}
		flags = {
			ignore_startup_effect
		}
	}

	planet = {
		name = "NAME_Venus"
		class = "pc_toxic"
		orbit_distance = 25
		orbit_angle = 125
		size = 17
		has_ring = no
		init_effect = {
			set_planet_entity = {
				entity = toxic_planet_venus_entity
				atmosphere_color = hsv { 0.854 0.072 0.7 }
				atmosphere_intensity = 0.2
				atmosphere_width = 1.0
			}
		}
	}

	planet = {
		name = "NAME_Old_Earth"
		class = "pc_toxic"
		orbit_distance = 25
		orbit_angle = 120
		size = 18
		has_ring = no
		modifiers = none
		flags = {
			planet_earth
			ignore_startup_effect
			habitat_1_planet
			has_megastructure
		}

		init_effect = {
			prevent_anomaly = yes
			clear_deposits = yes
			add_deposit = d_society_3
			save_global_event_target_as = sol_system_earth
		}

		moon = {
			name = "NAME_Luna"
			class = "pc_barren_cold"
			size = 5
			orbit_distance = 12
			orbit_angle = 40
			has_ring = no
			entity = "cold_barren_planet_luna_entity"
		}

		moon = {
			name = "NAME_Earth_Habitat"
			class = pc_habitat
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
			size = 6
			starting_planet = yes
			flags = {
				void_dweller_habitat_1
				special_start_planet
				megastructure habitat
				earth_habitat
			}
			deposit_blockers = none
		}
	}

	planet = {
		name = "NAME_Mars"
		class = "pc_shattered"
		orbit_distance = 25
		orbit_angle = 60
		flags = {
			ignore_startup_effect
			habitat_2_planet
			has_orbital
		}
		size = 13
		has_ring = no

		init_effect = {
			clear_deposits = yes
			add_deposit = d_minerals_3
		}
	}

	planet = {
		name = "NAME_1_Ceres"
		class = "pc_asteroid"
		orbit_distance = 30
		orbit_angle = -210
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_2_Pallas"
		class = "pc_asteroid"
		orbit_distance = 0
		orbit_angle = -95
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_3_Juno"
		class = "pc_asteroid"
		orbit_distance = 0
		orbit_angle = 285
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_4_Vesta"
		class = "pc_asteroid"
		orbit_distance = 0
		orbit_angle = -80
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_Jupiter"
		class = "pc_gas_giant"
		orbit_distance = 40
		orbit_angle = -160
		size = 35
		has_ring = no
		flags = { planet_jupiter }
		entity = "gas_giant_jupiter_entity"
		change_orbit = 6

		moon = {
			name = "NAME_Io"
			class = "pc_molten"
			size = 6
			orbit_distance = 10
			orbit_angle = 110
			has_ring = no
			flags = { moon_io }
		}
		moon = {
			name = "NAME_Europa"
			class = "pc_frozen"
			size = 6
			orbit_distance = 2.5
			orbit_angle = 190
			has_ring = no
			flags = { moon_europa }
		}
		moon = {
			name = "NAME_Ganymede"
			class = "pc_frozen"
			size = 9
			orbit_distance = 2.5
			orbit_angle = 80
			has_ring = no
			flags = { moon_ganymede }
		}
		moon = {
			name = "NAME_Callisto"
			class = "pc_frozen"
			size = 7
			orbit_distance = 2.5
			orbit_angle = -155
			has_ring = no
			flags = { moon_callisto }
		}
	}

	planet = {
		name = "NAME_Saturn"
		class = "pc_gas_giant"
		orbit_distance = 25
		orbit_angle = 170
		size = 30
		has_ring = yes
		entity = "gas_giant_05_entity"
		change_orbit = 7
		flags = {
			ignore_startup_effect
			habitat_3_planet
			has_orbital
		}

		init_effect = {
			clear_deposits = yes
			add_deposit = d_energy_4
		}


		moon = {
			name = "NAME_Titan"
			class = "pc_frozen"
			size = 8
			orbit_distance = 12
			orbit_angle = 320
			has_ring = no
		}
	}

	planet = {
		name = "NAME_Uranus"
		class = "pc_gas_giant"
		orbit_distance = 25
		orbit_angle = 125
		size = 20
		has_ring = no
		entity = "gas_giant_03_entity"
		init_effect = {
			set_planet_entity = {
				entity = gas_giant_uranus_entity
				atmosphere_color = hsv { 0.548 0.519 0.9 }
				atmosphere_intensity = 0.1
				atmosphere_width = 1.0
			}
		}
	}

	planet = {
		name = "NAME_Neptune"
		class = "pc_gas_giant"
		orbit_distance = 25
		orbit_angle = -195
		size = 20
		has_ring = no
		entity = "gas_giant_02_entity"
		change_orbit = 4

		moon = {
			name = "NAME_Triton"
			class = "pc_frozen"
			size = 6
			orbit_distance = 7
			orbit_angle = 115
			has_ring = no
		}

		init_effect = {
			set_planet_entity = {
				entity = gas_giant_neptune_entity
				atmosphere_color = hsv { 0.626 0.782 0.9 }
				atmosphere_intensity = 0.1
				atmosphere_width = 1.0
			}
		}
	}

	planet = {
		name = "NAME_134340_Pluto"
		class = "pc_asteroid"
		orbit_distance = 30
		orbit_angle = -210
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_136472_Makemake"
		class = "pc_ice_asteroid"
		orbit_distance = 0
		orbit_angle = -95
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_136108_Haumea"
		class = "pc_ice_asteroid"
		orbit_distance = 0
		orbit_angle = 285
		size = 5
		has_ring = no
	}

	planet = {
		name = "NAME_20000_Varuna"
		class = "pc_ice_asteroid"
		orbit_distance = 0
		orbit_angle = -80
		size = 5
		has_ring = no
	}

	neighbor_system = {
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "sol_neighbor_t1"
	}
	neighbor_system = {
		trigger = { num_guaranteed_colonies >= 1 }
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "sol_neighbor_t1_first_colony"
	}
	neighbor_system = {
		trigger = { num_guaranteed_colonies = 0 }
		hyperlane_jumps = { min = 1 max = @jumps }
		initializer = "sol_neighbor_t1_no_guaranteed_colony"
	}
}
