
planetmega_eg_init_01 = {
	class = "rl_standard_stars"
	usage = misc_system_init

	flags = { ruined_plnmg_eg_system }

	usage_odds = {
		base = @spawn_system_uncommon
	}

	max_instances = 1
	scaled_spawn_chance = 1

	planet = {
		class = star
		orbit_distance = 0
	}

	change_orbit = 45

	planet = {
		class = "pc_nuked"
		size = 16

		init_effect = {
			add_blocker = { type = d_plnmg_eg_destroyed }
			save_event_target_as = plnmg_eg_planet
		}
	}

	change_orbit = 25

	planet = {
		class = "pc_barren"
		size = { min = 10 max = 15 }

		init_effect = {
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			create_ambient_object = {
				type = "medium_debris_01_object"
				location = this
			}
		}
	}

	change_orbit = 25

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

		init_effect = {
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = 270
				}
			}
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = 180
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
			}
		}

		moon = {
			class = "pc_barren"
			size = 6
			orbit_distance = 20
			orbit_angle = { min = 90 max = 270 }
			has_ring = no

			init_effect = {
				create_ambient_object = {
					type = "abandoned_starbase_01_object"
					location = this
				}
				create_ambient_object = {
					type = "medium_debris_01_object"
					location = this
				}
			}
		}
	}

	change_orbit = 25

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

		init_effect = {
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 7
					angle = 270
				}
			}
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 7
					angle = 180
				}
			}
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 7
					angle = 0
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = 0
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = 180
				}
			}
		}

		moon = {
			class = "pc_barren_cold"
			size = 6
			orbit_distance = 20
			orbit_angle = { min = 90 max = 270 }
			has_ring = no
		}
		moon = {
			class = "pc_frozen"
			size = 6
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
			has_ring = no
		}
		moon = {
			class = "pc_barren"
			size = 6
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
			has_ring = no
		}
	}

	change_orbit = 25

	planet = {
		class = "pc_gas_giant"
		orbit_angle = { min = 90 max = 270 }
		size = 35

		init_effect = {
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = 270
				}
			}
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = 180
				}
			}
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = 0
				}
			}
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 10
					angle = 90
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = 180
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = 0
				}
			}
			create_ambient_object = {
				type = "large_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_location = {
					target = prev
					distance = 15
					angle = 270
				}
			}
		}

		moon = {
			class = "pc_frozen"
			size = 6
			orbit_distance = 20
			orbit_angle = { min = 90 max = 270 }
			has_ring = no
		}
		moon = {
			class = "pc_frozen"
			size = 6
			orbit_distance = 6
			orbit_angle = { min = 90 max = 270 }
			has_ring = no

			init_effect = {
				create_ambient_object = {
					type = "abandoned_starbase_01_object"
					location = this
				}
				create_ambient_object = {
					type = "medium_debris_01_object"
					location = this
				}
			}
		}
	}

	change_orbit = 25

	planet = {
		class = "pc_frozen"
		size = { min = 10 max = 15 }

		init_effect = {
			create_ambient_object = {
				type = "abandoned_starbase_01_object"
				location = this
			}
			create_ambient_object = {
				type = "medium_debris_02_object"
				location = this
			}
		}
	}

	init_effect = {
		spawn_megastructure = {
			type = "planetmega_eg_gateway_ruined"
			planet = event_target:plnmg_eg_planet
			orbit_angle = 15
			orbit_distance = 15
		}

		create_ambient_object = {
			type = "large_debris_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "large_debris_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "large_debris_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "medium_debris_01_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "medium_debris_02_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "medium_debris_01_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "medium_debris_02_object"
			location = solar_system
		}
		create_ambient_object = {
			type = "small_debris_object"
			location = solar_system
		}
	}
}
