5 #include "rooms-pitnest.h"
7 #include "monsterrace-hook.h"
12 #define NUM_NEST_MON_TYPE 64 /*!<nestの種別数 */
14 /*! pit/nest型情報のtypedef */
15 typedef struct vault_aux_type vault_aux_type;
17 /*! pit/nest型情報の構造体定義 */
21 bool(*hook_func)(MONRACE_IDX r_idx);
22 void(*prep_func)(void);
27 /*! nestのID定義 / Nest types code */
28 #define NEST_TYPE_CLONE 0
29 #define NEST_TYPE_JELLY 1
30 #define NEST_TYPE_SYMBOL_GOOD 2
31 #define NEST_TYPE_SYMBOL_EVIL 3
32 #define NEST_TYPE_MIMIC 4
33 #define NEST_TYPE_LOVECRAFTIAN 5
34 #define NEST_TYPE_KENNEL 6
35 #define NEST_TYPE_ANIMAL 7
36 #define NEST_TYPE_CHAPEL 8
37 #define NEST_TYPE_UNDEAD 9
39 /*! pitのID定義 / Pit types code */
40 #define PIT_TYPE_ORC 0
41 #define PIT_TYPE_TROLL 1
42 #define PIT_TYPE_GIANT 2
43 #define PIT_TYPE_LOVECRAFTIAN 3
44 #define PIT_TYPE_SYMBOL_GOOD 4
45 #define PIT_TYPE_SYMBOL_EVIL 5
46 #define PIT_TYPE_CHAPEL 6
47 #define PIT_TYPE_DRAGON 7
48 #define PIT_TYPE_DEMON 8
49 #define PIT_TYPE_DARK_ELF 9
53 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
54 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
55 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
56 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
58 static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
60 int tmp, total, count;
62 vault_aux_type *n_ptr;
64 /* Calculate the total possibilities */
65 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
68 if (!n_ptr->name) break;
70 /* Ignore excessive depth */
71 if (n_ptr->level > dun_level) continue;
73 /* Not matched with pit/nest flag */
74 if (!(allow_flag_mask & (1L << count))) continue;
76 /* Count this possibility */
77 total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
80 /* Pick a random type */
81 tmp = randint0(total);
84 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
87 if (!n_ptr->name) break;
89 /* Ignore excessive depth */
90 if (n_ptr->level > dun_level) continue;
92 /* Not matched with pit/nest flag */
93 if (!(allow_flag_mask & (1L << count))) continue;
95 /* Count this possibility */
96 total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
99 if (tmp < total) break;
102 return n_ptr->name ? count : -1;
106 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
107 * @param type pit/nestの型ID
108 * @param nest TRUEならばnest、FALSEならばpit
109 * @return デバッグ表示文字列の参照ポインタ
111 * Hack -- Get the string describing subtype of pit/nest
112 * Determined in prepare function (some pit/nest only)
114 static concptr pit_subtype_string(int type, bool nest)
116 static char inner_buf[256] = "";
118 inner_buf[0] = '\0'; /* Init string */
120 if (nest) /* Nests */
124 case NEST_TYPE_CLONE:
125 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
127 case NEST_TYPE_SYMBOL_GOOD:
128 case NEST_TYPE_SYMBOL_EVIL:
129 sprintf(inner_buf, "(%c)", vault_aux_char);
137 case PIT_TYPE_SYMBOL_GOOD:
138 case PIT_TYPE_SYMBOL_EVIL:
139 sprintf(inner_buf, "(%c)", vault_aux_char);
141 case PIT_TYPE_DRAGON:
142 switch (vault_aux_dragon_mask4)
144 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
145 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
146 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
147 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
148 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
149 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
150 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
151 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
161 *! @brief nestのモンスターリストをソートするための関数 /
162 * Comp function for sorting nest monster information
163 * @param u ソート処理対象配列ポインタ
168 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
170 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
171 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
172 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
173 monster_race *r1_ptr = &r_info[w1];
174 monster_race *r2_ptr = &r_info[w2];
180 /* Extract used info */
181 z1 = nest_mon_info[a].used;
182 z2 = nest_mon_info[b].used;
184 /* Compare used status */
185 if (z1 < z2) return FALSE;
186 if (z1 > z2) return TRUE;
189 if (r1_ptr->level < r2_ptr->level) return TRUE;
190 if (r1_ptr->level > r2_ptr->level) return FALSE;
192 /* Compare experience */
193 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
194 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
196 /* Compare indexes */
201 * @brief nestのモンスターリストをスワップするための関数 /
202 * Swap function for sorting nest monster information
203 * @param u スワップ処理対象配列ポインタ
205 * @param a スワップ対象参照ID1
206 * @param b スワップ対象参照ID2
208 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
210 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
211 nest_mon_info_type holder;
217 holder = nest_mon_info[a];
218 nest_mon_info[a] = nest_mon_info[b];
219 nest_mon_info[b] = holder;
225 static vault_aux_type nest_types[] =
227 { _("クローン", "clone"), vault_aux_clone, vault_prep_clone, 5, 3 },
228 { _("ゼリー", "jelly"), vault_aux_jelly, NULL, 5, 6 },
229 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 25, 2 },
230 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 25, 2 },
231 { _("ミミック", "mimic"), vault_aux_mimic, NULL, 30, 4 },
232 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 70, 2 },
233 { _("犬小屋", "kennel"), vault_aux_kennel, NULL, 45, 4 },
234 { _("動物園", "animal"), vault_aux_animal, NULL, 35, 5 },
235 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 75, 4 },
236 { _("アンデッド", "undead"), vault_aux_undead, NULL, 75, 5 },
237 { NULL, NULL, NULL, 0, 0 },
241 static vault_aux_type pit_types[] =
243 { _("オーク", "orc"), vault_aux_orc, NULL, 5, 6 },
244 { _("トロル", "troll"), vault_aux_troll, NULL, 20, 6 },
245 { _("ジャイアント", "giant"), vault_aux_giant, NULL, 50, 6 },
246 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 80, 2 },
247 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 70, 1 },
248 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 70, 1 },
249 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 65, 2 },
250 { _("ドラゴン", "dragon"), vault_aux_dragon, vault_prep_dragon, 70, 6 },
251 { _("デーモン", "demon"), vault_aux_demon, NULL, 80, 6 },
252 { _("ダークエルフ", "dark elf"), vault_aux_dark_elf, NULL, 45, 4 },
253 { NULL, NULL, NULL, 0, 0 },
260 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
263 * A monster nest is a "big" room, with an "inner" room, containing\n
264 * a "collection" of monsters of a given type strewn about the room.\n
266 * The monsters are chosen from a set of 64 randomly selected monster\n
267 * races, to allow the nest creation to fail instead of having "holes".\n
269 * Note the use of the "get_mon_num_prep()" function, and the special\n
270 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
271 * allocation table" in such a way as to optimize the selection of\n
272 * "appropriate" non-unique monsters for the nest.\n
274 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
275 * case the nest will be empty.\n
277 * Note that "monster nests" will never contain "unique" monsters.\n
279 bool build_type5(void)
281 POSITION y, x, y1, x1, y2, x2, xval, yval;
283 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
289 int cur_nest_type = pick_vault_type(nest_types, d_info[p_ptr->dungeon_idx].nest);
290 vault_aux_type *n_ptr;
292 /* No type available */
293 if (cur_nest_type < 0) return FALSE;
295 n_ptr = &nest_types[cur_nest_type];
297 /* Process a preparation function if necessary */
298 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
299 get_mon_num_prep(n_ptr->hook_func, NULL);
301 align.sub_align = SUB_ALIGN_NEUTRAL;
303 /* Pick some monster types */
304 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
306 MONRACE_IDX r_idx = 0;
308 monster_race *r_ptr = NULL;
312 /* Get a (hard) monster type */
313 r_idx = get_mon_num(dun_level + 11);
314 r_ptr = &r_info[r_idx];
316 /* Decline incorrect alignment */
317 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
319 /* Accept this monster */
324 if (!r_idx || !attempts) return FALSE;
326 /* Note the alignment */
327 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
328 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
330 nest_mon_info[i].r_idx = (s16b)r_idx;
331 nest_mon_info[i].used = FALSE;
334 /* Find and reserve some space in the dungeon. Get center of room. */
335 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
343 /* Place the floor area */
344 for (y = y1 - 1; y <= y2 + 1; y++)
346 for (x = x1 - 1; x <= x2 + 1; x++)
348 g_ptr = ¤t_floor_ptr->grid_array[y][x];
349 place_floor_grid(g_ptr);
350 g_ptr->info |= (CAVE_ROOM);
354 /* Place the outer walls */
355 for (y = y1 - 1; y <= y2 + 1; y++)
357 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
358 place_outer_grid(g_ptr);
359 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
360 place_outer_grid(g_ptr);
362 for (x = x1 - 1; x <= x2 + 1; x++)
364 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
365 place_outer_grid(g_ptr);
366 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
367 place_outer_grid(g_ptr);
371 /* Advance to the center room */
377 /* The inner walls */
378 for (y = y1 - 1; y <= y2 + 1; y++)
380 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
381 place_inner_grid(g_ptr);
382 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
383 place_inner_grid(g_ptr);
386 for (x = x1 - 1; x <= x2 + 1; x++)
388 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
389 place_inner_grid(g_ptr);
390 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
391 place_inner_grid(g_ptr);
393 for (y = y1; y <= y2; y++)
395 for (x = x1; x <= x2; x++)
397 add_cave_info(y, x, CAVE_ICKY);
401 /* Place a secret door */
404 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
405 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
406 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
407 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
410 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
412 /* Place some monsters */
413 for (y = yval - 2; y <= yval + 2; y++)
415 for (x = xval - 9; x <= xval + 9; x++)
419 i = randint0(NUM_NEST_MON_TYPE);
420 r_idx = nest_mon_info[i].r_idx;
422 /* Place that "random" monster (no groups) */
423 (void)place_monster_aux(0, y, x, r_idx, 0L);
425 nest_mon_info[i].used = TRUE;
431 ang_sort_comp = ang_sort_comp_nest_mon_info;
432 ang_sort_swap = ang_sort_swap_nest_mon_info;
433 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE);
435 /* Dump the entries (prevent multi-printing) */
436 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
438 if (!nest_mon_info[i].used) break;
439 for (; i < NUM_NEST_MON_TYPE - 1; i++)
441 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
442 if (!nest_mon_info[i + 1].used) break;
444 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
453 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
456 * A monster pit is a "big" room, with an "inner" room, containing\n
457 * a "collection" of monsters of a given type organized in the room.\n
459 * The inside room in a monster pit appears as shown below, where the\n
460 * actual monsters in each location depend on the type of the pit\n
462 * XXXXXXXXXXXXXXXXXXXXX\n
463 * X0000000000000000000X\n
464 * X0112233455543322110X\n
465 * X0112233467643322110X\n
466 * X0112233455543322110X\n
467 * X0000000000000000000X\n
468 * XXXXXXXXXXXXXXXXXXXXX\n
470 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
471 * to request 16 "appropriate" monsters, sorting them by level, and using\n
472 * the "even" entries in this sorted list for the contents of the pit.\n
474 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
475 * which is handled by requiring a specific "breath" attack for all of the\n
476 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
477 * be present in many of the dragon pits, if they have the proper breath.\n
479 * Note the use of the "get_mon_num_prep()" function, and the special\n
480 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
481 * allocation table" in such a way as to optimize the selection of\n
482 * "appropriate" non-unique monsters for the pit.\n
484 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
485 * the pit will be empty.\n
487 * Note that "monster pits" will never contain "unique" monsters.\n
489 bool build_type6(void)
491 POSITION y, x, y1, x1, y2, x2, xval, yval;
494 MONRACE_IDX what[16];
500 int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
501 vault_aux_type *n_ptr;
503 /* No type available */
504 if (cur_pit_type < 0) return FALSE;
506 n_ptr = &pit_types[cur_pit_type];
508 /* Process a preparation function if necessary */
509 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
510 get_mon_num_prep(n_ptr->hook_func, NULL);
512 align.sub_align = SUB_ALIGN_NEUTRAL;
514 /* Pick some monster types */
515 for (i = 0; i < 16; i++)
517 MONRACE_IDX r_idx = 0;
519 monster_race *r_ptr = NULL;
523 /* Get a (hard) monster type */
524 r_idx = get_mon_num(dun_level + 11);
525 r_ptr = &r_info[r_idx];
527 /* Decline incorrect alignment */
528 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
530 /* Accept this monster */
535 if (!r_idx || !attempts) return FALSE;
537 /* Note the alignment */
538 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
539 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
544 /* Find and reserve some space in the dungeon. Get center of room. */
545 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
553 /* Place the floor area */
554 for (y = y1 - 1; y <= y2 + 1; y++)
556 for (x = x1 - 1; x <= x2 + 1; x++)
558 g_ptr = ¤t_floor_ptr->grid_array[y][x];
559 place_floor_grid(g_ptr);
560 g_ptr->info |= (CAVE_ROOM);
564 /* Place the outer walls */
565 for (y = y1 - 1; y <= y2 + 1; y++)
567 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
568 place_outer_grid(g_ptr);
569 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
570 place_outer_grid(g_ptr);
572 for (x = x1 - 1; x <= x2 + 1; x++)
574 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
575 place_outer_grid(g_ptr);
576 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
577 place_outer_grid(g_ptr);
580 /* Advance to the center room */
586 /* The inner walls */
587 for (y = y1 - 1; y <= y2 + 1; y++)
589 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
590 place_inner_grid(g_ptr);
591 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
592 place_inner_grid(g_ptr);
594 for (x = x1 - 1; x <= x2 + 1; x++)
596 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
597 place_inner_grid(g_ptr);
598 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
599 place_inner_grid(g_ptr);
601 for (y = y1; y <= y2; y++)
603 for (x = x1; x <= x2; x++)
605 add_cave_info(y, x, CAVE_ICKY);
609 /* Place a secret door */
612 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
613 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
614 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
615 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
618 /* Sort the entries */
619 for (i = 0; i < 16 - 1; i++)
621 /* Sort the entries */
622 for (j = 0; j < 16 - 1; j++)
627 int p1 = r_info[what[i1]].level;
628 int p2 = r_info[what[i2]].level;
633 MONRACE_IDX tmp = what[i1];
640 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
642 /* Select the entries */
643 for (i = 0; i < 8; i++)
645 /* Every other entry */
646 what[i] = what[i * 2];
647 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
650 /* Top and bottom rows */
651 for (x = xval - 9; x <= xval + 9; x++)
653 place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
654 place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
658 for (y = yval - 1; y <= yval + 1; y++)
660 place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
661 place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
663 place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
664 place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
666 place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
667 place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
669 place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
670 place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
672 place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
673 place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
675 place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
676 place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
678 place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
679 place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
681 place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
682 place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
685 /* Above/Below the center monster */
686 for (x = xval - 1; x <= xval + 1; x++)
688 place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
689 place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
692 /* Next to the center monster */
693 place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
694 place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
697 place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
705 * Helper function for "trapped monster pit"
707 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
709 monster_race *r_ptr = &r_info[r_idx];
711 if (!vault_monster_okay(r_idx)) return (FALSE);
713 /* No wall passing monster */
714 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
721 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
724 * A trapped monster pit is a "big" room with a straight corridor in\n
725 * which wall opening traps are placed, and with two "inner" rooms\n
726 * containing a "collection" of monsters of a given type organized in\n
729 * The trapped monster pit appears as shown below, where the actual\n
730 * monsters in each location depend on the type of the pit\n
732 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
734 * XXXXXXXXXXXXXXXXXXXXXXX X\n
735 * XXXXX001123454321100XXX X\n
736 * XXX0012234567654322100X X\n
737 * XXXXXXXXXXXXXXXXXXXXXXX X\n
739 * X XXXXXXXXXXXXXXXXXXXXXXX\n
740 * X X0012234567654322100XXX\n
741 * X XXX001123454321100XXXXX\n
742 * X XXXXXXXXXXXXXXXXXXXXXXX\n
744 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
746 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
747 * to request 16 "appropriate" monsters, sorting them by level, and using\n
748 * the "even" entries in this sorted list for the contents of the pit.\n
750 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
751 * which is handled by requiring a specific "breath" attack for all of the\n
752 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
753 * be present in many of the dragon pits, if they have the proper breath.\n
755 * Note the use of the "get_mon_num_prep()" function, and the special\n
756 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
757 * allocation table" in such a way as to optimize the selection of\n
758 * "appropriate" non-unique monsters for the pit.\n
760 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
761 * the pit will be empty.\n
763 * Note that "monster pits" will never contain "unique" monsters.\n
765 bool build_type13(void)
767 static int placing[][3] = {
768 { -2, -9, 0 },{ -2, -8, 0 },{ -3, -7, 0 },{ -3, -6, 0 },
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, -7, 1 },{ -3, -5, 1 },{ -3, -4, 1 },
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, -6, 2 },{ -2, -5, 2 },{ -3, -3, 2 },
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, -4, 3 },{ -3, -2, 3 },
781 { +2, -4, 3 },{ +3, -2, 3 },
782 { -2, +4, 3 },{ -3, +2, 3 },
783 { +2, +4, 3 },{ +3, +2, 3 },
784 { -2, -3, 4 },{ -3, -1, 4 },
785 { +2, -3, 4 },{ +3, -1, 4 },
786 { -2, +3, 4 },{ -3, +1, 4 },
787 { +2, +3, 4 },{ +3, +1, 4 },
788 { -2, -2, 5 },{ -3, 0, 5 },{ -2, +2, 5 },
789 { +2, -2, 5 },{ +3, 0, 5 },{ +2, +2, 5 },
790 { -2, -1, 6 },{ -2, +1, 6 },
791 { +2, -1, 6 },{ +2, +1, 6 },
792 { -2, 0, 7 },{ +2, 0, 7 },
796 POSITION y, x, y1, x1, y2, x2, xval, yval;
799 MONRACE_IDX what[16];
805 int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
806 vault_aux_type *n_ptr;
808 /* Only in Angband */
809 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
811 /* No type available */
812 if (cur_pit_type < 0) return FALSE;
814 n_ptr = &pit_types[cur_pit_type];
816 /* Process a preparation function if necessary */
817 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
818 get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
820 align.sub_align = SUB_ALIGN_NEUTRAL;
822 /* Pick some monster types */
823 for (i = 0; i < 16; i++)
825 MONRACE_IDX r_idx = 0;
827 monster_race *r_ptr = NULL;
831 /* Get a (hard) monster type */
832 r_idx = get_mon_num(dun_level + 0);
833 r_ptr = &r_info[r_idx];
835 /* Decline incorrect alignment */
836 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
838 /* Accept this monster */
843 if (!r_idx || !attempts) return FALSE;
845 /* Note the alignment */
846 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
847 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
852 /* Find and reserve some space in the dungeon. Get center of room. */
853 if (!find_space(&yval, &xval, 13, 25)) return FALSE;
861 /* Fill with inner walls */
862 for (y = y1 - 1; y <= y2 + 1; y++)
864 for (x = x1 - 1; x <= x2 + 1; x++)
866 g_ptr = ¤t_floor_ptr->grid_array[y][x];
867 place_inner_grid(g_ptr);
868 g_ptr->info |= (CAVE_ROOM);
872 /* Place the floor area 1 */
873 for (x = x1 + 3; x <= x2 - 3; x++)
875 g_ptr = ¤t_floor_ptr->grid_array[yval - 2][x];
876 place_floor_grid(g_ptr);
877 add_cave_info(yval - 2, x, CAVE_ICKY);
879 g_ptr = ¤t_floor_ptr->grid_array[yval + 2][x];
880 place_floor_grid(g_ptr);
881 add_cave_info(yval + 2, x, CAVE_ICKY);
884 /* Place the floor area 2 */
885 for (x = x1 + 5; x <= x2 - 5; x++)
887 g_ptr = ¤t_floor_ptr->grid_array[yval - 3][x];
888 place_floor_grid(g_ptr);
889 add_cave_info(yval - 3, x, CAVE_ICKY);
891 g_ptr = ¤t_floor_ptr->grid_array[yval + 3][x];
892 place_floor_grid(g_ptr);
893 add_cave_info(yval + 3, x, CAVE_ICKY);
897 for (x = x1; x <= x2; x++)
899 g_ptr = ¤t_floor_ptr->grid_array[yval][x];
900 place_floor_grid(g_ptr);
901 g_ptr = ¤t_floor_ptr->grid_array[y1][x];
902 place_floor_grid(g_ptr);
903 g_ptr = ¤t_floor_ptr->grid_array[y2][x];
904 place_floor_grid(g_ptr);
907 /* Place the outer walls */
908 for (y = y1 - 1; y <= y2 + 1; y++)
910 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
911 place_outer_grid(g_ptr);
912 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
913 place_outer_grid(g_ptr);
915 for (x = x1 - 1; x <= x2 + 1; x++)
917 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
918 place_outer_grid(g_ptr);
919 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
920 place_outer_grid(g_ptr);
923 /* Random corridor */
926 for (y = y1; y <= yval; y++)
928 place_floor_bold(y, x2);
929 place_solid_bold(y, x1 - 1);
931 for (y = yval; y <= y2 + 1; y++)
933 place_floor_bold(y, x1);
934 place_solid_bold(y, x2 + 1);
939 for (y = yval; y <= y2 + 1; y++)
941 place_floor_bold(y, x1);
942 place_solid_bold(y, x2 + 1);
944 for (y = y1; y <= yval; y++)
946 place_floor_bold(y, x2);
947 place_solid_bold(y, x1 - 1);
951 /* Place the wall open trap */
952 current_floor_ptr->grid_array[yval][xval].mimic = current_floor_ptr->grid_array[yval][xval].feat;
953 current_floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
955 /* Sort the entries */
956 for (i = 0; i < 16 - 1; i++)
958 /* Sort the entries */
959 for (j = 0; j < 16 - 1; j++)
964 int p1 = r_info[what[i1]].level;
965 int p2 = r_info[what[i2]].level;
970 MONRACE_IDX tmp = what[i1];
977 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
978 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
980 /* Select the entries */
981 for (i = 0; i < 8; i++)
983 /* Every other entry */
984 what[i] = what[i * 2];
988 msg_print(r_name + r_info[what[i]].name);
992 for (i = 0; placing[i][2] >= 0; i++)
994 y = yval + placing[i][0];
995 x = xval + placing[i][1];
996 place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);