OSDN Git Service

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