OSDN Git Service

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