OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / spells2.c
1 /*!
2  * @file spells2.c
3  * @brief 魔法効果の実装/ Spell code (part 2)
4  * @date 2014/07/15
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * </pre>
12  */
13
14 #include "angband.h"
15 #include "grid.h"
16 #include "trap.h"
17
18
19 /*!
20  * @brief プレイヤー周辺の地形を感知する
21  * @param range 効果範囲
22  * @param flag 特定地形ID
23  * @param known 地形から危険フラグを外すならTRUE
24  * @return 効力があった場合TRUEを返す
25  */
26 static bool detect_feat_flag(POSITION range, int flag, bool known)
27 {
28         int x, y;
29         bool detect = FALSE;
30         cave_type *c_ptr;
31
32         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
33
34         /* Scan the current panel */
35         for (y = 1; y < cur_hgt - 1; y++)
36         {
37                 for (x = 1; x <= cur_wid - 1; x++)
38                 {
39                         int dist = distance(p_ptr->y, p_ptr->x, y, x);
40                         if (dist > range) continue;
41                         c_ptr = &cave[y][x];
42
43                         /* Hack -- Safe */
44                         if (flag == FF_TRAP)
45                         {
46                                 /* Mark as detected */
47                                 if (dist <= range && known)
48                                 {
49                                         if (dist <= range - 1) c_ptr->info |= (CAVE_IN_DETECT);
50
51                                         c_ptr->info &= ~(CAVE_UNSAFE);
52
53                                         /* Redraw */
54                                         lite_spot(y, x);
55                                 }
56                         }
57
58                         /* Detect flags */
59                         if (cave_have_flag_grid(c_ptr, flag))
60                         {
61                                 /* Detect secrets */
62                                 disclose_grid(y, x);
63
64                                 /* Hack -- Memorize */
65                                 c_ptr->info |= (CAVE_MARK);
66
67                                 /* Redraw */
68                                 lite_spot(y, x);
69
70                                 detect = TRUE;
71                         }
72                 }
73         }
74         return detect;
75 }
76
77
78 /*!
79  * @brief プレイヤー周辺のトラップを感知する / Detect all traps on current panel
80  * @param range 効果範囲
81  * @param known 感知外範囲を超える警告フラグを立てる場合TRUEを返す
82  * @return 効力があった場合TRUEを返す
83  */
84 bool detect_traps(POSITION range, bool known)
85 {
86         bool detect = detect_feat_flag(range, FF_TRAP, known);
87
88         if (known) p_ptr->dtrap = TRUE;
89
90         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 0) detect = FALSE;
91         if (detect)
92         {
93                 msg_print(_("トラップの存在を感じとった!", "You sense the presence of traps!"));
94         }
95         return detect;
96 }
97
98
99 /*!
100  * @brief プレイヤー周辺のドアを感知する / Detect all doors on current panel
101  * @param range 効果範囲
102  * @return 効力があった場合TRUEを返す
103  */
104 bool detect_doors(POSITION range)
105 {
106         bool detect = detect_feat_flag(range, FF_DOOR, TRUE);
107
108         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 0) detect = FALSE;
109         if (detect)
110         {
111                 msg_print(_("ドアの存在を感じとった!", "You sense the presence of doors!"));
112         }
113         return detect;
114 }
115
116
117 /*!
118  * @brief プレイヤー周辺の階段を感知する / Detect all stairs on current panel
119  * @param range 効果範囲
120  * @return 効力があった場合TRUEを返す
121  */
122 bool detect_stairs(POSITION range)
123 {
124         bool detect = detect_feat_flag(range, FF_STAIRS, TRUE);
125
126         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 0) detect = FALSE;
127         if (detect)
128         {
129                 msg_print(_("階段の存在を感じとった!", "You sense the presence of stairs!"));
130         }
131         return detect;
132 }
133
134
135 /*!
136  * @brief プレイヤー周辺の地形財宝を感知する / Detect any treasure on the current panel
137  * @param range 効果範囲
138  * @return 効力があった場合TRUEを返す
139  */
140 bool detect_treasure(POSITION range)
141 {
142         bool detect = detect_feat_flag(range, FF_HAS_GOLD, TRUE);
143
144         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 6) detect = FALSE;
145         if (detect)
146         {
147                 msg_print(_("埋蔵された財宝の存在を感じとった!", "You sense the presence of buried treasure!"));
148         }
149         return detect;
150 }
151
152
153 /*!
154  * @brief プレイヤー周辺のアイテム財宝を感知する / Detect all "gold" objects on the current panel
155  * @param range 効果範囲
156  * @return 効力があった場合TRUEを返す
157  */
158 bool detect_objects_gold(POSITION range)
159 {
160         int i, y, x;
161         POSITION range2 = range;
162
163         bool detect = FALSE;
164
165         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range2 /= 3;
166
167         /* Scan objects */
168         for (i = 1; i < o_max; i++)
169         {
170                 object_type *o_ptr = &o_list[i];
171
172                 /* Skip dead objects */
173                 if (!o_ptr->k_idx) continue;
174
175                 /* Skip held objects */
176                 if (o_ptr->held_m_idx) continue;
177
178                 y = o_ptr->iy;
179                 x = o_ptr->ix;
180
181                 /* Only detect nearby objects */
182                 if (distance(p_ptr->y, p_ptr->x, y, x) > range2) continue;
183
184                 /* Detect "gold" objects */
185                 if (o_ptr->tval == TV_GOLD)
186                 {
187                         o_ptr->marked |= OM_FOUND;
188                         lite_spot(y, x);
189                         detect = TRUE;
190                 }
191         }
192
193         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 6) detect = FALSE;
194         if (detect)
195         {
196                 msg_print(_("財宝の存在を感じとった!", "You sense the presence of treasure!"));
197         }
198
199         if (detect_monsters_string(range, "$"))
200         {
201                 detect = TRUE;
202         }
203         return (detect);
204 }
205
206
207 /*!
208  * @brief 通常のアイテムオブジェクトを感知する / Detect all "normal" objects on the current panel
209  * @param range 効果範囲
210  * @return 効力があった場合TRUEを返す
211  */
212 bool detect_objects_normal(POSITION range)
213 {
214         int i, y, x;
215         POSITION range2 = range;
216
217         bool detect = FALSE;
218
219         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range2 /= 3;
220
221         /* Scan objects */
222         for (i = 1; i < o_max; i++)
223         {
224                 object_type *o_ptr = &o_list[i];
225
226                 /* Skip dead objects */
227                 if (!o_ptr->k_idx) continue;
228
229                 /* Skip held objects */
230                 if (o_ptr->held_m_idx) continue;
231
232                 y = o_ptr->iy;
233                 x = o_ptr->ix;
234
235                 /* Only detect nearby objects */
236                 if (distance(p_ptr->y, p_ptr->x, y, x) > range2) continue;
237
238                 /* Detect "real" objects */
239                 if (o_ptr->tval != TV_GOLD)
240                 {
241                         o_ptr->marked |= OM_FOUND;
242                         lite_spot(y, x);
243                         detect = TRUE;
244                 }
245         }
246
247         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 6) detect = FALSE;
248         if (detect)
249         {
250                 msg_print(_("アイテムの存在を感じとった!", "You sense the presence of objects!"));
251         }
252
253         if (detect_monsters_string(range, "!=?|/`"))
254         {
255                 detect = TRUE;
256         }
257         return (detect);
258 }
259
260
261 /*!
262  * @brief 魔法効果のあるのアイテムオブジェクトを感知する / Detect all "magic" objects on the current panel.
263  * @param range 効果範囲
264  * @return 効力があった場合TRUEを返す
265  * @details
266  * <pre>
267  * This will light up all spaces with "magic" items, including artifacts,
268  * ego-items, potions, scrolls, books, rods, wands, staves, amulets, rings,
269  * and "enchanted" items of the "good" variety.
270  *
271  * It can probably be argued that this function is now too powerful.
272  * </pre>
273  */
274 bool detect_objects_magic(POSITION range)
275 {
276         int i, y, x, tv;
277
278         bool detect = FALSE;
279
280         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
281
282         /* Scan all objects */
283         for (i = 1; i < o_max; i++)
284         {
285                 object_type *o_ptr = &o_list[i];
286
287                 /* Skip dead objects */
288                 if (!o_ptr->k_idx) continue;
289
290                 /* Skip held objects */
291                 if (o_ptr->held_m_idx) continue;
292
293                 y = o_ptr->iy;
294                 x = o_ptr->ix;
295
296                 /* Only detect nearby objects */
297                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
298
299                 /* Examine the tval */
300                 tv = o_ptr->tval;
301
302                 /* Artifacts, misc magic items, or enchanted wearables */
303                 if (object_is_artifact(o_ptr) ||
304                         object_is_ego(o_ptr) ||
305                     (tv == TV_WHISTLE) ||
306                     (tv == TV_AMULET) ||
307                         (tv == TV_RING) ||
308                     (tv == TV_STAFF) ||
309                         (tv == TV_WAND) ||
310                         (tv == TV_ROD) ||
311                     (tv == TV_SCROLL) ||
312                         (tv == TV_POTION) ||
313                     (tv == TV_LIFE_BOOK) ||
314                         (tv == TV_SORCERY_BOOK) ||
315                     (tv == TV_NATURE_BOOK) ||
316                         (tv == TV_CHAOS_BOOK) ||
317                     (tv == TV_DEATH_BOOK) ||
318                     (tv == TV_TRUMP_BOOK) ||
319                         (tv == TV_ARCANE_BOOK) ||
320                         (tv == TV_CRAFT_BOOK) ||
321                         (tv == TV_DAEMON_BOOK) ||
322                         (tv == TV_CRUSADE_BOOK) ||
323                         (tv == TV_MUSIC_BOOK) ||
324                         (tv == TV_HISSATSU_BOOK) ||
325                         (tv == TV_HEX_BOOK) ||
326                     ((o_ptr->to_a > 0) || (o_ptr->to_h + o_ptr->to_d > 0)))
327                 {
328                         /* Memorize the item */
329                         o_ptr->marked |= OM_FOUND;
330                         lite_spot(y, x);
331                         detect = TRUE;
332                 }
333         }
334         if (detect)
335         {
336                 msg_print(_("魔法のアイテムの存在を感じとった!", "You sense the presence of magic objects!"));
337         }
338
339         /* Return result */
340         return (detect);
341 }
342
343
344 /*!
345  * @brief 一般のモンスターを感知する / Detect all "normal" monsters on the current panel
346  * @param range 効果範囲
347  * @return 効力があった場合TRUEを返す
348  */
349 bool detect_monsters_normal(POSITION range)
350 {
351         MONSTER_IDX i;
352         POSITION y, x;
353
354         bool flag = FALSE;
355
356         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
357
358         /* Scan monsters */
359         for (i = 1; i < m_max; i++)
360         {
361                 monster_type *m_ptr = &m_list[i];
362                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
363
364                 /* Skip dead monsters */
365                 if (!m_ptr->r_idx) continue;
366
367                 y = m_ptr->fy;
368                 x = m_ptr->fx;
369
370                 /* Only detect nearby monsters */
371                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
372
373                 /* Detect all non-invisible monsters */
374                 if (!(r_ptr->flags2 & RF2_INVISIBLE) || p_ptr->see_inv)
375                 {
376                         /* Repair visibility later */
377                         repair_monsters = TRUE;
378
379                         /* Hack -- Detect monster */
380                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
381                         update_monster(i, FALSE);
382                         flag = TRUE;
383                 }
384         }
385
386         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
387         if (flag)
388         {
389                 /* Describe result */
390                 msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
391         }
392         return (flag);
393 }
394
395
396 /*!
397  * @brief 不可視のモンスターを感知する / Detect all "invisible" monsters around the player
398  * @param range 効果範囲
399  * @return 効力があった場合TRUEを返す
400  */
401 bool detect_monsters_invis(POSITION range)
402 {
403         MONSTER_IDX i;
404         POSITION y, x;
405         bool flag = FALSE;
406
407         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
408
409         /* Scan monsters */
410         for (i = 1; i < m_max; i++)
411         {
412                 monster_type *m_ptr = &m_list[i];
413                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
414
415                 /* Skip dead monsters */
416                 if (!m_ptr->r_idx) continue;
417
418                 y = m_ptr->fy;
419                 x = m_ptr->fx;
420
421                 /* Only detect nearby monsters */
422                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
423
424                 /* Detect invisible monsters */
425                 if (r_ptr->flags2 & RF2_INVISIBLE)
426                 {
427                         /* Update monster recall window */
428                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
429                         {
430                                 p_ptr->window |= (PW_MONSTER);
431                         }
432
433                         /* Repair visibility later */
434                         repair_monsters = TRUE;
435
436                         /* Hack -- Detect monster */
437                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
438                         update_monster(i, FALSE);
439                         flag = TRUE;
440                 }
441         }
442
443         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
444         if (flag)
445         {
446                 /* Describe result */
447                 msg_print(_("透明な生物の存在を感じとった!", "You sense the presence of invisible creatures!"));
448         }
449         return (flag);
450 }
451
452 /*!
453  * @brief 邪悪なモンスターを感知する / Detect all "evil" monsters on current panel
454  * @param range 効果範囲
455  * @return 効力があった場合TRUEを返す
456  */
457 bool detect_monsters_evil(POSITION range)
458 {
459         MONSTER_IDX i;
460         POSITION y, x;
461         bool flag = FALSE;
462
463         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
464
465         /* Scan monsters */
466         for (i = 1; i < m_max; i++)
467         {
468                 monster_type *m_ptr = &m_list[i];
469                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
470
471                 /* Skip dead monsters */
472                 if (!m_ptr->r_idx) continue;
473
474                 y = m_ptr->fy;
475                 x = m_ptr->fx;
476
477                 /* Only detect nearby monsters */
478                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
479
480                 /* Detect evil monsters */
481                 if (r_ptr->flags3 & RF3_EVIL)
482                 {
483                         if (is_original_ap(m_ptr))
484                         {
485                                 /* Take note that they are evil */
486                                 r_ptr->r_flags3 |= (RF3_EVIL);
487
488                                 /* Update monster recall window */
489                                 if (p_ptr->monster_race_idx == m_ptr->r_idx)
490                                 {
491                                         p_ptr->window |= (PW_MONSTER);
492                                 }
493                         }
494
495                         /* Repair visibility later */
496                         repair_monsters = TRUE;
497
498                         /* Hack -- Detect monster */
499                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
500                         update_monster(i, FALSE);
501                         flag = TRUE;
502                 }
503         }
504         if (flag)
505         {
506                 /* Describe result */
507                 msg_print(_("邪悪なる生物の存在を感じとった!", "You sense the presence of evil creatures!"));
508         }
509         return (flag);
510 }
511
512 /*!
513  * @brief 無生命のモンスターを感知する(アンデッド、悪魔系を含む) / Detect all "nonliving", "undead" or "demonic" monsters on current panel
514  * @param range 効果範囲
515  * @return 効力があった場合TRUEを返す
516  */
517 bool detect_monsters_nonliving(POSITION range)
518 {
519         MONSTER_IDX i;
520         POSITION y, x;
521         bool flag = FALSE;
522
523         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
524
525         /* Scan monsters */
526         for (i = 1; i < m_max; i++)
527         {
528                 monster_type *m_ptr = &m_list[i];
529                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
530
531                 /* Skip dead monsters */
532                 if (!m_ptr->r_idx) continue;
533
534                 y = m_ptr->fy;
535                 x = m_ptr->fx;
536
537                 /* Only detect nearby monsters */
538                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
539
540                 /* Detect non-living monsters */
541                 if (!monster_living(r_ptr))
542                 {
543                         /* Update monster recall window */
544                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
545                         {
546                                 p_ptr->window |= (PW_MONSTER);
547                         }
548
549                         /* Repair visibility later */
550                         repair_monsters = TRUE;
551
552                         /* Hack -- Detect monster */
553                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
554                         update_monster(i, FALSE);
555                         flag = TRUE;
556                 }
557         }
558         if (flag)
559         {
560                 /* Describe result */
561                 msg_print(_("自然でないモンスターの存在を感じた!", "You sense the presence of unnatural beings!"));
562         }
563         return (flag);
564 }
565
566 /*!
567  * @brief 精神のあるモンスターを感知する / Detect all monsters it has mind on current panel
568  * @param range 効果範囲
569  * @return 効力があった場合TRUEを返す
570  */
571 bool detect_monsters_mind(POSITION range)
572 {
573         MONSTER_IDX i;
574         POSITION y, x;
575         bool    flag = FALSE;
576
577         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
578
579         /* Scan monsters */
580         for (i = 1; i < m_max; i++)
581         {
582                 monster_type *m_ptr = &m_list[i];
583                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
584
585                 /* Skip dead monsters */
586                 if (!m_ptr->r_idx) continue;
587
588                 y = m_ptr->fy;
589                 x = m_ptr->fx;
590
591                 /* Only detect nearby monsters */
592                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
593
594                 /* Detect non-living monsters */
595                 if (!(r_ptr->flags2 & RF2_EMPTY_MIND))
596                 {
597                         /* Update monster recall window */
598                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
599                         {
600                                 p_ptr->window |= (PW_MONSTER);
601                         }
602
603                         /* Repair visibility later */
604                         repair_monsters = TRUE;
605
606                         /* Hack -- Detect monster */
607                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
608                         update_monster(i, FALSE);
609                         flag = TRUE;
610                 }
611         }
612         if (flag)
613         {
614                 /* Describe result */
615                 msg_print(_("殺気を感じとった!", "You sense the presence of someone's mind!"));
616         }
617         return (flag);
618 }
619
620
621 /*!
622  * @brief 該当シンボルのモンスターを感知する / Detect all (string) monsters on current panel
623  * @param range 効果範囲
624  * @param Match 対応シンボルの混じったモンスター文字列(複数指定化)
625  * @return 効力があった場合TRUEを返す
626  */
627 bool detect_monsters_string(POSITION range, cptr Match)
628 {
629         MONSTER_IDX i;
630         POSITION y, x;
631         bool flag = FALSE;
632
633         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
634
635         /* Scan monsters */
636         for (i = 1; i < m_max; i++)
637         {
638                 monster_type *m_ptr = &m_list[i];
639                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
640
641                 /* Skip dead monsters */
642                 if (!m_ptr->r_idx) continue;
643
644                 y = m_ptr->fy;
645                 x = m_ptr->fx;
646
647                 /* Only detect nearby monsters */
648                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
649
650                 /* Detect monsters with the same symbol */
651                 if (my_strchr(Match, r_ptr->d_char))
652                 {
653                         /* Update monster recall window */
654                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
655                         {
656                                 p_ptr->window |= (PW_MONSTER);
657                         }
658
659                         /* Repair visibility later */
660                         repair_monsters = TRUE;
661
662                         /* Hack -- Detect monster */
663                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
664                         update_monster(i, FALSE);
665                         flag = TRUE;
666                 }
667         }
668
669         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
670         if (flag)
671         {
672                 /* Describe result */
673                 msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
674         }
675         return (flag);
676 }
677
678 /*!
679  * @brief flags3に対応するモンスターを感知する / A "generic" detect monsters routine, tagged to flags3
680  * @param range 効果範囲
681  * @param match_flag 感知フラグ
682  * @return 効力があった場合TRUEを返す
683  */
684 bool detect_monsters_xxx(POSITION range, u32b match_flag)
685 {
686         MONSTER_IDX i;
687         POSITION y, x;
688         bool flag = FALSE;
689         cptr desc_monsters = _("変なモンスター", "weird monsters");
690
691         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
692
693         /* Scan monsters */
694         for (i = 1; i < m_max; i++)
695         {
696                 monster_type *m_ptr = &m_list[i];
697                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
698
699                 /* Skip dead monsters */
700                 if (!m_ptr->r_idx) continue;
701
702                 y = m_ptr->fy;
703                 x = m_ptr->fx;
704
705                 /* Only detect nearby monsters */
706                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
707
708                 /* Detect evil monsters */
709                 if (r_ptr->flags3 & (match_flag))
710                 {
711                         if (is_original_ap(m_ptr))
712                         {
713                                 /* Take note that they are something */
714                                 r_ptr->r_flags3 |= (match_flag);
715
716                                 /* Update monster recall window */
717                                 if (p_ptr->monster_race_idx == m_ptr->r_idx)
718                                 {
719                                         p_ptr->window |= (PW_MONSTER);
720                                 }
721                         }
722
723                         /* Repair visibility later */
724                         repair_monsters = TRUE;
725
726                         /* Hack -- Detect monster */
727                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
728                         update_monster(i, FALSE);
729                         flag = TRUE;
730                 }
731         }
732         if (flag)
733         {
734                 switch (match_flag)
735                 {
736                         case RF3_DEMON:
737                         desc_monsters = _("デーモン", "demons");
738                                 break;
739                         case RF3_UNDEAD:
740                         desc_monsters = _("アンデッド", "the undead");
741                                 break;
742                 }
743
744                 /* Describe result */
745                 msg_format(_("%sの存在を感じとった!", "You sense the presence of %s!"), desc_monsters);
746                 msg_print(NULL);
747         }
748         return (flag);
749 }
750
751
752 /*!
753  * @brief 全感知処理 / Detect everything
754  * @param range 効果範囲
755  * @return 効力があった場合TRUEを返す
756  */
757 bool detect_all(POSITION range)
758 {
759         bool detect = FALSE;
760
761         /* Detect everything */
762         if (detect_traps(range, TRUE)) detect = TRUE;
763         if (detect_doors(range)) detect = TRUE;
764         if (detect_stairs(range)) detect = TRUE;
765
766         /* There are too many hidden treasure.  So... */
767         /* if (detect_treasure(range)) detect = TRUE; */
768
769         if (detect_objects_gold(range)) detect = TRUE;
770         if (detect_objects_normal(range)) detect = TRUE;
771         if (detect_monsters_invis(range)) detect = TRUE;
772         if (detect_monsters_normal(range)) detect = TRUE;
773         return (detect);
774 }
775
776
777 /*!
778  * @brief 視界内モンスターに魔法効果を与える / Apply a "project()" directly to all viewable monsters
779  * @param typ 属性効果
780  * @param dam 効果量
781  * @return 効力があった場合TRUEを返す
782  * @details
783  * <pre>
784  * Note that affected monsters are NOT auto-tracked by this usage.
785  *
786  * To avoid misbehavior when monster deaths have side-effects,
787  * this is done in two passes. -- JDL
788  * </pre>
789  */
790 bool project_hack(EFFECT_ID typ, HIT_POINT dam)
791 {
792         MONSTER_IDX i;
793         POSITION x, y;
794         BIT_FLAGS flg = PROJECT_JUMP | PROJECT_KILL | PROJECT_HIDE;
795         bool obvious = FALSE;
796
797
798         /* Mark all (nearby) monsters */
799         for (i = 1; i < m_max; i++)
800         {
801                 monster_type *m_ptr = &m_list[i];
802
803                 /* Paranoia -- Skip dead monsters */
804                 if (!m_ptr->r_idx) continue;
805
806                 y = m_ptr->fy;
807                 x = m_ptr->fx;
808
809                 /* Require line of sight */
810                 if (!player_has_los_bold(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)) continue;
811
812                 /* Mark the monster */
813                 m_ptr->mflag |= (MFLAG_TEMP);
814         }
815
816         /* Affect all marked monsters */
817         for (i = 1; i < m_max; i++)
818         {
819                 monster_type *m_ptr = &m_list[i];
820
821                 /* Skip unmarked monsters */
822                 if (!(m_ptr->mflag & (MFLAG_TEMP))) continue;
823
824                 /* Remove mark */
825                 m_ptr->mflag &= ~(MFLAG_TEMP);
826
827                 y = m_ptr->fy;
828                 x = m_ptr->fx;
829
830                 /* Jump directly to the target monster */
831                 if (project(0, 0, y, x, dam, typ, flg, -1)) obvious = TRUE;
832         }
833         return (obvious);
834 }
835
836
837 /*!
838  * @brief 視界内モンスターを加速する処理 / Speed monsters
839  * @return 効力があった場合TRUEを返す
840  */
841 bool speed_monsters(void)
842 {
843         return (project_hack(GF_OLD_SPEED, p_ptr->lev));
844 }
845
846 /*!
847  * @brief 視界内モンスターを加速する処理 / Slow monsters
848  * @return 効力があった場合TRUEを返す
849  */
850 bool slow_monsters(int power)
851 {
852         return (project_hack(GF_OLD_SLOW, power));
853 }
854
855 /*!
856  * @brief 視界内モンスターを眠らせる処理 / Sleep monsters
857  * @return 効力があった場合TRUEを返す
858  */
859 bool sleep_monsters(int power)
860 {
861         return (project_hack(GF_OLD_SLEEP, power));
862 }
863
864 /*!
865  * @brief 視界内の邪悪なモンスターをテレポート・アウェイさせる処理 / Banish evil monsters
866  * @return 効力があった場合TRUEを返す
867  */
868 bool banish_evil(int dist)
869 {
870         return (project_hack(GF_AWAY_EVIL, dist));
871 }
872
873 /*!
874  * @brief 視界内のアンデッド・モンスターを恐怖させる処理 / Turn undead
875  * @return 効力があった場合TRUEを返す
876  */
877 bool turn_undead(void)
878 {
879         bool tester = (project_hack(GF_TURN_UNDEAD, p_ptr->lev));
880         if (tester)
881                 chg_virtue(V_UNLIFE, -1);
882         return tester;
883 }
884
885 /*!
886  * @brief 視界内のアンデッド・モンスターにダメージを与える処理 / Dispel undead monsters
887  * @return 効力があった場合TRUEを返す
888  */
889 bool dispel_undead(HIT_POINT dam)
890 {
891         bool tester = (project_hack(GF_DISP_UNDEAD, dam));
892         if (tester)
893                 chg_virtue(V_UNLIFE, -2);
894         return tester;
895 }
896
897 /*!
898  * @brief 視界内の邪悪なモンスターにダメージを与える処理 / Dispel evil monsters
899  * @return 効力があった場合TRUEを返す
900  */
901 bool dispel_evil(HIT_POINT dam)
902 {
903         return (project_hack(GF_DISP_EVIL, dam));
904 }
905
906 /*!
907  * @brief 視界内の善良なモンスターにダメージを与える処理 / Dispel good monsters
908  * @return 効力があった場合TRUEを返す
909  */
910 bool dispel_good(HIT_POINT dam)
911 {
912         return (project_hack(GF_DISP_GOOD, dam));
913 }
914
915 /*!
916  * @brief 視界内のあらゆるモンスターにダメージを与える処理 / Dispel all monsters
917  * @return 効力があった場合TRUEを返す
918  */
919 bool dispel_monsters(HIT_POINT dam)
920 {
921         return (project_hack(GF_DISP_ALL, dam));
922 }
923
924 /*!
925  * @brief 視界内の生命のあるモンスターにダメージを与える処理 / Dispel 'living' monsters
926  * @return 効力があった場合TRUEを返す
927  */
928 bool dispel_living(HIT_POINT dam)
929 {
930         return (project_hack(GF_DISP_LIVING, dam));
931 }
932
933 /*!
934  * @brief 視界内の悪魔系モンスターにダメージを与える処理 / Dispel 'living' monsters
935  * @return 効力があった場合TRUEを返す
936  */
937 bool dispel_demons(HIT_POINT dam)
938 {
939         return (project_hack(GF_DISP_DEMON, dam));
940 }
941
942 /*!
943  * @brief 視界内のモンスターに「聖戦」効果を与える処理
944  * @return 効力があった場合TRUEを返す
945  */
946 bool crusade(void)
947 {
948         return (project_hack(GF_CRUSADE, p_ptr->lev*4));
949 }
950
951 /*!
952  * @brief 視界内モンスターを怒らせる処理 / Wake up all monsters, and speed up "los" monsters.
953  * @param who 怒らせる原因を起こしたモンスター(0ならばプレイヤー)
954  * @return なし
955  */
956 void aggravate_monsters(MONSTER_IDX who)
957 {
958         MONSTER_IDX i;
959         bool    sleep = FALSE;
960         bool    speed = FALSE;
961
962         /* Aggravate everyone nearby */
963         for (i = 1; i < m_max; i++)
964         {
965                 monster_type    *m_ptr = &m_list[i];
966 /*              monster_race    *r_ptr = &r_info[m_ptr->r_idx]; */
967
968                 /* Paranoia -- Skip dead monsters */
969                 if (!m_ptr->r_idx) continue;
970
971                 /* Skip aggravating monster (or player) */
972                 if (i == who) continue;
973
974                 /* Wake up nearby sleeping monsters */
975                 if (m_ptr->cdis < MAX_SIGHT * 2)
976                 {
977                         /* Wake up */
978                         if (MON_CSLEEP(m_ptr))
979                         {
980                                 (void)set_monster_csleep(i, 0);
981                                 sleep = TRUE;
982                         }
983                         if (!is_pet(m_ptr)) m_ptr->mflag2 |= MFLAG2_NOPET;
984                 }
985
986                 /* Speed up monsters in line of sight */
987                 if (player_has_los_bold(m_ptr->fy, m_ptr->fx))
988                 {
989                         if (!is_pet(m_ptr))
990                         {
991                                 (void)set_monster_fast(i, MON_FAST(m_ptr) + 100);
992                                 speed = TRUE;
993                         }
994                 }
995         }
996
997         if (speed) msg_print(_("付近で何かが突如興奮したような感じを受けた!", "You feel a sudden stirring nearby!"));
998         else if (sleep) msg_print(_("何かが突如興奮したような騒々しい音が遠くに聞こえた!", "You hear a sudden stirring in the distance!"));
999         if (p_ptr->riding) p_ptr->update |= PU_BONUS;
1000 }
1001
1002
1003 /*!
1004  * @brief モンスターへの単体抹殺処理サブルーチン / Delete a non-unique/non-quest monster
1005  * @param m_idx 抹殺するモンスターID
1006  * @param power 抹殺の威力
1007  * @param player_cast プレイヤーの魔法によるものならば TRUE
1008  * @param dam_side プレイヤーへの負担ダメージ量(1d(dam_side))
1009  * @param spell_name 抹殺効果を起こした魔法の名前
1010  * @return 効力があった場合TRUEを返す
1011  */
1012 bool genocide_aux(MONSTER_IDX m_idx, int power, bool player_cast, int dam_side, cptr spell_name)
1013 {
1014         int          msec = delay_factor * delay_factor * delay_factor;
1015         monster_type *m_ptr = &m_list[m_idx];
1016         monster_race *r_ptr = &r_info[m_ptr->r_idx];
1017         bool         resist = FALSE;
1018
1019         if (is_pet(m_ptr) && !player_cast) return FALSE;
1020
1021         /* Hack -- Skip Unique Monsters or Quest Monsters */
1022         if (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) resist = TRUE;
1023         else if (r_ptr->flags7 & RF7_UNIQUE2) resist = TRUE;
1024         else if (m_idx == p_ptr->riding) resist = TRUE;
1025         else if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle) resist = TRUE;
1026         else if (player_cast && (r_ptr->level > randint0(power))) resist = TRUE;
1027         else if (player_cast && (m_ptr->mflag2 & MFLAG2_NOGENO)) resist = TRUE;
1028
1029
1030         else
1031         {
1032                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1033                 {
1034                         char m_name[80];
1035
1036                         monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1037                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
1038                 }
1039
1040                 delete_monster_idx(m_idx);
1041         }
1042
1043         if (resist && player_cast)
1044         {
1045                 bool see_m = is_seen(m_ptr);
1046                 char m_name[80];
1047
1048                 monster_desc(m_name, m_ptr, 0);
1049                 if (see_m)
1050                 {
1051                         msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
1052                 }
1053                 if (MON_CSLEEP(m_ptr))
1054                 {
1055                         (void)set_monster_csleep(m_idx, 0);
1056                         if (m_ptr->ml)
1057                         {
1058                                 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1059                         }
1060                 }
1061                 if (is_friendly(m_ptr) && !is_pet(m_ptr))
1062                 {
1063                         if (see_m)
1064                         {
1065                                 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
1066                         }
1067                         set_hostile(m_ptr);
1068                 }
1069                 if (one_in_(13)) m_ptr->mflag2 |= MFLAG2_NOGENO;
1070         }
1071
1072         if (player_cast)
1073         {
1074                 take_hit(DAMAGE_GENO, randint1(dam_side), format(_("%^sの呪文を唱えた疲労", "the strain of casting %^s"), spell_name), -1);
1075         }
1076
1077         /* Visual feedback */
1078         move_cursor_relative(p_ptr->y, p_ptr->x);
1079
1080         /* Redraw */
1081         p_ptr->redraw |= (PR_HP);
1082         p_ptr->window |= (PW_PLAYER);
1083
1084         /* Handle */
1085         handle_stuff();
1086         Term_fresh();
1087
1088         Term_xtra(TERM_XTRA_DELAY, msec);
1089
1090         return !resist;
1091 }
1092
1093
1094 /*!
1095  * @brief モンスターへのシンボル抹殺処理ルーチン / Delete all non-unique/non-quest monsters of a given "type" from the level
1096  * @param power 抹殺の威力
1097  * @param player_cast プレイヤーの魔法によるものならば TRUE
1098  * @return 効力があった場合TRUEを返す
1099  */
1100 bool symbol_genocide(int power, bool player_cast)
1101 {
1102         MONSTER_IDX i;
1103         char typ;
1104         bool result = FALSE;
1105
1106         /* Prevent genocide in quest levels */
1107         if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
1108         {
1109                 return (FALSE);
1110         }
1111
1112         /* Mega-Hack -- Get a monster symbol */
1113         while (!get_com(_("どの種類(文字)のモンスターを抹殺しますか: ", "Choose a monster race (by symbol) to genocide: "), &typ, FALSE)) ;
1114
1115         /* Delete the monsters of that "type" */
1116         for (i = 1; i < m_max; i++)
1117         {
1118                 monster_type *m_ptr = &m_list[i];
1119                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1120
1121                 /* Paranoia -- Skip dead monsters */
1122                 if (!m_ptr->r_idx) continue;
1123
1124                 /* Skip "wrong" monsters */
1125                 if (r_ptr->d_char != typ) continue;
1126
1127                 /* Take note */
1128                 result |= genocide_aux(i, power, player_cast, 4, _("抹殺", "Genocide"));
1129         }
1130
1131         if (result)
1132         {
1133                 chg_virtue(V_VITALITY, -2);
1134                 chg_virtue(V_CHANCE, -1);
1135         }
1136
1137         return result;
1138 }
1139
1140
1141 /*!
1142  * @brief モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) monsters
1143  * @param power 抹殺の威力
1144  * @param player_cast プレイヤーの魔法によるものならば TRUE
1145  * @return 効力があった場合TRUEを返す
1146  */
1147 bool mass_genocide(int power, bool player_cast)
1148 {
1149         MONSTER_IDX i;
1150         bool result = FALSE;
1151
1152         /* Prevent mass genocide in quest levels */
1153         if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
1154         {
1155                 return (FALSE);
1156         }
1157
1158         /* Delete the (nearby) monsters */
1159         for (i = 1; i < m_max; i++)
1160         {
1161                 monster_type *m_ptr = &m_list[i];
1162
1163                 /* Paranoia -- Skip dead monsters */
1164                 if (!m_ptr->r_idx) continue;
1165
1166                 /* Skip distant monsters */
1167                 if (m_ptr->cdis > MAX_SIGHT) continue;
1168
1169                 /* Note effect */
1170                 result |= genocide_aux(i, power, player_cast, 3, _("周辺抹殺", "Mass Genocide"));
1171         }
1172
1173         if (result)
1174         {
1175                 chg_virtue(V_VITALITY, -2);
1176                 chg_virtue(V_CHANCE, -1);
1177         }
1178
1179         return result;
1180 }
1181
1182
1183 /*!
1184  * @brief アンデッド・モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) undead
1185  * @param power 抹殺の威力
1186  * @param player_cast プレイヤーの魔法によるものならば TRUE
1187  * @return 効力があった場合TRUEを返す
1188  */
1189 bool mass_genocide_undead(int power, bool player_cast)
1190 {
1191         MONSTER_IDX i;
1192         bool result = FALSE;
1193
1194         /* Prevent mass genocide in quest levels */
1195         if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
1196         {
1197                 return (FALSE);
1198         }
1199
1200         /* Delete the (nearby) monsters */
1201         for (i = 1; i < m_max; i++)
1202         {
1203                 monster_type *m_ptr = &m_list[i];
1204                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1205
1206                 /* Paranoia -- Skip dead monsters */
1207                 if (!m_ptr->r_idx) continue;
1208
1209                 if (!(r_ptr->flags3 & RF3_UNDEAD)) continue;
1210
1211                 /* Skip distant monsters */
1212                 if (m_ptr->cdis > MAX_SIGHT) continue;
1213
1214                 /* Note effect */
1215                 result |= genocide_aux(i, power, player_cast, 3, _("アンデッド消滅", "Annihilate Undead"));
1216         }
1217
1218         if (result)
1219         {
1220                 chg_virtue(V_UNLIFE, -2);
1221                 chg_virtue(V_CHANCE, -1);
1222         }
1223
1224         return result;
1225 }
1226
1227
1228 /*!
1229  * @brief 周辺モンスターを調査する / Probe nearby monsters
1230  * @return 効力があった場合TRUEを返す
1231  */
1232 bool probing(void)
1233 {
1234         int i;
1235         SPEED speed;
1236         bool_hack cu, cv;
1237         bool probe = FALSE;
1238         char buf[256];
1239         cptr align;
1240
1241         cu = Term->scr->cu;
1242         cv = Term->scr->cv;
1243         Term->scr->cu = 0;
1244         Term->scr->cv = 1;
1245
1246         /* Probe all (nearby) monsters */
1247         for (i = 1; i < m_max; i++)
1248         {
1249                 monster_type *m_ptr = &m_list[i];
1250                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1251
1252                 /* Paranoia -- Skip dead monsters */
1253                 if (!m_ptr->r_idx) continue;
1254
1255                 /* Require line of sight */
1256                 if (!player_has_los_bold(m_ptr->fy, m_ptr->fx)) continue;
1257
1258                 /* Probe visible monsters */
1259                 if (m_ptr->ml)
1260                 {
1261                         char m_name[80];
1262
1263                         /* Start the message */
1264                         if (!probe)
1265                         {
1266                                 msg_print(_("調査中...", "Probing..."));
1267                         }
1268
1269                         msg_print(NULL);
1270
1271                         if (!is_original_ap(m_ptr))
1272                         {
1273                                 if (m_ptr->mflag2 & MFLAG2_KAGE)
1274                                         m_ptr->mflag2 &= ~(MFLAG2_KAGE);
1275
1276                                 m_ptr->ap_r_idx = m_ptr->r_idx;
1277                                 lite_spot(m_ptr->fy, m_ptr->fx);
1278                         }
1279                         /* Get "the monster" or "something" */
1280                         monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_INDEF_HIDDEN);
1281
1282                         speed = m_ptr->mspeed - 110;
1283                         if (MON_FAST(m_ptr)) speed += 10;
1284                         if (MON_SLOW(m_ptr)) speed -= 10;
1285                         if (ironman_nightmare) speed += 5;
1286
1287                         /* Get the monster's alignment */
1288                         if ((r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) == (RF3_EVIL | RF3_GOOD)) align = _("善悪", "good&evil");
1289                         else if (r_ptr->flags3 & RF3_EVIL) align = _("邪悪", "evil");
1290                         else if (r_ptr->flags3 & RF3_GOOD) align = _("善良", "good");
1291                         else if ((m_ptr->sub_align & (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) == (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) _(align = "中立(善悪)", "neutral(good&evil)");
1292                         else if (m_ptr->sub_align & SUB_ALIGN_EVIL) align = _("中立(邪悪)", "neutral(evil)");
1293                         else if (m_ptr->sub_align & SUB_ALIGN_GOOD) align = _("中立(善良)", "neutral(good)");
1294                         else align = _("中立", "neutral");
1295
1296                         /* Describe the monster */
1297                         sprintf(buf,_("%s ... 属性:%s HP:%d/%d AC:%d 速度:%s%d 経験:", "%s ... align:%s HP:%d/%d AC:%d speed:%s%d exp:"),
1298                                 m_name, align, (int)m_ptr->hp, (int)m_ptr->maxhp, r_ptr->ac, (speed > 0) ? "+" : "", speed);
1299
1300                         if (r_ptr->next_r_idx)
1301                         {
1302                                 strcat(buf, format("%d/%d ", m_ptr->exp, r_ptr->next_exp));
1303                         }
1304                         else
1305                         {
1306                                 strcat(buf, "xxx ");
1307                         }
1308
1309                         if (MON_CSLEEP(m_ptr)) strcat(buf,_("睡眠 ", "sleeping "));
1310                         if (MON_STUNNED(m_ptr)) strcat(buf, _("朦朧 ", "stunned "));
1311                         if (MON_MONFEAR(m_ptr)) strcat(buf, _("恐怖 ", "scared "));
1312                         if (MON_CONFUSED(m_ptr)) strcat(buf, _("混乱 ", "confused "));
1313                         if (MON_INVULNER(m_ptr)) strcat(buf, _("無敵 ", "invulnerable "));
1314                         buf[strlen(buf)-1] = '\0';
1315                         prt(buf, 0, 0);
1316
1317                         /* HACK : Add the line to message buffer */
1318                         message_add(buf);
1319                         p_ptr->window |= (PW_MESSAGE);
1320                         window_stuff();
1321
1322                         if (m_ptr->ml) move_cursor_relative(m_ptr->fy, m_ptr->fx);
1323                         inkey();
1324
1325                         Term_erase(0, 0, 255);
1326
1327                         /* Learn everything about this monster */
1328                         if (lore_do_probe(m_ptr->r_idx))
1329                         {
1330                                 /* Get base name of monster */
1331                                 strcpy(buf, (r_name + r_ptr->name));
1332
1333 #ifdef JP
1334                                 /* Note that we learnt some new flags  -Mogami- */
1335                                 msg_format("%sについてさらに詳しくなった気がする。", buf);
1336 #else
1337                                 /* Pluralize it */
1338                                 plural_aux(buf);
1339
1340                                 /* Note that we learnt some new flags  -Mogami- */
1341                                 msg_format("You now know more about %s.", buf);
1342 #endif
1343                                 /* Clear -more- prompt */
1344                                 msg_print(NULL);
1345                         }
1346
1347                         /* Probe worked */
1348                         probe = TRUE;
1349                 }
1350         }
1351
1352         Term->scr->cu = cu;
1353         Term->scr->cv = cv;
1354         Term_fresh();
1355
1356         if (probe)
1357         {
1358                 chg_virtue(V_KNOWLEDGE, 1);
1359                 msg_print(_("これで全部です。", "That's all."));
1360         }
1361         return (probe);
1362 }
1363
1364
1365
1366 /*!
1367  * @brief *破壊*処理を行う / The spell of destruction
1368  * @param y1 破壊の中心Y座標
1369  * @param x1 破壊の中心X座標 
1370  * @param r 破壊の半径
1371  * @param in_generate ダンジョンフロア生成中の処理ならばTRUE
1372  * @return 効力があった場合TRUEを返す
1373  * @details
1374  * <pre>
1375  * This spell "deletes" monsters (instead of "killing" them).
1376  *
1377  * Later we may use one function for both "destruction" and
1378  * "earthquake" by using the "full" to select "destruction".
1379  * </pre>
1380  */
1381 bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
1382 {
1383         POSITION y, x;
1384         int k, t;
1385         cave_type *c_ptr;
1386         bool flag = FALSE;
1387
1388         /* Prevent destruction of quest levels and town */
1389         if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1390         {
1391                 return (FALSE);
1392         }
1393
1394         /* Lose monster light */
1395         if (!in_generate) clear_mon_lite();
1396
1397         /* Big area of affect */
1398         for (y = (y1 - r); y <= (y1 + r); y++)
1399         {
1400                 for (x = (x1 - r); x <= (x1 + r); x++)
1401                 {
1402                         /* Skip illegal grids */
1403                         if (!in_bounds(y, x)) continue;
1404
1405                         /* Extract the distance */
1406                         k = distance(y1, x1, y, x);
1407
1408                         /* Stay in the circle of death */
1409                         if (k > r) continue;
1410                         c_ptr = &cave[y][x];
1411
1412                         /* Lose room and vault */
1413                         c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1414
1415                         /* Lose light and knowledge */
1416                         c_ptr->info &= ~(CAVE_MARK | CAVE_GLOW | CAVE_KNOWN);
1417
1418                         if (!in_generate) /* Normal */
1419                         {
1420                                 /* Lose unsafety */
1421                                 c_ptr->info &= ~(CAVE_UNSAFE);
1422
1423                                 /* Hack -- Notice player affect */
1424                                 if (player_bold(y, x))
1425                                 {
1426                                         /* Hurt the player later */
1427                                         flag = TRUE;
1428
1429                                         /* Do not hurt this grid */
1430                                         continue;
1431                                 }
1432                         }
1433
1434                         /* Hack -- Skip the epicenter */
1435                         if ((y == y1) && (x == x1)) continue;
1436
1437                         if (c_ptr->m_idx)
1438                         {
1439                                 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1440                                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1441
1442                                 if (in_generate) /* In generation */
1443                                 {
1444                                         /* Delete the monster (if any) */
1445                                         delete_monster(y, x);
1446                                 }
1447                                 else if (r_ptr->flags1 & RF1_QUESTOR)
1448                                 {
1449                                         /* Heal the monster */
1450                                         m_ptr->hp = m_ptr->maxhp;
1451
1452                                         /* Try to teleport away quest monsters */
1453                                         if (!teleport_away(c_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
1454                                 }
1455                                 else
1456                                 {
1457                                         if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1458                                         {
1459                                                 char m_name[80];
1460
1461                                                 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1462                                                 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_DESTROY, m_name);
1463                                         }
1464
1465                                         /* Delete the monster (if any) */
1466                                         delete_monster(y, x);
1467                                 }
1468                         }
1469
1470                         /* During generation, destroyed artifacts are "preserved" */
1471                         if (preserve_mode || in_generate)
1472                         {
1473                                 OBJECT_IDX this_o_idx, next_o_idx = 0;
1474
1475                                 /* Scan all objects in the grid */
1476                                 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1477                                 {
1478                                         object_type *o_ptr;
1479
1480                                         /* Acquire object */
1481                                         o_ptr = &o_list[this_o_idx];
1482
1483                                         /* Acquire next object */
1484                                         next_o_idx = o_ptr->next_o_idx;
1485
1486                                         /* Hack -- Preserve unknown artifacts */
1487                                         if (object_is_fixed_artifact(o_ptr) && (!object_is_known(o_ptr) || in_generate))
1488                                         {
1489                                                 /* Mega-Hack -- Preserve the artifact */
1490                                                 a_info[o_ptr->name1].cur_num = 0;
1491
1492                                                 if (in_generate && cheat_peek)
1493                                                 {
1494                                                         char o_name[MAX_NLEN];
1495                                                         object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1496                                                         msg_format(_("伝説のアイテム (%s) は生成中に*破壊*された。", "Artifact (%s) was *destroyed* during generation."), o_name);
1497                                                 }
1498                                         }
1499                                         else if (in_generate && cheat_peek && o_ptr->art_name)
1500                                         {
1501                                                 msg_print(_("ランダム・アーティファクトの1つは生成中に*破壊*された。", 
1502                                                                         "One of the random artifacts was *destroyed* during generation."));
1503                                         }
1504                                 }
1505                         }
1506
1507                         /* Delete objects */
1508                         delete_object(y, x);
1509
1510                         /* Destroy "non-permanent" grids */
1511                         if (!cave_perma_grid(c_ptr))
1512                         {
1513                                 /* Wall (or floor) type */
1514                                 t = randint0(200);
1515
1516                                 if (!in_generate) /* Normal */
1517                                 {
1518                                         if (t < 20)
1519                                         {
1520                                                 /* Create granite wall */
1521                                                 cave_set_feat(y, x, feat_granite);
1522                                         }
1523                                         else if (t < 70)
1524                                         {
1525                                                 /* Create quartz vein */
1526                                                 cave_set_feat(y, x, feat_quartz_vein);
1527                                         }
1528                                         else if (t < 100)
1529                                         {
1530                                                 /* Create magma vein */
1531                                                 cave_set_feat(y, x, feat_magma_vein);
1532                                         }
1533                                         else
1534                                         {
1535                                                 /* Create floor */
1536                                                 cave_set_feat(y, x, floor_type[randint0(100)]);
1537                                         }
1538                                 }
1539                                 else /* In generation */
1540                                 {
1541                                         if (t < 20)
1542                                         {
1543                                                 /* Create granite wall */
1544                                                 place_extra_grid(c_ptr);
1545                                         }
1546                                         else if (t < 70)
1547                                         {
1548                                                 /* Create quartz vein */
1549                                                 c_ptr->feat = feat_quartz_vein;
1550                                         }
1551                                         else if (t < 100)
1552                                         {
1553                                                 /* Create magma vein */
1554                                                 c_ptr->feat = feat_magma_vein;
1555                                         }
1556                                         else
1557                                         {
1558                                                 /* Create floor */
1559                                                 place_floor_grid(c_ptr);
1560                                         }
1561
1562                                         /* Clear garbage of hidden trap or door */
1563                                         c_ptr->mimic = 0;
1564                                 }
1565                         }
1566                 }
1567         }
1568
1569         if (!in_generate)
1570         {
1571                 /* Process "re-glowing" */
1572                 for (y = (y1 - r); y <= (y1 + r); y++)
1573                 {
1574                         for (x = (x1 - r); x <= (x1 + r); x++)
1575                         {
1576                                 /* Skip illegal grids */
1577                                 if (!in_bounds(y, x)) continue;
1578
1579                                 /* Extract the distance */
1580                                 k = distance(y1, x1, y, x);
1581
1582                                 /* Stay in the circle of death */
1583                                 if (k > r) continue;
1584                                 c_ptr = &cave[y][x];
1585
1586                                 if (is_mirror_grid(c_ptr)) c_ptr->info |= CAVE_GLOW;
1587                                 else if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
1588                                 {
1589                                         int i, yy, xx;
1590                                         cave_type *cc_ptr;
1591
1592                                         for (i = 0; i < 9; i++)
1593                                         {
1594                                                 yy = y + ddy_ddd[i];
1595                                                 xx = x + ddx_ddd[i];
1596                                                 if (!in_bounds2(yy, xx)) continue;
1597                                                 cc_ptr = &cave[yy][xx];
1598                                                 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1599                                                 {
1600                                                         c_ptr->info |= CAVE_GLOW;
1601                                                         break;
1602                                                 }
1603                                         }
1604                                 }
1605                         }
1606                 }
1607
1608                 /* Hack -- Affect player */
1609                 if (flag)
1610                 {
1611                         msg_print(_("燃えるような閃光が発生した!", "There is a searing blast of light!"));
1612
1613                         /* Blind the player */
1614                         if (!p_ptr->resist_blind && !p_ptr->resist_lite)
1615                         {
1616                                 /* Become blind */
1617                                 (void)set_blind(p_ptr->blind + 10 + randint1(10));
1618                         }
1619                 }
1620
1621                 forget_flow();
1622
1623                 /* Mega-Hack -- Forget the view and lite */
1624                 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1625
1626                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1627
1628                 p_ptr->redraw |= (PR_MAP);
1629
1630                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1631
1632                 if (p_ptr->special_defense & NINJA_S_STEALTH)
1633                 {
1634                         if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
1635                 }
1636         }
1637
1638         /* Success */
1639         return (TRUE);
1640 }
1641
1642
1643 /*!
1644  * @brief 地震処理(サブルーチン) /
1645  * Induce an "earthquake" of the given radius at the given location.
1646  * @return 効力があった場合TRUEを返す
1647  * @param cy 中心Y座標
1648  * @param cx 中心X座標
1649  * @param r 効果半径
1650  * @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
1651  * @details
1652  * <pre>
1653  *
1654  * This will turn some walls into floors and some floors into walls.
1655  *
1656  * The player will take damage and "jump" into a safe grid if possible,
1657  * otherwise, he will "tunnel" through the rubble instantaneously.
1658  *
1659  * Monsters will take damage, and "jump" into a safe grid if possible,
1660  * otherwise they will be "buried" in the rubble, disappearing from
1661  * the level in the same way that they do when genocided.
1662  *
1663  * Note that thus the player and monsters (except eaters of walls and
1664  * passers through walls) will never occupy the same grid as a wall.
1665  * Note that as of now (2.7.8) no monster may occupy a "wall" grid, even
1666  * for a single turn, unless that monster can pass_walls or kill_walls.
1667  * This has allowed massive simplification of the "monster" code.
1668  * </pre>
1669  */
1670 bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
1671 {
1672         DIRECTION i;
1673         int t;
1674         POSITION y, x, yy, xx, dy, dx;
1675         int             damage = 0;
1676         int             sn = 0;
1677         POSITION        sy = 0, sx = 0;
1678         bool            hurt = FALSE;
1679         cave_type       *c_ptr;
1680         bool            map[32][32];
1681
1682
1683         /* Prevent destruction of quest levels and town */
1684         if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1685         {
1686                 return (FALSE);
1687         }
1688
1689         /* Paranoia -- Enforce maximum range */
1690         if (r > 12) r = 12;
1691
1692         /* Clear the "maximal blast" area */
1693         for (y = 0; y < 32; y++)
1694         {
1695                 for (x = 0; x < 32; x++)
1696                 {
1697                         map[y][x] = FALSE;
1698                 }
1699         }
1700
1701         /* Check around the epicenter */
1702         for (dy = -r; dy <= r; dy++)
1703         {
1704                 for (dx = -r; dx <= r; dx++)
1705                 {
1706                         /* Extract the location */
1707                         yy = cy + dy;
1708                         xx = cx + dx;
1709
1710                         /* Skip illegal grids */
1711                         if (!in_bounds(yy, xx)) continue;
1712
1713                         /* Skip distant grids */
1714                         if (distance(cy, cx, yy, xx) > r) continue;
1715                         c_ptr = &cave[yy][xx];
1716
1717                         /* Lose room and vault */
1718                         c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE);
1719
1720                         /* Lose light and knowledge */
1721                         c_ptr->info &= ~(CAVE_GLOW | CAVE_MARK | CAVE_KNOWN);
1722
1723                         /* Skip the epicenter */
1724                         if (!dx && !dy) continue;
1725
1726                         /* Skip most grids */
1727                         if (randint0(100) < 85) continue;
1728
1729                         /* Damage this grid */
1730                         map[16+yy-cy][16+xx-cx] = TRUE;
1731
1732                         /* Hack -- Take note of player damage */
1733                         if (player_bold(yy, xx)) hurt = TRUE;
1734                 }
1735         }
1736
1737         /* First, affect the player (if necessary) */
1738         if (hurt && !p_ptr->pass_wall && !p_ptr->kill_wall)
1739         {
1740                 /* Check around the player */
1741                 for (i = 0; i < 8; i++)
1742                 {
1743                         /* Access the location */
1744                         y = p_ptr->y + ddy_ddd[i];
1745                         x = p_ptr->x + ddx_ddd[i];
1746
1747                         /* Skip non-empty grids */
1748                         if (!cave_empty_bold(y, x)) continue;
1749
1750                         /* Important -- Skip "quake" grids */
1751                         if (map[16+y-cy][16+x-cx]) continue;
1752
1753                         if (cave[y][x].m_idx) continue;
1754
1755                         /* Count "safe" grids */
1756                         sn++;
1757
1758                         /* Randomize choice */
1759                         if (randint0(sn) > 0) continue;
1760
1761                         /* Save the safe location */
1762                         sy = y; sx = x;
1763                 }
1764
1765                 /* Random message */
1766                 switch (randint1(3))
1767                 {
1768                         case 1:
1769                         {
1770                                 msg_print(_("ダンジョンの壁が崩れた!", "The cave ceiling collapses!"));
1771                                 break;
1772                         }
1773                         case 2:
1774                         {
1775                                 msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The cave floor twists in an unnatural way!"));
1776                                 break;
1777                         }
1778                         default:
1779                         {
1780                                 msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The cave quakes!  You are pummeled with debris!"));
1781                                 break;
1782                         }
1783                 }
1784
1785                 /* Hurt the player a lot */
1786                 if (!sn)
1787                 {
1788                         /* Message and damage */
1789                         msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
1790                         damage = 200;
1791                 }
1792
1793                 /* Destroy the grid, and push the player to safety */
1794                 else
1795                 {
1796                         /* Calculate results */
1797                         switch (randint1(3))
1798                         {
1799                                 case 1:
1800                                 {
1801                                         msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
1802                                         damage = 0;
1803                                         break;
1804                                 }
1805                                 case 2:
1806                                 {
1807                                         msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
1808                                         damage = damroll(10, 4);
1809                                         (void)set_stun(p_ptr->stun + randint1(50));
1810                                         break;
1811                                 }
1812                                 case 3:
1813                                 {
1814                                         msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
1815                                         damage = damroll(10, 4);
1816                                         (void)set_stun(p_ptr->stun + randint1(50));
1817                                         break;
1818                                 }
1819                         }
1820
1821                         /* Move the player to the safe location */
1822                         (void)move_player_effect(sy, sx, MPE_DONT_PICKUP);
1823                 }
1824
1825                 /* Important -- no wall on player */
1826                 map[16+p_ptr->y-cy][16+p_ptr->x-cx] = FALSE;
1827
1828                 if (damage)
1829                 {
1830                         cptr killer;
1831
1832                         if (m_idx)
1833                         {
1834                                 char m_name[80];
1835                                 monster_type *m_ptr = &m_list[m_idx];
1836
1837                                 /* Get the monster's real name */
1838                                 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
1839
1840                                 killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
1841                         }
1842                         else
1843                         {
1844                                 killer = _("地震", "an earthquake");
1845                         }
1846
1847                         take_hit(DAMAGE_ATTACK, damage, killer, -1);
1848                 }
1849         }
1850
1851         /* Examine the quaked region */
1852         for (dy = -r; dy <= r; dy++)
1853         {
1854                 for (dx = -r; dx <= r; dx++)
1855                 {
1856                         /* Extract the location */
1857                         yy = cy + dy;
1858                         xx = cx + dx;
1859
1860                         /* Skip unaffected grids */
1861                         if (!map[16+yy-cy][16+xx-cx]) continue;
1862                         c_ptr = &cave[yy][xx];
1863
1864                         if (c_ptr->m_idx == p_ptr->riding) continue;
1865
1866                         /* Process monsters */
1867                         if (c_ptr->m_idx)
1868                         {
1869                                 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1870                                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1871
1872                                 /* Quest monsters */
1873                                 if (r_ptr->flags1 & RF1_QUESTOR)
1874                                 {
1875                                         /* No wall on quest monsters */
1876                                         map[16+yy-cy][16+xx-cx] = FALSE;
1877
1878                                         continue;
1879                                 }
1880
1881                                 /* Most monsters cannot co-exist with rock */
1882                                 if (!(r_ptr->flags2 & (RF2_KILL_WALL)) &&
1883                                     !(r_ptr->flags2 & (RF2_PASS_WALL)))
1884                                 {
1885                                         char m_name[80];
1886
1887                                         /* Assume not safe */
1888                                         sn = 0;
1889
1890                                         /* Monster can move to escape the wall */
1891                                         if (!(r_ptr->flags1 & (RF1_NEVER_MOVE)))
1892                                         {
1893                                                 /* Look for safety */
1894                                                 for (i = 0; i < 8; i++)
1895                                                 {
1896                                                         y = yy + ddy_ddd[i];
1897                                                         x = xx + ddx_ddd[i];
1898
1899                                                         /* Skip non-empty grids */
1900                                                         if (!cave_empty_bold(y, x)) continue;
1901
1902                                                         /* Hack -- no safety on glyph of warding */
1903                                                         if (is_glyph_grid(&cave[y][x])) continue;
1904                                                         if (is_explosive_rune_grid(&cave[y][x])) continue;
1905
1906                                                         /* ... nor on the Pattern */
1907                                                         if (pattern_tile(y, x)) continue;
1908
1909                                                         /* Important -- Skip "quake" grids */
1910                                                         if (map[16+y-cy][16+x-cx]) continue;
1911
1912                                                         if (cave[y][x].m_idx) continue;
1913                                                         if (player_bold(y, x)) continue;
1914
1915                                                         /* Count "safe" grids */
1916                                                         sn++;
1917
1918                                                         /* Randomize choice */
1919                                                         if (randint0(sn) > 0) continue;
1920
1921                                                         /* Save the safe grid */
1922                                                         sy = y; sx = x;
1923                                                 }
1924                                         }
1925
1926                                         /* Describe the monster */
1927                                         monster_desc(m_name, m_ptr, 0);
1928
1929                                         /* Scream in pain */
1930                                         if (!ignore_unview || is_seen(m_ptr)) msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
1931
1932                                         /* Take damage from the quake */
1933                                         damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
1934
1935                                         /* Monster is certainly awake */
1936                                         (void)set_monster_csleep(c_ptr->m_idx, 0);
1937
1938                                         /* Apply damage directly */
1939                                         m_ptr->hp -= damage;
1940
1941                                         /* Delete (not kill) "dead" monsters */
1942                                         if (m_ptr->hp < 0)
1943                                         {
1944                                                 if (!ignore_unview || is_seen(m_ptr)) 
1945                                                         msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
1946
1947                                                 if (c_ptr->m_idx)
1948                                                 {
1949                                                         if (record_named_pet && is_pet(&m_list[c_ptr->m_idx]) && m_list[c_ptr->m_idx].nickname)
1950                                                         {
1951                                                                 char m2_name[80];
1952
1953                                                                 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
1954                                                                 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
1955                                                         }
1956                                                 }
1957
1958
1959                                                 delete_monster(yy, xx);
1960
1961                                                 /* No longer safe */
1962                                                 sn = 0;
1963                                         }
1964
1965                                         /* Hack -- Escape from the rock */
1966                                         if (sn)
1967                                         {
1968                                                 IDX m_idx_aux = cave[yy][xx].m_idx;
1969
1970                                                 /* Update the old location */
1971                                                 cave[yy][xx].m_idx = 0;
1972
1973                                                 /* Update the new location */
1974                                                 cave[sy][sx].m_idx = m_idx_aux;
1975
1976                                                 /* Move the monster */
1977                                                 m_ptr->fy = sy;
1978                                                 m_ptr->fx = sx;
1979
1980                                                 /* Update the monster (new location) */
1981                                                 update_monster(m_idx, TRUE);
1982
1983                                                 /* Redraw the old grid */
1984                                                 lite_spot(yy, xx);
1985
1986                                                 /* Redraw the new grid */
1987                                                 lite_spot(sy, sx);
1988                                         }
1989                                 }
1990                         }
1991                 }
1992         }
1993
1994         /* Lose monster light */
1995         clear_mon_lite();
1996
1997         /* Examine the quaked region */
1998         for (dy = -r; dy <= r; dy++)
1999         {
2000                 for (dx = -r; dx <= r; dx++)
2001                 {
2002                         /* Extract the location */
2003                         yy = cy + dy;
2004                         xx = cx + dx;
2005
2006                         /* Skip unaffected grids */
2007                         if (!map[16+yy-cy][16+xx-cx]) continue;
2008
2009                         /* Access the cave grid */
2010                         c_ptr = &cave[yy][xx];
2011
2012                         /* Paranoia -- never affect player */
2013 /*                      if (player_bold(yy, xx)) continue; */
2014
2015                         /* Destroy location (if valid) */
2016                         if (cave_valid_bold(yy, xx))
2017                         {
2018                                 /* Delete objects */
2019                                 delete_object(yy, xx);
2020
2021                                 /* Wall (or floor) type */
2022                                 t = cave_have_flag_bold(yy, xx, FF_PROJECT) ? randint0(100) : 200;
2023
2024                                 /* Granite */
2025                                 if (t < 20)
2026                                 {
2027                                         /* Create granite wall */
2028                                         cave_set_feat(yy, xx, feat_granite);
2029                                 }
2030
2031                                 /* Quartz */
2032                                 else if (t < 70)
2033                                 {
2034                                         /* Create quartz vein */
2035                                         cave_set_feat(yy, xx, feat_quartz_vein);
2036                                 }
2037
2038                                 /* Magma */
2039                                 else if (t < 100)
2040                                 {
2041                                         /* Create magma vein */
2042                                         cave_set_feat(yy, xx, feat_magma_vein);
2043                                 }
2044
2045                                 /* Floor */
2046                                 else
2047                                 {
2048                                         /* Create floor */
2049                                         cave_set_feat(yy, xx, floor_type[randint0(100)]);
2050                                 }
2051                         }
2052                 }
2053         }
2054
2055
2056         /* Process "re-glowing" */
2057         for (dy = -r; dy <= r; dy++)
2058         {
2059                 for (dx = -r; dx <= r; dx++)
2060                 {
2061                         /* Extract the location */
2062                         yy = cy + dy;
2063                         xx = cx + dx;
2064
2065                         /* Skip illegal grids */
2066                         if (!in_bounds(yy, xx)) continue;
2067
2068                         /* Skip distant grids */
2069                         if (distance(cy, cx, yy, xx) > r) continue;
2070                         c_ptr = &cave[yy][xx];
2071
2072                         if (is_mirror_grid(c_ptr)) c_ptr->info |= CAVE_GLOW;
2073                         else if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
2074                         {
2075                                 int ii, yyy, xxx;
2076                                 cave_type *cc_ptr;
2077
2078                                 for (ii = 0; ii < 9; ii++)
2079                                 {
2080                                         yyy = yy + ddy_ddd[ii];
2081                                         xxx = xx + ddx_ddd[ii];
2082                                         if (!in_bounds2(yyy, xxx)) continue;
2083                                         cc_ptr = &cave[yyy][xxx];
2084                                         if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
2085                                         {
2086                                                 c_ptr->info |= CAVE_GLOW;
2087                                                 break;
2088                                         }
2089                                 }
2090                         }
2091                 }
2092         }
2093
2094
2095         /* Mega-Hack -- Forget the view and lite */
2096         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2097
2098         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
2099
2100         /* Update the health bar */
2101         p_ptr->redraw |= (PR_HEALTH | PR_UHEALTH);
2102
2103         p_ptr->redraw |= (PR_MAP);
2104
2105         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2106
2107         if (p_ptr->special_defense & NINJA_S_STEALTH)
2108         {
2109                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
2110         }
2111
2112         /* Success */
2113         return (TRUE);
2114 }
2115
2116 /*!
2117  * @brief 地震処理(プレイヤーの中心発動) /
2118  * Induce an "earthquake" of the given radius at the given location.
2119  * @return 効力があった場合TRUEを返す
2120  * @param cy 中心Y座標
2121  * @param cx 中心X座標
2122  * @param r 効果半径
2123  */
2124 bool earthquake(POSITION cy, POSITION cx, POSITION r)
2125 {
2126         return earthquake_aux(cy, cx, r, 0);
2127 }
2128
2129 /*!
2130  * @brief ペット爆破処理 /
2131  * @return なし
2132  */
2133 void discharge_minion(void)
2134 {
2135         MONSTER_IDX i;
2136         bool okay = TRUE;
2137
2138         for (i = 1; i < m_max; i++)
2139         {
2140                 monster_type *m_ptr = &m_list[i];
2141                 if (!m_ptr->r_idx || !is_pet(m_ptr)) continue;
2142                 if (m_ptr->nickname) okay = FALSE;
2143         }
2144         if (!okay || p_ptr->riding)
2145         {
2146                 if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? ")))
2147                         return;
2148         }
2149         for (i = 1; i < m_max; i++)
2150         {
2151                 HIT_POINT dam;
2152                 monster_type *m_ptr = &m_list[i];
2153                 monster_race *r_ptr;
2154
2155                 if (!m_ptr->r_idx || !is_pet(m_ptr)) continue;
2156                 r_ptr = &r_info[m_ptr->r_idx];
2157
2158                 /* Uniques resist discharging */
2159                 if (r_ptr->flags1 & RF1_UNIQUE)
2160                 {
2161                         char m_name[80];
2162                         monster_desc(m_name, m_ptr, 0x00);
2163                         msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists to be blasted, and run away."), m_name);
2164                         delete_monster_idx(i);
2165                         continue;
2166                 }
2167                 dam = m_ptr->maxhp / 2;
2168                 if (dam > 100) dam = (dam-100)/2 + 100;
2169                 if (dam > 400) dam = (dam-400)/2 + 400;
2170                 if (dam > 800) dam = 800;
2171                 project(i, 2+(r_ptr->level/20), m_ptr->fy,
2172                         m_ptr->fx, dam, GF_PLASMA, 
2173                         PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
2174
2175                 if (record_named_pet && m_ptr->nickname)
2176                 {
2177                         char m_name[80];
2178
2179                         monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2180                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name);
2181                 }
2182
2183                 delete_monster_idx(i);
2184         }
2185 }
2186
2187
2188 /*!
2189  * @brief 部屋全体を照らすサブルーチン
2190  * @return なし
2191  * @details
2192  * <pre>
2193  * This routine clears the entire "temp" set.
2194  * This routine will Perma-Lite all "temp" grids.
2195  * This routine is used (only) by "lite_room()"
2196  * Dark grids are illuminated.
2197  * Also, process all affected monsters.
2198  *
2199  * SMART monsters always wake up when illuminated
2200  * NORMAL monsters wake up 1/4 the time when illuminated
2201  * STUPID monsters wake up 1/10 the time when illuminated
2202  * </pre>
2203  */
2204 static void cave_temp_room_lite(void)
2205 {
2206         int i;
2207
2208         /* Clear them all */
2209         for (i = 0; i < temp_n; i++)
2210         {
2211                 POSITION y = temp_y[i];
2212                 POSITION x = temp_x[i];
2213
2214                 cave_type *c_ptr = &cave[y][x];
2215
2216                 /* No longer in the array */
2217                 c_ptr->info &= ~(CAVE_TEMP);
2218
2219                 /* Update only non-CAVE_GLOW grids */
2220                 /* if (c_ptr->info & (CAVE_GLOW)) continue; */
2221
2222                 /* Perma-Lite */
2223                 c_ptr->info |= (CAVE_GLOW);
2224
2225                 /* Process affected monsters */
2226                 if (c_ptr->m_idx)
2227                 {
2228                         int chance = 25;
2229
2230                         monster_type    *m_ptr = &m_list[c_ptr->m_idx];
2231
2232                         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
2233                         update_monster(c_ptr->m_idx, FALSE);
2234
2235                         /* Stupid monsters rarely wake up */
2236                         if (r_ptr->flags2 & (RF2_STUPID)) chance = 10;
2237
2238                         /* Smart monsters always wake up */
2239                         if (r_ptr->flags2 & (RF2_SMART)) chance = 100;
2240
2241                         /* Sometimes monsters wake up */
2242                         if (MON_CSLEEP(m_ptr) && (randint0(100) < chance))
2243                         {
2244                                 /* Wake up! */
2245                                 (void)set_monster_csleep(c_ptr->m_idx, 0);
2246
2247                                 /* Notice the "waking up" */
2248                                 if (m_ptr->ml)
2249                                 {
2250                                         char m_name[80];
2251
2252                                         /* Acquire the monster name */
2253                                         monster_desc(m_name, m_ptr, 0);
2254
2255                                         /* Dump a message */
2256                                         msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
2257                                 }
2258                         }
2259                 }
2260
2261                 /* Note */
2262                 note_spot(y, x);
2263
2264                 /* Redraw */
2265                 lite_spot(y, x);
2266
2267                 update_local_illumination(y, x);
2268         }
2269
2270         /* None left */
2271         temp_n = 0;
2272 }
2273
2274
2275
2276 /*!
2277  * @brief 部屋全体を暗くするサブルーチン
2278  * @return なし
2279  * @details
2280  * <pre>
2281  * This routine clears the entire "temp" set.
2282  * This routine will "darken" all "temp" grids.
2283  * In addition, some of these grids will be "unmarked".
2284  * This routine is used (only) by "unlite_room()"
2285  * Also, process all affected monsters
2286  * </pre>
2287  */
2288 static void cave_temp_room_unlite(void)
2289 {
2290         int i;
2291
2292         /* Clear them all */
2293         for (i = 0; i < temp_n; i++)
2294         {
2295                 POSITION y = temp_y[i];
2296                 POSITION x = temp_x[i];
2297                 int j;
2298
2299                 cave_type *c_ptr = &cave[y][x];
2300                 bool do_dark = !is_mirror_grid(c_ptr);
2301
2302                 /* No longer in the array */
2303                 c_ptr->info &= ~(CAVE_TEMP);
2304
2305                 /* Darken the grid */
2306                 if (do_dark)
2307                 {
2308                         if (dun_level || !is_daytime())
2309                         {
2310                                 for (j = 0; j < 9; j++)
2311                                 {
2312                                         int by = y + ddy_ddd[j];
2313                                         int bx = x + ddx_ddd[j];
2314
2315                                         if (in_bounds2(by, bx))
2316                                         {
2317                                                 cave_type *cc_ptr = &cave[by][bx];
2318
2319                                                 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
2320                                                 {
2321                                                         do_dark = FALSE;
2322                                                         break;
2323                                                 }
2324                                         }
2325                                 }
2326
2327                                 if (!do_dark) continue;
2328                         }
2329
2330                         c_ptr->info &= ~(CAVE_GLOW);
2331
2332                         /* Hack -- Forget "boring" grids */
2333                         if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_REMEMBER))
2334                         {
2335                                 /* Forget the grid */
2336                                 if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
2337
2338                                 note_spot(y, x);
2339                         }
2340
2341                         /* Process affected monsters */
2342                         if (c_ptr->m_idx)
2343                         {
2344                                 update_monster(c_ptr->m_idx, FALSE);
2345                         }
2346
2347                         /* Redraw */
2348                         lite_spot(y, x);
2349
2350                         update_local_illumination(y, x);
2351                 }
2352         }
2353
2354         /* None left */
2355         temp_n = 0;
2356 }
2357
2358
2359 /*!
2360  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2361  * @param cy Y座標
2362  * @param cx X座標
2363  * @param pass_bold 地形条件を返す関数ポインタ
2364  * @return 該当地形の数
2365  */
2366 static int next_to_open(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2367 {
2368         int i;
2369         POSITION y, x;
2370         int len = 0;
2371         int blen = 0;
2372
2373         for (i = 0; i < 16; i++)
2374         {
2375                 y = cy + ddy_cdd[i % 8];
2376                 x = cx + ddx_cdd[i % 8];
2377
2378                 /* Found a wall, break the length */
2379                 if (!pass_bold(y, x))
2380                 {
2381                         /* Track best length */
2382                         if (len > blen)
2383                         {
2384                                 blen = len;
2385                         }
2386
2387                         len = 0;
2388                 }
2389                 else
2390                 {
2391                         len++;
2392                 }
2393         }
2394
2395         return (MAX(len, blen));
2396 }
2397
2398 /*!
2399  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2400  * @param cy Y座標
2401  * @param cx X座標
2402  * @param pass_bold 地形条件を返す関数ポインタ
2403  * @return 該当地形の数
2404  */
2405 static int next_to_walls_adj(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2406 {
2407         DIRECTION i;
2408         POSITION y, x;
2409         int c = 0;
2410
2411         for (i = 0; i < 8; i++)
2412         {
2413                 y = cy + ddy_ddd[i];
2414                 x = cx + ddx_ddd[i];
2415
2416                 if (!pass_bold(y, x)) c++;
2417         }
2418
2419         return c;
2420 }
2421
2422
2423 /*!
2424  * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数temp_nに返す / Aux function -- see below
2425  * @param y 部屋内のy座標1点
2426  * @param x 部屋内のx座標1点
2427  * @param only_room 部屋内地形のみをチェック対象にするならば TRUE
2428  * @param pass_bold 地形条件を返す関数ポインタ
2429  * @return 該当地形の数
2430  */
2431 static void cave_temp_room_aux(POSITION y, POSITION x, bool only_room, bool (*pass_bold)(POSITION, POSITION))
2432 {
2433         cave_type *c_ptr;
2434
2435         /* Get the grid */
2436         c_ptr = &cave[y][x];
2437
2438         /* Avoid infinite recursion */
2439         if (c_ptr->info & (CAVE_TEMP)) return;
2440
2441         /* Do not "leave" the current room */
2442         if (!(c_ptr->info & (CAVE_ROOM)))
2443         {
2444                 if (only_room) return;
2445
2446                 /* Verify */
2447                 if (!in_bounds2(y, x)) return;
2448
2449                 /* Do not exceed the maximum spell range */
2450                 if (distance(p_ptr->y, p_ptr->x, y, x) > MAX_RANGE) return;
2451
2452                 /* Verify this grid */
2453                 /*
2454                  * The reason why it is ==6 instead of >5 is that 8 is impossible
2455                  * due to the check for cave_bold above.
2456                  * 7 lights dead-end corridors (you need to do this for the
2457                  * checkboard interesting rooms, so that the boundary is lit
2458                  * properly.
2459                  * This leaves only a check for 6 bounding walls!
2460                  */
2461                 if (in_bounds(y, x) && pass_bold(y, x) &&
2462                     (next_to_walls_adj(y, x, pass_bold) == 6) && (next_to_open(y, x, pass_bold) <= 1)) return;
2463         }
2464
2465         /* Paranoia -- verify space */
2466         if (temp_n == TEMP_MAX) return;
2467
2468         /* Mark the grid as "seen" */
2469         c_ptr->info |= (CAVE_TEMP);
2470
2471         /* Add it to the "seen" set */
2472         temp_y[temp_n] = y;
2473         temp_x[temp_n] = x;
2474         temp_n++;
2475 }
2476
2477 /*!
2478  * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
2479  * @param y 指定Y座標
2480  * @param x 指定X座標
2481  * @return 光を通すならばtrueを返す。
2482  */
2483 static bool cave_pass_lite_bold(POSITION y, POSITION x)
2484 {
2485         return cave_los_bold(y, x);
2486 }
2487
2488 /*!
2489  * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数temp_nに返す / Aux function -- see below
2490  * @param y 指定Y座標
2491  * @param x 指定X座標
2492  * @return なし
2493  */
2494 static void cave_temp_lite_room_aux(POSITION y, POSITION x)
2495 {
2496         cave_temp_room_aux(y, x, FALSE, cave_pass_lite_bold);
2497 }
2498
2499 /*!
2500  * @brief 指定のマスが光を通さず射線のみを通すかを返す。 / Aux function -- see below
2501  * @param y 指定Y座標
2502  * @param x 指定X座標
2503  * @return 射線を通すならばtrueを返す。
2504  */
2505 static bool cave_pass_dark_bold(POSITION y, POSITION x)
2506 {
2507         return cave_have_flag_bold(y, x, FF_PROJECT);
2508 }
2509
2510
2511 /*!
2512  * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数temp_nに返す / Aux function -- see below
2513  * @param y 指定Y座標
2514  * @param x 指定X座標
2515  * @return なし
2516  */
2517 static void cave_temp_unlite_room_aux(POSITION y, POSITION x)
2518 {
2519         cave_temp_room_aux(y, x, TRUE, cave_pass_dark_bold);
2520 }
2521
2522
2523 /*!
2524  * @brief 指定された部屋内を照らす / Illuminate any room containing the given location.
2525  * @param y1 指定Y座標
2526  * @param x1 指定X座標
2527  * @return なし
2528  */
2529 void lite_room(POSITION y1, POSITION x1)
2530 {
2531         int i;
2532         POSITION x, y;
2533
2534         /* Add the initial grid */
2535         cave_temp_lite_room_aux(y1, x1);
2536
2537         /* While grids are in the queue, add their neighbors */
2538         for (i = 0; i < temp_n; i++)
2539         {
2540                 x = temp_x[i], y = temp_y[i];
2541
2542                 /* Walls get lit, but stop light */
2543                 if (!cave_pass_lite_bold(y, x)) continue;
2544
2545                 /* Spread adjacent */
2546                 cave_temp_lite_room_aux(y + 1, x);
2547                 cave_temp_lite_room_aux(y - 1, x);
2548                 cave_temp_lite_room_aux(y, x + 1);
2549                 cave_temp_lite_room_aux(y, x - 1);
2550
2551                 /* Spread diagonal */
2552                 cave_temp_lite_room_aux(y + 1, x + 1);
2553                 cave_temp_lite_room_aux(y - 1, x - 1);
2554                 cave_temp_lite_room_aux(y - 1, x + 1);
2555                 cave_temp_lite_room_aux(y + 1, x - 1);
2556         }
2557
2558         /* Now, lite them all up at once */
2559         cave_temp_room_lite();
2560
2561         if (p_ptr->special_defense & NINJA_S_STEALTH)
2562         {
2563                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
2564         }
2565 }
2566
2567
2568 /*!
2569  * @brief 指定された部屋内を暗くする / Darken all rooms containing the given location
2570  * @param y1 指定Y座標
2571  * @param x1 指定X座標
2572  * @return なし
2573  */
2574 void unlite_room(POSITION y1, POSITION x1)
2575 {
2576         int i;
2577         POSITION x, y;
2578
2579         /* Add the initial grid */
2580         cave_temp_unlite_room_aux(y1, x1);
2581
2582         /* Spread, breadth first */
2583         for (i = 0; i < temp_n; i++)
2584         {
2585                 x = temp_x[i], y = temp_y[i];
2586
2587                 /* Walls get dark, but stop darkness */
2588                 if (!cave_pass_dark_bold(y, x)) continue;
2589
2590                 /* Spread adjacent */
2591                 cave_temp_unlite_room_aux(y + 1, x);
2592                 cave_temp_unlite_room_aux(y - 1, x);
2593                 cave_temp_unlite_room_aux(y, x + 1);
2594                 cave_temp_unlite_room_aux(y, x - 1);
2595
2596                 /* Spread diagonal */
2597                 cave_temp_unlite_room_aux(y + 1, x + 1);
2598                 cave_temp_unlite_room_aux(y - 1, x - 1);
2599                 cave_temp_unlite_room_aux(y - 1, x + 1);
2600                 cave_temp_unlite_room_aux(y + 1, x - 1);
2601         }
2602
2603         /* Now, darken them all at once */
2604         cave_temp_room_unlite();
2605 }
2606
2607
2608
2609 /*!
2610  * @brief プレイヤー位置を中心にLITE_WEAK属性を通じた照明処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2611  * @param dam 威力
2612  * @param rad 効果半径
2613  * @return 作用が実際にあった場合TRUEを返す
2614  */
2615 bool lite_area(HIT_POINT dam, POSITION rad)
2616 {
2617         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2618
2619         if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
2620         {
2621                 msg_print(_("ダンジョンが光を吸収した。", "The darkness of this dungeon absorb your light."));
2622                 return FALSE;
2623         }
2624
2625         /* Hack -- Message */
2626         if (!p_ptr->blind)
2627         {
2628                 msg_print(_("白い光が辺りを覆った。", "You are surrounded by a white light."));
2629         }
2630
2631         /* Hook into the "project()" function */
2632         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_LITE_WEAK, flg, -1);
2633
2634         /* Lite up the room */
2635         lite_room(p_ptr->y, p_ptr->x);
2636
2637         /* Assume seen */
2638         return (TRUE);
2639 }
2640
2641
2642 /*!
2643  * @brief プレイヤー位置を中心にLITE_DARK属性を通じた消灯処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2644  * @param dam 威力
2645  * @param rad 効果半径
2646  * @return 作用が実際にあった場合TRUEを返す
2647  */
2648 bool unlite_area(HIT_POINT dam, POSITION rad)
2649 {
2650         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2651
2652         /* Hack -- Message */
2653         if (!p_ptr->blind)
2654         {
2655                 msg_print(_("暗闇が辺りを覆った。", "Darkness surrounds you."));
2656         }
2657
2658         /* Hook into the "project()" function */
2659         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_DARK_WEAK, flg, -1);
2660
2661         /* Lite up the room */
2662         unlite_room(p_ptr->y, p_ptr->x);
2663
2664         /* Assume seen */
2665         return (TRUE);
2666 }
2667
2668
2669
2670 /*!
2671  * @brief ボール系スペルの発動 / Cast a ball spell
2672  * @param typ 効果属性
2673  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2674  * @param dam 威力
2675  * @param rad 半径
2676  * @return 作用が実際にあった場合TRUEを返す
2677  * @details
2678  * <pre>
2679  * Stop if we hit a monster, act as a "ball"
2680  * Allow "target" mode to pass over monsters
2681  * Affect grids, objects, and monsters
2682  * </pre>
2683  */
2684 bool fire_ball(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2685 {
2686         POSITION tx, ty;
2687
2688         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2689
2690         if (typ == GF_CHARM_LIVING) flg|= PROJECT_HIDE;
2691         /* Use the given direction */
2692         tx = p_ptr->x + 99 * ddx[dir];
2693         ty = p_ptr->y + 99 * ddy[dir];
2694
2695         /* Hack -- Use an actual "target" */
2696         if ((dir == 5) && target_okay())
2697         {
2698                 flg &= ~(PROJECT_STOP);
2699                 tx = target_col;
2700                 ty = target_row;
2701         }
2702
2703         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2704         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2705 }
2706
2707 /*!
2708 * @brief ブレス系スペルの発動 / Cast a breath spell
2709 * @param typ 効果属性
2710 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2711 * @param dam 威力
2712 * @param rad 半径
2713 * @return 作用が実際にあった場合TRUEを返す
2714 * @details
2715 * <pre>
2716 * Stop if we hit a monster, act as a "ball"
2717 * Allow "target" mode to pass over monsters
2718 * Affect grids, objects, and monsters
2719 * </pre>
2720 */
2721 bool fire_breath(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2722 {
2723         return fire_ball(typ, dir, dam, -rad);
2724 }
2725
2726
2727 /*!
2728  * @brief ロケット系スペルの発動(詳細な差は確認中) / Cast a ball spell
2729  * @param typ 効果属性
2730  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2731  * @param dam 威力
2732  * @param rad 半径
2733  * @return 作用が実際にあった場合TRUEを返す
2734  * @details
2735  * <pre>
2736  * Stop if we hit a monster, act as a "ball"
2737  * Allow "target" mode to pass over monsters
2738  * Affect grids, objects, and monsters
2739  * </pre>
2740  */
2741 bool fire_rocket(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2742 {
2743         POSITION tx, ty;
2744         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2745
2746         /* Use the given direction */
2747         tx = p_ptr->x + 99 * ddx[dir];
2748         ty = p_ptr->y + 99 * ddy[dir];
2749
2750         /* Hack -- Use an actual "target" */
2751         if ((dir == 5) && target_okay())
2752         {
2753                 tx = target_col;
2754                 ty = target_row;
2755         }
2756
2757         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2758         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2759 }
2760
2761
2762 /*!
2763  * @brief ボール(ハイド)系スペルの発動 / Cast a ball spell
2764  * @param typ 効果属性
2765  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2766  * @param dam 威力
2767  * @param rad 半径
2768  * @return 作用が実際にあった場合TRUEを返す
2769  * @details
2770  * <pre>
2771  * Stop if we hit a monster, act as a "ball"
2772  * Allow "target" mode to pass over monsters
2773  * Affect grids, objects, and monsters
2774  * </pre>
2775  */
2776 bool fire_ball_hide(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2777 {
2778         POSITION tx, ty;
2779         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE;
2780
2781         /* Use the given direction */
2782         tx = p_ptr->x + 99 * ddx[dir];
2783         ty = p_ptr->y + 99 * ddy[dir];
2784
2785         /* Hack -- Use an actual "target" */
2786         if ((dir == 5) && target_okay())
2787         {
2788                 flg &= ~(PROJECT_STOP);
2789                 tx = target_col;
2790                 ty = target_row;
2791         }
2792
2793         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2794         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2795 }
2796
2797
2798 /*!
2799  * @brief メテオ系スペルの発動 / Cast a meteor spell
2800  * @param who スぺル詠唱者のモンスターID(0=プレイヤー)
2801  * @param typ 効果属性
2802  * @param dam 威力
2803  * @param rad 半径
2804  * @param y 中心点Y座標
2805  * @param x 中心点X座標
2806  * @return 作用が実際にあった場合TRUEを返す
2807  * @details
2808  * <pre>
2809  * Cast a meteor spell, defined as a ball spell cast by an arbitary monster, 
2810  * player, or outside source, that starts out at an arbitrary location, and 
2811  * leaving no trail from the "caster" to the target.  This function is 
2812  * especially useful for bombardments and similar. -LM-
2813  * Option to hurt the player.
2814  * </pre>
2815  */
2816 bool fire_meteor(MONSTER_IDX who, EFFECT_ID typ, POSITION y, POSITION x, HIT_POINT dam, POSITION rad)
2817 {
2818         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2819
2820         /* Analyze the "target" and the caster. */
2821         return (project(who, rad, y, x, dam, typ, flg, -1));
2822 }
2823
2824
2825 /*!
2826  * @brief ブラスト系スペルの発動 / Cast a blast spell
2827  * @param typ 効果属性
2828  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2829  * @param dd 威力ダイス数
2830  * @param ds 威力ダイス目
2831  * @param num 基本回数
2832  * @param dev 回数分散
2833  * @return 作用が実際にあった場合TRUEを返す
2834  */
2835 bool fire_blast(EFFECT_ID typ, DIRECTION dir, int dd, int ds, int num, int dev)
2836 {
2837         POSITION ly, lx;
2838         int ld;
2839         POSITION ty, tx, y, x;
2840         int i;
2841
2842         BIT_FLAGS flg = PROJECT_FAST | PROJECT_THRU | PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE | PROJECT_GRID;
2843
2844         /* Assume okay */
2845         bool result = TRUE;
2846
2847         /* Use the given direction */
2848         if (dir != 5)
2849         {
2850                 ly = ty = p_ptr->y + 20 * ddy[dir];
2851                 lx = tx = p_ptr->x + 20 * ddx[dir];
2852         }
2853
2854         /* Use an actual "target" */
2855         else /* if (dir == 5) */
2856         {
2857                 tx = target_col;
2858                 ty = target_row;
2859
2860                 lx = 20 * (tx - p_ptr->x) + p_ptr->x;
2861                 ly = 20 * (ty - p_ptr->y) + p_ptr->y;
2862         }
2863
2864         ld = distance(p_ptr->y, p_ptr->x, ly, lx);
2865
2866         /* Blast */
2867         for (i = 0; i < num; i++)
2868         {
2869                 while (1)
2870                 {
2871                         /* Get targets for some bolts */
2872                         y = rand_spread(ly, ld * dev / 20);
2873                         x = rand_spread(lx, ld * dev / 20);
2874
2875                         if (distance(ly, lx, y, x) <= ld * dev / 20) break;
2876                 }
2877
2878                 /* Analyze the "dir" and the "target". */
2879                 if (!project(0, 0, y, x, damroll(dd, ds), typ, flg, -1))
2880                 {
2881                         result = FALSE;
2882                 }
2883         }
2884
2885         return (result);
2886 }
2887
2888
2889 /*!
2890  * @brief モンスターとの位置交換処理 / Switch position with a monster.
2891  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2892  * @return 作用が実際にあった場合TRUEを返す
2893  */
2894 bool teleport_swap(DIRECTION dir)
2895 {
2896         POSITION tx, ty;
2897         cave_type* c_ptr;
2898         monster_type* m_ptr;
2899         monster_race* r_ptr;
2900
2901         if ((dir == 5) && target_okay())
2902         {
2903                 tx = target_col;
2904                 ty = target_row;
2905         }
2906         else
2907         {
2908                 tx = p_ptr->x + ddx[dir];
2909                 ty = p_ptr->y + ddy[dir];
2910         }
2911         c_ptr = &cave[ty][tx];
2912
2913         if (p_ptr->anti_tele)
2914         {
2915                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
2916                 return FALSE;
2917         }
2918
2919         if (!c_ptr->m_idx || (c_ptr->m_idx == p_ptr->riding))
2920         {
2921                 msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
2922
2923                 /* Failure */
2924                 return FALSE;
2925         }
2926
2927         if ((c_ptr->info & CAVE_ICKY) || (distance(ty, tx, p_ptr->y, p_ptr->x) > p_ptr->lev * 3 / 2 + 10))
2928         {
2929                 msg_print(_("失敗した。", "Failed to swap."));
2930
2931                 /* Failure */
2932                 return FALSE;
2933         }
2934
2935         m_ptr = &m_list[c_ptr->m_idx];
2936         r_ptr = &r_info[m_ptr->r_idx];
2937
2938         (void)set_monster_csleep(c_ptr->m_idx, 0);
2939
2940         if (r_ptr->flagsr & RFR_RES_TELE)
2941         {
2942                 msg_print(_("テレポートを邪魔された!", "Your teleportation is blocked!"));
2943
2944                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2945
2946                 /* Failure */
2947                 return FALSE;
2948         }
2949
2950         sound(SOUND_TELEPORT);
2951
2952         /* Swap the player and monster */
2953         (void)move_player_effect(ty, tx, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
2954
2955         /* Success */
2956         return TRUE;
2957 }
2958
2959
2960 /*!
2961  * @brief 指定方向に飛び道具を飛ばす(フラグ任意指定) / Hack -- apply a "projection()" in a direction (or at the target)
2962  * @param typ 効果属性
2963  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2964  * @param dam 威力
2965  * @param flg フラグ
2966  * @return 作用が実際にあった場合TRUEを返す
2967  */
2968 bool project_hook(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, BIT_FLAGS flg)
2969 {
2970         int tx, ty;
2971
2972         /* Pass through the target if needed */
2973         flg |= (PROJECT_THRU);
2974
2975         /* Use the given direction */
2976         tx = p_ptr->x + ddx[dir];
2977         ty = p_ptr->y + ddy[dir];
2978
2979         /* Hack -- Use an actual "target" */
2980         if ((dir == 5) && target_okay())
2981         {
2982                 tx = target_col;
2983                 ty = target_row;
2984         }
2985
2986         /* Analyze the "dir" and the "target", do NOT explode */
2987         return (project(0, 0, ty, tx, dam, typ, flg, -1));
2988 }
2989
2990
2991 /*!
2992  * @brief ボルト系スペルの発動 / Cast a bolt spell.
2993  * @param typ 効果属性
2994  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2995  * @param dam 威力
2996  * @return 作用が実際にあった場合TRUEを返す
2997  * @details
2998  * <pre>
2999  * Stop if we hit a monster, as a "bolt".
3000  * Affect monsters and grids (not objects).
3001  * </pre>
3002  */
3003 bool fire_bolt(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3004 {
3005         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_GRID;
3006         if (typ != GF_ARROW) flg |= PROJECT_REFLECTABLE;
3007         return (project_hook(typ, dir, dam, flg));
3008 }
3009
3010
3011 /*!
3012  * @brief ビーム系スペルの発動 / Cast a beam spell.
3013  * @param typ 効果属性
3014  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3015  * @param dam 威力
3016  * @return 作用が実際にあった場合TRUEを返す
3017  * @details
3018  * <pre>
3019  * Pass through monsters, as a "beam".
3020  * Affect monsters, grids and objects.
3021  * </pre>
3022  */
3023 bool fire_beam(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3024 {
3025         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM;
3026         return (project_hook(typ, dir, dam, flg));
3027 }
3028
3029
3030 /*!
3031  * @brief 確率に応じたボルト系/ビーム系スペルの発動 / Cast a bolt spell, or rarely, a beam spell.
3032  * @param prob ビーム化する確率(%)
3033  * @param typ 効果属性
3034  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3035  * @param dam 威力
3036  * @return 作用が実際にあった場合TRUEを返す
3037  * @details
3038  * <pre>
3039  * Pass through monsters, as a "beam".
3040  * Affect monsters, grids and objects.
3041  * </pre>
3042  */
3043 bool fire_bolt_or_beam(PERCENTAGE prob, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3044 {
3045         if (randint0(100) < prob)
3046         {
3047                 return (fire_beam(typ, dir, dam));
3048         }
3049         else
3050         {
3051                 return (fire_bolt(typ, dir, dam));
3052         }
3053 }
3054
3055 /*!
3056  * @brief LITE_WEAK属性による光源ビーム処理
3057  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3058  * @param dam 威力
3059  * @return 作用が実際にあった場合TRUEを返す
3060  */
3061 bool lite_line(DIRECTION dir, HIT_POINT dam)
3062 {
3063         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_KILL;
3064         return (project_hook(GF_LITE_WEAK, dir, dam, flg));
3065 }
3066
3067 /*!
3068  * @brief 衰弱ボルト処理
3069  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3070  * @param dam 威力
3071  * @return 作用が実際にあった場合TRUEを返す
3072  */
3073 bool hypodynamic_bolt(DIRECTION dir, HIT_POINT dam)
3074 {
3075         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3076         return (project_hook(GF_HYPODYNAMIA, dir, dam, flg));
3077 }
3078
3079 /*!
3080  * @brief 岩石溶解処理
3081  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3082  * @param dam 威力
3083  * @return 作用が実際にあった場合TRUEを返す
3084  */
3085 bool wall_to_mud(DIRECTION dir, HIT_POINT dam)
3086 {
3087         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3088         return (project_hook(GF_KILL_WALL, dir, dam, flg));
3089 }
3090
3091 /*!
3092  * @brief 魔法の施錠処理
3093  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3094  * @return 作用が実際にあった場合TRUEを返す
3095  */
3096 bool wizard_lock(DIRECTION dir)
3097 {
3098         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3099         return (project_hook(GF_JAM_DOOR, dir, 20 + randint1(30), flg));
3100 }
3101
3102 /*!
3103  * @brief ドア破壊処理
3104  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3105  * @return 作用が実際にあった場合TRUEを返す
3106  */
3107 bool destroy_door(DIRECTION dir)
3108 {
3109         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3110         return (project_hook(GF_KILL_DOOR, dir, 0, flg));
3111 }
3112
3113 /*!
3114  * @brief トラップ解除処理
3115  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3116  * @return 作用が実際にあった場合TRUEを返す
3117  */
3118 bool disarm_trap(DIRECTION dir)
3119 {
3120         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3121         return (project_hook(GF_KILL_TRAP, dir, 0, flg));
3122 }
3123
3124 /*!
3125  * @brief モンスター回復処理
3126  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3127  * @param dam 威力
3128  * @return 作用が実際にあった場合TRUEを返す
3129  */
3130 bool heal_monster(DIRECTION dir, HIT_POINT dam)
3131 {
3132         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3133         return (project_hook(GF_OLD_HEAL, dir, dam, flg));
3134 }
3135
3136 /*!
3137  * @brief モンスター加速処理
3138  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3139  * @param power 効力
3140  * @return 作用が実際にあった場合TRUEを返す
3141  */
3142 bool speed_monster(DIRECTION dir, int power)
3143 {
3144         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3145         return (project_hook(GF_OLD_SPEED, dir, power, flg));
3146 }
3147
3148 /*!
3149  * @brief モンスター減速処理
3150  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3151  * @param power 効力
3152  * @return 作用が実際にあった場合TRUEを返す
3153  */
3154 bool slow_monster(DIRECTION dir, int power)
3155 {
3156         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3157         return (project_hook(GF_OLD_SLOW, dir, power, flg));
3158 }
3159
3160 /*!
3161  * @brief モンスター催眠処理
3162  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3163  * @param power 効力
3164  * @return 作用が実際にあった場合TRUEを返す
3165  */
3166 bool sleep_monster(DIRECTION dir, int power)
3167 {
3168         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3169         return (project_hook(GF_OLD_SLEEP, dir, power, flg));
3170 }
3171
3172 /*!
3173  * @brief モンスター拘束(STASIS)処理
3174  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3175  * @return 作用が実際にあった場合TRUEを返す
3176  * @details 威力はプレイヤーレベル*2に固定
3177  */
3178 bool stasis_monster(DIRECTION dir)
3179 {
3180         return (fire_ball_hide(GF_STASIS, dir, p_ptr->lev*2, 0));
3181 }
3182
3183 /*!
3184  * @brief 邪悪なモンスター拘束(STASIS)処理
3185  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3186  * @return 作用が実際にあった場合TRUEを返す
3187  * @details 威力はプレイヤーレベル*2に固定
3188  */
3189 bool stasis_evil(DIRECTION dir)
3190 {
3191         return (fire_ball_hide(GF_STASIS_EVIL, dir, p_ptr->lev*2, 0));
3192 }
3193
3194 /*!
3195  * @brief モンスター混乱処理
3196  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3197  * @param plev プレイヤーレベル(=効力)
3198  * @return 作用が実際にあった場合TRUEを返す
3199  */
3200 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
3201 {
3202         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3203         return (project_hook(GF_OLD_CONF, dir, plev, flg));
3204 }
3205
3206 /*!
3207  * @brief モンスター朦朧処理
3208  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3209  * @param plev プレイヤーレベル(=効力)
3210  * @return 作用が実際にあった場合TRUEを返す
3211  */
3212 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
3213 {
3214         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3215         return (project_hook(GF_STUN, dir, plev, flg));
3216 }
3217
3218 /*!
3219  * @brief チェンジモンスター処理
3220  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3221  * @param power 効力
3222  * @return 作用が実際にあった場合TRUEを返す
3223  */
3224 bool poly_monster(DIRECTION dir, int power)
3225 {
3226         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3227         bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
3228         if (tester)
3229                 chg_virtue(V_CHANCE, 1);
3230         return(tester);
3231 }
3232
3233 /*!
3234  * @brief クローンモンスター処理
3235  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3236  * @return 作用が実際にあった場合TRUEを返す
3237  */
3238 bool clone_monster(DIRECTION dir)
3239 {
3240         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3241         return (project_hook(GF_OLD_CLONE, dir, 0, flg));
3242 }
3243
3244 /*!
3245  * @brief モンスター恐慌処理
3246  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3247  * @param plev プレイヤーレベル(=効力)
3248  * @return 作用が実際にあった場合TRUEを返す
3249  */
3250 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
3251 {
3252         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3253         return (project_hook(GF_TURN_ALL, dir, plev, flg));
3254 }
3255
3256 /*!
3257  * @brief 死の光線処理
3258  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3259  * @param plev プレイヤーレベル(効力はplev*200)
3260  * @return 作用が実際にあった場合TRUEを返す
3261  */
3262 bool death_ray(DIRECTION dir, PLAYER_LEVEL plev)
3263 {
3264         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3265         return (project_hook(GF_DEATH_RAY, dir, plev * 200, flg));
3266 }
3267
3268 /*!
3269  * @brief モンスター用テレポート処理
3270  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3271  * @param distance 移動距離
3272  * @return 作用が実際にあった場合TRUEを返す
3273  */
3274 bool teleport_monster(DIRECTION dir, int distance)
3275 {
3276         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL;
3277         return (project_hook(GF_AWAY_ALL, dir, distance, flg));
3278 }
3279
3280 /*!
3281  * @brief ドア生成処理(プレイヤー中心に周囲1マス) / Hooks -- affect adjacent grids (radius 1 ball attack)
3282  * @return 作用が実際にあった場合TRUEを返す
3283  */
3284 bool door_creation(void)
3285 {
3286         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3287         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_DOOR, flg, -1));
3288 }
3289
3290 /*!
3291  * @brief トラップ生成処理(起点から周囲1マス)
3292  * @param y 起点Y座標
3293  * @param x 起点X座標
3294  * @return 作用が実際にあった場合TRUEを返す
3295  */
3296 bool trap_creation(POSITION y, POSITION x)
3297 {
3298         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3299         return (project(0, 1, y, x, 0, GF_MAKE_TRAP, flg, -1));
3300 }
3301
3302 /*!
3303  * @brief 森林生成処理(プレイヤー中心に周囲1マス)
3304  * @return 作用が実際にあった場合TRUEを返す
3305  */
3306 bool tree_creation(void)
3307 {
3308         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3309         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_TREE, flg, -1));
3310 }
3311
3312 /*!
3313  * @brief 魔法のルーン生成処理(プレイヤー中心に周囲1マス)
3314  * @return 作用が実際にあった場合TRUEを返す
3315  */
3316 bool glyph_creation(void)
3317 {
3318         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM;
3319         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_GLYPH, flg, -1));
3320 }
3321
3322 /*!
3323  * @brief 壁生成処理(プレイヤー中心に周囲1マス)
3324  * @return 作用が実際にあった場合TRUEを返す
3325  */
3326 bool wall_stone(void)
3327 {
3328         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3329
3330         bool dummy = (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_STONE_WALL, flg, -1));
3331
3332         p_ptr->update |= (PU_FLOW);
3333
3334         p_ptr->redraw |= (PR_MAP);
3335
3336         return dummy;
3337 }
3338
3339 /*!
3340  * @brief ドア破壊処理(プレイヤー中心に周囲1マス)
3341  * @return 作用が実際にあった場合TRUEを返す
3342  */
3343 bool destroy_doors_touch(void)
3344 {
3345         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3346         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_DOOR, flg, -1));
3347 }
3348
3349 /*!
3350  * @brief トラップ解除処理(プレイヤー中心に周囲1マス)
3351  * @return 作用が実際にあった場合TRUEを返す
3352  */
3353 bool disarm_traps_touch(void)
3354 {
3355         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3356         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_TRAP, flg, -1));
3357 }
3358
3359 /*!
3360  * @brief スリープモンスター処理(プレイヤー中心に周囲1マス)
3361  * @return 作用が実際にあった場合TRUEを返す
3362  */
3363 bool sleep_monsters_touch(void)
3364 {
3365         BIT_FLAGS flg = PROJECT_KILL | PROJECT_HIDE;
3366         return (project(0, 1, p_ptr->y, p_ptr->x, p_ptr->lev, GF_OLD_SLEEP, flg, -1));
3367 }
3368
3369
3370 /*!
3371  * @brief 死者復活処理(起点より周囲5マス)
3372  * @param who 術者モンスターID(0ならばプレイヤー)
3373  * @param y 起点Y座標
3374  * @param x 起点X座標
3375  * @return 作用が実際にあった場合TRUEを返す
3376  */
3377 bool animate_dead(MONSTER_IDX who, POSITION y, POSITION x)
3378 {
3379         BIT_FLAGS flg = PROJECT_ITEM | PROJECT_HIDE;
3380         return (project(who, 5, y, x, 0, GF_ANIM_DEAD, flg, -1));
3381 }
3382
3383 /*!
3384  * @brief 混沌招来処理
3385  * @return 作用が実際にあった場合TRUEを返す
3386  */
3387 void call_chaos(void)
3388 {
3389         int Chaos_type, dummy, dir;
3390         PLAYER_LEVEL plev = p_ptr->lev;
3391         bool line_chaos = FALSE;
3392
3393         int hurt_types[31] =
3394         {
3395                 GF_ELEC,      GF_POIS,    GF_ACID,    GF_COLD,
3396                 GF_FIRE,      GF_MISSILE, GF_ARROW,   GF_PLASMA,
3397                 GF_HOLY_FIRE, GF_WATER,   GF_LITE,    GF_DARK,
3398                 GF_FORCE,     GF_INERTIAL, GF_MANA,    GF_METEOR,
3399                 GF_ICE,       GF_CHAOS,   GF_NETHER,  GF_DISENCHANT,
3400                 GF_SHARDS,    GF_SOUND,   GF_NEXUS,   GF_CONFUSION,
3401                 GF_TIME,      GF_GRAVITY, GF_ROCKET,  GF_NUKE,
3402                 GF_HELL_FIRE, GF_DISINTEGRATE, GF_PSY_SPEAR
3403         };
3404
3405         Chaos_type = hurt_types[randint0(31)];
3406         if (one_in_(4)) line_chaos = TRUE;
3407
3408         if (one_in_(6))
3409         {
3410                 for (dummy = 1; dummy < 10; dummy++)
3411                 {
3412                         if (dummy - 5)
3413                         {
3414                                 if (line_chaos)
3415                                         fire_beam(Chaos_type, dummy, 150);
3416                                 else
3417                                         fire_ball(Chaos_type, dummy, 150, 2);
3418                         }
3419                 }
3420         }
3421         else if (one_in_(3))
3422         {
3423                 fire_ball(Chaos_type, 0, 500, 8);
3424         }
3425         else
3426         {
3427                 if (!get_aim_dir(&dir)) return;
3428                 if (line_chaos)
3429                         fire_beam(Chaos_type, dir, 250);
3430                 else
3431                         fire_ball(Chaos_type, dir, 250, 3 + (plev / 35));
3432         }
3433 }
3434
3435 /*!
3436  * @brief TY_CURSE処理発動 / Activate the evil Topi Ylinen curse
3437  * @param stop_ty 再帰処理停止フラグ
3438  * @param count 発動回数
3439  * @return 作用が実際にあった場合TRUEを返す
3440  * @details
3441  * <pre>
3442  * rr9: Stop the nasty things when a Cyberdemon is summoned
3443  * or the player gets paralyzed.
3444  * </pre>
3445  */
3446 bool activate_ty_curse(bool stop_ty, int *count)
3447 {
3448         int     i = 0;
3449
3450         BIT_FLAGS flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3451
3452         do
3453         {
3454                 switch (randint1(34))
3455                 {
3456                 case 28: case 29:
3457                         if (!(*count))
3458                         {
3459                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
3460                                 earthquake(p_ptr->y, p_ptr->x, 5 + randint0(10));
3461                                 if (!one_in_(6)) break;
3462                         }
3463                 case 30: case 31:
3464                         if (!(*count))
3465                         {
3466                                 HIT_POINT dam = damroll(10, 10);
3467                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3468                                 project(0, 8, p_ptr->y, p_ptr->x, dam, GF_MANA, flg, -1);
3469                                 take_hit(DAMAGE_NOESCAPE, dam, _("純粋な魔力の解放", "released pure mana"), -1);
3470                                 if (!one_in_(6)) break;
3471                         }
3472                 case 32: case 33:
3473                         if (!(*count))
3474                         {
3475                                 msg_print(_("周囲の空間が歪んだ!", "Space warps about you!"));
3476                                 teleport_player(damroll(10, 10), TELEPORT_PASSIVE);
3477                                 if (randint0(13)) (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3478                                 if (!one_in_(6)) break;
3479                         }
3480                 case 34:
3481                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3482                         wall_breaker();
3483                         if (!randint0(7))
3484                         {
3485                                 project(0, 7, p_ptr->y, p_ptr->x, 50, GF_KILL_WALL, flg, -1);
3486                                 take_hit(DAMAGE_NOESCAPE, 50, _("エネルギーのうねり", "surge of energy"), -1);
3487                         }
3488                         if (!one_in_(6)) break;
3489                 case 1: case 2: case 3: case 16: case 17:
3490                         aggravate_monsters(0);
3491                         if (!one_in_(6)) break;
3492                 case 4: case 5: case 6:
3493                         (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3494                         if (!one_in_(6)) break;
3495                 case 7: case 8: case 9: case 18:
3496                         (*count) += summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
3497                         if (!one_in_(6)) break;
3498                 case 10: case 11: case 12:
3499                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3500                         lose_exp(p_ptr->exp / 16);
3501                         if (!one_in_(6)) break;
3502                 case 13: case 14: case 15: case 19: case 20:
3503                         if (stop_ty || (p_ptr->free_act && (randint1(125) < p_ptr->skill_sav)) || (p_ptr->pclass == CLASS_BERSERKER))
3504                         {
3505                                 /* Do nothing */ ;
3506                         }
3507                         else
3508                         {
3509                                 msg_print(_("彫像になった気分だ!", "You feel like a statue!"));
3510                                 if (p_ptr->free_act)
3511                                         set_paralyzed(p_ptr->paralyzed + randint1(3));
3512                                 else
3513                                         set_paralyzed(p_ptr->paralyzed + randint1(13));
3514                                 stop_ty = TRUE;
3515                         }
3516                         if (!one_in_(6)) break;
3517                 case 21: case 22: case 23:
3518                         (void)do_dec_stat(randint0(6));
3519                         if (!one_in_(6)) break;
3520                 case 24:
3521                         msg_print(_("ほえ?私は誰?ここで何してる?", "Huh? Who am I? What am I doing here?"));
3522                         lose_all_info();
3523                         if (!one_in_(6)) break;
3524                 case 25:
3525                         /*
3526                          * Only summon Cyberdemons deep in the dungeon.
3527                          */
3528                         if ((dun_level > 65) && !stop_ty)
3529                         {
3530                                 (*count) += summon_cyber(-1, p_ptr->y, p_ptr->x);
3531                                 stop_ty = TRUE;
3532                                 break;
3533                         }
3534                         if (!one_in_(6)) break;
3535                 default:
3536                         while (i < 6)
3537                         {
3538                                 do
3539                                 {
3540                                         (void)do_dec_stat(i);
3541                                 }
3542                                 while (one_in_(2));
3543
3544                                 i++;
3545                         }
3546                 }
3547         }
3548         while (one_in_(3) && !stop_ty);
3549
3550         return stop_ty;
3551 }
3552
3553 /*!
3554  * @brief HI_SUMMON(上級召喚)処理発動
3555  * @param y 召喚位置Y座標
3556  * @param x 召喚位置X座標
3557  * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする
3558  * @return 作用が実際にあった場合TRUEを返す
3559  */
3560 int activate_hi_summon(POSITION y, POSITION x, bool can_pet)
3561 {
3562         int i;
3563         int count = 0;
3564         DEPTH summon_lev;
3565         BIT_FLAGS mode = PM_ALLOW_GROUP;
3566         bool pet = FALSE;
3567
3568         if (can_pet)
3569         {
3570                 if (one_in_(4))
3571                 {
3572                         mode |= PM_FORCE_FRIENDLY;
3573                 }
3574                 else
3575                 {
3576                         mode |= PM_FORCE_PET;
3577                         pet = TRUE;
3578                 }
3579         }
3580
3581         if (!pet) mode |= PM_NO_PET;
3582
3583         summon_lev = (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : dun_level);
3584
3585         for (i = 0; i < (randint1(7) + (dun_level / 40)); i++)
3586         {
3587                 switch (randint1(25) + (dun_level / 20))
3588                 {
3589                         case 1: case 2:
3590                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode);
3591                                 break;
3592                         case 3: case 4:
3593                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode);
3594                                 break;
3595                         case 5: case 6:
3596                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode);
3597                                 break;
3598                         case 7: case 8:
3599                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode);
3600                                 break;
3601                         case 9: case 10:
3602                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode);
3603                                 break;
3604                         case 11: case 12:
3605                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode);
3606                                 break;
3607                         case 13: case 14:
3608                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode);
3609                                 break;
3610                         case 15: case 16:
3611                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode);
3612                                 break;
3613                         case 17:
3614                                 if (can_pet) break;
3615                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
3616                                 break;
3617                         case 18: case 19:
3618                                 if (can_pet) break;
3619                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE));
3620                                 break;
3621                         case 20: case 21:
3622                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3623                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode);
3624                                 break;
3625                         case 22: case 23:
3626                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3627                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode);
3628                                 break;
3629                         case 24:
3630                                 count += summon_specific((pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode);
3631                                 break;
3632                         default:
3633                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3634                                 count += summon_specific((pet ? -1 : 0), y, x,pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode);
3635                 }
3636         }
3637
3638         return count;
3639 }
3640
3641
3642 /*!
3643  * @brief サイバーデーモンの召喚
3644  * @param who 召喚主のモンスターID(0ならばプレイヤー)
3645  * @param y 召喚位置Y座標
3646  * @param x 召喚位置X座標
3647  * @return 作用が実際にあった場合TRUEを返す
3648  */
3649 int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
3650 {
3651         int i;
3652         int max_cyber = (easy_band ? 1 : (dun_level / 50) + randint1(2));
3653         int count = 0;
3654         BIT_FLAGS mode = PM_ALLOW_GROUP;
3655
3656         /* Summoned by a monster */
3657         if (who > 0)
3658         {
3659                 monster_type *m_ptr = &m_list[who];
3660                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3661         }
3662
3663         if (max_cyber > 4) max_cyber = 4;
3664
3665         for (i = 0; i < max_cyber; i++)
3666         {
3667                 count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode);
3668         }
3669
3670         return count;
3671 }
3672
3673 /*!
3674  * @brief 周辺破壊効果(プレイヤー中心)
3675  * @return 作用が実際にあった場合TRUEを返す
3676  */
3677 void wall_breaker(void)
3678 {
3679         int i;
3680         POSITION y = 0, x = 0;
3681         int attempts = 1000;
3682
3683         if (randint1(80 + p_ptr->lev) < 70)
3684         {
3685                 while (attempts--)
3686                 {
3687                         scatter(&y, &x, p_ptr->y, p_ptr->x, 4, 0);
3688
3689                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
3690
3691                         if (!player_bold(y, x)) break;
3692                 }
3693
3694                 project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3695                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3696         }
3697         else if (randint1(100) > 30)
3698         {
3699                 earthquake(p_ptr->y, p_ptr->x, 1);
3700         }
3701         else
3702         {
3703                 int num = damroll(5, 3);
3704
3705                 for (i = 0; i < num; i++)
3706                 {
3707                         while (1)
3708                         {
3709                                 scatter(&y, &x, p_ptr->y, p_ptr->x, 10, 0);
3710
3711                                 if (!player_bold(y, x)) break;
3712                         }
3713
3714                         project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3715                                           (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3716                 }
3717         }
3718 }
3719
3720
3721 /*!
3722  * @brief パニック・モンスター効果(プレイヤー視界範囲内) / Confuse monsters
3723  * @param dam 効力
3724  * @return 作用が実際にあった場合TRUEを返す
3725  */
3726 bool confuse_monsters(HIT_POINT dam)
3727 {
3728         return (project_hack(GF_OLD_CONF, dam));
3729 }
3730
3731
3732 /*!
3733  * @brief チャーム・モンスター効果(プレイヤー視界範囲内) / Charm monsters
3734  * @param dam 効力
3735  * @return 作用が実際にあった場合TRUEを返す
3736  */
3737 bool charm_monsters(HIT_POINT dam)
3738 {
3739         return (project_hack(GF_CHARM, dam));
3740 }
3741
3742
3743 /*!
3744  * @brief 動物魅了効果(プレイヤー視界範囲内) / Charm Animals
3745  * @param dam 効力
3746  * @return 作用が実際にあった場合TRUEを返す
3747  */
3748 bool charm_animals(HIT_POINT dam)
3749 {
3750         return (project_hack(GF_CONTROL_ANIMAL, dam));
3751 }
3752
3753
3754 /*!
3755  * @brief モンスター朦朧効果(プレイヤー視界範囲内) / Stun monsters
3756  * @param dam 効力
3757  * @return 作用が実際にあった場合TRUEを返す
3758  */
3759 bool stun_monsters(HIT_POINT dam)
3760 {
3761         return (project_hack(GF_STUN, dam));
3762 }
3763
3764
3765 /*!
3766  * @brief モンスター停止効果(プレイヤー視界範囲内) / Stasis monsters
3767  * @param dam 効力
3768  * @return 作用が実際にあった場合TRUEを返す
3769  */
3770 bool stasis_monsters(HIT_POINT dam)
3771 {
3772         return (project_hack(GF_STASIS, dam));
3773 }
3774
3775
3776 /*!
3777  * @brief モンスター精神攻撃効果(プレイヤー視界範囲内) / Mindblast monsters
3778  * @param dam 効力
3779  * @return 作用が実際にあった場合TRUEを返す
3780  */
3781 bool mindblast_monsters(HIT_POINT dam)
3782 {
3783         return (project_hack(GF_PSI, dam));
3784 }
3785
3786
3787 /*!
3788  * @brief モンスター追放効果(プレイヤー視界範囲内) / Banish all monsters
3789  * @param dist 効力(距離)
3790  * @return 作用が実際にあった場合TRUEを返す
3791  */
3792 bool banish_monsters(int dist)
3793 {
3794         return (project_hack(GF_AWAY_ALL, dist));
3795 }
3796
3797
3798 /*!
3799  * @brief 邪悪退散効果(プレイヤー視界範囲内) / Turn evil
3800  * @param dam 効力
3801  * @return 作用が実際にあった場合TRUEを返す
3802  */
3803 bool turn_evil(HIT_POINT dam)
3804 {
3805         return (project_hack(GF_TURN_EVIL, dam));
3806 }
3807
3808
3809 /*!
3810  * @brief 全モンスター退散効果(プレイヤー視界範囲内) / Turn everyone
3811  * @param dam 効力
3812  * @return 作用が実際にあった場合TRUEを返す
3813  */
3814 bool turn_monsters(HIT_POINT dam)
3815 {
3816         return (project_hack(GF_TURN_ALL, dam));
3817 }
3818
3819
3820 /*!
3821  * @brief 死の光線(プレイヤー視界範囲内) / Death-ray all monsters (note: OBSCENELY powerful)
3822  * @return 作用が実際にあった場合TRUEを返す
3823  */
3824 bool deathray_monsters(void)
3825 {
3826         return (project_hack(GF_DEATH_RAY, p_ptr->lev * 200));
3827 }
3828
3829 /*!
3830  * @brief チャーム・モンスター(1体)
3831  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3832  * @param plev パワー
3833  * @return 作用が実際にあった場合TRUEを返す
3834  */
3835 bool charm_monster(DIRECTION dir, PLAYER_LEVEL plev)
3836 {
3837         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3838         return (project_hook(GF_CHARM, dir, plev, flg));
3839 }
3840
3841 /*!
3842  * @brief アンデッド支配(1体)
3843  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3844  * @param plev パワー
3845  * @return 作用が実際にあった場合TRUEを返す
3846  */
3847 bool control_one_undead(DIRECTION dir, PLAYER_LEVEL plev)
3848 {
3849         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3850         return (project_hook(GF_CONTROL_UNDEAD, dir, plev, flg));
3851 }
3852
3853 /*!
3854  * @brief 悪魔支配(1体)
3855  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3856  * @param plev パワー
3857  * @return 作用が実際にあった場合TRUEを返す
3858  */
3859 bool control_one_demon(DIRECTION dir, PLAYER_LEVEL plev)
3860 {
3861         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3862         return (project_hook(GF_CONTROL_DEMON, dir, plev, flg));
3863 }
3864
3865 /*!
3866  * @brief 動物支配(1体)
3867  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3868  * @param plev パワー
3869  * @return 作用が実際にあった場合TRUEを返す
3870  */
3871 bool charm_animal(DIRECTION dir, PLAYER_LEVEL plev)
3872 {
3873         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3874         return (project_hook(GF_CONTROL_ANIMAL, dir, plev, flg));
3875 }
3876
3877
3878 /*!
3879  * @brief 変わり身処理
3880  * @param success 判定成功上の処理ならばTRUE
3881  * @return 作用が実際にあった場合TRUEを返す
3882  */
3883 bool kawarimi(bool success)
3884 {
3885         object_type forge;
3886         object_type *q_ptr = &forge;
3887         POSITION y, x;
3888
3889         if (p_ptr->is_dead) return FALSE;
3890         if (p_ptr->confused || p_ptr->blind || p_ptr->paralyzed || p_ptr->image) return FALSE;
3891         if (randint0(200) < p_ptr->stun) return FALSE;
3892
3893         if (!success && one_in_(3))
3894         {
3895                 msg_print(_("失敗!逃げられなかった。", "Failed! You couldn't run away."));
3896                 p_ptr->special_defense &= ~(NINJA_KAWARIMI);
3897                 p_ptr->redraw |= (PR_STATUS);
3898                 return FALSE;
3899         }
3900
3901         y = p_ptr->y;
3902         x = p_ptr->x;
3903
3904         teleport_player(10 + randint1(90), 0L);
3905
3906         object_wipe(q_ptr);
3907
3908         object_prep(q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE));
3909
3910         q_ptr->pval = MON_NINJA;
3911
3912         /* Drop it in the dungeon */
3913         (void)drop_near(q_ptr, -1, y, x);
3914
3915 #ifdef JP
3916         if (success) msg_print("攻撃を受ける前に素早く身をひるがえした。");
3917         else msg_print("失敗!攻撃を受けてしまった。");
3918 #else
3919         if (success) msg_print("You have turned around just before the attack hit you.");
3920         else msg_print("Failed! You are hit by the attack.");
3921 #endif
3922
3923         p_ptr->special_defense &= ~(NINJA_KAWARIMI);
3924         p_ptr->redraw |= (PR_STATUS);
3925
3926         /* Teleported */
3927         return TRUE;
3928 }
3929
3930
3931 /*!
3932  * @brief 入身処理 / "Rush Attack" routine for Samurai or Ninja
3933  * @param mdeath 目標モンスターが死亡したかを返す
3934  * @return 作用が実際にあった場合TRUEを返す /  Return value is for checking "done"
3935  */
3936 bool rush_attack(bool *mdeath)
3937 {
3938         DIRECTION dir;
3939         int tx, ty;
3940         int tm_idx = 0;
3941         u16b path_g[32];
3942         int path_n, i;
3943         bool tmp_mdeath = FALSE;
3944         bool moved = FALSE;
3945
3946         if (mdeath) *mdeath = FALSE;
3947
3948         project_length = 5;
3949         if (!get_aim_dir(&dir)) return FALSE;
3950
3951         /* Use the given direction */
3952         tx = p_ptr->x + project_length * ddx[dir];
3953         ty = p_ptr->y + project_length * ddy[dir];
3954
3955         /* Hack -- Use an actual "target" */
3956         if ((dir == 5) && target_okay())
3957         {
3958                 tx = target_col;
3959                 ty = target_row;
3960         }
3961
3962         if (in_bounds(ty, tx)) tm_idx = cave[ty][tx].m_idx;
3963
3964         path_n = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_STOP | PROJECT_KILL);
3965         project_length = 0;
3966
3967         /* No need to move */
3968         if (!path_n) return TRUE;
3969
3970         /* Use ty and tx as to-move point */
3971         ty = p_ptr->y;
3972         tx = p_ptr->x;
3973
3974         /* Project along the path */
3975         for (i = 0; i < path_n; i++)
3976         {
3977                 monster_type *m_ptr;
3978
3979                 int ny = GRID_Y(path_g[i]);
3980                 int nx = GRID_X(path_g[i]);
3981
3982                 if (cave_empty_bold(ny, nx) && player_can_enter(cave[ny][nx].feat, 0))
3983                 {
3984                         ty = ny;
3985                         tx = nx;
3986
3987                         /* Go to next grid */
3988                         continue;
3989                 }
3990
3991                 if (!cave[ny][nx].m_idx)
3992                 {
3993                         if (tm_idx)
3994                         {
3995                                 msg_print(_("失敗!", "Failed!"));
3996                         }
3997                         else
3998                         {
3999                                 msg_print(_("ここには入身では入れない。", "You can't move to that place."));
4000                         }
4001
4002                         /* Exit loop */
4003                         break;
4004                 }
4005
4006                 /* Move player before updating the monster */
4007                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4008                 update_monster(cave[ny][nx].m_idx, TRUE);
4009
4010                 /* Found a monster */
4011                 m_ptr = &m_list[cave[ny][nx].m_idx];
4012
4013                 if (tm_idx != cave[ny][nx].m_idx)
4014                 {
4015 #ifdef JP
4016                         msg_format("%s%sが立ちふさがっている!", tm_idx ? "別の" : "",
4017                                    m_ptr->ml ? "モンスター" : "何か");
4018 #else
4019                         msg_format("There is %s in the way!", m_ptr->ml ? (tm_idx ? "another monster" : "a monster") : "someone");
4020 #endif
4021                 }
4022                 else if (!player_bold(ty, tx))
4023                 {
4024                         /* Hold the monster name */
4025                         char m_name[80];
4026
4027                         /* Get the monster name (BEFORE polymorphing) */
4028                         monster_desc(m_name, m_ptr, 0);
4029                         msg_format(_("素早く%sの懐に入り込んだ!", "You quickly jump in and attack %s!"), m_name);
4030                 }
4031
4032                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4033                 moved = TRUE;
4034                 tmp_mdeath = py_attack(ny, nx, HISSATSU_NYUSIN);
4035
4036                 break;
4037         }
4038
4039         if (!moved && !player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4040
4041         if (mdeath) *mdeath = tmp_mdeath;
4042         return TRUE;
4043 }
4044
4045
4046 /*!
4047  * @brief 全鏡の消去 / Remove all mirrors in this floor
4048  * @param explode 爆発処理を伴うならばTRUE
4049  * @return なし
4050  */
4051 void remove_all_mirrors(bool explode)
4052 {
4053         POSITION x, y;
4054
4055         for (x = 0; x < cur_wid; x++)
4056         {
4057                 for (y = 0; y < cur_hgt; y++)
4058                 {
4059                         if (is_mirror_grid(&cave[y][x]))
4060                         {
4061                                 remove_mirror(y, x);
4062                                 if (explode)
4063                                         project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS,
4064                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
4065                         }
4066                 }
4067         }
4068 }
4069
4070 /*!
4071  * @brief 『一つの指輪』の効果処理 /
4072  * Hack -- activate the ring of power
4073  * @param dir 発動の方向ID
4074  * @return なし
4075  */
4076 void ring_of_power(DIRECTION dir)
4077 {
4078         /* Pick a random effect */
4079         switch (randint1(10))
4080         {
4081         case 1:
4082         case 2:
4083         {
4084                 msg_print(_("あなたは悪性のオーラに包み込まれた。", "You are surrounded by a malignant aura."));
4085                 sound(SOUND_EVIL);
4086
4087                 /* Decrease all stats (permanently) */
4088                 (void)dec_stat(A_STR, 50, TRUE);
4089                 (void)dec_stat(A_INT, 50, TRUE);
4090                 (void)dec_stat(A_WIS, 50, TRUE);
4091                 (void)dec_stat(A_DEX, 50, TRUE);
4092                 (void)dec_stat(A_CON, 50, TRUE);
4093                 (void)dec_stat(A_CHR, 50, TRUE);
4094
4095                 /* Lose some experience (permanently) */
4096                 p_ptr->exp -= (p_ptr->exp / 4);
4097                 p_ptr->max_exp -= (p_ptr->exp / 4);
4098                 check_experience();
4099
4100                 break;
4101         }
4102
4103         case 3:
4104         {
4105                 msg_print(_("あなたは強力なオーラに包み込まれた。", "You are surrounded by a powerful aura."));
4106
4107                 /* Dispel monsters */
4108                 dispel_monsters(1000);
4109
4110                 break;
4111         }
4112
4113         case 4:
4114         case 5:
4115         case 6:
4116         {
4117                 /* Mana Ball */
4118                 fire_ball(GF_MANA, dir, 600, 3);
4119
4120                 break;
4121         }
4122
4123         case 7:
4124         case 8:
4125         case 9:
4126         case 10:
4127         {
4128                 /* Mana Bolt */
4129                 fire_bolt(GF_MANA, dir, 500);
4130
4131                 break;
4132         }
4133         }
4134 }
4135
4136 /*!
4137 * @brief 運命の輪、並びにカオス的な効果の発動
4138 * @param spell ランダムな効果を選択するための基準ID
4139 * @return なし
4140 */
4141 void wild_magic(int spell)
4142 {
4143         int counter = 0;
4144         int type = SUMMON_MOLD + randint0(6);
4145
4146         if (type < SUMMON_MOLD) type = SUMMON_MOLD;
4147         else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
4148
4149         switch (randint1(spell) + randint1(8) + 1)
4150         {
4151         case 1:
4152         case 2:
4153         case 3:
4154                 teleport_player(10, TELEPORT_PASSIVE);
4155                 break;
4156         case 4:
4157         case 5:
4158         case 6:
4159                 teleport_player(100, TELEPORT_PASSIVE);
4160                 break;
4161         case 7:
4162         case 8:
4163                 teleport_player(200, TELEPORT_PASSIVE);
4164                 break;
4165         case 9:
4166         case 10:
4167         case 11:
4168                 unlite_area(10, 3);
4169                 break;
4170         case 12:
4171         case 13:
4172         case 14:
4173                 lite_area(damroll(2, 3), 2);
4174                 break;
4175         case 15:
4176                 destroy_doors_touch();
4177                 break;
4178         case 16: case 17:
4179                 wall_breaker();
4180         case 18:
4181                 sleep_monsters_touch();
4182                 break;
4183         case 19:
4184         case 20:
4185                 trap_creation(p_ptr->y, p_ptr->x);
4186                 break;
4187         case 21:
4188         case 22:
4189                 door_creation();
4190                 break;
4191         case 23:
4192         case 24:
4193         case 25:
4194                 aggravate_monsters(0);
4195                 break;
4196         case 26:
4197                 earthquake(p_ptr->y, p_ptr->x, 5);
4198                 break;
4199         case 27:
4200         case 28:
4201                 (void)gain_random_mutation(0);
4202                 break;
4203         case 29:
4204         case 30:
4205                 apply_disenchant(1);
4206                 break;
4207         case 31:
4208                 lose_all_info();
4209                 break;
4210         case 32:
4211                 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
4212                 break;
4213         case 33:
4214                 wall_stone();
4215                 break;
4216         case 34:
4217         case 35:
4218                 while (counter++ < 8)
4219                 {
4220                         (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
4221                 }
4222                 break;
4223         case 36:
4224         case 37:
4225                 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4226                 break;
4227         case 38:
4228                 (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
4229                 break;
4230         default:
4231         {
4232                 int count = 0;
4233                 (void)activate_ty_curse(FALSE, &count);
4234                 break;
4235         }
4236         }
4237
4238         return;
4239 }
4240
4241 /*!
4242 * @brief カオス魔法「流星群」の処理としてプレイヤーを中心に隕石落下処理を10+1d10回繰り返す。
4243 * / Drop 10+1d10 meteor ball at random places near the player
4244 * @param dam ダメージ
4245 * @param rad 効力の半径
4246 * @return なし
4247 */
4248 void cast_meteor(HIT_POINT dam, POSITION rad)
4249 {
4250         int i;
4251         int b = 10 + randint1(10);
4252
4253         for (i = 0; i < b; i++)
4254         {
4255                 POSITION y = 0, x = 0;
4256                 int count;
4257
4258                 for (count = 0; count <= 20; count++)
4259                 {
4260                         int dy, dx, d;
4261
4262                         x = p_ptr->x - 8 + randint0(17);
4263                         y = p_ptr->y - 8 + randint0(17);
4264
4265                         dx = (p_ptr->x > x) ? (p_ptr->x - x) : (x - p_ptr->x);
4266                         dy = (p_ptr->y > y) ? (p_ptr->y - y) : (y - p_ptr->y);
4267
4268                         /* Approximate distance */
4269                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4270
4271                         if (d >= 9) continue;
4272
4273                         if (!in_bounds(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)
4274                                 || !cave_have_flag_bold(y, x, FF_PROJECT)) continue;
4275
4276                         /* Valid position */
4277                         break;
4278                 }
4279
4280                 if (count > 20) continue;
4281
4282                 project(0, rad, y, x, dam, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
4283         }
4284 }
4285
4286
4287 /*!
4288 * @brief 破邪魔法「神の怒り」の処理としてターゲットを指定した後分解のボールを最大20回発生させる。
4289 * @param dam ダメージ
4290 * @param rad 効力の半径
4291 * @return ターゲットを指定し、実行したならばTRUEを返す。
4292 */
4293 bool cast_wrath_of_the_god(HIT_POINT dam, POSITION rad)
4294 {
4295         POSITION x, y, tx, ty;
4296         POSITION nx, ny;
4297         DIRECTION dir;
4298         int i;
4299         int b = 10 + randint1(10);
4300
4301         if (!get_aim_dir(&dir)) return FALSE;
4302
4303         /* Use the given direction */
4304         tx = p_ptr->x + 99 * ddx[dir];
4305         ty = p_ptr->y + 99 * ddy[dir];
4306
4307         /* Hack -- Use an actual "target" */
4308         if ((dir == 5) && target_okay())
4309         {
4310                 tx = target_col;
4311                 ty = target_row;
4312         }
4313
4314         x = p_ptr->x;
4315         y = p_ptr->y;
4316
4317         while (1)
4318         {
4319                 /* Hack -- Stop at the target */
4320                 if ((y == ty) && (x == tx)) break;
4321
4322                 ny = y;
4323                 nx = x;
4324                 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
4325
4326                 /* Stop at maximum range */
4327                 if (MAX_RANGE <= distance(p_ptr->y, p_ptr->x, ny, nx)) break;
4328
4329                 /* Stopped by walls/doors */
4330                 if (!cave_have_flag_bold(ny, nx, FF_PROJECT)) break;
4331
4332                 /* Stopped by monsters */
4333                 if ((dir != 5) && cave[ny][nx].m_idx != 0) break;
4334
4335                 /* Save the new location */
4336                 x = nx;
4337                 y = ny;
4338         }
4339         tx = x;
4340         ty = y;
4341
4342         for (i = 0; i < b; i++)
4343         {
4344                 int count = 20, d = 0;
4345
4346                 while (count--)
4347                 {
4348                         int dx, dy;
4349
4350                         x = tx - 5 + randint0(11);
4351                         y = ty - 5 + randint0(11);
4352
4353                         dx = (tx > x) ? (tx - x) : (x - tx);
4354                         dy = (ty > y) ? (ty - y) : (y - ty);
4355
4356                         /* Approximate distance */
4357                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4358                         /* Within the radius */
4359                         if (d < 5) break;
4360                 }
4361
4362                 if (count < 0) continue;
4363
4364                 /* Cannot penetrate perm walls */
4365                 if (!in_bounds(y, x) ||
4366                         cave_stop_disintegration(y, x) ||
4367                         !in_disintegration_range(ty, tx, y, x))
4368                         continue;
4369
4370                 project(0, rad, y, x, dam, GF_DISINTEGRATE, PROJECT_JUMP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
4371         }
4372
4373         return TRUE;
4374 }
4375
4376 /*!
4377 * @brief 「ワンダー」のランダムな効果を決定して処理する。
4378 * @param dir 方向ID
4379 * @return なし
4380 * @details
4381 * This spell should become more useful (more controlled) as the\n
4382 * player gains experience levels.  Thus, add 1/5 of the player's\n
4383 * level to the die roll.  This eliminates the worst effects later on,\n
4384 * while keeping the results quite random.  It also allows some potent\n
4385 * effects only at high level.
4386 */
4387 void cast_wonder(DIRECTION dir)
4388 {
4389         PLAYER_LEVEL plev = p_ptr->lev;
4390         int die = randint1(100) + plev / 5;
4391         int vir = virtue_number(V_CHANCE);
4392
4393         if (vir)
4394         {
4395                 if (p_ptr->virtues[vir - 1] > 0)
4396                 {
4397                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4398                 }
4399                 else
4400                 {
4401                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4402                 }
4403         }
4404
4405         if (die < 26)
4406                 chg_virtue(V_CHANCE, 1);
4407
4408         if (die > 100)
4409         {
4410                 msg_print(_("あなたは力がみなぎるのを感じた!", "You feel a surge of power!"));
4411         }
4412
4413         if (die < 8) clone_monster(dir);
4414         else if (die < 14) speed_monster(dir, plev);
4415         else if (die < 26) heal_monster(dir, damroll(4, 6));
4416         else if (die < 31) poly_monster(dir, plev);
4417         else if (die < 36)
4418                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4419                         damroll(3 + ((plev - 1) / 5), 4));
4420         else if (die < 41) confuse_monster(dir, plev);
4421         else if (die < 46) fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4422         else if (die < 51) (void)lite_line(dir, damroll(6, 8));
4423         else if (die < 56)
4424                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4425                         damroll(3 + ((plev - 5) / 4), 8));
4426         else if (die < 61)
4427                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4428                         damroll(5 + ((plev - 5) / 4), 8));
4429         else if (die < 66)
4430                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4431                         damroll(6 + ((plev - 5) / 4), 8));
4432         else if (die < 71)
4433                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4434                         damroll(8 + ((plev - 5) / 4), 8));
4435         else if (die < 76) hypodynamic_bolt(dir, 75);
4436         else if (die < 81) fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4437         else if (die < 86) fire_ball(GF_ACID, dir, 40 + plev, 2);
4438         else if (die < 91) fire_ball(GF_ICE, dir, 70 + plev, 3);
4439         else if (die < 96) fire_ball(GF_FIRE, dir, 80 + plev, 3);
4440         else if (die < 101) hypodynamic_bolt(dir, 100 + plev);
4441         else if (die < 104)
4442         {
4443                 earthquake(p_ptr->y, p_ptr->x, 12);
4444         }
4445         else if (die < 106)
4446         {
4447                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4448         }
4449         else if (die < 108)
4450         {
4451                 symbol_genocide(plev + 50, TRUE);
4452         }
4453         else if (die < 110) dispel_monsters(120);
4454         else /* RARE */
4455         {
4456                 dispel_monsters(150);
4457                 slow_monsters(plev);
4458                 sleep_monsters(plev);
4459                 hp_player(300);
4460         }
4461 }
4462
4463
4464 /*!
4465 * @brief 「悪霊召喚」のランダムな効果を決定して処理する。
4466 * @param dir 方向ID
4467 * @return なし
4468 */
4469 void cast_invoke_spirits(DIRECTION dir)
4470 {
4471         PLAYER_LEVEL plev = p_ptr->lev;
4472         int die = randint1(100) + plev / 5;
4473         int vir = virtue_number(V_CHANCE);
4474
4475         if (vir)
4476         {
4477                 if (p_ptr->virtues[vir - 1] > 0)
4478                 {
4479                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4480                 }
4481                 else
4482                 {
4483                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4484                 }
4485         }
4486
4487         msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead..."));
4488         if (die < 26)
4489                 chg_virtue(V_CHANCE, 1);
4490
4491         if (die > 100)
4492         {
4493                 msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!"));
4494         }
4495
4496         if (die < 8)
4497         {
4498                 msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!",
4499                         "Oh no! Mouldering forms rise from the earth around you!"));
4500
4501                 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4502                 chg_virtue(V_UNLIFE, 1);
4503         }
4504         else if (die < 14)
4505         {
4506                 msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind..."));
4507
4508                 set_afraid(p_ptr->afraid + randint1(4) + 4);
4509         }
4510         else if (die < 26)
4511         {
4512                 msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...",
4513                         "Your head is invaded by a horde of gibbering spectral voices..."));
4514
4515                 set_confused(p_ptr->confused + randint1(4) + 4);
4516         }
4517         else if (die < 31)
4518         {
4519                 poly_monster(dir, plev);
4520         }
4521         else if (die < 36)
4522         {
4523                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4524                         damroll(3 + ((plev - 1) / 5), 4));
4525         }
4526         else if (die < 41)
4527         {
4528                 confuse_monster(dir, plev);
4529         }
4530         else if (die < 46)
4531         {
4532                 fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4533         }
4534         else if (die < 51)
4535         {
4536                 (void)lite_line(dir, damroll(6, 8));
4537         }
4538         else if (die < 56)
4539         {
4540                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4541                         damroll(3 + ((plev - 5) / 4), 8));
4542         }
4543         else if (die < 61)
4544         {
4545                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4546                         damroll(5 + ((plev - 5) / 4), 8));
4547         }
4548         else if (die < 66)
4549         {
4550                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4551                         damroll(6 + ((plev - 5) / 4), 8));
4552         }
4553         else if (die < 71)
4554         {
4555                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4556                         damroll(8 + ((plev - 5) / 4), 8));
4557         }
4558         else if (die < 76)
4559         {
4560                 hypodynamic_bolt(dir, 75);
4561         }
4562         else if (die < 81)
4563         {
4564                 fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4565         }
4566         else if (die < 86)
4567         {
4568                 fire_ball(GF_ACID, dir, 40 + plev, 2);
4569         }
4570         else if (die < 91)
4571         {
4572                 fire_ball(GF_ICE, dir, 70 + plev, 3);
4573         }
4574         else if (die < 96)
4575         {
4576                 fire_ball(GF_FIRE, dir, 80 + plev, 3);
4577         }
4578         else if (die < 101)
4579         {
4580                 hypodynamic_bolt(dir, 100 + plev);
4581         }
4582         else if (die < 104)
4583         {
4584                 earthquake(p_ptr->y, p_ptr->x, 12);
4585         }
4586         else if (die < 106)
4587         {
4588                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4589         }
4590         else if (die < 108)
4591         {
4592                 symbol_genocide(plev + 50, TRUE);
4593         }
4594         else if (die < 110)
4595         {
4596                 dispel_monsters(120);
4597         }
4598         else
4599         { /* RARE */
4600                 dispel_monsters(150);
4601                 slow_monsters(plev);
4602                 sleep_monsters(plev);
4603                 hp_player(300);
4604         }
4605
4606         if (die < 31)
4607         {
4608                 msg_print(_("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」",
4609                         "Sepulchral voices chuckle. 'Soon you will join us, mortal.'"));
4610         }
4611 }
4612
4613 /*!
4614 * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。
4615 * @return なし
4616 */
4617 void cast_shuffle(void)
4618 {
4619         PLAYER_LEVEL plev = p_ptr->lev;
4620         DIRECTION dir;
4621         int die;
4622         int vir = virtue_number(V_CHANCE);
4623         int i;
4624
4625         /* Card sharks and high mages get a level bonus */
4626         if ((p_ptr->pclass == CLASS_ROGUE) ||
4627                 (p_ptr->pclass == CLASS_HIGH_MAGE) ||
4628                 (p_ptr->pclass == CLASS_SORCERER))
4629                 die = (randint1(110)) + plev / 5;
4630         else
4631                 die = randint1(120);
4632
4633
4634         if (vir)
4635         {
4636                 if (p_ptr->virtues[vir - 1] > 0)
4637                 {
4638                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4639                 }
4640                 else
4641                 {
4642                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4643                 }
4644         }
4645
4646         msg_print(_("あなたはカードを切って一枚引いた...", "You shuffle the deck and draw a card..."));
4647
4648         if (die < 30)
4649                 chg_virtue(V_CHANCE, 1);
4650
4651         if (die < 7)
4652         {
4653                 msg_print(_("なんてこった!《死》だ!", "Oh no! It's Death!"));
4654
4655                 for (i = 0; i < randint1(3); i++)
4656                         activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4657         }
4658         else if (die < 14)
4659         {
4660                 msg_print(_("なんてこった!《悪魔》だ!", "Oh no! It's the Devil!"));
4661                 summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4662         }
4663         else if (die < 18)
4664         {
4665                 int count = 0;
4666                 msg_print(_("なんてこった!《吊られた男》だ!", "Oh no! It's the Hanged Man."));
4667                 activate_ty_curse(FALSE, &count);
4668         }
4669         else if (die < 22)
4670         {
4671                 msg_print(_("《不調和の剣》だ。", "It's the swords of discord."));
4672                 aggravate_monsters(0);
4673         }
4674         else if (die < 26)
4675         {
4676                 msg_print(_("《愚者》だ。", "It's the Fool."));
4677                 do_dec_stat(A_INT);
4678                 do_dec_stat(A_WIS);
4679         }
4680         else if (die < 30)
4681         {
4682                 msg_print(_("奇妙なモンスターの絵だ。", "It's the picture of a strange monster."));
4683                 trump_summoning(1, FALSE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), (32 + randint1(6)), PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
4684         }
4685         else if (die < 33)
4686         {
4687                 msg_print(_("《月》だ。", "It's the Moon."));
4688                 unlite_area(10, 3);
4689         }
4690         else if (die < 38)
4691         {
4692                 msg_print(_("《運命の輪》だ。", "It's the Wheel of Fortune."));
4693                 wild_magic(randint0(32));
4694         }
4695         else if (die < 40)
4696         {
4697                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4698                 teleport_player(10, TELEPORT_PASSIVE);
4699         }
4700         else if (die < 42)
4701         {
4702                 msg_print(_("《正義》だ。", "It's Justice."));
4703                 set_blessed(p_ptr->lev, FALSE);
4704         }
4705         else if (die < 47)
4706         {
4707                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4708                 teleport_player(100, TELEPORT_PASSIVE);
4709         }
4710         else if (die < 52)
4711         {
4712                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4713                 teleport_player(200, TELEPORT_PASSIVE);
4714         }
4715         else if (die < 60)
4716         {
4717                 msg_print(_("《塔》だ。", "It's the Tower."));
4718                 wall_breaker();
4719         }
4720         else if (die < 72)
4721         {
4722                 msg_print(_("《節制》だ。", "It's Temperance."));
4723                 sleep_monsters_touch();
4724         }
4725         else if (die < 80)
4726         {
4727                 msg_print(_("《塔》だ。", "It's the Tower."));
4728
4729                 earthquake(p_ptr->y, p_ptr->x, 5);
4730         }
4731         else if (die < 82)
4732         {
4733                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4734                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_MOLD, 0L);
4735         }
4736         else if (die < 84)
4737         {
4738                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4739                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_BAT, 0L);
4740         }
4741         else if (die < 86)
4742         {
4743                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4744                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_VORTEX, 0L);
4745         }
4746         else if (die < 88)
4747         {
4748                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4749                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_COIN_MIMIC, 0L);
4750         }
4751         else if (die < 96)
4752         {
4753                 msg_print(_("《恋人》だ。", "It's the Lovers."));
4754
4755                 if (get_aim_dir(&dir))
4756                         charm_monster(dir, MIN(p_ptr->lev, 20));
4757         }
4758         else if (die < 101)
4759         {
4760                 msg_print(_("《隠者》だ。", "It's the Hermit."));
4761                 wall_stone();
4762         }
4763         else if (die < 111)
4764         {
4765                 msg_print(_("《審判》だ。", "It's the Judgement."));
4766                 do_cmd_rerate(FALSE);
4767                 lose_all_mutations();
4768         }
4769         else if (die < 120)
4770         {
4771                 msg_print(_("《太陽》だ。", "It's the Sun."));
4772                 chg_virtue(V_KNOWLEDGE, 1);
4773                 chg_virtue(V_ENLIGHTEN, 1);
4774                 wiz_lite(FALSE);
4775         }
4776         else
4777         {
4778                 msg_print(_("《世界》だ。", "It's the World."));
4779                 if (p_ptr->exp < PY_MAX_EXP)
4780                 {
4781                         s32b ee = (p_ptr->exp / 25) + 1;
4782                         if (ee > 5000) ee = 5000;
4783                         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4784                         gain_exp(ee);
4785                 }
4786         }
4787 }
4788
4789 bool_hack life_stream(bool_hack message, bool_hack virtue)
4790 {
4791         if(virtue)
4792         {
4793                 chg_virtue(V_VITALITY, 1);
4794                 chg_virtue(V_UNLIFE, -5);
4795         }
4796         if(message)
4797         {
4798                 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
4799         }
4800         restore_level();
4801         (void)set_poisoned(0);
4802         (void)set_blind(0);
4803         (void)set_confused(0);
4804         (void)set_image(0);
4805         (void)set_stun(0);
4806         (void)set_cut(0);
4807         (void)restore_all_status();
4808         (void)set_shero(0, TRUE);
4809         update_stuff();
4810         hp_player(5000);
4811
4812         return TRUE;
4813 }
4814
4815 bool_hack heroism(int base)
4816 {
4817         bool_hack ident = FALSE;
4818         if(set_afraid(0)) ident = TRUE;
4819         if(set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4820         if(hp_player(10)) ident = TRUE;
4821         return ident;
4822 }
4823
4824 bool_hack berserk(int base)
4825 {
4826         bool_hack ident = FALSE;
4827         if (set_afraid(0)) ident = TRUE;
4828         if (set_shero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4829         if (hp_player(30)) ident = TRUE;
4830         return ident;
4831 }
4832
4833 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
4834 {
4835         bool_hack ident = FALSE;
4836         if (hp_player(damroll(dice, sides))) ident = TRUE;
4837         if (set_blind(0)) ident = TRUE;
4838         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
4839         if (set_shero(0, TRUE)) ident = TRUE;
4840         return ident;
4841 }
4842
4843 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
4844 {
4845         bool_hack ident = FALSE;
4846         if (hp_player(damroll(dice, sides))) ident = TRUE;
4847         if (set_blind(0)) ident = TRUE;
4848         if (set_confused(0)) ident = TRUE;
4849         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
4850         if (set_shero(0, TRUE)) ident = TRUE;
4851         return ident;
4852 }
4853
4854 bool_hack cure_critical_wounds(HIT_POINT pow)
4855 {
4856         bool_hack ident = FALSE;
4857         if (hp_player(pow)) ident = TRUE;
4858         if (set_blind(0)) ident = TRUE;
4859         if (set_confused(0)) ident = TRUE;
4860         if (set_poisoned(0)) ident = TRUE;
4861         if (set_stun(0)) ident = TRUE;
4862         if (set_cut(0)) ident = TRUE;
4863         if (set_shero(0, TRUE)) ident = TRUE;
4864         return ident;
4865 }
4866
4867 bool_hack true_healing(HIT_POINT pow)
4868 {
4869         bool_hack ident = FALSE;
4870         if (hp_player(pow)) ident = TRUE;
4871         if (set_blind(0)) ident = TRUE;
4872         if (set_confused(0)) ident = TRUE;
4873         if (set_poisoned(0)) ident = TRUE;
4874         if (set_stun(0)) ident = TRUE;
4875         if (set_cut(0)) ident = TRUE;
4876         if (set_image(0)) ident = TRUE;
4877         return ident;
4878 }
4879
4880 bool_hack restore_mana(bool_hack magic_eater)
4881 {
4882         bool_hack ident = FALSE;
4883
4884         if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
4885         {
4886                 int i;
4887                 for (i = 0; i < EATER_EXT * 2; i++)
4888                 {
4889                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
4890                         if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i] * EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i] * EATER_CHARGE;
4891                 }
4892                 for (; i < EATER_EXT * 3; i++)
4893                 {
4894                         KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
4895                         p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3)*k_info[k_idx].pval;
4896                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
4897                 }
4898                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
4899                 p_ptr->window |= (PW_PLAYER);
4900                 ident = TRUE;
4901         }
4902         else if (p_ptr->csp < p_ptr->msp)
4903         {
4904                 p_ptr->csp = p_ptr->msp;
4905                 p_ptr->csp_frac = 0;
4906                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
4907                 p_ptr->redraw |= (PR_MANA);
4908                 p_ptr->window |= (PW_PLAYER);
4909                 p_ptr->window |= (PW_SPELL);
4910                 ident = TRUE;
4911         }
4912
4913         return ident;
4914 }
4915
4916 bool restore_all_status(void)
4917 {
4918         bool ident = FALSE; 
4919         if (do_res_stat(A_STR)) ident = TRUE;
4920         if (do_res_stat(A_INT)) ident = TRUE;
4921         if (do_res_stat(A_WIS)) ident = TRUE;
4922         if (do_res_stat(A_DEX)) ident = TRUE;
4923         if (do_res_stat(A_CON)) ident = TRUE;
4924         if (do_res_stat(A_CHR)) ident = TRUE;
4925         return ident;
4926 }
4927
4928 /*!
4929  * @brief 口を使う継続的な処理を中断する
4930  * @return なし
4931  */
4932 void stop_mouth(void)
4933 {
4934         if (music_singing_any()) stop_singing();
4935         if (hex_spelling_any()) stop_hex_spell_all();
4936 }
4937
4938
4939 bool_hack vampirism(void)
4940 {
4941         DIRECTION dir;
4942         POSITION x, y;
4943         int dummy;
4944         cave_type *c_ptr;
4945
4946         if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
4947         {
4948                 msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking."));
4949                 return FALSE;
4950         }
4951
4952         /* Only works on adjacent monsters */
4953         if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
4954         y = p_ptr->y + ddy[dir];
4955         x = p_ptr->x + ddx[dir];
4956         c_ptr = &cave[y][x];
4957
4958         stop_mouth();
4959
4960         if (!(c_ptr->m_idx))
4961         {
4962                 msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
4963                 return FALSE;
4964         }
4965
4966         msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
4967
4968         dummy = p_ptr->lev * 2;
4969
4970         if (hypodynamic_bolt(dir, dummy))
4971         {
4972                 if (p_ptr->food < PY_FOOD_FULL)
4973                         /* No heal if we are "full" */
4974                         (void)hp_player(dummy);
4975                 else
4976                         msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
4977
4978                 /* Gain nutritional sustenance: 150/hp drained */
4979                 /* A Food ration gives 5000 food points (by contrast) */
4980                 /* Don't ever get more than "Full" this way */
4981                 /* But if we ARE Gorged,  it won't cure us */
4982                 dummy = p_ptr->food + MIN(5000, 100 * dummy);
4983                 if (p_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
4984                         (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
4985         }
4986         else
4987                 msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
4988         return TRUE;
4989 }
4990
4991 bool panic_hit(void)
4992 {
4993         DIRECTION dir;
4994         POSITION x, y;
4995
4996         if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
4997         y = p_ptr->y + ddy[dir];
4998         x = p_ptr->x + ddx[dir];
4999         if (cave[y][x].m_idx)
5000         {
5001                 py_attack(y, x, 0);
5002                 if (randint0(p_ptr->skill_dis) < 7)
5003                         msg_print(_("うまく逃げられなかった。", "You failed to run away."));
5004                 else
5005                         teleport_player(30, 0L);
5006                 return TRUE;
5007         }
5008         else
5009         {
5010                 msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
5011                 msg_print(NULL);
5012                 return FALSE;
5013         }
5014
5015 }
5016
5017 /*!
5018 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
5019 * @return なし
5020 * @note
5021 * currently this function allows pseudo-id of any object,
5022 * including silly ones like potions & scrolls, which always
5023 * get '{average}'. This should be changed, either to stop such
5024 * items from being pseudo-id'd, or to allow psychometry to
5025 * detect whether the unidentified potion/scroll/etc is
5026 * good (Cure Light Wounds, Restore Strength, etc) or
5027 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
5028 */
5029 bool psychometry(void)
5030 {
5031         OBJECT_IDX      item;
5032         object_type     *o_ptr;
5033         char            o_name[MAX_NLEN];
5034         byte            feel;
5035         cptr            q, s;
5036         bool okay = FALSE;
5037
5038         item_tester_no_ryoute = TRUE;
5039         q = _("どのアイテムを調べますか?", "Meditate on which item? ");
5040         s = _("調べるアイテムがありません。", "You have nothing appropriate.");
5041
5042         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
5043
5044         /* Get the item (in the pack) */
5045         if (item >= 0)
5046         {
5047                 o_ptr = &inventory[item];
5048         }
5049
5050         /* Get the item (on the floor) */
5051         else
5052         {
5053                 o_ptr = &o_list[0 - item];
5054         }
5055
5056         /* It is fully known, no information needed */
5057         if (object_is_known(o_ptr))
5058         {
5059                 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
5060                 return TRUE;
5061         }
5062
5063         /* Check for a feeling */
5064         feel = value_check_aux1(o_ptr);
5065
5066         /* Get an object description */
5067         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5068
5069         /* Skip non-feelings */
5070         if (!feel)
5071         {
5072                 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
5073                 return TRUE;
5074         }
5075
5076 #ifdef JP
5077         msg_format("%sは%sという感じがする...",
5078                 o_name, game_inscriptions[feel]);
5079 #else
5080         msg_format("You feel that the %s %s %s...",
5081                 o_name, ((o_ptr->number == 1) ? "is" : "are"),
5082                 game_inscriptions[feel]);
5083 #endif
5084
5085
5086         /* We have "felt" it */
5087         o_ptr->ident |= (IDENT_SENSE);
5088
5089         /* "Inscribe" it */
5090         o_ptr->feeling = feel;
5091
5092         /* Player touches it */
5093         o_ptr->marked |= OM_TOUCHED;
5094
5095         /* Combine / Reorder the pack (later) */
5096         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5097
5098         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5099
5100         /* Valid "tval" codes */
5101         switch (o_ptr->tval)
5102         {
5103         case TV_SHOT:
5104         case TV_ARROW:
5105         case TV_BOLT:
5106         case TV_BOW:
5107         case TV_DIGGING:
5108         case TV_HAFTED:
5109         case TV_POLEARM:
5110         case TV_SWORD:
5111         case TV_BOOTS:
5112         case TV_GLOVES:
5113         case TV_HELM:
5114         case TV_CROWN:
5115         case TV_SHIELD:
5116         case TV_CLOAK:
5117         case TV_SOFT_ARMOR:
5118         case TV_HARD_ARMOR:
5119         case TV_DRAG_ARMOR:
5120         case TV_CARD:
5121         case TV_RING:
5122         case TV_AMULET:
5123         case TV_LITE:
5124         case TV_FIGURINE:
5125                 okay = TRUE;
5126                 break;
5127         }
5128
5129         /* Auto-inscription/destroy */
5130         autopick_alter_item(item, (bool)(okay && destroy_feeling));
5131
5132         /* Something happened */
5133         return (TRUE);
5134 }