3 #include "floor-generate.h"
5 #include "rooms-pitnest.h"
7 #include "monsterrace-hook.h"
13 #define NUM_NEST_MON_TYPE 64 /*!<nestの種別数 */
15 /*! pit/nest型情報のtypedef */
16 typedef struct vault_aux_type vault_aux_type;
18 /*! pit/nest型情報の構造体定義 */
22 bool(*hook_func)(MONRACE_IDX r_idx);
23 void(*prep_func)(void);
28 /*! nestのID定義 / Nest types code */
29 #define NEST_TYPE_CLONE 0
30 #define NEST_TYPE_JELLY 1
31 #define NEST_TYPE_SYMBOL_GOOD 2
32 #define NEST_TYPE_SYMBOL_EVIL 3
33 #define NEST_TYPE_MIMIC 4
34 #define NEST_TYPE_LOVECRAFTIAN 5
35 #define NEST_TYPE_KENNEL 6
36 #define NEST_TYPE_ANIMAL 7
37 #define NEST_TYPE_CHAPEL 8
38 #define NEST_TYPE_UNDEAD 9
40 /*! pitのID定義 / Pit types code */
41 #define PIT_TYPE_ORC 0
42 #define PIT_TYPE_TROLL 1
43 #define PIT_TYPE_GIANT 2
44 #define PIT_TYPE_LOVECRAFTIAN 3
45 #define PIT_TYPE_SYMBOL_GOOD 4
46 #define PIT_TYPE_SYMBOL_EVIL 5
47 #define PIT_TYPE_CHAPEL 6
48 #define PIT_TYPE_DRAGON 7
49 #define PIT_TYPE_DEMON 8
50 #define PIT_TYPE_DARK_ELF 9
54 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
55 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
56 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
57 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
59 static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
61 int tmp, total, count;
63 vault_aux_type *n_ptr;
65 /* Calculate the total possibilities */
66 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
69 if (!n_ptr->name) break;
71 /* Ignore excessive depth */
72 if (n_ptr->level > current_floor_ptr->dun_level) continue;
74 /* Not matched with pit/nest flag */
75 if (!(allow_flag_mask & (1L << count))) continue;
77 /* Count this possibility */
78 total += n_ptr->chance * MAX_DEPTH / (MIN(current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
81 /* Pick a random type */
82 tmp = randint0(total);
85 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
88 if (!n_ptr->name) break;
90 /* Ignore excessive depth */
91 if (n_ptr->level > current_floor_ptr->dun_level) continue;
93 /* Not matched with pit/nest flag */
94 if (!(allow_flag_mask & (1L << count))) continue;
96 /* Count this possibility */
97 total += n_ptr->chance * MAX_DEPTH / (MIN(current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
100 if (tmp < total) break;
103 return n_ptr->name ? count : -1;
107 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
108 * @param type pit/nestの型ID
109 * @param nest TRUEならばnest、FALSEならばpit
110 * @return デバッグ表示文字列の参照ポインタ
112 * Hack -- Get the string describing subtype of pit/nest
113 * Determined in prepare function (some pit/nest only)
115 static concptr pit_subtype_string(int type, bool nest)
117 static char inner_buf[256] = "";
119 inner_buf[0] = '\0'; /* Init string */
121 if (nest) /* Nests */
125 case NEST_TYPE_CLONE:
126 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
128 case NEST_TYPE_SYMBOL_GOOD:
129 case NEST_TYPE_SYMBOL_EVIL:
130 sprintf(inner_buf, "(%c)", vault_aux_char);
138 case PIT_TYPE_SYMBOL_GOOD:
139 case PIT_TYPE_SYMBOL_EVIL:
140 sprintf(inner_buf, "(%c)", vault_aux_char);
142 case PIT_TYPE_DRAGON:
143 switch (vault_aux_dragon_mask4)
145 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
146 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
147 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
148 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
149 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
150 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
151 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
152 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
162 *! @brief nestのモンスターリストをソートするための関数 /
163 * Comp function for sorting nest monster information
164 * @param u ソート処理対象配列ポインタ
170 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
172 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
173 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
174 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
175 monster_race *r1_ptr = &r_info[w1];
176 monster_race *r2_ptr = &r_info[w2];
182 /* Extract used info */
183 z1 = nest_mon_info[a].used;
184 z2 = nest_mon_info[b].used;
186 /* Compare used status */
187 if (z1 < z2) return FALSE;
188 if (z1 > z2) return TRUE;
191 if (r1_ptr->level < r2_ptr->level) return TRUE;
192 if (r1_ptr->level > r2_ptr->level) return FALSE;
194 /* Compare experience */
195 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
196 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
198 /* Compare indexes */
203 * @brief nestのモンスターリストをスワップするための関数 /
204 * Swap function for sorting nest monster information
205 * @param u スワップ処理対象配列ポインタ
207 * @param a スワップ対象参照ID1
208 * @param b スワップ対象参照ID2
211 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
213 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
214 nest_mon_info_type holder;
220 holder = nest_mon_info[a];
221 nest_mon_info[a] = nest_mon_info[b];
222 nest_mon_info[b] = holder;
228 static vault_aux_type nest_types[] =
230 { _("クローン", "clone"), vault_aux_clone, vault_prep_clone, 5, 3 },
231 { _("ゼリー", "jelly"), vault_aux_jelly, NULL, 5, 6 },
232 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 25, 2 },
233 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 25, 2 },
234 { _("ミミック", "mimic"), vault_aux_mimic, NULL, 30, 4 },
235 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 70, 2 },
236 { _("犬小屋", "kennel"), vault_aux_kennel, NULL, 45, 4 },
237 { _("動物園", "animal"), vault_aux_animal, NULL, 35, 5 },
238 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 75, 4 },
239 { _("アンデッド", "undead"), vault_aux_undead, NULL, 75, 5 },
240 { NULL, NULL, NULL, 0, 0 },
244 static vault_aux_type pit_types[] =
246 { _("オーク", "orc"), vault_aux_orc, NULL, 5, 6 },
247 { _("トロル", "troll"), vault_aux_troll, NULL, 20, 6 },
248 { _("ジャイアント", "giant"), vault_aux_giant, NULL, 50, 6 },
249 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 80, 2 },
250 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 70, 1 },
251 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 70, 1 },
252 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 65, 2 },
253 { _("ドラゴン", "dragon"), vault_aux_dragon, vault_prep_dragon, 70, 6 },
254 { _("デーモン", "demon"), vault_aux_demon, NULL, 80, 6 },
255 { _("ダークエルフ", "dark elf"), vault_aux_dark_elf, NULL, 45, 4 },
256 { NULL, NULL, NULL, 0, 0 },
263 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
266 * A monster nest is a "big" room, with an "inner" room, containing\n
267 * a "collection" of monsters of a given type strewn about the room.\n
269 * The monsters are chosen from a set of 64 randomly selected monster\n
270 * races, to allow the nest creation to fail instead of having "holes".\n
272 * Note the use of the "get_mon_num_prep()" function, and the special\n
273 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
274 * allocation table" in such a way as to optimize the selection of\n
275 * "appropriate" non-unique monsters for the nest.\n
277 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
278 * case the nest will be empty.\n
280 * Note that "monster nests" will never contain "unique" monsters.\n
282 bool build_type5(void)
284 POSITION y, x, y1, x1, y2, x2, xval, yval;
286 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
292 int cur_nest_type = pick_vault_type(nest_types, d_info[p_ptr->dungeon_idx].nest);
293 vault_aux_type *n_ptr;
295 /* No type available */
296 if (cur_nest_type < 0) return FALSE;
298 n_ptr = &nest_types[cur_nest_type];
300 /* Process a preparation function if necessary */
301 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
302 get_mon_num_prep(n_ptr->hook_func, NULL);
304 align.sub_align = SUB_ALIGN_NEUTRAL;
306 /* Pick some monster types */
307 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
309 MONRACE_IDX r_idx = 0;
311 monster_race *r_ptr = NULL;
315 /* Get a (hard) monster type */
316 r_idx = get_mon_num(current_floor_ptr->dun_level + 11);
317 r_ptr = &r_info[r_idx];
319 /* Decline incorrect alignment */
320 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
322 /* Accept this monster */
327 if (!r_idx || !attempts) return FALSE;
329 /* Note the alignment */
330 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
331 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
333 nest_mon_info[i].r_idx = (s16b)r_idx;
334 nest_mon_info[i].used = FALSE;
337 /* Find and reserve some space in the dungeon. Get center of room. */
338 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
346 /* Place the floor area */
347 for (y = y1 - 1; y <= y2 + 1; y++)
349 for (x = x1 - 1; x <= x2 + 1; x++)
351 g_ptr = ¤t_floor_ptr->grid_array[y][x];
352 place_floor_grid(g_ptr);
353 g_ptr->info |= (CAVE_ROOM);
357 /* Place the outer walls */
358 for (y = y1 - 1; y <= y2 + 1; y++)
360 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
361 place_outer_grid(g_ptr);
362 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
363 place_outer_grid(g_ptr);
365 for (x = x1 - 1; x <= x2 + 1; x++)
367 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
368 place_outer_grid(g_ptr);
369 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
370 place_outer_grid(g_ptr);
374 /* Advance to the center room */
380 /* The inner walls */
381 for (y = y1 - 1; y <= y2 + 1; y++)
383 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
384 place_inner_grid(g_ptr);
385 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
386 place_inner_grid(g_ptr);
389 for (x = x1 - 1; x <= x2 + 1; x++)
391 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
392 place_inner_grid(g_ptr);
393 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
394 place_inner_grid(g_ptr);
396 for (y = y1; y <= y2; y++)
398 for (x = x1; x <= x2; x++)
400 add_cave_info(y, x, CAVE_ICKY);
404 /* Place a secret door */
407 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
408 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
409 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
410 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
413 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
415 /* Place some monsters */
416 for (y = yval - 2; y <= yval + 2; y++)
418 for (x = xval - 9; x <= xval + 9; x++)
422 i = randint0(NUM_NEST_MON_TYPE);
423 r_idx = nest_mon_info[i].r_idx;
425 /* Place that "random" monster (no groups) */
426 (void)place_monster_aux(0, y, x, r_idx, 0L);
428 nest_mon_info[i].used = TRUE;
434 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
436 /* Dump the entries (prevent multi-printing) */
437 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
439 if (!nest_mon_info[i].used) break;
440 for (; i < NUM_NEST_MON_TYPE - 1; i++)
442 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
443 if (!nest_mon_info[i + 1].used) break;
445 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
454 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
457 * A monster pit is a "big" room, with an "inner" room, containing\n
458 * a "collection" of monsters of a given type organized in the room.\n
460 * The inside room in a monster pit appears as shown below, where the\n
461 * actual monsters in each location depend on the type of the pit\n
463 * XXXXXXXXXXXXXXXXXXXXX\n
464 * X0000000000000000000X\n
465 * X0112233455543322110X\n
466 * X0112233467643322110X\n
467 * X0112233455543322110X\n
468 * X0000000000000000000X\n
469 * XXXXXXXXXXXXXXXXXXXXX\n
471 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
472 * to request 16 "appropriate" monsters, sorting them by level, and using\n
473 * the "even" entries in this sorted list for the contents of the pit.\n
475 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
476 * which is handled by requiring a specific "breath" attack for all of the\n
477 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
478 * be present in many of the dragon pits, if they have the proper breath.\n
480 * Note the use of the "get_mon_num_prep()" function, and the special\n
481 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
482 * allocation table" in such a way as to optimize the selection of\n
483 * "appropriate" non-unique monsters for the pit.\n
485 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
486 * the pit will be empty.\n
488 * Note that "monster pits" will never contain "unique" monsters.\n
490 bool build_type6(void)
492 POSITION y, x, y1, x1, y2, x2, xval, yval;
495 MONRACE_IDX what[16];
501 int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
502 vault_aux_type *n_ptr;
504 /* No type available */
505 if (cur_pit_type < 0) return FALSE;
507 n_ptr = &pit_types[cur_pit_type];
509 /* Process a preparation function if necessary */
510 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
511 get_mon_num_prep(n_ptr->hook_func, NULL);
513 align.sub_align = SUB_ALIGN_NEUTRAL;
515 /* Pick some monster types */
516 for (i = 0; i < 16; i++)
518 MONRACE_IDX r_idx = 0;
520 monster_race *r_ptr = NULL;
524 /* Get a (hard) monster type */
525 r_idx = get_mon_num(current_floor_ptr->dun_level + 11);
526 r_ptr = &r_info[r_idx];
528 /* Decline incorrect alignment */
529 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
531 /* Accept this monster */
536 if (!r_idx || !attempts) return FALSE;
538 /* Note the alignment */
539 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
540 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
545 /* Find and reserve some space in the dungeon. Get center of room. */
546 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
554 /* Place the floor area */
555 for (y = y1 - 1; y <= y2 + 1; y++)
557 for (x = x1 - 1; x <= x2 + 1; x++)
559 g_ptr = ¤t_floor_ptr->grid_array[y][x];
560 place_floor_grid(g_ptr);
561 g_ptr->info |= (CAVE_ROOM);
565 /* Place the outer walls */
566 for (y = y1 - 1; y <= y2 + 1; y++)
568 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
569 place_outer_grid(g_ptr);
570 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
571 place_outer_grid(g_ptr);
573 for (x = x1 - 1; x <= x2 + 1; x++)
575 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
576 place_outer_grid(g_ptr);
577 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
578 place_outer_grid(g_ptr);
581 /* Advance to the center room */
587 /* The inner walls */
588 for (y = y1 - 1; y <= y2 + 1; y++)
590 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
591 place_inner_grid(g_ptr);
592 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
593 place_inner_grid(g_ptr);
595 for (x = x1 - 1; x <= x2 + 1; x++)
597 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
598 place_inner_grid(g_ptr);
599 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
600 place_inner_grid(g_ptr);
602 for (y = y1; y <= y2; y++)
604 for (x = x1; x <= x2; x++)
606 add_cave_info(y, x, CAVE_ICKY);
610 /* Place a secret door */
613 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
614 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
615 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
616 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
619 /* Sort the entries */
620 for (i = 0; i < 16 - 1; i++)
622 /* Sort the entries */
623 for (j = 0; j < 16 - 1; j++)
628 int p1 = r_info[what[i1]].level;
629 int p2 = r_info[what[i2]].level;
634 MONRACE_IDX tmp = what[i1];
641 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
643 /* Select the entries */
644 for (i = 0; i < 8; i++)
646 /* Every other entry */
647 what[i] = what[i * 2];
648 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
651 /* Top and bottom rows */
652 for (x = xval - 9; x <= xval + 9; x++)
654 place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
655 place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
659 for (y = yval - 1; y <= yval + 1; y++)
661 place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
662 place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
664 place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
665 place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
667 place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
668 place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
670 place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
671 place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
673 place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
674 place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
676 place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
677 place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
679 place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
680 place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
682 place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
683 place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
686 /* Above/Below the center monster */
687 for (x = xval - 1; x <= xval + 1; x++)
689 place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
690 place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
693 /* Next to the center monster */
694 place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
695 place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
698 place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
706 * Helper function for "trapped monster pit"
708 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
710 monster_race *r_ptr = &r_info[r_idx];
712 if (!vault_monster_okay(r_idx)) return (FALSE);
714 /* No wall passing monster */
715 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
722 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
725 * A trapped monster pit is a "big" room with a straight corridor in\n
726 * which wall opening traps are placed, and with two "inner" rooms\n
727 * containing a "collection" of monsters of a given type organized in\n
730 * The trapped monster pit appears as shown below, where the actual\n
731 * monsters in each location depend on the type of the pit\n
733 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
735 * XXXXXXXXXXXXXXXXXXXXXXX X\n
736 * XXXXX001123454321100XXX X\n
737 * XXX0012234567654322100X X\n
738 * XXXXXXXXXXXXXXXXXXXXXXX X\n
740 * X XXXXXXXXXXXXXXXXXXXXXXX\n
741 * X X0012234567654322100XXX\n
742 * X XXX001123454321100XXXXX\n
743 * X XXXXXXXXXXXXXXXXXXXXXXX\n
745 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
747 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
748 * to request 16 "appropriate" monsters, sorting them by level, and using\n
749 * the "even" entries in this sorted list for the contents of the pit.\n
751 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
752 * which is handled by requiring a specific "breath" attack for all of the\n
753 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
754 * be present in many of the dragon pits, if they have the proper breath.\n
756 * Note the use of the "get_mon_num_prep()" function, and the special\n
757 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
758 * allocation table" in such a way as to optimize the selection of\n
759 * "appropriate" non-unique monsters for the pit.\n
761 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
762 * the pit will be empty.\n
764 * Note that "monster pits" will never contain "unique" monsters.\n
766 bool build_type13(void)
768 static int placing[][3] = {
769 { -2, -9, 0 },{ -2, -8, 0 },{ -3, -7, 0 },{ -3, -6, 0 },
770 { +2, -9, 0 },{ +2, -8, 0 },{ +3, -7, 0 },{ +3, -6, 0 },
771 { -2, +9, 0 },{ -2, +8, 0 },{ -3, +7, 0 },{ -3, +6, 0 },
772 { +2, +9, 0 },{ +2, +8, 0 },{ +3, +7, 0 },{ +3, +6, 0 },
773 { -2, -7, 1 },{ -3, -5, 1 },{ -3, -4, 1 },
774 { +2, -7, 1 },{ +3, -5, 1 },{ +3, -4, 1 },
775 { -2, +7, 1 },{ -3, +5, 1 },{ -3, +4, 1 },
776 { +2, +7, 1 },{ +3, +5, 1 },{ +3, +4, 1 },
777 { -2, -6, 2 },{ -2, -5, 2 },{ -3, -3, 2 },
778 { +2, -6, 2 },{ +2, -5, 2 },{ +3, -3, 2 },
779 { -2, +6, 2 },{ -2, +5, 2 },{ -3, +3, 2 },
780 { +2, +6, 2 },{ +2, +5, 2 },{ +3, +3, 2 },
781 { -2, -4, 3 },{ -3, -2, 3 },
782 { +2, -4, 3 },{ +3, -2, 3 },
783 { -2, +4, 3 },{ -3, +2, 3 },
784 { +2, +4, 3 },{ +3, +2, 3 },
785 { -2, -3, 4 },{ -3, -1, 4 },
786 { +2, -3, 4 },{ +3, -1, 4 },
787 { -2, +3, 4 },{ -3, +1, 4 },
788 { +2, +3, 4 },{ +3, +1, 4 },
789 { -2, -2, 5 },{ -3, 0, 5 },{ -2, +2, 5 },
790 { +2, -2, 5 },{ +3, 0, 5 },{ +2, +2, 5 },
791 { -2, -1, 6 },{ -2, +1, 6 },
792 { +2, -1, 6 },{ +2, +1, 6 },
793 { -2, 0, 7 },{ +2, 0, 7 },
797 POSITION y, x, y1, x1, y2, x2, xval, yval;
800 MONRACE_IDX what[16];
806 int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
807 vault_aux_type *n_ptr;
809 /* Only in Angband */
810 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
812 /* No type available */
813 if (cur_pit_type < 0) return FALSE;
815 n_ptr = &pit_types[cur_pit_type];
817 /* Process a preparation function if necessary */
818 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
819 get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
821 align.sub_align = SUB_ALIGN_NEUTRAL;
823 /* Pick some monster types */
824 for (i = 0; i < 16; i++)
826 MONRACE_IDX r_idx = 0;
828 monster_race *r_ptr = NULL;
832 /* Get a (hard) monster type */
833 r_idx = get_mon_num(current_floor_ptr->dun_level + 0);
834 r_ptr = &r_info[r_idx];
836 /* Decline incorrect alignment */
837 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
839 /* Accept this monster */
844 if (!r_idx || !attempts) return FALSE;
846 /* Note the alignment */
847 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
848 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
853 /* Find and reserve some space in the dungeon. Get center of room. */
854 if (!find_space(&yval, &xval, 13, 25)) return FALSE;
862 /* Fill with inner walls */
863 for (y = y1 - 1; y <= y2 + 1; y++)
865 for (x = x1 - 1; x <= x2 + 1; x++)
867 g_ptr = ¤t_floor_ptr->grid_array[y][x];
868 place_inner_grid(g_ptr);
869 g_ptr->info |= (CAVE_ROOM);
873 /* Place the floor area 1 */
874 for (x = x1 + 3; x <= x2 - 3; x++)
876 g_ptr = ¤t_floor_ptr->grid_array[yval - 2][x];
877 place_floor_grid(g_ptr);
878 add_cave_info(yval - 2, x, CAVE_ICKY);
880 g_ptr = ¤t_floor_ptr->grid_array[yval + 2][x];
881 place_floor_grid(g_ptr);
882 add_cave_info(yval + 2, x, CAVE_ICKY);
885 /* Place the floor area 2 */
886 for (x = x1 + 5; x <= x2 - 5; x++)
888 g_ptr = ¤t_floor_ptr->grid_array[yval - 3][x];
889 place_floor_grid(g_ptr);
890 add_cave_info(yval - 3, x, CAVE_ICKY);
892 g_ptr = ¤t_floor_ptr->grid_array[yval + 3][x];
893 place_floor_grid(g_ptr);
894 add_cave_info(yval + 3, x, CAVE_ICKY);
898 for (x = x1; x <= x2; x++)
900 g_ptr = ¤t_floor_ptr->grid_array[yval][x];
901 place_floor_grid(g_ptr);
902 g_ptr = ¤t_floor_ptr->grid_array[y1][x];
903 place_floor_grid(g_ptr);
904 g_ptr = ¤t_floor_ptr->grid_array[y2][x];
905 place_floor_grid(g_ptr);
908 /* Place the outer walls */
909 for (y = y1 - 1; y <= y2 + 1; y++)
911 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
912 place_outer_grid(g_ptr);
913 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
914 place_outer_grid(g_ptr);
916 for (x = x1 - 1; x <= x2 + 1; x++)
918 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
919 place_outer_grid(g_ptr);
920 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
921 place_outer_grid(g_ptr);
924 /* Random corridor */
927 for (y = y1; y <= yval; y++)
929 place_floor_bold(y, x2);
930 place_solid_bold(y, x1 - 1);
932 for (y = yval; y <= y2 + 1; y++)
934 place_floor_bold(y, x1);
935 place_solid_bold(y, x2 + 1);
940 for (y = yval; y <= y2 + 1; y++)
942 place_floor_bold(y, x1);
943 place_solid_bold(y, x2 + 1);
945 for (y = y1; y <= yval; y++)
947 place_floor_bold(y, x2);
948 place_solid_bold(y, x1 - 1);
952 /* Place the wall open trap */
953 current_floor_ptr->grid_array[yval][xval].mimic = current_floor_ptr->grid_array[yval][xval].feat;
954 current_floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
956 /* Sort the entries */
957 for (i = 0; i < 16 - 1; i++)
959 /* Sort the entries */
960 for (j = 0; j < 16 - 1; j++)
965 int p1 = r_info[what[i1]].level;
966 int p2 = r_info[what[i2]].level;
971 MONRACE_IDX tmp = what[i1];
978 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
979 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
981 /* Select the entries */
982 for (i = 0; i < 8; i++)
984 /* Every other entry */
985 what[i] = what[i * 2];
989 msg_print(r_name + r_info[what[i]].name);
993 for (i = 0; placing[i][2] >= 0; i++)
995 y = yval + placing[i][0];
996 x = xval + placing[i][1];
997 place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);