1 #include "room/rooms-pit-nest.h"
2 #include "dungeon/dungeon.h"
3 #include "floor/floor-generator.h"
4 #include "game-option/cheat-options.h"
5 #include "game-option/cheat-types.h"
7 #include "grid/feature.h"
9 #include "monster-floor/monster-generator.h"
10 #include "monster-floor/place-monster-types.h"
11 #include "monster-race/monster-race-hook.h"
12 #include "monster-race/monster-race.h"
13 #include "monster-race/race-flags-resistance.h"
14 #include "monster-race/race-flags1.h"
15 #include "monster-race/race-flags2.h"
16 #include "monster-race/race-flags3.h"
17 #include "monster-race/race-flags4.h"
18 #include "monster-race/race-flags7.h"
19 #include "monster/monster-info.h"
20 #include "monster/monster-list.h"
21 #include "monster/monster-util.h"
22 #include "room/pit-nest-kinds-table.h"
23 #include "room/space-finder.h"
24 #include "system/floor-type-definition.h"
25 #include "util/sort.h"
26 #include "view/display-messages.h"
27 #include "wizard/wizard-messages.h"
30 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
31 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
32 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
33 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
35 static int pick_vault_type(floor_type *floor_ptr, vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
37 int tmp, total, count;
39 vault_aux_type *n_ptr;
41 /* Calculate the total possibilities */
42 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
45 if (!n_ptr->name) break;
47 /* Ignore excessive depth */
48 if (n_ptr->level > floor_ptr->dun_level) continue;
50 /* Not matched with pit/nest flag */
51 if (!(allow_flag_mask & (1L << count))) continue;
53 /* Count this possibility */
54 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
57 /* Pick a random type */
58 tmp = randint0(total);
61 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
64 if (!n_ptr->name) break;
66 /* Ignore excessive depth */
67 if (n_ptr->level > floor_ptr->dun_level) continue;
69 /* Not matched with pit/nest flag */
70 if (!(allow_flag_mask & (1L << count))) continue;
72 /* Count this possibility */
73 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
76 if (tmp < total) break;
79 return n_ptr->name ? count : -1;
84 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
85 * @param type pit/nestの型ID
86 * @param nest TRUEならばnest、FALSEならばpit
87 * @return デバッグ表示文字列の参照ポインタ
89 * Hack -- Get the string describing subtype of pit/nest
90 * Determined in prepare function (some pit/nest only)
92 static concptr pit_subtype_string(int type, bool nest)
94 static char inner_buf[256] = "";
96 inner_buf[0] = '\0'; /* Init string */
102 case NEST_TYPE_CLONE:
103 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
105 case NEST_TYPE_SYMBOL_GOOD:
106 case NEST_TYPE_SYMBOL_EVIL:
107 sprintf(inner_buf, "(%c)", vault_aux_char);
115 case PIT_TYPE_SYMBOL_GOOD:
116 case PIT_TYPE_SYMBOL_EVIL:
117 sprintf(inner_buf, "(%c)", vault_aux_char);
119 case PIT_TYPE_DRAGON:
120 switch (vault_aux_dragon_mask4)
122 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
123 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
124 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
125 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
126 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
127 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
128 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
129 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
140 *! @brief nestのモンスターリストをソートするための関数 /
141 * Comp function for sorting nest monster information
142 * @param u ソート処理対象配列ポインタ
148 static bool ang_sort_comp_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
154 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
155 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
156 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
157 monster_race *r1_ptr = &r_info[w1];
158 monster_race *r2_ptr = &r_info[w2];
161 /* Extract used info */
162 z1 = nest_mon_info[a].used;
163 z2 = nest_mon_info[b].used;
165 /* Compare used status */
166 if (z1 < z2) return FALSE;
167 if (z1 > z2) return TRUE;
170 if (r1_ptr->level < r2_ptr->level) return TRUE;
171 if (r1_ptr->level > r2_ptr->level) return FALSE;
173 /* Compare experience */
174 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
175 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
177 /* Compare indexes */
183 * @brief nestのモンスターリストをスワップするための関数 /
184 * Swap function for sorting nest monster information
185 * @param u スワップ処理対象配列ポインタ
187 * @param a スワップ対象参照ID1
188 * @param b スワップ対象参照ID2
191 static void ang_sort_swap_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
197 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
198 nest_mon_info_type holder;
201 holder = nest_mon_info[a];
202 nest_mon_info[a] = nest_mon_info[b];
203 nest_mon_info[b] = holder;
208 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
209 * @param player_ptr プレーヤーへの参照ポインタ
212 * A monster nest is a "big" room, with an "inner" room, containing\n
213 * a "collection" of monsters of a given type strewn about the room.\n
215 * The monsters are chosen from a set of 64 randomly selected monster\n
216 * races, to allow the nest creation to fail instead of having "holes".\n
218 * Note the use of the "get_mon_num_prep()" function, and the special\n
219 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
220 * allocation table" in such a way as to optimize the selection of\n
221 * "appropriate" non-unique monsters for the nest.\n
223 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
224 * case the nest will be empty.\n
226 * Note that "monster nests" will never contain "unique" monsters.\n
228 bool build_type5(player_type *player_ptr, dun_data_type *dd_ptr)
230 POSITION y, x, y1, x1, y2, x2, xval, yval;
232 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
238 floor_type *floor_ptr = player_ptr->current_floor_ptr;
239 int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
240 vault_aux_type *n_ptr;
242 /* No type available */
243 if (cur_nest_type < 0) return FALSE;
245 n_ptr = &nest_types[cur_nest_type];
247 /* Process a preparation function if necessary */
248 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
249 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
251 align.sub_align = SUB_ALIGN_NEUTRAL;
253 /* Pick some monster types */
254 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
256 MONRACE_IDX r_idx = 0;
258 monster_race *r_ptr = NULL;
262 /* Get a (hard) monster type */
263 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
264 r_ptr = &r_info[r_idx];
266 /* Decline incorrect alignment */
267 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
269 /* Accept this monster */
274 if (!r_idx || !attempts) return FALSE;
276 /* Note the alignment */
277 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
278 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
280 nest_mon_info[i].r_idx = (s16b)r_idx;
281 nest_mon_info[i].used = FALSE;
284 /* Find and reserve some space in the dungeon. Get center of room. */
285 if (!find_space(player_ptr, dd_ptr, &yval, &xval, 11, 25)) return FALSE;
293 /* Place the floor area */
294 for (y = y1 - 1; y <= y2 + 1; y++)
296 for (x = x1 - 1; x <= x2 + 1; x++)
298 g_ptr = &floor_ptr->grid_array[y][x];
299 place_grid(player_ptr, g_ptr, GB_FLOOR);
300 g_ptr->info |= (CAVE_ROOM);
304 /* Place the outer walls */
305 for (y = y1 - 1; y <= y2 + 1; y++)
307 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
308 place_grid(player_ptr, g_ptr, GB_OUTER);
309 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
310 place_grid(player_ptr, g_ptr, GB_OUTER);
312 for (x = x1 - 1; x <= x2 + 1; x++)
314 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
315 place_grid(player_ptr, g_ptr, GB_OUTER);
316 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
317 place_grid(player_ptr, g_ptr, GB_OUTER);
321 /* Advance to the center room */
327 /* The inner walls */
328 for (y = y1 - 1; y <= y2 + 1; y++)
330 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
331 place_grid(player_ptr, g_ptr, GB_INNER);
332 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
333 place_grid(player_ptr, g_ptr, GB_INNER);
336 for (x = x1 - 1; x <= x2 + 1; x++)
338 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
339 place_grid(player_ptr, g_ptr, GB_INNER);
340 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
341 place_grid(player_ptr, g_ptr, GB_INNER);
343 for (y = y1; y <= y2; y++)
345 for (x = x1; x <= x2; x++)
347 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
351 /* Place a secret door */
354 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
355 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
356 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
357 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
360 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name,
361 pit_subtype_string(cur_nest_type, TRUE));
363 /* Place some monsters */
364 for (y = yval - 2; y <= yval + 2; y++)
366 for (x = xval - 9; x <= xval + 9; x++)
370 i = randint0(NUM_NEST_MON_TYPE);
371 r_idx = nest_mon_info[i].r_idx;
373 /* Place that "random" monster (no groups) */
374 (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
376 nest_mon_info[i].used = TRUE;
382 ang_sort(player_ptr, nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
384 /* Dump the entries (prevent multi-printing) */
385 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
387 if (!nest_mon_info[i].used) break;
388 for (; i < NUM_NEST_MON_TYPE - 1; i++)
390 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
391 if (!nest_mon_info[i + 1].used) break;
394 msg_format_wizard(player_ptr, CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
403 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
406 * A monster pit is a "big" room, with an "inner" room, containing\n
407 * a "collection" of monsters of a given type organized in the room.\n
409 * The inside room in a monster pit appears as shown below, where the\n
410 * actual monsters in each location depend on the type of the pit\n
412 * XXXXXXXXXXXXXXXXXXXXX\n
413 * X0000000000000000000X\n
414 * X0112233455543322110X\n
415 * X0112233467643322110X\n
416 * X0112233455543322110X\n
417 * X0000000000000000000X\n
418 * XXXXXXXXXXXXXXXXXXXXX\n
420 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
421 * to request 16 "appropriate" monsters, sorting them by level, and using\n
422 * the "even" entries in this sorted list for the contents of the pit.\n
424 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
425 * which is handled by requiring a specific "breath" attack for all of the\n
426 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
427 * be present in many of the dragon pits, if they have the proper breath.\n
429 * Note the use of the "get_mon_num_prep()" function, and the special\n
430 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
431 * allocation table" in such a way as to optimize the selection of\n
432 * "appropriate" non-unique monsters for the pit.\n
434 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
435 * the pit will be empty.\n
437 * Note that "monster pits" will never contain "unique" monsters.\n
439 bool build_type6(player_type *player_ptr, dun_data_type *dd_ptr)
441 POSITION y, x, y1, x1, y2, x2, xval, yval;
444 MONRACE_IDX what[16];
450 floor_type *floor_ptr = player_ptr->current_floor_ptr;
451 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
452 vault_aux_type *n_ptr;
454 /* No type available */
455 if (cur_pit_type < 0) return FALSE;
457 n_ptr = &pit_types[cur_pit_type];
459 /* Process a preparation function if necessary */
460 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
461 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
463 align.sub_align = SUB_ALIGN_NEUTRAL;
465 /* Pick some monster types */
466 for (i = 0; i < 16; i++)
468 MONRACE_IDX r_idx = 0;
470 monster_race *r_ptr = NULL;
474 /* Get a (hard) monster type */
475 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
476 r_ptr = &r_info[r_idx];
478 /* Decline incorrect alignment */
479 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
481 /* Accept this monster */
486 if (!r_idx || !attempts) return FALSE;
488 /* Note the alignment */
489 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
490 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
495 /* Find and reserve some space in the dungeon. Get center of room. */
496 if (!find_space(player_ptr, dd_ptr, &yval, &xval, 11, 25)) return FALSE;
504 /* Place the floor area */
505 for (y = y1 - 1; y <= y2 + 1; y++)
507 for (x = x1 - 1; x <= x2 + 1; x++)
509 g_ptr = &floor_ptr->grid_array[y][x];
510 place_grid(player_ptr, g_ptr, GB_FLOOR);
511 g_ptr->info |= (CAVE_ROOM);
515 /* Place the outer walls */
516 for (y = y1 - 1; y <= y2 + 1; y++)
518 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
519 place_grid(player_ptr, g_ptr, GB_OUTER);
520 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
521 place_grid(player_ptr, g_ptr, GB_OUTER);
523 for (x = x1 - 1; x <= x2 + 1; x++)
525 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
526 place_grid(player_ptr, g_ptr, GB_OUTER);
527 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
528 place_grid(player_ptr, g_ptr, GB_OUTER);
531 /* Advance to the center room */
537 /* The inner walls */
538 for (y = y1 - 1; y <= y2 + 1; y++)
540 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
541 place_grid(player_ptr, g_ptr, GB_INNER);
542 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
543 place_grid(player_ptr, g_ptr, GB_INNER);
545 for (x = x1 - 1; x <= x2 + 1; x++)
547 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
548 place_grid(player_ptr, g_ptr, GB_INNER);
549 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
550 place_grid(player_ptr, g_ptr, GB_INNER);
552 for (y = y1; y <= y2; y++)
554 for (x = x1; x <= x2; x++)
556 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
560 /* Place a secret door */
563 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
564 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
565 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
566 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
569 /* Sort the entries */
570 for (i = 0; i < 16 - 1; i++)
572 /* Sort the entries */
573 for (j = 0; j < 16 - 1; j++)
578 int p1 = r_info[what[i1]].level;
579 int p2 = r_info[what[i2]].level;
584 MONRACE_IDX tmp = what[i1];
591 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name,
592 pit_subtype_string(cur_pit_type, FALSE));
594 /* Select the entries */
595 for (i = 0; i < 8; i++)
597 /* Every other entry */
598 what[i] = what[i * 2];
599 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);
602 /* Top and bottom rows */
603 for (x = xval - 9; x <= xval + 9; x++)
605 place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
606 place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
610 for (y = yval - 1; y <= yval + 1; y++)
612 place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
613 place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
615 place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
616 place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
618 place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
619 place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
621 place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
622 place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
624 place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
625 place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
627 place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
628 place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
630 place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
631 place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
633 place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
634 place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
637 /* Above/Below the center monster */
638 for (x = xval - 1; x <= xval + 1; x++)
640 place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
641 place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
644 /* Next to the center monster */
645 place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
646 place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
649 place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
655 * Helper function for "trapped monster pit"
657 static bool vault_aux_trapped_pit(player_type *player_ptr, MONRACE_IDX r_idx)
662 monster_race *r_ptr = &r_info[r_idx];
664 if (!vault_monster_okay(player_ptr, r_idx)) return FALSE;
666 /* No wall passing monster */
667 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
674 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
677 * A trapped monster pit is a "big" room with a straight corridor in\n
678 * which wall opening traps are placed, and with two "inner" rooms\n
679 * containing a "collection" of monsters of a given type organized in\n
682 * The trapped monster pit appears as shown below, where the actual\n
683 * monsters in each location depend on the type of the pit\n
685 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
687 * XXXXXXXXXXXXXXXXXXXXXXX X\n
688 * XXXXX001123454321100XXX X\n
689 * XXX0012234567654322100X X\n
690 * XXXXXXXXXXXXXXXXXXXXXXX X\n
692 * X XXXXXXXXXXXXXXXXXXXXXXX\n
693 * X X0012234567654322100XXX\n
694 * X XXX001123454321100XXXXX\n
695 * X XXXXXXXXXXXXXXXXXXXXXXX\n
697 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
699 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
700 * to request 16 "appropriate" monsters, sorting them by level, and using\n
701 * the "even" entries in this sorted list for the contents of the pit.\n
703 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
704 * which is handled by requiring a specific "breath" attack for all of the\n
705 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
706 * be present in many of the dragon pits, if they have the proper breath.\n
708 * Note the use of the "get_mon_num_prep()" function, and the special\n
709 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
710 * allocation table" in such a way as to optimize the selection of\n
711 * "appropriate" non-unique monsters for the pit.\n
713 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
714 * the pit will be empty.\n
716 * Note that "monster pits" will never contain "unique" monsters.\n
718 bool build_type13(player_type *player_ptr, dun_data_type *dd_ptr)
720 POSITION y, x, y1, x1, y2, x2, xval, yval;
723 MONRACE_IDX what[16];
729 floor_type *floor_ptr = player_ptr->current_floor_ptr;
730 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
731 vault_aux_type *n_ptr;
733 /* Only in Angband */
734 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
736 /* No type available */
737 if (cur_pit_type < 0) return FALSE;
739 n_ptr = &pit_types[cur_pit_type];
741 /* Process a preparation function if necessary */
742 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
743 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
745 align.sub_align = SUB_ALIGN_NEUTRAL;
747 /* Pick some monster types */
748 for (i = 0; i < 16; i++)
750 MONRACE_IDX r_idx = 0;
752 monster_race *r_ptr = NULL;
756 /* Get a (hard) monster type */
757 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0, 0);
758 r_ptr = &r_info[r_idx];
760 /* Decline incorrect alignment */
761 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
763 /* Accept this monster */
768 if (!r_idx || !attempts) return FALSE;
770 /* Note the alignment */
771 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
772 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
777 /* Find and reserve some space in the dungeon. Get center of room. */
778 if (!find_space(player_ptr, dd_ptr, &yval, &xval, 13, 25)) return FALSE;
786 /* Fill with inner walls */
787 for (y = y1 - 1; y <= y2 + 1; y++)
789 for (x = x1 - 1; x <= x2 + 1; x++)
791 g_ptr = &floor_ptr->grid_array[y][x];
792 place_grid(player_ptr, g_ptr, GB_INNER);
793 g_ptr->info |= (CAVE_ROOM);
797 /* Place the floor area 1 */
798 for (x = x1 + 3; x <= x2 - 3; x++)
800 g_ptr = &floor_ptr->grid_array[yval - 2][x];
801 place_grid(player_ptr, g_ptr, GB_FLOOR);
802 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
804 g_ptr = &floor_ptr->grid_array[yval + 2][x];
805 place_grid(player_ptr, g_ptr, GB_FLOOR);
806 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
809 /* Place the floor area 2 */
810 for (x = x1 + 5; x <= x2 - 5; x++)
812 g_ptr = &floor_ptr->grid_array[yval - 3][x];
813 place_grid(player_ptr, g_ptr, GB_FLOOR);
814 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
816 g_ptr = &floor_ptr->grid_array[yval + 3][x];
817 place_grid(player_ptr, g_ptr, GB_FLOOR);
818 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
822 for (x = x1; x <= x2; x++)
824 g_ptr = &floor_ptr->grid_array[yval][x];
825 place_grid(player_ptr, g_ptr, GB_FLOOR);
826 g_ptr = &floor_ptr->grid_array[y1][x];
827 place_grid(player_ptr, g_ptr, GB_FLOOR);
828 g_ptr = &floor_ptr->grid_array[y2][x];
829 place_grid(player_ptr, g_ptr, GB_FLOOR);
832 /* Place the outer walls */
833 for (y = y1 - 1; y <= y2 + 1; y++)
835 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
836 place_grid(player_ptr, g_ptr, GB_OUTER);
837 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
838 place_grid(player_ptr, g_ptr, GB_OUTER);
840 for (x = x1 - 1; x <= x2 + 1; x++)
842 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
843 place_grid(player_ptr, g_ptr, GB_OUTER);
844 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
845 place_grid(player_ptr, g_ptr, GB_OUTER);
848 /* Random corridor */
851 for (y = y1; y <= yval; y++)
853 place_bold(player_ptr, y, x2, GB_FLOOR);
854 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
856 for (y = yval; y <= y2 + 1; y++)
858 place_bold(player_ptr, y, x1, GB_FLOOR);
859 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
864 for (y = yval; y <= y2 + 1; y++)
866 place_bold(player_ptr, y, x1, GB_FLOOR);
867 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
869 for (y = y1; y <= yval; y++)
871 place_bold(player_ptr, y, x2, GB_FLOOR);
872 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
876 /* Place the wall open trap */
877 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
878 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
880 /* Sort the entries */
881 for (i = 0; i < 16 - 1; i++)
883 /* Sort the entries */
884 for (j = 0; j < 16 - 1; j++)
889 int p1 = r_info[what[i1]].level;
890 int p2 = r_info[what[i2]].level;
895 MONRACE_IDX tmp = what[i1];
902 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
903 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
905 /* Select the entries */
906 for (i = 0; i < 8; i++)
908 /* Every other entry */
909 what[i] = what[i * 2];
913 msg_print(r_name + r_info[what[i]].name);
917 for (i = 0; placing[i][2] >= 0; i++)
919 y = yval + placing[i][0];
920 x = xval + placing[i][1];
921 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);