1 #include "room/rooms-pit-nest.h"
2 #include "dungeon/dungeon.h"
3 #include "floor/floor-generate.h"
4 #include "floor/floor.h"
5 #include "game-option/cheat-options.h"
6 #include "game-option/cheat-types.h"
7 #include "grid/feature.h"
9 #include "monster-floor/monster-generator.h"
10 #include "monster-floor/place-monster-types.h"
11 #include "monster-race/monster-race-hook.h"
12 #include "monster-race/monster-race.h"
13 #include "monster-race/race-flags-resistance.h"
14 #include "monster-race/race-flags1.h"
15 #include "monster-race/race-flags2.h"
16 #include "monster-race/race-flags3.h"
17 #include "monster-race/race-flags4.h"
18 #include "monster-race/race-flags7.h"
19 #include "monster/monster-info.h"
20 #include "monster/monster-list.h"
21 #include "monster/monster-util.h"
22 #include "room/pit-nest-kinds-table.h"
24 #include "util/sort.h"
25 #include "view/display-messages.h"
26 #include "wizard/wizard-messages.h"
29 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
30 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
31 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
32 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
34 static int pick_vault_type(floor_type *floor_ptr, vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
36 int tmp, total, count;
38 vault_aux_type *n_ptr;
40 /* Calculate the total possibilities */
41 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
44 if (!n_ptr->name) break;
46 /* Ignore excessive depth */
47 if (n_ptr->level > floor_ptr->dun_level) continue;
49 /* Not matched with pit/nest flag */
50 if (!(allow_flag_mask & (1L << count))) continue;
52 /* Count this possibility */
53 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
56 /* Pick a random type */
57 tmp = randint0(total);
60 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
63 if (!n_ptr->name) break;
65 /* Ignore excessive depth */
66 if (n_ptr->level > floor_ptr->dun_level) continue;
68 /* Not matched with pit/nest flag */
69 if (!(allow_flag_mask & (1L << count))) continue;
71 /* Count this possibility */
72 total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
75 if (tmp < total) break;
78 return n_ptr->name ? count : -1;
83 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
84 * @param type pit/nestの型ID
85 * @param nest TRUEならばnest、FALSEならばpit
86 * @return デバッグ表示文字列の参照ポインタ
88 * Hack -- Get the string describing subtype of pit/nest
89 * Determined in prepare function (some pit/nest only)
91 static concptr pit_subtype_string(int type, bool nest)
93 static char inner_buf[256] = "";
95 inner_buf[0] = '\0'; /* Init string */
101 case NEST_TYPE_CLONE:
102 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
104 case NEST_TYPE_SYMBOL_GOOD:
105 case NEST_TYPE_SYMBOL_EVIL:
106 sprintf(inner_buf, "(%c)", vault_aux_char);
114 case PIT_TYPE_SYMBOL_GOOD:
115 case PIT_TYPE_SYMBOL_EVIL:
116 sprintf(inner_buf, "(%c)", vault_aux_char);
118 case PIT_TYPE_DRAGON:
119 switch (vault_aux_dragon_mask4)
121 case RF4_BR_ACID: strcpy(inner_buf, _("(酸)", "(acid)")); break;
122 case RF4_BR_ELEC: strcpy(inner_buf, _("(稲妻)", "(lightning)")); break;
123 case RF4_BR_FIRE: strcpy(inner_buf, _("(火炎)", "(fire)")); break;
124 case RF4_BR_COLD: strcpy(inner_buf, _("(冷気)", "(frost)")); break;
125 case RF4_BR_POIS: strcpy(inner_buf, _("(毒)", "(poison)")); break;
126 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS) :
127 strcpy(inner_buf, _("(万色)", "(multi-hued)")); break;
128 default: strcpy(inner_buf, _("(未定義)", "(undefined)")); break;
139 *! @brief nestのモンスターリストをソートするための関数 /
140 * Comp function for sorting nest monster information
141 * @param u ソート処理対象配列ポインタ
147 static bool ang_sort_comp_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
153 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
154 MONSTER_IDX w1 = nest_mon_info[a].r_idx;
155 MONSTER_IDX w2 = nest_mon_info[b].r_idx;
156 monster_race *r1_ptr = &r_info[w1];
157 monster_race *r2_ptr = &r_info[w2];
160 /* Extract used info */
161 z1 = nest_mon_info[a].used;
162 z2 = nest_mon_info[b].used;
164 /* Compare used status */
165 if (z1 < z2) return FALSE;
166 if (z1 > z2) return TRUE;
169 if (r1_ptr->level < r2_ptr->level) return TRUE;
170 if (r1_ptr->level > r2_ptr->level) return FALSE;
172 /* Compare experience */
173 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
174 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
176 /* Compare indexes */
182 * @brief nestのモンスターリストをスワップするための関数 /
183 * Swap function for sorting nest monster information
184 * @param u スワップ処理対象配列ポインタ
186 * @param a スワップ対象参照ID1
187 * @param b スワップ対象参照ID2
190 static void ang_sort_swap_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
196 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
197 nest_mon_info_type holder;
200 holder = nest_mon_info[a];
201 nest_mon_info[a] = nest_mon_info[b];
202 nest_mon_info[b] = holder;
207 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
208 * @param player_ptr プレーヤーへの参照ポインタ
211 * A monster nest is a "big" room, with an "inner" room, containing\n
212 * a "collection" of monsters of a given type strewn about the room.\n
214 * The monsters are chosen from a set of 64 randomly selected monster\n
215 * races, to allow the nest creation to fail instead of having "holes".\n
217 * Note the use of the "get_mon_num_prep()" function, and the special\n
218 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
219 * allocation table" in such a way as to optimize the selection of\n
220 * "appropriate" non-unique monsters for the nest.\n
222 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
223 * case the nest will be empty.\n
225 * Note that "monster nests" will never contain "unique" monsters.\n
227 bool build_type5(player_type *player_ptr)
229 POSITION y, x, y1, x1, y2, x2, xval, yval;
231 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
237 floor_type *floor_ptr = player_ptr->current_floor_ptr;
238 int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
239 vault_aux_type *n_ptr;
241 /* No type available */
242 if (cur_nest_type < 0) return FALSE;
244 n_ptr = &nest_types[cur_nest_type];
246 /* Process a preparation function if necessary */
247 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
248 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
250 align.sub_align = SUB_ALIGN_NEUTRAL;
252 /* Pick some monster types */
253 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
255 MONRACE_IDX r_idx = 0;
257 monster_race *r_ptr = NULL;
261 /* Get a (hard) monster type */
262 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
263 r_ptr = &r_info[r_idx];
265 /* Decline incorrect alignment */
266 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
268 /* Accept this monster */
273 if (!r_idx || !attempts) return FALSE;
275 /* Note the alignment */
276 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
277 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
279 nest_mon_info[i].r_idx = (s16b)r_idx;
280 nest_mon_info[i].used = FALSE;
283 /* Find and reserve some space in the dungeon. Get center of room. */
284 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
292 /* Place the floor area */
293 for (y = y1 - 1; y <= y2 + 1; y++)
295 for (x = x1 - 1; x <= x2 + 1; x++)
297 g_ptr = &floor_ptr->grid_array[y][x];
298 place_grid(player_ptr, g_ptr, GB_FLOOR);
299 g_ptr->info |= (CAVE_ROOM);
303 /* Place the outer walls */
304 for (y = y1 - 1; y <= y2 + 1; y++)
306 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
307 place_grid(player_ptr, g_ptr, GB_OUTER);
308 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
309 place_grid(player_ptr, g_ptr, GB_OUTER);
311 for (x = x1 - 1; x <= x2 + 1; x++)
313 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
314 place_grid(player_ptr, g_ptr, GB_OUTER);
315 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
316 place_grid(player_ptr, g_ptr, GB_OUTER);
320 /* Advance to the center room */
326 /* The inner walls */
327 for (y = y1 - 1; y <= y2 + 1; y++)
329 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
330 place_grid(player_ptr, g_ptr, GB_INNER);
331 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
332 place_grid(player_ptr, g_ptr, GB_INNER);
335 for (x = x1 - 1; x <= x2 + 1; x++)
337 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
338 place_grid(player_ptr, g_ptr, GB_INNER);
339 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
340 place_grid(player_ptr, g_ptr, GB_INNER);
342 for (y = y1; y <= y2; y++)
344 for (x = x1; x <= x2; x++)
346 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
350 /* Place a secret door */
353 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
354 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
355 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
356 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
359 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
361 /* Place some monsters */
362 for (y = yval - 2; y <= yval + 2; y++)
364 for (x = xval - 9; x <= xval + 9; x++)
368 i = randint0(NUM_NEST_MON_TYPE);
369 r_idx = nest_mon_info[i].r_idx;
371 /* Place that "random" monster (no groups) */
372 (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
374 nest_mon_info[i].used = TRUE;
380 ang_sort(player_ptr, nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
382 /* Dump the entries (prevent multi-printing) */
383 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
385 if (!nest_mon_info[i].used) break;
386 for (; i < NUM_NEST_MON_TYPE - 1; i++)
388 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
389 if (!nest_mon_info[i + 1].used) break;
392 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
401 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
404 * A monster pit is a "big" room, with an "inner" room, containing\n
405 * a "collection" of monsters of a given type organized in the room.\n
407 * The inside room in a monster pit appears as shown below, where the\n
408 * actual monsters in each location depend on the type of the pit\n
410 * XXXXXXXXXXXXXXXXXXXXX\n
411 * X0000000000000000000X\n
412 * X0112233455543322110X\n
413 * X0112233467643322110X\n
414 * X0112233455543322110X\n
415 * X0000000000000000000X\n
416 * XXXXXXXXXXXXXXXXXXXXX\n
418 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
419 * to request 16 "appropriate" monsters, sorting them by level, and using\n
420 * the "even" entries in this sorted list for the contents of the pit.\n
422 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
423 * which is handled by requiring a specific "breath" attack for all of the\n
424 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
425 * be present in many of the dragon pits, if they have the proper breath.\n
427 * Note the use of the "get_mon_num_prep()" function, and the special\n
428 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
429 * allocation table" in such a way as to optimize the selection of\n
430 * "appropriate" non-unique monsters for the pit.\n
432 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
433 * the pit will be empty.\n
435 * Note that "monster pits" will never contain "unique" monsters.\n
437 bool build_type6(player_type *player_ptr)
439 POSITION y, x, y1, x1, y2, x2, xval, yval;
442 MONRACE_IDX what[16];
448 floor_type *floor_ptr = player_ptr->current_floor_ptr;
449 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
450 vault_aux_type *n_ptr;
452 /* No type available */
453 if (cur_pit_type < 0) return FALSE;
455 n_ptr = &pit_types[cur_pit_type];
457 /* Process a preparation function if necessary */
458 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
459 get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
461 align.sub_align = SUB_ALIGN_NEUTRAL;
463 /* Pick some monster types */
464 for (i = 0; i < 16; i++)
466 MONRACE_IDX r_idx = 0;
468 monster_race *r_ptr = NULL;
472 /* Get a (hard) monster type */
473 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11, 0);
474 r_ptr = &r_info[r_idx];
476 /* Decline incorrect alignment */
477 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
479 /* Accept this monster */
484 if (!r_idx || !attempts) return FALSE;
486 /* Note the alignment */
487 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
488 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
493 /* Find and reserve some space in the dungeon. Get center of room. */
494 if (!find_space(player_ptr, &yval, &xval, 11, 25)) return FALSE;
502 /* Place the floor area */
503 for (y = y1 - 1; y <= y2 + 1; y++)
505 for (x = x1 - 1; x <= x2 + 1; x++)
507 g_ptr = &floor_ptr->grid_array[y][x];
508 place_grid(player_ptr, g_ptr, GB_FLOOR);
509 g_ptr->info |= (CAVE_ROOM);
513 /* Place the outer walls */
514 for (y = y1 - 1; y <= y2 + 1; y++)
516 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
517 place_grid(player_ptr, g_ptr, GB_OUTER);
518 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
519 place_grid(player_ptr, g_ptr, GB_OUTER);
521 for (x = x1 - 1; x <= x2 + 1; x++)
523 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
524 place_grid(player_ptr, g_ptr, GB_OUTER);
525 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
526 place_grid(player_ptr, g_ptr, GB_OUTER);
529 /* Advance to the center room */
535 /* The inner walls */
536 for (y = y1 - 1; y <= y2 + 1; y++)
538 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
539 place_grid(player_ptr, g_ptr, GB_INNER);
540 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
541 place_grid(player_ptr, g_ptr, GB_INNER);
543 for (x = x1 - 1; x <= x2 + 1; x++)
545 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
546 place_grid(player_ptr, g_ptr, GB_INNER);
547 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
548 place_grid(player_ptr, g_ptr, GB_INNER);
550 for (y = y1; y <= y2; y++)
552 for (x = x1; x <= x2; x++)
554 add_cave_info(floor_ptr, y, x, CAVE_ICKY);
558 /* Place a secret door */
561 case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
562 case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
563 case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
564 case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
567 /* Sort the entries */
568 for (i = 0; i < 16 - 1; i++)
570 /* Sort the entries */
571 for (j = 0; j < 16 - 1; j++)
576 int p1 = r_info[what[i1]].level;
577 int p2 = r_info[what[i2]].level;
582 MONRACE_IDX tmp = what[i1];
589 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
591 /* Select the entries */
592 for (i = 0; i < 8; i++)
594 /* Every other entry */
595 what[i] = what[i * 2];
596 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
599 /* Top and bottom rows */
600 for (x = xval - 9; x <= xval + 9; x++)
602 place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
603 place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
607 for (y = yval - 1; y <= yval + 1; y++)
609 place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
610 place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
612 place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
613 place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
615 place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
616 place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
618 place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
619 place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
621 place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
622 place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
624 place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
625 place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
627 place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
628 place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
630 place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
631 place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
634 /* Above/Below the center monster */
635 for (x = xval - 1; x <= xval + 1; x++)
637 place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
638 place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
641 /* Next to the center monster */
642 place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
643 place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
646 place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
652 * Helper function for "trapped monster pit"
654 static bool vault_aux_trapped_pit(player_type *player_ptr, MONRACE_IDX r_idx)
659 monster_race *r_ptr = &r_info[r_idx];
661 if (!vault_monster_okay(player_ptr, r_idx)) return FALSE;
663 /* No wall passing monster */
664 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
671 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
674 * A trapped monster pit is a "big" room with a straight corridor in\n
675 * which wall opening traps are placed, and with two "inner" rooms\n
676 * containing a "collection" of monsters of a given type organized in\n
679 * The trapped monster pit appears as shown below, where the actual\n
680 * monsters in each location depend on the type of the pit\n
682 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
684 * XXXXXXXXXXXXXXXXXXXXXXX X\n
685 * XXXXX001123454321100XXX X\n
686 * XXX0012234567654322100X X\n
687 * XXXXXXXXXXXXXXXXXXXXXXX X\n
689 * X XXXXXXXXXXXXXXXXXXXXXXX\n
690 * X X0012234567654322100XXX\n
691 * X XXX001123454321100XXXXX\n
692 * X XXXXXXXXXXXXXXXXXXXXXXX\n
694 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
696 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
697 * to request 16 "appropriate" monsters, sorting them by level, and using\n
698 * the "even" entries in this sorted list for the contents of the pit.\n
700 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
701 * which is handled by requiring a specific "breath" attack for all of the\n
702 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
703 * be present in many of the dragon pits, if they have the proper breath.\n
705 * Note the use of the "get_mon_num_prep()" function, and the special\n
706 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
707 * allocation table" in such a way as to optimize the selection of\n
708 * "appropriate" non-unique monsters for the pit.\n
710 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
711 * the pit will be empty.\n
713 * Note that "monster pits" will never contain "unique" monsters.\n
715 bool build_type13(player_type *player_ptr)
717 POSITION y, x, y1, x1, y2, x2, xval, yval;
720 MONRACE_IDX what[16];
726 floor_type *floor_ptr = player_ptr->current_floor_ptr;
727 int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
728 vault_aux_type *n_ptr;
730 /* Only in Angband */
731 if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
733 /* No type available */
734 if (cur_pit_type < 0) return FALSE;
736 n_ptr = &pit_types[cur_pit_type];
738 /* Process a preparation function if necessary */
739 if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
740 get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
742 align.sub_align = SUB_ALIGN_NEUTRAL;
744 /* Pick some monster types */
745 for (i = 0; i < 16; i++)
747 MONRACE_IDX r_idx = 0;
749 monster_race *r_ptr = NULL;
753 /* Get a (hard) monster type */
754 r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0, 0);
755 r_ptr = &r_info[r_idx];
757 /* Decline incorrect alignment */
758 if (monster_has_hostile_align(player_ptr, &align, 0, 0, r_ptr)) continue;
760 /* Accept this monster */
765 if (!r_idx || !attempts) return FALSE;
767 /* Note the alignment */
768 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
769 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
774 /* Find and reserve some space in the dungeon. Get center of room. */
775 if (!find_space(player_ptr, &yval, &xval, 13, 25)) return FALSE;
783 /* Fill with inner walls */
784 for (y = y1 - 1; y <= y2 + 1; y++)
786 for (x = x1 - 1; x <= x2 + 1; x++)
788 g_ptr = &floor_ptr->grid_array[y][x];
789 place_grid(player_ptr, g_ptr, GB_INNER);
790 g_ptr->info |= (CAVE_ROOM);
794 /* Place the floor area 1 */
795 for (x = x1 + 3; x <= x2 - 3; x++)
797 g_ptr = &floor_ptr->grid_array[yval - 2][x];
798 place_grid(player_ptr, g_ptr, GB_FLOOR);
799 add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
801 g_ptr = &floor_ptr->grid_array[yval + 2][x];
802 place_grid(player_ptr, g_ptr, GB_FLOOR);
803 add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
806 /* Place the floor area 2 */
807 for (x = x1 + 5; x <= x2 - 5; x++)
809 g_ptr = &floor_ptr->grid_array[yval - 3][x];
810 place_grid(player_ptr, g_ptr, GB_FLOOR);
811 add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
813 g_ptr = &floor_ptr->grid_array[yval + 3][x];
814 place_grid(player_ptr, g_ptr, GB_FLOOR);
815 add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
819 for (x = x1; x <= x2; x++)
821 g_ptr = &floor_ptr->grid_array[yval][x];
822 place_grid(player_ptr, g_ptr, GB_FLOOR);
823 g_ptr = &floor_ptr->grid_array[y1][x];
824 place_grid(player_ptr, g_ptr, GB_FLOOR);
825 g_ptr = &floor_ptr->grid_array[y2][x];
826 place_grid(player_ptr, g_ptr, GB_FLOOR);
829 /* Place the outer walls */
830 for (y = y1 - 1; y <= y2 + 1; y++)
832 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
833 place_grid(player_ptr, g_ptr, GB_OUTER);
834 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
835 place_grid(player_ptr, g_ptr, GB_OUTER);
837 for (x = x1 - 1; x <= x2 + 1; x++)
839 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
840 place_grid(player_ptr, g_ptr, GB_OUTER);
841 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
842 place_grid(player_ptr, g_ptr, GB_OUTER);
845 /* Random corridor */
848 for (y = y1; y <= yval; y++)
850 place_bold(player_ptr, y, x2, GB_FLOOR);
851 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
853 for (y = yval; y <= y2 + 1; y++)
855 place_bold(player_ptr, y, x1, GB_FLOOR);
856 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
861 for (y = yval; y <= y2 + 1; y++)
863 place_bold(player_ptr, y, x1, GB_FLOOR);
864 place_bold(player_ptr, y, x2 + 1, GB_SOLID);
866 for (y = y1; y <= yval; y++)
868 place_bold(player_ptr, y, x2, GB_FLOOR);
869 place_bold(player_ptr, y, x1 - 1, GB_SOLID);
873 /* Place the wall open trap */
874 floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
875 floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
877 /* Sort the entries */
878 for (i = 0; i < 16 - 1; i++)
880 /* Sort the entries */
881 for (j = 0; j < 16 - 1; j++)
886 int p1 = r_info[what[i1]].level;
887 int p2 = r_info[what[i2]].level;
892 MONRACE_IDX tmp = what[i1];
899 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
900 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
902 /* Select the entries */
903 for (i = 0; i < 8; i++)
905 /* Every other entry */
906 what[i] = what[i * 2];
910 msg_print(r_name + r_info[what[i]].name);
914 for (i = 0; placing[i][2] >= 0; i++)
916 y = yval + placing[i][0];
917 x = xval + placing[i][1];
918 place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);