//#define DGEN_USE_TORCHES
-NoiseParams nparams_dungeon_rarity(0.0, 1.0, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);
-NoiseParams nparams_dungeon_wetness(0.0, 1.0, v3f(40.0, 40.0, 40.0), 32474, 4, 1.1, 2.0);
-NoiseParams nparams_dungeon_density(0.0, 1.0, v3f(2.5, 2.5, 2.5), 0, 2, 1.4, 2.0);
+NoiseParams nparams_dungeon_density(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);
+NoiseParams nparams_dungeon_alt_wall(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
///////////////////////////////////////////////////////////////////////////////
} else {
dp.seed = 0;
- dp.c_water = ndef->getId("mapgen_water_source");
- dp.c_cobble = ndef->getId("mapgen_cobble");
- dp.c_moss = ndef->getId("mapgen_mossycobble");
- dp.c_stair = ndef->getId("mapgen_stair_cobble");
+ dp.c_water = ndef->getId("mapgen_water_source");
+ dp.c_river_water = ndef->getId("mapgen_river_water_source");
+ dp.c_wall = ndef->getId("mapgen_cobble");
+ dp.c_alt_wall = ndef->getId("mapgen_mossycobble");
+ dp.c_stair = ndef->getId("mapgen_stair_cobble");
+
+ if (dp.c_river_water == CONTENT_IGNORE)
+ dp.c_river_water = ndef->getId("mapgen_water_source");
dp.diagonal_dirs = false;
- dp.mossratio = 3.0;
dp.holesize = v3s16(1, 2, 1);
dp.roomsize = v3s16(0, 0, 0);
+ dp.rooms_min = 2;
+ dp.rooms_max = 16;
+ dp.y_min = -MAX_MAP_GENERATION_LIMIT;
+ dp.y_max = MAX_MAP_GENERATION_LIMIT;
dp.notifytype = GENNOTIFY_DUNGEON;
- dp.np_rarity = nparams_dungeon_rarity;
- dp.np_wetness = nparams_dungeon_wetness;
- dp.np_density = nparams_dungeon_density;
+ dp.np_density = nparams_dungeon_density;
+ dp.np_alt_wall = nparams_dungeon_alt_wall;
}
-
- // For mapgens using river water
- dp.c_river_water = ndef->getId("mapgen_river_water_source");
- if (dp.c_river_water == CONTENT_IGNORE)
- dp.c_river_water = ndef->getId("mapgen_water_source");
}
assert(vm);
//TimeTaker t("gen dungeons");
- if (NoisePerlin3D(&dp.np_rarity, nmin.X, nmin.Y, nmin.Z, dp.seed) < 0.2)
+ if (nmin.Y < dp.y_min || nmax.Y > dp.y_max)
+ return;
+
+ float nval_density = NoisePerlin3D(&dp.np_density, nmin.X, nmin.Y, nmin.Z, dp.seed);
+ if (nval_density < 1.0f)
return;
this->vm = vm;
}
}
- // Add it
- makeDungeon(v3s16(1, 1, 1) * MAP_BLOCKSIZE);
+ // Add them
+ for (u32 i = 0; i < floor(nval_density); i++)
+ makeDungeon(v3s16(1, 1, 1) * MAP_BLOCKSIZE);
- // Convert some cobble to mossy cobble
- if (dp.mossratio != 0.0) {
- for (s16 z = nmin.Z; z <= nmax.Z; z++)
- for (s16 y = nmin.Y; y <= nmax.Y; y++) {
- u32 i = vm->m_area.index(nmin.X, y, z);
- for (s16 x = nmin.X; x <= nmax.X; x++) {
- if (vm->m_data[i].getContent() == dp.c_cobble) {
- float wetness = NoisePerlin3D(&dp.np_wetness, x, y, z, dp.seed);
- float density = NoisePerlin3D(&dp.np_density, x, y, z, blockseed);
- if (density < wetness / dp.mossratio)
- vm->m_data[i].setContent(dp.c_moss);
- }
- i++;
+ // Optionally convert some structure to alternative structure
+ if (dp.c_alt_wall == CONTENT_IGNORE)
+ return;
+
+ for (s16 z = nmin.Z; z <= nmax.Z; z++)
+ for (s16 y = nmin.Y; y <= nmax.Y; y++) {
+ u32 i = vm->m_area.index(nmin.X, y, z);
+ for (s16 x = nmin.X; x <= nmax.X; x++) {
+ if (vm->m_data[i].getContent() == dp.c_wall) {
+ if (NoisePerlin3D(&dp.np_alt_wall, x, y, z, blockseed) > 0.0f)
+ vm->m_data[i].setContent(dp.c_alt_wall);
}
+ i++;
}
}
*/
v3s16 last_room_center = roomplace + v3s16(roomsize.X / 2, 1, roomsize.Z / 2);
- u32 room_count = random.range(2, 16);
+ u32 room_count = random.range(dp.rooms_min, dp.rooms_max);
for (u32 i = 0; i < room_count; i++) {
// Make a room to the determined place
makeRoom(roomsize, roomplace);
void DungeonGen::makeRoom(v3s16 roomsize, v3s16 roomplace)
{
- MapNode n_cobble(dp.c_cobble);
+ MapNode n_wall(dp.c_wall);
MapNode n_air(CONTENT_AIR);
// Make +-X walls
u32 vi = vm->m_area.index(p);
if (vm->m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vm->m_data[vi] = n_cobble;
+ vm->m_data[vi] = n_wall;
}
{
v3s16 p = roomplace + v3s16(roomsize.X - 1, y, z);
u32 vi = vm->m_area.index(p);
if (vm->m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vm->m_data[vi] = n_cobble;
+ vm->m_data[vi] = n_wall;
}
}
u32 vi = vm->m_area.index(p);
if (vm->m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vm->m_data[vi] = n_cobble;
+ vm->m_data[vi] = n_wall;
}
{
v3s16 p = roomplace + v3s16(x, y, roomsize.Z - 1);
u32 vi = vm->m_area.index(p);
if (vm->m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vm->m_data[vi] = n_cobble;
+ vm->m_data[vi] = n_wall;
}
}
u32 vi = vm->m_area.index(p);
if (vm->m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vm->m_data[vi] = n_cobble;
+ vm->m_data[vi] = n_wall;
}
{
v3s16 p = roomplace + v3s16(x,roomsize. Y - 1, z);
u32 vi = vm->m_area.index(p);
if (vm->m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vm->m_data[vi] = n_cobble;
+ vm->m_data[vi] = n_wall;
}
}
makeFill(p + v3s16(-1, -1, -1),
dp.holesize + v3s16(2, 3, 2),
VMANIP_FLAG_DUNGEON_UNTOUCHABLE,
- MapNode(dp.c_cobble),
+ MapNode(dp.c_wall),
0);
makeHole(p);
makeHole(p - dir);
int facedir = dir_to_facedir(dir * make_stairs);
u32 vi = vm->m_area.index(p.X - dir.X, p.Y - 1, p.Z - dir.Z);
- if (vm->m_data[vi].getContent() == dp.c_cobble)
+ if (vm->m_data[vi].getContent() == dp.c_wall)
vm->m_data[vi] = MapNode(dp.c_stair, 0, facedir);
vi = vm->m_area.index(p.X, p.Y, p.Z);
- if (vm->m_data[vi].getContent() == dp.c_cobble)
+ if (vm->m_data[vi].getContent() == dp.c_wall)
vm->m_data[vi] = MapNode(dp.c_stair, 0, facedir);
}
} else {
makeFill(p + v3s16(-1, -1, -1),
dp.holesize + v3s16(2, 2, 2),
VMANIP_FLAG_DUNGEON_UNTOUCHABLE,
- MapNode(dp.c_cobble),
+ MapNode(dp.c_wall),
0);
makeHole(p);
}
randomizeDir();
continue;
}
- if (vm->getNodeNoExNoEmerge(p).getContent() == dp.c_cobble &&
- vm->getNodeNoExNoEmerge(p1).getContent() == dp.c_cobble) {
+ if (vm->getNodeNoExNoEmerge(p).getContent() == dp.c_wall &&
+ vm->getNodeNoExNoEmerge(p1).getContent() == dp.c_wall) {
// Found wall, this is a good place!
result_place = p;
result_dir = m_dir;
*/
// Jump one up if the actual space is there
if (vm->getNodeNoExNoEmerge(p +
- v3s16(0, 0, 0)).getContent() == dp.c_cobble &&
+ v3s16(0, 0, 0)).getContent() == dp.c_wall &&
vm->getNodeNoExNoEmerge(p +
v3s16(0, 1, 0)).getContent() == CONTENT_AIR &&
vm->getNodeNoExNoEmerge(p +
p += v3s16(0,1,0);
// Jump one down if the actual space is there
if (vm->getNodeNoExNoEmerge(p +
- v3s16(0, 1, 0)).getContent() == dp.c_cobble &&
+ v3s16(0, 1, 0)).getContent() == dp.c_wall &&
vm->getNodeNoExNoEmerge(p +
v3s16(0, 0, 0)).getContent() == CONTENT_AIR &&
vm->getNodeNoExNoEmerge(p +
DungeonParams dp;
- dp.seed = seed;
-
- dp.np_rarity = nparams_dungeon_rarity;
- dp.np_density = nparams_dungeon_density;
- dp.np_wetness = nparams_dungeon_wetness;
- dp.c_water = c_water_source;
+ dp.seed = seed;
+ dp.c_water = c_water_source;
+ dp.c_river_water = c_river_water_source;
+ dp.rooms_min = 2;
+ dp.rooms_max = 16;
+ dp.y_min = -MAX_MAP_GENERATION_LIMIT;
+ dp.y_max = MAX_MAP_GENERATION_LIMIT;
+ dp.np_density = nparams_dungeon_density;
+ dp.np_alt_wall = nparams_dungeon_alt_wall;
switch (stone_type) {
default:
case MGSTONE_STONE:
- dp.c_cobble = c_cobble;
- dp.c_moss = c_mossycobble;
- dp.c_stair = c_stair_cobble;
+ dp.c_wall = c_cobble;
+ dp.c_alt_wall = c_mossycobble;
+ dp.c_stair = c_stair_cobble;
dp.diagonal_dirs = false;
- dp.mossratio = 3.0;
dp.holesize = v3s16(1, 2, 1);
dp.roomsize = v3s16(0, 0, 0);
dp.notifytype = GENNOTIFY_DUNGEON;
break;
case MGSTONE_DESERT_STONE:
- dp.c_cobble = c_desert_stone;
- dp.c_moss = c_desert_stone;
- dp.c_stair = c_desert_stone;
+ dp.c_wall = c_desert_stone;
+ dp.c_alt_wall = CONTENT_IGNORE;
+ dp.c_stair = c_desert_stone;
dp.diagonal_dirs = true;
- dp.mossratio = 0.0;
dp.holesize = v3s16(2, 3, 2);
dp.roomsize = v3s16(2, 5, 2);
dp.notifytype = GENNOTIFY_TEMPLE;
break;
case MGSTONE_SANDSTONE:
- dp.c_cobble = c_sandstonebrick;
- dp.c_moss = c_sandstonebrick;
- dp.c_stair = c_sandstonebrick;
+ dp.c_wall = c_sandstonebrick;
+ dp.c_alt_wall = CONTENT_IGNORE;
+ dp.c_stair = c_sandstonebrick;
dp.diagonal_dirs = false;
- dp.mossratio = 0.0;
dp.holesize = v3s16(2, 2, 2);
dp.roomsize = v3s16(2, 0, 2);
dp.notifytype = GENNOTIFY_DUNGEON;
DungeonParams dp;
dp.seed = seed;
+ dp.c_water = c_water_source;
+ dp.c_river_water = c_water_source;
+ dp.rooms_min = 2;
+ dp.rooms_max = 16;
+ dp.y_min = -MAX_MAP_GENERATION_LIMIT;
+ dp.y_max = MAX_MAP_GENERATION_LIMIT;
+ dp.np_density = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0);
+ dp.np_alt_wall = NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
- dp.np_rarity = nparams_dungeon_rarity;
- dp.np_density = nparams_dungeon_density;
- dp.np_wetness = nparams_dungeon_wetness;
- dp.c_water = c_water_source;
if (getBiome(0, v2s16(node_min.X, node_min.Z)) == BT_DESERT) {
- dp.c_cobble = c_desert_stone;
- dp.c_moss = c_desert_stone;
- dp.c_stair = c_desert_stone;
+ dp.c_wall = c_desert_stone;
+ dp.c_alt_wall = CONTENT_IGNORE;
+ dp.c_stair = c_desert_stone;
dp.diagonal_dirs = true;
- dp.mossratio = 0.0;
dp.holesize = v3s16(2, 3, 2);
dp.roomsize = v3s16(2, 5, 2);
dp.notifytype = GENNOTIFY_TEMPLE;
} else {
- dp.c_cobble = c_cobble;
- dp.c_moss = c_mossycobble;
- dp.c_stair = c_stair_cobble;
+ dp.c_wall = c_cobble;
+ dp.c_alt_wall = c_mossycobble;
+ dp.c_stair = c_stair_cobble;
dp.diagonal_dirs = false;
- dp.mossratio = 3.0;
dp.holesize = v3s16(1, 2, 1);
dp.roomsize = v3s16(0, 0, 0);
dp.notifytype = GENNOTIFY_DUNGEON;