5 #include "floor/floor-generate.h"
7 #include "room/rooms-pit-nest.h"
8 #include "monster/monster.h"
9 #include "monster/monsterrace-hook.h"
11 #include "floor/floor.h"
13 #include "dungeon/dungeon.h"
14 #include "room/pit-nest-kinds-table.h"
17 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
18 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
19 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
20 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
22 static int pick_vault_type(floor_type *floor_ptr, vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
24 int tmp, total, count;
26 vault_aux_type *n_ptr;
28 /* Calculate the total possibilities */
29 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
32 if (!n_ptr->name) break;
34 /* Ignore excessive depth */
35 if (n_ptr->level > floor_ptr->dun_level) continue;
37 /* Not matched with pit/nest flag */
38 if (!(allow_flag_mask & (1L << count))) continue;
40 /* Count this possibility */
41 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
44 /* Pick a random type */
45 tmp = randint0(total);
48 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
51 if (!n_ptr->name) break;
53 /* Ignore excessive depth */
54 if (n_ptr->level > floor_ptr->dun_level) continue;
56 /* Not matched with pit/nest flag */
57 if (!(allow_flag_mask & (1L << count))) continue;
59 /* Count this possibility */
60 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
63 if (tmp < total) break;
66 return n_ptr->name ? count : -1;
71 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
72 * @param type pit/nestの型ID
73 * @param nest TRUEならばnest、FALSEならばpit
74 * @return デバッグ表示文字列の参照ポインタ
76 * Hack -- Get the string describing subtype of pit/nest
77 * Determined in prepare function (some pit/nest only)
79 static concptr pit_subtype_string(int type, bool nest)
81 static char inner_buf[256] = "";
83 inner_buf[0] = '\0'; /* Init string */
90 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
92 case NEST_TYPE_SYMBOL_GOOD:
93 case NEST_TYPE_SYMBOL_EVIL:
94 sprintf(inner_buf, "(%c)", vault_aux_char);
102 case PIT_TYPE_SYMBOL_GOOD:
103 case PIT_TYPE_SYMBOL_EVIL:
104 sprintf(inner_buf, "(%c)", vault_aux_char);
106 case PIT_TYPE_DRAGON:
107 switch (vault_aux_dragon_mask4)
109 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
110 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
111 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
112 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
113 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
114 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
115 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
116 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
127 *! @brief nestのモンスターリストをソートするための関数 /
128 * Comp function for sorting nest monster information
129 * @param u ソート処理対象配列ポインタ
135 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
137 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
138 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
139 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
140 monster_race *r1_ptr = &r_info[w1];
141 monster_race *r2_ptr = &r_info[w2];
147 /* Extract used info */
148 z1 = nest_mon_info[a].used;
149 z2 = nest_mon_info[b].used;
151 /* Compare used status */
152 if (z1 < z2) return FALSE;
153 if (z1 > z2) return TRUE;
156 if (r1_ptr->level < r2_ptr->level) return TRUE;
157 if (r1_ptr->level > r2_ptr->level) return FALSE;
159 /* Compare experience */
160 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
161 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
163 /* Compare indexes */
169 * @brief nestのモンスターリストをスワップするための関数 /
170 * Swap function for sorting nest monster information
171 * @param u スワップ処理対象配列ポインタ
173 * @param a スワップ対象参照ID1
174 * @param b スワップ対象参照ID2
177 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
179 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
180 nest_mon_info_type holder;
186 holder = nest_mon_info[a];
187 nest_mon_info[a] = nest_mon_info[b];
188 nest_mon_info[b] = holder;
193 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
194 * @param player_ptr プレーヤーへの参照ポインタ
197 * A monster nest is a "big" room, with an "inner" room, containing\n
198 * a "collection" of monsters of a given type strewn about the room.\n
200 * The monsters are chosen from a set of 64 randomly selected monster\n
201 * races, to allow the nest creation to fail instead of having "holes".\n
203 * Note the use of the "get_mon_num_prep()" function, and the special\n
204 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
205 * allocation table" in such a way as to optimize the selection of\n
206 * "appropriate" non-unique monsters for the nest.\n
208 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
209 * case the nest will be empty.\n
211 * Note that "monster nests" will never contain "unique" monsters.\n
213 bool build_type5(player_type *player_ptr)
215 POSITION y, x, y1, x1, y2, x2, xval, yval;
217 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
223 floor_type *floor_ptr = player_ptr->current_floor_ptr;
224 int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
225 vault_aux_type *n_ptr;
227 /* No type available */
228 if (cur_nest_type < 0) return FALSE;
230 n_ptr = &nest_types[cur_nest_type];
232 /* Process a preparation function if necessary */
233 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
234 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
236 align.sub_align = SUB_ALIGN_NEUTRAL;
238 /* Pick some monster types */
239 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
241 MONRACE_IDX r_idx = 0;
243 monster_race *r_ptr = NULL;
247 /* Get a (hard) monster type */
248 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
249 r_ptr = &r_info[r_idx];
251 /* Decline incorrect alignment */
252 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
254 /* Accept this monster */
259 if (!r_idx || !attempts) return FALSE;
261 /* Note the alignment */
262 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
263 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
265 nest_mon_info[i].r_idx = (s16b)r_idx;
266 nest_mon_info[i].used = FALSE;
269 /* Find and reserve some space in the dungeon. Get center of room. */
270 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
278 /* Place the floor area */
279 for (y = y1 - 1; y <= y2 + 1; y++)
281 for (x = x1 - 1; x <= x2 + 1; x++)
283 g_ptr = &floor_ptr->grid_array[y][x];
284 place_grid(player_ptr, g_ptr, GB_FLOOR);
285 g_ptr->info |= (CAVE_ROOM);
289 /* Place the outer walls */
290 for (y = y1 - 1; y <= y2 + 1; y++)
292 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
293 place_grid(player_ptr, g_ptr, GB_OUTER);
294 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
295 place_grid(player_ptr, g_ptr, GB_OUTER);
297 for (x = x1 - 1; x <= x2 + 1; x++)
299 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
300 place_grid(player_ptr, g_ptr, GB_OUTER);
301 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
302 place_grid(player_ptr, g_ptr, GB_OUTER);
306 /* Advance to the center room */
312 /* The inner walls */
313 for (y = y1 - 1; y <= y2 + 1; y++)
315 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
316 place_grid(player_ptr, g_ptr, GB_INNER);
317 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
318 place_grid(player_ptr, g_ptr, GB_INNER);
321 for (x = x1 - 1; x <= x2 + 1; x++)
323 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
324 place_grid(player_ptr, g_ptr, GB_INNER);
325 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
326 place_grid(player_ptr, g_ptr, GB_INNER);
328 for (y = y1; y <= y2; y++)
330 for (x = x1; x <= x2; x++)
332 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
336 /* Place a secret door */
339 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
340 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
341 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
342 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
345 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
347 /* Place some monsters */
348 for (y = yval - 2; y <= yval + 2; y++)
350 for (x = xval - 9; x <= xval + 9; x++)
354 i = randint0(NUM_NEST_MON_TYPE);
355 r_idx = nest_mon_info[i].r_idx;
357 /* Place that "random" monster (no groups) */
358 (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
360 nest_mon_info[i].used = TRUE;
366 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
368 /* Dump the entries (prevent multi-printing) */
369 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
371 if (!nest_mon_info[i].used) break;
372 for (; i < NUM_NEST_MON_TYPE - 1; i++)
374 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
375 if (!nest_mon_info[i + 1].used) break;
377 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
386 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
389 * A monster pit is a "big" room, with an "inner" room, containing\n
390 * a "collection" of monsters of a given type organized in the room.\n
392 * The inside room in a monster pit appears as shown below, where the\n
393 * actual monsters in each location depend on the type of the pit\n
395 * XXXXXXXXXXXXXXXXXXXXX\n
396 * X0000000000000000000X\n
397 * X0112233455543322110X\n
398 * X0112233467643322110X\n
399 * X0112233455543322110X\n
400 * X0000000000000000000X\n
401 * XXXXXXXXXXXXXXXXXXXXX\n
403 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
404 * to request 16 "appropriate" monsters, sorting them by level, and using\n
405 * the "even" entries in this sorted list for the contents of the pit.\n
407 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
408 * which is handled by requiring a specific "breath" attack for all of the\n
409 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
410 * be present in many of the dragon pits, if they have the proper breath.\n
412 * Note the use of the "get_mon_num_prep()" function, and the special\n
413 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
414 * allocation table" in such a way as to optimize the selection of\n
415 * "appropriate" non-unique monsters for the pit.\n
417 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
418 * the pit will be empty.\n
420 * Note that "monster pits" will never contain "unique" monsters.\n
422 bool build_type6(player_type *player_ptr)
424 POSITION y, x, y1, x1, y2, x2, xval, yval;
427 MONRACE_IDX what[16];
433 floor_type *floor_ptr = player_ptr->current_floor_ptr;
434 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
435 vault_aux_type *n_ptr;
437 /* No type available */
438 if (cur_pit_type < 0) return FALSE;
440 n_ptr = &pit_types[cur_pit_type];
442 /* Process a preparation function if necessary */
443 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
444 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
446 align.sub_align = SUB_ALIGN_NEUTRAL;
448 /* Pick some monster types */
449 for (i = 0; i < 16; i++)
451 MONRACE_IDX r_idx = 0;
453 monster_race *r_ptr = NULL;
457 /* Get a (hard) monster type */
458 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
459 r_ptr = &r_info[r_idx];
461 /* Decline incorrect alignment */
462 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
464 /* Accept this monster */
469 if (!r_idx || !attempts) return FALSE;
471 /* Note the alignment */
472 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
473 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
478 /* Find and reserve some space in the dungeon. Get center of room. */
479 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
487 /* Place the floor area */
488 for (y = y1 - 1; y <= y2 + 1; y++)
490 for (x = x1 - 1; x <= x2 + 1; x++)
492 g_ptr = &floor_ptr->grid_array[y][x];
493 place_grid(player_ptr, g_ptr, GB_FLOOR);
494 g_ptr->info |= (CAVE_ROOM);
498 /* Place the outer walls */
499 for (y = y1 - 1; y <= y2 + 1; y++)
501 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
502 place_grid(player_ptr, g_ptr, GB_OUTER);
503 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
504 place_grid(player_ptr, g_ptr, GB_OUTER);
506 for (x = x1 - 1; x <= x2 + 1; x++)
508 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
509 place_grid(player_ptr, g_ptr, GB_OUTER);
510 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
511 place_grid(player_ptr, g_ptr, GB_OUTER);
514 /* Advance to the center room */
520 /* The inner walls */
521 for (y = y1 - 1; y <= y2 + 1; y++)
523 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
524 place_grid(player_ptr, g_ptr, GB_INNER);
525 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
526 place_grid(player_ptr, g_ptr, GB_INNER);
528 for (x = x1 - 1; x <= x2 + 1; x++)
530 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
531 place_grid(player_ptr, g_ptr, GB_INNER);
532 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
533 place_grid(player_ptr, g_ptr, GB_INNER);
535 for (y = y1; y <= y2; y++)
537 for (x = x1; x <= x2; x++)
539 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
543 /* Place a secret door */
546 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
547 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
548 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
549 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
552 /* Sort the entries */
553 for (i = 0; i < 16 - 1; i++)
555 /* Sort the entries */
556 for (j = 0; j < 16 - 1; j++)
561 int p1 = r_info[what[i1]].level;
562 int p2 = r_info[what[i2]].level;
567 MONRACE_IDX tmp = what[i1];
574 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
576 /* Select the entries */
577 for (i = 0; i < 8; i++)
579 /* Every other entry */
580 what[i] = what[i * 2];
581 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
584 /* Top and bottom rows */
585 for (x = xval - 9; x <= xval + 9; x++)
587 place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
588 place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
592 for (y = yval - 1; y <= yval + 1; y++)
594 place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
595 place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
597 place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
598 place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
600 place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
601 place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
603 place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
604 place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
606 place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
607 place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
609 place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
610 place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
612 place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
613 place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
615 place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
616 place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
619 /* Above/Below the center monster */
620 for (x = xval - 1; x <= xval + 1; x++)
622 place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
623 place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
626 /* Next to the center monster */
627 place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
628 place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
631 place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
638 * todo vault_monster_okay() をmonsterrace-hook以外から呼んでいるのはここだけなので、何とかしたい
639 * Helper function for "trapped monster pit"
641 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
643 monster_race *r_ptr = &r_info[r_idx];
645 if (!vault_monster_okay(r_idx)) return FALSE;
647 /* No wall passing monster */
648 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
655 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
658 * A trapped monster pit is a "big" room with a straight corridor in\n
659 * which wall opening traps are placed, and with two "inner" rooms\n
660 * containing a "collection" of monsters of a given type organized in\n
663 * The trapped monster pit appears as shown below, where the actual\n
664 * monsters in each location depend on the type of the pit\n
666 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
668 * XXXXXXXXXXXXXXXXXXXXXXX X\n
669 * XXXXX001123454321100XXX X\n
670 * XXX0012234567654322100X X\n
671 * XXXXXXXXXXXXXXXXXXXXXXX X\n
673 * X XXXXXXXXXXXXXXXXXXXXXXX\n
674 * X X0012234567654322100XXX\n
675 * X XXX001123454321100XXXXX\n
676 * X XXXXXXXXXXXXXXXXXXXXXXX\n
678 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
680 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
681 * to request 16 "appropriate" monsters, sorting them by level, and using\n
682 * the "even" entries in this sorted list for the contents of the pit.\n
684 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
685 * which is handled by requiring a specific "breath" attack for all of the\n
686 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
687 * be present in many of the dragon pits, if they have the proper breath.\n
689 * Note the use of the "get_mon_num_prep()" function, and the special\n
690 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
691 * allocation table" in such a way as to optimize the selection of\n
692 * "appropriate" non-unique monsters for the pit.\n
694 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
695 * the pit will be empty.\n
697 * Note that "monster pits" will never contain "unique" monsters.\n
699 bool build_type13(player_type *player_ptr)
701 POSITION y, x, y1, x1, y2, x2, xval, yval;
704 MONRACE_IDX what[16];
710 floor_type *floor_ptr = player_ptr->current_floor_ptr;
711 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
712 vault_aux_type *n_ptr;
714 /* Only in Angband */
715 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
717 /* No type available */
718 if (cur_pit_type < 0) return FALSE;
720 n_ptr = &pit_types[cur_pit_type];
722 /* Process a preparation function if necessary */
723 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
724 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
726 align.sub_align = SUB_ALIGN_NEUTRAL;
728 /* Pick some monster types */
729 for (i = 0; i < 16; i++)
731 MONRACE_IDX r_idx = 0;
733 monster_race *r_ptr = NULL;
737 /* Get a (hard) monster type */
738 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0, 0);
739 r_ptr = &r_info[r_idx];
741 /* Decline incorrect alignment */
742 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
744 /* Accept this monster */
749 if (!r_idx || !attempts) return FALSE;
751 /* Note the alignment */
752 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
753 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
758 /* Find and reserve some space in the dungeon. Get center of room. */
759 if (!find_space(player_ptr, &yval, &xval, 13, 25)) return FALSE;
767 /* Fill with inner walls */
768 for (y = y1 - 1; y <= y2 + 1; y++)
770 for (x = x1 - 1; x <= x2 + 1; x++)
772 g_ptr = &floor_ptr->grid_array[y][x];
773 place_grid(player_ptr, g_ptr, GB_INNER);
774 g_ptr->info |= (CAVE_ROOM);
778 /* Place the floor area 1 */
779 for (x = x1 + 3; x <= x2 - 3; x++)
781 g_ptr = &floor_ptr->grid_array[yval - 2][x];
782 place_grid(player_ptr, g_ptr, GB_FLOOR);
783 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
785 g_ptr = &floor_ptr->grid_array[yval + 2][x];
786 place_grid(player_ptr, g_ptr, GB_FLOOR);
787 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
790 /* Place the floor area 2 */
791 for (x = x1 + 5; x <= x2 - 5; x++)
793 g_ptr = &floor_ptr->grid_array[yval - 3][x];
794 place_grid(player_ptr, g_ptr, GB_FLOOR);
795 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
797 g_ptr = &floor_ptr->grid_array[yval + 3][x];
798 place_grid(player_ptr, g_ptr, GB_FLOOR);
799 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
803 for (x = x1; x <= x2; x++)
805 g_ptr = &floor_ptr->grid_array[yval][x];
806 place_grid(player_ptr, g_ptr, GB_FLOOR);
807 g_ptr = &floor_ptr->grid_array[y1][x];
808 place_grid(player_ptr, g_ptr, GB_FLOOR);
809 g_ptr = &floor_ptr->grid_array[y2][x];
810 place_grid(player_ptr, g_ptr, GB_FLOOR);
813 /* Place the outer walls */
814 for (y = y1 - 1; y <= y2 + 1; y++)
816 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
817 place_grid(player_ptr, g_ptr, GB_OUTER);
818 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
819 place_grid(player_ptr, g_ptr, GB_OUTER);
821 for (x = x1 - 1; x <= x2 + 1; x++)
823 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
824 place_grid(player_ptr, g_ptr, GB_OUTER);
825 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
826 place_grid(player_ptr, g_ptr, GB_OUTER);
829 /* Random corridor */
832 for (y = y1; y <= yval; y++)
834 place_bold(player_ptr, y, x2, GB_FLOOR);
835 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
837 for (y = yval; y <= y2 + 1; y++)
839 place_bold(player_ptr, y, x1, GB_FLOOR);
840 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
845 for (y = yval; y <= y2 + 1; y++)
847 place_bold(player_ptr, y, x1, GB_FLOOR);
848 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
850 for (y = y1; y <= yval; y++)
852 place_bold(player_ptr, y, x2, GB_FLOOR);
853 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
857 /* Place the wall open trap */
858 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
859 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
861 /* Sort the entries */
862 for (i = 0; i < 16 - 1; i++)
864 /* Sort the entries */
865 for (j = 0; j < 16 - 1; j++)
870 int p1 = r_info[what[i1]].level;
871 int p2 = r_info[what[i2]].level;
876 MONRACE_IDX tmp = what[i1];
883 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
884 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
886 /* Select the entries */
887 for (i = 0; i < 8; i++)
889 /* Every other entry */
890 what[i] = what[i * 2];
894 msg_print(r_name + r_info[what[i]].name);
898 for (i = 0; placing[i][2] >= 0; i++)
900 y = yval + placing[i][0];
901 x = xval + placing[i][1];
902 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);