System

A **system** in *Master of Orion* consists of a single star, optionally up to five planets, and at least one warp point.

When a system has planets, it can be colonized. A single system with several planets can be colonized by different empires, though this will create diplomatic tension between them.

Colony leaders and several colony structures will provide bonuses shared by all colonies in the system.

## Modding

Orbits are defined in Globals.yaml:

```
- globals: &Backend.Galaxy.SolarSystemGenerator
    PLANETARY_ORBITS:
        - minOrbitRadius: 0.40
          maxOrbitRadius: 0.40
          bodyCapacity: 1
        - minOrbitRadius: 0.55
          maxOrbitRadius: 0.55
          bodyCapacity: 2
        - minOrbitRadius: 0.70
          maxOrbitRadius: 0.70
          bodyCapacity: 3
        - minOrbitRadius: 0.85
          maxOrbitRadius: 0.85
          bodyCapacity: 3
        - minOrbitRadius: 1.00
          maxOrbitRadius: 1.00
          bodyCapacity: 3
    LUNAR_ORBITS:
        - minOrbitRadius: 0.125
          maxOrbitRadius: 0.125
          bodyCapacity: 1
        - minOrbitRadius: 0.20
          maxOrbitRadius: 0.20
          bodyCapacity: 1
    WARPGATE_ORBIT_RADIUS_OFFSET: 0.20

```

This defines five planetary orbits and two lunar orbits. Redefining this block can allow to have more orbits, though the outermost orbit should keep a maximum radius of 1.0.
Once more planetary orbits are available, they can be implemented in PlanetaryDensityPackages.yaml.

```
- collection: &Backend.Galaxy.PlanetDensityPackage
    items:
      - key: normal_planetary_density
        name: NORMAL_PLANETARY_DENSITY_NAME
        displayOrder: 0
        starDensities:
          - star_type: star_blue_white
            occupationChances:
              - planetCount: 0
                chance: 3
              - planetCount: 1
                chance: 16
              - planetCount: 2
                chance: 23
              - planetCount: 3
                chance: 25
              - planetCount: 4
                chance: 22
              - planetCount: 5
                chance: 11
          - star_type: star_white
            occupationChances:
              - planetCount: 0
                chance: 3
              - planetCount: 1
                chance: 8
              - planetCount: 2
                chance: 23
              - planetCount: 3
                chance: 31
              - planetCount: 4
                chance: 22
              - planetCount: 5
                chance: 13
...

```

Additional entries have to be created for each possible greater planetCount, and the chances must be redistributed. Note that any planetCount above 6 will result in the engine hanging, as the game uses a suffix table to name planets, and this table has only six entries. There are six types of stars and four planetary density sets, though the tutorial one can be ignored. But planetary densities are not enough, we also need to cover the stars themselves directly in StarTypes.yaml.

```
- collection: &Backend.Galaxy.StarType
    items:
        - key: star_blue_white
          name: STAR_TYPE_BLUE_WHITE
          nebulaeDensity: 2
          description: STAR_TYPE_BLUE_WHITE_DESCRIPTION
          occupationChances:
                - planetCount: 0
                  chance: 4
                - planetCount: 1
                  chance: 18
                - planetCount: 2
                  chance: 28
                - planetCount: 3
                  chance: 29
                - planetCount: 4
                  chance: 15
                - planetCount: 5
                  chance: 6
          orbitChances:
                - orbit: 1
                  chance: 20
                - orbit: 2
                  chance: 20
                - orbit: 3
                  chance: 20
                - orbit: 4
                  chance: 20
                - orbit: 5
                  chance: 20
          orbits:
                - orbit: 1
                  planetChance: 20
                  asteroidFieldChance: 0
                  gasGiantChance: 0
                  multipleObjectChance: 0
                - orbit: 2
                  planetChance: 35
                  asteroidFieldChance: 0
                  gasGiantChance: 0
                  multipleObjectChance: 0
                - orbit: 3
                  planetChance: 45
                  asteroidFieldChance: 0
                  gasGiantChance: 0
                  multipleObjectChance: 0
                - orbit: 4
                  planetChance: 65
                  asteroidFieldChance: 20
                  gasGiantChance: 15
                  multipleObjectChance: 0
                - orbit: 5
                  planetChance: 65
                  asteroidFieldChance: 15
                  gasGiantChance: 20
                  multipleObjectChance: 0
...

```

Each of the six star types needs to be covered. Once we have additional orbits and a chance for a planet to be generated there, we need to set the necessary information for the generation of this planet. This includes its size, defined in PlanetSizeChances.yaml.

```
- collection: &Backend.Galaxy.PlanetSizeChances
    items:
        - key: orbit_1
          sizeChances:
                - size: planetsize_tiny
                  chance: 25
                - size: planetsize_small
                  chance: 39
                - size: planetsize_medium
                  chance: 33
                - size: planetsize_large
                  chance: 3
                - size: planetsize_huge
                  chance: 0
        - key: orbit_2
          sizeChances:
                - size: planetsize_tiny
                  chance: 20
                - size: planetsize_small
                  chance: 35
                - size: planetsize_medium
                  chance: 34
                - size: planetsize_large
                  chance: 9
                - size: planetsize_huge
                  chance: 2
...

```

Using this model, additional keys must be created for each new orbit.

In addition, it is also possible to have several planets per orbit, as hinted by the bodyCapacity values in orbit definitions. The chance of this happening is covered by multipleObjectChance in the star type definitions. Beware that enabling this risks creating visual glitches, by having planets overlapping each others. This can be alleviated by reducing planet scaling through changing the scaleFactor values in PlanetSizeTypes.yaml:

```
- collection: &Backend.Galaxy.PlanetSizeType
    items:
          - key: planetsize_tiny
            name: PLANET_SIZE_TYPE_TINY
            level: 1
            maxTiles: 8
            scaleFactor: 0.75
            satelliteOrbits: 1
            satelliteChance: 0.25
            satelliteSizeChances:
                - satellitesize_small: 1
            pollutionCapacity: 250
            terraformingCostFactor: 0.35
            minRequiredFood: 75
            maxRequiredFoodStart: 80
            maxRequiredFoodEnd: 170
...

```

Besides orbits, planet counts, and planet sizes, a system is also defined by its planet biomes. The data for those is found in BiomeChances.yaml.

## ```
- collection: &Backend.Galaxy.BiomeChances
    items:
        - key: galaxy_young
          inhabitable_biome_chance:
                - star_type: star_blue_white
                  biomes:
                    - biome: biome_volcanic
                      chance: 20
                    - biome: biome_toxic
                      chance: 10
                    - biome: biome_radiated
                      chance: 31
                    - biome: biome_barren
                      chance: 26
                    - biome: biome_desert
                      chance: 8
                    - biome: biome_tundra
                      chance: 0
                    - biome: biome_arid
                      chance: 5
                    - biome: biome_ocean
                      chance: 0
                    - biome: biome_swamp
                      chance: 0
                    - biome: biome_terran
                      chance: 0
                    - biome: biome_gaia
                      chance: 0
...

```

There is a list of available biomes for each star type in each galaxy age category.

## Orbits

There are inner and outer orbits. This affects terraformation and pollution-induced degradation.

```
public PlanetBiomeType GetNextAvailableTerraformBiome()
{
	if (this.biome.key == "biome_terran")
	{
		return SerializedData<PlanetBiomeType>.Get("biome_gaia");
	}
	if (this.orbitIndex < Star.ORBITS_PER_STAR / 2)
	{
		return this.biome.innerOrbitTerraformBiome;
	}
	if (this.orbitIndex > Star.ORBITS_PER_STAR / 2)
	{
		return this.biome.outerOrbitTerraformBiome;
	}
	return (new GameRandom(this.universe.turn).NextDouble() < 0.5) ? this.biome.innerOrbitTerraformBiome : this.biome.outerOrbitTerraformBiome;
}

private PlanetBiomeType GetDowngradedBiome(PlanetBiomeType biome)
{
	PlanetBiomeType planetBiomeType;
	if (this.orbitIndex < Star.ORBITS_PER_STAR / 2)
	{
		planetBiomeType = biome.innerOrbitDowngradeBiome;
	}
	else if (this.orbitIndex > Star.ORBITS_PER_STAR / 2)
	{
		planetBiomeType = biome.outerOrbitDowngradeBiome;
	}
	else
	{
		planetBiomeType = ((new GameRandom(this.universe.turn).NextDouble() < 0.5) ? biome.innerOrbitDowngradeBiome : biome.outerOrbitDowngradeBiome);
	}
	if (planetBiomeType != null)
	{
		return planetBiomeType;
	}
	Debug.LogError("Planet.GetDowngradedBiome(): Biome Type " + biome + " does not have a downgraded biome set! Returning same biome.");
	return biome;
}

```

Note that this refers to orbit indices, not planet indices. A system with two planets can very well have both in an inner orbit, or both in an outer orbit.

## External links

* orbit with 2 planets? thread on the official forums