5 #include "floor-generate.h"
7 #include "rooms-pitnest.h"
9 #include "monsterrace-hook.h"
17 #define NUM_NEST_MON_TYPE 64 /*!<nestの種別数 */
19 /*! pit/nest型情報のtypedef */
20 typedef struct vault_aux_type vault_aux_type;
22 /*! pit/nest型情報の構造体定義 */
26 bool(*hook_func)(MONRACE_IDX r_idx);
27 void(*prep_func)(void);
32 /*! nestのID定義 / Nest types code */
33 #define NEST_TYPE_CLONE 0
34 #define NEST_TYPE_JELLY 1
35 #define NEST_TYPE_SYMBOL_GOOD 2
36 #define NEST_TYPE_SYMBOL_EVIL 3
37 #define NEST_TYPE_MIMIC 4
38 #define NEST_TYPE_LOVECRAFTIAN 5
39 #define NEST_TYPE_KENNEL 6
40 #define NEST_TYPE_ANIMAL 7
41 #define NEST_TYPE_CHAPEL 8
42 #define NEST_TYPE_UNDEAD 9
44 /*! pitのID定義 / Pit types code */
45 #define PIT_TYPE_ORC 0
46 #define PIT_TYPE_TROLL 1
47 #define PIT_TYPE_GIANT 2
48 #define PIT_TYPE_LOVECRAFTIAN 3
49 #define PIT_TYPE_SYMBOL_GOOD 4
50 #define PIT_TYPE_SYMBOL_EVIL 5
51 #define PIT_TYPE_CHAPEL 6
52 #define PIT_TYPE_DRAGON 7
53 #define PIT_TYPE_DEMON 8
54 #define PIT_TYPE_DARK_ELF 9
58 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
59 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
60 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
61 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
63 static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
65 int tmp, total, count;
67 vault_aux_type *n_ptr;
69 /* Calculate the total possibilities */
70 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
73 if (!n_ptr->name) break;
75 /* Ignore excessive depth */
76 if (n_ptr->level > p_ptr->current_floor_ptr->dun_level) continue;
78 /* Not matched with pit/nest flag */
79 if (!(allow_flag_mask & (1L << count))) continue;
81 /* Count this possibility */
82 total += n_ptr->chance * MAX_DEPTH / (MIN(p_ptr->current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
85 /* Pick a random type */
86 tmp = randint0(total);
89 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
92 if (!n_ptr->name) break;
94 /* Ignore excessive depth */
95 if (n_ptr->level > p_ptr->current_floor_ptr->dun_level) continue;
97 /* Not matched with pit/nest flag */
98 if (!(allow_flag_mask & (1L << count))) continue;
100 /* Count this possibility */
101 total += n_ptr->chance * MAX_DEPTH / (MIN(p_ptr->current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
104 if (tmp < total) break;
107 return n_ptr->name ? count : -1;
111 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
112 * @param type pit/nestの型ID
113 * @param nest TRUEならばnest、FALSEならばpit
114 * @return デバッグ表示文字列の参照ポインタ
116 * Hack -- Get the string describing subtype of pit/nest
117 * Determined in prepare function (some pit/nest only)
119 static concptr pit_subtype_string(int type, bool nest)
121 static char inner_buf[256] = "";
123 inner_buf[0] = '\0'; /* Init string */
125 if (nest) /* Nests */
129 case NEST_TYPE_CLONE:
130 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
132 case NEST_TYPE_SYMBOL_GOOD:
133 case NEST_TYPE_SYMBOL_EVIL:
134 sprintf(inner_buf, "(%c)", vault_aux_char);
142 case PIT_TYPE_SYMBOL_GOOD:
143 case PIT_TYPE_SYMBOL_EVIL:
144 sprintf(inner_buf, "(%c)", vault_aux_char);
146 case PIT_TYPE_DRAGON:
147 switch (vault_aux_dragon_mask4)
149 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
150 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
151 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
152 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
153 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
154 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
155 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
156 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
166 *! @brief nestのモンスターリストをソートするための関数 /
167 * Comp function for sorting nest monster information
168 * @param u ソート処理対象配列ポインタ
174 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
176 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
177 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
178 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
179 monster_race *r1_ptr = &r_info[w1];
180 monster_race *r2_ptr = &r_info[w2];
186 /* Extract used info */
187 z1 = nest_mon_info[a].used;
188 z2 = nest_mon_info[b].used;
190 /* Compare used status */
191 if (z1 < z2) return FALSE;
192 if (z1 > z2) return TRUE;
195 if (r1_ptr->level < r2_ptr->level) return TRUE;
196 if (r1_ptr->level > r2_ptr->level) return FALSE;
198 /* Compare experience */
199 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
200 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
202 /* Compare indexes */
207 * @brief nestのモンスターリストをスワップするための関数 /
208 * Swap function for sorting nest monster information
209 * @param u スワップ処理対象配列ポインタ
211 * @param a スワップ対象参照ID1
212 * @param b スワップ対象参照ID2
215 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
217 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
218 nest_mon_info_type holder;
224 holder = nest_mon_info[a];
225 nest_mon_info[a] = nest_mon_info[b];
226 nest_mon_info[b] = holder;
232 static vault_aux_type nest_types[] =
234 { _("クローン", "clone"), vault_aux_clone, vault_prep_clone, 5, 3 },
235 { _("ゼリー", "jelly"), vault_aux_jelly, NULL, 5, 6 },
236 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 25, 2 },
237 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 25, 2 },
238 { _("ミミック", "mimic"), vault_aux_mimic, NULL, 30, 4 },
239 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 70, 2 },
240 { _("犬小屋", "kennel"), vault_aux_kennel, NULL, 45, 4 },
241 { _("動物園", "animal"), vault_aux_animal, NULL, 35, 5 },
242 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 75, 4 },
243 { _("アンデッド", "undead"), vault_aux_undead, NULL, 75, 5 },
244 { NULL, NULL, NULL, 0, 0 },
248 static vault_aux_type pit_types[] =
250 { _("オーク", "orc"), vault_aux_orc, NULL, 5, 6 },
251 { _("トロル", "troll"), vault_aux_troll, NULL, 20, 6 },
252 { _("巨人", "giant"), vault_aux_giant, NULL, 50, 6 },
253 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 80, 2 },
254 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 70, 1 },
255 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 70, 1 },
256 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 65, 2 },
257 { _("ドラゴン", "dragon"), vault_aux_dragon, vault_prep_dragon, 70, 6 },
258 { _("デーモン", "demon"), vault_aux_demon, NULL, 80, 6 },
259 { _("ダークエルフ", "dark elf"), vault_aux_dark_elf, NULL, 45, 4 },
260 { NULL, NULL, NULL, 0, 0 },
267 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
270 * A monster nest is a "big" room, with an "inner" room, containing\n
271 * a "collection" of monsters of a given type strewn about the room.\n
273 * The monsters are chosen from a set of 64 randomly selected monster\n
274 * races, to allow the nest creation to fail instead of having "holes".\n
276 * Note the use of the "get_mon_num_prep()" function, and the special\n
277 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
278 * allocation table" in such a way as to optimize the selection of\n
279 * "appropriate" non-unique monsters for the nest.\n
281 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
282 * case the nest will be empty.\n
284 * Note that "monster nests" will never contain "unique" monsters.\n
286 bool build_type5(floor_type *floor_ptr)
288 POSITION y, x, y1, x1, y2, x2, xval, yval;
290 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
296 int cur_nest_type = pick_vault_type(nest_types, d_info[floor_ptr->dungeon_idx].nest);
297 vault_aux_type *n_ptr;
299 /* No type available */
300 if (cur_nest_type < 0) return FALSE;
302 n_ptr = &nest_types[cur_nest_type];
304 /* Process a preparation function if necessary */
305 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
306 get_mon_num_prep(n_ptr->hook_func, NULL);
308 align.sub_align = SUB_ALIGN_NEUTRAL;
310 /* Pick some monster types */
311 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
313 MONRACE_IDX r_idx = 0;
315 monster_race *r_ptr = NULL;
319 /* Get a (hard) monster type */
320 r_idx = get_mon_num(floor_ptr->dun_level + 11);
321 r_ptr = &r_info[r_idx];
323 /* Decline incorrect alignment */
324 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
326 /* Accept this monster */
331 if (!r_idx || !attempts) return FALSE;
333 /* Note the alignment */
334 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
335 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
337 nest_mon_info[i].r_idx = (s16b)r_idx;
338 nest_mon_info[i].used = FALSE;
341 /* Find and reserve some space in the dungeon. Get center of room. */
342 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
350 /* Place the floor area */
351 for (y = y1 - 1; y <= y2 + 1; y++)
353 for (x = x1 - 1; x <= x2 + 1; x++)
355 g_ptr = &floor_ptr->grid_array[y][x];
356 place_floor_grid(g_ptr);
357 g_ptr->info |= (CAVE_ROOM);
361 /* Place the outer walls */
362 for (y = y1 - 1; y <= y2 + 1; y++)
364 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
365 place_outer_grid(g_ptr);
366 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
367 place_outer_grid(g_ptr);
369 for (x = x1 - 1; x <= x2 + 1; x++)
371 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
372 place_outer_grid(g_ptr);
373 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
374 place_outer_grid(g_ptr);
378 /* Advance to the center room */
384 /* The inner walls */
385 for (y = y1 - 1; y <= y2 + 1; y++)
387 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
388 place_inner_grid(g_ptr);
389 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
390 place_inner_grid(g_ptr);
393 for (x = x1 - 1; x <= x2 + 1; x++)
395 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
396 place_inner_grid(g_ptr);
397 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
398 place_inner_grid(g_ptr);
400 for (y = y1; y <= y2; y++)
402 for (x = x1; x <= x2; x++)
404 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
408 /* Place a secret door */
411 case 1: place_secret_door(floor_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
412 case 2: place_secret_door(floor_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
413 case 3: place_secret_door(floor_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
414 case 4: place_secret_door(floor_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
417 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
419 /* Place some monsters */
420 for (y = yval - 2; y <= yval + 2; y++)
422 for (x = xval - 9; x <= xval + 9; x++)
426 i = randint0(NUM_NEST_MON_TYPE);
427 r_idx = nest_mon_info[i].r_idx;
429 /* Place that "random" monster (no groups) */
430 (void)place_monster_aux(0, y, x, r_idx, 0L);
432 nest_mon_info[i].used = TRUE;
438 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
440 /* Dump the entries (prevent multi-printing) */
441 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
443 if (!nest_mon_info[i].used) break;
444 for (; i < NUM_NEST_MON_TYPE - 1; i++)
446 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
447 if (!nest_mon_info[i + 1].used) break;
449 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
458 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
461 * A monster pit is a "big" room, with an "inner" room, containing\n
462 * a "collection" of monsters of a given type organized in the room.\n
464 * The inside room in a monster pit appears as shown below, where the\n
465 * actual monsters in each location depend on the type of the pit\n
467 * XXXXXXXXXXXXXXXXXXXXX\n
468 * X0000000000000000000X\n
469 * X0112233455543322110X\n
470 * X0112233467643322110X\n
471 * X0112233455543322110X\n
472 * X0000000000000000000X\n
473 * XXXXXXXXXXXXXXXXXXXXX\n
475 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
476 * to request 16 "appropriate" monsters, sorting them by level, and using\n
477 * the "even" entries in this sorted list for the contents of the pit.\n
479 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
480 * which is handled by requiring a specific "breath" attack for all of the\n
481 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
482 * be present in many of the dragon pits, if they have the proper breath.\n
484 * Note the use of the "get_mon_num_prep()" function, and the special\n
485 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
486 * allocation table" in such a way as to optimize the selection of\n
487 * "appropriate" non-unique monsters for the pit.\n
489 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
490 * the pit will be empty.\n
492 * Note that "monster pits" will never contain "unique" monsters.\n
494 bool build_type6(floor_type *floor_ptr)
496 POSITION y, x, y1, x1, y2, x2, xval, yval;
499 MONRACE_IDX what[16];
505 int cur_pit_type = pick_vault_type(pit_types, d_info[floor_ptr->dungeon_idx].pit);
506 vault_aux_type *n_ptr;
508 /* No type available */
509 if (cur_pit_type < 0) return FALSE;
511 n_ptr = &pit_types[cur_pit_type];
513 /* Process a preparation function if necessary */
514 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
515 get_mon_num_prep(n_ptr->hook_func, NULL);
517 align.sub_align = SUB_ALIGN_NEUTRAL;
519 /* Pick some monster types */
520 for (i = 0; i < 16; i++)
522 MONRACE_IDX r_idx = 0;
524 monster_race *r_ptr = NULL;
528 /* Get a (hard) monster type */
529 r_idx = get_mon_num(floor_ptr->dun_level + 11);
530 r_ptr = &r_info[r_idx];
532 /* Decline incorrect alignment */
533 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
535 /* Accept this monster */
540 if (!r_idx || !attempts) return FALSE;
542 /* Note the alignment */
543 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
544 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
549 /* Find and reserve some space in the dungeon. Get center of room. */
550 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
558 /* Place the floor area */
559 for (y = y1 - 1; y <= y2 + 1; y++)
561 for (x = x1 - 1; x <= x2 + 1; x++)
563 g_ptr = &floor_ptr->grid_array[y][x];
564 place_floor_grid(g_ptr);
565 g_ptr->info |= (CAVE_ROOM);
569 /* Place the outer walls */
570 for (y = y1 - 1; y <= y2 + 1; y++)
572 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
573 place_outer_grid(g_ptr);
574 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
575 place_outer_grid(g_ptr);
577 for (x = x1 - 1; x <= x2 + 1; x++)
579 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
580 place_outer_grid(g_ptr);
581 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
582 place_outer_grid(g_ptr);
585 /* Advance to the center room */
591 /* The inner walls */
592 for (y = y1 - 1; y <= y2 + 1; y++)
594 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
595 place_inner_grid(g_ptr);
596 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
597 place_inner_grid(g_ptr);
599 for (x = x1 - 1; x <= x2 + 1; x++)
601 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
602 place_inner_grid(g_ptr);
603 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
604 place_inner_grid(g_ptr);
606 for (y = y1; y <= y2; y++)
608 for (x = x1; x <= x2; x++)
610 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
614 /* Place a secret door */
617 case 1: place_secret_door(floor_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
618 case 2: place_secret_door(floor_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
619 case 3: place_secret_door(floor_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
620 case 4: place_secret_door(floor_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
623 /* Sort the entries */
624 for (i = 0; i < 16 - 1; i++)
626 /* Sort the entries */
627 for (j = 0; j < 16 - 1; j++)
632 int p1 = r_info[what[i1]].level;
633 int p2 = r_info[what[i2]].level;
638 MONRACE_IDX tmp = what[i1];
645 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
647 /* Select the entries */
648 for (i = 0; i < 8; i++)
650 /* Every other entry */
651 what[i] = what[i * 2];
652 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
655 /* Top and bottom rows */
656 for (x = xval - 9; x <= xval + 9; x++)
658 place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
659 place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
663 for (y = yval - 1; y <= yval + 1; y++)
665 place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
666 place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
668 place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
669 place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
671 place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
672 place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
674 place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
675 place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
677 place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
678 place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
680 place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
681 place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
683 place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
684 place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
686 place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
687 place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
690 /* Above/Below the center monster */
691 for (x = xval - 1; x <= xval + 1; x++)
693 place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
694 place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
697 /* Next to the center monster */
698 place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
699 place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
702 place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
710 * Helper function for "trapped monster pit"
712 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
714 monster_race *r_ptr = &r_info[r_idx];
716 if (!vault_monster_okay(r_idx)) return (FALSE);
718 /* No wall passing monster */
719 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
726 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
729 * A trapped monster pit is a "big" room with a straight corridor in\n
730 * which wall opening traps are placed, and with two "inner" rooms\n
731 * containing a "collection" of monsters of a given type organized in\n
734 * The trapped monster pit appears as shown below, where the actual\n
735 * monsters in each location depend on the type of the pit\n
737 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
739 * XXXXXXXXXXXXXXXXXXXXXXX X\n
740 * XXXXX001123454321100XXX X\n
741 * XXX0012234567654322100X X\n
742 * XXXXXXXXXXXXXXXXXXXXXXX X\n
744 * X XXXXXXXXXXXXXXXXXXXXXXX\n
745 * X X0012234567654322100XXX\n
746 * X XXX001123454321100XXXXX\n
747 * X XXXXXXXXXXXXXXXXXXXXXXX\n
749 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
751 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
752 * to request 16 "appropriate" monsters, sorting them by level, and using\n
753 * the "even" entries in this sorted list for the contents of the pit.\n
755 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
756 * which is handled by requiring a specific "breath" attack for all of the\n
757 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
758 * be present in many of the dragon pits, if they have the proper breath.\n
760 * Note the use of the "get_mon_num_prep()" function, and the special\n
761 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
762 * allocation table" in such a way as to optimize the selection of\n
763 * "appropriate" non-unique monsters for the pit.\n
765 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
766 * the pit will be empty.\n
768 * Note that "monster pits" will never contain "unique" monsters.\n
770 bool build_type13(floor_type *floor_ptr)
772 static int placing[][3] = {
773 { -2, -9, 0 },{ -2, -8, 0 },{ -3, -7, 0 },{ -3, -6, 0 },
774 { +2, -9, 0 },{ +2, -8, 0 },{ +3, -7, 0 },{ +3, -6, 0 },
775 { -2, +9, 0 },{ -2, +8, 0 },{ -3, +7, 0 },{ -3, +6, 0 },
776 { +2, +9, 0 },{ +2, +8, 0 },{ +3, +7, 0 },{ +3, +6, 0 },
777 { -2, -7, 1 },{ -3, -5, 1 },{ -3, -4, 1 },
778 { +2, -7, 1 },{ +3, -5, 1 },{ +3, -4, 1 },
779 { -2, +7, 1 },{ -3, +5, 1 },{ -3, +4, 1 },
780 { +2, +7, 1 },{ +3, +5, 1 },{ +3, +4, 1 },
781 { -2, -6, 2 },{ -2, -5, 2 },{ -3, -3, 2 },
782 { +2, -6, 2 },{ +2, -5, 2 },{ +3, -3, 2 },
783 { -2, +6, 2 },{ -2, +5, 2 },{ -3, +3, 2 },
784 { +2, +6, 2 },{ +2, +5, 2 },{ +3, +3, 2 },
785 { -2, -4, 3 },{ -3, -2, 3 },
786 { +2, -4, 3 },{ +3, -2, 3 },
787 { -2, +4, 3 },{ -3, +2, 3 },
788 { +2, +4, 3 },{ +3, +2, 3 },
789 { -2, -3, 4 },{ -3, -1, 4 },
790 { +2, -3, 4 },{ +3, -1, 4 },
791 { -2, +3, 4 },{ -3, +1, 4 },
792 { +2, +3, 4 },{ +3, +1, 4 },
793 { -2, -2, 5 },{ -3, 0, 5 },{ -2, +2, 5 },
794 { +2, -2, 5 },{ +3, 0, 5 },{ +2, +2, 5 },
795 { -2, -1, 6 },{ -2, +1, 6 },
796 { +2, -1, 6 },{ +2, +1, 6 },
797 { -2, 0, 7 },{ +2, 0, 7 },
801 POSITION y, x, y1, x1, y2, x2, xval, yval;
804 MONRACE_IDX what[16];
810 int cur_pit_type = pick_vault_type(pit_types, d_info[floor_ptr->dungeon_idx].pit);
811 vault_aux_type *n_ptr;
813 /* Only in Angband */
814 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
816 /* No type available */
817 if (cur_pit_type < 0) return FALSE;
819 n_ptr = &pit_types[cur_pit_type];
821 /* Process a preparation function if necessary */
822 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
823 get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
825 align.sub_align = SUB_ALIGN_NEUTRAL;
827 /* Pick some monster types */
828 for (i = 0; i < 16; i++)
830 MONRACE_IDX r_idx = 0;
832 monster_race *r_ptr = NULL;
836 /* Get a (hard) monster type */
837 r_idx = get_mon_num(floor_ptr->dun_level + 0);
838 r_ptr = &r_info[r_idx];
840 /* Decline incorrect alignment */
841 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
843 /* Accept this monster */
848 if (!r_idx || !attempts) return FALSE;
850 /* Note the alignment */
851 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
852 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
857 /* Find and reserve some space in the dungeon. Get center of room. */
858 if (!find_space(&yval, &xval, 13, 25)) return FALSE;
866 /* Fill with inner walls */
867 for (y = y1 - 1; y <= y2 + 1; y++)
869 for (x = x1 - 1; x <= x2 + 1; x++)
871 g_ptr = &floor_ptr->grid_array[y][x];
872 place_inner_grid(g_ptr);
873 g_ptr->info |= (CAVE_ROOM);
877 /* Place the floor area 1 */
878 for (x = x1 + 3; x <= x2 - 3; x++)
880 g_ptr = &floor_ptr->grid_array[yval - 2][x];
881 place_floor_grid(g_ptr);
882 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
884 g_ptr = &floor_ptr->grid_array[yval + 2][x];
885 place_floor_grid(g_ptr);
886 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
889 /* Place the floor area 2 */
890 for (x = x1 + 5; x <= x2 - 5; x++)
892 g_ptr = &floor_ptr->grid_array[yval - 3][x];
893 place_floor_grid(g_ptr);
894 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
896 g_ptr = &floor_ptr->grid_array[yval + 3][x];
897 place_floor_grid(g_ptr);
898 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
902 for (x = x1; x <= x2; x++)
904 g_ptr = &floor_ptr->grid_array[yval][x];
905 place_floor_grid(g_ptr);
906 g_ptr = &floor_ptr->grid_array[y1][x];
907 place_floor_grid(g_ptr);
908 g_ptr = &floor_ptr->grid_array[y2][x];
909 place_floor_grid(g_ptr);
912 /* Place the outer walls */
913 for (y = y1 - 1; y <= y2 + 1; y++)
915 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
916 place_outer_grid(g_ptr);
917 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
918 place_outer_grid(g_ptr);
920 for (x = x1 - 1; x <= x2 + 1; x++)
922 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
923 place_outer_grid(g_ptr);
924 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
925 place_outer_grid(g_ptr);
928 /* Random corridor */
931 for (y = y1; y <= yval; y++)
933 place_floor_bold(y, x2);
934 place_solid_bold(y, x1 - 1);
936 for (y = yval; y <= y2 + 1; y++)
938 place_floor_bold(y, x1);
939 place_solid_bold(y, x2 + 1);
944 for (y = yval; y <= y2 + 1; y++)
946 place_floor_bold(y, x1);
947 place_solid_bold(y, x2 + 1);
949 for (y = y1; y <= yval; y++)
951 place_floor_bold(y, x2);
952 place_solid_bold(y, x1 - 1);
956 /* Place the wall open trap */
957 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
958 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
960 /* Sort the entries */
961 for (i = 0; i < 16 - 1; i++)
963 /* Sort the entries */
964 for (j = 0; j < 16 - 1; j++)
969 int p1 = r_info[what[i1]].level;
970 int p2 = r_info[what[i2]].level;
975 MONRACE_IDX tmp = what[i1];
982 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
983 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
985 /* Select the entries */
986 for (i = 0; i < 8; i++)
988 /* Every other entry */
989 what[i] = what[i * 2];
993 msg_print(r_name + r_info[what[i]].name);
997 for (i = 0; placing[i][2] >= 0; i++)
999 y = yval + placing[i][0];
1000 x = xval + placing[i][1];
1001 place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);