OSDN Git Service

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