@distance = 50
@base_moon_distance = 10

# Relic World
relic_system_1 = {
	class = "rl_binary_stars"
	asteroid_belt = {
		type = icy_asteroid_belt
		radius = 168
	}

	usage = misc_system_init

	usage_odds = {
		base = @spawn_system_common
		modifier = {
			factor = 0
			is_bottleneck_system = yes
		}
		 modifier = {
			factor = 0
			has_ancrel = no
		}
		inline_script = {
			script = solar_system_initializers/initializer_modifiers_habitable_world_systems_mult
			VALUE = 0.4 # e.g. 0.5x habitable = factor of 0.2; 5x habitable worlds = factor of 2
		}
	}

	max_instances = 1
	scaled_spawn_chance = 4

	flags = { relic_system_1 precursor_system }

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

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

	change_orbit = 45

	planet = {
		class = pc_molten
		size = 13
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		class = pc_molten
		size = 9
		orbit_distance = 25
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		class = pc_molten
		size = 17
		orbit_distance = 25
		orbit_angle = { min = 90 max = 270 }

		moon = {
			class = "pc_barren"
			orbit_distance = 12
			size = 10
			orbit_angle = { min = 90 max = 270 }
		}
	}

	change_orbit = 30

	planet = {
		count = { min = 2 max = 3 }
		class = pc_ice_asteroid
		orbit_distance = 0
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 35

	planet = {
		class = pc_toxic
		size = 26
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 30

	planet = {
		class = pc_shielded
		size = 30
		has_ring = no
		orbit_angle = { min = 90 max = 270 }
		flags = { minigalaxy_planet }

		init_effect = {
			prevent_anomaly = yes

			create_country = {
				name = "NAME_Armistice_Initiative"
				type = faction
			}
			last_created_country = {
				create_fleet = {
					name = "NAME_Occupation_Flotilla"
					settings = { spawn_debris = no }
					effect = {
						set_owner = PREV
						while = {
							count = 12
							create_ship = {
								name = "NAME_Autonomous_Drone"
								design = "NAME_Guardian"
							}
						}
						set_location = prevprev
						set_fleet_stance = aggressive
						set_aggro_range_measure_from = self
						set_aggro_range = 500
						add_modifier = {
							modifier = armistice_power
							days = -1
						}
					}
				}
			}
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 12
			size = 10
			has_ring = no
			orbit_angle = { min = 90 max = 270 }
			flags = { minigalaxy_moon }

			init_effect = { prevent_anomaly = yes }
		}
	}

	planet = {
		class = pc_gas_giant
		size = 22
		orbit_distance = 30
		orbit_angle = { min = 90 max = 270 }

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 14
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_frozen"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}
	}
}

# Zrocursor Home System
Zrocursor_system = {
	name = "NAME_Zron"
	class = "sc_f"
	max_instances = 1
	asteroid_belt = {
		type = rocky_asteroid_belt
		radius = 125
	}
	flags = { Zrocursor precursor_system }

	planet = {
		class = star
		orbit_distance = 0
	}

	planet = {
		class = "pc_molten"
		orbit_distance = 35
		orbit_angle = 40
		size = 15
		has_ring = no
	}

	planet = {
		class = "pc_broken"
		orbit_distance = 20
		orbit_angle = 210
		size = 25
		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
				}
			}
		}
	}

	planet = {
		class = "pc_shattered"
		orbit_distance = 20
		orbit_angle = 70
		size = 20
		has_ring = no

		init_effect = {
			prevent_anomaly = yes
			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
				}
			}
		}
	}

	planet = {
		class = "pc_broken"
		orbit_distance = 20
		orbit_angle = 275
		size = 15
		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
				}
			}
		}
	}

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

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

	planet = {
		class = "pc_barren"
		orbit_distance = 30
		orbit_angle = 45
		size = 20
		has_ring = no
	}

	planet = {
		name = "NAME_Zron_Prime"
		class = "pc_shrouded"
		orbit_distance = 50
		orbit_angle = 145
		size = 35
		has_ring = no
		flags = { Zrocursor_homeworld }

		init_effect = {
			prevent_anomaly = yes
			clear_deposits = yes
			create_archaeological_site = zroni_digsite_6
			add_deposit = d_zro_deposit_5
		}
	}

	planet = {
		class = "pc_gas_giant"
		orbit_distance = 20
		orbit_angle = 145
		size = 20
		has_ring = no

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

		moon = {
			class = "pc_frozen"
			size = 8
			orbit_distance = 4
			orbit_angle = 150
			has_ring = no
		}
	}

	planet = {
		class = "pc_gas_giant"
		orbit_distance = 20
		orbit_angle = 145
		size = 25
		has_ring = no

		init_effect = {
			prevent_anomaly = yes
		}
	}

	planet = {
		class = "pc_shattered"
		orbit_distance = 20
		orbit_angle = 45
		size = 15
		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
				}
			}
		}
	}
}

# Relic World
relic_system_4 = {
	class = "sc_b"
	asteroid_belt = {
		type = icy_asteroid_belt
		radius = 168
	}

	usage = misc_system_init

	usage_odds = {
		base = @spawn_system_common
		modifier = {
			factor = 0
			is_bottleneck_system = yes
		}
		 modifier = {
			factor = 0
			has_ancrel = no
		}
		inline_script = {
			script = solar_system_initializers/initializer_modifiers_habitable_world_systems_mult
			VALUE = 0.4 # e.g. 0.5x habitable = factor of 0.2; 5x habitable worlds = factor of 2
		}
	}

	max_instances = 1
	scaled_spawn_chance = 4

	flags = { relic_system_4 }

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

	change_orbit = 45

	planet = {
		class = pc_molten
		size = 13
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		class = pc_molten
		size = 9
		orbit_distance = 25
		orbit_angle = { min = 90 max = 270 }
	}

	planet = {
		class = pc_molten
		size = 17
		orbit_distance = 25
		orbit_angle = { min = 90 max = 270 }

		moon = {
			class = "pc_broken"
			orbit_distance = 12
			size = 10
			orbit_angle = { min = 90 max = 270 }
		}
	}

	change_orbit = 30

	planet = {
		count = { min = 2 max = 3 }
		class = pc_ice_asteroid
		orbit_distance = 0
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 35

	planet = {
		class = pc_toxic
		size = 26
		orbit_angle = { min = 90 max = 270 }
	}

	change_orbit = 30

	planet = {
		class = pc_relic
		size = 25
		has_ring = no
		orbit_angle = { min = 90 max = 270 }
		flags = { omnicodex_planet }

		init_effect = {
			prevent_anomaly = yes
			clear_deposits = yes
			relic_world_deposits = yes
			create_archaeological_site = omnirelic_site
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 12
			size = 10
			has_ring = no
			orbit_angle = { min = 90 max = 270 }
		}
	}

	planet = {
		class = pc_gas_giant
		size = 40
		orbit_distance = 30
		orbit_angle = { min = 90 max = 270 }

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 14
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_frozen"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}
	}

	planet = {
		class = pc_gas_giant
		size = 25
		orbit_distance = 40
		orbit_angle = { min = 90 max = 270 }

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 14
			orbit_angle = { min = 90 max = 270 }
		}

		moon = {
			class = "pc_barren_cold"
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
		}

	}
}

# The Last Baol System
last_baol_system = {
	name = "NAME_Grunur"
	class = "sc_a"
	asteroid_belt = {
		type = icy_asteroid_belt
		radius = 250
	}
	flags = { last_baol_system }

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

	planet = {
		class = "pc_barren"
		orbit_distance = 40
		orbit_angle = 15
		size = 15
		init_effect = {
			prevent_anomaly = yes
		}
	}

	planet = {
		class = "pc_molten"
		orbit_distance = 20
		orbit_angle = 60
		size = 17
		init_effect = {
			prevent_anomaly = yes
		}
	}

	planet = {
		class = "pc_barren_cold"
		orbit_distance = 25
		orbit_angle = 120
		size = 12
		init_effect = {
			prevent_anomaly = yes
		}
	}

	planet = {
		name = "NAME_Grunur_Prime"
		class = "pc_nuked"
		orbit_distance = 25
		orbit_angle = 120
		size = 20
		init_effect = {
			prevent_anomaly = yes
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = random
				}
				save_global_event_target_as = the_last_baol_obj
			}
			create_ambient_object = {
				type = "large_debris_object"
			}
			last_created_ambient_object = {
				set_location = event_target:the_last_baol_obj
			}
			clear_deposits = yes
			clear_blockers = yes
			add_deposit = d_metal_boneyard
			add_deposit = d_metal_boneyard
			add_deposit = d_irradiated_valley
			add_deposit = d_irradiated_valley
			add_deposit = d_impact_crater
			add_deposit = d_ore_rich_caverns
			add_deposit = d_ore_rich_caverns
			add_deposit = d_underwater_vent
			add_deposit = d_radioactive_wasteland
			add_deposit = d_city_ruins
			add_deposit = d_city_ruins
			set_carrier_flag = grunur_prime
		}
	}

	planet = {
		class = "pc_broken"
		orbit_distance = 35
		orbit_angle = 1
		size = 16
		init_effect = {
			prevent_anomaly = yes
		}
		moon = {
			class = "pc_broken"
			size = 6
			orbit_distance = 12
			orbit_angle = 50
			has_ring = no
		}
	}

	planet = {
		class = "pc_gas_giant"
		orbit_distance = 45
		orbit_angle = 165
		size = 30
		has_ring = yes
		init_effect = {
			prevent_anomaly = yes
		}

		moon = {
			class = "pc_toxic"
			size = 7
			orbit_distance = 15
			orbit_angle = 100
			init_effect = {
				prevent_anomaly = yes
			}
		}
	}
}

# The Planetary Mechanocalibrator
mechanocalibrator_system = {
	class = "sc_binary_10"

	usage = misc_system_init
	usage_odds = {
		base = @spawn_system_common
		modifier = {
			factor = 0
			has_ancrel = no
		}
		inline_script = {
			script = solar_system_initializers/initializer_modifiers_habitable_world_systems_mult
			VALUE = 0.4 # e.g. 0.5x habitable = factor of 0.2; 5x habitable worlds = factor of 2
		}
	}
	scaled_spawn_chance = 8
	max_instances = 1

	flags = { mechanocalibrator_system }

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

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

	change_orbit = 55

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

	change_orbit = 35

	planet = {
		count = 1
		class = "pc_relic"
		orbit_angle = { min = 90 max = 270 }
		init_effect = {
			clear_deposits = yes
			save_global_event_target_as = mechanocalibrator_planet
			add_deposit = d_shattered_solar_array
			add_deposit = d_flooded_reactor_pits
			add_deposit = d_ancient_reactor_pits
			add_deposit = d_collapsed_spire
			add_deposit = d_relic_metal_boneyard
			add_deposit = d_relic_dense_ruins
		}
	}

	change_orbit = 35

	planet = {
		count = { min = 2 max = 3 }
		orbit_angle = { min = 90 max = 270 }

		change_orbit = @base_moon_distance
	}
}

# The Rubricator System
rubricator_system = {
	class = rl_standard_stars
	usage = misc_system_init

	usage_odds = 0

	flags = { rubricator_system }

	prevent_anomalies = yes

	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 = 4 }
		class = rl_unhabitable_planets
		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
		}
	}

	planet = {
		class = pc_relic
		orbit_distance = 30
		init_effect = {
			set_carrier_flag = rubricator_planet
			save_global_event_target_as = rubricator_planet
			relic_world_deposits = yes
			create_archaeological_site = rubricator_digsite
		}
	}
	planet = {
		count = { min = 2 max = 4 }
		class = rl_unhabitable_planets
		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 = rubricator_system
	}
}

