How to create new biome?

Started by Tom Ether, September 17, 2017, 05:15:28 PM

Previous topic - Next topic

Tom Ether

Hi!
I want to create new biome. Can I do this only in .xml? Maybe I need edit in C#? Can you write me a small instruction? Thank you in advance!

neitsa

You can take a look at the XML biome definition files in \Mods\Core\Defs\BiomeDefs. They define the biomes you see in the vanilla game.

As for C# or not, it depends. If you look at preexisting biomes (e.g AridShrubland):


  <BiomeDef>
    <defName>AridShrubland</defName>
    <label>arid shrubland</label>
    <description>A dry region, but not dry enough to become a true desert. Open plains with grasses and bushes give way to scattered groves of trees. Plants are hardy and there is a moderate density of animals.</description>
    <workerClass>BiomeWorker_AridShrubland</workerClass>


You can see that there's a tag named "workerClass" which, as it name implies, refers to a class in the C# code. All the BiomeWorker_XXX classes inherit from the same abstract class (BiomeWorker) with only one abstract method (GetScore):


public abstract class BiomeWorker
{
public abstract float GetScore(Tile tile);
}


As far as I understand the code, the method returns a score (seems to be in range [-100, 100]) which gives the frequency at which the biome will appear on the world map. You might just reuse one of the preexisting classes for your biome, though you will immediately have the same frequency than that biome.

As for the other entries (tags) in the biome definitions, they all seem to be related to appearance frequency (e.g how much animals, how much rain, etc.). You'll also need to provide your own texture(s) for your biome.

For Modding, see Modding and XML modding on the RW wiki.

dburgdorf

To expand a bit on what Neitsa wrote, the score returned by the BiomeWorker class actually reflects the likelihood of a biome being chosen for a particular *tile*.

When a world is generated, certain things -- land masses, temperature patterns, rainfall patterns, etc. -- are generated first. Then, for each tile on the map, each biome's BiomeWorker class is called to determine how likely the biome is to appear in that spot. If the tile happens to be a land tile with a high temperature and a good amount of rainfall, for example, the tropical forest biome will have a high score, and temperate forest and arid shrubland biomes will have lower scores, but desert, tundra and ocean biomes won't be options at all. Once all the biomes are checked, a specific biome is assigned to the tile randomly, but with preference given to biomes with higher scores.

The point of explaining that is to say that simply referencing an existing BiomeWorker class might or might not be appropriate, depending upon what sort of biome you're trying to add.

Let's say you want to add a "painted desert" biome. As long as you're happy with it being pretty common, you could easily just assign your biome the existing desert BiomeWorker class. The end result would be that roughly half the desert tiles in any new world would be painted deserts instead of vanilla desert.

On the other hand, if you wanted to add a "mystical forest" biome, even though it might have the same temperature and rainfall requirements as temperate forests, you wouldn't want to just use the temperate forest BiomeWorker, as you'd presumably want your new biome to be much less common.  And that would require a custom BiomeWorker.

As Neitsa said, though, everything else about a biome -- the types of terrain found in it, the types of animals and plants that inhabit it, the weather it experiences, etc. -- is all defined in the biome's XML definition. Examine the vanilla biome XML files, and you should be able to figure out how it all works.

The vanilla biome definitions are split across four XML files, by the way. There's one for arid biomes (desert, extreme desert, and arid shrubland), one for cold biomes (boreal forest, tundra, ice sheets and sea ice), one for moderate biomes (temperate forests and tropical rainforests), and one for inaccessible biomes (ocean and impassable mountains).
- Rainbeau Flambe (aka Darryl Burgdorf) -
Old. Short. Grumpy. Bearded. "Yeah, I'm a dorf."



Buy me a Dr Pepper?

Tom Ether

Thank you sooo much! That helps a lot! You're great :D