1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* Specials in this file: |
25 | /* Specials in this file: |
26 | included maps */ |
26 | included maps */ |
27 | |
27 | |
28 | #include <global.h> |
28 | #include <global.h> |
29 | #include <random_map.h> |
29 | #include <rmg.h> |
30 | #include <rproto.h> |
30 | #include <rproto.h> |
31 | |
31 | |
|
|
32 | enum { |
|
|
33 | NO_SPECIAL, |
|
|
34 | SPECIAL_SUBMAP, |
|
|
35 | SPECIAL_FOUNTAIN, |
|
|
36 | SPECIAL_EXIT, |
32 | #define NUM_OF_SPECIAL_TYPES 4 |
37 | NUM_OF_SPECIAL_TYPES |
33 | #define NO_SPECIAL 0 |
38 | }; |
34 | #define SPECIAL_SUBMAP 1 |
|
|
35 | #define SPECIAL_FOUNTAIN 2 |
|
|
36 | #define SPECIAL_EXIT 3 |
|
|
37 | |
39 | |
38 | #define GLORY_HOLE 1 |
40 | enum { |
39 | #define ORC_ZONE 2 |
41 | GLORY_HOLE = 1, |
40 | #define MINING_ZONE 3 |
42 | ORC_ZONE, |
|
|
43 | MINING_ZONE, |
41 | #define NR_OF_HOLE_TYPES 3 |
44 | NR_OF_HOLE_TYPES |
|
|
45 | }; |
42 | |
46 | |
43 | /* clear map completely of all !floor objects: |
47 | /* clear map completely of all !floor objects: |
44 | * a rectangular area of xsize, ysize |
48 | * a rectangular area of xsize, ysize |
45 | * is cleared with the top left corner at xstart, ystart |
49 | * is cleared with the top left corner at xstart, ystart |
46 | */ |
50 | */ |
47 | static void |
51 | static void |
48 | nuke_map_region (maptile *map, char **maze, int xstart, int ystart, int xsize, int ysize) |
52 | nuke_map_region (maptile *map, layout &maze, int xstart, int ystart, int xsize, int ysize) |
49 | { |
53 | { |
50 | for (int i = xstart; i < xstart + xsize; i++) |
54 | for (int i = xstart; i < xstart + xsize; i++) |
51 | for (int j = ystart; j < ystart + ysize; j++) |
55 | for (int j = ystart; j < ystart + ysize; j++) |
52 | { |
56 | { |
53 | maze[i][j] = 'S'; |
57 | maze[i][j] = 'S'; |
… | |
… | |
84 | dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON); |
88 | dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON); |
85 | } |
89 | } |
86 | } |
90 | } |
87 | |
91 | |
88 | static int |
92 | static int |
89 | find_spot_for_submap (maptile *map, char **maze, int *ix, int *iy, int xsize, int ysize) |
93 | find_spot_for_submap (maptile *map, layout &maze, int *ix, int *iy, int xsize, int ysize) |
90 | { |
94 | { |
91 | int blocked, i, j; |
95 | int blocked, i, j; |
92 | |
96 | |
93 | /* don't even try to place a submap into a map if the big map isn't |
97 | /* don't even try to place a submap into a map if the big map isn't |
94 | sufficiently large. */ |
98 | sufficiently large. */ |
… | |
… | |
219 | break; |
223 | break; |
220 | } |
224 | } |
221 | } |
225 | } |
222 | |
226 | |
223 | if (!hole_type) |
227 | if (!hole_type) |
224 | hole_type = rmg_rndm (NR_OF_HOLE_TYPES) + 1; |
228 | hole_type = rmg_rndm (1, NR_OF_HOLE_TYPES - 1); |
225 | |
229 | |
226 | const char *style, *decor, *mon; |
230 | const char *style, *decor, *mon; |
227 | int g_xsize, g_ysize; |
231 | int g_xsize, g_ysize; |
228 | |
232 | |
229 | switch (hole_type) |
233 | switch (hole_type) |
… | |
… | |
286 | rp.set ("monsterstyle" , mon); |
290 | rp.set ("monsterstyle" , mon); |
287 | rp.set ("treasurestyle", "none"); |
291 | rp.set ("treasurestyle", "none"); |
288 | rp.set ("layoutstyle" , style); |
292 | rp.set ("layoutstyle" , style); |
289 | rp.set ("decorstyle" , decor); |
293 | rp.set ("decorstyle" , decor); |
290 | rp.set ("decoroptions" , (IV)-1); |
294 | rp.set ("decoroptions" , (IV)-1); |
|
|
295 | rp.set ("symmetry" , (IV)SYMMETRY_NONE); |
|
|
296 | rp.set ("orientation" , (IV)1); |
|
|
297 | rp.set ("random_seed" , RP->get_uv ("random_seed") + 0xdeadbeefU); |
291 | |
298 | |
292 | rp.layoutoptions1 = RMOPT_WALLS_ONLY; |
299 | rp.layoutoptions1 = RMOPT_WALLS_ONLY; |
293 | rp.symmetry = SYMMETRY_NONE; |
|
|
294 | rp.dungeon_depth = RP->dungeon_level; |
300 | rp.dungeon_depth = RP->dungeon_level; |
295 | rp.dungeon_level = RP->dungeon_level; |
301 | rp.dungeon_level = RP->dungeon_level; |
296 | rp.difficulty = RP->difficulty; |
302 | rp.difficulty = RP->difficulty; |
297 | rp.difficulty_given = RP->difficulty; |
303 | rp.difficulty_given = RP->difficulty; |
298 | rp.difficulty_increase = RP->difficulty_increase; |
304 | rp.difficulty_increase = RP->difficulty_increase; |
299 | rp.orientation = 1; |
|
|
300 | rp.random_seed = uint32_t (RP->random_seed + 0xdeadbeef); |
|
|
301 | |
305 | |
302 | the_exit->slaying = shstr_random_map_exit; |
306 | the_exit->slaying = shstr_random_map_exit; |
303 | the_exit->msg = rp.as_shstr (); |
307 | the_exit->msg = rp.as_shstr (); |
304 | |
308 | |
305 | delete &rp; |
309 | delete &rp; |
… | |
… | |
307 | |
311 | |
308 | insert_ob_in_map (the_exit, map, NULL, 0); |
312 | insert_ob_in_map (the_exit, map, NULL, 0); |
309 | } |
313 | } |
310 | |
314 | |
311 | void |
315 | void |
312 | place_specials_in_map (maptile *map, char **maze, random_map_params *RP) |
316 | place_specials_in_map (maptile *map, layout &maze, random_map_params *RP) |
313 | { |
317 | { |
314 | switch (rmg_rndm (NUM_OF_SPECIAL_TYPES)) |
318 | switch (rmg_rndm (NUM_OF_SPECIAL_TYPES)) // can be NO_SPECIAL as well |
315 | { |
319 | { |
316 | case SPECIAL_SUBMAP: |
320 | case SPECIAL_SUBMAP: |
317 | { |
321 | { |
318 | /* includes a special map into the random map being made. */ |
322 | /* includes a special map into the random map being made. */ |
319 | maptile *special_map = find_style ("/styles/specialmaps", 0, RP->difficulty, true); |
323 | maptile *special_map = find_style ("/styles/specialmaps", 0, RP->difficulty, true); |