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)(player_type *player_ptr);
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(floor_type *floor_ptr, 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 > 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(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 > 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(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
268 * @param player_ptr プレーヤーへの参照ポインタ
271 * A monster nest is a "big" room, with an "inner" room, containing\n
272 * a "collection" of monsters of a given type strewn about the room.\n
274 * The monsters are chosen from a set of 64 randomly selected monster\n
275 * races, to allow the nest creation to fail instead of having "holes".\n
277 * Note the use of the "get_mon_num_prep()" function, and the special\n
278 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
279 * allocation table" in such a way as to optimize the selection of\n
280 * "appropriate" non-unique monsters for the nest.\n
282 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
283 * case the nest will be empty.\n
285 * Note that "monster nests" will never contain "unique" monsters.\n
287 bool build_type5(player_type *player_ptr)
289 POSITION y, x, y1, x1, y2, x2, xval, yval;
291 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
297 floor_type *floor_ptr = player_ptr->current_floor_ptr;
298 int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
299 vault_aux_type *n_ptr;
301 /* No type available */
302 if (cur_nest_type < 0) return FALSE;
304 n_ptr = &nest_types[cur_nest_type];
306 /* Process a preparation function if necessary */
307 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
308 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
310 align.sub_align = SUB_ALIGN_NEUTRAL;
312 /* Pick some monster types */
313 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
315 MONRACE_IDX r_idx = 0;
317 monster_race *r_ptr = NULL;
321 /* Get a (hard) monster type */
322 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11);
323 r_ptr = &r_info[r_idx];
325 /* Decline incorrect alignment */
326 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
328 /* Accept this monster */
333 if (!r_idx || !attempts) return FALSE;
335 /* Note the alignment */
336 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
337 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
339 nest_mon_info[i].r_idx = (s16b)r_idx;
340 nest_mon_info[i].used = FALSE;
343 /* Find and reserve some space in the dungeon. Get center of room. */
344 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
352 /* Place the floor area */
353 for (y = y1 - 1; y <= y2 + 1; y++)
355 for (x = x1 - 1; x <= x2 + 1; x++)
357 g_ptr = &floor_ptr->grid_array[y][x];
358 place_grid(player_ptr, g_ptr, floor);
359 g_ptr->info |= (CAVE_ROOM);
363 /* Place the outer walls */
364 for (y = y1 - 1; y <= y2 + 1; y++)
366 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
367 place_grid(player_ptr, g_ptr, outer);
368 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
369 place_grid(player_ptr, g_ptr, outer);
371 for (x = x1 - 1; x <= x2 + 1; x++)
373 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
374 place_grid(player_ptr, g_ptr, outer);
375 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
376 place_grid(player_ptr, g_ptr, outer);
380 /* Advance to the center room */
386 /* The inner walls */
387 for (y = y1 - 1; y <= y2 + 1; y++)
389 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
390 place_grid(player_ptr, g_ptr, inner);
391 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
392 place_grid(player_ptr, g_ptr, inner);
395 for (x = x1 - 1; x <= x2 + 1; x++)
397 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
398 place_grid(player_ptr, g_ptr, inner);
399 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
400 place_grid(player_ptr, g_ptr, inner);
402 for (y = y1; y <= y2; y++)
404 for (x = x1; x <= x2; x++)
406 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
410 /* Place a secret door */
413 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
414 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
415 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
416 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
419 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
421 /* Place some monsters */
422 for (y = yval - 2; y <= yval + 2; y++)
424 for (x = xval - 9; x <= xval + 9; x++)
428 i = randint0(NUM_NEST_MON_TYPE);
429 r_idx = nest_mon_info[i].r_idx;
431 /* Place that "random" monster (no groups) */
432 (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
434 nest_mon_info[i].used = TRUE;
440 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
442 /* Dump the entries (prevent multi-printing) */
443 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
445 if (!nest_mon_info[i].used) break;
446 for (; i < NUM_NEST_MON_TYPE - 1; i++)
448 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
449 if (!nest_mon_info[i + 1].used) break;
451 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
460 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
463 * A monster pit is a "big" room, with an "inner" room, containing\n
464 * a "collection" of monsters of a given type organized in the room.\n
466 * The inside room in a monster pit appears as shown below, where the\n
467 * actual monsters in each location depend on the type of the pit\n
469 * XXXXXXXXXXXXXXXXXXXXX\n
470 * X0000000000000000000X\n
471 * X0112233455543322110X\n
472 * X0112233467643322110X\n
473 * X0112233455543322110X\n
474 * X0000000000000000000X\n
475 * XXXXXXXXXXXXXXXXXXXXX\n
477 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
478 * to request 16 "appropriate" monsters, sorting them by level, and using\n
479 * the "even" entries in this sorted list for the contents of the pit.\n
481 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
482 * which is handled by requiring a specific "breath" attack for all of the\n
483 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
484 * be present in many of the dragon pits, if they have the proper breath.\n
486 * Note the use of the "get_mon_num_prep()" function, and the special\n
487 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
488 * allocation table" in such a way as to optimize the selection of\n
489 * "appropriate" non-unique monsters for the pit.\n
491 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
492 * the pit will be empty.\n
494 * Note that "monster pits" will never contain "unique" monsters.\n
496 bool build_type6(player_type *player_ptr)
498 POSITION y, x, y1, x1, y2, x2, xval, yval;
501 MONRACE_IDX what[16];
507 floor_type *floor_ptr = player_ptr->current_floor_ptr;
508 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
509 vault_aux_type *n_ptr;
511 /* No type available */
512 if (cur_pit_type < 0) return FALSE;
514 n_ptr = &pit_types[cur_pit_type];
516 /* Process a preparation function if necessary */
517 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
518 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
520 align.sub_align = SUB_ALIGN_NEUTRAL;
522 /* Pick some monster types */
523 for (i = 0; i < 16; i++)
525 MONRACE_IDX r_idx = 0;
527 monster_race *r_ptr = NULL;
531 /* Get a (hard) monster type */
532 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11);
533 r_ptr = &r_info[r_idx];
535 /* Decline incorrect alignment */
536 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
538 /* Accept this monster */
543 if (!r_idx || !attempts) return FALSE;
545 /* Note the alignment */
546 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
547 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
552 /* Find and reserve some space in the dungeon. Get center of room. */
553 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
561 /* Place the floor area */
562 for (y = y1 - 1; y <= y2 + 1; y++)
564 for (x = x1 - 1; x <= x2 + 1; x++)
566 g_ptr = &floor_ptr->grid_array[y][x];
567 place_grid(player_ptr, g_ptr, floor);
568 g_ptr->info |= (CAVE_ROOM);
572 /* Place the outer walls */
573 for (y = y1 - 1; y <= y2 + 1; y++)
575 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
576 place_grid(player_ptr, g_ptr, outer);
577 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
578 place_grid(player_ptr, g_ptr, outer);
580 for (x = x1 - 1; x <= x2 + 1; x++)
582 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
583 place_grid(player_ptr, g_ptr, outer);
584 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
585 place_grid(player_ptr, g_ptr, outer);
588 /* Advance to the center room */
594 /* The inner walls */
595 for (y = y1 - 1; y <= y2 + 1; y++)
597 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
598 place_grid(player_ptr, g_ptr, inner);
599 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
600 place_grid(player_ptr, g_ptr, inner);
602 for (x = x1 - 1; x <= x2 + 1; x++)
604 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
605 place_grid(player_ptr, g_ptr, inner);
606 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
607 place_grid(player_ptr, g_ptr, inner);
609 for (y = y1; y <= y2; y++)
611 for (x = x1; x <= x2; x++)
613 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
617 /* Place a secret door */
620 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
621 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
622 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
623 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
626 /* Sort the entries */
627 for (i = 0; i < 16 - 1; i++)
629 /* Sort the entries */
630 for (j = 0; j < 16 - 1; j++)
635 int p1 = r_info[what[i1]].level;
636 int p2 = r_info[what[i2]].level;
641 MONRACE_IDX tmp = what[i1];
648 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
650 /* Select the entries */
651 for (i = 0; i < 8; i++)
653 /* Every other entry */
654 what[i] = what[i * 2];
655 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
658 /* Top and bottom rows */
659 for (x = xval - 9; x <= xval + 9; x++)
661 place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
662 place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
666 for (y = yval - 1; y <= yval + 1; y++)
668 place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
669 place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
671 place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
672 place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
674 place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
675 place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
677 place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
678 place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
680 place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
681 place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
683 place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
684 place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
686 place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
687 place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
689 place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
690 place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
693 /* Above/Below the center monster */
694 for (x = xval - 1; x <= xval + 1; x++)
696 place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
697 place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
700 /* Next to the center monster */
701 place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
702 place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
705 place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
713 * Helper function for "trapped monster pit"
715 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
717 monster_race *r_ptr = &r_info[r_idx];
719 if (!vault_monster_okay(r_idx)) return FALSE;
721 /* No wall passing monster */
722 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
729 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
732 * A trapped monster pit is a "big" room with a straight corridor in\n
733 * which wall opening traps are placed, and with two "inner" rooms\n
734 * containing a "collection" of monsters of a given type organized in\n
737 * The trapped monster pit appears as shown below, where the actual\n
738 * monsters in each location depend on the type of the pit\n
740 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
742 * XXXXXXXXXXXXXXXXXXXXXXX X\n
743 * XXXXX001123454321100XXX X\n
744 * XXX0012234567654322100X X\n
745 * XXXXXXXXXXXXXXXXXXXXXXX X\n
747 * X XXXXXXXXXXXXXXXXXXXXXXX\n
748 * X X0012234567654322100XXX\n
749 * X XXX001123454321100XXXXX\n
750 * X XXXXXXXXXXXXXXXXXXXXXXX\n
752 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
754 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
755 * to request 16 "appropriate" monsters, sorting them by level, and using\n
756 * the "even" entries in this sorted list for the contents of the pit.\n
758 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
759 * which is handled by requiring a specific "breath" attack for all of the\n
760 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
761 * be present in many of the dragon pits, if they have the proper breath.\n
763 * Note the use of the "get_mon_num_prep()" function, and the special\n
764 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
765 * allocation table" in such a way as to optimize the selection of\n
766 * "appropriate" non-unique monsters for the pit.\n
768 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
769 * the pit will be empty.\n
771 * Note that "monster pits" will never contain "unique" monsters.\n
773 bool build_type13(player_type *player_ptr)
775 static int placing[][3] = {
776 { -2, -9, 0 },{ -2, -8, 0 },{ -3, -7, 0 },{ -3, -6, 0 },
777 { +2, -9, 0 },{ +2, -8, 0 },{ +3, -7, 0 },{ +3, -6, 0 },
778 { -2, +9, 0 },{ -2, +8, 0 },{ -3, +7, 0 },{ -3, +6, 0 },
779 { +2, +9, 0 },{ +2, +8, 0 },{ +3, +7, 0 },{ +3, +6, 0 },
780 { -2, -7, 1 },{ -3, -5, 1 },{ -3, -4, 1 },
781 { +2, -7, 1 },{ +3, -5, 1 },{ +3, -4, 1 },
782 { -2, +7, 1 },{ -3, +5, 1 },{ -3, +4, 1 },
783 { +2, +7, 1 },{ +3, +5, 1 },{ +3, +4, 1 },
784 { -2, -6, 2 },{ -2, -5, 2 },{ -3, -3, 2 },
785 { +2, -6, 2 },{ +2, -5, 2 },{ +3, -3, 2 },
786 { -2, +6, 2 },{ -2, +5, 2 },{ -3, +3, 2 },
787 { +2, +6, 2 },{ +2, +5, 2 },{ +3, +3, 2 },
788 { -2, -4, 3 },{ -3, -2, 3 },
789 { +2, -4, 3 },{ +3, -2, 3 },
790 { -2, +4, 3 },{ -3, +2, 3 },
791 { +2, +4, 3 },{ +3, +2, 3 },
792 { -2, -3, 4 },{ -3, -1, 4 },
793 { +2, -3, 4 },{ +3, -1, 4 },
794 { -2, +3, 4 },{ -3, +1, 4 },
795 { +2, +3, 4 },{ +3, +1, 4 },
796 { -2, -2, 5 },{ -3, 0, 5 },{ -2, +2, 5 },
797 { +2, -2, 5 },{ +3, 0, 5 },{ +2, +2, 5 },
798 { -2, -1, 6 },{ -2, +1, 6 },
799 { +2, -1, 6 },{ +2, +1, 6 },
800 { -2, 0, 7 },{ +2, 0, 7 },
804 POSITION y, x, y1, x1, y2, x2, xval, yval;
807 MONRACE_IDX what[16];
813 floor_type *floor_ptr = player_ptr->current_floor_ptr;
814 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
815 vault_aux_type *n_ptr;
817 /* Only in Angband */
818 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
820 /* No type available */
821 if (cur_pit_type < 0) return FALSE;
823 n_ptr = &pit_types[cur_pit_type];
825 /* Process a preparation function if necessary */
826 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
827 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
829 align.sub_align = SUB_ALIGN_NEUTRAL;
831 /* Pick some monster types */
832 for (i = 0; i < 16; i++)
834 MONRACE_IDX r_idx = 0;
836 monster_race *r_ptr = NULL;
840 /* Get a (hard) monster type */
841 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0);
842 r_ptr = &r_info[r_idx];
844 /* Decline incorrect alignment */
845 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
847 /* Accept this monster */
852 if (!r_idx || !attempts) return FALSE;
854 /* Note the alignment */
855 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
856 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
861 /* Find and reserve some space in the dungeon. Get center of room. */
862 if (!find_space(player_ptr, &yval, &xval, 13, 25)) return FALSE;
870 /* Fill with inner walls */
871 for (y = y1 - 1; y <= y2 + 1; y++)
873 for (x = x1 - 1; x <= x2 + 1; x++)
875 g_ptr = &floor_ptr->grid_array[y][x];
876 place_grid(player_ptr, g_ptr, inner);
877 g_ptr->info |= (CAVE_ROOM);
881 /* Place the floor area 1 */
882 for (x = x1 + 3; x <= x2 - 3; x++)
884 g_ptr = &floor_ptr->grid_array[yval - 2][x];
885 place_grid(player_ptr, g_ptr, floor);
886 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
888 g_ptr = &floor_ptr->grid_array[yval + 2][x];
889 place_grid(player_ptr, g_ptr, floor);
890 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
893 /* Place the floor area 2 */
894 for (x = x1 + 5; x <= x2 - 5; x++)
896 g_ptr = &floor_ptr->grid_array[yval - 3][x];
897 place_grid(player_ptr, g_ptr, floor);
898 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
900 g_ptr = &floor_ptr->grid_array[yval + 3][x];
901 place_grid(player_ptr, g_ptr, floor);
902 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
906 for (x = x1; x <= x2; x++)
908 g_ptr = &floor_ptr->grid_array[yval][x];
909 place_grid(player_ptr, g_ptr, floor);
910 g_ptr = &floor_ptr->grid_array[y1][x];
911 place_grid(player_ptr, g_ptr, floor);
912 g_ptr = &floor_ptr->grid_array[y2][x];
913 place_grid(player_ptr, g_ptr, floor);
916 /* Place the outer walls */
917 for (y = y1 - 1; y <= y2 + 1; y++)
919 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
920 place_grid(player_ptr, g_ptr, outer);
921 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
922 place_grid(player_ptr, g_ptr, outer);
924 for (x = x1 - 1; x <= x2 + 1; x++)
926 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
927 place_grid(player_ptr, g_ptr, outer);
928 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
929 place_grid(player_ptr, g_ptr, outer);
932 /* Random corridor */
935 for (y = y1; y <= yval; y++)
937 place_bold(player_ptr, y, x2, floor);
938 place_bold(player_ptr, y, x1 - 1, solid);
940 for (y = yval; y <= y2 + 1; y++)
942 place_bold(player_ptr, y, x1, floor);
943 place_bold(player_ptr, y, x2 + 1, solid);
948 for (y = yval; y <= y2 + 1; y++)
950 place_bold(player_ptr, y, x1, floor);
951 place_bold(player_ptr, y, x2 + 1, solid);
953 for (y = y1; y <= yval; y++)
955 place_bold(player_ptr, y, x2, floor);
956 place_bold(player_ptr, y, x1 - 1, solid);
960 /* Place the wall open trap */
961 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
962 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
964 /* Sort the entries */
965 for (i = 0; i < 16 - 1; i++)
967 /* Sort the entries */
968 for (j = 0; j < 16 - 1; j++)
973 int p1 = r_info[what[i1]].level;
974 int p2 = r_info[what[i2]].level;
979 MONRACE_IDX tmp = what[i1];
986 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
987 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
989 /* Select the entries */
990 for (i = 0; i < 8; i++)
992 /* Every other entry */
993 what[i] = what[i * 2];
997 msg_print(r_name + r_info[what[i]].name);
1001 for (i = 0; placing[i][2] >= 0; i++)
1003 y = yval + placing[i][0];
1004 x = xval + placing[i][1];
1005 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);