Changes between Initial Version and Version 1 of Random_Biome_Library


Ignore:
Timestamp:
Dec 5, 2017, 11:36:41 PM (6 years ago)
Author:
elexis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Random_Biome_Library

    v1 v1  
     1Random map scripts can use predefined biomes. This allows specification of one biome that will be used by many maps.
     2
     3== Using The Random Biome System
     4
     5In order to use the random biome library, the `JSON` file of the random map script needs to either specify that it can support all biomes, or specify an array of supported biome names.
     6So for instance
     7{{{
     8"SupportedBiomes": true
     9}}}
     10or
     11{{{
     12"SupportedBiomes": [
     13        "temperate",
     14        "snowy",
     15        "desert"
     16],
     17}}}
     18
     19These biomes are then selectable in the gamesetup.
     20
     21The random map script has to to include and initialize the library using
     22{{{
     23Engine.LoadLibrary("rmbiome");
     24
     25// ...
     26
     27setSelectedBiome();
     28}}}
     29
     30After that, four globals inform the random map script which values to use for map generation:
     31* **g_Environment**: sun, water, fog settings
     32* **g_Terrains**: texture filenames
     33* **g_Gaia**: template names of animals, trees and mines
     34* **g_Decoratives**: grass, rocks and flower template names
     35* **g_TreeCount**: determines the total of trees and the likelihood of a tree being part of a forest. These values are specifically useful for the `createStragglerTrees` and `createForests` function.
     36
     37See the issue below for the properties in detail.
     38
     39== Adding New Biomes
     40
     41A biome is defined by a JSON file in `binaries/data/mods/public/maps/random/rmbiome/biomes/`.
     42See this example:
     43{{{
     44{
     45        "Description": {
     46                "Title": "Savanna",
     47                "Description": "The savanna, a dry climate in which only the hardy Baobab trees thrive. Solitary gazelles graze the sparse grass, while herds of zebras, wildebeest, giraffes or elephants roam the wild in search of food."
     48        },
     49        "Environment": {
     50                "Water": {
     51                        "WaterBody": {
     52                                "Color": { "r": 0.055, "g": 0.176, "b": 0.431 },
     53                                "Tint": { "r": 0.227, "g": 0.749, "b": 0.549 },
     54                                "Murkiness": 0.77,
     55                                "Waviness": 1.5
     56                        }
     57                },
     58                "Fog": {
     59                        "FogThickness": 0.15,
     60                        "FogFactor": 0.0025,
     61                        "FogColor": { "r": 0.847059, "g": 0.737255, "b": 0.482353 }
     62                },
     63                "Postproc": {
     64                        "PostprocEffect": "hdr",
     65                        "Contrast": 1.07031,
     66                        "Bloom": 0.132
     67                }
     68        },
     69        "Terrains": {
     70                "mainTerrain": [
     71                        "savanna_grass_a",
     72                        "savanna_grass_b"
     73                ],
     74                "forestFloor1": "savanna_forestfloor_a",
     75                "forestFloor2": "savanna_forestfloor_b",
     76                "cliff": [
     77                        "savanna_cliff_a",
     78                        "savanna_cliff_b"
     79                ],
     80                "tier1Terrain": "savanna_shrubs_a",
     81                "tier2Terrain": "savanna_dirt_rocks_b",
     82                "tier3Terrain": "savanna_dirt_rocks_a",
     83                "tier4Terrain": "savanna_grass_a",
     84                "hill": [
     85                        "savanna_grass_a",
     86                        "savanna_grass_b"
     87                ],
     88                "dirt": [
     89                        "savanna_dirt_rocks_b",
     90                        "dirt_brown_e"
     91                ],
     92                "road": "savanna_tile_a",
     93                "roadWild": "savanna_tile_a",
     94                "shoreBlend": "savanna_riparian",
     95                "shore": "savanna_riparian_bank",
     96                "water": "savanna_riparian_wet"
     97        },
     98        "Gaia": {
     99                "tree1": "gaia/flora_tree_baobab",
     100                "tree2": "gaia/flora_tree_baobab",
     101                "tree3": "gaia/flora_tree_baobab",
     102                "tree4": "gaia/flora_tree_baobab",
     103                "tree5": "gaia/flora_tree_baobab",
     104                "fruitBush": "gaia/flora_bush_grapes",
     105                "chicken": "gaia/fauna_chicken",
     106                "fish": "gaia/fauna_fish",
     107                "secondaryHuntableAnimal": "gaia/fauna_gazelle",
     108                "stoneLarge": "gaia/geology_stonemine_desert_quarry",
     109                "stoneSmall": "gaia/geology_stone_savanna_small",
     110                "metalLarge": "gaia/geology_metal_savanna_slabs"
     111        },
     112        "Decoratives": {
     113                "grass": "actor|props/flora/grass_savanna.xml",
     114                "grassShort": "actor|props/flora/grass_medit_field.xml",
     115                "reeds": "actor|props/flora/reeds_pond_lush_a.xml",
     116                "lillies": "actor|props/flora/reeds_pond_lush_b.xml",
     117                "rockLarge": "actor|geology/stone_savanna_med.xml",
     118                "rockMedium": "actor|geology/stone_savanna_med.xml",
     119                "bushMedium": "actor|props/flora/bush_desert_dry_a.xml",
     120                "bushSmall": "actor|props/flora/bush_dry_a.xml",
     121                "tree": "actor|flora/trees/baobab.xml"
     122        },
     123        "TreeCount": {
     124                "minTrees": 200,
     125                "maxTrees": 1250,
     126                "forestProbability": 0
     127        }
     128}
     129}}}
     130
     131A biome can optionally execute some JavaScript code upon initialization.
     132In that case there should be a JS file with the same name in that `biomes` directory.
     133It must contain a function starting with `setupBiome_` followed by the name of the Biome identifier:
     134{{{
     135function setupBiome_savanna()
     136{
     137        g_Gaia.mainHuntableAnimal = pickRandom([
     138                "gaia/fauna_wildebeest",
     139                "gaia/fauna_zebra",
     140                "gaia/fauna_giraffe",
     141                "gaia/fauna_elephant_african_bush"
     142        ]);
     143}
     144}}}