OSDN Git Service

[Refactor] #2712 Renamed enum FloorFeatureType to TerrainCharacteristics
[hengbandforosx/hengbandosx.git] / src / grid / trap.cpp
1 #include "grid/trap.h"
2 #include "cmd-io/cmd-dump.h"
3 #include "cmd-io/cmd-save.h"
4 #include "core/disturbance.h"
5 #include "dungeon/quest.h"
6 #include "effect/effect-characteristics.h"
7 #include "effect/effect-processor.h"
8 #include "floor/cave.h"
9 #include "floor/floor-mode-changer.h"
10 #include "game-option/birth-options.h"
11 #include "game-option/special-options.h"
12 #include "grid/feature.h"
13 #include "grid/grid.h"
14 #include "info-reader/feature-reader.h"
15 #include "io/files-util.h"
16 #include "io/write-diary.h"
17 #include "main/sound-definitions-table.h"
18 #include "main/sound-of-music.h"
19 #include "mind/mind-mirror-master.h"
20 #include "monster-floor/monster-summon.h"
21 #include "monster-floor/place-monster-types.h"
22 #include "monster/monster-util.h"
23 #include "player-info/class-info.h"
24 #include "player/eldritch-horror.h"
25 #include "player/player-damage.h"
26 #include "player/player-personality-types.h"
27 #include "player/player-status-flags.h"
28 #include "player/player-status.h"
29 #include "spell-kind/spells-launcher.h"
30 #include "spell-kind/spells-random.h"
31 #include "spell-kind/spells-sight.h"
32 #include "spell-kind/spells-teleport.h"
33 #include "spell/summon-types.h"
34 #include "status/bad-status-setter.h"
35 #include "status/base-status.h"
36 #include "status/element-resistance.h"
37 #include "system/dungeon-info.h"
38 #include "system/floor-type-definition.h"
39 #include "system/grid-type-definition.h"
40 #include "system/monster-type-definition.h"
41 #include "system/player-type-definition.h"
42 #include "target/projection-path-calculator.h"
43 #include "timed-effect/player-cut.h"
44 #include "timed-effect/timed-effects.h"
45 #include "util/enum-converter.h"
46 #include "view/display-messages.h"
47 #include "world/world.h"
48
49 static std::vector<int16_t> normal_traps;
50
51 /*!
52  * @brief 箱のトラップテーブル
53  * @details
54  * <pre>
55  * Each chest has a certain set of traps, determined by pval
56  * Each chest has a "pval" from 1 to the chest level (max 55)
57  * If the "pval" is negative then the trap has been disarmed
58  * The "pval" of a chest determines the quality of its treasure
59  * Note that disarming a trap on a chest also removes the lock.
60  * </pre>
61  */
62 const std::vector<EnumClassFlagGroup<ChestTrapType>> chest_traps = {
63     {}, /* empty */
64     { ChestTrapType::POISON },
65     { ChestTrapType::LOSE_STR },
66     { ChestTrapType::LOSE_CON },
67     { ChestTrapType::LOSE_STR },
68     { ChestTrapType::LOSE_CON }, /* 5 == best small wooden */
69     {},
70     { ChestTrapType::ALARM },
71     { ChestTrapType::ALARM },
72     { ChestTrapType::LOSE_STR },
73     { ChestTrapType::LOSE_CON },
74     { ChestTrapType::POISON },
75     { ChestTrapType::SCATTER },
76     { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
77     { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
78     { ChestTrapType::SUMMON }, /* 15 == best large wooden */
79     {},
80     { ChestTrapType::ALARM },
81     { ChestTrapType::SCATTER },
82     { ChestTrapType::PARALYZE },
83     { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
84     { ChestTrapType::SUMMON },
85     { ChestTrapType::PARALYZE },
86     { ChestTrapType::LOSE_STR },
87     { ChestTrapType::LOSE_CON },
88     { ChestTrapType::EXPLODE }, /* 25 == best small iron */
89     {},
90     { ChestTrapType::E_SUMMON },
91     { ChestTrapType::POISON, ChestTrapType::LOSE_CON },
92     { ChestTrapType::LOSE_STR, ChestTrapType::LOSE_CON },
93     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
94     { ChestTrapType::BIRD_STORM },
95     { ChestTrapType::POISON, ChestTrapType::SUMMON },
96     { ChestTrapType::E_SUMMON, ChestTrapType::ALARM },
97     { ChestTrapType::EXPLODE },
98     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON }, /* 35 == best large iron */
99     {},
100     { ChestTrapType::SUMMON, ChestTrapType::ALARM },
101     { ChestTrapType::EXPLODE },
102     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
103     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
104     { ChestTrapType::POISON, ChestTrapType::PARALYZE },
105     { ChestTrapType::EXPLODE },
106     { ChestTrapType::BIRD_STORM },
107     { ChestTrapType::EXPLODE, ChestTrapType::E_SUMMON, ChestTrapType::ALARM },
108     { ChestTrapType::H_SUMMON }, /* 45 == best small steel */
109     {},
110     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON, ChestTrapType::ALARM },
111     { ChestTrapType::BIRD_STORM },
112     { ChestTrapType::RUNES_OF_EVIL },
113     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON, ChestTrapType::ALARM },
114     { ChestTrapType::BIRD_STORM, ChestTrapType::ALARM },
115     { ChestTrapType::H_SUMMON, ChestTrapType::ALARM },
116     { ChestTrapType::RUNES_OF_EVIL },
117     { ChestTrapType::H_SUMMON, ChestTrapType::SCATTER, ChestTrapType::ALARM },
118     { ChestTrapType::RUNES_OF_EVIL, ChestTrapType::EXPLODE }, /* 55 == best large steel */
119     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
120     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
121     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
122     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
123     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
124     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
125     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
126     { ChestTrapType::EXPLODE, ChestTrapType::SUMMON },
127 };
128
129 /*!
130  * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
131  */
132 void init_normal_traps(void)
133 {
134     normal_traps.push_back(f_tag_to_index_in_init("TRAP_TRAPDOOR"));
135     normal_traps.push_back(f_tag_to_index_in_init("TRAP_PIT"));
136     normal_traps.push_back(f_tag_to_index_in_init("TRAP_SPIKED_PIT"));
137     normal_traps.push_back(f_tag_to_index_in_init("TRAP_POISON_PIT"));
138     normal_traps.push_back(f_tag_to_index_in_init("TRAP_TY_CURSE"));
139     normal_traps.push_back(f_tag_to_index_in_init("TRAP_TELEPORT"));
140     normal_traps.push_back(f_tag_to_index_in_init("TRAP_FIRE"));
141     normal_traps.push_back(f_tag_to_index_in_init("TRAP_ACID"));
142     normal_traps.push_back(f_tag_to_index_in_init("TRAP_SLOW"));
143     normal_traps.push_back(f_tag_to_index_in_init("TRAP_LOSE_STR"));
144     normal_traps.push_back(f_tag_to_index_in_init("TRAP_LOSE_DEX"));
145     normal_traps.push_back(f_tag_to_index_in_init("TRAP_LOSE_CON"));
146     normal_traps.push_back(f_tag_to_index_in_init("TRAP_BLIND"));
147     normal_traps.push_back(f_tag_to_index_in_init("TRAP_CONFUSE"));
148     normal_traps.push_back(f_tag_to_index_in_init("TRAP_POISON"));
149     normal_traps.push_back(f_tag_to_index_in_init("TRAP_SLEEP"));
150     normal_traps.push_back(f_tag_to_index_in_init("TRAP_TRAPS"));
151     normal_traps.push_back(f_tag_to_index_in_init("TRAP_ALARM"));
152 }
153
154 /*!
155  * @brief 基本トラップをランダムに選択する /
156  * Get random trap
157  * @return 選択したトラップのID
158  * @details
159  * This routine should be redone to reflect trap "level".\n
160  * That is, it does not make sense to have spiked pits at 50 feet.\n
161  * Actually, it is not this routine, but the "trap instantiation"\n
162  * code, which should also check for "trap doors" on quest levels.\n
163  */
164 FEAT_IDX choose_random_trap(PlayerType *player_ptr)
165 {
166     FEAT_IDX feat;
167
168     /* Pick a trap */
169     auto *floor_ptr = player_ptr->current_floor_ptr;
170     while (true) {
171         feat = normal_traps[randint0(normal_traps.size())];
172
173         /* Accept non-trapdoors */
174         if (terrains_info[feat].flags.has_not(TerrainCharacteristics::MORE)) {
175             break;
176         }
177
178         /* Hack -- no trap doors on special levels */
179         if (floor_ptr->inside_arena || inside_quest(quest_number(player_ptr, floor_ptr->dun_level))) {
180             continue;
181         }
182
183         /* Hack -- no trap doors on the deepest level */
184         if (floor_ptr->dun_level >= dungeons_info[floor_ptr->dungeon_idx].maxdepth) {
185             continue;
186         }
187
188         break;
189     }
190
191     return feat;
192 }
193
194 /*!
195  * @brief マスに存在する隠しトラップを公開する /
196  * Disclose an invisible trap
197  * @param player
198  * @param y 秘匿したいマスのY座標
199  * @param x 秘匿したいマスのX座標
200  */
201 void disclose_grid(PlayerType *player_ptr, POSITION y, POSITION x)
202 {
203     auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
204
205     if (g_ptr->cave_has_flag(TerrainCharacteristics::SECRET)) {
206         /* No longer hidden */
207         cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::SECRET);
208     } else if (g_ptr->mimic) {
209         /* No longer hidden */
210         g_ptr->mimic = 0;
211
212         note_spot(player_ptr, y, x);
213         lite_spot(player_ptr, y, x);
214     }
215 }
216
217 /*!
218  * @brief マスをトラップを配置する /
219  * The location must be a legal, naked, floor grid.
220  * @param y 配置したいマスのY座標
221  * @param x 配置したいマスのX座標
222  * @return
223  * Note that all traps start out as "invisible" and "untyped", and then\n
224  * when they are "discovered" (by detecting them or setting them off),\n
225  * the trap is "instantiated" as a visible, "typed", trap.\n
226  */
227 void place_trap(PlayerType *player_ptr, POSITION y, POSITION x)
228 {
229     auto *floor_ptr = player_ptr->current_floor_ptr;
230     auto *g_ptr = &floor_ptr->grid_array[y][x];
231
232     /* Paranoia -- verify location */
233     if (!in_bounds(floor_ptr, y, x)) {
234         return;
235     }
236
237     /* Require empty, clean, floor grid */
238     if (!cave_clean_bold(floor_ptr, y, x)) {
239         return;
240     }
241
242     /* Place an invisible trap */
243     g_ptr->mimic = g_ptr->feat;
244     g_ptr->feat = choose_random_trap(player_ptr);
245 }
246
247 /*!
248  * @brief プレイヤーへのトラップ命中判定 /
249  * Determine if a trap affects the player.
250  * @param power 基本回避難度
251  * @return トラップが命中した場合TRUEを返す。
252  * @details
253  * Always miss 5% of the time, Always hit 5% of the time.
254  * Otherwise, match trap power against player armor.
255  */
256 static int check_hit_from_monster_to_player(PlayerType *player_ptr, int power)
257 {
258     int k;
259     ARMOUR_CLASS ac;
260
261     /* Percentile dice */
262     k = randint0(100);
263
264     /* Hack -- 5% hit, 5% miss */
265     if (k < 10) {
266         return k < 5;
267     }
268
269     if (player_ptr->ppersonality == PERSONALITY_LAZY) {
270         if (one_in_(20)) {
271             return true;
272         }
273     }
274
275     /* Paranoia -- No power */
276     if (power <= 0) {
277         return false;
278     }
279
280     /* Total armor */
281     ac = player_ptr->ac + player_ptr->to_a;
282
283     /* Power competes against Armor */
284     if (randint1(power) > ((ac * 3) / 4)) {
285         return true;
286     }
287
288     /* Assume miss */
289     return false;
290 }
291
292 /*!
293  * @brief 落とし穴系トラップの判定とプレイヤーの被害処理
294  * @param trap_feat_type トラップの種別ID
295  */
296 static void hit_trap_pit(PlayerType *player_ptr, TrapType trap_feat_type)
297 {
298     int dam;
299     concptr trap_name = "";
300     concptr spike_name = "";
301
302     switch (trap_feat_type) {
303     case TrapType::PIT:
304         trap_name = _("落とし穴", "a pit trap");
305         break;
306     case TrapType::SPIKED_PIT:
307         trap_name = _("スパイクが敷かれた落とし穴", "a spiked pit");
308         spike_name = _("スパイク", "spikes");
309         break;
310     case TrapType::POISON_PIT:
311         trap_name = _("スパイクが敷かれた落とし穴", "a spiked pit");
312         spike_name = _("毒を塗られたスパイク", "poisonous spikes");
313         break;
314     default:
315         return;
316     }
317
318     if (player_ptr->levitation) {
319         msg_format(_("%sを飛び越えた。", "You fly over %s."), trap_name);
320         return;
321     }
322
323     msg_format(_("%sに落ちてしまった!", "You have fallen into %s!"), trap_name);
324     dam = damroll(2, 6);
325     if (((trap_feat_type != TrapType::SPIKED_PIT) && (trap_feat_type != TrapType::POISON_PIT)) || one_in_(2)) {
326         take_hit(player_ptr, DAMAGE_NOESCAPE, dam, trap_name);
327         return;
328     }
329
330     msg_format(_("%sが刺さった!", "You are impaled on %s!"), spike_name);
331     dam = dam * 2;
332     BadStatusSetter bss(player_ptr);
333     (void)bss.mod_cut(randint1(dam));
334     if (trap_feat_type != TrapType::POISON_PIT) {
335         take_hit(player_ptr, DAMAGE_NOESCAPE, dam, trap_name);
336         return;
337     }
338
339     if (has_resist_pois(player_ptr) || is_oppose_pois(player_ptr)) {
340         msg_print(_("しかし毒の影響はなかった!", "The poison does not affect you!"));
341         take_hit(player_ptr, DAMAGE_NOESCAPE, dam, trap_name);
342         return;
343     }
344
345     dam = dam * 2;
346     (void)bss.mod_poison(randint1(dam));
347     take_hit(player_ptr, DAMAGE_NOESCAPE, dam, trap_name);
348 }
349
350 /*!
351  * @brief ダーツ系トラップ(通常ダメージ)の判定とプレイヤーの被害処理
352  * @return ダーツが命中した場合TRUEを返す
353  */
354 static bool hit_trap_dart(PlayerType *player_ptr)
355 {
356     bool hit = false;
357
358     if (check_hit_from_monster_to_player(player_ptr, 125)) {
359         msg_print(_("小さなダーツが飛んできて刺さった!", "A small dart hits you!"));
360         take_hit(player_ptr, DAMAGE_ATTACK, damroll(1, 4), _("ダーツの罠", "a dart trap"));
361         if (!check_multishadow(player_ptr)) {
362             hit = true;
363         }
364     } else {
365         msg_print(_("小さなダーツが飛んできた!が、運良く当たらなかった。", "A small dart barely misses you."));
366     }
367
368     return hit;
369 }
370
371 /*!
372  * @brief ダーツ系トラップ(通常ダメージ+能力値減少)の判定とプレイヤーの被害処理
373  * @param stat 低下する能力値ID
374  */
375 static void hit_trap_lose_stat(PlayerType *player_ptr, int stat)
376 {
377     if (hit_trap_dart(player_ptr)) {
378         do_dec_stat(player_ptr, stat);
379     }
380 }
381
382 /*!
383  * @brief ダーツ系トラップ(通常ダメージ+減速)の判定とプレイヤーの被害処理
384  */
385 static void hit_trap_slow(PlayerType *player_ptr)
386 {
387     if (hit_trap_dart(player_ptr)) {
388         (void)BadStatusSetter(player_ptr).mod_deceleration(randint0(20) + 20, false);
389     }
390 }
391
392 /*!
393  * @brief プレイヤーへのトラップ作動処理メインルーチン /
394  * Handle player hitting a real trap
395  * @param break_trap 作動後のトラップ破壊が確定しているならばTRUE
396  * @todo cmd-save.h への依存あり。コールバックで何とかしたい
397  */
398 void hit_trap(PlayerType *player_ptr, bool break_trap)
399 {
400     int i, num, dam;
401     POSITION x = player_ptr->x, y = player_ptr->y;
402     auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
403     auto *f_ptr = &terrains_info[g_ptr->feat];
404     TrapType trap_feat_type = f_ptr->flags.has(TerrainCharacteristics::TRAP) ? i2enum<TrapType>(f_ptr->subtype) : TrapType::NOT_TRAP;
405     concptr name = _("トラップ", "a trap");
406
407     disturb(player_ptr, false, true);
408
409     cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::HIT_TRAP);
410
411     /* Analyze */
412     switch (trap_feat_type) {
413     case TrapType::TRAPDOOR: {
414         if (player_ptr->levitation) {
415             msg_print(_("落とし戸を飛び越えた。", "You fly over a trap door."));
416         } else {
417             msg_print(_("落とし戸に落ちた!", "You have fallen through a trap door!"));
418             if (is_echizen(player_ptr)) {
419                 msg_print(_("くっそ~!", ""));
420             } else if (is_chargeman(player_ptr)) {
421                 msg_print(_("ジュラル星人の仕業に違いない!", ""));
422             }
423
424             sound(SOUND_FALL);
425             dam = damroll(2, 8);
426             name = _("落とし戸", "a trap door");
427
428             take_hit(player_ptr, DAMAGE_NOESCAPE, dam, name);
429
430             /* Still alive and autosave enabled */
431             if (autosave_l && (player_ptr->chp >= 0)) {
432                 do_cmd_save_game(player_ptr, true);
433             }
434
435             exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("落とし戸に落ちた", "fell through a trap door!"));
436             prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
437             player_ptr->leaving = true;
438         }
439         break;
440     }
441
442     case TrapType::PIT:
443     case TrapType::SPIKED_PIT:
444     case TrapType::POISON_PIT: {
445         hit_trap_pit(player_ptr, trap_feat_type);
446         break;
447     }
448
449     case TrapType::TY_CURSE: {
450         msg_print(_("何かがピカッと光った!", "There is a flash of shimmering light!"));
451         num = 2 + randint1(3);
452         for (i = 0; i < num; i++) {
453             (void)summon_specific(player_ptr, 0, y, x, player_ptr->current_floor_ptr->dun_level, SUMMON_NONE, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
454         }
455
456         if (player_ptr->current_floor_ptr->dun_level > randint1(100)) /* No nasty effect for low levels */
457         {
458             bool stop_ty = false;
459             int count = 0;
460
461             do {
462                 stop_ty = activate_ty_curse(player_ptr, stop_ty, &count);
463             } while (one_in_(6));
464         }
465         break;
466     }
467
468     case TrapType::TELEPORT: {
469         msg_print(_("テレポート・トラップにひっかかった!", "You hit a teleport trap!"));
470         teleport_player(player_ptr, 100, TELEPORT_PASSIVE);
471         break;
472     }
473
474     case TrapType::FIRE: {
475         msg_print(_("炎に包まれた!", "You are enveloped in flames!"));
476         dam = damroll(4, 6);
477         (void)fire_dam(player_ptr, dam, _("炎のトラップ", "a fire trap"), false);
478         break;
479     }
480
481     case TrapType::ACID: {
482         msg_print(_("酸が吹きかけられた!", "You are splashed with acid!"));
483         dam = damroll(4, 6);
484         (void)acid_dam(player_ptr, dam, _("酸のトラップ", "an acid trap"), false);
485         break;
486     }
487
488     case TrapType::SLOW: {
489         hit_trap_slow(player_ptr);
490         break;
491     }
492
493     case TrapType::LOSE_STR: {
494         hit_trap_lose_stat(player_ptr, A_STR);
495         break;
496     }
497
498     case TrapType::LOSE_DEX: {
499         hit_trap_lose_stat(player_ptr, A_DEX);
500         break;
501     }
502
503     case TrapType::LOSE_CON: {
504         hit_trap_lose_stat(player_ptr, A_CON);
505         break;
506     }
507
508     case TrapType::BLIND:
509         msg_print(_("黒いガスに包み込まれた!", "A black gas surrounds you!"));
510         if (has_resist_blind(player_ptr) == 0) {
511             (void)BadStatusSetter(player_ptr).mod_blindness(randint0(50) + 25);
512         }
513
514         break;
515     case TrapType::CONFUSE: {
516         msg_print(_("きらめくガスに包み込まれた!", "A gas of scintillating colors surrounds you!"));
517         if (has_resist_conf(player_ptr) == 0) {
518             (void)BadStatusSetter(player_ptr).mod_confusion(randint0(20) + 10);
519         }
520
521         break;
522     }
523
524     case TrapType::POISON: {
525         msg_print(_("刺激的な緑色のガスに包み込まれた!", "A pungent green gas surrounds you!"));
526         if (has_resist_pois(player_ptr) == 0) {
527             (void)BadStatusSetter(player_ptr).mod_poison(randint0(20) + 10);
528         }
529
530         break;
531     }
532
533     case TrapType::SLEEP: {
534         msg_print(_("奇妙な白い霧に包まれた!", "A strange white mist surrounds you!"));
535         if (player_ptr->free_act) {
536             break;
537         }
538
539         msg_print(_("あなたは眠りに就いた。", "You fall asleep."));
540         if (ironman_nightmare) {
541             msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
542             sanity_blast(player_ptr, nullptr, false);
543         }
544
545         (void)BadStatusSetter(player_ptr).mod_paralysis(randint0(10) + 5);
546         break;
547     }
548
549     case TrapType::TRAPS: {
550         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
551         /* Make some new traps */
552         project(player_ptr, 0, 1, y, x, 0, AttributeType::MAKE_TRAP, PROJECT_HIDE | PROJECT_JUMP | PROJECT_GRID);
553
554         break;
555     }
556
557     case TrapType::ALARM: {
558         msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!"));
559
560         aggravate_monsters(player_ptr, 0);
561
562         break;
563     }
564
565     case TrapType::OPEN: {
566         msg_print(_("大音響と共にまわりの壁が崩れた!", "Suddenly, surrounding walls are opened!"));
567         (void)project(player_ptr, 0, 3, y, x, 0, AttributeType::DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
568         (void)project(player_ptr, 0, 3, y, x - 4, 0, AttributeType::DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
569         (void)project(player_ptr, 0, 3, y, x + 4, 0, AttributeType::DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE);
570         aggravate_monsters(player_ptr, 0);
571
572         break;
573     }
574
575     case TrapType::ARMAGEDDON: {
576         static int levs[10] = { 0, 0, 20, 10, 5, 3, 2, 1, 1, 1 };
577         int evil_idx = 0, good_idx = 0;
578
579         DEPTH lev;
580         msg_print(_("突然天界の戦争に巻き込まれた!", "Suddenly, you are surrounded by immotal beings!"));
581
582         /* Summon Demons and Angels */
583         for (lev = player_ptr->current_floor_ptr->dun_level; lev >= 20; lev -= 1 + lev / 16) {
584             num = levs[std::min(lev / 10, 9)];
585             for (i = 0; i < num; i++) {
586                 POSITION x1 = rand_spread(x, 7);
587                 POSITION y1 = rand_spread(y, 5);
588
589                 if (!in_bounds(player_ptr->current_floor_ptr, y1, x1)) {
590                     continue;
591                 }
592
593                 /* Require line of projection */
594                 if (!projectable(player_ptr, player_ptr->y, player_ptr->x, y1, x1)) {
595                     continue;
596                 }
597
598                 if (summon_specific(player_ptr, 0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET))) {
599                     evil_idx = hack_m_idx_ii;
600                 }
601
602                 if (summon_specific(player_ptr, 0, y1, x1, lev, SUMMON_ARMAGE_GOOD, (PM_NO_PET))) {
603                     good_idx = hack_m_idx_ii;
604                 }
605
606                 /* Let them fight each other */
607                 if (evil_idx && good_idx) {
608                     monster_type *evil_ptr = &player_ptr->current_floor_ptr->m_list[evil_idx];
609                     monster_type *good_ptr = &player_ptr->current_floor_ptr->m_list[good_idx];
610                     evil_ptr->target_y = good_ptr->fy;
611                     evil_ptr->target_x = good_ptr->fx;
612                     good_ptr->target_y = evil_ptr->fy;
613                     good_ptr->target_x = evil_ptr->fx;
614                 }
615             }
616         }
617
618         break;
619     }
620
621     case TrapType::PIRANHA: {
622         msg_print(_("突然壁から水が溢れ出した!ピラニアがいる!", "Suddenly, the room is filled with water with piranhas!"));
623
624         /* Water fills room */
625         fire_ball_hide(player_ptr, AttributeType::WATER_FLOW, 0, 1, 10);
626
627         /* Summon Piranhas */
628         num = 1 + player_ptr->current_floor_ptr->dun_level / 20;
629         for (i = 0; i < num; i++) {
630             (void)summon_specific(player_ptr, 0, y, x, player_ptr->current_floor_ptr->dun_level, SUMMON_PIRANHAS, (PM_ALLOW_GROUP | PM_NO_PET));
631         }
632         break;
633     }
634
635     default:
636         break;
637     }
638
639     if (break_trap && is_trap(player_ptr, g_ptr->feat)) {
640         cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::DISARM);
641         msg_print(_("トラップを粉砕した。", "You destroyed the trap."));
642     }
643 }