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 s16b 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(s16b);
162 int roughness = 1; /* The roughness of the level. */
163 u32b state_backup[4];
168 /* The outer wall is easy */
169 if (terrain == TERRAIN_EDGE)
171 /* Create level background */
172 for (y1 = 0; y1 < MAX_HGT; y1++)
174 for (x1 = 0; x1 < MAX_WID; x1++)
176 cave[y1][x1].feat = feat_permanent;
180 /* We are done already */
185 /* Hack -- Backup the RNG state */
186 Rand_state_backup(state_backup);
188 /* Hack -- Induce consistant flavors */
189 Rand_state_init(seed);
193 /* Create level background */
194 for (y1 = 0; y1 < MAX_HGT; y1++)
196 for (x1 = 0; x1 < MAX_WID; x1++)
198 cave[y1][x1].feat = table_size / 2;
204 * Initialize the four corners
205 * ToDo: calculate the medium height of the adjacent
206 * terrains for every corner.
208 cave[1][1].feat = randint0(table_size);
209 cave[MAX_HGT-2][1].feat = randint0(table_size);
210 cave[1][MAX_WID-2].feat = randint0(table_size);
211 cave[MAX_HGT-2][MAX_WID-2].feat = randint0(table_size);
215 /* Hack -- preserve four corners */
216 s16b north_west = cave[1][1].feat;
217 s16b south_west = cave[MAX_HGT - 2][1].feat;
218 s16b north_east = cave[1][MAX_WID - 2].feat;
219 s16b south_east = cave[MAX_HGT - 2][MAX_WID - 2].feat;
221 /* x1, y1, x2, y2, num_depths, roughness */
222 plasma_recursive(1, 1, MAX_WID-2, MAX_HGT-2, table_size-1, roughness);
224 /* Hack -- copyback four corners */
225 cave[1][1].feat = north_west;
226 cave[MAX_HGT - 2][1].feat = south_west;
227 cave[1][MAX_WID - 2].feat = north_east;
228 cave[MAX_HGT - 2][MAX_WID - 2].feat = south_east;
230 for (y1 = 1; y1 < MAX_HGT - 1; y1++)
232 for (x1 = 1; x1 < MAX_WID - 1; x1++)
234 cave[y1][x1].feat = terrain_table[terrain][cave[y1][x1].feat];
238 else /* Hack -- only four corners */
240 cave[1][1].feat = terrain_table[terrain][cave[1][1].feat];
241 cave[MAX_HGT - 2][1].feat = terrain_table[terrain][cave[MAX_HGT - 2][1].feat];
242 cave[1][MAX_WID - 2].feat = terrain_table[terrain][cave[1][MAX_WID - 2].feat];
243 cave[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][cave[MAX_HGT - 2][MAX_WID - 2].feat];
246 /* Hack -- Restore the RNG state */
247 Rand_state_restore(state_backup);
253 * Load a town or generate a terrain level using "plasma" fractals.
255 * x and y are the coordinates of the area in the wilderness.
256 * Border and corner are optimization flags to speed up the
257 * generation of the fractal terrain.
258 * If border is set then only the border of the terrain should
259 * be generated (for initializing the border structure).
260 * If corner is set then only the corners of the area are needed.
262 static void generate_area(int y, int x, bool border, bool corner)
266 /* Number of the town (if any) */
267 p_ptr->town_num = wilderness[y][x].town;
269 /* Set the base level */
270 base_level = wilderness[y][x].level;
272 /* Set the dungeon level */
275 /* Set the monster generation level */
276 monster_level = base_level;
278 /* Set the object generation level */
279 object_level = base_level;
282 /* Create the town */
285 /* Reset the buildings */
288 /* Initialize the town */
290 init_flags = INIT_CREATE_DUNGEON | INIT_ONLY_FEATURES;
292 init_flags = INIT_CREATE_DUNGEON;
294 process_dungeon_file("t_info.txt", 0, 0, MAX_HGT, MAX_WID);
296 if (!corner && !border) p_ptr->visit |= (1L << (p_ptr->town_num - 1));
300 int terrain = wilderness[y][x].terrain;
301 u32b seed = wilderness[y][x].seed;
303 generate_wilderness_area(terrain, seed, border, corner);
306 if (!corner && !wilderness[y][x].town)
309 * Place roads in the wilderness
310 * ToDo: make the road a bit more interresting
312 if (wilderness[y][x].road)
314 cave[MAX_HGT/2][MAX_WID/2].feat = feat_floor;
316 if (wilderness[y-1][x].road)
319 for (y1 = 1; y1 < MAX_HGT/2; y1++)
322 cave[y1][x1].feat = feat_floor;
326 if (wilderness[y+1][x].road)
329 for (y1 = MAX_HGT/2; y1 < MAX_HGT - 1; y1++)
332 cave[y1][x1].feat = feat_floor;
336 if (wilderness[y][x+1].road)
339 for (x1 = MAX_WID/2; x1 < MAX_WID - 1; x1++)
342 cave[y1][x1].feat = feat_floor;
346 if (wilderness[y][x-1].road)
349 for (x1 = 1; x1 < MAX_WID/2; x1++)
352 cave[y1][x1].feat = feat_floor;
358 if (wilderness[y][x].entrance && !wilderness[y][x].town && (p_ptr->total_winner || !(d_info[wilderness[y][x].entrance].flags1 & DF1_WINNER)))
361 u32b state_backup[4];
363 /* Hack -- Backup the RNG state */
364 Rand_state_backup(state_backup);
366 /* Hack -- Induce consistant flavors */
367 Rand_state_init(wilderness[y][x].seed);
369 dy = rand_range(6, cur_hgt - 6);
370 dx = rand_range(6, cur_wid - 6);
372 cave[dy][dx].feat = feat_entrance;
373 cave[dy][dx].special = wilderness[y][x].entrance;
375 /* Hack -- Restore the RNG state */
376 Rand_state_restore(state_backup);
382 * Border of the wilderness area
384 static border_type border;
388 * Build the wilderness area outside of the town.
390 void wilderness_gen(void)
400 /* Assume illegal panel */
401 panel_row_min = cur_hgt;
402 panel_col_min = cur_wid;
404 /* Init the wilderness */
406 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
408 x = p_ptr->wilderness_x;
409 y = p_ptr->wilderness_y;
411 /* Prepare allocation table */
412 get_mon_num_prep(get_monster_hook(), NULL);
415 generate_area(y - 1, x, TRUE, FALSE);
417 for (i = 1; i < MAX_WID - 1; i++)
419 border.north[i] = cave[MAX_HGT - 2][i].feat;
423 generate_area(y + 1, x, TRUE, FALSE);
425 for (i = 1; i < MAX_WID - 1; i++)
427 border.south[i] = cave[1][i].feat;
431 generate_area(y, x - 1, TRUE, FALSE);
433 for (i = 1; i < MAX_HGT - 1; i++)
435 border.west[i] = cave[i][MAX_WID - 2].feat;
439 generate_area(y, x + 1, TRUE, FALSE);
441 for (i = 1; i < MAX_HGT - 1; i++)
443 border.east[i] = cave[i][1].feat;
446 /* North west corner */
447 generate_area(y - 1, x - 1, FALSE, TRUE);
448 border.north_west = cave[MAX_HGT - 2][MAX_WID - 2].feat;
450 /* North east corner */
451 generate_area(y - 1, x + 1, FALSE, TRUE);
452 border.north_east = cave[MAX_HGT - 2][1].feat;
454 /* South west corner */
455 generate_area(y + 1, x - 1, FALSE, TRUE);
456 border.south_west = cave[1][MAX_WID - 2].feat;
458 /* South east corner */
459 generate_area(y + 1, x + 1, FALSE, TRUE);
460 border.south_east = cave[1][1].feat;
463 /* Create terrain of the current area */
464 generate_area(y, x, FALSE, FALSE);
467 /* Special boundary walls -- North */
468 for (i = 0; i < MAX_WID; i++)
470 cave[0][i].feat = feat_permanent;
471 cave[0][i].mimic = border.north[i];
474 /* Special boundary walls -- South */
475 for (i = 0; i < MAX_WID; i++)
477 cave[MAX_HGT - 1][i].feat = feat_permanent;
478 cave[MAX_HGT - 1][i].mimic = border.south[i];
481 /* Special boundary walls -- West */
482 for (i = 0; i < MAX_HGT; i++)
484 cave[i][0].feat = feat_permanent;
485 cave[i][0].mimic = border.west[i];
488 /* Special boundary walls -- East */
489 for (i = 0; i < MAX_HGT; i++)
491 cave[i][MAX_WID - 1].feat = feat_permanent;
492 cave[i][MAX_WID - 1].mimic = border.east[i];
495 /* North west corner */
496 cave[0][0].mimic = border.north_west;
498 /* North east corner */
499 cave[0][MAX_WID - 1].mimic = border.north_east;
501 /* South west corner */
502 cave[MAX_HGT - 1][0].mimic = border.south_west;
504 /* South east corner */
505 cave[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east;
507 /* Light up or darken the area */
508 for (y = 0; y < cur_hgt; y++)
510 for (x = 0; x < cur_wid; x++)
512 /* Get the cave grid */
518 c_ptr->info |= (CAVE_GLOW);
520 /* Hack -- Memorize lit grids if allowed */
521 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
525 /* Feature code (applying "mimic" field) */
526 f_ptr = &f_info[get_feat_mimic(c_ptr)];
528 if (!is_mirror_grid(c_ptr) && !have_flag(f_ptr->flags, FF_QUEST_ENTER) &&
529 !have_flag(f_ptr->flags, FF_ENTRANCE))
532 c_ptr->info &= ~(CAVE_GLOW);
534 /* Darken "boring" features */
535 if (!have_flag(f_ptr->flags, FF_REMEMBER))
537 /* Forget the grid */
538 c_ptr->info &= ~(CAVE_MARK);
541 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
544 c_ptr->info |= (CAVE_GLOW);
546 /* Hack -- Memorize lit grids if allowed */
547 if (view_perma_grids) c_ptr->info |= (CAVE_MARK);
553 if (p_ptr->teleport_town)
555 for (y = 0; y < cur_hgt; y++)
557 for (x = 0; x < cur_wid; x++)
559 /* Get the cave grid */
562 /* Seeing true feature code (ignore mimic) */
563 f_ptr = &f_info[c_ptr->feat];
565 if (have_flag(f_ptr->flags, FF_BLDG))
567 if ((f_ptr->subtype == 4) || ((p_ptr->town_num == 1) && (f_ptr->subtype == 0)))
569 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
576 p_ptr->teleport_town = FALSE;
579 else if (p_ptr->leaving_dungeon)
581 for (y = 0; y < cur_hgt; y++)
583 for (x = 0; x < cur_wid; x++)
585 /* Get the cave grid */
588 if (cave_have_flag_grid(c_ptr, FF_ENTRANCE))
590 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
596 p_ptr->teleport_town = FALSE;
599 player_place(p_ptr->oldpy, p_ptr->oldpx);
600 /* p_ptr->leaving_dungeon = FALSE;*/
602 lim = (generate_encounter==TRUE)?40:MIN_M_ALLOC_TN;
604 /* Make some residents */
605 for (i = 0; i < lim; i++)
609 if (!(generate_encounter || (one_in_(2) && (!p_ptr->town_num))))
610 mode |= PM_ALLOW_SLEEP;
612 /* Make a resident */
613 (void)alloc_monster(generate_encounter ? 0 : 3, mode);
616 if(generate_encounter) ambush_flag = TRUE;
617 generate_encounter = FALSE;
619 /* Fill the arrays of floors and walls in the good proportions */
620 set_floor_and_wall(0);
622 /* Set rewarded quests to finished */
623 for (i = 0; i < max_quests; i++)
625 if (quest[i].status == QUEST_STATUS_REWARDED)
626 quest[i].status = QUEST_STATUS_FINISHED;
631 static s16b conv_terrain2feat[MAX_WILDERNESS];
634 * Build the wilderness area.
637 void wilderness_gen_small()
641 /* To prevent stupid things */
642 for (i = 0; i < MAX_WID; i++)
643 for (j = 0; j < MAX_HGT; j++)
645 cave[j][i].feat = feat_permanent;
648 /* Init the wilderness */
649 process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
652 for (i = 0; i < max_wild_x; i++)
653 for (j = 0; j < max_wild_y; j++)
655 if (wilderness[j][i].town && (wilderness[j][i].town != NO_TOWN))
657 cave[j][i].feat = feat_town;
658 cave[j][i].special = wilderness[j][i].town;
660 else if (wilderness[j][i].road) cave[j][i].feat = feat_floor;
661 else if (wilderness[j][i].entrance && (p_ptr->total_winner || !(d_info[wilderness[j][i].entrance].flags1 & DF1_WINNER)))
663 cave[j][i].feat = feat_entrance;
664 cave[j][i].special = (byte)wilderness[j][i].entrance;
666 else cave[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
668 cave[j][i].info |= (CAVE_GLOW | CAVE_MARK);
671 cur_hgt = (s16b) max_wild_y;
672 cur_wid = (s16b) max_wild_x;
674 if (cur_hgt > MAX_HGT) cur_hgt = MAX_HGT;
675 if (cur_wid > MAX_WID) cur_wid = MAX_WID;
677 /* Assume illegal panel */
678 panel_row_min = cur_hgt;
679 panel_col_min = cur_wid;
681 /* Place the player */
682 px = p_ptr->wilderness_x;
683 py = p_ptr->wilderness_y;
689 typedef struct wilderness_grid wilderness_grid;
691 struct wilderness_grid
693 int terrain; /* Terrain type */
694 int town; /* Town number */
695 s16b level; /* Level of the wilderness */
696 byte road; /* Road */
697 char name[32]; /* Name of the town/wilderness */
701 static wilderness_grid w_letter[255];
705 * Parse a sub-file of the "extra info"
707 errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, int *y, int *x)
717 if (!(buf[0] == 'W')) return (PARSE_ERROR_GENERIC);
721 /* Process "W:F:<letter>:<terrain>:<town>:<road>:<name> */
734 if ((num = tokenize(buf+4, 6, zz, 0)) > 1)
736 int index = zz[0][0];
739 w_letter[index].terrain = atoi(zz[1]);
741 w_letter[index].terrain = 0;
744 w_letter[index].level = atoi(zz[2]);
746 w_letter[index].level = 0;
749 w_letter[index].town = atoi(zz[3]);
751 w_letter[index].town = 0;
754 w_letter[index].road = atoi(zz[4]);
756 w_letter[index].road = 0;
759 strcpy(w_letter[index].name, zz[5]);
761 w_letter[index].name[0] = 0;
766 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
772 /* Process "W:D:<layout> */
773 /* Layout of the wilderness */
776 /* Acquire the text */
779 /* Length of the text */
782 for (*x = xmin, i = 0; ((*x < xmax) && (i < len)); (*x)++, s++, i++)
786 wilderness[*y][*x].terrain = w_letter[idx].terrain;
788 wilderness[*y][*x].level = w_letter[idx].level;
790 wilderness[*y][*x].town = w_letter[idx].town;
792 wilderness[*y][*x].road = w_letter[idx].road;
794 strcpy(town[w_letter[idx].town].name, w_letter[idx].name);
802 /* Process "W:P:<x>:<y> - starting position in the wilderness */
805 if ((p_ptr->wilderness_x == 0) &&
806 (p_ptr->wilderness_y == 0))
808 if (tokenize(buf+4, 2, zz, 0) == 2)
810 p_ptr->wilderness_y = atoi(zz[0]);
811 p_ptr->wilderness_x = atoi(zz[1]);
813 if ((p_ptr->wilderness_x < 1) ||
814 (p_ptr->wilderness_x > max_wild_x) ||
815 (p_ptr->wilderness_y < 1) ||
816 (p_ptr->wilderness_y > max_wild_y))
818 return (PARSE_ERROR_OUT_OF_BOUNDS);
823 return (PARSE_ERROR_TOO_FEW_ARGUMENTS);
832 return (PARSE_ERROR_UNDEFINED_DIRECTIVE);
835 for (i = 1; i < max_d_idx; i++)
837 if (!d_info[i].maxdepth) continue;
838 wilderness[d_info[i].dy][d_info[i].dx].entrance = i;
839 if (!wilderness[d_info[i].dy][d_info[i].dx].town)
840 wilderness[d_info[i].dy][d_info[i].dx].level = d_info[i].mindepth;
849 * Generate the random seeds for the wilderness
851 void seed_wilderness(void)
855 /* Init wilderness seeds */
856 for (x = 0; x < max_wild_x; x++)
858 for (y = 0; y < max_wild_y; y++)
860 wilderness[y][x].seed = randint0(0x10000000);
861 wilderness[y][x].entrance = 0;
868 * Pointer to wilderness_type
870 typedef wilderness_type *wilderness_type_ptr;
873 * Initialize wilderness array
875 errr init_wilderness(void)
879 /* Allocate the wilderness (two-dimension array) */
880 C_MAKE(wilderness, max_wild_y, wilderness_type_ptr);
881 C_MAKE(wilderness[0], max_wild_x * max_wild_y, wilderness_type);
883 /* Init the other pointers */
884 for (i = 1; i < max_wild_y; i++)
885 wilderness[i] = wilderness[0] + i * max_wild_x;
887 generate_encounter = FALSE;
893 static void init_terrain_table(int terrain, s16b feat_global, cptr fmt, ...)
902 /* Begin the varargs stuff */
905 /* Wilderness terrains on global map */
906 conv_terrain2feat[terrain] = feat_global;
908 /* Wilderness terrains on local map */
909 for (p = fmt; *p; p++)
915 feat = (s16b)va_arg(vp, int);
916 num = va_arg(vp, int);
919 for (; (cur < lim) && (cur < MAX_FEAT_IN_TERRAIN); cur++)
920 terrain_table[terrain][cur] = feat;
921 if (cur >= MAX_FEAT_IN_TERRAIN) break;
927 plog_fmt("Format error");
932 if (cur < MAX_FEAT_IN_TERRAIN)
934 plog_fmt("Too few parameters");
937 /* End the varargs stuff */
943 * Initialize arrays for wilderness terrains
945 void init_wilderness_terrains(void)
947 init_terrain_table(TERRAIN_EDGE, feat_permanent, "a",
948 feat_permanent, MAX_FEAT_IN_TERRAIN);
950 init_terrain_table(TERRAIN_TOWN, feat_town, "a",
951 feat_floor, MAX_FEAT_IN_TERRAIN);
953 init_terrain_table(TERRAIN_DEEP_WATER, feat_deep_water, "ab",
955 feat_shallow_water, MAX_FEAT_IN_TERRAIN - 12);
957 init_terrain_table(TERRAIN_SHALLOW_WATER, feat_shallow_water, "abcde",
959 feat_shallow_water, 12,
962 feat_grass, MAX_FEAT_IN_TERRAIN - 17);
964 init_terrain_table(TERRAIN_SWAMP, feat_swamp, "abcdef",
969 feat_shallow_water, 4,
970 feat_swamp, MAX_FEAT_IN_TERRAIN - 11);
972 init_terrain_table(TERRAIN_DIRT, feat_dirt, "abcdef",
978 feat_tree, MAX_FEAT_IN_TERRAIN - 16);
980 init_terrain_table(TERRAIN_GRASS, feat_grass, "abcdef",
986 feat_tree, MAX_FEAT_IN_TERRAIN - 16);
988 init_terrain_table(TERRAIN_TREES, feat_tree, "abcde",
993 feat_grass, MAX_FEAT_IN_TERRAIN - 16);
995 init_terrain_table(TERRAIN_DESERT, feat_dirt, "abc",
998 feat_grass, MAX_FEAT_IN_TERRAIN - 15);
1000 init_terrain_table(TERRAIN_SHALLOW_LAVA, feat_shallow_lava, "abc",
1001 feat_shallow_lava, 14,
1003 feat_mountain, MAX_FEAT_IN_TERRAIN - 17);
1005 init_terrain_table(TERRAIN_DEEP_LAVA, feat_deep_lava, "abcd",
1007 feat_shallow_lava, 3,
1009 feat_mountain, MAX_FEAT_IN_TERRAIN - 16);
1011 init_terrain_table(TERRAIN_MOUNTAIN, feat_mountain, "abcdef",
1017 feat_mountain, MAX_FEAT_IN_TERRAIN - 8);
1021 bool change_wild_mode(void)
1024 bool have_pet = FALSE;
1026 /* It is in the middle of changing map */
1027 if (p_ptr->leaving) return FALSE;
1030 if (lite_town || vanilla_town)
1033 msg_print("¹ÓÌî¤Ê¤ó¤Æ¤Ê¤¤¡£");
1035 msg_print("No global map.");
1040 if (p_ptr->wild_mode)
1042 /* Save the location in the global map */
1043 p_ptr->wilderness_x = px;
1044 p_ptr->wilderness_y = py;
1046 /* Give first move to the player */
1047 p_ptr->energy_need = 0;
1049 /* Go back to the ordinary map */
1050 p_ptr->wild_mode = FALSE;
1053 p_ptr->leaving = TRUE;
1059 for (i = 1; i < m_max; i++)
1061 monster_type *m_ptr = &m_list[i];
1063 if (!m_ptr->r_idx) continue;
1064 if (is_pet(m_ptr) && i != p_ptr->riding) have_pet = TRUE;
1065 if (MON_CSLEEP(m_ptr)) continue;
1066 if (m_ptr->cdis > MAX_SIGHT) continue;
1067 if (!is_hostile(m_ptr)) continue;
1069 msg_print("Ũ¤¬¤¹¤°¶á¤¯¤Ë¤¤¤ë¤È¤¤Ï¹°è¥Þ¥Ã¥×¤ËÆþ¤ì¤Ê¤¤¡ª");
1071 msg_print("You cannot enter global map, since there is some monsters nearby!");
1080 cptr msg = "¥Ú¥Ã¥È¤òÃÖ¤¤¤Æ¹°è¥Þ¥Ã¥×¤ËÆþ¤ê¤Þ¤¹¤«¡©";
1082 cptr msg = "Do you leave your pets behind? ";
1085 if (!get_check_strict(msg, CHECK_OKAY_CANCEL))
1095 /* Remember the position */
1099 /* Cancel hex spelling */
1100 if (hex_spelling_any()) stop_hex_spell_all();
1102 /* Cancel any special action */
1103 set_action(ACTION_NONE);
1105 /* Go into the global map */
1106 p_ptr->wild_mode = TRUE;
1109 p_ptr->leaving = TRUE;