@base_moon_distance = 10

# Crystal Entities - Blue
hostile_init_01 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 2
	
	flags = { hostile_system blue_system }

	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 = {
		create_crystal_country = yes
		random_system_planet = {
			limit = { is_star = no }
			event_target:crystal_country = {
				create_fleet = { name = "Crystalline Entity" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 150
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Blue"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Blue"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Blue"
					}
					set_location = PREVPREV
				}
			}
		}		
	}
}

# Crystal Entities - Blue VARIATION
hostile_init_02 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 2
	
	flags = { hostile_system blue2_system }

	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 = {
		create_crystal_country = yes
		random_system_planet = {
			limit = {
				is_star = no
			}
			save_event_target_as = blue2_trigger_1
		}
		random_system_planet = {
			limit = {
				is_star = no
				NOT = {
					is_same_value = event_target:blue2_trigger_1
				}
			}
			save_event_target_as = blue2_trigger_2
		}
		random_system_planet = {
			limit = {
				is_star = no
				NOT = {
					is_same_value = event_target:blue2_trigger_1
					is_same_value = event_target:blue2_trigger_2
				}
			}
			save_event_target_as = blue2_trigger_3
		}
		event_target:crystal_country = {
			if = { limit = { exists = event_target:blue2_trigger_3 }
				create_fleet = { name = "Crystalline Entity" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 150
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Blue"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Blue"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Blue"
					}
					set_location = event_target:blue2_trigger_3
				}
			}
			if = { limit = { exists = event_target:blue2_trigger_2 }
				create_fleet = { name = "Crystalline Entity" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Blue"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Blue"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Blue"
					}
					set_location = event_target:blue2_trigger_2
				}
			}
			if = { limit = { exists = event_target:blue2_trigger_1 }
				create_fleet = { name = "Crystalline Entity" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Blue"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Blue"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Blue"
					}
					set_location = event_target:blue2_trigger_1
				}
			}
		}		
	}
}

# Crystal Entities - Green (Patrol)
hostile_init_03 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 2

	flags = { hostile_system green_system }

	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 = 3 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 = {
		create_crystal_country = yes
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
			}
			save_event_target_as = green_trigger_1
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:green_trigger_1
				}
			}
			save_event_target_as = green_trigger_2
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:green_trigger_1
					is_same_value = event_target:green_trigger_2
				}
			}
			save_event_target_as = green_trigger_3
		}
		event_target:crystal_country = {
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = self
				set_aggro_range = 100
				create_ship = {
					name = "Delta"
					design = "Large Crystal Entity Green"
				}
				create_ship = {
					name = "Epsilon"
					design = "Medium Crystal Entity Green"
				}
				create_ship = {
					name = "Omega"
					design = "Small Crystal Entity Green"
				}
				set_location = event_target:green_trigger_3
				queue_actions = {
					repeat = {
						find_closest_planet = {
							trigger = {
								id = "greenC.1.trigger.1"
								is_planet = event_target:green_trigger_1
							}
							found_planet = {
								move_to = this
								orbit_planet = THIS
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC.1.trigger.2"
								is_planet = event_target:green_trigger_2
							}
							found_planet = {
								move_to = this
								orbit_planet = THIS
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC.1.trigger.3"
								is_planet = event_target:green_trigger_3
							}
							found_planet = {
								move_to = this
								orbit_planet = THIS
							}
						}
					}
				}
			}
		}
	}
}

# Crystal Entities - Green (Patrol) VARIATION
hostile_init_04 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 2
	
	flags = { hostile_system green2_system }

	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 = 3 max = 3 }
		orbit_distance = 20
		orbit_angle = { min = 90 max = 270 }
		
		change_orbit = @base_moon_distance
		
		moon = {
			count = { min = 0 max = 0 }
			orbit_angle = { min = 90 max = 270 }
			orbit_distance = 5
		}
	}
	
	init_effect = {
		create_crystal_country = yes
		random_system_planet = {
			limit = {
				is_star = no
			}
			save_event_target_as = green2_trigger_1
		}
		random_system_planet = {
			limit = {
				is_star = no
				NOT = {
					is_same_value = event_target:green2_trigger_1
				}
			}
			save_event_target_as = green2_trigger_2
		}
		random_system_planet = {
			limit = {
				is_star = no
				NOT = {
					is_same_value = event_target:green2_trigger_1
					is_same_value = event_target:green2_trigger_2
				}
			}
			save_event_target_as = green2_trigger_3
		}
		event_target:crystal_country = {
			save_event_target_as = green2_owner
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 40
				create_ship = {
					name = "Omega"
					design = "Small Crystal Entity Green"
				}
				create_ship = {
					name = "Iota"
					design = "Small Crystal Entity Green"
				}
				create_ship = {
					name = "Mu"
					design = "Small Crystal Entity Green"
				}
				set_location = event_target:green2_trigger_3
				queue_actions = {
					repeat = {
						find_closest_planet = {
							trigger = {
								id = "greenC2.1.trigger.1"
								is_planet = event_target:green2_trigger_1
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC2.1.trigger.2"
								is_planet = event_target:green2_trigger_2
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC2.1.trigger.3"
								is_planet = event_target:green2_trigger_3
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = self
				set_aggro_range = 40
				create_ship = {
					name = "Omega"
					design = "Small Crystal Entity Green"
				}
				create_ship = {
					name = "Iota"
					design = "Small Crystal Entity Green"
				}
				create_ship = {
					name = "Mu"
					design = "Small Crystal Entity Green"
				}
				set_location = event_target:green2_trigger_1
				queue_actions = {
					repeat = {
						find_closest_planet = {
							trigger = {
								id = "greenC2.2.trigger.2"
								is_planet = event_target:green2_trigger_2
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC2.2.trigger.3"
								is_planet = event_target:green2_trigger_3
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC2.2.trigger.1"
								is_planet = event_target:green2_trigger_1
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = self
				set_aggro_range = 40
				create_ship = {
					name = "Omega"
					design = "Small Crystal Entity Green"
				}
				create_ship = {
					name = "Iota"
					design = "Small Crystal Entity Green"
				}
				create_ship = {
					name = "Mu"
					design = "Small Crystal Entity Green"
				}
				set_location = event_target:green2_trigger_2
				queue_actions = {
					repeat = {
						find_closest_planet = {
							trigger = {
								id = "greenC2.3.trigger.3"
								is_planet = event_target:green2_trigger_3
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC2.3.trigger.1"
								is_planet = event_target:green2_trigger_1
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
						find_closest_planet = {
							trigger = {
								id = "greenC2.3.trigger.2"
								is_planet = event_target:green2_trigger_2
							}
							found_planet = {
								move_to = this
								orbit_planet = this
							}
						}
					}
				}
			}
		}
	}
}

# Crystal Entities - Red (Guardians)
hostile_init_05 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 2
	
	flags = { hostile_system red_system }

	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 = 4 max = 8 }
		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_star = no
				is_moon = no
			}
			save_event_target_as = red_trigger_1
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:red_trigger_1
				}
			}
			save_event_target_as = red_trigger_2
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:red_trigger_1
					is_same_value = event_target:red_trigger_2
				}
			}
			save_event_target_as = red_trigger_3
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:red_trigger_1
					is_same_value = event_target:red_trigger_2
					is_same_value = event_target:red_trigger_3
				}
			}
			save_event_target_as = red_trigger_4
		}
		create_crystal_country = yes
		event_target:crystal_country = {
			create_fleet = { name = "Crystalline Entity" }
			save_event_target_as = red_crystals
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 40
				create_ship = {
					name = "Delta"
					design = "Large Crystal Entity Red"
				}
				set_location = event_target:red_trigger_1
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 30
				set_owner = event_target:crystal_country
				create_ship = {
					name = "Epsilon"
					design = "Large Crystal Entity Red"
				}
				set_location = event_target:red_trigger_2
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 40
				create_ship = {
					name = "Omega"
					design = "Large Crystal Entity Red"
				}
				set_location = event_target:red_trigger_3
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 30
				create_ship = {
					name = "Alpha"
					design = "Large Crystal Entity Red"
				}
				set_location = event_target:red_trigger_4
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
		}
	}
}

# Crystal Entities - Red (Guardians) VARIATION
hostile_init_06 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 2
	
	flags = { hostile_system red2_system }

	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 = 6 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 = {
		create_crystal_country = yes
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
			}
			save_event_target_as = red2_trigger_1
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:red2_trigger_1
				}
			}
			save_event_target_as = red2_trigger_2
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:red2_trigger_1
					is_same_value = event_target:red2_trigger_2
				}
			}
			save_event_target_as = red2_trigger_3
		}
		random_system_planet = {
			limit = {
				is_star = no
				is_moon = no
				NOT = {
					is_same_value = event_target:red2_trigger_1
					is_same_value = event_target:red2_trigger_2
					is_same_value = event_target:red2_trigger_3
				}
			}
			save_event_target_as = red2_trigger_4
		}
		event_target:crystal_country = {
			create_fleet = { name = "Crystalline Entity" }
			save_event_target_as = red2_crystals
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 100
				create_ship = {
					name = "Delta"
					design = "Large Crystal Entity Red"
				}
				create_ship = {
					name = "Omicron"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Kappa"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Lambda"
					design = "Small Crystal Entity Red"
				}
				create_ship = {
					name = "Tau"
					design = "Small Crystal Entity Red"
				}
				set_location = event_target:red2_trigger_1
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 100
				create_ship = {
					name = "Epsilon"
					design = "Large Crystal Entity Red"
				}
				create_ship = {
					name = "Omicron"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Kappa"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Lambda"
					design = "Small Crystal Entity Red"
				}
				create_ship = {
					name = "Tau"
					design = "Small Crystal Entity Red"
				}
				set_location = event_target:red2_trigger_2
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 100
				create_ship = {
					name = "Omega"
					design = "Large Crystal Entity Red"
				}
				create_ship = {
					name = "Omicron"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Kappa"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Lambda"
					design = "Small Crystal Entity Red"
				}
				create_ship = {
					name = "Tau"
					design = "Small Crystal Entity Red"
				}
				set_location = event_target:red2_trigger_3
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
			create_fleet = { name = "Crystalline Entity" }
			last_created_fleet = {
				set_owner = event_target:crystal_country
				set_fleet_stance = aggressive
				set_aggro_range_measure_from = return_point
				set_aggro_range = 100
				create_ship = {
					name = "Alpha"
					design = "Large Crystal Entity Red"
				}
				create_ship = {
					name = "Omicron"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Kappa"
					design = "Medium Crystal Entity Red"
				}
				create_ship = {
					name = "Lambda"
					design = "Small Crystal Entity Red"
				}
				create_ship = {
					name = "Tau"
					design = "Small Crystal Entity Red"
				}
				set_location = event_target:red2_trigger_4
				queue_actions = {
					repeat = {
						wait = {
							duration = 9999
						}
					}
				}
			}
		}
	}
}

# Crystal Entities - Elites (Hunting)
hostile_init_07 = {

	class = sc_pulsar
	
	usage = misc_system_init
	usage_odds = 1
	
	flags = { hostile_system elite_system }
	
	planet = {
		class = star
		orbit_distance = 0
	}
	
	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 = {
		create_crystal_country = yes
		random_system_planet = {
			limit = { is_star = yes }
			event_target:crystal_country = {
				save_event_target_as = elite1_owner
				create_fleet = { name = "Crystalline Elites" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 500
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Red Elite"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Blue Elite"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Yellow Elite"
					}
					create_ship = {
						name = "Beta"
						design = "Large Crystal Entity Blue Elite"
					}
					create_ship = {
						name = "Gamma"
						design = "Medium Crystal Entity Yellow Elite"
					}
					create_ship = {
						name = "Psi"
						design = "Small Crystal Entity Red Elite"
					}
					set_location = PREVPREV
				}
				create_fleet = { name = "Crystalline Elites" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 500
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Yellow Elite"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Red Elite"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Blue Elite"
					}
					create_ship = {
						name = "Beta"
						design = "Large Crystal Entity Red Elite"
					}
					create_ship = {
						name = "Gamma"
						design = "Medium Crystal Entity Yellow Elite"
					}
					create_ship = {
						name = "Psi"
						design = "Small Crystal Entity Blue Elite"
					}
					set_location = PREVPREV
				}
				create_fleet = { name = "Crystalline Elites" }
				last_created_fleet = {
					set_owner = event_target:crystal_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 500
					create_ship = {
						name = "Delta"
						design = "Large Crystal Entity Blue Elite"
					}
					create_ship = {
						name = "Epsilon"
						design = "Medium Crystal Entity Red Elite"
					}
					create_ship = {
						name = "Omega"
						design = "Small Crystal Entity Yellow Elite"
					}
					create_ship = {
						name = "Beta"
						design = "Large Crystal Entity Yellow Elite"
					}
					create_ship = {
						name = "Gamma"
						design = "Medium Crystal Entity Blue Elite"
					}
					create_ship = {
						name = "Psi"
						design = "Small Crystal Entity Red Elite"
					}
					set_location = PREVPREV
				}
			}
		}
	}
}

# Cloud Entity
hostile_init_08 = {
	class = "rl_standard_stars"
	asteroids_distance = 95
	
	usage = misc_system_init
	usage_odds = 6
	
	flags = { hostile_system void_system }
	
	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 = {
		class = random_asteroid
		orbit_distance = 0
		orbit_angle = { min = 0 max 150 }
	}
	planet = {
		class = random_asteroid
		orbit_distance = 0
		orbit_angle = { min = 160 max 330 }
	}
	
	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 = {
		create_cloud_country = yes
		random_system_planet = {
			limit = { is_star = no }
			event_target:cloud_country = {
				set_aggro_range = 500
				create_fleet = { name = "Void Cloud" }
				last_created_fleet = {
					set_owner = event_target:cloud_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 500
					create_ship = {
						name = "XUUL"
						design = "Cloud Entity"
					}
					set_location = PREVPREV
				}
			}
		}		
	}
}

# Void Cloud Home System
hostile_init_09 = {
	class = sc_black_hole
	
	usage = misc_system_init
	usage_odds = 1

	flags = { hostile_system = void2_system }
	
	planet = {
		class = star
		orbit_distance = 0
	}
	
	change_orbit = 60
	
	planet = {
		count = { min = 0 max = 1 }
		class = "pc_barren"
		entity = "barren_planet_01_destroyed_entity"
		size = { min = 10 max = 15 }
	}
	
	change_orbit = 20
	
	planet = {
		count = { min = 0 max = 1 }
		class = "pc_barren_cold"
		size = { min = 10 max = 20 }
	}

	init_effect = {
		create_cloud_country = yes
		random_system_planet = {
			limit = { is_star = yes }
			save_event_target_as = voidhome_star
			event_target:cloud_country = {
				save_event_target_as = voidhome_owner
				create_fleet = { name = "Abyssal Host" }
				last_created_fleet = {
					set_owner = event_target:cloud_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = return_point
					set_aggro_range = 150
					create_ship = {
						name = "YAQU"
						design = "Cloud Entity"
					}
					create_ship = {
						name = "SHAR"
						design = "Cloud Entity"
					}
					create_ship = {
						name = "APED"
						design = "Cloud Entity"
					}
					create_ship = {
						name = "HAPI"
						design = "Cloud Entity"
					}
					set_location = event_target:voidhome_star
				}
				create_fleet = { name = "Chasmal Horde" }
				last_created_fleet = {
					set_owner = event_target:cloud_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = return_point
					set_aggro_range = 150
					create_ship = {
						name = "ANED"
						design = "Cloud Entity"
					}
					create_ship = {
						name = "DJER"
						design = "Cloud Entity"
					}
					create_ship = {
						name = "SEME"
						design = "Cloud Entity"
					}
					create_ship = {
						name = "MERN"
						design = "Cloud Entity"
					}
					set_location = event_target:voidhome_star
				}
			}
		}
	}
}

# Space Amoeba
hostile_init_10 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 6
	
	flags = { hostile_system amoeba_system }

	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 = {
		create_amoeba_country = yes
		random_system_planet = {
			limit = { is_star = no }
			event_target:amoeba_country = {
				create_fleet = { name = "Space Amoeba" }
				last_created_fleet = {
					set_owner = event_target:amoeba_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 100
					create_ship = {
						name = "Ortus"
						design = "Large Space Organism"
					}
					create_ship = {
						name = "Oriens"
						design = "Large Space Organism"
					}
					create_ship = {
						name = "Cortus"
						design = "Large Space Organism"
					}
					set_location = PREVPREV
				}
			}
		}
	}
}

# Space Amoeba ROAMING VARIATION
hostile_init_11 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 4
	
	flags = { hostile_system amoeba2_system }

	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 = {
		create_amoeba_country = yes
		random_system_planet = {
			limit = { is_star = no }
			save_event_target_as = grazing_grounds
			event_target:amoeba_country = {
				create_fleet = { name = "Space Amoeba" }
				last_created_fleet = {
					set_owner = event_target:amoeba_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = self
					set_aggro_range = 20
					random_list = {
						20 = {
							set_fleet_flag = tiyanki_hunter
						}
						70 = {
							set_fleet_flag = empty_system
						}
					}
					create_ship = {
						name = "Ortus"
						design = "Great Space Organism"
					}
					set_location = PREVPREV

					if = {
						limit = { has_fleet_flag = tiyanki_hunter }
						save_event_target_as = hunting_amoeba
						queue_actions = {
							repeat = {
								find_random_system = {
									trigger = {
										id = amoeba.2.trigger.1
										any_ship_in_system = {
											is_ship_size = space_whale_3
											# hunt calves
										}
									}
									found_system = {
										move_to = this
									}
								}
								find_closest_planet = {
									trigger = {
										id = amoeba.2.trigger.2
										is_star = yes
									}
									found_planet = {
										effect = { 
											id = amoeba.2.effect.1
											event_target:hunting_amoeba = { set_aggro_range = 500 }
										}
										move_to = this
										orbit_planet = this
										wait = {
											duration = 50
											random = 10
										}
									}
								}
								find_random_system = {
									trigger = {
										id = amoeba.2.trigger.3
										any_planet = {
											is_planet = event_target:grazing_grounds
										}
									}
									found_system = {
										move_to = this
									}
								}
								find_closest_planet = {
									trigger = {
										id = amoeba.2.trigger.4
										is_planet = event_target:grazing_grounds
									}
									found_planet = {
										effect = { 
											id = amoeba.2.effect.2
											event_target:hunting_amoeba = { set_aggro_range = 40 }
										}
										move_to = this
										orbit_planet = this
										wait = {
											duration = 200
											random = 40
										}
									}
								}
							}
						}
						else = {
							queue_actions = {
								repeat = {
									find_random_system = {
										trigger = {
											id = amoeba.1.trigger.1
											NOT = {
												has_star_flag = sanctuary_system
												has_star_flag = hostile_system
												any_planet = { is_capital = yes }
												any_neighbor_system = { any_planet = { is_capital = yes } }
											}
										}
										found_system = {
											move_to = this
										}
									}
									find_closest_planet = {
										trigger = {
											id = amoeba.1.trigger.2
											is_star = yes
										}
										found_planet = {
											move_to = this
											orbit_planet = this
											wait = {
												duration = 100
												random = 50
											}
										}
									}
									find_random_system = {
										trigger = {
											id = amoeba.1.trigger.3
											NOT = {
												has_star_flag = sanctuary_system
												has_star_flag = hostile_system
												any_planet = { is_capital = yes }
												any_neighbor_system = { any_planet = { is_capital = yes } }
											}
										}
										found_system = {
											move_to = this
										}
									}
									find_closest_planet = {
										trigger = {
											id = amoeba.1.trigger.4
											is_star = yes
										}
										found_planet = {
											move_to = this
											orbit_planet = this
											wait = {
												duration = 100
												random = 50
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

# Mining Drones
hostile_init_12 = {
	class = "rl_standard_stars"
	asteroids_distance = 95
	
	usage = misc_system_init
	usage_odds = 9
	
	flags = { hostile_system drone_system }
	
	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 = {
		class = random_asteroid
		orbit_distance = 0
		orbit_angle = { min = 0 max 150 }
	}
	planet = {
		class = random_asteroid
		orbit_distance = 0
		orbit_angle = { min = 160 max 330 }
	}
	
	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 = {
		create_drone_country = yes
		random_system_planet = {
			limit = { has_deposit_for = shipclass_mining_station }
			event_target:drone_country = {
				save_event_target_as = mining_drones
				create_fleet = { name = "Ancient Mining Drones" }
				last_created_fleet = {
					set_owner = event_target:drone_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = return_point
					set_aggro_range = 150
					create_ship = {
						name = "Drone 2432-D"
						design = "Mining"
					}
					create_ship = {
						name = "Drone 7731-A"
						design = "Mining"
					}
					create_ship = {
						name = "Drone 4119-X"
						design = "Mining"
					}
					set_location = PREVPREV
					queue_actions = {
						repeat = {
							wait = {
								duration = 999
								random = 10
							}
						}
					}
				}
			}
			create_mining_station = {
				owner = event_target:mining_drones
			}
		}	
	}
}

# Mining Drones ALTERNATE
hostile_init_13 = {
	class = "rl_standard_stars"
	asteroids_distance = 120

	usage = misc_system_init
	usage_odds = 1
	
	flags = { hostile_system drone2_system }
	
	planet = {
		count = 1
		class = star
		orbit_distance = 0
		orbit_angle = 1
		size = 30
		has_ring = no
	}

	planet = {
		count = 1
		orbit_distance = 40
		orbit_angle = 15
	}

	planet = {
		count = 1
		orbit_distance = 20
		orbit_angle = 125
	}

	planet = {
		count = 1
		orbit_distance = 20
		orbit_angle = 120

		moon = {
			orbit_distance = 12
			orbit_angle = 40
		}
	}

	planet = {
		count = 1
		orbit_distance = 20
		orbit_angle = 60
	}
	
	planet = {
		count = 1
		class = pc_asteroid
		orbit_distance = 20
		orbit_angle = -210
	}

	planet = {
		count = 1
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = -95
	}

	planet = {
		count = 1
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = 285
	}

	planet = {
		count = 1
		class = pc_asteroid
		orbit_distance = 0
		orbit_angle = -80
	}

	planet = {
		count = 1
		class = pc_gas_giant
		orbit_distance = 30
		orbit_angle = -160
		size = 35
		change_orbit = 6

		moon = {
			count = 1
			class = pc_molten
			size = 6
			orbit_distance = 10
			orbit_angle = 100 
		}
		moon = {
			count = 1
			class = "pc_frozen"
			size = 6
			orbit_distance = 2.5
			orbit_angle = 10
			has_ring = no
		}
		moon = {
			count = 1
			class = "pc_frozen"
			size = 9
			orbit_distance = 2.5
			orbit_angle = 80
			has_ring = no
		}
		moon = {
			count = 1
			class = "pc_frozen"
			size = 7
			orbit_distance = 2.5
			orbit_angle = -155
			has_ring = no
		}
	}

	planet = {
		count = 1
		class = pc_gas_giant
		orbit_distance = 20
		orbit_angle = 170
		size = 30
		has_ring = yes
		change_orbit = 7

		moon = {
			count = 1
			class = pc_frozen
			size = 8
			orbit_distance = 12
			orbit_angle = 320
		}
	}

	planet = {
		count = 1
		orbit_distance = 20
		orbit_angle = 125
	}
	
	planet = {
		count = 1
		orbit_distance = 20
		orbit_angle = -195

		change_orbit = 4

		moon = {
			count = 1
		}
	}

	init_effect = {
		create_drone_country = yes
		every_system_planet = {
			limit = { has_deposit_for = shipclass_mining_station }
			event_target:drone_country = {
				save_event_target_as = mining_drones2
				create_fleet = { name = "Ancient Mining Drones" }
				last_created_fleet = {
					set_owner = event_target:drone_country
					set_fleet_stance = aggressive
					set_aggro_range_measure_from = return_point
					set_aggro_range = 200
					create_ship = {
						name = "Drone 1832-D"
						design = "Mining"
					}
					create_ship = {
						name = "Drone 0931-F"
						design = "Mining"
					}
					create_ship = {
						name = "Drone 1119-X"
						design = "Mining"
					}
					set_location = PREVPREV
				}
			}
			create_mining_station = {
				owner = event_target:mining_drones2
			}
		}
	}	
}

# Tiyanki
hostile_init_14 = {
	class = "rl_standard_stars"
	
	usage = misc_system_init
	usage_odds = 8

	flags = { tiyanki_home_system }
	
	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 = 1 }
		orbit_distance = 10
		orbit_angle = { min = 90 max = 270 }
	}
	
	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 = {
		create_tiyanki_country = yes
		random_system_planet = {
			limit = { is_planet_class = pc_gas_giant }
			save_event_target_as = giant
			event_target:tiyanki_country = {
				save_event_target_as = tiyanki_country2
				create_fleet = { name = "Gas Grazers" }
				last_created_fleet = {
					set_owner = event_target:tiyanki_country
					set_fleet_stance = passive
					set_aggro_range_measure_from = return_point
					set_aggro_range = 0
					create_ship = {
						name = "Dhenu"
						design = "Tiyanki Cow"
					}
					create_ship = {
						name = "Uks"
						design = "Tiyanki Bull"
					}
					create_ship = {
						name = "Hesat"
						design = "Tiyanki Calf"
					}
					set_location = event_target:giant
					queue_actions = {
						repeat = {
							find_random_system = {
								trigger = {
									id = tiyanki.1.trigger.1
									NOT = {
										has_star_flag = hostile_system
										has_star_flag = sanctuary_system
									}
									any_planet = {
										is_planet_class = pc_gas_giant
									}
								}
								found_system = {
									move_to = this
								}
							}
							find_closest_planet = {
								trigger = {
									id = tiyanki.1.trigger.2
									is_planet_class = pc_gas_giant
								}
								found_planet = {
									move_to = this
									orbit_planet = this
									wait = {
										duration = 20
										random = 10
									}
								}
							}
						}
					}
				}
			}
		}
	}
}