5 #include "floor-generate.h"
7 #include "rooms-pitnest.h"
9 #include "monsterrace-hook.h"
15 #define NUM_NEST_MON_TYPE 64 /*!<nestの種別数 */
17 /*! pit/nest型情報のtypedef */
18 typedef struct vault_aux_type vault_aux_type;
20 /*! pit/nest型情報の構造体定義 */
24 bool(*hook_func)(MONRACE_IDX r_idx);
25 void(*prep_func)(void);
30 /*! nestのID定義 / Nest types code */
31 #define NEST_TYPE_CLONE 0
32 #define NEST_TYPE_JELLY 1
33 #define NEST_TYPE_SYMBOL_GOOD 2
34 #define NEST_TYPE_SYMBOL_EVIL 3
35 #define NEST_TYPE_MIMIC 4
36 #define NEST_TYPE_LOVECRAFTIAN 5
37 #define NEST_TYPE_KENNEL 6
38 #define NEST_TYPE_ANIMAL 7
39 #define NEST_TYPE_CHAPEL 8
40 #define NEST_TYPE_UNDEAD 9
42 /*! pitのID定義 / Pit types code */
43 #define PIT_TYPE_ORC 0
44 #define PIT_TYPE_TROLL 1
45 #define PIT_TYPE_GIANT 2
46 #define PIT_TYPE_LOVECRAFTIAN 3
47 #define PIT_TYPE_SYMBOL_GOOD 4
48 #define PIT_TYPE_SYMBOL_EVIL 5
49 #define PIT_TYPE_CHAPEL 6
50 #define PIT_TYPE_DRAGON 7
51 #define PIT_TYPE_DEMON 8
52 #define PIT_TYPE_DARK_ELF 9
56 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
57 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
58 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
59 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
61 static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
63 int tmp, total, count;
65 vault_aux_type *n_ptr;
67 /* Calculate the total possibilities */
68 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
71 if (!n_ptr->name) break;
73 /* Ignore excessive depth */
74 if (n_ptr->level > current_floor_ptr->dun_level) continue;
76 /* Not matched with pit/nest flag */
77 if (!(allow_flag_mask & (1L << count))) continue;
79 /* Count this possibility */
80 total += n_ptr->chance * MAX_DEPTH / (MIN(current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
83 /* Pick a random type */
84 tmp = randint0(total);
87 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
90 if (!n_ptr->name) break;
92 /* Ignore excessive depth */
93 if (n_ptr->level > current_floor_ptr->dun_level) continue;
95 /* Not matched with pit/nest flag */
96 if (!(allow_flag_mask & (1L << count))) continue;
98 /* Count this possibility */
99 total += n_ptr->chance * MAX_DEPTH / (MIN(current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
102 if (tmp < total) break;
105 return n_ptr->name ? count : -1;
109 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
110 * @param type pit/nestの型ID
111 * @param nest TRUEならばnest、FALSEならばpit
112 * @return デバッグ表示文字列の参照ポインタ
114 * Hack -- Get the string describing subtype of pit/nest
115 * Determined in prepare function (some pit/nest only)
117 static concptr pit_subtype_string(int type, bool nest)
119 static char inner_buf[256] = "";
121 inner_buf[0] = '\0'; /* Init string */
123 if (nest) /* Nests */
127 case NEST_TYPE_CLONE:
128 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
130 case NEST_TYPE_SYMBOL_GOOD:
131 case NEST_TYPE_SYMBOL_EVIL:
132 sprintf(inner_buf, "(%c)", vault_aux_char);
140 case PIT_TYPE_SYMBOL_GOOD:
141 case PIT_TYPE_SYMBOL_EVIL:
142 sprintf(inner_buf, "(%c)", vault_aux_char);
144 case PIT_TYPE_DRAGON:
145 switch (vault_aux_dragon_mask4)
147 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
148 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
149 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
150 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
151 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
152 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
153 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
154 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
164 *! @brief nestのモンスターリストをソートするための関数 /
165 * Comp function for sorting nest monster information
166 * @param u ソート処理対象配列ポインタ
172 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
174 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
175 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
176 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
177 monster_race *r1_ptr = &r_info[w1];
178 monster_race *r2_ptr = &r_info[w2];
184 /* Extract used info */
185 z1 = nest_mon_info[a].used;
186 z2 = nest_mon_info[b].used;
188 /* Compare used status */
189 if (z1 < z2) return FALSE;
190 if (z1 > z2) return TRUE;
193 if (r1_ptr->level < r2_ptr->level) return TRUE;
194 if (r1_ptr->level > r2_ptr->level) return FALSE;
196 /* Compare experience */
197 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
198 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
200 /* Compare indexes */
205 * @brief nestのモンスターリストをスワップするための関数 /
206 * Swap function for sorting nest monster information
207 * @param u スワップ処理対象配列ポインタ
209 * @param a スワップ対象参照ID1
210 * @param b スワップ対象参照ID2
213 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
215 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
216 nest_mon_info_type holder;
222 holder = nest_mon_info[a];
223 nest_mon_info[a] = nest_mon_info[b];
224 nest_mon_info[b] = holder;
230 static vault_aux_type nest_types[] =
232 { _("クローン", "clone"), vault_aux_clone, vault_prep_clone, 5, 3 },
233 { _("ゼリー", "jelly"), vault_aux_jelly, NULL, 5, 6 },
234 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 25, 2 },
235 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 25, 2 },
236 { _("ミミック", "mimic"), vault_aux_mimic, NULL, 30, 4 },
237 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 70, 2 },
238 { _("犬小屋", "kennel"), vault_aux_kennel, NULL, 45, 4 },
239 { _("動物園", "animal"), vault_aux_animal, NULL, 35, 5 },
240 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 75, 4 },
241 { _("アンデッド", "undead"), vault_aux_undead, NULL, 75, 5 },
242 { NULL, NULL, NULL, 0, 0 },
246 static vault_aux_type pit_types[] =
248 { _("オーク", "orc"), vault_aux_orc, NULL, 5, 6 },
249 { _("トロル", "troll"), vault_aux_troll, NULL, 20, 6 },
250 { _("ジャイアント", "giant"), vault_aux_giant, NULL, 50, 6 },
251 { _("狂気", "lovecraftian"), vault_aux_cthulhu, NULL, 80, 2 },
252 { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 70, 1 },
253 { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 70, 1 },
254 { _("教会", "chapel"), vault_aux_chapel_g, NULL, 65, 2 },
255 { _("ドラゴン", "dragon"), vault_aux_dragon, vault_prep_dragon, 70, 6 },
256 { _("デーモン", "demon"), vault_aux_demon, NULL, 80, 6 },
257 { _("ダークエルフ", "dark elf"), vault_aux_dark_elf, NULL, 45, 4 },
258 { NULL, NULL, NULL, 0, 0 },
265 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
268 * A monster nest is a "big" room, with an "inner" room, containing\n
269 * a "collection" of monsters of a given type strewn about the room.\n
271 * The monsters are chosen from a set of 64 randomly selected monster\n
272 * races, to allow the nest creation to fail instead of having "holes".\n
274 * Note the use of the "get_mon_num_prep()" function, and the special\n
275 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
276 * allocation table" in such a way as to optimize the selection of\n
277 * "appropriate" non-unique monsters for the nest.\n
279 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
280 * case the nest will be empty.\n
282 * Note that "monster nests" will never contain "unique" monsters.\n
284 bool build_type5(void)
286 POSITION y, x, y1, x1, y2, x2, xval, yval;
288 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
294 int cur_nest_type = pick_vault_type(nest_types, d_info[p_ptr->dungeon_idx].nest);
295 vault_aux_type *n_ptr;
297 /* No type available */
298 if (cur_nest_type < 0) return FALSE;
300 n_ptr = &nest_types[cur_nest_type];
302 /* Process a preparation function if necessary */
303 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
304 get_mon_num_prep(n_ptr->hook_func, NULL);
306 align.sub_align = SUB_ALIGN_NEUTRAL;
308 /* Pick some monster types */
309 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
311 MONRACE_IDX r_idx = 0;
313 monster_race *r_ptr = NULL;
317 /* Get a (hard) monster type */
318 r_idx = get_mon_num(current_floor_ptr->dun_level + 11);
319 r_ptr = &r_info[r_idx];
321 /* Decline incorrect alignment */
322 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
324 /* Accept this monster */
329 if (!r_idx || !attempts) return FALSE;
331 /* Note the alignment */
332 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
333 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
335 nest_mon_info[i].r_idx = (s16b)r_idx;
336 nest_mon_info[i].used = FALSE;
339 /* Find and reserve some space in the dungeon. Get center of room. */
340 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
348 /* Place the floor area */
349 for (y = y1 - 1; y <= y2 + 1; y++)
351 for (x = x1 - 1; x <= x2 + 1; x++)
353 g_ptr = ¤t_floor_ptr->grid_array[y][x];
354 place_floor_grid(g_ptr);
355 g_ptr->info |= (CAVE_ROOM);
359 /* Place the outer walls */
360 for (y = y1 - 1; y <= y2 + 1; y++)
362 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
363 place_outer_grid(g_ptr);
364 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
365 place_outer_grid(g_ptr);
367 for (x = x1 - 1; x <= x2 + 1; x++)
369 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
370 place_outer_grid(g_ptr);
371 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
372 place_outer_grid(g_ptr);
376 /* Advance to the center room */
382 /* The inner walls */
383 for (y = y1 - 1; y <= y2 + 1; y++)
385 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
386 place_inner_grid(g_ptr);
387 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
388 place_inner_grid(g_ptr);
391 for (x = x1 - 1; x <= x2 + 1; x++)
393 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
394 place_inner_grid(g_ptr);
395 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
396 place_inner_grid(g_ptr);
398 for (y = y1; y <= y2; y++)
400 for (x = x1; x <= x2; x++)
402 add_cave_info(y, x, CAVE_ICKY);
406 /* Place a secret door */
409 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
410 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
411 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
412 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
415 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
417 /* Place some monsters */
418 for (y = yval - 2; y <= yval + 2; y++)
420 for (x = xval - 9; x <= xval + 9; x++)
424 i = randint0(NUM_NEST_MON_TYPE);
425 r_idx = nest_mon_info[i].r_idx;
427 /* Place that "random" monster (no groups) */
428 (void)place_monster_aux(0, y, x, r_idx, 0L);
430 nest_mon_info[i].used = TRUE;
436 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
438 /* Dump the entries (prevent multi-printing) */
439 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
441 if (!nest_mon_info[i].used) break;
442 for (; i < NUM_NEST_MON_TYPE - 1; i++)
444 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
445 if (!nest_mon_info[i + 1].used) break;
447 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
456 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
459 * A monster pit is a "big" room, with an "inner" room, containing\n
460 * a "collection" of monsters of a given type organized in the room.\n
462 * The inside room in a monster pit appears as shown below, where the\n
463 * actual monsters in each location depend on the type of the pit\n
465 * XXXXXXXXXXXXXXXXXXXXX\n
466 * X0000000000000000000X\n
467 * X0112233455543322110X\n
468 * X0112233467643322110X\n
469 * X0112233455543322110X\n
470 * X0000000000000000000X\n
471 * XXXXXXXXXXXXXXXXXXXXX\n
473 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
474 * to request 16 "appropriate" monsters, sorting them by level, and using\n
475 * the "even" entries in this sorted list for the contents of the pit.\n
477 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
478 * which is handled by requiring a specific "breath" attack for all of the\n
479 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
480 * be present in many of the dragon pits, if they have the proper breath.\n
482 * Note the use of the "get_mon_num_prep()" function, and the special\n
483 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
484 * allocation table" in such a way as to optimize the selection of\n
485 * "appropriate" non-unique monsters for the pit.\n
487 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
488 * the pit will be empty.\n
490 * Note that "monster pits" will never contain "unique" monsters.\n
492 bool build_type6(void)
494 POSITION y, x, y1, x1, y2, x2, xval, yval;
497 MONRACE_IDX what[16];
503 int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
504 vault_aux_type *n_ptr;
506 /* No type available */
507 if (cur_pit_type < 0) return FALSE;
509 n_ptr = &pit_types[cur_pit_type];
511 /* Process a preparation function if necessary */
512 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
513 get_mon_num_prep(n_ptr->hook_func, NULL);
515 align.sub_align = SUB_ALIGN_NEUTRAL;
517 /* Pick some monster types */
518 for (i = 0; i < 16; i++)
520 MONRACE_IDX r_idx = 0;
522 monster_race *r_ptr = NULL;
526 /* Get a (hard) monster type */
527 r_idx = get_mon_num(current_floor_ptr->dun_level + 11);
528 r_ptr = &r_info[r_idx];
530 /* Decline incorrect alignment */
531 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
533 /* Accept this monster */
538 if (!r_idx || !attempts) return FALSE;
540 /* Note the alignment */
541 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
542 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
547 /* Find and reserve some space in the dungeon. Get center of room. */
548 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
556 /* Place the floor area */
557 for (y = y1 - 1; y <= y2 + 1; y++)
559 for (x = x1 - 1; x <= x2 + 1; x++)
561 g_ptr = ¤t_floor_ptr->grid_array[y][x];
562 place_floor_grid(g_ptr);
563 g_ptr->info |= (CAVE_ROOM);
567 /* Place the outer walls */
568 for (y = y1 - 1; y <= y2 + 1; y++)
570 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
571 place_outer_grid(g_ptr);
572 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
573 place_outer_grid(g_ptr);
575 for (x = x1 - 1; x <= x2 + 1; x++)
577 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
578 place_outer_grid(g_ptr);
579 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
580 place_outer_grid(g_ptr);
583 /* Advance to the center room */
589 /* The inner walls */
590 for (y = y1 - 1; y <= y2 + 1; y++)
592 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
593 place_inner_grid(g_ptr);
594 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
595 place_inner_grid(g_ptr);
597 for (x = x1 - 1; x <= x2 + 1; x++)
599 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
600 place_inner_grid(g_ptr);
601 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
602 place_inner_grid(g_ptr);
604 for (y = y1; y <= y2; y++)
606 for (x = x1; x <= x2; x++)
608 add_cave_info(y, x, CAVE_ICKY);
612 /* Place a secret door */
615 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
616 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
617 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
618 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
621 /* Sort the entries */
622 for (i = 0; i < 16 - 1; i++)
624 /* Sort the entries */
625 for (j = 0; j < 16 - 1; j++)
630 int p1 = r_info[what[i1]].level;
631 int p2 = r_info[what[i2]].level;
636 MONRACE_IDX tmp = what[i1];
643 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
645 /* Select the entries */
646 for (i = 0; i < 8; i++)
648 /* Every other entry */
649 what[i] = what[i * 2];
650 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
653 /* Top and bottom rows */
654 for (x = xval - 9; x <= xval + 9; x++)
656 place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
657 place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
661 for (y = yval - 1; y <= yval + 1; y++)
663 place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
664 place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
666 place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
667 place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
669 place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
670 place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
672 place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
673 place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
675 place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
676 place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
678 place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
679 place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
681 place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
682 place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
684 place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
685 place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
688 /* Above/Below the center monster */
689 for (x = xval - 1; x <= xval + 1; x++)
691 place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
692 place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
695 /* Next to the center monster */
696 place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
697 place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
700 place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
708 * Helper function for "trapped monster pit"
710 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
712 monster_race *r_ptr = &r_info[r_idx];
714 if (!vault_monster_okay(r_idx)) return (FALSE);
716 /* No wall passing monster */
717 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
724 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
727 * A trapped monster pit is a "big" room with a straight corridor in\n
728 * which wall opening traps are placed, and with two "inner" rooms\n
729 * containing a "collection" of monsters of a given type organized in\n
732 * The trapped monster pit appears as shown below, where the actual\n
733 * monsters in each location depend on the type of the pit\n
735 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
737 * XXXXXXXXXXXXXXXXXXXXXXX X\n
738 * XXXXX001123454321100XXX X\n
739 * XXX0012234567654322100X X\n
740 * XXXXXXXXXXXXXXXXXXXXXXX X\n
742 * X XXXXXXXXXXXXXXXXXXXXXXX\n
743 * X X0012234567654322100XXX\n
744 * X XXX001123454321100XXXXX\n
745 * X XXXXXXXXXXXXXXXXXXXXXXX\n
747 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
749 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
750 * to request 16 "appropriate" monsters, sorting them by level, and using\n
751 * the "even" entries in this sorted list for the contents of the pit.\n
753 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
754 * which is handled by requiring a specific "breath" attack for all of the\n
755 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
756 * be present in many of the dragon pits, if they have the proper breath.\n
758 * Note the use of the "get_mon_num_prep()" function, and the special\n
759 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
760 * allocation table" in such a way as to optimize the selection of\n
761 * "appropriate" non-unique monsters for the pit.\n
763 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
764 * the pit will be empty.\n
766 * Note that "monster pits" will never contain "unique" monsters.\n
768 bool build_type13(void)
770 static int placing[][3] = {
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, +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, -7, 1 },{ -3, -5, 1 },{ -3, -4, 1 },
776 { +2, -7, 1 },{ +3, -5, 1 },{ +3, -4, 1 },
777 { -2, +7, 1 },{ -3, +5, 1 },{ -3, +4, 1 },
778 { +2, +7, 1 },{ +3, +5, 1 },{ +3, +4, 1 },
779 { -2, -6, 2 },{ -2, -5, 2 },{ -3, -3, 2 },
780 { +2, -6, 2 },{ +2, -5, 2 },{ +3, -3, 2 },
781 { -2, +6, 2 },{ -2, +5, 2 },{ -3, +3, 2 },
782 { +2, +6, 2 },{ +2, +5, 2 },{ +3, +3, 2 },
783 { -2, -4, 3 },{ -3, -2, 3 },
784 { +2, -4, 3 },{ +3, -2, 3 },
785 { -2, +4, 3 },{ -3, +2, 3 },
786 { +2, +4, 3 },{ +3, +2, 3 },
787 { -2, -3, 4 },{ -3, -1, 4 },
788 { +2, -3, 4 },{ +3, -1, 4 },
789 { -2, +3, 4 },{ -3, +1, 4 },
790 { +2, +3, 4 },{ +3, +1, 4 },
791 { -2, -2, 5 },{ -3, 0, 5 },{ -2, +2, 5 },
792 { +2, -2, 5 },{ +3, 0, 5 },{ +2, +2, 5 },
793 { -2, -1, 6 },{ -2, +1, 6 },
794 { +2, -1, 6 },{ +2, +1, 6 },
795 { -2, 0, 7 },{ +2, 0, 7 },
799 POSITION y, x, y1, x1, y2, x2, xval, yval;
802 MONRACE_IDX what[16];
808 int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
809 vault_aux_type *n_ptr;
811 /* Only in Angband */
812 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
814 /* No type available */
815 if (cur_pit_type < 0) return FALSE;
817 n_ptr = &pit_types[cur_pit_type];
819 /* Process a preparation function if necessary */
820 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
821 get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
823 align.sub_align = SUB_ALIGN_NEUTRAL;
825 /* Pick some monster types */
826 for (i = 0; i < 16; i++)
828 MONRACE_IDX r_idx = 0;
830 monster_race *r_ptr = NULL;
834 /* Get a (hard) monster type */
835 r_idx = get_mon_num(current_floor_ptr->dun_level + 0);
836 r_ptr = &r_info[r_idx];
838 /* Decline incorrect alignment */
839 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
841 /* Accept this monster */
846 if (!r_idx || !attempts) return FALSE;
848 /* Note the alignment */
849 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
850 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
855 /* Find and reserve some space in the dungeon. Get center of room. */
856 if (!find_space(&yval, &xval, 13, 25)) return FALSE;
864 /* Fill with inner walls */
865 for (y = y1 - 1; y <= y2 + 1; y++)
867 for (x = x1 - 1; x <= x2 + 1; x++)
869 g_ptr = ¤t_floor_ptr->grid_array[y][x];
870 place_inner_grid(g_ptr);
871 g_ptr->info |= (CAVE_ROOM);
875 /* Place the floor area 1 */
876 for (x = x1 + 3; x <= x2 - 3; x++)
878 g_ptr = ¤t_floor_ptr->grid_array[yval - 2][x];
879 place_floor_grid(g_ptr);
880 add_cave_info(yval - 2, x, CAVE_ICKY);
882 g_ptr = ¤t_floor_ptr->grid_array[yval + 2][x];
883 place_floor_grid(g_ptr);
884 add_cave_info(yval + 2, x, CAVE_ICKY);
887 /* Place the floor area 2 */
888 for (x = x1 + 5; x <= x2 - 5; x++)
890 g_ptr = ¤t_floor_ptr->grid_array[yval - 3][x];
891 place_floor_grid(g_ptr);
892 add_cave_info(yval - 3, x, CAVE_ICKY);
894 g_ptr = ¤t_floor_ptr->grid_array[yval + 3][x];
895 place_floor_grid(g_ptr);
896 add_cave_info(yval + 3, x, CAVE_ICKY);
900 for (x = x1; x <= x2; x++)
902 g_ptr = ¤t_floor_ptr->grid_array[yval][x];
903 place_floor_grid(g_ptr);
904 g_ptr = ¤t_floor_ptr->grid_array[y1][x];
905 place_floor_grid(g_ptr);
906 g_ptr = ¤t_floor_ptr->grid_array[y2][x];
907 place_floor_grid(g_ptr);
910 /* Place the outer walls */
911 for (y = y1 - 1; y <= y2 + 1; y++)
913 g_ptr = ¤t_floor_ptr->grid_array[y][x1 - 1];
914 place_outer_grid(g_ptr);
915 g_ptr = ¤t_floor_ptr->grid_array[y][x2 + 1];
916 place_outer_grid(g_ptr);
918 for (x = x1 - 1; x <= x2 + 1; x++)
920 g_ptr = ¤t_floor_ptr->grid_array[y1 - 1][x];
921 place_outer_grid(g_ptr);
922 g_ptr = ¤t_floor_ptr->grid_array[y2 + 1][x];
923 place_outer_grid(g_ptr);
926 /* Random corridor */
929 for (y = y1; y <= yval; y++)
931 place_floor_bold(y, x2);
932 place_solid_bold(y, x1 - 1);
934 for (y = yval; y <= y2 + 1; y++)
936 place_floor_bold(y, x1);
937 place_solid_bold(y, x2 + 1);
942 for (y = yval; y <= y2 + 1; y++)
944 place_floor_bold(y, x1);
945 place_solid_bold(y, x2 + 1);
947 for (y = y1; y <= yval; y++)
949 place_floor_bold(y, x2);
950 place_solid_bold(y, x1 - 1);
954 /* Place the wall open trap */
955 current_floor_ptr->grid_array[yval][xval].mimic = current_floor_ptr->grid_array[yval][xval].feat;
956 current_floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
958 /* Sort the entries */
959 for (i = 0; i < 16 - 1; i++)
961 /* Sort the entries */
962 for (j = 0; j < 16 - 1; j++)
967 int p1 = r_info[what[i1]].level;
968 int p2 = r_info[what[i2]].level;
973 MONRACE_IDX tmp = what[i1];
980 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
981 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
983 /* Select the entries */
984 for (i = 0; i < 8; i++)
986 /* Every other entry */
987 what[i] = what[i * 2];
991 msg_print(r_name + r_info[what[i]].name);
995 for (i = 0; placing[i][2] >= 0; i++)
997 y = yval + placing[i][0];
998 x = xval + placing[i][1];
999 place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);