1 #include "room/rooms-pit-nest.h"
3 #include "dungeon/dungeon.h"
4 #include "floor/floor-generate.h"
5 #include "floor/floor.h"
6 #include "game-option/cheat-options.h"
7 #include "game-option/cheat-types.h"
8 #include "grid/feature.h"
10 #include "monster-race/race-flags2.h"
11 #include "monster-race/race-flags3.h"
12 #include "monster-race/race-flags4.h"
13 #include "monster-race/monster-race-hook.h"
14 #include "monster-floor/monster-generator.h"
15 #include "monster/monster-info.h"
16 #include "monster/monster-list.h"
17 #include "monster/monster-util.h"
18 #include "monster-floor/place-monster-types.h"
19 #include "room/pit-nest-kinds-table.h"
21 #include "view/display-messages.h"
24 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
25 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
26 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
27 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
29 static int pick_vault_type(floor_type *floor_ptr, vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
31 int tmp, total, count;
33 vault_aux_type *n_ptr;
35 /* Calculate the total possibilities */
36 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
39 if (!n_ptr->name) break;
41 /* Ignore excessive depth */
42 if (n_ptr->level > floor_ptr->dun_level) continue;
44 /* Not matched with pit/nest flag */
45 if (!(allow_flag_mask & (1L << count))) continue;
47 /* Count this possibility */
48 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
51 /* Pick a random type */
52 tmp = randint0(total);
55 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
58 if (!n_ptr->name) break;
60 /* Ignore excessive depth */
61 if (n_ptr->level > floor_ptr->dun_level) continue;
63 /* Not matched with pit/nest flag */
64 if (!(allow_flag_mask & (1L << count))) continue;
66 /* Count this possibility */
67 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
70 if (tmp < total) break;
73 return n_ptr->name ? count : -1;
78 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
79 * @param type pit/nestの型ID
80 * @param nest TRUEならばnest、FALSEならばpit
81 * @return デバッグ表示文字列の参照ポインタ
83 * Hack -- Get the string describing subtype of pit/nest
84 * Determined in prepare function (some pit/nest only)
86 static concptr pit_subtype_string(int type, bool nest)
88 static char inner_buf[256] = "";
90 inner_buf[0] = '\0'; /* Init string */
97 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
99 case NEST_TYPE_SYMBOL_GOOD:
100 case NEST_TYPE_SYMBOL_EVIL:
101 sprintf(inner_buf, "(%c)", vault_aux_char);
109 case PIT_TYPE_SYMBOL_GOOD:
110 case PIT_TYPE_SYMBOL_EVIL:
111 sprintf(inner_buf, "(%c)", vault_aux_char);
113 case PIT_TYPE_DRAGON:
114 switch (vault_aux_dragon_mask4)
116 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
117 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
118 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
119 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
120 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
121 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
122 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
123 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
134 *! @brief nestのモンスターリストをソートするための関数 /
135 * Comp function for sorting nest monster information
136 * @param u ソート処理対象配列ポインタ
142 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
144 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
145 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
146 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
147 monster_race *r1_ptr = &r_info[w1];
148 monster_race *r2_ptr = &r_info[w2];
154 /* Extract used info */
155 z1 = nest_mon_info[a].used;
156 z2 = nest_mon_info[b].used;
158 /* Compare used status */
159 if (z1 < z2) return FALSE;
160 if (z1 > z2) return TRUE;
163 if (r1_ptr->level < r2_ptr->level) return TRUE;
164 if (r1_ptr->level > r2_ptr->level) return FALSE;
166 /* Compare experience */
167 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
168 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
170 /* Compare indexes */
176 * @brief nestのモンスターリストをスワップするための関数 /
177 * Swap function for sorting nest monster information
178 * @param u スワップ処理対象配列ポインタ
180 * @param a スワップ対象参照ID1
181 * @param b スワップ対象参照ID2
184 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
186 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
187 nest_mon_info_type holder;
193 holder = nest_mon_info[a];
194 nest_mon_info[a] = nest_mon_info[b];
195 nest_mon_info[b] = holder;
200 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
201 * @param player_ptr プレーヤーへの参照ポインタ
204 * A monster nest is a "big" room, with an "inner" room, containing\n
205 * a "collection" of monsters of a given type strewn about the room.\n
207 * The monsters are chosen from a set of 64 randomly selected monster\n
208 * races, to allow the nest creation to fail instead of having "holes".\n
210 * Note the use of the "get_mon_num_prep()" function, and the special\n
211 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
212 * allocation table" in such a way as to optimize the selection of\n
213 * "appropriate" non-unique monsters for the nest.\n
215 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
216 * case the nest will be empty.\n
218 * Note that "monster nests" will never contain "unique" monsters.\n
220 bool build_type5(player_type *player_ptr)
222 POSITION y, x, y1, x1, y2, x2, xval, yval;
224 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
230 floor_type *floor_ptr = player_ptr->current_floor_ptr;
231 int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
232 vault_aux_type *n_ptr;
234 /* No type available */
235 if (cur_nest_type < 0) return FALSE;
237 n_ptr = &nest_types[cur_nest_type];
239 /* Process a preparation function if necessary */
240 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
241 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
243 align.sub_align = SUB_ALIGN_NEUTRAL;
245 /* Pick some monster types */
246 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
248 MONRACE_IDX r_idx = 0;
250 monster_race *r_ptr = NULL;
254 /* Get a (hard) monster type */
255 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
256 r_ptr = &r_info[r_idx];
258 /* Decline incorrect alignment */
259 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
261 /* Accept this monster */
266 if (!r_idx || !attempts) return FALSE;
268 /* Note the alignment */
269 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
270 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
272 nest_mon_info[i].r_idx = (s16b)r_idx;
273 nest_mon_info[i].used = FALSE;
276 /* Find and reserve some space in the dungeon. Get center of room. */
277 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
285 /* Place the floor area */
286 for (y = y1 - 1; y <= y2 + 1; y++)
288 for (x = x1 - 1; x <= x2 + 1; x++)
290 g_ptr = &floor_ptr->grid_array[y][x];
291 place_grid(player_ptr, g_ptr, GB_FLOOR);
292 g_ptr->info |= (CAVE_ROOM);
296 /* Place the outer walls */
297 for (y = y1 - 1; y <= y2 + 1; y++)
299 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
300 place_grid(player_ptr, g_ptr, GB_OUTER);
301 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
302 place_grid(player_ptr, g_ptr, GB_OUTER);
304 for (x = x1 - 1; x <= x2 + 1; x++)
306 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
307 place_grid(player_ptr, g_ptr, GB_OUTER);
308 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
309 place_grid(player_ptr, g_ptr, GB_OUTER);
313 /* Advance to the center room */
319 /* The inner walls */
320 for (y = y1 - 1; y <= y2 + 1; y++)
322 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
323 place_grid(player_ptr, g_ptr, GB_INNER);
324 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
325 place_grid(player_ptr, g_ptr, GB_INNER);
328 for (x = x1 - 1; x <= x2 + 1; x++)
330 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
331 place_grid(player_ptr, g_ptr, GB_INNER);
332 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
333 place_grid(player_ptr, g_ptr, GB_INNER);
335 for (y = y1; y <= y2; y++)
337 for (x = x1; x <= x2; x++)
339 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
343 /* Place a secret door */
346 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
347 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
348 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
349 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
352 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
354 /* Place some monsters */
355 for (y = yval - 2; y <= yval + 2; y++)
357 for (x = xval - 9; x <= xval + 9; x++)
361 i = randint0(NUM_NEST_MON_TYPE);
362 r_idx = nest_mon_info[i].r_idx;
364 /* Place that "random" monster (no groups) */
365 (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
367 nest_mon_info[i].used = TRUE;
373 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
375 /* Dump the entries (prevent multi-printing) */
376 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
378 if (!nest_mon_info[i].used) break;
379 for (; i < NUM_NEST_MON_TYPE - 1; i++)
381 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
382 if (!nest_mon_info[i + 1].used) break;
384 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
393 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
396 * A monster pit is a "big" room, with an "inner" room, containing\n
397 * a "collection" of monsters of a given type organized in the room.\n
399 * The inside room in a monster pit appears as shown below, where the\n
400 * actual monsters in each location depend on the type of the pit\n
402 * XXXXXXXXXXXXXXXXXXXXX\n
403 * X0000000000000000000X\n
404 * X0112233455543322110X\n
405 * X0112233467643322110X\n
406 * X0112233455543322110X\n
407 * X0000000000000000000X\n
408 * XXXXXXXXXXXXXXXXXXXXX\n
410 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
411 * to request 16 "appropriate" monsters, sorting them by level, and using\n
412 * the "even" entries in this sorted list for the contents of the pit.\n
414 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
415 * which is handled by requiring a specific "breath" attack for all of the\n
416 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
417 * be present in many of the dragon pits, if they have the proper breath.\n
419 * Note the use of the "get_mon_num_prep()" function, and the special\n
420 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
421 * allocation table" in such a way as to optimize the selection of\n
422 * "appropriate" non-unique monsters for the pit.\n
424 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
425 * the pit will be empty.\n
427 * Note that "monster pits" will never contain "unique" monsters.\n
429 bool build_type6(player_type *player_ptr)
431 POSITION y, x, y1, x1, y2, x2, xval, yval;
434 MONRACE_IDX what[16];
440 floor_type *floor_ptr = player_ptr->current_floor_ptr;
441 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
442 vault_aux_type *n_ptr;
444 /* No type available */
445 if (cur_pit_type < 0) return FALSE;
447 n_ptr = &pit_types[cur_pit_type];
449 /* Process a preparation function if necessary */
450 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
451 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
453 align.sub_align = SUB_ALIGN_NEUTRAL;
455 /* Pick some monster types */
456 for (i = 0; i < 16; i++)
458 MONRACE_IDX r_idx = 0;
460 monster_race *r_ptr = NULL;
464 /* Get a (hard) monster type */
465 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
466 r_ptr = &r_info[r_idx];
468 /* Decline incorrect alignment */
469 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
471 /* Accept this monster */
476 if (!r_idx || !attempts) return FALSE;
478 /* Note the alignment */
479 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
480 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
485 /* Find and reserve some space in the dungeon. Get center of room. */
486 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
494 /* Place the floor area */
495 for (y = y1 - 1; y <= y2 + 1; y++)
497 for (x = x1 - 1; x <= x2 + 1; x++)
499 g_ptr = &floor_ptr->grid_array[y][x];
500 place_grid(player_ptr, g_ptr, GB_FLOOR);
501 g_ptr->info |= (CAVE_ROOM);
505 /* Place the outer walls */
506 for (y = y1 - 1; y <= y2 + 1; y++)
508 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
509 place_grid(player_ptr, g_ptr, GB_OUTER);
510 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
511 place_grid(player_ptr, g_ptr, GB_OUTER);
513 for (x = x1 - 1; x <= x2 + 1; x++)
515 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
516 place_grid(player_ptr, g_ptr, GB_OUTER);
517 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
518 place_grid(player_ptr, g_ptr, GB_OUTER);
521 /* Advance to the center room */
527 /* The inner walls */
528 for (y = y1 - 1; y <= y2 + 1; y++)
530 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
531 place_grid(player_ptr, g_ptr, GB_INNER);
532 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
533 place_grid(player_ptr, g_ptr, GB_INNER);
535 for (x = x1 - 1; x <= x2 + 1; x++)
537 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
538 place_grid(player_ptr, g_ptr, GB_INNER);
539 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
540 place_grid(player_ptr, g_ptr, GB_INNER);
542 for (y = y1; y <= y2; y++)
544 for (x = x1; x <= x2; x++)
546 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
550 /* Place a secret door */
553 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
554 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
555 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
556 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
559 /* Sort the entries */
560 for (i = 0; i < 16 - 1; i++)
562 /* Sort the entries */
563 for (j = 0; j < 16 - 1; j++)
568 int p1 = r_info[what[i1]].level;
569 int p2 = r_info[what[i2]].level;
574 MONRACE_IDX tmp = what[i1];
581 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
583 /* Select the entries */
584 for (i = 0; i < 8; i++)
586 /* Every other entry */
587 what[i] = what[i * 2];
588 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
591 /* Top and bottom rows */
592 for (x = xval - 9; x <= xval + 9; x++)
594 place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
595 place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
599 for (y = yval - 1; y <= yval + 1; y++)
601 place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
602 place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
604 place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
605 place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
607 place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
608 place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
610 place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
611 place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
613 place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
614 place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
616 place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
617 place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
619 place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
620 place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
622 place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
623 place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
626 /* Above/Below the center monster */
627 for (x = xval - 1; x <= xval + 1; x++)
629 place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
630 place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
633 /* Next to the center monster */
634 place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
635 place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
638 place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
645 * todo vault_monster_okay() をmonsterrace-hook以外から呼んでいるのはここだけなので、何とかしたい
646 * Helper function for "trapped monster pit"
648 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
650 monster_race *r_ptr = &r_info[r_idx];
652 if (!vault_monster_okay(r_idx)) return FALSE;
654 /* No wall passing monster */
655 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
662 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
665 * A trapped monster pit is a "big" room with a straight corridor in\n
666 * which wall opening traps are placed, and with two "inner" rooms\n
667 * containing a "collection" of monsters of a given type organized in\n
670 * The trapped monster pit appears as shown below, where the actual\n
671 * monsters in each location depend on the type of the pit\n
673 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
675 * XXXXXXXXXXXXXXXXXXXXXXX X\n
676 * XXXXX001123454321100XXX X\n
677 * XXX0012234567654322100X X\n
678 * XXXXXXXXXXXXXXXXXXXXXXX X\n
680 * X XXXXXXXXXXXXXXXXXXXXXXX\n
681 * X X0012234567654322100XXX\n
682 * X XXX001123454321100XXXXX\n
683 * X XXXXXXXXXXXXXXXXXXXXXXX\n
685 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
687 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
688 * to request 16 "appropriate" monsters, sorting them by level, and using\n
689 * the "even" entries in this sorted list for the contents of the pit.\n
691 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
692 * which is handled by requiring a specific "breath" attack for all of the\n
693 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
694 * be present in many of the dragon pits, if they have the proper breath.\n
696 * Note the use of the "get_mon_num_prep()" function, and the special\n
697 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
698 * allocation table" in such a way as to optimize the selection of\n
699 * "appropriate" non-unique monsters for the pit.\n
701 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
702 * the pit will be empty.\n
704 * Note that "monster pits" will never contain "unique" monsters.\n
706 bool build_type13(player_type *player_ptr)
708 POSITION y, x, y1, x1, y2, x2, xval, yval;
711 MONRACE_IDX what[16];
717 floor_type *floor_ptr = player_ptr->current_floor_ptr;
718 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
719 vault_aux_type *n_ptr;
721 /* Only in Angband */
722 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
724 /* No type available */
725 if (cur_pit_type < 0) return FALSE;
727 n_ptr = &pit_types[cur_pit_type];
729 /* Process a preparation function if necessary */
730 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
731 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
733 align.sub_align = SUB_ALIGN_NEUTRAL;
735 /* Pick some monster types */
736 for (i = 0; i < 16; i++)
738 MONRACE_IDX r_idx = 0;
740 monster_race *r_ptr = NULL;
744 /* Get a (hard) monster type */
745 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0, 0);
746 r_ptr = &r_info[r_idx];
748 /* Decline incorrect alignment */
749 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
751 /* Accept this monster */
756 if (!r_idx || !attempts) return FALSE;
758 /* Note the alignment */
759 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
760 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
765 /* Find and reserve some space in the dungeon. Get center of room. */
766 if (!find_space(player_ptr, &yval, &xval, 13, 25)) return FALSE;
774 /* Fill with inner walls */
775 for (y = y1 - 1; y <= y2 + 1; y++)
777 for (x = x1 - 1; x <= x2 + 1; x++)
779 g_ptr = &floor_ptr->grid_array[y][x];
780 place_grid(player_ptr, g_ptr, GB_INNER);
781 g_ptr->info |= (CAVE_ROOM);
785 /* Place the floor area 1 */
786 for (x = x1 + 3; x <= x2 - 3; x++)
788 g_ptr = &floor_ptr->grid_array[yval - 2][x];
789 place_grid(player_ptr, g_ptr, GB_FLOOR);
790 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
792 g_ptr = &floor_ptr->grid_array[yval + 2][x];
793 place_grid(player_ptr, g_ptr, GB_FLOOR);
794 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
797 /* Place the floor area 2 */
798 for (x = x1 + 5; x <= x2 - 5; x++)
800 g_ptr = &floor_ptr->grid_array[yval - 3][x];
801 place_grid(player_ptr, g_ptr, GB_FLOOR);
802 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
804 g_ptr = &floor_ptr->grid_array[yval + 3][x];
805 place_grid(player_ptr, g_ptr, GB_FLOOR);
806 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
810 for (x = x1; x <= x2; x++)
812 g_ptr = &floor_ptr->grid_array[yval][x];
813 place_grid(player_ptr, g_ptr, GB_FLOOR);
814 g_ptr = &floor_ptr->grid_array[y1][x];
815 place_grid(player_ptr, g_ptr, GB_FLOOR);
816 g_ptr = &floor_ptr->grid_array[y2][x];
817 place_grid(player_ptr, g_ptr, GB_FLOOR);
820 /* Place the outer walls */
821 for (y = y1 - 1; y <= y2 + 1; y++)
823 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
824 place_grid(player_ptr, g_ptr, GB_OUTER);
825 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
826 place_grid(player_ptr, g_ptr, GB_OUTER);
828 for (x = x1 - 1; x <= x2 + 1; x++)
830 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
831 place_grid(player_ptr, g_ptr, GB_OUTER);
832 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
833 place_grid(player_ptr, g_ptr, GB_OUTER);
836 /* Random corridor */
839 for (y = y1; y <= yval; y++)
841 place_bold(player_ptr, y, x2, GB_FLOOR);
842 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
844 for (y = yval; y <= y2 + 1; y++)
846 place_bold(player_ptr, y, x1, GB_FLOOR);
847 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
852 for (y = yval; y <= y2 + 1; y++)
854 place_bold(player_ptr, y, x1, GB_FLOOR);
855 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
857 for (y = y1; y <= yval; y++)
859 place_bold(player_ptr, y, x2, GB_FLOOR);
860 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
864 /* Place the wall open trap */
865 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
866 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
868 /* Sort the entries */
869 for (i = 0; i < 16 - 1; i++)
871 /* Sort the entries */
872 for (j = 0; j < 16 - 1; j++)
877 int p1 = r_info[what[i1]].level;
878 int p2 = r_info[what[i2]].level;
883 MONRACE_IDX tmp = what[i1];
890 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
891 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
893 /* Select the entries */
894 for (i = 0; i < 8; i++)
896 /* Every other entry */
897 what[i] = what[i * 2];
901 msg_print(r_name + r_info[what[i]].name);
905 for (i = 0; placing[i][2] >= 0; i++)
907 y = yval + placing[i][0];
908 x = xval + placing[i][1];
909 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);