4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke,
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
12 /* Purpose: Wilderness generation */
17 static void set_floor_and_wall_aux(s16b feat_type[100], feat_prob prob[DUNGEON_FEAT_PROB_NUM])
19 int lim[DUNGEON_FEAT_PROB_NUM], cur = 0, i;
21 lim[0] = prob[0].percent;
22 for (i = 1; i < DUNGEON_FEAT_PROB_NUM; i++) lim[i] = lim[i - 1] + prob[i].percent;
25 if (lim[DUNGEON_FEAT_PROB_NUM - 1] < 100) lim[DUNGEON_FEAT_PROB_NUM - 1] = 100;
27 for (i = 0; i < 100; i++)
29 while (i == lim[cur]) cur++;
30 feat_type[i] = prob[cur].feat;
35 * Fill the arrays of floors and walls in the good proportions
37 void set_floor_and_wall(byte type)
39 static byte cur_type = 255;
40 dungeon_info_type *d_ptr;
43 if (cur_type == type) return;
46 d_ptr = &d_info[type];
48 set_floor_and_wall_aux(floor_type, d_ptr->floor);
49 set_floor_and_wall_aux(fill_type, d_ptr->fill);
51 feat_wall_outer = d_ptr->outer_wall;
52 feat_wall_inner = d_ptr->inner_wall;
53 feat_wall_solid = d_ptr->outer_wall;
58 * Helper for plasma generation.
60 static void perturb_point_mid(int x1, int x2, int x3, int x4,
61 int xmid, int ymid, int rough, int depth_max)
64 * Average the four corners & perturb it a bit.
65 * tmp is a random int +/- rough
67 int tmp2 = rough*2 + 1;
68 int tmp = randint1(tmp2) - (rough + 1);
70 int avg = ((x1 + x2 + x3 + x4) / 4) + tmp;
72 /* Division always rounds down, so we round up again */
73 if (((x1 + x2 + x3 + x4) % 4) > 1)
78 if (avg > depth_max) avg = depth_max;
80 /* Set the new value. */
81 cave[ymid][xmid].feat = avg;
85 static void perturb_point_end(int x1, int x2, int x3,
86 int xmid, int ymid, int rough, int depth_max)
89 * Average the three corners & perturb it a bit.
90 * tmp is a random int +/- rough
92 int tmp2 = rough * 2 + 1;
93 int tmp = randint0(tmp2) - rough;
95 int avg = ((x1 + x2 + x3) / 3) + tmp;
97 /* Division always rounds down, so we round up again */
98 if ((x1 + x2 + x3) % 3) avg++;
101 if (avg < 0) avg = 0;
102 if (avg > depth_max) avg = depth_max;
104 /* Set the new value. */
105 cave[ymid][xmid].feat = avg;
110 * A generic function to generate the plasma fractal.
111 * Note that it uses ``cave_feat'' as temporary storage.
112 * The values in ``cave_feat'' after this function
113 * are NOT actual features; They are raw heights which
114 * need to be converted to features.
116 static void plasma_recursive(int x1, int y1, int x2, int y2,
117 int depth_max, int rough)
120 int xmid = (x2 - x1) / 2 + x1;
121 int ymid = (y2 - y1) / 2 + y1;
124 if (x1 + 1 == x2) return;
126 perturb_point_mid(cave[y1][x1].feat, cave[y2][x1].feat, cave[y1][x2].feat,
127 cave[y2][x2].feat, xmid, ymid, rough, depth_max);
129 perturb_point_end(cave[y1][x1].feat, cave[y1][x2].feat, cave[ymid][xmid].feat,
130 xmid, y1, rough, depth_max);
132 perturb_point_end(cave[y1][x2].feat, cave[y2][x2].feat, cave[ymid][xmid].feat,
133 x2, ymid, rough, depth_max);
135 perturb_point_end(cave[y2][x2].feat, cave[y2][x1].feat, cave[ymid][xmid].feat,
136 xmid, y2, rough, depth_max);
138 perturb_point_end(cave[y2][x1].feat, cave[y1][x1].feat, cave[ymid][xmid].feat,
139 x1, ymid, rough, depth_max);
142 /* Recurse the four quadrants */
143 plasma_recursive(x1, y1, xmid, ymid, depth_max, rough);
144 plasma_recursive(xmid, y1, x2, ymid, depth_max, rough);
145 plasma_recursive(x1, ymid, xmid, y2, depth_max, rough);
146 plasma_recursive(xmid, ymid, x2, y2, depth_max, rough);
150 #define MAX_FEAT_IN_TERRAIN 18
153 * The default table in terrain level generation.
155 static int terrain_table[MAX_WILDERNESS][MAX_FEAT_IN_TERRAIN];
158 static void generate_wilderness_area(int terrain, u32b seed, bool border, bool corner)
161 int table_size = sizeof(terrain_table[0]) / sizeof(int);
162 int roughness = 1; /* The roughness of the level. */
167 /* The outer wall is easy */
168 if (terrain == TERRAIN_EDGE)
170 /* Create level background */
171 for (y1 = 0; y1 < MAX_HGT; y1++)
173 for (x1 = 0; x1 < MAX_WID; x1++)
175 cave[y1][x1].feat = feat_permanent;
179 /* We are done already */
184 /* Hack -- Use the "simple" RNG */
187 /* Hack -- Induce consistant town layout */
192 /* Create level background */
193 for (y1 = 0; y1 < MAX_HGT; y1++)
195 for (x1 = 0; x1 < MAX_WID; x1++)
197 cave[y1][x1].feat = table_size / 2;
203 * Initialize the four corners
204 * ToDo: calculate the medium height of the adjacent
205 * terrains for every corner.
207 cave[1][1].feat = randint0(table_size);
208 cave[MAX_HGT-2][1].feat = randint0(table_size);
209 cave[1][MAX_WID-2].feat = randint0(table_size);
210 cave[MAX_HGT-2][MAX_WID-2].feat = randint0(table_size);
214 /* Hack -- preserve four corners */
215 s16b north_west = cave[1][1].feat;
216 s16b south_west = cave[MAX_HGT - 2][1].feat;
217 s16b north_east = cave[1][MAX_WID - 2].feat;
218 s16b south_east = cave[MAX_HGT - 2][MAX_WID - 2].feat;
220 /* x1, y1, x2, y2, num_depths, roughness */
221 plasma_recursive(1, 1, MAX_WID-2, MAX_HGT-2, table_size-1, roughness);
223 /* Hack -- copyback four corners */
224 cave[1][1].feat = north_west;
225 cave[MAX_HGT - 2][1].feat = south_west;
226 cave[1][MAX_WID - 2].feat = north_east;
227 cave[MAX_HGT - 2][MAX_WID - 2].feat = south_east;
229 for (y1 = 1; y1 < MAX_HGT - 1; y1++)
231 for (x1 = 1; x1 < MAX_WID - 1; x1++)
233 cave[y1][x1].feat = terrain_table[terrain][cave[y1][x1].feat];
237 else /* Hack -- only four corners */
239 cave[1][1].feat = terrain_table[terrain][cave[1][1].feat];
240 cave[MAX_HGT - 2][1].feat = terrain_table[terrain][cave[MAX_HGT - 2][1].feat];
241 cave[1][MAX_WID - 2].feat = terrain_table[terrain][cave[1][MAX_WID - 2].feat];
242 cave[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][cave[MAX_HGT - 2][MAX_WID - 2].feat];
245 /* Use the complex RNG */
252 * Load a town or generate a terrain level using "plasma" fractals.
254 * x and y are the coordinates of the area in the wilderness.
255 * Border and corner are optimization flags to speed up the
256 * generation of the fractal terrain.
257 * If border is set then only the border of the terrain should
258 * be generated (for initializing the border structure).
259 * If corner is set then only the corners of the area are needed.
261 static void generate_area(int y, int x, bool border, bool corner)
265 /* Number of the town (if any) */
266 p_ptr->town_num = wilderness[y][x].town;
268 /* Set the base level */
269 base_level = wilderness[y][x].level;
271 /* Set the dungeon level */
274 /* Set the monster generation level */
275 monster_level = base_level;
277 /* Set the object generation level */
278 object_level = base_level;
281 /* Create the town */
284 /* Reset the buildings */
287 /* Initialize the town */
289 init_flags = INIT_CREATE_DUNGEON | INIT_ONLY_FEATURES;
291 init_flags = INIT_CREATE_DUNGEON;
293 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
295 if (!corner && !border) p_ptr->visit |= (1L << (p_ptr->town_num - 1));
299 int terrain = wilderness[y][x].terrain;
300 u32b seed = wilderness[y][x].seed;
302 generate_wilderness_area(terrain, seed, border, corner);
305 if (!corner && !wilderness[y][x].town)
308 * Place roads in the wilderness
309 * ToDo: make the road a bit more interresting
311 if (wilderness[y][x].road)
313 cave[MAX_HGT/2][MAX_WID/2].feat = feat_floor;
315 if (wilderness[y-1][x].road)
318 for (y1 = 1; y1 < MAX_HGT/2; y1++)
321 cave[y1][x1].feat = feat_floor;
325 if (wilderness[y+1][x].road)
328 for (y1 = MAX_HGT/2; y1 < MAX_HGT - 1; y1++)
331 cave[y1][x1].feat = feat_floor;
335 if (wilderness[y][x+1].road)
338 for (x1 = MAX_WID/2; x1 < MAX_WID - 1; x1++)
341 cave[y1][x1].feat = feat_floor;
345 if (wilderness[y][x-1].road)
348 for (x1 = 1; x1 < MAX_WID/2; x1++)
351 cave[y1][x1].feat = feat_floor;
357 if (wilderness[y][x].entrance && !wilderness[y][x].town && (p_ptr->total_winner || !(d_info[wilderness[y][x].entrance].flags1 & DF1_WINNER)))
361 /* Hack -- Use the "simple" RNG */
364 /* Hack -- Induce consistant town layout */
365 Rand_value = wilderness[y][x].seed;
367 dy = rand_range(6, cur_hgt - 6);
368 dx = rand_range(6, cur_wid - 6);
370 cave[dy][dx].feat = feat_entrance;
371 cave[dy][dx].special = wilderness[y][x].entrance;
373 /* Use the complex RNG */
380 * Border of the wilderness area
382 static border_type border;
386 * Build the wilderness area outside of the town.
388 void wilderness_gen(void)
398 /* Assume illegal panel */
399 panel_row_min = cur_hgt;
400 panel_col_min = cur_wid;
402 /* Init the wilderness */
404 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
406 x = p_ptr->wilderness_x;
407 y = p_ptr->wilderness_y;
409 /* Prepare allocation table */
410 get_mon_num_prep(get_monster_hook(), NULL);
413 generate_area(y - 1, x, TRUE, FALSE);
415 for (i = 1; i < MAX_WID - 1; i++)
417 border.north[i] = cave[MAX_HGT - 2][i].feat;
421 generate_area(y + 1, x, TRUE, FALSE);
423 for (i = 1; i < MAX_WID - 1; i++)
425 border.south[i] = cave[1][i].feat;
429 generate_area(y, x - 1, TRUE, FALSE);
431 for (i = 1; i < MAX_HGT - 1; i++)
433 border.west[i] = cave[i][MAX_WID - 2].feat;
437 generate_area(y, x + 1, TRUE, FALSE);
439 for (i = 1; i < MAX_HGT - 1; i++)
441 border.east[i] = cave[i][1].feat;
444 /* North west corner */
445 generate_area(y - 1, x - 1, FALSE, TRUE);
446 border.north_west = cave[MAX_HGT - 2][MAX_WID - 2].feat;
448 /* North east corner */
449 generate_area(y - 1, x + 1, FALSE, TRUE);
450 border.north_east = cave[MAX_HGT - 2][1].feat;
452 /* South west corner */
453 generate_area(y + 1, x - 1, FALSE, TRUE);
454 border.south_west = cave[1][MAX_WID - 2].feat;
456 /* South east corner */
457 generate_area(y + 1, x + 1, FALSE, TRUE);
458 border.south_east = cave[1][1].feat;
461 /* Create terrain of the current area */
462 generate_area(y, x, FALSE, FALSE);
465 /* Special boundary walls -- North */
466 for (i = 0; i < MAX_WID; i++)
468 cave[0][i].feat = feat_permanent;
469 cave[0][i].mimic = border.north[i];
472 /* Special boundary walls -- South */
473 for (i = 0; i < MAX_WID; i++)
475 cave[MAX_HGT - 1][i].feat = feat_permanent;
476 cave[MAX_HGT - 1][i].mimic = border.south[i];
479 /* Special boundary walls -- West */
480 for (i = 0; i < MAX_HGT; i++)
482 cave[i][0].feat = feat_permanent;
483 cave[i][0].mimic = border.west[i];
486 /* Special boundary walls -- East */
487 for (i = 0; i < MAX_HGT; i++)
489 cave[i][MAX_WID - 1].feat = feat_permanent;
490 cave[i][MAX_WID - 1].mimic = border.east[i];
493 /* North west corner */
494 cave[0][0].mimic = border.north_west;
496 /* North east corner */
497 cave[0][MAX_WID - 1].mimic = border.north_east;
499 /* South west corner */
500 cave[MAX_HGT - 1][0].mimic = border.south_west;
502 /* South east corner */
503 cave[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east;
505 /* Light up or darken the area */
506 for (y = 0; y < cur_hgt; y++)
508 for (x = 0; x < cur_wid; x++)
510 /* Get the cave grid */
516 c_ptr->info |= (CAVE_GLOW);
518 /* Hack -- Memorize lit grids if allowed */
519 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
523 /* Feature code (applying "mimic" field) */
524 f_ptr = &f_info[get_feat_mimic(c_ptr)];
526 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
527 !have_flag(f_ptr->flags, FF_ENTRANCE))
530 c_ptr->info &= ~(CAVE_GLOW);
532 /* Darken "boring" features */
533 if (!have_flag(f_ptr->flags, FF_REMEMBER))
535 /* Forget the grid */
536 c_ptr->info &= ~(CAVE_MARK);
539 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
542 c_ptr->info |= (CAVE_GLOW);
544 /* Hack -- Memorize lit grids if allowed */
545 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
551 if (p_ptr->teleport_town)
553 for (y = 0; y < cur_hgt; y++)
555 for (x = 0; x < cur_wid; x++)
557 /* Get the cave grid */
560 /* Seeing true feature code (ignore mimic) */
561 f_ptr = &f_info[c_ptr->feat];
563 if (have_flag(f_ptr->flags, FF_BLDG))
565 if ((f_ptr->subtype == 4) || ((p_ptr->town_num == 1) && (f_ptr->subtype == 0)))
567 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
574 p_ptr->teleport_town = FALSE;
577 else if (p_ptr->leaving_dungeon)
579 for (y = 0; y < cur_hgt; y++)
581 for (x = 0; x < cur_wid; x++)
583 /* Get the cave grid */
586 if (cave_have_flag_grid(c_ptr, FF_ENTRANCE))
588 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
594 p_ptr->teleport_town = FALSE;
597 player_place(p_ptr->oldpy, p_ptr->oldpx);
598 /* p_ptr->leaving_dungeon = FALSE;*/
600 lim = (generate_encounter==TRUE)?40:MIN_M_ALLOC_TN;
602 /* Make some residents */
603 for (i = 0; i < lim; i++)
607 if (!(generate_encounter || (one_in_(2) && (!p_ptr->town_num))))
608 mode |= PM_ALLOW_SLEEP;
610 /* Make a resident */
611 (void)alloc_monster(generate_encounter ? 0 : 3, mode);
614 if(generate_encounter) ambush_flag = TRUE;
615 generate_encounter = FALSE;
617 /* Fill the arrays of floors and walls in the good proportions */
618 set_floor_and_wall(0);
620 /* Set rewarded quests to finished */
621 for (i = 0; i < max_quests; i++)
623 if (quest[i].status == QUEST_STATUS_REWARDED)
624 quest[i].status = QUEST_STATUS_FINISHED;
629 static s16b conv_terrain2feat[MAX_WILDERNESS];
632 * Build the wilderness area.
635 void wilderness_gen_small()
639 /* To prevent stupid things */
640 for (i = 0; i < MAX_WID; i++)
641 for (j = 0; j < MAX_HGT; j++)
643 cave[j][i].feat = feat_permanent;
646 /* Init the wilderness */
647 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
650 for (i = 0; i < max_wild_x; i++)
651 for (j = 0; j < max_wild_y; j++)
653 if (wilderness[j][i].town && (wilderness[j][i].town != NO_TOWN))
655 cave[j][i].feat = feat_town;
656 cave[j][i].special = wilderness[j][i].town;
658 else if (wilderness[j][i].road) cave[j][i].feat = feat_floor;
659 else if (wilderness[j][i].entrance && (p_ptr->total_winner || !(d_info[wilderness[j][i].entrance].flags1 & DF1_WINNER)))
661 cave[j][i].feat = feat_entrance;
662 cave[j][i].special = (byte)wilderness[j][i].entrance;
664 else cave[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
666 cave[j][i].info |= (CAVE_GLOW | CAVE_MARK);
669 cur_hgt = (s16b) max_wild_y;
670 cur_wid = (s16b) max_wild_x;
672 if (cur_hgt > MAX_HGT) cur_hgt = MAX_HGT;
673 if (cur_wid > MAX_WID) cur_wid = MAX_WID;
675 /* Assume illegal panel */
676 panel_row_min = cur_hgt;
677 panel_col_min = cur_wid;
679 /* Place the player */
680 px = p_ptr->wilderness_x;
681 py = p_ptr->wilderness_y;
687 typedef struct wilderness_grid wilderness_grid;
689 struct wilderness_grid
691 int terrain; /* Terrain type */
692 int town; /* Town number */
693 s16b level; /* Level of the wilderness */
694 byte road; /* Road */
695 char name[32]; /* Name of the town/wilderness */
699 static wilderness_grid w_letter[255];
703 * Parse a sub-file of the "extra info"
705 errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
715 if (!(buf[0] == 'W')) return (PARSE_ERROR_GENERIC);
719 /* Process "W:F:<letter>:<terrain>:<town>:<road>:<name> */
732 if ((num = tokenize(buf+4, 6, zz, 0)) > 1)
734 int index = zz[0][0];
737 w_letter[index].terrain = atoi(zz[1]);
739 w_letter[index].terrain = 0;
742 w_letter[index].level = atoi(zz[2]);
744 w_letter[index].level = 0;
747 w_letter[index].town = atoi(zz[3]);
749 w_letter[index].town = 0;
752 w_letter[index].road = atoi(zz[4]);
754 w_letter[index].road = 0;
757 strcpy(w_letter[index].name, zz[5]);
759 w_letter[index].name[0] = 0;
764 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
770 /* Process "W:D:<layout> */
771 /* Layout of the wilderness */
774 /* Acquire the text */
777 /* Length of the text */
780 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
784 wilderness[*y][*x].terrain = w_letter[idx].terrain;
786 wilderness[*y][*x].level = w_letter[idx].level;
788 wilderness[*y][*x].town = w_letter[idx].town;
790 wilderness[*y][*x].road = w_letter[idx].road;
792 strcpy(town[w_letter[idx].town].name, w_letter[idx].name);
800 /* Process "W:P:<x>:<y> - starting position in the wilderness */
803 if ((p_ptr->wilderness_x == 0) &&
804 (p_ptr->wilderness_y == 0))
806 if (tokenize(buf+4, 2, zz, 0) == 2)
808 p_ptr->wilderness_y = atoi(zz[0]);
809 p_ptr->wilderness_x = atoi(zz[1]);
811 if ((p_ptr->wilderness_x < 1) ||
812 (p_ptr->wilderness_x > max_wild_x) ||
813 (p_ptr->wilderness_y < 1) ||
814 (p_ptr->wilderness_y > max_wild_y))
816 return (PARSE_ERROR_OUT_OF_BOUNDS);
821 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
830 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
833 for (i = 1; i < max_d_idx; i++)
835 if (!d_info[i].maxdepth) continue;
836 wilderness[d_info[i].dy][d_info[i].dx].entrance = i;
837 if (!wilderness[d_info[i].dy][d_info[i].dx].town)
838 wilderness[d_info[i].dy][d_info[i].dx].level = d_info[i].mindepth;
847 * Generate the random seeds for the wilderness
849 void seed_wilderness(void)
853 /* Init wilderness seeds */
854 for (x = 0; x < max_wild_x; x++)
856 for (y = 0; y < max_wild_y; y++)
858 wilderness[y][x].seed = randint0(0x10000000);
859 wilderness[y][x].entrance = 0;
866 * Pointer to wilderness_type
868 typedef wilderness_type *wilderness_type_ptr;
871 * Initialize wilderness array
873 errr init_wilderness(void)
877 /* Allocate the wilderness (two-dimension array) */
878 C_MAKE(wilderness, max_wild_y, wilderness_type_ptr);
879 C_MAKE(wilderness[0], max_wild_x * max_wild_y, wilderness_type);
881 /* Init the other pointers */
882 for (i = 1; i < max_wild_y; i++)
883 wilderness[i] = wilderness[0] + i * max_wild_x;
885 generate_encounter = FALSE;
891 static void init_terrain_table(int terrain, s16b feat_global, cptr fmt, ...)
900 /* Begin the varargs stuff */
903 /* Wilderness terrains on global map */
904 conv_terrain2feat[terrain] = feat_global;
906 /* Wilderness terrains on local map */
907 for (p = fmt; *p; p++)
913 feat = va_arg(vp, s16b);
914 num = va_arg(vp, int);
917 for (; (cur < lim) && (cur < MAX_FEAT_IN_TERRAIN); cur++)
918 terrain_table[terrain][cur] = feat;
919 if (cur >= MAX_FEAT_IN_TERRAIN) break;
925 plog_fmt("Format error");
929 feat = terrain_table[terrain][cur];
930 for (; cur < MAX_FEAT_IN_TERRAIN; cur++) terrain_table[terrain][cur] = feat;
932 /* End the varargs stuff */
938 * Initialize arrays for wilderness terrains
940 void init_wilderness_terrains(void)
942 init_terrain_table(TERRAIN_EDGE, feat_permanent, "a",
943 feat_permanent, MAX_FEAT_IN_TERRAIN);
945 init_terrain_table(TERRAIN_TOWN, feat_town, "a",
946 feat_floor, MAX_FEAT_IN_TERRAIN);
948 init_terrain_table(TERRAIN_DEEP_WATER, feat_deep_water, "ab",
950 feat_shallow_water, MAX_FEAT_IN_TERRAIN - 12);
952 init_terrain_table(TERRAIN_SHALLOW_WATER, feat_shallow_water, "abcde",
954 feat_shallow_water, 12,
957 feat_grass, MAX_FEAT_IN_TERRAIN - 17);
959 init_terrain_table(TERRAIN_SWAMP, feat_swamp, "abcdef",
964 feat_shallow_water, 4,
965 feat_swamp, MAX_FEAT_IN_TERRAIN - 11);
967 init_terrain_table(TERRAIN_DIRT, feat_dirt, "abcdef",
973 feat_tree, MAX_FEAT_IN_TERRAIN - 16);
975 init_terrain_table(TERRAIN_GRASS, feat_grass, "abcdef",
981 feat_tree, MAX_FEAT_IN_TERRAIN - 16);
983 init_terrain_table(TERRAIN_TREES, feat_tree, "abcde",
988 feat_grass, MAX_FEAT_IN_TERRAIN - 16);
990 init_terrain_table(TERRAIN_DESERT, feat_dirt, "abc",
993 feat_grass, MAX_FEAT_IN_TERRAIN - 15);
995 init_terrain_table(TERRAIN_SHALLOW_LAVA, feat_shallow_lava, "abc",
996 feat_shallow_lava, 14,
998 feat_mountain, MAX_FEAT_IN_TERRAIN - 17);
1000 init_terrain_table(TERRAIN_DEEP_LAVA, feat_deep_lava, "abcd",
1002 feat_shallow_lava, 3,
1004 feat_mountain, MAX_FEAT_IN_TERRAIN - 16);
1006 init_terrain_table(TERRAIN_MOUNTAIN, feat_mountain, "abcdef",
1012 feat_mountain, MAX_FEAT_IN_TERRAIN - 8);
1016 bool change_wild_mode(void)
1019 bool have_pet = FALSE;
1021 /* It is in the middle of changing map */
1022 if (p_ptr->leaving) return FALSE;
1025 if (lite_town || vanilla_town)
1028 msg_print("¹ÓÌî¤Ê¤ó¤Æ¤Ê¤¤¡£");
1030 msg_print("No global map.");
1035 if (p_ptr->wild_mode)
1037 /* Save the location in the global map */
1038 p_ptr->wilderness_x = px;
1039 p_ptr->wilderness_y = py;
1041 /* Give first move to the player */
1042 p_ptr->energy_need = 0;
1044 /* Go back to the ordinary map */
1045 p_ptr->wild_mode = FALSE;
1048 p_ptr->leaving = TRUE;
1054 for (i = 1; i < m_max; i++)
1056 monster_type *m_ptr = &m_list[i];
1058 if (!m_ptr->r_idx) continue;
1059 if (is_pet(m_ptr) && i != p_ptr->riding) have_pet = TRUE;
1060 if (MON_CSLEEP(m_ptr)) continue;
1061 if (m_ptr->cdis > MAX_SIGHT) continue;
1062 if (!is_hostile(m_ptr)) continue;
1064 msg_print("Ũ¤¬¤¹¤°¶á¤¯¤Ë¤¤¤ë¤È¤¤Ï¹°è¥Þ¥Ã¥×¤ËÆþ¤ì¤Ê¤¤¡ª");
1066 msg_print("You cannot enter global map, since there is some monsters nearby!");
1075 cptr msg = "¥Ú¥Ã¥È¤òÃÖ¤¤¤Æ¹°è¥Þ¥Ã¥×¤ËÆþ¤ê¤Þ¤¹¤«¡©";
1077 cptr msg = "Do you leave your pets behind? ";
1080 if (!get_check_strict(msg, CHECK_OKAY_CANCEL))
1090 /* Remember the position */
1094 /* Cancel any special action */
1095 set_action(ACTION_NONE);
1097 /* Go into the global map */
1098 p_ptr->wild_mode = TRUE;
1101 p_ptr->leaving = TRUE;