3 Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2015-2018 paramat
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #define VMANIP_FLAG_DUNGEON_INSIDE VOXELFLAG_CHECKED1
28 #define VMANIP_FLAG_DUNGEON_PRESERVE VOXELFLAG_CHECKED2
29 #define VMANIP_FLAG_DUNGEON_UNTOUCHABLE (\
30 VMANIP_FLAG_DUNGEON_INSIDE|VMANIP_FLAG_DUNGEON_PRESERVE)
35 v3s16 rand_ortho_dir(PseudoRandom &random, bool diagonal_dirs);
36 v3s16 turn_xz(v3s16 olddir, int t);
37 void random_turn(PseudoRandom &random, v3s16 &dir);
38 int dir_to_facedir(v3s16 d);
41 struct DungeonParams {
45 // Randomly scattered alternative wall nodes
49 // Diagonal corridors are possible
51 // Dungeon only generates in ground
53 // Dimensions of 3D 'brush' that creates corridors.
54 // Dimensions are of the empty space, not including walls / floor / ceilng.
59 // Room size includes walls / floor / ceilng
62 // The 1st room generated has a 1 in 4 chance of being 'large', all other
63 // rooms are not 'large'.
64 v3s16 room_size_large_min;
65 v3s16 room_size_large_max;
69 // Usually 'GENNOTIFY_DUNGEON', but mapgen v6 uses 'GENNOTIFY_TEMPLE' for
71 GenNotifyType notifytype;
73 // 3D noise that determines which c_wall nodes are converted to c_alt_wall
74 NoiseParams np_alt_wall;
79 MMVManip *vm = nullptr;
80 const NodeDefManager *ndef;
81 GenerateNotifier *gennotify;
94 DungeonGen(const NodeDefManager *ndef,
95 GenerateNotifier *gennotify, DungeonParams *dparams);
97 void generate(MMVManip *vm, u32 bseed,
98 v3s16 full_node_min, v3s16 full_node_max, u16 num_dungeons);
100 void makeDungeon(v3s16 start_padding);
101 void makeRoom(v3s16 roomsize, v3s16 roomplace);
102 void makeCorridor(v3s16 doorplace, v3s16 doordir,
103 v3s16 &result_place, v3s16 &result_dir);
104 void makeDoor(v3s16 doorplace, v3s16 doordir);
105 void makeFill(v3s16 place, v3s16 size, u8 avoid_flags, MapNode n, u8 or_flags);
106 void makeHole(v3s16 place);
108 bool findPlaceForDoor(v3s16 &result_place, v3s16 &result_dir);
109 bool findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace,
110 v3s16 &result_doordir, v3s16 &result_roomplace);
112 inline void randomizeDir()
114 m_dir = rand_ortho_dir(random, dp.diagonal_dirs);
118 extern NoiseParams nparams_dungeon_density;
119 extern NoiseParams nparams_dungeon_alt_wall;