OSDN Git Service

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