Custom Biomes
Posted: 15 Jul 2018, 18:03
In this tutorial, I'll be showing you how to make custom biomes. Using this technique, you'll have full control over the biome's size, position, and decorations. This will also allow you to have more than one ground type in map generation. This process uses a combination of decoration spawning and basic fun. Using the decoration spawning, we can put decorations in world generation that place a new ground type underneath them in order to create new biomes. You will also be able to provide some decorations to have spawned in your biome as well.
Some Sample Code
Code: Select all
[
{
"author":"Kingtut101",
"autobuild":false,
"borderframes":[
{
"count":16,
"h":16,
"w":32,
"x":0,
"y":32
}
],
"edgeborderframes":[
{
"count":32,
"h":32,
"w":16,
"x":0,
"y":144
}
],
"edgeframes":[
{
"count":12,
"h":48,
"w":16,
"x":0,
"y":96
}
],
"frames":[
{
"bmp":"stoneground.png"
}
],
"height":1,
"id":"stoneground.kt101",
"text":"Hard,graygroundforyourcities.",
"title":"Stone",
"type":"ground",
"water":false,
"width":1
},
{
"author":"Kingtut101",
"category":"$cat_terrain00",
"drawground":true,
"framealignmentarea":true,
"frames":[
{
"bmp":"blank.png"
},
{
"steal":"$searocks00"
}
],
"fun":[
{
"actions":[
{
"id":"stoneground.kt101",
"type":"build"
},
{
"type":"remove"
}
],
"condition":{
"inner":[
{
"invert":true,
"type":"wire"
},
{
"frame":0,
"type":"building"
}
],
"type":"and"
},
"p":1
},
{
"actions":[
{
"id":"stoneground.kt101",
"type":"build"
}
],
"condition":{
"inner":[
{
"invert":true,
"type":"wire"
},
{
"frame":1,
"type":"building"
}
],
"type":"and"
},
"p":1
}
],
"height":1,
"hidden":false,
"id":"rocks.kt101",
"price":100,
"pricefactor":0,
"spawn":{
"height":300,
"p":1,
"radius":150
},
"title":"Rocks",
"type":"decoration",
"width":1
}
]
-Blank frames
-Decoration frames (optional)
-A ground type
-A decoration that will be spawned in map generation
All of the custom biome's functionality rests in the decoration code, so don't worry too much about the ground code. Next I'll begin to talk about how this all works in more detail.
Code: Select all
"fun":[
{
"actions":[
{
"id":"stoneground.kt101",
"type":"build"
},
{
"type":"remove"
}
],
"condition":{
"inner":[
{
"invert":true,
"type":"wire"
},
{
"frame":0,
"type":"building"
}
],
"type":"and"
},
"p":1
},
{
"actions":[
{
"id":"stoneground.kt101",
"type":"build"
}
],
"condition":{
"inner":[
{
"invert":true,
"type":"wire"
},
{
"frame":1,
"type":"building"
}
],
"type":"and"
},
"p":1
}
],
The next part requires you to add decoration spawning code. You can find the tutorial here:
https://theotown.com/forum/viewtopic.php?f=41&t=1355
Of course, this is just an example of how to accomplish custom biomes and I'm sure that there are better ways to code such a thing. There are probably an endless amount of combinations for custom biomes. However, this tutorial should get across the basic points. I will be providing the example plug-in below and if you don't understand this concept I would recommend that you take a look at it and tweak it to your liking. Feel free to reuse this plug-in code in your own plug-ins. Just make sure to credit me.