Skip to content
Permalink
Browse files

Randomwalk caves: Add parameters for number, proportion flooded. Allo…

…w small caves (#8928)

Add mapgen parameters to set the range of the random number of
randomwalk caves per mapchunk, and to set the proportion that are
flooded with liquids.
Default values are, for now, unchanged from the previous hardcoded
values.

Add parameters to allow small randomwalk caves
Disabled by default for now as they have never been present in the
non-mgv6 mapgens.
  • Loading branch information
paramat committed Nov 8, 2019
1 parent 5506e97 commit 2a74727857a9bfd950ce1e6a58e0ade879033574
@@ -1479,6 +1479,21 @@ mgv5_large_cave_depth (Large cave depth) int -256
# Y of upper limit of lava in large caves.
mgv5_lava_depth (Lava depth) int -256

# Minimum limit of random number of small caves per mapchunk.
mgv5_small_cave_num_min (Small cave minimum number) int 0 0 256

# Maximum limit of random number of small caves per mapchunk.
mgv5_small_cave_num_max (Small cave maximum number) int 0 0 256

# Minimum limit of random number of large caves per mapchunk.
mgv5_large_cave_num_min (Large cave minimum number) int 0 0 64

# Maximum limit of random number of large caves per mapchunk.
mgv5_large_cave_num_max (Large cave maximum number) int 2 0 64

# Proportion of large caves that contain liquid.
mgv5_large_cave_flooded (Large cave proportion flooded) float 0.5 0.0 1.0

# Y-level of cavern upper limit.
mgv5_cavern_limit (Cavern limit) int -256

@@ -1596,6 +1611,21 @@ mgv7_large_cave_depth (Large cave depth) int -33
# Y of upper limit of lava in large caves.
mgv7_lava_depth (Lava depth) int -256

# Minimum limit of random number of small caves per mapchunk.
mgv7_small_cave_num_min (Small cave minimum number) int 0 0 256

# Maximum limit of random number of small caves per mapchunk.
mgv7_small_cave_num_max (Small cave maximum number) int 0 0 256

# Minimum limit of random number of large caves per mapchunk.
mgv7_large_cave_num_min (Large cave minimum number) int 0 0 64

# Maximum limit of random number of large caves per mapchunk.
mgv7_large_cave_num_max (Large cave maximum number) int 2 0 64

# Proportion of large caves that contain liquid.
mgv7_large_cave_flooded (Large cave proportion flooded) float 0.5 0.0 1.0

# Controls the density of mountain-type floatlands.
# Is a noise offset added to the 'mgv7_np_mountain' noise value.
mgv7_float_mount_density (Floatland mountain density) float 0.6
@@ -1704,6 +1734,21 @@ mgcarpathian_large_cave_depth (Large cave depth) int -33
# Y of upper limit of lava in large caves.
mgcarpathian_lava_depth (Lava depth) int -256

# Minimum limit of random number of small caves per mapchunk.
mgcarpathian_small_cave_num_min (Small cave minimum number) int 0 0 256

# Maximum limit of random number of small caves per mapchunk.
mgcarpathian_small_cave_num_max (Small cave maximum number) int 0 0 256

# Minimum limit of random number of large caves per mapchunk.
mgcarpathian_large_cave_num_min (Large cave minimum number) int 0 0 64

# Maximum limit of random number of large caves per mapchunk.
mgcarpathian_large_cave_num_max (Large cave maximum number) int 2 0 64

# Proportion of large caves that contain liquid.
mgcarpathian_large_cave_flooded (Large cave proportion flooded) float 0.5 0.0 1.0

# Y-level of cavern upper limit.
mgcarpathian_cavern_limit (Cavern limit) int -256

@@ -1788,6 +1833,21 @@ mgflat_large_cave_depth (Large cave depth) int -33
# Y of upper limit of lava in large caves.
mgflat_lava_depth (Lava depth) int -256

# Minimum limit of random number of small caves per mapchunk.
mgflat_small_cave_num_min (Small cave minimum number) int 0 0 256

# Maximum limit of random number of small caves per mapchunk.
mgflat_small_cave_num_max (Small cave maximum number) int 0 0 256

# Minimum limit of random number of large caves per mapchunk.
mgflat_large_cave_num_min (Large cave minimum number) int 0 0 64

# Maximum limit of random number of large caves per mapchunk.
mgflat_large_cave_num_max (Large cave maximum number) int 2 0 64

# Proportion of large caves that contain liquid.
mgflat_large_cave_flooded (Large cave proportion flooded) float 0.5 0.0 1.0

# Controls width of tunnels, a smaller value creates wider tunnels.
mgflat_cave_width (Cave width) float 0.09

@@ -1847,6 +1907,21 @@ mgfractal_large_cave_depth (Large cave depth) int -33
# Y of upper limit of lava in large caves.
mgfractal_lava_depth (Lava depth) int -256

# Minimum limit of random number of small caves per mapchunk.
mgfractal_small_cave_num_min (Small cave minimum number) int 0 0 256

# Maximum limit of random number of small caves per mapchunk.
mgfractal_small_cave_num_max (Small cave maximum number) int 0 0 256

# Minimum limit of random number of large caves per mapchunk.
mgfractal_large_cave_num_min (Large cave minimum number) int 0 0 64

# Maximum limit of random number of large caves per mapchunk.
mgfractal_large_cave_num_max (Large cave maximum number) int 2 0 64

# Proportion of large caves that contain liquid.
mgfractal_large_cave_flooded (Large cave proportion flooded) float 0.5 0.0 1.0

# Lower Y limit of dungeons.
mgfractal_dungeon_ymin (Dungeon minimum Y) int -31000

@@ -1970,6 +2045,21 @@ mgvalleys_large_cave_depth (Large cave depth) int -33
# Y of upper limit of lava in large caves.
mgvalleys_lava_depth (Lava depth) int 1

# Minimum limit of random number of small caves per mapchunk.
mgvalleys_small_cave_num_min (Small cave minimum number) int 0 0 256

# Maximum limit of random number of small caves per mapchunk.
mgvalleys_small_cave_num_max (Small cave maximum number) int 0 0 256

# Minimum limit of random number of large caves per mapchunk.
mgvalleys_large_cave_num_min (Large cave minimum number) int 0 0 64

# Maximum limit of random number of large caves per mapchunk.
mgvalleys_large_cave_num_max (Large cave maximum number) int 2 0 64

# Proportion of large caves that contain liquid.
mgvalleys_large_cave_flooded (Large cave proportion flooded) float 0.5 0.0 1.0

# Depth below which you'll find giant caverns.
mgvalleys_cavern_limit (Cavern upper limit) int -256

@@ -280,18 +280,20 @@ CavesRandomWalk::CavesRandomWalk(
int water_level,
content_t water_source,
content_t lava_source,
float large_cave_flooded,
int lava_depth,
BiomeGen *biomegen)
{
assert(ndef);

this->ndef = ndef;
this->gennotify = gennotify;
this->seed = seed;
this->water_level = water_level;
this->np_caveliquids = &nparams_caveliquids;
this->lava_depth = lava_depth;
this->bmgn = biomegen;
this->ndef = ndef;
this->gennotify = gennotify;
this->seed = seed;
this->water_level = water_level;
this->np_caveliquids = &nparams_caveliquids;
this->large_cave_flooded = large_cave_flooded;
this->lava_depth = lava_depth;
this->bmgn = biomegen;

c_water_source = water_source;
if (c_water_source == CONTENT_IGNORE)
@@ -322,7 +324,7 @@ void CavesRandomWalk::makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax,

this->ystride = nmax.X - nmin.X + 1;

flooded = ps->range(1, 2) == 2;
flooded = ps->range(1, 1000) <= large_cave_flooded * 1000.0f;

// If flooded:
// Get biome at mapchunk midpoint. If cave liquid defined for biome, use it.
@@ -116,15 +116,14 @@ class CavesRandomWalk
s16 *heightmap;
BiomeGen *bmgn;

// configurable parameters
s32 seed;
int water_level;
float large_cave_flooded;
// TODO 'lava_depth' and 'np_caveliquids' are deprecated and should be removed.
// Cave liquids are now defined and located using biome definitions.
int lava_depth;
NoiseParams *np_caveliquids;

// intermediate state variables
u16 ystride;

s16 min_tunnel_diameter;
@@ -161,7 +160,8 @@ class CavesRandomWalk
CavesRandomWalk(const NodeDefManager *ndef, GenerateNotifier *gennotify =
NULL, s32 seed = 0, int water_level = 1, content_t water_source =
CONTENT_IGNORE, content_t lava_source = CONTENT_IGNORE,
int lava_depth = -256, BiomeGen *biomegen = NULL);
float large_cave_flooded = 0.5f, int lava_depth = -256,
BiomeGen *biomegen = NULL);

// vm and ps are mandatory parameters.
// If heightmap is NULL, the surface level at all points is assumed to
@@ -843,18 +843,29 @@ void MapgenBasic::generateCavesNoiseIntersection(s16 max_stone_y)

void MapgenBasic::generateCavesRandomWalk(s16 max_stone_y, s16 large_cave_depth)
{
if (node_min.Y > max_stone_y || node_max.Y > large_cave_depth)
if (node_min.Y > max_stone_y)
return;

PseudoRandom ps(blockseed + 21343);
u32 bruises_count = ps.range(0, 2);
// Small randomwalk caves
u32 num_small_caves = ps.range(small_cave_num_min, small_cave_num_max);

for (u32 i = 0; i < bruises_count; i++) {
for (u32 i = 0; i < num_small_caves; i++) {
CavesRandomWalk cave(ndef, &gennotify, seed, water_level,
c_water_source, c_lava_source, lava_depth, biomegen);
c_water_source, c_lava_source, large_cave_flooded, lava_depth, biomegen);
cave.makeCave(vm, node_min, node_max, &ps, false, max_stone_y, heightmap);
}

if (node_max.Y > large_cave_depth)
return;

// Large randomwalk caves below 'large_cave_depth'
u32 num_large_caves = ps.range(large_cave_num_min, large_cave_num_max);

cave.makeCave(vm, node_min, node_max, &ps, true, max_stone_y,
heightmap);
for (u32 i = 0; i < num_large_caves; i++) {
CavesRandomWalk cave(ndef, &gennotify, seed, water_level,
c_water_source, c_lava_source, large_cave_flooded, lava_depth, biomegen);
cave.makeCave(vm, node_min, node_max, &ps, true, max_stone_y, heightmap);
}
}

@@ -280,6 +280,11 @@ class MapgenBasic : public Mapgen {
float cavern_limit;
float cavern_taper;
float cavern_threshold;
int small_cave_num_min;
int small_cave_num_max;
int large_cave_num_min;
int large_cave_num_max;
float large_cave_flooded;
// TODO 'lava_depth' is deprecated and should be removed. Cave liquids are
// now defined and located using biome definitions.
int lava_depth;
@@ -58,15 +58,20 @@ MapgenCarpathian::MapgenCarpathian(MapgenCarpathianParams *params, EmergeManager
river_depth = params->river_depth;
valley_width = params->valley_width;

spflags = params->spflags;
cave_width = params->cave_width;
large_cave_depth = params->large_cave_depth;
lava_depth = params->lava_depth;
cavern_limit = params->cavern_limit;
cavern_taper = params->cavern_taper;
cavern_threshold = params->cavern_threshold;
dungeon_ymin = params->dungeon_ymin;
dungeon_ymax = params->dungeon_ymax;
spflags = params->spflags;
cave_width = params->cave_width;
large_cave_depth = params->large_cave_depth;
lava_depth = params->lava_depth;
small_cave_num_min = params->small_cave_num_min;
small_cave_num_max = params->small_cave_num_max;
large_cave_num_min = params->large_cave_num_min;
large_cave_num_max = params->large_cave_num_max;
large_cave_flooded = params->large_cave_flooded;
cavern_limit = params->cavern_limit;
cavern_taper = params->cavern_taper;
cavern_threshold = params->cavern_threshold;
dungeon_ymin = params->dungeon_ymin;
dungeon_ymax = params->dungeon_ymax;

grad_wl = 1 - water_level;

@@ -148,14 +153,19 @@ void MapgenCarpathianParams::readParams(const Settings *settings)
settings->getFloatNoEx("mgcarpathian_river_depth", river_depth);
settings->getFloatNoEx("mgcarpathian_valley_width", valley_width);

settings->getFloatNoEx("mgcarpathian_cave_width", cave_width);
settings->getS16NoEx("mgcarpathian_large_cave_depth", large_cave_depth);
settings->getS16NoEx("mgcarpathian_lava_depth", lava_depth);
settings->getS16NoEx("mgcarpathian_cavern_limit", cavern_limit);
settings->getS16NoEx("mgcarpathian_cavern_taper", cavern_taper);
settings->getFloatNoEx("mgcarpathian_cavern_threshold", cavern_threshold);
settings->getS16NoEx("mgcarpathian_dungeon_ymin", dungeon_ymin);
settings->getS16NoEx("mgcarpathian_dungeon_ymax", dungeon_ymax);
settings->getFloatNoEx("mgcarpathian_cave_width", cave_width);
settings->getS16NoEx("mgcarpathian_large_cave_depth", large_cave_depth);
settings->getS16NoEx("mgcarpathian_lava_depth", lava_depth);
settings->getU16NoEx("mgcarpathian_small_cave_num_min", small_cave_num_min);
settings->getU16NoEx("mgcarpathian_small_cave_num_max", small_cave_num_max);
settings->getU16NoEx("mgcarpathian_large_cave_num_min", large_cave_num_min);
settings->getU16NoEx("mgcarpathian_large_cave_num_max", large_cave_num_max);
settings->getFloatNoEx("mgcarpathian_large_cave_flooded", large_cave_flooded);
settings->getS16NoEx("mgcarpathian_cavern_limit", cavern_limit);
settings->getS16NoEx("mgcarpathian_cavern_taper", cavern_taper);
settings->getFloatNoEx("mgcarpathian_cavern_threshold", cavern_threshold);
settings->getS16NoEx("mgcarpathian_dungeon_ymin", dungeon_ymin);
settings->getS16NoEx("mgcarpathian_dungeon_ymax", dungeon_ymax);

settings->getNoiseParams("mgcarpathian_np_filler_depth", np_filler_depth);
settings->getNoiseParams("mgcarpathian_np_height1", np_height1);
@@ -186,14 +196,19 @@ void MapgenCarpathianParams::writeParams(Settings *settings) const
settings->setFloat("mgcarpathian_river_depth", river_depth);
settings->setFloat("mgcarpathian_valley_width", valley_width);

settings->setFloat("mgcarpathian_cave_width", cave_width);
settings->setS16("mgcarpathian_large_cave_depth", large_cave_depth);
settings->setS16("mgcarpathian_lava_depth", lava_depth);
settings->setS16("mgcarpathian_cavern_limit", cavern_limit);
settings->setS16("mgcarpathian_cavern_taper", cavern_taper);
settings->setFloat("mgcarpathian_cavern_threshold", cavern_threshold);
settings->setS16("mgcarpathian_dungeon_ymin", dungeon_ymin);
settings->setS16("mgcarpathian_dungeon_ymax", dungeon_ymax);
settings->setFloat("mgcarpathian_cave_width", cave_width);
settings->setS16("mgcarpathian_large_cave_depth", large_cave_depth);
settings->setS16("mgcarpathian_lava_depth", lava_depth);
settings->setU16("mgcarpathian_small_cave_num_min", small_cave_num_min);
settings->setU16("mgcarpathian_small_cave_num_max", small_cave_num_max);
settings->setU16("mgcarpathian_large_cave_num_min", large_cave_num_min);
settings->setU16("mgcarpathian_large_cave_num_max", large_cave_num_max);
settings->setFloat("mgcarpathian_large_cave_flooded", large_cave_flooded);
settings->setS16("mgcarpathian_cavern_limit", cavern_limit);
settings->setS16("mgcarpathian_cavern_taper", cavern_taper);
settings->setFloat("mgcarpathian_cavern_threshold", cavern_threshold);
settings->setS16("mgcarpathian_dungeon_ymin", dungeon_ymin);
settings->setS16("mgcarpathian_dungeon_ymax", dungeon_ymax);

settings->setNoiseParams("mgcarpathian_np_filler_depth", np_filler_depth);
settings->setNoiseParams("mgcarpathian_np_height1", np_height1);
@@ -37,15 +37,20 @@ struct MapgenCarpathianParams : public MapgenParams
float river_depth = 24.0f;
float valley_width = 0.25f;

u32 spflags = MGCARPATHIAN_CAVERNS;
float cave_width = 0.09f;
s16 large_cave_depth = -33;
s16 lava_depth = -256;
s16 cavern_limit = -256;
s16 cavern_taper = 256;
float cavern_threshold = 0.7f;
s16 dungeon_ymin = -31000;
s16 dungeon_ymax = 31000;
u32 spflags = MGCARPATHIAN_CAVERNS;
float cave_width = 0.09f;
s16 large_cave_depth = -33;
s16 lava_depth = -256;
u16 small_cave_num_min = 0;
u16 small_cave_num_max = 0;
u16 large_cave_num_min = 0;
u16 large_cave_num_max = 2;
float large_cave_flooded = 0.5f;
s16 cavern_limit = -256;
s16 cavern_taper = 256;
float cavern_threshold = 0.7f;
s16 dungeon_ymin = -31000;
s16 dungeon_ymax = 31000;

NoiseParams np_filler_depth;
NoiseParams np_height1;

0 comments on commit 2a74727

Please sign in to comment.
You can’t perform that action at this time.