1 #include "room/rooms-pit-nest.h"
2 #include "dungeon/dungeon.h"
3 #include "floor/floor-generate.h"
4 #include "game-option/cheat-options.h"
5 #include "game-option/cheat-types.h"
6 #include "grid/feature.h"
8 #include "monster-floor/monster-generator.h"
9 #include "monster-floor/place-monster-types.h"
10 #include "monster-race/monster-race-hook.h"
11 #include "monster-race/monster-race.h"
12 #include "monster-race/race-flags-resistance.h"
13 #include "monster-race/race-flags1.h"
14 #include "monster-race/race-flags2.h"
15 #include "monster-race/race-flags3.h"
16 #include "monster-race/race-flags4.h"
17 #include "monster-race/race-flags7.h"
18 #include "monster/monster-info.h"
19 #include "monster/monster-list.h"
20 #include "monster/monster-util.h"
21 #include "room/pit-nest-kinds-table.h"
22 #include "room/rooms.h"
23 #include "system/floor-type-definition.h"
24 #include "util/sort.h"
25 #include "view/display-messages.h"
26 #include "wizard/wizard-messages.h"
29 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
30 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
31 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
32 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
34 static int pick_vault_type(floor_type *floor_ptr, vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
36 int tmp, total, count;
38 vault_aux_type *n_ptr;
40 /* Calculate the total possibilities */
41 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
44 if (!n_ptr->name) break;
46 /* Ignore excessive depth */
47 if (n_ptr->level > floor_ptr->dun_level) continue;
49 /* Not matched with pit/nest flag */
50 if (!(allow_flag_mask & (1L << count))) continue;
52 /* Count this possibility */
53 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
56 /* Pick a random type */
57 tmp = randint0(total);
60 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
63 if (!n_ptr->name) break;
65 /* Ignore excessive depth */
66 if (n_ptr->level > floor_ptr->dun_level) continue;
68 /* Not matched with pit/nest flag */
69 if (!(allow_flag_mask & (1L << count))) continue;
71 /* Count this possibility */
72 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
75 if (tmp < total) break;
78 return n_ptr->name ? count : -1;
83 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
84 * @param type pit/nestの型ID
85 * @param nest TRUEならばnest、FALSEならばpit
86 * @return デバッグ表示文字列の参照ポインタ
88 * Hack -- Get the string describing subtype of pit/nest
89 * Determined in prepare function (some pit/nest only)
91 static concptr pit_subtype_string(int type, bool nest)
93 static char inner_buf[256] = "";
95 inner_buf[0] = '\0'; /* Init string */
101 case NEST_TYPE_CLONE:
102 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
104 case NEST_TYPE_SYMBOL_GOOD:
105 case NEST_TYPE_SYMBOL_EVIL:
106 sprintf(inner_buf, "(%c)", vault_aux_char);
114 case PIT_TYPE_SYMBOL_GOOD:
115 case PIT_TYPE_SYMBOL_EVIL:
116 sprintf(inner_buf, "(%c)", vault_aux_char);
118 case PIT_TYPE_DRAGON:
119 switch (vault_aux_dragon_mask4)
121 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
122 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
123 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
124 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
125 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
126 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
127 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
128 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
139 *! @brief nestのモンスターリストをソートするための関数 /
140 * Comp function for sorting nest monster information
141 * @param u ソート処理対象配列ポインタ
147 static bool ang_sort_comp_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
153 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
154 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
155 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
156 monster_race *r1_ptr = &r_info[w1];
157 monster_race *r2_ptr = &r_info[w2];
160 /* Extract used info */
161 z1 = nest_mon_info[a].used;
162 z2 = nest_mon_info[b].used;
164 /* Compare used status */
165 if (z1 < z2) return FALSE;
166 if (z1 > z2) return TRUE;
169 if (r1_ptr->level < r2_ptr->level) return TRUE;
170 if (r1_ptr->level > r2_ptr->level) return FALSE;
172 /* Compare experience */
173 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
174 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
176 /* Compare indexes */
182 * @brief nestのモンスターリストをスワップするための関数 /
183 * Swap function for sorting nest monster information
184 * @param u スワップ処理対象配列ポインタ
186 * @param a スワップ対象参照ID1
187 * @param b スワップ対象参照ID2
190 static void ang_sort_swap_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
196 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
197 nest_mon_info_type holder;
200 holder = nest_mon_info[a];
201 nest_mon_info[a] = nest_mon_info[b];
202 nest_mon_info[b] = holder;
207 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
208 * @param player_ptr プレーヤーへの参照ポインタ
211 * A monster nest is a "big" room, with an "inner" room, containing\n
212 * a "collection" of monsters of a given type strewn about the room.\n
214 * The monsters are chosen from a set of 64 randomly selected monster\n
215 * races, to allow the nest creation to fail instead of having "holes".\n
217 * Note the use of the "get_mon_num_prep()" function, and the special\n
218 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
219 * allocation table" in such a way as to optimize the selection of\n
220 * "appropriate" non-unique monsters for the nest.\n
222 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
223 * case the nest will be empty.\n
225 * Note that "monster nests" will never contain "unique" monsters.\n
227 bool build_type5(player_type *player_ptr)
229 POSITION y, x, y1, x1, y2, x2, xval, yval;
231 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
237 floor_type *floor_ptr = player_ptr->current_floor_ptr;
238 int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
239 vault_aux_type *n_ptr;
241 /* No type available */
242 if (cur_nest_type < 0) return FALSE;
244 n_ptr = &nest_types[cur_nest_type];
246 /* Process a preparation function if necessary */
247 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
248 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
250 align.sub_align = SUB_ALIGN_NEUTRAL;
252 /* Pick some monster types */
253 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
255 MONRACE_IDX r_idx = 0;
257 monster_race *r_ptr = NULL;
261 /* Get a (hard) monster type */
262 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
263 r_ptr = &r_info[r_idx];
265 /* Decline incorrect alignment */
266 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
268 /* Accept this monster */
273 if (!r_idx || !attempts) return FALSE;
275 /* Note the alignment */
276 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
277 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
279 nest_mon_info[i].r_idx = (s16b)r_idx;
280 nest_mon_info[i].used = FALSE;
283 /* Find and reserve some space in the dungeon. Get center of room. */
284 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
292 /* Place the floor area */
293 for (y = y1 - 1; y <= y2 + 1; y++)
295 for (x = x1 - 1; x <= x2 + 1; x++)
297 g_ptr = &floor_ptr->grid_array[y][x];
298 place_grid(player_ptr, g_ptr, GB_FLOOR);
299 g_ptr->info |= (CAVE_ROOM);
303 /* Place the outer walls */
304 for (y = y1 - 1; y <= y2 + 1; y++)
306 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
307 place_grid(player_ptr, g_ptr, GB_OUTER);
308 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
309 place_grid(player_ptr, g_ptr, GB_OUTER);
311 for (x = x1 - 1; x <= x2 + 1; x++)
313 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
314 place_grid(player_ptr, g_ptr, GB_OUTER);
315 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
316 place_grid(player_ptr, g_ptr, GB_OUTER);
320 /* Advance to the center room */
326 /* The inner walls */
327 for (y = y1 - 1; y <= y2 + 1; y++)
329 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
330 place_grid(player_ptr, g_ptr, GB_INNER);
331 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
332 place_grid(player_ptr, g_ptr, GB_INNER);
335 for (x = x1 - 1; x <= x2 + 1; x++)
337 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
338 place_grid(player_ptr, g_ptr, GB_INNER);
339 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
340 place_grid(player_ptr, g_ptr, GB_INNER);
342 for (y = y1; y <= y2; y++)
344 for (x = x1; x <= x2; x++)
346 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
350 /* Place a secret door */
353 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
354 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
355 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
356 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
359 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name,
360 pit_subtype_string(cur_nest_type, TRUE));
362 /* Place some monsters */
363 for (y = yval - 2; y <= yval + 2; y++)
365 for (x = xval - 9; x <= xval + 9; x++)
369 i = randint0(NUM_NEST_MON_TYPE);
370 r_idx = nest_mon_info[i].r_idx;
372 /* Place that "random" monster (no groups) */
373 (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
375 nest_mon_info[i].used = TRUE;
381 ang_sort(player_ptr, nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
383 /* Dump the entries (prevent multi-printing) */
384 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
386 if (!nest_mon_info[i].used) break;
387 for (; i < NUM_NEST_MON_TYPE - 1; i++)
389 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
390 if (!nest_mon_info[i + 1].used) break;
393 msg_format_wizard(player_ptr, CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
402 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
405 * A monster pit is a "big" room, with an "inner" room, containing\n
406 * a "collection" of monsters of a given type organized in the room.\n
408 * The inside room in a monster pit appears as shown below, where the\n
409 * actual monsters in each location depend on the type of the pit\n
411 * XXXXXXXXXXXXXXXXXXXXX\n
412 * X0000000000000000000X\n
413 * X0112233455543322110X\n
414 * X0112233467643322110X\n
415 * X0112233455543322110X\n
416 * X0000000000000000000X\n
417 * XXXXXXXXXXXXXXXXXXXXX\n
419 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
420 * to request 16 "appropriate" monsters, sorting them by level, and using\n
421 * the "even" entries in this sorted list for the contents of the pit.\n
423 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
424 * which is handled by requiring a specific "breath" attack for all of the\n
425 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
426 * be present in many of the dragon pits, if they have the proper breath.\n
428 * Note the use of the "get_mon_num_prep()" function, and the special\n
429 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
430 * allocation table" in such a way as to optimize the selection of\n
431 * "appropriate" non-unique monsters for the pit.\n
433 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
434 * the pit will be empty.\n
436 * Note that "monster pits" will never contain "unique" monsters.\n
438 bool build_type6(player_type *player_ptr)
440 POSITION y, x, y1, x1, y2, x2, xval, yval;
443 MONRACE_IDX what[16];
449 floor_type *floor_ptr = player_ptr->current_floor_ptr;
450 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
451 vault_aux_type *n_ptr;
453 /* No type available */
454 if (cur_pit_type < 0) return FALSE;
456 n_ptr = &pit_types[cur_pit_type];
458 /* Process a preparation function if necessary */
459 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
460 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
462 align.sub_align = SUB_ALIGN_NEUTRAL;
464 /* Pick some monster types */
465 for (i = 0; i < 16; i++)
467 MONRACE_IDX r_idx = 0;
469 monster_race *r_ptr = NULL;
473 /* Get a (hard) monster type */
474 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
475 r_ptr = &r_info[r_idx];
477 /* Decline incorrect alignment */
478 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
480 /* Accept this monster */
485 if (!r_idx || !attempts) return FALSE;
487 /* Note the alignment */
488 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
489 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
494 /* Find and reserve some space in the dungeon. Get center of room. */
495 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
503 /* Place the floor area */
504 for (y = y1 - 1; y <= y2 + 1; y++)
506 for (x = x1 - 1; x <= x2 + 1; x++)
508 g_ptr = &floor_ptr->grid_array[y][x];
509 place_grid(player_ptr, g_ptr, GB_FLOOR);
510 g_ptr->info |= (CAVE_ROOM);
514 /* Place the outer walls */
515 for (y = y1 - 1; y <= y2 + 1; y++)
517 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
518 place_grid(player_ptr, g_ptr, GB_OUTER);
519 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
520 place_grid(player_ptr, g_ptr, GB_OUTER);
522 for (x = x1 - 1; x <= x2 + 1; x++)
524 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
525 place_grid(player_ptr, g_ptr, GB_OUTER);
526 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
527 place_grid(player_ptr, g_ptr, GB_OUTER);
530 /* Advance to the center room */
536 /* The inner walls */
537 for (y = y1 - 1; y <= y2 + 1; y++)
539 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
540 place_grid(player_ptr, g_ptr, GB_INNER);
541 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
542 place_grid(player_ptr, g_ptr, GB_INNER);
544 for (x = x1 - 1; x <= x2 + 1; x++)
546 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
547 place_grid(player_ptr, g_ptr, GB_INNER);
548 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
549 place_grid(player_ptr, g_ptr, GB_INNER);
551 for (y = y1; y <= y2; y++)
553 for (x = x1; x <= x2; x++)
555 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
559 /* Place a secret door */
562 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
563 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
564 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
565 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
568 /* Sort the entries */
569 for (i = 0; i < 16 - 1; i++)
571 /* Sort the entries */
572 for (j = 0; j < 16 - 1; j++)
577 int p1 = r_info[what[i1]].level;
578 int p2 = r_info[what[i2]].level;
583 MONRACE_IDX tmp = what[i1];
590 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name,
591 pit_subtype_string(cur_pit_type, FALSE));
593 /* Select the entries */
594 for (i = 0; i < 8; i++)
596 /* Every other entry */
597 what[i] = what[i * 2];
598 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
601 /* Top and bottom rows */
602 for (x = xval - 9; x <= xval + 9; x++)
604 place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
605 place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
609 for (y = yval - 1; y <= yval + 1; y++)
611 place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
612 place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
614 place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
615 place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
617 place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
618 place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
620 place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
621 place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
623 place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
624 place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
626 place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
627 place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
629 place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
630 place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
632 place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
633 place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
636 /* Above/Below the center monster */
637 for (x = xval - 1; x <= xval + 1; x++)
639 place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
640 place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
643 /* Next to the center monster */
644 place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
645 place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
648 place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
654 * Helper function for "trapped monster pit"
656 static bool vault_aux_trapped_pit(player_type *player_ptr, MONRACE_IDX r_idx)
661 monster_race *r_ptr = &r_info[r_idx];
663 if (!vault_monster_okay(player_ptr, r_idx)) return FALSE;
665 /* No wall passing monster */
666 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
673 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
676 * A trapped monster pit is a "big" room with a straight corridor in\n
677 * which wall opening traps are placed, and with two "inner" rooms\n
678 * containing a "collection" of monsters of a given type organized in\n
681 * The trapped monster pit appears as shown below, where the actual\n
682 * monsters in each location depend on the type of the pit\n
684 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
686 * XXXXXXXXXXXXXXXXXXXXXXX X\n
687 * XXXXX001123454321100XXX X\n
688 * XXX0012234567654322100X X\n
689 * XXXXXXXXXXXXXXXXXXXXXXX X\n
691 * X XXXXXXXXXXXXXXXXXXXXXXX\n
692 * X X0012234567654322100XXX\n
693 * X XXX001123454321100XXXXX\n
694 * X XXXXXXXXXXXXXXXXXXXXXXX\n
696 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
698 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
699 * to request 16 "appropriate" monsters, sorting them by level, and using\n
700 * the "even" entries in this sorted list for the contents of the pit.\n
702 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
703 * which is handled by requiring a specific "breath" attack for all of the\n
704 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
705 * be present in many of the dragon pits, if they have the proper breath.\n
707 * Note the use of the "get_mon_num_prep()" function, and the special\n
708 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
709 * allocation table" in such a way as to optimize the selection of\n
710 * "appropriate" non-unique monsters for the pit.\n
712 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
713 * the pit will be empty.\n
715 * Note that "monster pits" will never contain "unique" monsters.\n
717 bool build_type13(player_type *player_ptr)
719 POSITION y, x, y1, x1, y2, x2, xval, yval;
722 MONRACE_IDX what[16];
728 floor_type *floor_ptr = player_ptr->current_floor_ptr;
729 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
730 vault_aux_type *n_ptr;
732 /* Only in Angband */
733 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
735 /* No type available */
736 if (cur_pit_type < 0) return FALSE;
738 n_ptr = &pit_types[cur_pit_type];
740 /* Process a preparation function if necessary */
741 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
742 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
744 align.sub_align = SUB_ALIGN_NEUTRAL;
746 /* Pick some monster types */
747 for (i = 0; i < 16; i++)
749 MONRACE_IDX r_idx = 0;
751 monster_race *r_ptr = NULL;
755 /* Get a (hard) monster type */
756 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0, 0);
757 r_ptr = &r_info[r_idx];
759 /* Decline incorrect alignment */
760 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
762 /* Accept this monster */
767 if (!r_idx || !attempts) return FALSE;
769 /* Note the alignment */
770 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
771 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
776 /* Find and reserve some space in the dungeon. Get center of room. */
777 if (!find_space(player_ptr, &yval, &xval, 13, 25)) return FALSE;
785 /* Fill with inner walls */
786 for (y = y1 - 1; y <= y2 + 1; y++)
788 for (x = x1 - 1; x <= x2 + 1; x++)
790 g_ptr = &floor_ptr->grid_array[y][x];
791 place_grid(player_ptr, g_ptr, GB_INNER);
792 g_ptr->info |= (CAVE_ROOM);
796 /* Place the floor area 1 */
797 for (x = x1 + 3; x <= x2 - 3; x++)
799 g_ptr = &floor_ptr->grid_array[yval - 2][x];
800 place_grid(player_ptr, g_ptr, GB_FLOOR);
801 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
803 g_ptr = &floor_ptr->grid_array[yval + 2][x];
804 place_grid(player_ptr, g_ptr, GB_FLOOR);
805 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
808 /* Place the floor area 2 */
809 for (x = x1 + 5; x <= x2 - 5; x++)
811 g_ptr = &floor_ptr->grid_array[yval - 3][x];
812 place_grid(player_ptr, g_ptr, GB_FLOOR);
813 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
815 g_ptr = &floor_ptr->grid_array[yval + 3][x];
816 place_grid(player_ptr, g_ptr, GB_FLOOR);
817 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
821 for (x = x1; x <= x2; x++)
823 g_ptr = &floor_ptr->grid_array[yval][x];
824 place_grid(player_ptr, g_ptr, GB_FLOOR);
825 g_ptr = &floor_ptr->grid_array[y1][x];
826 place_grid(player_ptr, g_ptr, GB_FLOOR);
827 g_ptr = &floor_ptr->grid_array[y2][x];
828 place_grid(player_ptr, g_ptr, GB_FLOOR);
831 /* Place the outer walls */
832 for (y = y1 - 1; y <= y2 + 1; y++)
834 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
835 place_grid(player_ptr, g_ptr, GB_OUTER);
836 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
837 place_grid(player_ptr, g_ptr, GB_OUTER);
839 for (x = x1 - 1; x <= x2 + 1; x++)
841 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
842 place_grid(player_ptr, g_ptr, GB_OUTER);
843 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
844 place_grid(player_ptr, g_ptr, GB_OUTER);
847 /* Random corridor */
850 for (y = y1; y <= yval; y++)
852 place_bold(player_ptr, y, x2, GB_FLOOR);
853 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
855 for (y = yval; y <= y2 + 1; y++)
857 place_bold(player_ptr, y, x1, GB_FLOOR);
858 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
863 for (y = yval; y <= y2 + 1; y++)
865 place_bold(player_ptr, y, x1, GB_FLOOR);
866 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
868 for (y = y1; y <= yval; y++)
870 place_bold(player_ptr, y, x2, GB_FLOOR);
871 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
875 /* Place the wall open trap */
876 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
877 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
879 /* Sort the entries */
880 for (i = 0; i < 16 - 1; i++)
882 /* Sort the entries */
883 for (j = 0; j < 16 - 1; j++)
888 int p1 = r_info[what[i1]].level;
889 int p2 = r_info[what[i2]].level;
894 MONRACE_IDX tmp = what[i1];
901 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
902 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
904 /* Select the entries */
905 for (i = 0; i < 8; i++)
907 /* Every other entry */
908 what[i] = what[i * 2];
912 msg_print(r_name + r_info[what[i]].name);
916 for (i = 0; placing[i][2] >= 0; i++)
918 y = yval + placing[i][0];
919 x = xval + placing[i][1];
920 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);