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