Page 1 of 1

How to Increase the number of dungeons generated by mapgen

PostPosted: Thu Jan 07, 2016 02:47
by Neuromancer
How can I increase the number of dungeons generated by mapgen? The only reference I found to dungeon in minetest game is in C:\Users\Audoo\Downloads\minetest-0.4.13-win64-msvc\minetest-0.4.13\games\minetest_game\mods\default\mapgen.lua but I couldn't find where I could increase the number of dungeons in the mapgen. Is it part of the engine, or is there a .lua file I can tweak?

Re: How to Increase the number of dungeons generated by mapg

PostPosted: Sat Jan 09, 2016 00:21
by sofar
Modify the mgv7_np_cave1 perlin noise, or the mgv6_np_cave noise for mgv6.

You can edit map_meta.txt in your world and regenerating all the terrain by removing map.sqlite (while your server is shut down), and try and play with it.

Re: How to Increase the number of dungeons generated by mapg

PostPosted: Sat Jan 09, 2016 23:26
by paramat
^ Cave noise won't affect dungeons.

Only up to 1 dungeon is generated per chunk, and each has up to 16 rooms, both these values are hardcoded in C++. There is such a thing as dungeon parameters, currently inaccessible to players, dungeon number per chunk and room number could be added. If i can work out how to make dungeon parameters settable i'll do it.

Re: How to Increase the number of dungeons generated by mapg

PostPosted: Sun Jan 10, 2016 00:45
by duane
paramat wrote:Only up to 1 dungeon is generated per chunk, and each has up to 16 rooms, both these values are hardcoded in C++. There is such a thing as dungeon parameters, currently inaccessible to players, dungeon number per chunk and room number could be added. If i can work out how to make dungeon parameters settable i'll do it.


If you didn't want more than one per chunk (which seems extravagant to me), wouldn't just exposing the dungeon rarity noise be sufficient? Adding more rooms would be nice, but it might end up being a pain.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index 2521140..f2b313e 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -865,6 +865,9 @@ mg_biome_np_heat_blend (Mapgen heat blend noise parameters) noise_params 0, 1.5,
 mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (750, 750, 750), 842, 3, 0.5, 2.0
 mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0
 
+#    Noise parameters for dungeon generation.
+mg_dungeon_rarity (Mapgen dungeon frequency noise) noise_params 0, 1, (500, 500, 500, 0, 2, 0.8, 2.0
+
 [***Mapgen v5]
 
 mgv5_np_filler_depth (Mapgen v5 filler depth noise parameters) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0
diff --git a/minetest.conf.example b/minetest.conf.example
index 4dd6d95..dd79aac 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -1071,6 +1071,9 @@
 #    type: noise_params
 # mg_biome_np_humidity_blend = 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0
 
+#    Noise parameters for dungeon generation.
+#mg_dungeon_rarity = 0, 1, (500, 500, 500, 0, 2, 0.8, 2.0
+
 #### Mapgen v5
 
 #    type: noise_params
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 36d19bf..e4836a9 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -436,6 +436,7 @@ void MapgenParams::load(const Settings &settings)
    settings.getNoiseParams("mg_biome_np_heat_blend", np_biome_heat_blend);
    settings.getNoiseParams("mg_biome_np_humidity", np_biome_humidity);
    settings.getNoiseParams("mg_biome_np_humidity_blend", np_biome_humidity_blend);
+   settings.getNoiseParams("mg_dungeon_rarity", np_dungeon_rarity);
 
    delete sparams;
    MapgenFactory *mgfactory = EmergeManager::getMapgenFactory(mg_name);
diff --git a/src/mapgen.h b/src/mapgen.h
index 9bb7d03..0d093e5 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -120,6 +120,8 @@ struct MapgenParams {
    NoiseParams np_biome_humidity;
    NoiseParams np_biome_humidity_blend;
 
+   NoiseParams np_dungeon_rarity;
+
    MapgenSpecificParams *sparams;
 
    MapgenParams() :
@@ -132,6 +134,7 @@ struct MapgenParams {
       np_biome_heat_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 13, 2, 1.0, 2.0)),
       np_biome_humidity(NoiseParams(50, 50, v3f(750.0, 750.0, 750.0), 842, 3, 0.5, 2.0)),
       np_biome_humidity_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 90003, 2, 1.0, 2.0)),
+      np_dungeon_rarity(NoiseParams(0.0, 1.0, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0)),
       sparams(NULL)
    {}
 
diff --git a/src/mapgen_valleys.cpp b/src/mapgen_valleys.cpp
index d64d7e0..7607b8b 100644
--- a/src/mapgen_valleys.cpp
+++ b/src/mapgen_valleys.cpp
@@ -93,6 +93,7 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager *
 
    this->altitude_chill        = sp->altitude_chill;
    this->cave_water_max_height = sp->cave_water_max_height;
+   this->dungeon_rarity        = &params->np_dungeon_rarity;
    this->humidity_adjust       = sp->humidity - 50.f;
    this->humidity_break_point  = sp->humidity_break_point;
    this->lava_max_height       = sp->lava_max_height;
@@ -309,7 +310,7 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
    if ((flags & MG_DUNGEONS) && node_max.Y < 50 && (stone_surface_max_y >= node_min.Y)) {
       DungeonParams dp;
 
-      dp.np_rarity  = nparams_dungeon_rarity;
+      dp.np_rarity  = *dungeon_rarity;
       dp.np_density = nparams_dungeon_density;
       dp.np_wetness = nparams_dungeon_wetness;
       dp.c_water    = c_water_source;
diff --git a/src/mapgen_valleys.h b/src/mapgen_valleys.h
index 8ac2cf2..b3691d2 100644
--- a/src/mapgen_valleys.h
+++ b/src/mapgen_valleys.h
@@ -65,6 +65,7 @@ struct MapgenValleysParams : public MapgenSpecificParams {
    NoiseParams np_biome_humidity_blend;
    NoiseParams np_cliffs;
    NoiseParams np_corr;
+   NoiseParams np_dungeon_rarity;
    NoiseParams np_filler_depth;
    NoiseParams np_inter_valley_fill;
    NoiseParams np_inter_valley_slope;
@@ -121,6 +122,7 @@ class MapgenValleys : public Mapgen {
 
    float altitude_chill;
    float cave_water_max_height;
+   NoiseParams *dungeon_rarity;
    float humidity_adjust;
    float humidity_break_point;
    float lava_max_height;

Re: How to Increase the number of dungeons generated by mapg

PostPosted: Sun Jan 10, 2016 13:58
by Neuromancer
dungeon.jpg
Decorated Dungeon
dungeon.jpg (241.89 KiB) Viewed 1301 times
If you do make any changes, anything you can do to make them more easily decoratable, say by being able to get the coordinates of the room boundaries would be way cool. That way you could figure out a good place to put anvils, cauldrons, book cases, cobwebs, chandeliers, dead torches, chests and the like would be wonderful. Also it would be nice to have rooms with more varied heights. Most of them are either extremely tall, or just 2 blocks tall. It would be good to have some 3 & 4 blocks tall. Although I'm wondering if it just makes more sense to go more the route of the villages modpack, and have a bunch of pre-decorated dungeon rooms that could be appended on to dungeons. It seems like x-decor would be needed to decorate these dungeons, The cobwebs, iron bars, barrels, etc

Re: How to Increase the number of dungeons generated by mapg

PostPosted: Sun Jan 10, 2016 21:06
by paramat
> If you didn't want more than one per chunk (which seems extravagant to me), wouldn't just exposing the dungeon rarity noise be sufficient?

Yes.

Dungeon room height varies but also depends on whether they are stone or sandstone dungeons or desert temples.