Modding Help How do I make my modded biomes/planets rarer?

Discussion in 'Starbound Modding' started by North\WestTrees, Dec 18, 2019.

  1. North\WestTrees

    North\WestTrees Void-Bound Voyager

    Is there a way to make my planet biomes in my own mod rarer when they generate?

    Thanks in advance for the help.
     
  2. bk3k

    bk3k Oxygen Tank

    That's all in celestial.config
    This is from the white stars -
    Code:
          "orbitRegions" : [
            {
              "regionName" : "Tier1Inner",
              "orbitRange" : [2, 5],
              "bodyProbability" : 0.5,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "Tier1"},
                {"weight" : 0.7, "item" : "Tier2"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"}
              ]
            },
            {
              "regionName" : "Tier1Mid",
              "orbitRange" : [6, 7],
              "bodyProbability" : 0.25,
              "planetaryTypes" : [
                {"weight" : 0.9, "item" : "GasGiant"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 0.1, "item" : "Moon"},
                {"weight" : 0.3, "item" : "Tier1"},
                {"weight" : 0.6, "item" : "Tier2"}
              ]
            },
            {
              "regionName" : "Tier1Outer",
              "orbitRange" : [8, 10],
              "bodyProbability" : 0.5,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "Tier1"},
                {"weight" : 0.7, "item" : "Tier2"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"}
              ]
            },
            {
              "regionName" : "Gate",
              "orbitRange" : [11, 11],
              "bodyProbability" : 1.0,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "AncientGateway"},
                {"weight" : 0.1, "item" : "AsteroidField"},
                {"weight" : 0.1, "item" : "Barren"},
                {"weight" : 0.1, "item" : "Tier1"},
                {"weight" : 0.5, "item" : "Tier2"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"}
              ]
            }
          ]
    Each star class sets their own regions. "orbitRange" you can think of as planetary slots aka which slots that region governs. "bodyProbability" is the chance that anything appears at all. And "planetaryTypes" is an array with a weighted selection of planetary types. We aren't talking individual biomes however unless that planetType has only 1 biome option. But lower weighted planetTypes are less likely to be chosen. Ditto for satelliteTypes.
    If the weights adds up to 1.0 (and they don't need to), the statistical math is easy. 0.2 = 20%. 0.01 = 1%. If your biome belongs in a planetType with other biomes, you can't change ONLY your biome's probability. It will affect them all.

    Now the next piece is this -
    Code:
        "Tier1" : {
          "satelliteProbability" : 1,
          "maxSatelliteCount" : 1,
    
          "baseParameters" : {
            "worldType" : "Terrestrial",
            "description" : "Tier 1 Planet",
            "smallImage" : "/celestial/system/planet_small.png",
    
            "terrestrialType" : [ "garden" ]
          },
    
          "variationParameters" : [
            {
              "imageScale" : 0.1,
              "smallImageScale" : 0.5,
              "worldSize" : "small"
            },
            {
              "imageScale" : 0.125,
              "smallImageScale" : 0.6,
              "worldSize" : "medium"
            }
          ]
        },
    That's just the definition of 1 planetType which is named "Teir1" and that has only "garden" to choose from. Therefore if "Tier1" was chosen, it would be "garden" 100% of the time. That would be easy to change the probability for "garden" (aka lush) planets since you just adjust the entire "tier1" weights. But with this -
    Code:
        "Tier6" : {
          "satelliteProbability" : 0.35,
          "maxSatelliteCount" : 2,
    
          "baseParameters" : {
            "worldType" : "Terrestrial",
            "description" : "Tier 6 Planet",
            "smallImage" : "/celestial/system/planet_small.png",
    
            "terrestrialType" : [ "volcanic", "scorchedcity", "magma" ]
          },
    
          "variationParameters" : [
            {
              "imageScale" : 0.1,
              "smallImageScale" : 0.5,
              "worldSize" : "medium"
            },
            {
              "imageScale" : 0.125,
              "smallImageScale" : 0.6,
              "worldSize" : "large"
            }
          ]
        },
    You have "volcanic", "scorchedcity", and "magma" as options. Everything in that array is equally likely If "Teir6" was chosen, there is 1/3rd chance of "volcanic". So if you had a 30% chance of "Tier6", and 1/3rd chance of "volcanic" within "Tier6", then your odds of "volcanic" are really 10%. The base odds / the number of possible choices.

    Now assuming you want to finely control the odds of your own planet without strongly affecting others, you'd define your own planetType and/or Satellite Type. Then you inject your own types into the regions at the weight you choose. Remember the total weights do not have to add up to 1.0 - even if that makes calculating probability slightly harder - it doesn't create any problem for the game engine. Also I'd strongly recommend using an online patch maker for this since it would be a pretty big headache to do that all by hand.

    The next thing after that is if you want to make it TrueSpace compatible.

    Starbound supports an expanded (not official) patching standard that is useful. You can put them into batches.
    ordinary patch -
    Code:
    [
      {
        //some patch here
      }
    }
    Batched
    Code:
    [
    [  //unconditional batch like usual
      {
        //some patch here
      }
    ].
    [  //some conditional patches such as TrueSpace
      {
        //conditional check
        //if it fails, the rest of the batch
        //will not be applied
        //no other batches affected
      },
      {
        //some patch
      }
    ]
    ]
    And if you want a real example that adds optional TrueSpace compatibility -
    Code:
    [
      [
        {
          "op" : "add",
          "path" : "/terrestrialHorizonGraphics/lavamoon",
          "value" : {
            "baseImages" : "/celestial/system/terrestrial/horizon/textures/volcanic_<selector>.png",
            "maskTextures" : "/celestial/system/terrestrial/horizon/masks/temperate/<mask>_<selector>.png",
            "liquidTextures" : "/celestial/system/terrestrial/horizon/liquids/lava_<selector>.png",
            "maskRange" : [1, 25],
            "maskPerPlanetRange" : [3, 3]
          }
        },
        {
          "op" : "add",
          "path" : "/terrestrialGraphics/lavamoon",
          "value" : {
            "baseImages" : "/celestial/system/terrestrial/biomes/lavamoon/maskie<num>.png",
            "dynamicsImages" : "/celestial/system/terrestrial/dynamics/arid/<num>.png",
            "dynamicsRange" : [1, 50]
            }
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/Tier6/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/Tier5/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/Tier4/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/Tier3/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/Tier2/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/Tier1/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        }
      ],
      [
        {  //test for TrueSpace
          "inverse": false,
          "op": "test",
          "path": "/systemTypes/ClassBStar"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/IradNSat/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/SpicyNSat/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/HotNSat/baseParameters/terrestrialType/-",
          "value" : "lavamoon"
        }
      ]
    ]
    So you make your patches with a patch maker like normal, but then put the results into batches. In that case it is injecting their biome into existing TrueSpace satelliteTypes, but injecting your own types into regions works the same way. You just need the conditional check to only apply the TrueSpace patches if it is present. And that's why it is looking for "/systemTypes/ClassBStar" since that is a path TrueSpace would add. Compatibility patches for any mod would work the same way - just detect something they add to that file.
    You'd also alter _metadata
    Code:
    "includes" : ["TrueSpace"]
    That's all you need to make sure your mod loads after whatever mods you list in that array.
     
  3. North\WestTrees

    North\WestTrees Void-Bound Voyager

    Thank you very much for your reply this will help a tone.
    I was not expecting such a detailed and fast reply, thanks so much :)
     
  4. North\WestTrees

    North\WestTrees Void-Bound Voyager

    Is there any way to add a new Tier group then change add it to the satelliteTypes list and control the wight that way?
    I have attempted to do that but I made my game spawn them at a more than they were.

    This is the code I tried to use, it works still without any errors but did not seem to do what I was hoping.
    Code:
        {
          "op" : "add",
          "path" : "/planetaryTypes/-",
          "value" : {   
            "Ba2GentleAsteroid" : {
            "satelliteProbability" : 0.0,
    
            "baseParameters" : {
              "worldType" : "Terrestrial",
              "description" : "Gentle Asteriod",
              "smallImage" : "/celestial/system/planet_small.png",
    
              "terrestrialType" : [ "ba2gentleasteroid" ]
            },
    
            "variationParameters" : [
              {
                "imageScale" : 0.125,
                "smallImageScale" : 0.5,
                "worldSize" : "small"
              }
            ]
          }}
        },
        {
          "op" : "add",
          "path" : "/satelliteTypes/-",
          "value" : {   
            "Ba2GentleAsteroid" : {
            "baseParameters" : {
              "worldType" : "Terrestrial",
              "description" : "Gentle Asteroid",
    
              "terrestrialType" : [ "ba2gentleasteroid" ]
            },
    
            "variationParameters" : [
              {
                "imageScale" : 0.035,
                "worldSize" : "small"
              },
              {
                "imageScale" : 0.045,
                "worldSize" : "small"
              },
              {
                "imageScale" : 0.055,
                "worldSize" : "small"
              }
            ]
          }}
        },
        {
          "op" : "add",
          "path" : "/systemTypes/White/orbitRegions/0/satelliteTypes/-",
          "value" : {"weight" : 0.05, "item" "Ba2GentleAsteroid"}
        },
        {
          "op" : "add",
          "path" : "/systemTypes/White/orbitRegions/1/satelliteTypes/-",
          "value" : {"weight" : 0.05, "item" "Ba2GentleAsteroid"}
        },
        {
          "op" : "add",
          "path" : "/systemTypes/White/orbitRegions/2/satelliteTypes/-",
          "value" : {"weight" : 0.05, "item" "Ba2GentleAsteroid"}
        },
        {
          "op" : "add",
          "path" : "/systemTypes/White/orbitRegions/3/satelliteTypes/-",
          "value" : {"weight" : 0.05, "item" "Ba2GentleAsteroid"}
        },
     
  5. bk3k

    bk3k Oxygen Tank

    So they're still too common? You could do weight 0.001 etc. And keep in mind every region you put it in has its own individual chance to spawn your planet.
    So that's like adding more dice when you are looking for only rolls of 1. It makes it more likely to come up overall.

    By tier groups, you mean "Tier6" etc? That's just a name of a planet type which they decided to put only Tier 6 planets in, but nothing stops you from putting planets of any threat tier in there. It is just a name which happens to be descriptive, but has no special meaning to the engine.

    edit:
    make sure you don't have your old patch in there too. For example if you previously had it in Tier3 etc.
     
  6. North\WestTrees

    North\WestTrees Void-Bound Voyager

    One more question have I targeted the array properly using the numbers in the path "/0/, /1/, /2/ and /3/" the default code is below. I can't remember if it starts with 0 or 1 in starbound, or if its even coded in right.

    Code:
        {
          "op" : "add",
          "path" : "/systemTypes/White/orbitRegions/0/satelliteTypes/-", // to targer the group in the array would the number 0 be the first item in the array?
          "value" : {"weight" : 0.05, "item" "Ba2GentleAsteroid"}
        },

    I am going by 0 for "Tier1Inner" in the current code.

    Code:
          "orbitRegions" : [
            {  // Is this 0 or 1?
              "regionName" : "Tier1Inner",
              "orbitRange" : [2, 5],
              "bodyProbability" : 0.5,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "Tier1"},
                {"weight" : 0.7, "item" : "Tier2"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"}
              ]
            },
            {
              "regionName" : "Tier1Mid",
              "orbitRange" : [6, 7],
              "bodyProbability" : 0.25,
              "planetaryTypes" : [
                {"weight" : 0.9, "item" : "GasGiant"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 0.1, "item" : "Moon"},
                {"weight" : 0.3, "item" : "Tier1"},
                {"weight" : 0.6, "item" : "Tier2"}
              ]
            },
            {
              "regionName" : "Tier1Outer",
              "orbitRange" : [8, 10],
              "bodyProbability" : 0.5,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "Tier1"},
                {"weight" : 0.7, "item" : "Tier2"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"}
              ]
            },
            {
              "regionName" : "Gate",
              "orbitRange" : [11, 11],
              "bodyProbability" : 1.0,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "AncientGateway"},
                {"weight" : 0.1, "item" : "AsteroidField"},
                {"weight" : 0.1, "item" : "Barren"},
                {"weight" : 0.1, "item" : "Tier1"},
                {"weight" : 0.5, "item" : "Tier2"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"}
              ]
            }
          ]
    And just to confirm, the code above would insert the following line as listed below?


    Code:
            {
              "regionName" : "Tier1Inner",
              "orbitRange" : [2, 5],
              "bodyProbability" : 0.5,
              "planetaryTypes" : [
                {"weight" : 0.2, "item" : "Tier1"},
                {"weight" : 0.7, "item" : "Tier2"},
                {"weight" : 0.05, "item" : "Barren"},
                {"weight" : 0.05, "item" : "AsteroidField"}
              ],
              "satelliteTypes" : [
                {"weight" : 1, "item" : "Moon"},
                {"weight" : 0.05, "item" : "Ba2GentleAsteroid"} // My modded planet.
              ]
            },
    Thank you for your continued help it's much appreciated.
    I am looking forward to your reply :)
     
  7. bk3k

    bk3k Oxygen Tank

    That is indeed 0. But as I mentioned, there are patch makers that can take that guesswork out. And that one can also test your patch to make sure the outcome is what you wanted. But it doesn't tolerate comments.
     

Share This Page