forked from Mirrorlandia_minetest/minetest
Dungeons: Make multiple large rooms possible (#8678)
Re-add the random size range for large rooms. Remove 'first_room_large' bool. Add 'large_room_chance' parameter that can disable large rooms, specify 1 large room, or specify a chance for large rooms. If 1 or a chance is specified, the first generated room is large, to take advantage of the intersection checks that are done for the 1st room only.
This commit is contained in:
parent
47492386ec
commit
458f617575
@ -64,9 +64,10 @@ DungeonGen::DungeonGen(const NodeDefManager *ndef,
|
|||||||
dp.corridor_len_max = 13;
|
dp.corridor_len_max = 13;
|
||||||
dp.room_size_min = v3s16(4, 4, 4);
|
dp.room_size_min = v3s16(4, 4, 4);
|
||||||
dp.room_size_max = v3s16(8, 6, 8);
|
dp.room_size_max = v3s16(8, 6, 8);
|
||||||
dp.room_size_large = v3s16(16, 16, 16);
|
dp.room_size_large_min = v3s16(8, 8, 8);
|
||||||
dp.first_room_large = true;
|
dp.room_size_large_max = v3s16(16, 16, 16);
|
||||||
dp.num_rooms = 16;
|
dp.large_room_chance = 1;
|
||||||
|
dp.num_rooms = 8;
|
||||||
dp.num_dungeons = 1;
|
dp.num_dungeons = 1;
|
||||||
dp.notifytype = GENNOTIFY_DUNGEON;
|
dp.notifytype = GENNOTIFY_DUNGEON;
|
||||||
|
|
||||||
@ -152,11 +153,10 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
|
|||||||
*/
|
*/
|
||||||
bool fits = false;
|
bool fits = false;
|
||||||
for (u32 i = 0; i < 100 && !fits; i++) {
|
for (u32 i = 0; i < 100 && !fits; i++) {
|
||||||
// Only the first room can be 'large'
|
if (dp.large_room_chance >= 1) {
|
||||||
if (dp.first_room_large) {
|
roomsize.Z = random.range(dp.room_size_large_min.Z, dp.room_size_large_max.Z);
|
||||||
roomsize.Z = dp.room_size_large.Z;
|
roomsize.Y = random.range(dp.room_size_large_min.Y, dp.room_size_large_max.Y);
|
||||||
roomsize.Y = dp.room_size_large.Y;
|
roomsize.X = random.range(dp.room_size_large_min.X, dp.room_size_large_max.X);
|
||||||
roomsize.X = dp.room_size_large.X;
|
|
||||||
} else {
|
} else {
|
||||||
roomsize.Z = random.range(dp.room_size_min.Z, dp.room_size_max.Z);
|
roomsize.Z = random.range(dp.room_size_min.Z, dp.room_size_max.Z);
|
||||||
roomsize.Y = random.range(dp.room_size_min.Y, dp.room_size_max.Y);
|
roomsize.Y = random.range(dp.room_size_min.Y, dp.room_size_max.Y);
|
||||||
@ -250,9 +250,16 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
|
|||||||
makeCorridor(doorplace, doordir, corridor_end, corridor_end_dir);
|
makeCorridor(doorplace, doordir, corridor_end, corridor_end_dir);
|
||||||
|
|
||||||
// Find a place for a random sized room
|
// Find a place for a random sized room
|
||||||
|
if (dp.large_room_chance > 1 && random.range(1, dp.large_room_chance) == 1) {
|
||||||
|
// Large room
|
||||||
|
roomsize.Z = random.range(dp.room_size_large_min.Z, dp.room_size_large_max.Z);
|
||||||
|
roomsize.Y = random.range(dp.room_size_large_min.Y, dp.room_size_large_max.Y);
|
||||||
|
roomsize.X = random.range(dp.room_size_large_min.X, dp.room_size_large_max.X);
|
||||||
|
} else {
|
||||||
roomsize.Z = random.range(dp.room_size_min.Z, dp.room_size_max.Z);
|
roomsize.Z = random.range(dp.room_size_min.Z, dp.room_size_max.Z);
|
||||||
roomsize.Y = random.range(dp.room_size_min.Y, dp.room_size_max.Y);
|
roomsize.Y = random.range(dp.room_size_min.Y, dp.room_size_max.Y);
|
||||||
roomsize.X = random.range(dp.room_size_min.X, dp.room_size_max.X);
|
roomsize.X = random.range(dp.room_size_min.X, dp.room_size_max.X);
|
||||||
|
}
|
||||||
|
|
||||||
m_pos = corridor_end;
|
m_pos = corridor_end;
|
||||||
m_dir = corridor_end_dir;
|
m_dir = corridor_end_dir;
|
||||||
@ -265,7 +272,6 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
|
|||||||
else
|
else
|
||||||
// Don't actually make a door
|
// Don't actually make a door
|
||||||
roomplace -= doordir;
|
roomplace -= doordir;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +58,14 @@ struct DungeonParams {
|
|||||||
// Room size random range. Includes walls / floor / ceilng
|
// Room size random range. Includes walls / floor / ceilng
|
||||||
v3s16 room_size_min;
|
v3s16 room_size_min;
|
||||||
v3s16 room_size_max;
|
v3s16 room_size_max;
|
||||||
// Large room size
|
// Large room size random range. Includes walls / floor / ceilng
|
||||||
v3s16 room_size_large;
|
v3s16 room_size_large_min;
|
||||||
// First generated room is large
|
v3s16 room_size_large_max;
|
||||||
bool first_room_large;
|
// Value 0 disables large rooms.
|
||||||
|
// Value 1 results in 1 large room, the first generated room.
|
||||||
|
// Value > 1 makes the first generated room large, all other rooms have a
|
||||||
|
// '1 in value' chance of being large.
|
||||||
|
u16 large_room_chance;
|
||||||
// Dimensions of 3D 'brush' that creates corridors.
|
// Dimensions of 3D 'brush' that creates corridors.
|
||||||
// Dimensions are of the empty space, not including walls / floor / ceilng.
|
// Dimensions are of the empty space, not including walls / floor / ceilng.
|
||||||
v3s16 holesize;
|
v3s16 holesize;
|
||||||
|
@ -883,9 +883,9 @@ void MapgenBasic::generateDungeons(s16 max_stone_y)
|
|||||||
dp.num_rooms = ps.range(2, 16);
|
dp.num_rooms = ps.range(2, 16);
|
||||||
dp.room_size_min = v3s16(6, 5, 6);
|
dp.room_size_min = v3s16(6, 5, 6);
|
||||||
dp.room_size_max = v3s16(10, 6, 10);
|
dp.room_size_max = v3s16(10, 6, 10);
|
||||||
dp.room_size_large = v3s16(
|
dp.room_size_large_min = v3s16(10, 8, 10);
|
||||||
ps.range(10, 18), ps.range(8, 16), ps.range(10, 18));
|
dp.room_size_large_max = v3s16(18, 16, 18);
|
||||||
dp.first_room_large = ps.range(1, 4) == 1;
|
dp.large_room_chance = (ps.range(1, 4) == 1) ? 1 : 0;
|
||||||
dp.holesize = v3s16(2, 3, 2);
|
dp.holesize = v3s16(2, 3, 2);
|
||||||
dp.corridor_len_min = 1;
|
dp.corridor_len_min = 1;
|
||||||
dp.corridor_len_max = 13;
|
dp.corridor_len_max = 13;
|
||||||
|
@ -578,7 +578,7 @@ void MapgenV6::makeChunk(BlockMakeData *data)
|
|||||||
dp.corridor_len_min = 1;
|
dp.corridor_len_min = 1;
|
||||||
dp.corridor_len_max = 13;
|
dp.corridor_len_max = 13;
|
||||||
dp.num_rooms = ps.range(2, 16);
|
dp.num_rooms = ps.range(2, 16);
|
||||||
dp.first_room_large = ps.range(1, 4) == 1;
|
dp.large_room_chance = (ps.range(1, 4) == 1) ? 1 : 0;
|
||||||
|
|
||||||
dp.np_alt_wall
|
dp.np_alt_wall
|
||||||
= NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
|
= NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0);
|
||||||
@ -592,8 +592,8 @@ void MapgenV6::makeChunk(BlockMakeData *data)
|
|||||||
dp.holesize = v3s16(2, 3, 2);
|
dp.holesize = v3s16(2, 3, 2);
|
||||||
dp.room_size_min = v3s16(6, 9, 6);
|
dp.room_size_min = v3s16(6, 9, 6);
|
||||||
dp.room_size_max = v3s16(10, 11, 10);
|
dp.room_size_max = v3s16(10, 11, 10);
|
||||||
dp.room_size_large = v3s16(
|
dp.room_size_large_min = v3s16(10, 13, 10);
|
||||||
ps.range(10, 18), ps.range(13, 21), ps.range(10, 18));
|
dp.room_size_large_max = v3s16(18, 21, 18);
|
||||||
dp.notifytype = GENNOTIFY_TEMPLE;
|
dp.notifytype = GENNOTIFY_TEMPLE;
|
||||||
} else {
|
} else {
|
||||||
dp.c_wall = c_cobble;
|
dp.c_wall = c_cobble;
|
||||||
@ -604,8 +604,8 @@ void MapgenV6::makeChunk(BlockMakeData *data)
|
|||||||
dp.holesize = v3s16(1, 2, 1);
|
dp.holesize = v3s16(1, 2, 1);
|
||||||
dp.room_size_min = v3s16(4, 4, 4);
|
dp.room_size_min = v3s16(4, 4, 4);
|
||||||
dp.room_size_max = v3s16(8, 6, 8);
|
dp.room_size_max = v3s16(8, 6, 8);
|
||||||
dp.room_size_large = v3s16(
|
dp.room_size_large_min = v3s16(8, 8, 8);
|
||||||
ps.range(8, 16), ps.range(8, 16), ps.range(8, 16));
|
dp.room_size_large_max = v3s16(16, 16, 16);
|
||||||
dp.notifytype = GENNOTIFY_DUNGEON;
|
dp.notifytype = GENNOTIFY_DUNGEON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user