OSDN Git Service

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