OSDN Git Service

354d56ba89624feb93cfeaf82fd113650da2fda3
[hengband/hengband.git] / src / spells2.c
1 /*!
2  * @file spells2.c
3  * @brief 魔法効果の実装/ Spell code (part 2)
4  * @date 2014/07/15
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * </pre>
12  */
13
14 #include "angband.h"
15 #include "grid.h"
16 #include "trap.h"
17 #include "monster-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                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
533
534                 /* Skip dead monsters */
535                 if (!m_ptr->r_idx) continue;
536
537                 y = m_ptr->fy;
538                 x = m_ptr->fx;
539
540                 /* Only detect nearby monsters */
541                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
542
543                 /* Detect non-living monsters */
544                 if (!monster_living(r_ptr))
545                 {
546                         /* Update monster recall window */
547                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
548                         {
549                                 p_ptr->window |= (PW_MONSTER);
550                         }
551
552                         /* Repair visibility later */
553                         repair_monsters = TRUE;
554
555                         /* Hack -- Detect monster */
556                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
557                         update_monster(i, FALSE);
558                         flag = TRUE;
559                 }
560         }
561         if (flag)
562         {
563                 /* Describe result */
564                 msg_print(_("自然でないモンスターの存在を感じた!", "You sense the presence of unnatural beings!"));
565         }
566         return (flag);
567 }
568
569 /*!
570  * @brief 精神のあるモンスターを感知する / Detect all monsters it has mind on current panel
571  * @param range 効果範囲
572  * @return 効力があった場合TRUEを返す
573  */
574 bool detect_monsters_mind(POSITION range)
575 {
576         MONSTER_IDX i;
577         POSITION y, x;
578         bool flag = FALSE;
579
580         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
581
582         /* Scan monsters */
583         for (i = 1; i < m_max; i++)
584         {
585                 monster_type *m_ptr = &m_list[i];
586                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
587
588                 /* Skip dead monsters */
589                 if (!m_ptr->r_idx) continue;
590
591                 y = m_ptr->fy;
592                 x = m_ptr->fx;
593
594                 /* Only detect nearby monsters */
595                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
596
597                 /* Detect non-living monsters */
598                 if (!(r_ptr->flags2 & RF2_EMPTY_MIND))
599                 {
600                         /* Update monster recall window */
601                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
602                         {
603                                 p_ptr->window |= (PW_MONSTER);
604                         }
605
606                         /* Repair visibility later */
607                         repair_monsters = TRUE;
608
609                         /* Hack -- Detect monster */
610                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
611                         update_monster(i, FALSE);
612                         flag = TRUE;
613                 }
614         }
615         if (flag)
616         {
617                 /* Describe result */
618                 msg_print(_("殺気を感じとった!", "You sense the presence of someone's mind!"));
619         }
620         return (flag);
621 }
622
623
624 /*!
625  * @brief 該当シンボルのモンスターを感知する / Detect all (string) monsters on current panel
626  * @param range 効果範囲
627  * @param Match 対応シンボルの混じったモンスター文字列(複数指定化)
628  * @return 効力があった場合TRUEを返す
629  */
630 bool detect_monsters_string(POSITION range, cptr Match)
631 {
632         MONSTER_IDX i;
633         POSITION y, x;
634         bool flag = FALSE;
635
636         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
637
638         /* Scan monsters */
639         for (i = 1; i < m_max; i++)
640         {
641                 monster_type *m_ptr = &m_list[i];
642                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
643
644                 /* Skip dead monsters */
645                 if (!m_ptr->r_idx) continue;
646
647                 y = m_ptr->fy;
648                 x = m_ptr->fx;
649
650                 /* Only detect nearby monsters */
651                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
652
653                 /* Detect monsters with the same symbol */
654                 if (my_strchr(Match, r_ptr->d_char))
655                 {
656                         /* Update monster recall window */
657                         if (p_ptr->monster_race_idx == m_ptr->r_idx)
658                         {
659                                 p_ptr->window |= (PW_MONSTER);
660                         }
661
662                         /* Repair visibility later */
663                         repair_monsters = TRUE;
664
665                         /* Hack -- Detect monster */
666                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
667                         update_monster(i, FALSE);
668                         flag = TRUE;
669                 }
670         }
671
672         if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
673         if (flag)
674         {
675                 /* Describe result */
676                 msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
677         }
678         return (flag);
679 }
680
681 /*!
682  * @brief flags3に対応するモンスターを感知する / A "generic" detect monsters routine, tagged to flags3
683  * @param range 効果範囲
684  * @param match_flag 感知フラグ
685  * @return 効力があった場合TRUEを返す
686  */
687 bool detect_monsters_xxx(POSITION range, u32b match_flag)
688 {
689         MONSTER_IDX i;
690         POSITION y, x;
691         bool flag = FALSE;
692         cptr desc_monsters = _("変なモンスター", "weird monsters");
693
694         if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
695
696         /* Scan monsters */
697         for (i = 1; i < m_max; i++)
698         {
699                 monster_type *m_ptr = &m_list[i];
700                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
701
702                 /* Skip dead monsters */
703                 if (!m_ptr->r_idx) continue;
704
705                 y = m_ptr->fy;
706                 x = m_ptr->fx;
707
708                 /* Only detect nearby monsters */
709                 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
710
711                 /* Detect evil monsters */
712                 if (r_ptr->flags3 & (match_flag))
713                 {
714                         if (is_original_ap(m_ptr))
715                         {
716                                 /* Take note that they are something */
717                                 r_ptr->r_flags3 |= (match_flag);
718
719                                 /* Update monster recall window */
720                                 if (p_ptr->monster_race_idx == m_ptr->r_idx)
721                                 {
722                                         p_ptr->window |= (PW_MONSTER);
723                                 }
724                         }
725
726                         /* Repair visibility later */
727                         repair_monsters = TRUE;
728
729                         /* Hack -- Detect monster */
730                         m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
731                         update_monster(i, FALSE);
732                         flag = TRUE;
733                 }
734         }
735         if (flag)
736         {
737                 switch (match_flag)
738                 {
739                         case RF3_DEMON:
740                         desc_monsters = _("デーモン", "demons");
741                                 break;
742                         case RF3_UNDEAD:
743                         desc_monsters = _("アンデッド", "the undead");
744                                 break;
745                 }
746
747                 /* Describe result */
748                 msg_format(_("%sの存在を感じとった!", "You sense the presence of %s!"), desc_monsters);
749                 msg_print(NULL);
750         }
751         return (flag);
752 }
753
754
755 /*!
756  * @brief 全感知処理 / Detect everything
757  * @param range 効果範囲
758  * @return 効力があった場合TRUEを返す
759  */
760 bool detect_all(POSITION range)
761 {
762         bool detect = FALSE;
763
764         /* Detect everything */
765         if (detect_traps(range, TRUE)) detect = TRUE;
766         if (detect_doors(range)) detect = TRUE;
767         if (detect_stairs(range)) detect = TRUE;
768
769         /* There are too many hidden treasure.  So... */
770         /* if (detect_treasure(range)) detect = TRUE; */
771
772         if (detect_objects_gold(range)) detect = TRUE;
773         if (detect_objects_normal(range)) detect = TRUE;
774         if (detect_monsters_invis(range)) detect = TRUE;
775         if (detect_monsters_normal(range)) detect = TRUE;
776         return (detect);
777 }
778
779
780 /*!
781  * @brief 視界内モンスターに魔法効果を与える / Apply a "project()" directly to all viewable monsters
782  * @param typ 属性効果
783  * @param dam 効果量
784  * @return 効力があった場合TRUEを返す
785  * @details
786  * <pre>
787  * Note that affected monsters are NOT auto-tracked by this usage.
788  *
789  * To avoid misbehavior when monster deaths have side-effects,
790  * this is done in two passes. -- JDL
791  * </pre>
792  */
793 bool project_hack(EFFECT_ID typ, HIT_POINT dam)
794 {
795         MONSTER_IDX i;
796         POSITION x, y;
797         BIT_FLAGS flg = PROJECT_JUMP | PROJECT_KILL | PROJECT_HIDE;
798         bool obvious = FALSE;
799
800
801         /* Mark all (nearby) monsters */
802         for (i = 1; i < m_max; i++)
803         {
804                 monster_type *m_ptr = &m_list[i];
805
806                 /* Paranoia -- Skip dead monsters */
807                 if (!m_ptr->r_idx) continue;
808
809                 y = m_ptr->fy;
810                 x = m_ptr->fx;
811
812                 /* Require line of sight */
813                 if (!player_has_los_bold(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)) continue;
814
815                 /* Mark the monster */
816                 m_ptr->mflag |= (MFLAG_TEMP);
817         }
818
819         /* Affect all marked monsters */
820         for (i = 1; i < m_max; i++)
821         {
822                 monster_type *m_ptr = &m_list[i];
823
824                 /* Skip unmarked monsters */
825                 if (!(m_ptr->mflag & (MFLAG_TEMP))) continue;
826
827                 /* Remove mark */
828                 m_ptr->mflag &= ~(MFLAG_TEMP);
829
830                 y = m_ptr->fy;
831                 x = m_ptr->fx;
832
833                 /* Jump directly to the target monster */
834                 if (project(0, 0, y, x, dam, typ, flg, -1)) obvious = TRUE;
835         }
836         return (obvious);
837 }
838
839
840 /*!
841  * @brief 視界内モンスターを加速する処理 / Speed monsters
842  * @return 効力があった場合TRUEを返す
843  */
844 bool speed_monsters(void)
845 {
846         return (project_hack(GF_OLD_SPEED, p_ptr->lev));
847 }
848
849 /*!
850  * @brief 視界内モンスターを加速する処理 / Slow monsters
851  * @return 効力があった場合TRUEを返す
852  */
853 bool slow_monsters(int power)
854 {
855         return (project_hack(GF_OLD_SLOW, power));
856 }
857
858 /*!
859  * @brief 視界内モンスターを眠らせる処理 / Sleep monsters
860  * @return 効力があった場合TRUEを返す
861  */
862 bool sleep_monsters(int power)
863 {
864         return (project_hack(GF_OLD_SLEEP, power));
865 }
866
867 /*!
868  * @brief 視界内の邪悪なモンスターをテレポート・アウェイさせる処理 / Banish evil monsters
869  * @return 効力があった場合TRUEを返す
870  */
871 bool banish_evil(int dist)
872 {
873         return (project_hack(GF_AWAY_EVIL, dist));
874 }
875
876 /*!
877  * @brief 視界内のアンデッド・モンスターを恐怖させる処理 / Turn undead
878  * @return 効力があった場合TRUEを返す
879  */
880 bool turn_undead(void)
881 {
882         bool tester = (project_hack(GF_TURN_UNDEAD, p_ptr->lev));
883         if (tester)
884                 chg_virtue(V_UNLIFE, -1);
885         return tester;
886 }
887
888 /*!
889  * @brief 視界内のアンデッド・モンスターにダメージを与える処理 / Dispel undead monsters
890  * @return 効力があった場合TRUEを返す
891  */
892 bool dispel_undead(HIT_POINT dam)
893 {
894         bool tester = (project_hack(GF_DISP_UNDEAD, dam));
895         if (tester)
896                 chg_virtue(V_UNLIFE, -2);
897         return tester;
898 }
899
900 /*!
901  * @brief 視界内の邪悪なモンスターにダメージを与える処理 / Dispel evil monsters
902  * @return 効力があった場合TRUEを返す
903  */
904 bool dispel_evil(HIT_POINT dam)
905 {
906         return (project_hack(GF_DISP_EVIL, dam));
907 }
908
909 /*!
910  * @brief 視界内の善良なモンスターにダメージを与える処理 / Dispel good monsters
911  * @return 効力があった場合TRUEを返す
912  */
913 bool dispel_good(HIT_POINT dam)
914 {
915         return (project_hack(GF_DISP_GOOD, dam));
916 }
917
918 /*!
919  * @brief 視界内のあらゆるモンスターにダメージを与える処理 / Dispel all monsters
920  * @return 効力があった場合TRUEを返す
921  */
922 bool dispel_monsters(HIT_POINT dam)
923 {
924         return (project_hack(GF_DISP_ALL, dam));
925 }
926
927 /*!
928  * @brief 視界内の生命のあるモンスターにダメージを与える処理 / Dispel 'living' monsters
929  * @return 効力があった場合TRUEを返す
930  */
931 bool dispel_living(HIT_POINT dam)
932 {
933         return (project_hack(GF_DISP_LIVING, dam));
934 }
935
936 /*!
937  * @brief 視界内の悪魔系モンスターにダメージを与える処理 / Dispel 'living' monsters
938  * @return 効力があった場合TRUEを返す
939  */
940 bool dispel_demons(HIT_POINT dam)
941 {
942         return (project_hack(GF_DISP_DEMON, dam));
943 }
944
945 /*!
946  * @brief 視界内のモンスターに「聖戦」効果を与える処理
947  * @return 効力があった場合TRUEを返す
948  */
949 bool crusade(void)
950 {
951         return (project_hack(GF_CRUSADE, p_ptr->lev*4));
952 }
953
954 /*!
955  * @brief 視界内モンスターを怒らせる処理 / Wake up all monsters, and speed up "los" monsters.
956  * @param who 怒らせる原因を起こしたモンスター(0ならばプレイヤー)
957  * @return なし
958  */
959 void aggravate_monsters(MONSTER_IDX who)
960 {
961         MONSTER_IDX i;
962         bool    sleep = FALSE;
963         bool    speed = FALSE;
964
965         /* Aggravate everyone nearby */
966         for (i = 1; i < m_max; i++)
967         {
968                 monster_type *m_ptr = &m_list[i];
969
970                 /* Paranoia -- Skip dead monsters */
971                 if (!m_ptr->r_idx) continue;
972
973                 /* Skip aggravating monster (or player) */
974                 if (i == who) continue;
975
976                 /* Wake up nearby sleeping monsters */
977                 if (m_ptr->cdis < MAX_SIGHT * 2)
978                 {
979                         /* Wake up */
980                         if (MON_CSLEEP(m_ptr))
981                         {
982                                 (void)set_monster_csleep(i, 0);
983                                 sleep = TRUE;
984                         }
985                         if (!is_pet(m_ptr)) m_ptr->mflag2 |= MFLAG2_NOPET;
986                 }
987
988                 /* Speed up monsters in line of sight */
989                 if (player_has_los_bold(m_ptr->fy, m_ptr->fx))
990                 {
991                         if (!is_pet(m_ptr))
992                         {
993                                 (void)set_monster_fast(i, MON_FAST(m_ptr) + 100);
994                                 speed = TRUE;
995                         }
996                 }
997         }
998
999         if (speed) msg_print(_("付近で何かが突如興奮したような感じを受けた!", "You feel a sudden stirring nearby!"));
1000         else if (sleep) msg_print(_("何かが突如興奮したような騒々しい音が遠くに聞こえた!", "You hear a sudden stirring in the distance!"));
1001         if (p_ptr->riding) p_ptr->update |= PU_BONUS;
1002 }
1003
1004
1005 /*!
1006  * @brief モンスターへの単体抹殺処理サブルーチン / Delete a non-unique/non-quest monster
1007  * @param m_idx 抹殺するモンスターID
1008  * @param power 抹殺の威力
1009  * @param player_cast プレイヤーの魔法によるものならば TRUE
1010  * @param dam_side プレイヤーへの負担ダメージ量(1d(dam_side))
1011  * @param spell_name 抹殺効果を起こした魔法の名前
1012  * @return 効力があった場合TRUEを返す
1013  */
1014 bool genocide_aux(MONSTER_IDX m_idx, int power, bool player_cast, int dam_side, cptr spell_name)
1015 {
1016         int          msec = delay_factor * delay_factor * delay_factor;
1017         monster_type *m_ptr = &m_list[m_idx];
1018         monster_race *r_ptr = &r_info[m_ptr->r_idx];
1019         bool         resist = FALSE;
1020
1021         if (is_pet(m_ptr) && !player_cast) return FALSE;
1022
1023         /* Hack -- Skip Unique Monsters or Quest Monsters */
1024         if (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) resist = TRUE;
1025         else if (r_ptr->flags7 & RF7_UNIQUE2) resist = TRUE;
1026         else if (m_idx == p_ptr->riding) resist = TRUE;
1027         else if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle) resist = TRUE;
1028         else if (player_cast && (r_ptr->level > randint0(power))) resist = TRUE;
1029         else if (player_cast && (m_ptr->mflag2 & MFLAG2_NOGENO)) resist = TRUE;
1030
1031
1032         else
1033         {
1034                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1035                 {
1036                         char m_name[80];
1037
1038                         monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1039                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
1040                 }
1041
1042                 delete_monster_idx(m_idx);
1043         }
1044
1045         if (resist && player_cast)
1046         {
1047                 bool see_m = is_seen(m_ptr);
1048                 char m_name[80];
1049
1050                 monster_desc(m_name, m_ptr, 0);
1051                 if (see_m)
1052                 {
1053                         msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
1054                 }
1055                 if (MON_CSLEEP(m_ptr))
1056                 {
1057                         (void)set_monster_csleep(m_idx, 0);
1058                         if (m_ptr->ml)
1059                         {
1060                                 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1061                         }
1062                 }
1063                 if (is_friendly(m_ptr) && !is_pet(m_ptr))
1064                 {
1065                         if (see_m)
1066                         {
1067                                 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
1068                         }
1069                         set_hostile(m_ptr);
1070                 }
1071                 if (one_in_(13)) m_ptr->mflag2 |= MFLAG2_NOGENO;
1072         }
1073
1074         if (player_cast)
1075         {
1076                 take_hit(DAMAGE_GENO, randint1(dam_side), format(_("%^sの呪文を唱えた疲労", "the strain of casting %^s"), spell_name), -1);
1077         }
1078
1079         /* Visual feedback */
1080         move_cursor_relative(p_ptr->y, p_ptr->x);
1081
1082         p_ptr->redraw |= (PR_HP);
1083         p_ptr->window |= (PW_PLAYER);
1084
1085         /* Handle */
1086         handle_stuff();
1087         Term_fresh();
1088
1089         Term_xtra(TERM_XTRA_DELAY, msec);
1090
1091         return !resist;
1092 }
1093
1094
1095 /*!
1096  * @brief モンスターへのシンボル抹殺処理ルーチン / Delete all non-unique/non-quest monsters of a given "type" from the level
1097  * @param power 抹殺の威力
1098  * @param player_cast プレイヤーの魔法によるものならば TRUE
1099  * @return 効力があった場合TRUEを返す
1100  */
1101 bool symbol_genocide(int power, bool player_cast)
1102 {
1103         MONSTER_IDX i;
1104         char typ;
1105         bool result = FALSE;
1106
1107         /* Prevent genocide in quest levels */
1108         if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
1109         {
1110                 return (FALSE);
1111         }
1112
1113         /* Mega-Hack -- Get a monster symbol */
1114         while (!get_com(_("どの種類(文字)のモンスターを抹殺しますか: ", "Choose a monster race (by symbol) to genocide: "), &typ, FALSE)) ;
1115
1116         /* Delete the monsters of that "type" */
1117         for (i = 1; i < m_max; i++)
1118         {
1119                 monster_type *m_ptr = &m_list[i];
1120                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1121
1122                 /* Paranoia -- Skip dead monsters */
1123                 if (!m_ptr->r_idx) continue;
1124
1125                 /* Skip "wrong" monsters */
1126                 if (r_ptr->d_char != typ) continue;
1127
1128                 /* Take note */
1129                 result |= genocide_aux(i, power, player_cast, 4, _("抹殺", "Genocide"));
1130         }
1131
1132         if (result)
1133         {
1134                 chg_virtue(V_VITALITY, -2);
1135                 chg_virtue(V_CHANCE, -1);
1136         }
1137
1138         return result;
1139 }
1140
1141
1142 /*!
1143  * @brief モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) monsters
1144  * @param power 抹殺の威力
1145  * @param player_cast プレイヤーの魔法によるものならば TRUE
1146  * @return 効力があった場合TRUEを返す
1147  */
1148 bool mass_genocide(int power, bool player_cast)
1149 {
1150         MONSTER_IDX i;
1151         bool result = FALSE;
1152
1153         /* Prevent mass genocide in quest levels */
1154         if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
1155         {
1156                 return (FALSE);
1157         }
1158
1159         /* Delete the (nearby) monsters */
1160         for (i = 1; i < m_max; i++)
1161         {
1162                 monster_type *m_ptr = &m_list[i];
1163
1164                 /* Paranoia -- Skip dead monsters */
1165                 if (!m_ptr->r_idx) continue;
1166
1167                 /* Skip distant monsters */
1168                 if (m_ptr->cdis > MAX_SIGHT) continue;
1169
1170                 /* Note effect */
1171                 result |= genocide_aux(i, power, player_cast, 3, _("周辺抹殺", "Mass Genocide"));
1172         }
1173
1174         if (result)
1175         {
1176                 chg_virtue(V_VITALITY, -2);
1177                 chg_virtue(V_CHANCE, -1);
1178         }
1179
1180         return result;
1181 }
1182
1183
1184 /*!
1185  * @brief アンデッド・モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) undead
1186  * @param power 抹殺の威力
1187  * @param player_cast プレイヤーの魔法によるものならば TRUE
1188  * @return 効力があった場合TRUEを返す
1189  */
1190 bool mass_genocide_undead(int power, bool player_cast)
1191 {
1192         MONSTER_IDX i;
1193         bool result = FALSE;
1194
1195         /* Prevent mass genocide in quest levels */
1196         if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
1197         {
1198                 return (FALSE);
1199         }
1200
1201         /* Delete the (nearby) monsters */
1202         for (i = 1; i < m_max; i++)
1203         {
1204                 monster_type *m_ptr = &m_list[i];
1205                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1206
1207                 /* Paranoia -- Skip dead monsters */
1208                 if (!m_ptr->r_idx) continue;
1209
1210                 if (!(r_ptr->flags3 & RF3_UNDEAD)) continue;
1211
1212                 /* Skip distant monsters */
1213                 if (m_ptr->cdis > MAX_SIGHT) continue;
1214
1215                 /* Note effect */
1216                 result |= genocide_aux(i, power, player_cast, 3, _("アンデッド消滅", "Annihilate Undead"));
1217         }
1218
1219         if (result)
1220         {
1221                 chg_virtue(V_UNLIFE, -2);
1222                 chg_virtue(V_CHANCE, -1);
1223         }
1224
1225         return result;
1226 }
1227
1228
1229 /*!
1230  * @brief 周辺モンスターを調査する / Probe nearby monsters
1231  * @return 効力があった場合TRUEを返す
1232  */
1233 bool probing(void)
1234 {
1235         int i;
1236         SPEED speed;
1237         bool_hack cu, cv;
1238         bool probe = FALSE;
1239         char buf[256];
1240         cptr align;
1241
1242         cu = Term->scr->cu;
1243         cv = Term->scr->cv;
1244         Term->scr->cu = 0;
1245         Term->scr->cv = 1;
1246
1247         /* Probe all (nearby) monsters */
1248         for (i = 1; i < m_max; i++)
1249         {
1250                 monster_type *m_ptr = &m_list[i];
1251                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1252
1253                 /* Paranoia -- Skip dead monsters */
1254                 if (!m_ptr->r_idx) continue;
1255
1256                 /* Require line of sight */
1257                 if (!player_has_los_bold(m_ptr->fy, m_ptr->fx)) continue;
1258
1259                 /* Probe visible monsters */
1260                 if (m_ptr->ml)
1261                 {
1262                         char m_name[80];
1263
1264                         /* Start the message */
1265                         if (!probe)
1266                         {
1267                                 msg_print(_("調査中...", "Probing..."));
1268                         }
1269
1270                         msg_print(NULL);
1271
1272                         if (!is_original_ap(m_ptr))
1273                         {
1274                                 if (m_ptr->mflag2 & MFLAG2_KAGE)
1275                                         m_ptr->mflag2 &= ~(MFLAG2_KAGE);
1276
1277                                 m_ptr->ap_r_idx = m_ptr->r_idx;
1278                                 lite_spot(m_ptr->fy, m_ptr->fx);
1279                         }
1280                         /* Get "the monster" or "something" */
1281                         monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_INDEF_HIDDEN);
1282
1283                         speed = m_ptr->mspeed - 110;
1284                         if (MON_FAST(m_ptr)) speed += 10;
1285                         if (MON_SLOW(m_ptr)) speed -= 10;
1286                         if (ironman_nightmare) speed += 5;
1287
1288                         /* Get the monster's alignment */
1289                         if ((r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) == (RF3_EVIL | RF3_GOOD)) align = _("善悪", "good&evil");
1290                         else if (r_ptr->flags3 & RF3_EVIL) align = _("邪悪", "evil");
1291                         else if (r_ptr->flags3 & RF3_GOOD) align = _("善良", "good");
1292                         else if ((m_ptr->sub_align & (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) == (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) _(align = "中立(善悪)", "neutral(good&evil)");
1293                         else if (m_ptr->sub_align & SUB_ALIGN_EVIL) align = _("中立(邪悪)", "neutral(evil)");
1294                         else if (m_ptr->sub_align & SUB_ALIGN_GOOD) align = _("中立(善良)", "neutral(good)");
1295                         else align = _("中立", "neutral");
1296
1297                         /* Describe the monster */
1298                         sprintf(buf,_("%s ... 属性:%s HP:%d/%d AC:%d 速度:%s%d 経験:", "%s ... align:%s HP:%d/%d AC:%d speed:%s%d exp:"),
1299                                 m_name, align, (int)m_ptr->hp, (int)m_ptr->maxhp, r_ptr->ac, (speed > 0) ? "+" : "", speed);
1300
1301                         if (r_ptr->next_r_idx)
1302                         {
1303                                 strcat(buf, format("%d/%d ", m_ptr->exp, r_ptr->next_exp));
1304                         }
1305                         else
1306                         {
1307                                 strcat(buf, "xxx ");
1308                         }
1309
1310                         if (MON_CSLEEP(m_ptr)) strcat(buf,_("睡眠 ", "sleeping "));
1311                         if (MON_STUNNED(m_ptr)) strcat(buf, _("朦朧 ", "stunned "));
1312                         if (MON_MONFEAR(m_ptr)) strcat(buf, _("恐怖 ", "scared "));
1313                         if (MON_CONFUSED(m_ptr)) strcat(buf, _("混乱 ", "confused "));
1314                         if (MON_INVULNER(m_ptr)) strcat(buf, _("無敵 ", "invulnerable "));
1315                         buf[strlen(buf)-1] = '\0';
1316                         prt(buf, 0, 0);
1317
1318                         /* HACK : Add the line to message buffer */
1319                         message_add(buf);
1320                         p_ptr->window |= (PW_MESSAGE);
1321                         window_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
2251                                         /* Acquire the monster name */
2252                                         monster_desc(m_name, m_ptr, 0);
2253
2254                                         /* Dump a message */
2255                                         msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
2256                                 }
2257                         }
2258                 }
2259
2260                 /* Note */
2261                 note_spot(y, x);
2262
2263                 lite_spot(y, x);
2264
2265                 update_local_illumination(y, x);
2266         }
2267
2268         /* None left */
2269         temp_n = 0;
2270 }
2271
2272
2273
2274 /*!
2275  * @brief 部屋全体を暗くするサブルーチン
2276  * @return なし
2277  * @details
2278  * <pre>
2279  * This routine clears the entire "temp" set.
2280  * This routine will "darken" all "temp" grids.
2281  * In addition, some of these grids will be "unmarked".
2282  * This routine is used (only) by "unlite_room()"
2283  * Also, process all affected monsters
2284  * </pre>
2285  */
2286 static void cave_temp_room_unlite(void)
2287 {
2288         int i;
2289
2290         /* Clear them all */
2291         for (i = 0; i < temp_n; i++)
2292         {
2293                 POSITION y = temp_y[i];
2294                 POSITION x = temp_x[i];
2295                 int j;
2296
2297                 cave_type *c_ptr = &cave[y][x];
2298                 bool do_dark = !is_mirror_grid(c_ptr);
2299
2300                 /* No longer in the array */
2301                 c_ptr->info &= ~(CAVE_TEMP);
2302
2303                 /* Darken the grid */
2304                 if (do_dark)
2305                 {
2306                         if (dun_level || !is_daytime())
2307                         {
2308                                 for (j = 0; j < 9; j++)
2309                                 {
2310                                         int by = y + ddy_ddd[j];
2311                                         int bx = x + ddx_ddd[j];
2312
2313                                         if (in_bounds2(by, bx))
2314                                         {
2315                                                 cave_type *cc_ptr = &cave[by][bx];
2316
2317                                                 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
2318                                                 {
2319                                                         do_dark = FALSE;
2320                                                         break;
2321                                                 }
2322                                         }
2323                                 }
2324
2325                                 if (!do_dark) continue;
2326                         }
2327
2328                         c_ptr->info &= ~(CAVE_GLOW);
2329
2330                         /* Hack -- Forget "boring" grids */
2331                         if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_REMEMBER))
2332                         {
2333                                 /* Forget the grid */
2334                                 if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
2335
2336                                 note_spot(y, x);
2337                         }
2338
2339                         /* Process affected monsters */
2340                         if (c_ptr->m_idx)
2341                         {
2342                                 update_monster(c_ptr->m_idx, FALSE);
2343                         }
2344
2345                         lite_spot(y, x);
2346
2347                         update_local_illumination(y, x);
2348                 }
2349         }
2350
2351         /* None left */
2352         temp_n = 0;
2353 }
2354
2355
2356 /*!
2357  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2358  * @param cy Y座標
2359  * @param cx X座標
2360  * @param pass_bold 地形条件を返す関数ポインタ
2361  * @return 該当地形の数
2362  */
2363 static int next_to_open(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2364 {
2365         int i;
2366         POSITION y, x;
2367         int len = 0;
2368         int blen = 0;
2369
2370         for (i = 0; i < 16; i++)
2371         {
2372                 y = cy + ddy_cdd[i % 8];
2373                 x = cx + ddx_cdd[i % 8];
2374
2375                 /* Found a wall, break the length */
2376                 if (!pass_bold(y, x))
2377                 {
2378                         /* Track best length */
2379                         if (len > blen)
2380                         {
2381                                 blen = len;
2382                         }
2383
2384                         len = 0;
2385                 }
2386                 else
2387                 {
2388                         len++;
2389                 }
2390         }
2391
2392         return (MAX(len, blen));
2393 }
2394
2395 /*!
2396  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2397  * @param cy Y座標
2398  * @param cx X座標
2399  * @param pass_bold 地形条件を返す関数ポインタ
2400  * @return 該当地形の数
2401  */
2402 static int next_to_walls_adj(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2403 {
2404         DIRECTION i;
2405         POSITION y, x;
2406         int c = 0;
2407
2408         for (i = 0; i < 8; i++)
2409         {
2410                 y = cy + ddy_ddd[i];
2411                 x = cx + ddx_ddd[i];
2412
2413                 if (!pass_bold(y, x)) c++;
2414         }
2415
2416         return c;
2417 }
2418
2419
2420 /*!
2421  * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数temp_nに返す / Aux function -- see below
2422  * @param y 部屋内のy座標1点
2423  * @param x 部屋内のx座標1点
2424  * @param only_room 部屋内地形のみをチェック対象にするならば TRUE
2425  * @param pass_bold 地形条件を返す関数ポインタ
2426  * @return 該当地形の数
2427  */
2428 static void cave_temp_room_aux(POSITION y, POSITION x, bool only_room, bool (*pass_bold)(POSITION, POSITION))
2429 {
2430         cave_type *c_ptr;
2431
2432         /* Get the grid */
2433         c_ptr = &cave[y][x];
2434
2435         /* Avoid infinite recursion */
2436         if (c_ptr->info & (CAVE_TEMP)) return;
2437
2438         /* Do not "leave" the current room */
2439         if (!(c_ptr->info & (CAVE_ROOM)))
2440         {
2441                 if (only_room) return;
2442
2443                 /* Verify */
2444                 if (!in_bounds2(y, x)) return;
2445
2446                 /* Do not exceed the maximum spell range */
2447                 if (distance(p_ptr->y, p_ptr->x, y, x) > MAX_RANGE) return;
2448
2449                 /* Verify this grid */
2450                 /*
2451                  * The reason why it is ==6 instead of >5 is that 8 is impossible
2452                  * due to the check for cave_bold above.
2453                  * 7 lights dead-end corridors (you need to do this for the
2454                  * checkboard interesting rooms, so that the boundary is lit
2455                  * properly.
2456                  * This leaves only a check for 6 bounding walls!
2457                  */
2458                 if (in_bounds(y, x) && pass_bold(y, x) &&
2459                     (next_to_walls_adj(y, x, pass_bold) == 6) && (next_to_open(y, x, pass_bold) <= 1)) return;
2460         }
2461
2462         /* Paranoia -- verify space */
2463         if (temp_n == TEMP_MAX) return;
2464
2465         /* Mark the grid as "seen" */
2466         c_ptr->info |= (CAVE_TEMP);
2467
2468         /* Add it to the "seen" set */
2469         temp_y[temp_n] = y;
2470         temp_x[temp_n] = x;
2471         temp_n++;
2472 }
2473
2474 /*!
2475  * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
2476  * @param y 指定Y座標
2477  * @param x 指定X座標
2478  * @return 光を通すならばtrueを返す。
2479  */
2480 static bool cave_pass_lite_bold(POSITION y, POSITION x)
2481 {
2482         return cave_los_bold(y, x);
2483 }
2484
2485 /*!
2486  * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数temp_nに返す / Aux function -- see below
2487  * @param y 指定Y座標
2488  * @param x 指定X座標
2489  * @return なし
2490  */
2491 static void cave_temp_lite_room_aux(POSITION y, POSITION x)
2492 {
2493         cave_temp_room_aux(y, x, FALSE, cave_pass_lite_bold);
2494 }
2495
2496 /*!
2497  * @brief 指定のマスが光を通さず射線のみを通すかを返す。 / Aux function -- see below
2498  * @param y 指定Y座標
2499  * @param x 指定X座標
2500  * @return 射線を通すならばtrueを返す。
2501  */
2502 static bool cave_pass_dark_bold(POSITION y, POSITION x)
2503 {
2504         return cave_have_flag_bold(y, x, FF_PROJECT);
2505 }
2506
2507
2508 /*!
2509  * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数temp_nに返す / Aux function -- see below
2510  * @param y 指定Y座標
2511  * @param x 指定X座標
2512  * @return なし
2513  */
2514 static void cave_temp_unlite_room_aux(POSITION y, POSITION x)
2515 {
2516         cave_temp_room_aux(y, x, TRUE, cave_pass_dark_bold);
2517 }
2518
2519
2520 /*!
2521  * @brief 指定された部屋内を照らす / Illuminate any room containing the given location.
2522  * @param y1 指定Y座標
2523  * @param x1 指定X座標
2524  * @return なし
2525  */
2526 void lite_room(POSITION y1, POSITION x1)
2527 {
2528         int i;
2529         POSITION x, y;
2530
2531         /* Add the initial grid */
2532         cave_temp_lite_room_aux(y1, x1);
2533
2534         /* While grids are in the queue, add their neighbors */
2535         for (i = 0; i < temp_n; i++)
2536         {
2537                 x = temp_x[i], y = temp_y[i];
2538
2539                 /* Walls get lit, but stop light */
2540                 if (!cave_pass_lite_bold(y, x)) continue;
2541
2542                 /* Spread adjacent */
2543                 cave_temp_lite_room_aux(y + 1, x);
2544                 cave_temp_lite_room_aux(y - 1, x);
2545                 cave_temp_lite_room_aux(y, x + 1);
2546                 cave_temp_lite_room_aux(y, x - 1);
2547
2548                 /* Spread diagonal */
2549                 cave_temp_lite_room_aux(y + 1, x + 1);
2550                 cave_temp_lite_room_aux(y - 1, x - 1);
2551                 cave_temp_lite_room_aux(y - 1, x + 1);
2552                 cave_temp_lite_room_aux(y + 1, x - 1);
2553         }
2554
2555         /* Now, lite them all up at once */
2556         cave_temp_room_lite();
2557
2558         if (p_ptr->special_defense & NINJA_S_STEALTH)
2559         {
2560                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
2561         }
2562 }
2563
2564
2565 /*!
2566  * @brief 指定された部屋内を暗くする / Darken all rooms containing the given location
2567  * @param y1 指定Y座標
2568  * @param x1 指定X座標
2569  * @return なし
2570  */
2571 void unlite_room(POSITION y1, POSITION x1)
2572 {
2573         int i;
2574         POSITION x, y;
2575
2576         /* Add the initial grid */
2577         cave_temp_unlite_room_aux(y1, x1);
2578
2579         /* Spread, breadth first */
2580         for (i = 0; i < temp_n; i++)
2581         {
2582                 x = temp_x[i], y = temp_y[i];
2583
2584                 /* Walls get dark, but stop darkness */
2585                 if (!cave_pass_dark_bold(y, x)) continue;
2586
2587                 /* Spread adjacent */
2588                 cave_temp_unlite_room_aux(y + 1, x);
2589                 cave_temp_unlite_room_aux(y - 1, x);
2590                 cave_temp_unlite_room_aux(y, x + 1);
2591                 cave_temp_unlite_room_aux(y, x - 1);
2592
2593                 /* Spread diagonal */
2594                 cave_temp_unlite_room_aux(y + 1, x + 1);
2595                 cave_temp_unlite_room_aux(y - 1, x - 1);
2596                 cave_temp_unlite_room_aux(y - 1, x + 1);
2597                 cave_temp_unlite_room_aux(y + 1, x - 1);
2598         }
2599
2600         /* Now, darken them all at once */
2601         cave_temp_room_unlite();
2602 }
2603
2604
2605
2606 /*!
2607  * @brief プレイヤー位置を中心にLITE_WEAK属性を通じた照明処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2608  * @param dam 威力
2609  * @param rad 効果半径
2610  * @return 作用が実際にあった場合TRUEを返す
2611  */
2612 bool lite_area(HIT_POINT dam, POSITION rad)
2613 {
2614         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2615
2616         if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
2617         {
2618                 msg_print(_("ダンジョンが光を吸収した。", "The darkness of this dungeon absorb your light."));
2619                 return FALSE;
2620         }
2621
2622         /* Hack -- Message */
2623         if (!p_ptr->blind)
2624         {
2625                 msg_print(_("白い光が辺りを覆った。", "You are surrounded by a white light."));
2626         }
2627
2628         /* Hook into the "project()" function */
2629         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_LITE_WEAK, flg, -1);
2630
2631         /* Lite up the room */
2632         lite_room(p_ptr->y, p_ptr->x);
2633
2634         /* Assume seen */
2635         return (TRUE);
2636 }
2637
2638
2639 /*!
2640  * @brief プレイヤー位置を中心にLITE_DARK属性を通じた消灯処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2641  * @param dam 威力
2642  * @param rad 効果半径
2643  * @return 作用が実際にあった場合TRUEを返す
2644  */
2645 bool unlite_area(HIT_POINT dam, POSITION rad)
2646 {
2647         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2648
2649         /* Hack -- Message */
2650         if (!p_ptr->blind)
2651         {
2652                 msg_print(_("暗闇が辺りを覆った。", "Darkness surrounds you."));
2653         }
2654
2655         /* Hook into the "project()" function */
2656         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_DARK_WEAK, flg, -1);
2657
2658         /* Lite up the room */
2659         unlite_room(p_ptr->y, p_ptr->x);
2660
2661         /* Assume seen */
2662         return (TRUE);
2663 }
2664
2665
2666
2667 /*!
2668  * @brief ボール系スペルの発動 / Cast a ball spell
2669  * @param typ 効果属性
2670  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2671  * @param dam 威力
2672  * @param rad 半径
2673  * @return 作用が実際にあった場合TRUEを返す
2674  * @details
2675  * <pre>
2676  * Stop if we hit a monster, act as a "ball"
2677  * Allow "target" mode to pass over monsters
2678  * Affect grids, objects, and monsters
2679  * </pre>
2680  */
2681 bool fire_ball(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2682 {
2683         POSITION tx, ty;
2684
2685         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2686
2687         if (typ == GF_CHARM_LIVING) flg|= PROJECT_HIDE;
2688         /* Use the given direction */
2689         tx = p_ptr->x + 99 * ddx[dir];
2690         ty = p_ptr->y + 99 * ddy[dir];
2691
2692         /* Hack -- Use an actual "target" */
2693         if ((dir == 5) && target_okay())
2694         {
2695                 flg &= ~(PROJECT_STOP);
2696                 tx = target_col;
2697                 ty = target_row;
2698         }
2699
2700         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2701         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2702 }
2703
2704 /*!
2705 * @brief ブレス系スペルの発動 / Cast a breath spell
2706 * @param typ 効果属性
2707 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2708 * @param dam 威力
2709 * @param rad 半径
2710 * @return 作用が実際にあった場合TRUEを返す
2711 * @details
2712 * <pre>
2713 * Stop if we hit a monster, act as a "ball"
2714 * Allow "target" mode to pass over monsters
2715 * Affect grids, objects, and monsters
2716 * </pre>
2717 */
2718 bool fire_breath(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2719 {
2720         return fire_ball(typ, dir, dam, -rad);
2721 }
2722
2723
2724 /*!
2725  * @brief ロケット系スペルの発動(詳細な差は確認中) / Cast a ball spell
2726  * @param typ 効果属性
2727  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2728  * @param dam 威力
2729  * @param rad 半径
2730  * @return 作用が実際にあった場合TRUEを返す
2731  * @details
2732  * <pre>
2733  * Stop if we hit a monster, act as a "ball"
2734  * Allow "target" mode to pass over monsters
2735  * Affect grids, objects, and monsters
2736  * </pre>
2737  */
2738 bool fire_rocket(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2739 {
2740         POSITION tx, ty;
2741         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2742
2743         /* Use the given direction */
2744         tx = p_ptr->x + 99 * ddx[dir];
2745         ty = p_ptr->y + 99 * ddy[dir];
2746
2747         /* Hack -- Use an actual "target" */
2748         if ((dir == 5) && target_okay())
2749         {
2750                 tx = target_col;
2751                 ty = target_row;
2752         }
2753
2754         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2755         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2756 }
2757
2758
2759 /*!
2760  * @brief ボール(ハイド)系スペルの発動 / Cast a ball spell
2761  * @param typ 効果属性
2762  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2763  * @param dam 威力
2764  * @param rad 半径
2765  * @return 作用が実際にあった場合TRUEを返す
2766  * @details
2767  * <pre>
2768  * Stop if we hit a monster, act as a "ball"
2769  * Allow "target" mode to pass over monsters
2770  * Affect grids, objects, and monsters
2771  * </pre>
2772  */
2773 bool fire_ball_hide(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2774 {
2775         POSITION tx, ty;
2776         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE;
2777
2778         /* Use the given direction */
2779         tx = p_ptr->x + 99 * ddx[dir];
2780         ty = p_ptr->y + 99 * ddy[dir];
2781
2782         /* Hack -- Use an actual "target" */
2783         if ((dir == 5) && target_okay())
2784         {
2785                 flg &= ~(PROJECT_STOP);
2786                 tx = target_col;
2787                 ty = target_row;
2788         }
2789
2790         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2791         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2792 }
2793
2794
2795 /*!
2796  * @brief メテオ系スペルの発動 / Cast a meteor spell
2797  * @param who スぺル詠唱者のモンスターID(0=プレイヤー)
2798  * @param typ 効果属性
2799  * @param dam 威力
2800  * @param rad 半径
2801  * @param y 中心点Y座標
2802  * @param x 中心点X座標
2803  * @return 作用が実際にあった場合TRUEを返す
2804  * @details
2805  * <pre>
2806  * Cast a meteor spell, defined as a ball spell cast by an arbitary monster, 
2807  * player, or outside source, that starts out at an arbitrary location, and 
2808  * leaving no trail from the "caster" to the target.  This function is 
2809  * especially useful for bombardments and similar. -LM-
2810  * Option to hurt the player.
2811  * </pre>
2812  */
2813 bool fire_meteor(MONSTER_IDX who, EFFECT_ID typ, POSITION y, POSITION x, HIT_POINT dam, POSITION rad)
2814 {
2815         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2816
2817         /* Analyze the "target" and the caster. */
2818         return (project(who, rad, y, x, dam, typ, flg, -1));
2819 }
2820
2821
2822 /*!
2823  * @brief ブラスト系スペルの発動 / Cast a blast spell
2824  * @param typ 効果属性
2825  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2826  * @param dd 威力ダイス数
2827  * @param ds 威力ダイス目
2828  * @param num 基本回数
2829  * @param dev 回数分散
2830  * @return 作用が実際にあった場合TRUEを返す
2831  */
2832 bool fire_blast(EFFECT_ID typ, DIRECTION dir, int dd, int ds, int num, int dev)
2833 {
2834         POSITION ly, lx;
2835         int ld;
2836         POSITION ty, tx, y, x;
2837         int i;
2838
2839         BIT_FLAGS flg = PROJECT_FAST | PROJECT_THRU | PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE | PROJECT_GRID;
2840
2841         /* Assume okay */
2842         bool result = TRUE;
2843
2844         /* Use the given direction */
2845         if (dir != 5)
2846         {
2847                 ly = ty = p_ptr->y + 20 * ddy[dir];
2848                 lx = tx = p_ptr->x + 20 * ddx[dir];
2849         }
2850
2851         /* Use an actual "target" */
2852         else /* if (dir == 5) */
2853         {
2854                 tx = target_col;
2855                 ty = target_row;
2856
2857                 lx = 20 * (tx - p_ptr->x) + p_ptr->x;
2858                 ly = 20 * (ty - p_ptr->y) + p_ptr->y;
2859         }
2860
2861         ld = distance(p_ptr->y, p_ptr->x, ly, lx);
2862
2863         /* Blast */
2864         for (i = 0; i < num; i++)
2865         {
2866                 while (1)
2867                 {
2868                         /* Get targets for some bolts */
2869                         y = rand_spread(ly, ld * dev / 20);
2870                         x = rand_spread(lx, ld * dev / 20);
2871
2872                         if (distance(ly, lx, y, x) <= ld * dev / 20) break;
2873                 }
2874
2875                 /* Analyze the "dir" and the "target". */
2876                 if (!project(0, 0, y, x, damroll(dd, ds), typ, flg, -1))
2877                 {
2878                         result = FALSE;
2879                 }
2880         }
2881
2882         return (result);
2883 }
2884
2885
2886 /*!
2887  * @brief モンスターとの位置交換処理 / Switch position with a monster.
2888  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2889  * @return 作用が実際にあった場合TRUEを返す
2890  */
2891 bool teleport_swap(DIRECTION dir)
2892 {
2893         POSITION tx, ty;
2894         cave_type* c_ptr;
2895         monster_type* m_ptr;
2896         monster_race* r_ptr;
2897
2898         if ((dir == 5) && target_okay())
2899         {
2900                 tx = target_col;
2901                 ty = target_row;
2902         }
2903         else
2904         {
2905                 tx = p_ptr->x + ddx[dir];
2906                 ty = p_ptr->y + ddy[dir];
2907         }
2908         c_ptr = &cave[ty][tx];
2909
2910         if (p_ptr->anti_tele)
2911         {
2912                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
2913                 return FALSE;
2914         }
2915
2916         if (!c_ptr->m_idx || (c_ptr->m_idx == p_ptr->riding))
2917         {
2918                 msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
2919
2920                 /* Failure */
2921                 return FALSE;
2922         }
2923
2924         if ((c_ptr->info & CAVE_ICKY) || (distance(ty, tx, p_ptr->y, p_ptr->x) > p_ptr->lev * 3 / 2 + 10))
2925         {
2926                 msg_print(_("失敗した。", "Failed to swap."));
2927
2928                 /* Failure */
2929                 return FALSE;
2930         }
2931
2932         m_ptr = &m_list[c_ptr->m_idx];
2933         r_ptr = &r_info[m_ptr->r_idx];
2934
2935         (void)set_monster_csleep(c_ptr->m_idx, 0);
2936
2937         if (r_ptr->flagsr & RFR_RES_TELE)
2938         {
2939                 msg_print(_("テレポートを邪魔された!", "Your teleportation is blocked!"));
2940
2941                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2942
2943                 /* Failure */
2944                 return FALSE;
2945         }
2946
2947         sound(SOUND_TELEPORT);
2948
2949         /* Swap the player and monster */
2950         (void)move_player_effect(ty, tx, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
2951
2952         /* Success */
2953         return TRUE;
2954 }
2955
2956
2957 /*!
2958  * @brief 指定方向に飛び道具を飛ばす(フラグ任意指定) / Hack -- apply a "projection()" in a direction (or at the target)
2959  * @param typ 効果属性
2960  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2961  * @param dam 威力
2962  * @param flg フラグ
2963  * @return 作用が実際にあった場合TRUEを返す
2964  */
2965 bool project_hook(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, BIT_FLAGS flg)
2966 {
2967         int tx, ty;
2968
2969         /* Pass through the target if needed */
2970         flg |= (PROJECT_THRU);
2971
2972         /* Use the given direction */
2973         tx = p_ptr->x + ddx[dir];
2974         ty = p_ptr->y + ddy[dir];
2975
2976         /* Hack -- Use an actual "target" */
2977         if ((dir == 5) && target_okay())
2978         {
2979                 tx = target_col;
2980                 ty = target_row;
2981         }
2982
2983         /* Analyze the "dir" and the "target", do NOT explode */
2984         return (project(0, 0, ty, tx, dam, typ, flg, -1));
2985 }
2986
2987
2988 /*!
2989  * @brief ボルト系スペルの発動 / Cast a bolt spell.
2990  * @param typ 効果属性
2991  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2992  * @param dam 威力
2993  * @return 作用が実際にあった場合TRUEを返す
2994  * @details
2995  * <pre>
2996  * Stop if we hit a monster, as a "bolt".
2997  * Affect monsters and grids (not objects).
2998  * </pre>
2999  */
3000 bool fire_bolt(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3001 {
3002         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_GRID;
3003         if (typ != GF_ARROW) flg |= PROJECT_REFLECTABLE;
3004         return (project_hook(typ, dir, dam, flg));
3005 }
3006
3007
3008 /*!
3009  * @brief ビーム系スペルの発動 / Cast a beam spell.
3010  * @param typ 効果属性
3011  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3012  * @param dam 威力
3013  * @return 作用が実際にあった場合TRUEを返す
3014  * @details
3015  * <pre>
3016  * Pass through monsters, as a "beam".
3017  * Affect monsters, grids and objects.
3018  * </pre>
3019  */
3020 bool fire_beam(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3021 {
3022         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM;
3023         return (project_hook(typ, dir, dam, flg));
3024 }
3025
3026
3027 /*!
3028  * @brief 確率に応じたボルト系/ビーム系スペルの発動 / Cast a bolt spell, or rarely, a beam spell.
3029  * @param prob ビーム化する確率(%)
3030  * @param typ 効果属性
3031  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3032  * @param dam 威力
3033  * @return 作用が実際にあった場合TRUEを返す
3034  * @details
3035  * <pre>
3036  * Pass through monsters, as a "beam".
3037  * Affect monsters, grids and objects.
3038  * </pre>
3039  */
3040 bool fire_bolt_or_beam(PERCENTAGE prob, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3041 {
3042         if (randint0(100) < prob)
3043         {
3044                 return (fire_beam(typ, dir, dam));
3045         }
3046         else
3047         {
3048                 return (fire_bolt(typ, dir, dam));
3049         }
3050 }
3051
3052 /*!
3053  * @brief LITE_WEAK属性による光源ビーム処理
3054  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3055  * @param dam 威力
3056  * @return 作用が実際にあった場合TRUEを返す
3057  */
3058 bool lite_line(DIRECTION dir, HIT_POINT dam)
3059 {
3060         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_KILL;
3061         return (project_hook(GF_LITE_WEAK, dir, dam, flg));
3062 }
3063
3064 /*!
3065  * @brief 衰弱ボルト処理
3066  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3067  * @param dam 威力
3068  * @return 作用が実際にあった場合TRUEを返す
3069  */
3070 bool hypodynamic_bolt(DIRECTION dir, HIT_POINT dam)
3071 {
3072         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3073         return (project_hook(GF_HYPODYNAMIA, dir, dam, flg));
3074 }
3075
3076 /*!
3077  * @brief 岩石溶解処理
3078  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3079  * @param dam 威力
3080  * @return 作用が実際にあった場合TRUEを返す
3081  */
3082 bool wall_to_mud(DIRECTION dir, HIT_POINT dam)
3083 {
3084         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3085         return (project_hook(GF_KILL_WALL, dir, dam, flg));
3086 }
3087
3088 /*!
3089  * @brief 魔法の施錠処理
3090  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3091  * @return 作用が実際にあった場合TRUEを返す
3092  */
3093 bool wizard_lock(DIRECTION dir)
3094 {
3095         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3096         return (project_hook(GF_JAM_DOOR, dir, 20 + randint1(30), flg));
3097 }
3098
3099 /*!
3100  * @brief ドア破壊処理
3101  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3102  * @return 作用が実際にあった場合TRUEを返す
3103  */
3104 bool destroy_door(DIRECTION dir)
3105 {
3106         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3107         return (project_hook(GF_KILL_DOOR, dir, 0, flg));
3108 }
3109
3110 /*!
3111  * @brief トラップ解除処理
3112  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3113  * @return 作用が実際にあった場合TRUEを返す
3114  */
3115 bool disarm_trap(DIRECTION dir)
3116 {
3117         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3118         return (project_hook(GF_KILL_TRAP, dir, 0, flg));
3119 }
3120
3121 /*!
3122  * @brief モンスター回復処理
3123  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3124  * @param dam 威力
3125  * @return 作用が実際にあった場合TRUEを返す
3126  */
3127 bool heal_monster(DIRECTION dir, HIT_POINT dam)
3128 {
3129         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3130         return (project_hook(GF_OLD_HEAL, dir, dam, flg));
3131 }
3132
3133 /*!
3134  * @brief モンスター加速処理
3135  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3136  * @param power 効力
3137  * @return 作用が実際にあった場合TRUEを返す
3138  */
3139 bool speed_monster(DIRECTION dir, int power)
3140 {
3141         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3142         return (project_hook(GF_OLD_SPEED, dir, power, flg));
3143 }
3144
3145 /*!
3146  * @brief モンスター減速処理
3147  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3148  * @param power 効力
3149  * @return 作用が実際にあった場合TRUEを返す
3150  */
3151 bool slow_monster(DIRECTION dir, int power)
3152 {
3153         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3154         return (project_hook(GF_OLD_SLOW, dir, power, flg));
3155 }
3156
3157 /*!
3158  * @brief モンスター催眠処理
3159  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3160  * @param power 効力
3161  * @return 作用が実際にあった場合TRUEを返す
3162  */
3163 bool sleep_monster(DIRECTION dir, int power)
3164 {
3165         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3166         return (project_hook(GF_OLD_SLEEP, dir, power, flg));
3167 }
3168
3169 /*!
3170  * @brief モンスター拘束(STASIS)処理
3171  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3172  * @return 作用が実際にあった場合TRUEを返す
3173  * @details 威力はプレイヤーレベル*2に固定
3174  */
3175 bool stasis_monster(DIRECTION dir)
3176 {
3177         return (fire_ball_hide(GF_STASIS, dir, p_ptr->lev*2, 0));
3178 }
3179
3180 /*!
3181  * @brief 邪悪なモンスター拘束(STASIS)処理
3182  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3183  * @return 作用が実際にあった場合TRUEを返す
3184  * @details 威力はプレイヤーレベル*2に固定
3185  */
3186 bool stasis_evil(DIRECTION dir)
3187 {
3188         return (fire_ball_hide(GF_STASIS_EVIL, dir, p_ptr->lev*2, 0));
3189 }
3190
3191 /*!
3192  * @brief モンスター混乱処理
3193  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3194  * @param plev プレイヤーレベル(=効力)
3195  * @return 作用が実際にあった場合TRUEを返す
3196  */
3197 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
3198 {
3199         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3200         return (project_hook(GF_OLD_CONF, dir, plev, flg));
3201 }
3202
3203 /*!
3204  * @brief モンスター朦朧処理
3205  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3206  * @param plev プレイヤーレベル(=効力)
3207  * @return 作用が実際にあった場合TRUEを返す
3208  */
3209 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
3210 {
3211         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3212         return (project_hook(GF_STUN, dir, plev, flg));
3213 }
3214
3215 /*!
3216  * @brief チェンジモンスター処理
3217  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3218  * @param power 効力
3219  * @return 作用が実際にあった場合TRUEを返す
3220  */
3221 bool poly_monster(DIRECTION dir, int power)
3222 {
3223         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3224         bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
3225         if (tester)
3226                 chg_virtue(V_CHANCE, 1);
3227         return(tester);
3228 }
3229
3230 /*!
3231  * @brief クローンモンスター処理
3232  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3233  * @return 作用が実際にあった場合TRUEを返す
3234  */
3235 bool clone_monster(DIRECTION dir)
3236 {
3237         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3238         return (project_hook(GF_OLD_CLONE, dir, 0, flg));
3239 }
3240
3241 /*!
3242  * @brief モンスター恐慌処理
3243  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3244  * @param plev プレイヤーレベル(=効力)
3245  * @return 作用が実際にあった場合TRUEを返す
3246  */
3247 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
3248 {
3249         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3250         return (project_hook(GF_TURN_ALL, dir, plev, flg));
3251 }
3252
3253 /*!
3254  * @brief 死の光線処理
3255  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3256  * @param plev プレイヤーレベル(効力はplev*200)
3257  * @return 作用が実際にあった場合TRUEを返す
3258  */
3259 bool death_ray(DIRECTION dir, PLAYER_LEVEL plev)
3260 {
3261         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3262         return (project_hook(GF_DEATH_RAY, dir, plev * 200, flg));
3263 }
3264
3265 /*!
3266  * @brief モンスター用テレポート処理
3267  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3268  * @param distance 移動距離
3269  * @return 作用が実際にあった場合TRUEを返す
3270  */
3271 bool teleport_monster(DIRECTION dir, int distance)
3272 {
3273         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL;
3274         return (project_hook(GF_AWAY_ALL, dir, distance, flg));
3275 }
3276
3277 /*!
3278  * @brief ドア生成処理(プレイヤー中心に周囲1マス) / Hooks -- affect adjacent grids (radius 1 ball attack)
3279  * @return 作用が実際にあった場合TRUEを返す
3280  */
3281 bool door_creation(void)
3282 {
3283         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3284         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_DOOR, flg, -1));
3285 }
3286
3287 /*!
3288  * @brief トラップ生成処理(起点から周囲1マス)
3289  * @param y 起点Y座標
3290  * @param x 起点X座標
3291  * @return 作用が実際にあった場合TRUEを返す
3292  */
3293 bool trap_creation(POSITION y, POSITION x)
3294 {
3295         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3296         return (project(0, 1, y, x, 0, GF_MAKE_TRAP, flg, -1));
3297 }
3298
3299 /*!
3300  * @brief 森林生成処理(プレイヤー中心に周囲1マス)
3301  * @return 作用が実際にあった場合TRUEを返す
3302  */
3303 bool tree_creation(void)
3304 {
3305         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3306         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_TREE, flg, -1));
3307 }
3308
3309 /*!
3310  * @brief 魔法のルーン生成処理(プレイヤー中心に周囲1マス)
3311  * @return 作用が実際にあった場合TRUEを返す
3312  */
3313 bool glyph_creation(void)
3314 {
3315         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM;
3316         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_GLYPH, flg, -1));
3317 }
3318
3319 /*!
3320  * @brief 壁生成処理(プレイヤー中心に周囲1マス)
3321  * @return 作用が実際にあった場合TRUEを返す
3322  */
3323 bool wall_stone(void)
3324 {
3325         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3326
3327         bool dummy = (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_STONE_WALL, flg, -1));
3328
3329         p_ptr->update |= (PU_FLOW);
3330
3331         p_ptr->redraw |= (PR_MAP);
3332
3333         return dummy;
3334 }
3335
3336 /*!
3337  * @brief ドア破壊処理(プレイヤー中心に周囲1マス)
3338  * @return 作用が実際にあった場合TRUEを返す
3339  */
3340 bool destroy_doors_touch(void)
3341 {
3342         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3343         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_DOOR, flg, -1));
3344 }
3345
3346 /*!
3347  * @brief トラップ解除処理(プレイヤー中心に周囲1マス)
3348  * @return 作用が実際にあった場合TRUEを返す
3349  */
3350 bool disarm_traps_touch(void)
3351 {
3352         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3353         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_TRAP, flg, -1));
3354 }
3355
3356 /*!
3357  * @brief スリープモンスター処理(プレイヤー中心に周囲1マス)
3358  * @return 作用が実際にあった場合TRUEを返す
3359  */
3360 bool sleep_monsters_touch(void)
3361 {
3362         BIT_FLAGS flg = PROJECT_KILL | PROJECT_HIDE;
3363         return (project(0, 1, p_ptr->y, p_ptr->x, p_ptr->lev, GF_OLD_SLEEP, flg, -1));
3364 }
3365
3366
3367 /*!
3368  * @brief 死者復活処理(起点より周囲5マス)
3369  * @param who 術者モンスターID(0ならばプレイヤー)
3370  * @param y 起点Y座標
3371  * @param x 起点X座標
3372  * @return 作用が実際にあった場合TRUEを返す
3373  */
3374 bool animate_dead(MONSTER_IDX who, POSITION y, POSITION x)
3375 {
3376         BIT_FLAGS flg = PROJECT_ITEM | PROJECT_HIDE;
3377         return (project(who, 5, y, x, 0, GF_ANIM_DEAD, flg, -1));
3378 }
3379
3380 /*!
3381  * @brief 混沌招来処理
3382  * @return 作用が実際にあった場合TRUEを返す
3383  */
3384 void call_chaos(void)
3385 {
3386         int Chaos_type, dummy, dir;
3387         PLAYER_LEVEL plev = p_ptr->lev;
3388         bool line_chaos = FALSE;
3389
3390         int hurt_types[31] =
3391         {
3392                 GF_ELEC,      GF_POIS,    GF_ACID,    GF_COLD,
3393                 GF_FIRE,      GF_MISSILE, GF_ARROW,   GF_PLASMA,
3394                 GF_HOLY_FIRE, GF_WATER,   GF_LITE,    GF_DARK,
3395                 GF_FORCE,     GF_INERTIAL, GF_MANA,    GF_METEOR,
3396                 GF_ICE,       GF_CHAOS,   GF_NETHER,  GF_DISENCHANT,
3397                 GF_SHARDS,    GF_SOUND,   GF_NEXUS,   GF_CONFUSION,
3398                 GF_TIME,      GF_GRAVITY, GF_ROCKET,  GF_NUKE,
3399                 GF_HELL_FIRE, GF_DISINTEGRATE, GF_PSY_SPEAR
3400         };
3401
3402         Chaos_type = hurt_types[randint0(31)];
3403         if (one_in_(4)) line_chaos = TRUE;
3404
3405         if (one_in_(6))
3406         {
3407                 for (dummy = 1; dummy < 10; dummy++)
3408                 {
3409                         if (dummy - 5)
3410                         {
3411                                 if (line_chaos)
3412                                         fire_beam(Chaos_type, dummy, 150);
3413                                 else
3414                                         fire_ball(Chaos_type, dummy, 150, 2);
3415                         }
3416                 }
3417         }
3418         else if (one_in_(3))
3419         {
3420                 fire_ball(Chaos_type, 0, 500, 8);
3421         }
3422         else
3423         {
3424                 if (!get_aim_dir(&dir)) return;
3425                 if (line_chaos)
3426                         fire_beam(Chaos_type, dir, 250);
3427                 else
3428                         fire_ball(Chaos_type, dir, 250, 3 + (plev / 35));
3429         }
3430 }
3431
3432 /*!
3433  * @brief TY_CURSE処理発動 / Activate the evil Topi Ylinen curse
3434  * @param stop_ty 再帰処理停止フラグ
3435  * @param count 発動回数
3436  * @return 作用が実際にあった場合TRUEを返す
3437  * @details
3438  * <pre>
3439  * rr9: Stop the nasty things when a Cyberdemon is summoned
3440  * or the player gets paralyzed.
3441  * </pre>
3442  */
3443 bool activate_ty_curse(bool stop_ty, int *count)
3444 {
3445         int     i = 0;
3446
3447         BIT_FLAGS flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3448
3449         do
3450         {
3451                 switch (randint1(34))
3452                 {
3453                 case 28: case 29:
3454                         if (!(*count))
3455                         {
3456                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
3457                                 earthquake(p_ptr->y, p_ptr->x, 5 + randint0(10));
3458                                 if (!one_in_(6)) break;
3459                         }
3460                 case 30: case 31:
3461                         if (!(*count))
3462                         {
3463                                 HIT_POINT dam = damroll(10, 10);
3464                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3465                                 project(0, 8, p_ptr->y, p_ptr->x, dam, GF_MANA, flg, -1);
3466                                 take_hit(DAMAGE_NOESCAPE, dam, _("純粋な魔力の解放", "released pure mana"), -1);
3467                                 if (!one_in_(6)) break;
3468                         }
3469                 case 32: case 33:
3470                         if (!(*count))
3471                         {
3472                                 msg_print(_("周囲の空間が歪んだ!", "Space warps about you!"));
3473                                 teleport_player(damroll(10, 10), TELEPORT_PASSIVE);
3474                                 if (randint0(13)) (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3475                                 if (!one_in_(6)) break;
3476                         }
3477                 case 34:
3478                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3479                         wall_breaker();
3480                         if (!randint0(7))
3481                         {
3482                                 project(0, 7, p_ptr->y, p_ptr->x, 50, GF_KILL_WALL, flg, -1);
3483                                 take_hit(DAMAGE_NOESCAPE, 50, _("エネルギーのうねり", "surge of energy"), -1);
3484                         }
3485                         if (!one_in_(6)) break;
3486                 case 1: case 2: case 3: case 16: case 17:
3487                         aggravate_monsters(0);
3488                         if (!one_in_(6)) break;
3489                 case 4: case 5: case 6:
3490                         (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3491                         if (!one_in_(6)) break;
3492                 case 7: case 8: case 9: case 18:
3493                         (*count) += summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
3494                         if (!one_in_(6)) break;
3495                 case 10: case 11: case 12:
3496                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3497                         lose_exp(p_ptr->exp / 16);
3498                         if (!one_in_(6)) break;
3499                 case 13: case 14: case 15: case 19: case 20:
3500                         if (stop_ty || (p_ptr->free_act && (randint1(125) < p_ptr->skill_sav)) || (p_ptr->pclass == CLASS_BERSERKER))
3501                         {
3502                                 /* Do nothing */ ;
3503                         }
3504                         else
3505                         {
3506                                 msg_print(_("彫像になった気分だ!", "You feel like a statue!"));
3507                                 if (p_ptr->free_act)
3508                                         set_paralyzed(p_ptr->paralyzed + randint1(3));
3509                                 else
3510                                         set_paralyzed(p_ptr->paralyzed + randint1(13));
3511                                 stop_ty = TRUE;
3512                         }
3513                         if (!one_in_(6)) break;
3514                 case 21: case 22: case 23:
3515                         (void)do_dec_stat(randint0(6));
3516                         if (!one_in_(6)) break;
3517                 case 24:
3518                         msg_print(_("ほえ?私は誰?ここで何してる?", "Huh? Who am I? What am I doing here?"));
3519                         lose_all_info();
3520                         if (!one_in_(6)) break;
3521                 case 25:
3522                         /*
3523                          * Only summon Cyberdemons deep in the dungeon.
3524                          */
3525                         if ((dun_level > 65) && !stop_ty)
3526                         {
3527                                 (*count) += summon_cyber(-1, p_ptr->y, p_ptr->x);
3528                                 stop_ty = TRUE;
3529                                 break;
3530                         }
3531                         if (!one_in_(6)) break;
3532                 default:
3533                         while (i < 6)
3534                         {
3535                                 do
3536                                 {
3537                                         (void)do_dec_stat(i);
3538                                 }
3539                                 while (one_in_(2));
3540
3541                                 i++;
3542                         }
3543                 }
3544         }
3545         while (one_in_(3) && !stop_ty);
3546
3547         return stop_ty;
3548 }
3549
3550 /*!
3551  * @brief HI_SUMMON(上級召喚)処理発動
3552  * @param y 召喚位置Y座標
3553  * @param x 召喚位置X座標
3554  * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする
3555  * @return 作用が実際にあった場合TRUEを返す
3556  */
3557 int activate_hi_summon(POSITION y, POSITION x, bool can_pet)
3558 {
3559         int i;
3560         int count = 0;
3561         DEPTH summon_lev;
3562         BIT_FLAGS mode = PM_ALLOW_GROUP;
3563         bool pet = FALSE;
3564
3565         if (can_pet)
3566         {
3567                 if (one_in_(4))
3568                 {
3569                         mode |= PM_FORCE_FRIENDLY;
3570                 }
3571                 else
3572                 {
3573                         mode |= PM_FORCE_PET;
3574                         pet = TRUE;
3575                 }
3576         }
3577
3578         if (!pet) mode |= PM_NO_PET;
3579
3580         summon_lev = (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : dun_level);
3581
3582         for (i = 0; i < (randint1(7) + (dun_level / 40)); i++)
3583         {
3584                 switch (randint1(25) + (dun_level / 20))
3585                 {
3586                         case 1: case 2:
3587                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode);
3588                                 break;
3589                         case 3: case 4:
3590                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode);
3591                                 break;
3592                         case 5: case 6:
3593                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode);
3594                                 break;
3595                         case 7: case 8:
3596                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode);
3597                                 break;
3598                         case 9: case 10:
3599                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode);
3600                                 break;
3601                         case 11: case 12:
3602                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode);
3603                                 break;
3604                         case 13: case 14:
3605                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode);
3606                                 break;
3607                         case 15: case 16:
3608                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode);
3609                                 break;
3610                         case 17:
3611                                 if (can_pet) break;
3612                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
3613                                 break;
3614                         case 18: case 19:
3615                                 if (can_pet) break;
3616                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE));
3617                                 break;
3618                         case 20: case 21:
3619                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3620                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode);
3621                                 break;
3622                         case 22: case 23:
3623                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3624                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode);
3625                                 break;
3626                         case 24:
3627                                 count += summon_specific((pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode);
3628                                 break;
3629                         default:
3630                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3631                                 count += summon_specific((pet ? -1 : 0), y, x,pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode);
3632                 }
3633         }
3634
3635         return count;
3636 }
3637
3638
3639 /*!
3640  * @brief サイバーデーモンの召喚
3641  * @param who 召喚主のモンスターID(0ならばプレイヤー)
3642  * @param y 召喚位置Y座標
3643  * @param x 召喚位置X座標
3644  * @return 作用が実際にあった場合TRUEを返す
3645  */
3646 int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
3647 {
3648         int i;
3649         int max_cyber = (easy_band ? 1 : (dun_level / 50) + randint1(2));
3650         int count = 0;
3651         BIT_FLAGS mode = PM_ALLOW_GROUP;
3652
3653         /* Summoned by a monster */
3654         if (who > 0)
3655         {
3656                 monster_type *m_ptr = &m_list[who];
3657                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3658         }
3659
3660         if (max_cyber > 4) max_cyber = 4;
3661
3662         for (i = 0; i < max_cyber; i++)
3663         {
3664                 count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode);
3665         }
3666
3667         return count;
3668 }
3669
3670 /*!
3671  * @brief 周辺破壊効果(プレイヤー中心)
3672  * @return 作用が実際にあった場合TRUEを返す
3673  */
3674 void wall_breaker(void)
3675 {
3676         int i;
3677         POSITION y = 0, x = 0;
3678         int attempts = 1000;
3679
3680         if (randint1(80 + p_ptr->lev) < 70)
3681         {
3682                 while (attempts--)
3683                 {
3684                         scatter(&y, &x, p_ptr->y, p_ptr->x, 4, 0);
3685
3686                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
3687
3688                         if (!player_bold(y, x)) break;
3689                 }
3690
3691                 project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3692                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3693         }
3694         else if (randint1(100) > 30)
3695         {
3696                 earthquake(p_ptr->y, p_ptr->x, 1);
3697         }
3698         else
3699         {
3700                 int num = damroll(5, 3);
3701
3702                 for (i = 0; i < num; i++)
3703                 {
3704                         while (1)
3705                         {
3706                                 scatter(&y, &x, p_ptr->y, p_ptr->x, 10, 0);
3707
3708                                 if (!player_bold(y, x)) break;
3709                         }
3710
3711                         project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3712                                           (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3713                 }
3714         }
3715 }
3716
3717
3718 /*!
3719  * @brief パニック・モンスター効果(プレイヤー視界範囲内) / Confuse monsters
3720  * @param dam 効力
3721  * @return 作用が実際にあった場合TRUEを返す
3722  */
3723 bool confuse_monsters(HIT_POINT dam)
3724 {
3725         return (project_hack(GF_OLD_CONF, dam));
3726 }
3727
3728
3729 /*!
3730  * @brief チャーム・モンスター効果(プレイヤー視界範囲内) / Charm monsters
3731  * @param dam 効力
3732  * @return 作用が実際にあった場合TRUEを返す
3733  */
3734 bool charm_monsters(HIT_POINT dam)
3735 {
3736         return (project_hack(GF_CHARM, dam));
3737 }
3738
3739
3740 /*!
3741  * @brief 動物魅了効果(プレイヤー視界範囲内) / Charm Animals
3742  * @param dam 効力
3743  * @return 作用が実際にあった場合TRUEを返す
3744  */
3745 bool charm_animals(HIT_POINT dam)
3746 {
3747         return (project_hack(GF_CONTROL_ANIMAL, dam));
3748 }
3749
3750
3751 /*!
3752  * @brief モンスター朦朧効果(プレイヤー視界範囲内) / Stun monsters
3753  * @param dam 効力
3754  * @return 作用が実際にあった場合TRUEを返す
3755  */
3756 bool stun_monsters(HIT_POINT dam)
3757 {
3758         return (project_hack(GF_STUN, dam));
3759 }
3760
3761
3762 /*!
3763  * @brief モンスター停止効果(プレイヤー視界範囲内) / Stasis monsters
3764  * @param dam 効力
3765  * @return 作用が実際にあった場合TRUEを返す
3766  */
3767 bool stasis_monsters(HIT_POINT dam)
3768 {
3769         return (project_hack(GF_STASIS, dam));
3770 }
3771
3772
3773 /*!
3774  * @brief モンスター精神攻撃効果(プレイヤー視界範囲内) / Mindblast monsters
3775  * @param dam 効力
3776  * @return 作用が実際にあった場合TRUEを返す
3777  */
3778 bool mindblast_monsters(HIT_POINT dam)
3779 {
3780         return (project_hack(GF_PSI, dam));
3781 }
3782
3783
3784 /*!
3785  * @brief モンスター追放効果(プレイヤー視界範囲内) / Banish all monsters
3786  * @param dist 効力(距離)
3787  * @return 作用が実際にあった場合TRUEを返す
3788  */
3789 bool banish_monsters(int dist)
3790 {
3791         return (project_hack(GF_AWAY_ALL, dist));
3792 }
3793
3794
3795 /*!
3796  * @brief 邪悪退散効果(プレイヤー視界範囲内) / Turn evil
3797  * @param dam 効力
3798  * @return 作用が実際にあった場合TRUEを返す
3799  */
3800 bool turn_evil(HIT_POINT dam)
3801 {
3802         return (project_hack(GF_TURN_EVIL, dam));
3803 }
3804
3805
3806 /*!
3807  * @brief 全モンスター退散効果(プレイヤー視界範囲内) / Turn everyone
3808  * @param dam 効力
3809  * @return 作用が実際にあった場合TRUEを返す
3810  */
3811 bool turn_monsters(HIT_POINT dam)
3812 {
3813         return (project_hack(GF_TURN_ALL, dam));
3814 }
3815
3816
3817 /*!
3818  * @brief 死の光線(プレイヤー視界範囲内) / Death-ray all monsters (note: OBSCENELY powerful)
3819  * @return 作用が実際にあった場合TRUEを返す
3820  */
3821 bool deathray_monsters(void)
3822 {
3823         return (project_hack(GF_DEATH_RAY, p_ptr->lev * 200));
3824 }
3825
3826 /*!
3827  * @brief チャーム・モンスター(1体)
3828  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3829  * @param plev パワー
3830  * @return 作用が実際にあった場合TRUEを返す
3831  */
3832 bool charm_monster(DIRECTION dir, PLAYER_LEVEL plev)
3833 {
3834         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3835         return (project_hook(GF_CHARM, dir, plev, flg));
3836 }
3837
3838 /*!
3839  * @brief アンデッド支配(1体)
3840  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3841  * @param plev パワー
3842  * @return 作用が実際にあった場合TRUEを返す
3843  */
3844 bool control_one_undead(DIRECTION dir, PLAYER_LEVEL plev)
3845 {
3846         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3847         return (project_hook(GF_CONTROL_UNDEAD, dir, plev, flg));
3848 }
3849
3850 /*!
3851  * @brief 悪魔支配(1体)
3852  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3853  * @param plev パワー
3854  * @return 作用が実際にあった場合TRUEを返す
3855  */
3856 bool control_one_demon(DIRECTION dir, PLAYER_LEVEL plev)
3857 {
3858         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3859         return (project_hook(GF_CONTROL_DEMON, dir, plev, flg));
3860 }
3861
3862 /*!
3863  * @brief 動物支配(1体)
3864  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3865  * @param plev パワー
3866  * @return 作用が実際にあった場合TRUEを返す
3867  */
3868 bool charm_animal(DIRECTION dir, PLAYER_LEVEL plev)
3869 {
3870         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3871         return (project_hook(GF_CONTROL_ANIMAL, dir, plev, flg));
3872 }
3873
3874
3875 /*!
3876  * @brief 変わり身処理
3877  * @param success 判定成功上の処理ならばTRUE
3878  * @return 作用が実際にあった場合TRUEを返す
3879  */
3880 bool kawarimi(bool success)
3881 {
3882         object_type forge;
3883         object_type *q_ptr = &forge;
3884         POSITION y, x;
3885
3886         if (p_ptr->is_dead) return FALSE;
3887         if (p_ptr->confused || p_ptr->blind || p_ptr->paralyzed || p_ptr->image) return FALSE;
3888         if (randint0(200) < p_ptr->stun) return FALSE;
3889
3890         if (!success && one_in_(3))
3891         {
3892                 msg_print(_("失敗!逃げられなかった。", "Failed! You couldn't run away."));
3893                 p_ptr->special_defense &= ~(NINJA_KAWARIMI);
3894                 p_ptr->redraw |= (PR_STATUS);
3895                 return FALSE;
3896         }
3897
3898         y = p_ptr->y;
3899         x = p_ptr->x;
3900
3901         teleport_player(10 + randint1(90), 0L);
3902
3903         object_wipe(q_ptr);
3904
3905         object_prep(q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE));
3906
3907         q_ptr->pval = MON_NINJA;
3908
3909         /* Drop it in the dungeon */
3910         (void)drop_near(q_ptr, -1, y, x);
3911
3912 #ifdef JP
3913         if (success) msg_print("攻撃を受ける前に素早く身をひるがえした。");
3914         else msg_print("失敗!攻撃を受けてしまった。");
3915 #else
3916         if (success) msg_print("You have turned around just before the attack hit you.");
3917         else msg_print("Failed! You are hit by the attack.");
3918 #endif
3919
3920         p_ptr->special_defense &= ~(NINJA_KAWARIMI);
3921         p_ptr->redraw |= (PR_STATUS);
3922
3923         /* Teleported */
3924         return TRUE;
3925 }
3926
3927
3928 /*!
3929  * @brief 入身処理 / "Rush Attack" routine for Samurai or Ninja
3930  * @param mdeath 目標モンスターが死亡したかを返す
3931  * @return 作用が実際にあった場合TRUEを返す /  Return value is for checking "done"
3932  */
3933 bool rush_attack(bool *mdeath)
3934 {
3935         DIRECTION dir;
3936         int tx, ty;
3937         int tm_idx = 0;
3938         u16b path_g[32];
3939         int path_n, i;
3940         bool tmp_mdeath = FALSE;
3941         bool moved = FALSE;
3942
3943         if (mdeath) *mdeath = FALSE;
3944
3945         project_length = 5;
3946         if (!get_aim_dir(&dir)) return FALSE;
3947
3948         /* Use the given direction */
3949         tx = p_ptr->x + project_length * ddx[dir];
3950         ty = p_ptr->y + project_length * ddy[dir];
3951
3952         /* Hack -- Use an actual "target" */
3953         if ((dir == 5) && target_okay())
3954         {
3955                 tx = target_col;
3956                 ty = target_row;
3957         }
3958
3959         if (in_bounds(ty, tx)) tm_idx = cave[ty][tx].m_idx;
3960
3961         path_n = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_STOP | PROJECT_KILL);
3962         project_length = 0;
3963
3964         /* No need to move */
3965         if (!path_n) return TRUE;
3966
3967         /* Use ty and tx as to-move point */
3968         ty = p_ptr->y;
3969         tx = p_ptr->x;
3970
3971         /* Project along the path */
3972         for (i = 0; i < path_n; i++)
3973         {
3974                 monster_type *m_ptr;
3975
3976                 int ny = GRID_Y(path_g[i]);
3977                 int nx = GRID_X(path_g[i]);
3978
3979                 if (cave_empty_bold(ny, nx) && player_can_enter(cave[ny][nx].feat, 0))
3980                 {
3981                         ty = ny;
3982                         tx = nx;
3983
3984                         /* Go to next grid */
3985                         continue;
3986                 }
3987
3988                 if (!cave[ny][nx].m_idx)
3989                 {
3990                         if (tm_idx)
3991                         {
3992                                 msg_print(_("失敗!", "Failed!"));
3993                         }
3994                         else
3995                         {
3996                                 msg_print(_("ここには入身では入れない。", "You can't move to that place."));
3997                         }
3998
3999                         /* Exit loop */
4000                         break;
4001                 }
4002
4003                 /* Move player before updating the monster */
4004                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4005                 update_monster(cave[ny][nx].m_idx, TRUE);
4006
4007                 /* Found a monster */
4008                 m_ptr = &m_list[cave[ny][nx].m_idx];
4009
4010                 if (tm_idx != cave[ny][nx].m_idx)
4011                 {
4012 #ifdef JP
4013                         msg_format("%s%sが立ちふさがっている!", tm_idx ? "別の" : "",
4014                                    m_ptr->ml ? "モンスター" : "何か");
4015 #else
4016                         msg_format("There is %s in the way!", m_ptr->ml ? (tm_idx ? "another monster" : "a monster") : "someone");
4017 #endif
4018                 }
4019                 else if (!player_bold(ty, tx))
4020                 {
4021                         /* Hold the monster name */
4022                         char m_name[80];
4023
4024                         /* Get the monster name (BEFORE polymorphing) */
4025                         monster_desc(m_name, m_ptr, 0);
4026                         msg_format(_("素早く%sの懐に入り込んだ!", "You quickly jump in and attack %s!"), m_name);
4027                 }
4028
4029                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4030                 moved = TRUE;
4031                 tmp_mdeath = py_attack(ny, nx, HISSATSU_NYUSIN);
4032
4033                 break;
4034         }
4035
4036         if (!moved && !player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4037
4038         if (mdeath) *mdeath = tmp_mdeath;
4039         return TRUE;
4040 }
4041
4042
4043 /*!
4044  * @brief 全鏡の消去 / Remove all mirrors in this floor
4045  * @param explode 爆発処理を伴うならばTRUE
4046  * @return なし
4047  */
4048 void remove_all_mirrors(bool explode)
4049 {
4050         POSITION x, y;
4051
4052         for (x = 0; x < cur_wid; x++)
4053         {
4054                 for (y = 0; y < cur_hgt; y++)
4055                 {
4056                         if (is_mirror_grid(&cave[y][x]))
4057                         {
4058                                 remove_mirror(y, x);
4059                                 if (explode)
4060                                         project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS,
4061                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
4062                         }
4063                 }
4064         }
4065 }
4066
4067 /*!
4068  * @brief 『一つの指輪』の効果処理 /
4069  * Hack -- activate the ring of power
4070  * @param dir 発動の方向ID
4071  * @return なし
4072  */
4073 void ring_of_power(DIRECTION dir)
4074 {
4075         /* Pick a random effect */
4076         switch (randint1(10))
4077         {
4078         case 1:
4079         case 2:
4080         {
4081                 msg_print(_("あなたは悪性のオーラに包み込まれた。", "You are surrounded by a malignant aura."));
4082                 sound(SOUND_EVIL);
4083
4084                 /* Decrease all stats (permanently) */
4085                 (void)dec_stat(A_STR, 50, TRUE);
4086                 (void)dec_stat(A_INT, 50, TRUE);
4087                 (void)dec_stat(A_WIS, 50, TRUE);
4088                 (void)dec_stat(A_DEX, 50, TRUE);
4089                 (void)dec_stat(A_CON, 50, TRUE);
4090                 (void)dec_stat(A_CHR, 50, TRUE);
4091
4092                 /* Lose some experience (permanently) */
4093                 p_ptr->exp -= (p_ptr->exp / 4);
4094                 p_ptr->max_exp -= (p_ptr->exp / 4);
4095                 check_experience();
4096
4097                 break;
4098         }
4099
4100         case 3:
4101         {
4102                 msg_print(_("あなたは強力なオーラに包み込まれた。", "You are surrounded by a powerful aura."));
4103
4104                 /* Dispel monsters */
4105                 dispel_monsters(1000);
4106
4107                 break;
4108         }
4109
4110         case 4:
4111         case 5:
4112         case 6:
4113         {
4114                 /* Mana Ball */
4115                 fire_ball(GF_MANA, dir, 600, 3);
4116
4117                 break;
4118         }
4119
4120         case 7:
4121         case 8:
4122         case 9:
4123         case 10:
4124         {
4125                 /* Mana Bolt */
4126                 fire_bolt(GF_MANA, dir, 500);
4127
4128                 break;
4129         }
4130         }
4131 }
4132
4133 /*!
4134 * @brief 運命の輪、並びにカオス的な効果の発動
4135 * @param spell ランダムな効果を選択するための基準ID
4136 * @return なし
4137 */
4138 void wild_magic(int spell)
4139 {
4140         int counter = 0;
4141         int type = SUMMON_MOLD + randint0(6);
4142
4143         if (type < SUMMON_MOLD) type = SUMMON_MOLD;
4144         else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
4145
4146         switch (randint1(spell) + randint1(8) + 1)
4147         {
4148         case 1:
4149         case 2:
4150         case 3:
4151                 teleport_player(10, TELEPORT_PASSIVE);
4152                 break;
4153         case 4:
4154         case 5:
4155         case 6:
4156                 teleport_player(100, TELEPORT_PASSIVE);
4157                 break;
4158         case 7:
4159         case 8:
4160                 teleport_player(200, TELEPORT_PASSIVE);
4161                 break;
4162         case 9:
4163         case 10:
4164         case 11:
4165                 unlite_area(10, 3);
4166                 break;
4167         case 12:
4168         case 13:
4169         case 14:
4170                 lite_area(damroll(2, 3), 2);
4171                 break;
4172         case 15:
4173                 destroy_doors_touch();
4174                 break;
4175         case 16: case 17:
4176                 wall_breaker();
4177         case 18:
4178                 sleep_monsters_touch();
4179                 break;
4180         case 19:
4181         case 20:
4182                 trap_creation(p_ptr->y, p_ptr->x);
4183                 break;
4184         case 21:
4185         case 22:
4186                 door_creation();
4187                 break;
4188         case 23:
4189         case 24:
4190         case 25:
4191                 aggravate_monsters(0);
4192                 break;
4193         case 26:
4194                 earthquake(p_ptr->y, p_ptr->x, 5);
4195                 break;
4196         case 27:
4197         case 28:
4198                 (void)gain_random_mutation(0);
4199                 break;
4200         case 29:
4201         case 30:
4202                 apply_disenchant(1);
4203                 break;
4204         case 31:
4205                 lose_all_info();
4206                 break;
4207         case 32:
4208                 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
4209                 break;
4210         case 33:
4211                 wall_stone();
4212                 break;
4213         case 34:
4214         case 35:
4215                 while (counter++ < 8)
4216                 {
4217                         (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
4218                 }
4219                 break;
4220         case 36:
4221         case 37:
4222                 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4223                 break;
4224         case 38:
4225                 (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
4226                 break;
4227         default:
4228         {
4229                 int count = 0;
4230                 (void)activate_ty_curse(FALSE, &count);
4231                 break;
4232         }
4233         }
4234
4235         return;
4236 }
4237
4238 /*!
4239 * @brief カオス魔法「流星群」の処理としてプレイヤーを中心に隕石落下処理を10+1d10回繰り返す。
4240 * / Drop 10+1d10 meteor ball at random places near the player
4241 * @param dam ダメージ
4242 * @param rad 効力の半径
4243 * @return なし
4244 */
4245 void cast_meteor(HIT_POINT dam, POSITION rad)
4246 {
4247         int i;
4248         int b = 10 + randint1(10);
4249
4250         for (i = 0; i < b; i++)
4251         {
4252                 POSITION y = 0, x = 0;
4253                 int count;
4254
4255                 for (count = 0; count <= 20; count++)
4256                 {
4257                         int dy, dx, d;
4258
4259                         x = p_ptr->x - 8 + randint0(17);
4260                         y = p_ptr->y - 8 + randint0(17);
4261
4262                         dx = (p_ptr->x > x) ? (p_ptr->x - x) : (x - p_ptr->x);
4263                         dy = (p_ptr->y > y) ? (p_ptr->y - y) : (y - p_ptr->y);
4264
4265                         /* Approximate distance */
4266                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4267
4268                         if (d >= 9) continue;
4269
4270                         if (!in_bounds(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)
4271                                 || !cave_have_flag_bold(y, x, FF_PROJECT)) continue;
4272
4273                         /* Valid position */
4274                         break;
4275                 }
4276
4277                 if (count > 20) continue;
4278
4279                 project(0, rad, y, x, dam, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
4280         }
4281 }
4282
4283
4284 /*!
4285 * @brief 破邪魔法「神の怒り」の処理としてターゲットを指定した後分解のボールを最大20回発生させる。
4286 * @param dam ダメージ
4287 * @param rad 効力の半径
4288 * @return ターゲットを指定し、実行したならばTRUEを返す。
4289 */
4290 bool cast_wrath_of_the_god(HIT_POINT dam, POSITION rad)
4291 {
4292         POSITION x, y, tx, ty;
4293         POSITION nx, ny;
4294         DIRECTION dir;
4295         int i;
4296         int b = 10 + randint1(10);
4297
4298         if (!get_aim_dir(&dir)) return FALSE;
4299
4300         /* Use the given direction */
4301         tx = p_ptr->x + 99 * ddx[dir];
4302         ty = p_ptr->y + 99 * ddy[dir];
4303
4304         /* Hack -- Use an actual "target" */
4305         if ((dir == 5) && target_okay())
4306         {
4307                 tx = target_col;
4308                 ty = target_row;
4309         }
4310
4311         x = p_ptr->x;
4312         y = p_ptr->y;
4313
4314         while (1)
4315         {
4316                 /* Hack -- Stop at the target */
4317                 if ((y == ty) && (x == tx)) break;
4318
4319                 ny = y;
4320                 nx = x;
4321                 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
4322
4323                 /* Stop at maximum range */
4324                 if (MAX_RANGE <= distance(p_ptr->y, p_ptr->x, ny, nx)) break;
4325
4326                 /* Stopped by walls/doors */
4327                 if (!cave_have_flag_bold(ny, nx, FF_PROJECT)) break;
4328
4329                 /* Stopped by monsters */
4330                 if ((dir != 5) && cave[ny][nx].m_idx != 0) break;
4331
4332                 /* Save the new location */
4333                 x = nx;
4334                 y = ny;
4335         }
4336         tx = x;
4337         ty = y;
4338
4339         for (i = 0; i < b; i++)
4340         {
4341                 int count = 20, d = 0;
4342
4343                 while (count--)
4344                 {
4345                         int dx, dy;
4346
4347                         x = tx - 5 + randint0(11);
4348                         y = ty - 5 + randint0(11);
4349
4350                         dx = (tx > x) ? (tx - x) : (x - tx);
4351                         dy = (ty > y) ? (ty - y) : (y - ty);
4352
4353                         /* Approximate distance */
4354                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4355                         /* Within the radius */
4356                         if (d < 5) break;
4357                 }
4358
4359                 if (count < 0) continue;
4360
4361                 /* Cannot penetrate perm walls */
4362                 if (!in_bounds(y, x) ||
4363                         cave_stop_disintegration(y, x) ||
4364                         !in_disintegration_range(ty, tx, y, x))
4365                         continue;
4366
4367                 project(0, rad, y, x, dam, GF_DISINTEGRATE, PROJECT_JUMP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
4368         }
4369
4370         return TRUE;
4371 }
4372
4373 /*!
4374 * @brief 「ワンダー」のランダムな効果を決定して処理する。
4375 * @param dir 方向ID
4376 * @return なし
4377 * @details
4378 * This spell should become more useful (more controlled) as the\n
4379 * player gains experience levels.  Thus, add 1/5 of the player's\n
4380 * level to the die roll.  This eliminates the worst effects later on,\n
4381 * while keeping the results quite random.  It also allows some potent\n
4382 * effects only at high level.
4383 */
4384 void cast_wonder(DIRECTION dir)
4385 {
4386         PLAYER_LEVEL plev = p_ptr->lev;
4387         int die = randint1(100) + plev / 5;
4388         int vir = virtue_number(V_CHANCE);
4389
4390         if (vir)
4391         {
4392                 if (p_ptr->virtues[vir - 1] > 0)
4393                 {
4394                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4395                 }
4396                 else
4397                 {
4398                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4399                 }
4400         }
4401
4402         if (die < 26)
4403                 chg_virtue(V_CHANCE, 1);
4404
4405         if (die > 100)
4406         {
4407                 msg_print(_("あなたは力がみなぎるのを感じた!", "You feel a surge of power!"));
4408         }
4409
4410         if (die < 8) clone_monster(dir);
4411         else if (die < 14) speed_monster(dir, plev);
4412         else if (die < 26) heal_monster(dir, damroll(4, 6));
4413         else if (die < 31) poly_monster(dir, plev);
4414         else if (die < 36)
4415                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4416                         damroll(3 + ((plev - 1) / 5), 4));
4417         else if (die < 41) confuse_monster(dir, plev);
4418         else if (die < 46) fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4419         else if (die < 51) (void)lite_line(dir, damroll(6, 8));
4420         else if (die < 56)
4421                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4422                         damroll(3 + ((plev - 5) / 4), 8));
4423         else if (die < 61)
4424                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4425                         damroll(5 + ((plev - 5) / 4), 8));
4426         else if (die < 66)
4427                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4428                         damroll(6 + ((plev - 5) / 4), 8));
4429         else if (die < 71)
4430                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4431                         damroll(8 + ((plev - 5) / 4), 8));
4432         else if (die < 76) hypodynamic_bolt(dir, 75);
4433         else if (die < 81) fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4434         else if (die < 86) fire_ball(GF_ACID, dir, 40 + plev, 2);
4435         else if (die < 91) fire_ball(GF_ICE, dir, 70 + plev, 3);
4436         else if (die < 96) fire_ball(GF_FIRE, dir, 80 + plev, 3);
4437         else if (die < 101) hypodynamic_bolt(dir, 100 + plev);
4438         else if (die < 104)
4439         {
4440                 earthquake(p_ptr->y, p_ptr->x, 12);
4441         }
4442         else if (die < 106)
4443         {
4444                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4445         }
4446         else if (die < 108)
4447         {
4448                 symbol_genocide(plev + 50, TRUE);
4449         }
4450         else if (die < 110) dispel_monsters(120);
4451         else /* RARE */
4452         {
4453                 dispel_monsters(150);
4454                 slow_monsters(plev);
4455                 sleep_monsters(plev);
4456                 hp_player(300);
4457         }
4458 }
4459
4460
4461 /*!
4462 * @brief 「悪霊召喚」のランダムな効果を決定して処理する。
4463 * @param dir 方向ID
4464 * @return なし
4465 */
4466 void cast_invoke_spirits(DIRECTION dir)
4467 {
4468         PLAYER_LEVEL plev = p_ptr->lev;
4469         int die = randint1(100) + plev / 5;
4470         int vir = virtue_number(V_CHANCE);
4471
4472         if (vir)
4473         {
4474                 if (p_ptr->virtues[vir - 1] > 0)
4475                 {
4476                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4477                 }
4478                 else
4479                 {
4480                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4481                 }
4482         }
4483
4484         msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead..."));
4485         if (die < 26)
4486                 chg_virtue(V_CHANCE, 1);
4487
4488         if (die > 100)
4489         {
4490                 msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!"));
4491         }
4492
4493         if (die < 8)
4494         {
4495                 msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!",
4496                         "Oh no! Mouldering forms rise from the earth around you!"));
4497
4498                 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4499                 chg_virtue(V_UNLIFE, 1);
4500         }
4501         else if (die < 14)
4502         {
4503                 msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind..."));
4504
4505                 set_afraid(p_ptr->afraid + randint1(4) + 4);
4506         }
4507         else if (die < 26)
4508         {
4509                 msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...",
4510                         "Your head is invaded by a horde of gibbering spectral voices..."));
4511
4512                 set_confused(p_ptr->confused + randint1(4) + 4);
4513         }
4514         else if (die < 31)
4515         {
4516                 poly_monster(dir, plev);
4517         }
4518         else if (die < 36)
4519         {
4520                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4521                         damroll(3 + ((plev - 1) / 5), 4));
4522         }
4523         else if (die < 41)
4524         {
4525                 confuse_monster(dir, plev);
4526         }
4527         else if (die < 46)
4528         {
4529                 fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4530         }
4531         else if (die < 51)
4532         {
4533                 (void)lite_line(dir, damroll(6, 8));
4534         }
4535         else if (die < 56)
4536         {
4537                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4538                         damroll(3 + ((plev - 5) / 4), 8));
4539         }
4540         else if (die < 61)
4541         {
4542                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4543                         damroll(5 + ((plev - 5) / 4), 8));
4544         }
4545         else if (die < 66)
4546         {
4547                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4548                         damroll(6 + ((plev - 5) / 4), 8));
4549         }
4550         else if (die < 71)
4551         {
4552                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4553                         damroll(8 + ((plev - 5) / 4), 8));
4554         }
4555         else if (die < 76)
4556         {
4557                 hypodynamic_bolt(dir, 75);
4558         }
4559         else if (die < 81)
4560         {
4561                 fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4562         }
4563         else if (die < 86)
4564         {
4565                 fire_ball(GF_ACID, dir, 40 + plev, 2);
4566         }
4567         else if (die < 91)
4568         {
4569                 fire_ball(GF_ICE, dir, 70 + plev, 3);
4570         }
4571         else if (die < 96)
4572         {
4573                 fire_ball(GF_FIRE, dir, 80 + plev, 3);
4574         }
4575         else if (die < 101)
4576         {
4577                 hypodynamic_bolt(dir, 100 + plev);
4578         }
4579         else if (die < 104)
4580         {
4581                 earthquake(p_ptr->y, p_ptr->x, 12);
4582         }
4583         else if (die < 106)
4584         {
4585                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4586         }
4587         else if (die < 108)
4588         {
4589                 symbol_genocide(plev + 50, TRUE);
4590         }
4591         else if (die < 110)
4592         {
4593                 dispel_monsters(120);
4594         }
4595         else
4596         { /* RARE */
4597                 dispel_monsters(150);
4598                 slow_monsters(plev);
4599                 sleep_monsters(plev);
4600                 hp_player(300);
4601         }
4602
4603         if (die < 31)
4604         {
4605                 msg_print(_("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」",
4606                         "Sepulchral voices chuckle. 'Soon you will join us, mortal.'"));
4607         }
4608 }
4609
4610 /*!
4611 * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。
4612 * @return なし
4613 */
4614 void cast_shuffle(void)
4615 {
4616         PLAYER_LEVEL plev = p_ptr->lev;
4617         DIRECTION dir;
4618         int die;
4619         int vir = virtue_number(V_CHANCE);
4620         int i;
4621
4622         /* Card sharks and high mages get a level bonus */
4623         if ((p_ptr->pclass == CLASS_ROGUE) ||
4624                 (p_ptr->pclass == CLASS_HIGH_MAGE) ||
4625                 (p_ptr->pclass == CLASS_SORCERER))
4626                 die = (randint1(110)) + plev / 5;
4627         else
4628                 die = randint1(120);
4629
4630
4631         if (vir)
4632         {
4633                 if (p_ptr->virtues[vir - 1] > 0)
4634                 {
4635                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4636                 }
4637                 else
4638                 {
4639                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4640                 }
4641         }
4642
4643         msg_print(_("あなたはカードを切って一枚引いた...", "You shuffle the deck and draw a card..."));
4644
4645         if (die < 30)
4646                 chg_virtue(V_CHANCE, 1);
4647
4648         if (die < 7)
4649         {
4650                 msg_print(_("なんてこった!《死》だ!", "Oh no! It's Death!"));
4651
4652                 for (i = 0; i < randint1(3); i++)
4653                         activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4654         }
4655         else if (die < 14)
4656         {
4657                 msg_print(_("なんてこった!《悪魔》だ!", "Oh no! It's the Devil!"));
4658                 summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4659         }
4660         else if (die < 18)
4661         {
4662                 int count = 0;
4663                 msg_print(_("なんてこった!《吊られた男》だ!", "Oh no! It's the Hanged Man."));
4664                 activate_ty_curse(FALSE, &count);
4665         }
4666         else if (die < 22)
4667         {
4668                 msg_print(_("《不調和の剣》だ。", "It's the swords of discord."));
4669                 aggravate_monsters(0);
4670         }
4671         else if (die < 26)
4672         {
4673                 msg_print(_("《愚者》だ。", "It's the Fool."));
4674                 do_dec_stat(A_INT);
4675                 do_dec_stat(A_WIS);
4676         }
4677         else if (die < 30)
4678         {
4679                 msg_print(_("奇妙なモンスターの絵だ。", "It's the picture of a strange monster."));
4680                 trump_summoning(1, FALSE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), (32 + randint1(6)), PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
4681         }
4682         else if (die < 33)
4683         {
4684                 msg_print(_("《月》だ。", "It's the Moon."));
4685                 unlite_area(10, 3);
4686         }
4687         else if (die < 38)
4688         {
4689                 msg_print(_("《運命の輪》だ。", "It's the Wheel of Fortune."));
4690                 wild_magic(randint0(32));
4691         }
4692         else if (die < 40)
4693         {
4694                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4695                 teleport_player(10, TELEPORT_PASSIVE);
4696         }
4697         else if (die < 42)
4698         {
4699                 msg_print(_("《正義》だ。", "It's Justice."));
4700                 set_blessed(p_ptr->lev, FALSE);
4701         }
4702         else if (die < 47)
4703         {
4704                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4705                 teleport_player(100, TELEPORT_PASSIVE);
4706         }
4707         else if (die < 52)
4708         {
4709                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4710                 teleport_player(200, TELEPORT_PASSIVE);
4711         }
4712         else if (die < 60)
4713         {
4714                 msg_print(_("《塔》だ。", "It's the Tower."));
4715                 wall_breaker();
4716         }
4717         else if (die < 72)
4718         {
4719                 msg_print(_("《節制》だ。", "It's Temperance."));
4720                 sleep_monsters_touch();
4721         }
4722         else if (die < 80)
4723         {
4724                 msg_print(_("《塔》だ。", "It's the Tower."));
4725
4726                 earthquake(p_ptr->y, p_ptr->x, 5);
4727         }
4728         else if (die < 82)
4729         {
4730                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4731                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_MOLD, 0L);
4732         }
4733         else if (die < 84)
4734         {
4735                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4736                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_BAT, 0L);
4737         }
4738         else if (die < 86)
4739         {
4740                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4741                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_VORTEX, 0L);
4742         }
4743         else if (die < 88)
4744         {
4745                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4746                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_COIN_MIMIC, 0L);
4747         }
4748         else if (die < 96)
4749         {
4750                 msg_print(_("《恋人》だ。", "It's the Lovers."));
4751
4752                 if (get_aim_dir(&dir))
4753                         charm_monster(dir, MIN(p_ptr->lev, 20));
4754         }
4755         else if (die < 101)
4756         {
4757                 msg_print(_("《隠者》だ。", "It's the Hermit."));
4758                 wall_stone();
4759         }
4760         else if (die < 111)
4761         {
4762                 msg_print(_("《審判》だ。", "It's the Judgement."));
4763                 do_cmd_rerate(FALSE);
4764                 lose_all_mutations();
4765         }
4766         else if (die < 120)
4767         {
4768                 msg_print(_("《太陽》だ。", "It's the Sun."));
4769                 chg_virtue(V_KNOWLEDGE, 1);
4770                 chg_virtue(V_ENLIGHTEN, 1);
4771                 wiz_lite(FALSE);
4772         }
4773         else
4774         {
4775                 msg_print(_("《世界》だ。", "It's the World."));
4776                 if (p_ptr->exp < PY_MAX_EXP)
4777                 {
4778                         s32b ee = (p_ptr->exp / 25) + 1;
4779                         if (ee > 5000) ee = 5000;
4780                         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4781                         gain_exp(ee);
4782                 }
4783         }
4784 }
4785
4786 bool_hack life_stream(bool_hack message, bool_hack virtue)
4787 {
4788         if(virtue)
4789         {
4790                 chg_virtue(V_VITALITY, 1);
4791                 chg_virtue(V_UNLIFE, -5);
4792         }
4793         if(message)
4794         {
4795                 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
4796         }
4797         restore_level();
4798         (void)set_poisoned(0);
4799         (void)set_blind(0);
4800         (void)set_confused(0);
4801         (void)set_image(0);
4802         (void)set_stun(0);
4803         (void)set_cut(0);
4804         (void)restore_all_status();
4805         (void)set_shero(0, TRUE);
4806         update_stuff();
4807         hp_player(5000);
4808
4809         return TRUE;
4810 }
4811
4812 bool_hack heroism(int base)
4813 {
4814         bool_hack ident = FALSE;
4815         if(set_afraid(0)) ident = TRUE;
4816         if(set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4817         if(hp_player(10)) ident = TRUE;
4818         return ident;
4819 }
4820
4821 bool_hack berserk(int base)
4822 {
4823         bool_hack ident = FALSE;
4824         if (set_afraid(0)) ident = TRUE;
4825         if (set_shero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4826         if (hp_player(30)) ident = TRUE;
4827         return ident;
4828 }
4829
4830 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
4831 {
4832         bool_hack ident = FALSE;
4833         if (hp_player(damroll(dice, sides))) ident = TRUE;
4834         if (set_blind(0)) ident = TRUE;
4835         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
4836         if (set_shero(0, TRUE)) ident = TRUE;
4837         return ident;
4838 }
4839
4840 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
4841 {
4842         bool_hack ident = FALSE;
4843         if (hp_player(damroll(dice, sides))) ident = TRUE;
4844         if (set_blind(0)) ident = TRUE;
4845         if (set_confused(0)) ident = TRUE;
4846         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
4847         if (set_shero(0, TRUE)) ident = TRUE;
4848         return ident;
4849 }
4850
4851 bool_hack cure_critical_wounds(HIT_POINT pow)
4852 {
4853         bool_hack ident = FALSE;
4854         if (hp_player(pow)) ident = TRUE;
4855         if (set_blind(0)) ident = TRUE;
4856         if (set_confused(0)) ident = TRUE;
4857         if (set_poisoned(0)) ident = TRUE;
4858         if (set_stun(0)) ident = TRUE;
4859         if (set_cut(0)) ident = TRUE;
4860         if (set_shero(0, TRUE)) ident = TRUE;
4861         return ident;
4862 }
4863
4864 bool_hack true_healing(HIT_POINT pow)
4865 {
4866         bool_hack ident = FALSE;
4867         if (hp_player(pow)) ident = TRUE;
4868         if (set_blind(0)) ident = TRUE;
4869         if (set_confused(0)) ident = TRUE;
4870         if (set_poisoned(0)) ident = TRUE;
4871         if (set_stun(0)) ident = TRUE;
4872         if (set_cut(0)) ident = TRUE;
4873         if (set_image(0)) ident = TRUE;
4874         return ident;
4875 }
4876
4877 bool_hack restore_mana(bool_hack magic_eater)
4878 {
4879         bool_hack ident = FALSE;
4880
4881         if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
4882         {
4883                 int i;
4884                 for (i = 0; i < EATER_EXT * 2; i++)
4885                 {
4886                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
4887                         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;
4888                 }
4889                 for (; i < EATER_EXT * 3; i++)
4890                 {
4891                         KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
4892                         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;
4893                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
4894                 }
4895                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
4896                 p_ptr->window |= (PW_PLAYER);
4897                 ident = TRUE;
4898         }
4899         else if (p_ptr->csp < p_ptr->msp)
4900         {
4901                 p_ptr->csp = p_ptr->msp;
4902                 p_ptr->csp_frac = 0;
4903                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
4904                 p_ptr->redraw |= (PR_MANA);
4905                 p_ptr->window |= (PW_PLAYER);
4906                 p_ptr->window |= (PW_SPELL);
4907                 ident = TRUE;
4908         }
4909
4910         return ident;
4911 }
4912
4913 bool restore_all_status(void)
4914 {
4915         bool ident = FALSE; 
4916         if (do_res_stat(A_STR)) ident = TRUE;
4917         if (do_res_stat(A_INT)) ident = TRUE;
4918         if (do_res_stat(A_WIS)) ident = TRUE;
4919         if (do_res_stat(A_DEX)) ident = TRUE;
4920         if (do_res_stat(A_CON)) ident = TRUE;
4921         if (do_res_stat(A_CHR)) ident = TRUE;
4922         return ident;
4923 }
4924
4925 /*!
4926  * @brief 口を使う継続的な処理を中断する
4927  * @return なし
4928  */
4929 void stop_mouth(void)
4930 {
4931         if (music_singing_any()) stop_singing();
4932         if (hex_spelling_any()) stop_hex_spell_all();
4933 }
4934
4935
4936 bool_hack vampirism(void)
4937 {
4938         DIRECTION dir;
4939         POSITION x, y;
4940         int dummy;
4941         cave_type *c_ptr;
4942
4943         if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
4944         {
4945                 msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking."));
4946                 return FALSE;
4947         }
4948
4949         /* Only works on adjacent monsters */
4950         if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
4951         y = p_ptr->y + ddy[dir];
4952         x = p_ptr->x + ddx[dir];
4953         c_ptr = &cave[y][x];
4954
4955         stop_mouth();
4956
4957         if (!(c_ptr->m_idx))
4958         {
4959                 msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
4960                 return FALSE;
4961         }
4962
4963         msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
4964
4965         dummy = p_ptr->lev * 2;
4966
4967         if (hypodynamic_bolt(dir, dummy))
4968         {
4969                 if (p_ptr->food < PY_FOOD_FULL)
4970                         /* No heal if we are "full" */
4971                         (void)hp_player(dummy);
4972                 else
4973                         msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
4974
4975                 /* Gain nutritional sustenance: 150/hp drained */
4976                 /* A Food ration gives 5000 food points (by contrast) */
4977                 /* Don't ever get more than "Full" this way */
4978                 /* But if we ARE Gorged,  it won't cure us */
4979                 dummy = p_ptr->food + MIN(5000, 100 * dummy);
4980                 if (p_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
4981                         (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
4982         }
4983         else
4984                 msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
4985         return TRUE;
4986 }
4987
4988 bool panic_hit(void)
4989 {
4990         DIRECTION dir;
4991         POSITION x, y;
4992
4993         if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
4994         y = p_ptr->y + ddy[dir];
4995         x = p_ptr->x + ddx[dir];
4996         if (cave[y][x].m_idx)
4997         {
4998                 py_attack(y, x, 0);
4999                 if (randint0(p_ptr->skill_dis) < 7)
5000                         msg_print(_("うまく逃げられなかった。", "You failed to run away."));
5001                 else
5002                         teleport_player(30, 0L);
5003                 return TRUE;
5004         }
5005         else
5006         {
5007                 msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
5008                 msg_print(NULL);
5009                 return FALSE;
5010         }
5011
5012 }
5013
5014 /*!
5015 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
5016 * @return なし
5017 * @note
5018 * currently this function allows pseudo-id of any object,
5019 * including silly ones like potions & scrolls, which always
5020 * get '{average}'. This should be changed, either to stop such
5021 * items from being pseudo-id'd, or to allow psychometry to
5022 * detect whether the unidentified potion/scroll/etc is
5023 * good (Cure Light Wounds, Restore Strength, etc) or
5024 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
5025 */
5026 bool psychometry(void)
5027 {
5028         OBJECT_IDX      item;
5029         object_type     *o_ptr;
5030         char            o_name[MAX_NLEN];
5031         byte            feel;
5032         cptr            q, s;
5033         bool okay = FALSE;
5034
5035         item_tester_no_ryoute = TRUE;
5036         q = _("どのアイテムを調べますか?", "Meditate on which item? ");
5037         s = _("調べるアイテムがありません。", "You have nothing appropriate.");
5038
5039         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
5040
5041         /* Get the item (in the pack) */
5042         if (item >= 0)
5043         {
5044                 o_ptr = &inventory[item];
5045         }
5046
5047         /* Get the item (on the floor) */
5048         else
5049         {
5050                 o_ptr = &o_list[0 - item];
5051         }
5052
5053         /* It is fully known, no information needed */
5054         if (object_is_known(o_ptr))
5055         {
5056                 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
5057                 return TRUE;
5058         }
5059
5060         /* Check for a feeling */
5061         feel = value_check_aux1(o_ptr);
5062
5063         /* Get an object description */
5064         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5065
5066         /* Skip non-feelings */
5067         if (!feel)
5068         {
5069                 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
5070                 return TRUE;
5071         }
5072
5073 #ifdef JP
5074         msg_format("%sは%sという感じがする...",
5075                 o_name, game_inscriptions[feel]);
5076 #else
5077         msg_format("You feel that the %s %s %s...",
5078                 o_name, ((o_ptr->number == 1) ? "is" : "are"),
5079                 game_inscriptions[feel]);
5080 #endif
5081
5082
5083         /* We have "felt" it */
5084         o_ptr->ident |= (IDENT_SENSE);
5085
5086         /* "Inscribe" it */
5087         o_ptr->feeling = feel;
5088
5089         /* Player touches it */
5090         o_ptr->marked |= OM_TOUCHED;
5091
5092         /* Combine / Reorder the pack (later) */
5093         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5094
5095         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5096
5097         /* Valid "tval" codes */
5098         switch (o_ptr->tval)
5099         {
5100         case TV_SHOT:
5101         case TV_ARROW:
5102         case TV_BOLT:
5103         case TV_BOW:
5104         case TV_DIGGING:
5105         case TV_HAFTED:
5106         case TV_POLEARM:
5107         case TV_SWORD:
5108         case TV_BOOTS:
5109         case TV_GLOVES:
5110         case TV_HELM:
5111         case TV_CROWN:
5112         case TV_SHIELD:
5113         case TV_CLOAK:
5114         case TV_SOFT_ARMOR:
5115         case TV_HARD_ARMOR:
5116         case TV_DRAG_ARMOR:
5117         case TV_CARD:
5118         case TV_RING:
5119         case TV_AMULET:
5120         case TV_LITE:
5121         case TV_FIGURINE:
5122                 okay = TRUE;
5123                 break;
5124         }
5125
5126         /* Auto-inscription/destroy */
5127         autopick_alter_item(item, (bool)(okay && destroy_feeling));
5128
5129         /* Something happened */
5130         return (TRUE);
5131 }