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, gb_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, gb_outer);
368 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
369 place_grid(player_ptr, g_ptr, gb_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, gb_outer);
375 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
376 place_grid(player_ptr, g_ptr, gb_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, gb_inner);
391 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
392 place_grid(player_ptr, g_ptr, gb_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, gb_inner);
399 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
400 place_grid(player_ptr, g_ptr, gb_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, gb_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, gb_outer);
577 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
578 place_grid(player_ptr, g_ptr, gb_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, gb_outer);
584 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
585 place_grid(player_ptr, g_ptr, gb_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, gb_inner);
599 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
600 place_grid(player_ptr, g_ptr, gb_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, gb_inner);
606 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
607 place_grid(player_ptr, g_ptr, gb_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 * todo vault_monster_okay() をmonsterrace-hook以外から呼んでいるのはここだけなので、何とかしたい
714 * Helper function for "trapped monster pit"
716 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
718 monster_race *r_ptr = &r_info[r_idx];
720 if (!vault_monster_okay(r_idx)) return FALSE;
722 /* No wall passing monster */
723 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
730 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
733 * A trapped monster pit is a "big" room with a straight corridor in\n
734 * which wall opening traps are placed, and with two "inner" rooms\n
735 * containing a "collection" of monsters of a given type organized in\n
738 * The trapped monster pit appears as shown below, where the actual\n
739 * monsters in each location depend on the type of the pit\n
741 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
743 * XXXXXXXXXXXXXXXXXXXXXXX X\n
744 * XXXXX001123454321100XXX X\n
745 * XXX0012234567654322100X X\n
746 * XXXXXXXXXXXXXXXXXXXXXXX X\n
748 * X XXXXXXXXXXXXXXXXXXXXXXX\n
749 * X X0012234567654322100XXX\n
750 * X XXX001123454321100XXXXX\n
751 * X XXXXXXXXXXXXXXXXXXXXXXX\n
753 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
755 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
756 * to request 16 "appropriate" monsters, sorting them by level, and using\n
757 * the "even" entries in this sorted list for the contents of the pit.\n
759 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
760 * which is handled by requiring a specific "breath" attack for all of the\n
761 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
762 * be present in many of the dragon pits, if they have the proper breath.\n
764 * Note the use of the "get_mon_num_prep()" function, and the special\n
765 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
766 * allocation table" in such a way as to optimize the selection of\n
767 * "appropriate" non-unique monsters for the pit.\n
769 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
770 * the pit will be empty.\n
772 * Note that "monster pits" will never contain "unique" monsters.\n
774 bool build_type13(player_type *player_ptr)
776 static int placing[][3] = {
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, +9, 0 },{ +2, +8, 0 },{ +3, +7, 0 },{ +3, +6, 0 },
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, +7, 1 },{ +3, +5, 1 },{ +3, +4, 1 },
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, +6, 2 },{ +2, +5, 2 },{ +3, +3, 2 },
789 { -2, -4, 3 },{ -3, -2, 3 },
790 { +2, -4, 3 },{ +3, -2, 3 },
791 { -2, +4, 3 },{ -3, +2, 3 },
792 { +2, +4, 3 },{ +3, +2, 3 },
793 { -2, -3, 4 },{ -3, -1, 4 },
794 { +2, -3, 4 },{ +3, -1, 4 },
795 { -2, +3, 4 },{ -3, +1, 4 },
796 { +2, +3, 4 },{ +3, +1, 4 },
797 { -2, -2, 5 },{ -3, 0, 5 },{ -2, +2, 5 },
798 { +2, -2, 5 },{ +3, 0, 5 },{ +2, +2, 5 },
799 { -2, -1, 6 },{ -2, +1, 6 },
800 { +2, -1, 6 },{ +2, +1, 6 },
801 { -2, 0, 7 },{ +2, 0, 7 },
805 POSITION y, x, y1, x1, y2, x2, xval, yval;
808 MONRACE_IDX what[16];
814 floor_type *floor_ptr = player_ptr->current_floor_ptr;
815 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
816 vault_aux_type *n_ptr;
818 /* Only in Angband */
819 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
821 /* No type available */
822 if (cur_pit_type < 0) return FALSE;
824 n_ptr = &pit_types[cur_pit_type];
826 /* Process a preparation function if necessary */
827 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
828 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
830 align.sub_align = SUB_ALIGN_NEUTRAL;
832 /* Pick some monster types */
833 for (i = 0; i < 16; i++)
835 MONRACE_IDX r_idx = 0;
837 monster_race *r_ptr = NULL;
841 /* Get a (hard) monster type */
842 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0);
843 r_ptr = &r_info[r_idx];
845 /* Decline incorrect alignment */
846 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
848 /* Accept this monster */
853 if (!r_idx || !attempts) return FALSE;
855 /* Note the alignment */
856 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
857 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
862 /* Find and reserve some space in the dungeon. Get center of room. */
863 if (!find_space(player_ptr, &yval, &xval, 13, 25)) return FALSE;
871 /* Fill with inner walls */
872 for (y = y1 - 1; y <= y2 + 1; y++)
874 for (x = x1 - 1; x <= x2 + 1; x++)
876 g_ptr = &floor_ptr->grid_array[y][x];
877 place_grid(player_ptr, g_ptr, gb_inner);
878 g_ptr->info |= (CAVE_ROOM);
882 /* Place the floor area 1 */
883 for (x = x1 + 3; x <= x2 - 3; x++)
885 g_ptr = &floor_ptr->grid_array[yval - 2][x];
886 place_grid(player_ptr, g_ptr, gb_floor);
887 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
889 g_ptr = &floor_ptr->grid_array[yval + 2][x];
890 place_grid(player_ptr, g_ptr, gb_floor);
891 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
894 /* Place the floor area 2 */
895 for (x = x1 + 5; x <= x2 - 5; x++)
897 g_ptr = &floor_ptr->grid_array[yval - 3][x];
898 place_grid(player_ptr, g_ptr, gb_floor);
899 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
901 g_ptr = &floor_ptr->grid_array[yval + 3][x];
902 place_grid(player_ptr, g_ptr, gb_floor);
903 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
907 for (x = x1; x <= x2; x++)
909 g_ptr = &floor_ptr->grid_array[yval][x];
910 place_grid(player_ptr, g_ptr, gb_floor);
911 g_ptr = &floor_ptr->grid_array[y1][x];
912 place_grid(player_ptr, g_ptr, gb_floor);
913 g_ptr = &floor_ptr->grid_array[y2][x];
914 place_grid(player_ptr, g_ptr, gb_floor);
917 /* Place the outer walls */
918 for (y = y1 - 1; y <= y2 + 1; y++)
920 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
921 place_grid(player_ptr, g_ptr, gb_outer);
922 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
923 place_grid(player_ptr, g_ptr, gb_outer);
925 for (x = x1 - 1; x <= x2 + 1; x++)
927 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
928 place_grid(player_ptr, g_ptr, gb_outer);
929 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
930 place_grid(player_ptr, g_ptr, gb_outer);
933 /* Random corridor */
936 for (y = y1; y <= yval; y++)
938 place_bold(player_ptr, y, x2, gb_floor);
939 place_bold(player_ptr, y, x1 - 1, gb_solid);
941 for (y = yval; y <= y2 + 1; y++)
943 place_bold(player_ptr, y, x1, gb_floor);
944 place_bold(player_ptr, y, x2 + 1, gb_solid);
949 for (y = yval; y <= y2 + 1; y++)
951 place_bold(player_ptr, y, x1, gb_floor);
952 place_bold(player_ptr, y, x2 + 1, gb_solid);
954 for (y = y1; y <= yval; y++)
956 place_bold(player_ptr, y, x2, gb_floor);
957 place_bold(player_ptr, y, x1 - 1, gb_solid);
961 /* Place the wall open trap */
962 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
963 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
965 /* Sort the entries */
966 for (i = 0; i < 16 - 1; i++)
968 /* Sort the entries */
969 for (j = 0; j < 16 - 1; j++)
974 int p1 = r_info[what[i1]].level;
975 int p2 = r_info[what[i2]].level;
980 MONRACE_IDX tmp = what[i1];
987 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
988 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
990 /* Select the entries */
991 for (i = 0; i < 8; i++)
993 /* Every other entry */
994 what[i] = what[i * 2];
998 msg_print(r_name + r_info[what[i]].name);
1002 for (i = 0; placing[i][2] >= 0; i++)
1004 y = yval + placing[i][0];
1005 x = xval + placing[i][1];
1006 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);