OSDN Git Service

[Refactor] #37353 メッセージ整理。
[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                         if ((r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) == (RF3_EVIL | RF3_GOOD)) align = _("善悪", "good&evil");
1428                         else if (r_ptr->flags3 & RF3_EVIL) align = _("邪悪", "evil");
1429                         else if (r_ptr->flags3 & RF3_GOOD) align = _("善良", "good");
1430                         else if ((m_ptr->sub_align & (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) == (SUB_ALIGN_EVIL | SUB_ALIGN_GOOD)) _(align = "中立(善悪)", "neutral(good&evil)");
1431                         else if (m_ptr->sub_align & SUB_ALIGN_EVIL) align = _("中立(邪悪)", "neutral(evil)");
1432                         else if (m_ptr->sub_align & SUB_ALIGN_GOOD) align = _("中立(善良)", "neutral(good)");
1433                         else align = _("中立", "neutral");
1434
1435                         /* Describe the monster */
1436                         sprintf(buf,_("%s ... 属性:%s HP:%d/%d AC:%d 速度:%s%d 経験:", "%s ... align:%s HP:%d/%d AC:%d speed:%s%d exp:"),
1437                                 m_name, align, (int)m_ptr->hp, (int)m_ptr->maxhp, r_ptr->ac, (speed > 0) ? "+" : "", speed);
1438
1439                         if (r_ptr->next_r_idx)
1440                         {
1441                                 strcat(buf, format("%d/%d ", m_ptr->exp, r_ptr->next_exp));
1442                         }
1443                         else
1444                         {
1445                                 strcat(buf, "xxx ");
1446                         }
1447
1448                         if (MON_CSLEEP(m_ptr)) strcat(buf,_("睡眠 ", "sleeping "));
1449                         if (MON_STUNNED(m_ptr)) strcat(buf, _("朦朧 ", "stunned "));
1450                         if (MON_MONFEAR(m_ptr)) strcat(buf, _("恐怖 ", "scared "));
1451                         if (MON_CONFUSED(m_ptr)) strcat(buf, _("混乱 ", "confused "));
1452                         if (MON_INVULNER(m_ptr)) strcat(buf, _("無敵 ", "invulnerable "));
1453                         buf[strlen(buf)-1] = '\0';
1454                         prt(buf, 0, 0);
1455
1456                         /* HACK : Add the line to message buffer */
1457                         message_add(buf);
1458                         p_ptr->window |= (PW_MESSAGE);
1459                         window_stuff();
1460
1461                         if (m_ptr->ml) move_cursor_relative(m_ptr->fy, m_ptr->fx);
1462                         inkey();
1463
1464                         Term_erase(0, 0, 255);
1465
1466                         /* Learn everything about this monster */
1467                         if (lore_do_probe(m_ptr->r_idx))
1468                         {
1469                                 /* Get base name of monster */
1470                                 strcpy(buf, (r_name + r_ptr->name));
1471
1472 #ifdef JP
1473                                 /* Note that we learnt some new flags  -Mogami- */
1474                                 msg_format("%sについてさらに詳しくなった気がする。", buf);
1475 #else
1476                                 /* Pluralize it */
1477                                 plural_aux(buf);
1478
1479                                 /* Note that we learnt some new flags  -Mogami- */
1480                                 msg_format("You now know more about %s.", buf);
1481 #endif
1482                                 /* Clear -more- prompt */
1483                                 msg_print(NULL);
1484                         }
1485
1486                         /* Probe worked */
1487                         probe = TRUE;
1488                 }
1489         }
1490
1491         Term->scr->cu = cu;
1492         Term->scr->cv = cv;
1493         Term_fresh();
1494
1495         if (probe)
1496         {
1497                 chg_virtue(V_KNOWLEDGE, 1);
1498                 msg_print(_("これで全部です。", "That's all."));
1499         }
1500
1501         /* Result */
1502         return (probe);
1503 }
1504
1505
1506
1507 /*!
1508  * @brief *破壊*処理を行う / The spell of destruction
1509  * @param y1 破壊の中心Y座標
1510  * @param x1 破壊の中心X座標 
1511  * @param r 破壊の半径
1512  * @param in_generate ダンジョンフロア生成中の処理ならばTRUE
1513  * @return 効力があった場合TRUEを返す
1514  * @details
1515  * <pre>
1516  * This spell "deletes" monsters (instead of "killing" them).
1517  *
1518  * Later we may use one function for both "destruction" and
1519  * "earthquake" by using the "full" to select "destruction".
1520  * </pre>
1521  */
1522 bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
1523 {
1524         POSITION y, x;
1525         int k, t;
1526         cave_type *c_ptr;
1527         bool      flag = FALSE;
1528
1529         /* Prevent destruction of quest levels and town */
1530         if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1531         {
1532                 return (FALSE);
1533         }
1534
1535         /* Lose monster light */
1536         if (!in_generate) clear_mon_lite();
1537
1538         /* Big area of affect */
1539         for (y = (y1 - r); y <= (y1 + r); y++)
1540         {
1541                 for (x = (x1 - r); x <= (x1 + r); x++)
1542                 {
1543                         /* Skip illegal grids */
1544                         if (!in_bounds(y, x)) continue;
1545
1546                         /* Extract the distance */
1547                         k = distance(y1, x1, y, x);
1548
1549                         /* Stay in the circle of death */
1550                         if (k > r) continue;
1551
1552                         /* Access the grid */
1553                         c_ptr = &cave[y][x];
1554
1555                         /* Lose room and vault */
1556                         c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1557
1558                         /* Lose light and knowledge */
1559                         c_ptr->info &= ~(CAVE_MARK | CAVE_GLOW | CAVE_KNOWN);
1560
1561                         if (!in_generate) /* Normal */
1562                         {
1563                                 /* Lose unsafety */
1564                                 c_ptr->info &= ~(CAVE_UNSAFE);
1565
1566                                 /* Hack -- Notice player affect */
1567                                 if (player_bold(y, x))
1568                                 {
1569                                         /* Hurt the player later */
1570                                         flag = TRUE;
1571
1572                                         /* Do not hurt this grid */
1573                                         continue;
1574                                 }
1575                         }
1576
1577                         /* Hack -- Skip the epicenter */
1578                         if ((y == y1) && (x == x1)) continue;
1579
1580                         if (c_ptr->m_idx)
1581                         {
1582                                 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1583                                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1584
1585                                 if (in_generate) /* In generation */
1586                                 {
1587                                         /* Delete the monster (if any) */
1588                                         delete_monster(y, x);
1589                                 }
1590                                 else if (r_ptr->flags1 & RF1_QUESTOR)
1591                                 {
1592                                         /* Heal the monster */
1593                                         m_ptr->hp = m_ptr->maxhp;
1594
1595                                         /* Try to teleport away quest monsters */
1596                                         if (!teleport_away(c_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
1597                                 }
1598                                 else
1599                                 {
1600                                         if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
1601                                         {
1602                                                 char m_name[80];
1603
1604                                                 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1605                                                 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_DESTROY, m_name);
1606                                         }
1607
1608                                         /* Delete the monster (if any) */
1609                                         delete_monster(y, x);
1610                                 }
1611                         }
1612
1613                         /* During generation, destroyed artifacts are "preserved" */
1614                         if (preserve_mode || in_generate)
1615                         {
1616                                 OBJECT_IDX this_o_idx, next_o_idx = 0;
1617
1618                                 /* Scan all objects in the grid */
1619                                 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1620                                 {
1621                                         object_type *o_ptr;
1622
1623                                         /* Acquire object */
1624                                         o_ptr = &o_list[this_o_idx];
1625
1626                                         /* Acquire next object */
1627                                         next_o_idx = o_ptr->next_o_idx;
1628
1629                                         /* Hack -- Preserve unknown artifacts */
1630                                         if (object_is_fixed_artifact(o_ptr) && (!object_is_known(o_ptr) || in_generate))
1631                                         {
1632                                                 /* Mega-Hack -- Preserve the artifact */
1633                                                 a_info[o_ptr->name1].cur_num = 0;
1634
1635                                                 if (in_generate && cheat_peek)
1636                                                 {
1637                                                         char o_name[MAX_NLEN];
1638                                                         object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1639                                                         msg_format(_("伝説のアイテム (%s) は生成中に*破壊*された。", "Artifact (%s) was *destroyed* during generation."), o_name);
1640                                                 }
1641                                         }
1642                                         else if (in_generate && cheat_peek && o_ptr->art_name)
1643                                         {
1644                                                 msg_print(_("ランダム・アーティファクトの1つは生成中に*破壊*された。", 
1645                                                                         "One of the random artifacts was *destroyed* during generation."));
1646                                         }
1647                                 }
1648                         }
1649
1650                         /* Delete objects */
1651                         delete_object(y, x);
1652
1653                         /* Destroy "non-permanent" grids */
1654                         if (!cave_perma_grid(c_ptr))
1655                         {
1656                                 /* Wall (or floor) type */
1657                                 t = randint0(200);
1658
1659                                 if (!in_generate) /* Normal */
1660                                 {
1661                                         if (t < 20)
1662                                         {
1663                                                 /* Create granite wall */
1664                                                 cave_set_feat(y, x, feat_granite);
1665                                         }
1666                                         else if (t < 70)
1667                                         {
1668                                                 /* Create quartz vein */
1669                                                 cave_set_feat(y, x, feat_quartz_vein);
1670                                         }
1671                                         else if (t < 100)
1672                                         {
1673                                                 /* Create magma vein */
1674                                                 cave_set_feat(y, x, feat_magma_vein);
1675                                         }
1676                                         else
1677                                         {
1678                                                 /* Create floor */
1679                                                 cave_set_feat(y, x, floor_type[randint0(100)]);
1680                                         }
1681                                 }
1682                                 else /* In generation */
1683                                 {
1684                                         if (t < 20)
1685                                         {
1686                                                 /* Create granite wall */
1687                                                 place_extra_grid(c_ptr);
1688                                         }
1689                                         else if (t < 70)
1690                                         {
1691                                                 /* Create quartz vein */
1692                                                 c_ptr->feat = feat_quartz_vein;
1693                                         }
1694                                         else if (t < 100)
1695                                         {
1696                                                 /* Create magma vein */
1697                                                 c_ptr->feat = feat_magma_vein;
1698                                         }
1699                                         else
1700                                         {
1701                                                 /* Create floor */
1702                                                 place_floor_grid(c_ptr);
1703                                         }
1704
1705                                         /* Clear garbage of hidden trap or door */
1706                                         c_ptr->mimic = 0;
1707                                 }
1708                         }
1709                 }
1710         }
1711
1712         if (!in_generate)
1713         {
1714                 /* Process "re-glowing" */
1715                 for (y = (y1 - r); y <= (y1 + r); y++)
1716                 {
1717                         for (x = (x1 - r); x <= (x1 + r); x++)
1718                         {
1719                                 /* Skip illegal grids */
1720                                 if (!in_bounds(y, x)) continue;
1721
1722                                 /* Extract the distance */
1723                                 k = distance(y1, x1, y, x);
1724
1725                                 /* Stay in the circle of death */
1726                                 if (k > r) continue;
1727
1728                                 /* Access the grid */
1729                                 c_ptr = &cave[y][x];
1730
1731                                 if (is_mirror_grid(c_ptr)) c_ptr->info |= CAVE_GLOW;
1732                                 else if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
1733                                 {
1734                                         int i, yy, xx;
1735                                         cave_type *cc_ptr;
1736
1737                                         for (i = 0; i < 9; i++)
1738                                         {
1739                                                 yy = y + ddy_ddd[i];
1740                                                 xx = x + ddx_ddd[i];
1741                                                 if (!in_bounds2(yy, xx)) continue;
1742                                                 cc_ptr = &cave[yy][xx];
1743                                                 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1744                                                 {
1745                                                         c_ptr->info |= CAVE_GLOW;
1746                                                         break;
1747                                                 }
1748                                         }
1749                                 }
1750                         }
1751                 }
1752
1753                 /* Hack -- Affect player */
1754                 if (flag)
1755                 {
1756                         msg_print(_("燃えるような閃光が発生した!", "There is a searing blast of light!"));
1757
1758                         /* Blind the player */
1759                         if (!p_ptr->resist_blind && !p_ptr->resist_lite)
1760                         {
1761                                 /* Become blind */
1762                                 (void)set_blind(p_ptr->blind + 10 + randint1(10));
1763                         }
1764                 }
1765
1766                 forget_flow();
1767
1768                 /* Mega-Hack -- Forget the view and lite */
1769                 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1770
1771                 /* Update stuff */
1772                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1773
1774                 /* Redraw map */
1775                 p_ptr->redraw |= (PR_MAP);
1776
1777                 /* Window stuff */
1778                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1779
1780                 if (p_ptr->special_defense & NINJA_S_STEALTH)
1781                 {
1782                         if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
1783                 }
1784         }
1785
1786         /* Success */
1787         return (TRUE);
1788 }
1789
1790
1791 /*!
1792  * @brief 地震処理(サブルーチン) /
1793  * Induce an "earthquake" of the given radius at the given location.
1794  * @return 効力があった場合TRUEを返す
1795  * @param cy 中心Y座標
1796  * @param cx 中心X座標
1797  * @param r 効果半径
1798  * @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
1799  * @details
1800  * <pre>
1801  *
1802  * This will turn some walls into floors and some floors into walls.
1803  *
1804  * The player will take damage and "jump" into a safe grid if possible,
1805  * otherwise, he will "tunnel" through the rubble instantaneously.
1806  *
1807  * Monsters will take damage, and "jump" into a safe grid if possible,
1808  * otherwise they will be "buried" in the rubble, disappearing from
1809  * the level in the same way that they do when genocided.
1810  *
1811  * Note that thus the player and monsters (except eaters of walls and
1812  * passers through walls) will never occupy the same grid as a wall.
1813  * Note that as of now (2.7.8) no monster may occupy a "wall" grid, even
1814  * for a single turn, unless that monster can pass_walls or kill_walls.
1815  * This has allowed massive simplification of the "monster" code.
1816  * </pre>
1817  */
1818 bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
1819 {
1820         DIRECTION i;
1821         int t;
1822         POSITION y, x, yy, xx, dy, dx;
1823         int             damage = 0;
1824         int             sn = 0;
1825         POSITION        sy = 0, sx = 0;
1826         bool            hurt = FALSE;
1827         cave_type       *c_ptr;
1828         bool            map[32][32];
1829
1830
1831         /* Prevent destruction of quest levels and town */
1832         if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1833         {
1834                 return (FALSE);
1835         }
1836
1837         /* Paranoia -- Enforce maximum range */
1838         if (r > 12) r = 12;
1839
1840         /* Clear the "maximal blast" area */
1841         for (y = 0; y < 32; y++)
1842         {
1843                 for (x = 0; x < 32; x++)
1844                 {
1845                         map[y][x] = FALSE;
1846                 }
1847         }
1848
1849         /* Check around the epicenter */
1850         for (dy = -r; dy <= r; dy++)
1851         {
1852                 for (dx = -r; dx <= r; dx++)
1853                 {
1854                         /* Extract the location */
1855                         yy = cy + dy;
1856                         xx = cx + dx;
1857
1858                         /* Skip illegal grids */
1859                         if (!in_bounds(yy, xx)) continue;
1860
1861                         /* Skip distant grids */
1862                         if (distance(cy, cx, yy, xx) > r) continue;
1863
1864                         /* Access the grid */
1865                         c_ptr = &cave[yy][xx];
1866
1867                         /* Lose room and vault */
1868                         c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE);
1869
1870                         /* Lose light and knowledge */
1871                         c_ptr->info &= ~(CAVE_GLOW | CAVE_MARK | CAVE_KNOWN);
1872
1873                         /* Skip the epicenter */
1874                         if (!dx && !dy) continue;
1875
1876                         /* Skip most grids */
1877                         if (randint0(100) < 85) continue;
1878
1879                         /* Damage this grid */
1880                         map[16+yy-cy][16+xx-cx] = TRUE;
1881
1882                         /* Hack -- Take note of player damage */
1883                         if (player_bold(yy, xx)) hurt = TRUE;
1884                 }
1885         }
1886
1887         /* First, affect the player (if necessary) */
1888         if (hurt && !p_ptr->pass_wall && !p_ptr->kill_wall)
1889         {
1890                 /* Check around the player */
1891                 for (i = 0; i < 8; i++)
1892                 {
1893                         /* Access the location */
1894                         y = p_ptr->y + ddy_ddd[i];
1895                         x = p_ptr->x + ddx_ddd[i];
1896
1897                         /* Skip non-empty grids */
1898                         if (!cave_empty_bold(y, x)) continue;
1899
1900                         /* Important -- Skip "quake" grids */
1901                         if (map[16+y-cy][16+x-cx]) continue;
1902
1903                         if (cave[y][x].m_idx) continue;
1904
1905                         /* Count "safe" grids */
1906                         sn++;
1907
1908                         /* Randomize choice */
1909                         if (randint0(sn) > 0) continue;
1910
1911                         /* Save the safe location */
1912                         sy = y; sx = x;
1913                 }
1914
1915                 /* Random message */
1916                 switch (randint1(3))
1917                 {
1918                         case 1:
1919                         {
1920                                 msg_print(_("ダンジョンの壁が崩れた!", "The cave ceiling collapses!"));
1921                                 break;
1922                         }
1923                         case 2:
1924                         {
1925                                 msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The cave floor twists in an unnatural way!"));
1926                                 break;
1927                         }
1928                         default:
1929                         {
1930                                 msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The cave quakes!  You are pummeled with debris!"));
1931                                 break;
1932                         }
1933                 }
1934
1935                 /* Hurt the player a lot */
1936                 if (!sn)
1937                 {
1938                         /* Message and damage */
1939                         msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
1940                         damage = 200;
1941                 }
1942
1943                 /* Destroy the grid, and push the player to safety */
1944                 else
1945                 {
1946                         /* Calculate results */
1947                         switch (randint1(3))
1948                         {
1949                                 case 1:
1950                                 {
1951                                         msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
1952                                         damage = 0;
1953                                         break;
1954                                 }
1955                                 case 2:
1956                                 {
1957                                         msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
1958                                         damage = damroll(10, 4);
1959                                         (void)set_stun(p_ptr->stun + randint1(50));
1960                                         break;
1961                                 }
1962                                 case 3:
1963                                 {
1964                                         msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
1965                                         damage = damroll(10, 4);
1966                                         (void)set_stun(p_ptr->stun + randint1(50));
1967                                         break;
1968                                 }
1969                         }
1970
1971                         /* Move the player to the safe location */
1972                         (void)move_player_effect(sy, sx, MPE_DONT_PICKUP);
1973                 }
1974
1975                 /* Important -- no wall on player */
1976                 map[16+p_ptr->y-cy][16+p_ptr->x-cx] = FALSE;
1977
1978                 /* Take some damage */
1979                 if (damage)
1980                 {
1981                         cptr killer;
1982
1983                         if (m_idx)
1984                         {
1985                                 char m_name[80];
1986                                 monster_type *m_ptr = &m_list[m_idx];
1987
1988                                 /* Get the monster's real name */
1989                                 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
1990
1991                                 killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
1992                         }
1993                         else
1994                         {
1995                                 killer = _("地震", "an earthquake");
1996                         }
1997
1998                         take_hit(DAMAGE_ATTACK, damage, killer, -1);
1999                 }
2000         }
2001
2002         /* Examine the quaked region */
2003         for (dy = -r; dy <= r; dy++)
2004         {
2005                 for (dx = -r; dx <= r; dx++)
2006                 {
2007                         /* Extract the location */
2008                         yy = cy + dy;
2009                         xx = cx + dx;
2010
2011                         /* Skip unaffected grids */
2012                         if (!map[16+yy-cy][16+xx-cx]) continue;
2013
2014                         /* Access the grid */
2015                         c_ptr = &cave[yy][xx];
2016
2017                         if (c_ptr->m_idx == p_ptr->riding) continue;
2018
2019                         /* Process monsters */
2020                         if (c_ptr->m_idx)
2021                         {
2022                                 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2023                                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2024
2025                                 /* Quest monsters */
2026                                 if (r_ptr->flags1 & RF1_QUESTOR)
2027                                 {
2028                                         /* No wall on quest monsters */
2029                                         map[16+yy-cy][16+xx-cx] = FALSE;
2030
2031                                         continue;
2032                                 }
2033
2034                                 /* Most monsters cannot co-exist with rock */
2035                                 if (!(r_ptr->flags2 & (RF2_KILL_WALL)) &&
2036                                     !(r_ptr->flags2 & (RF2_PASS_WALL)))
2037                                 {
2038                                         char m_name[80];
2039
2040                                         /* Assume not safe */
2041                                         sn = 0;
2042
2043                                         /* Monster can move to escape the wall */
2044                                         if (!(r_ptr->flags1 & (RF1_NEVER_MOVE)))
2045                                         {
2046                                                 /* Look for safety */
2047                                                 for (i = 0; i < 8; i++)
2048                                                 {
2049                                                         /* Access the grid */
2050                                                         y = yy + ddy_ddd[i];
2051                                                         x = xx + ddx_ddd[i];
2052
2053                                                         /* Skip non-empty grids */
2054                                                         if (!cave_empty_bold(y, x)) continue;
2055
2056                                                         /* Hack -- no safety on glyph of warding */
2057                                                         if (is_glyph_grid(&cave[y][x])) continue;
2058                                                         if (is_explosive_rune_grid(&cave[y][x])) continue;
2059
2060                                                         /* ... nor on the Pattern */
2061                                                         if (pattern_tile(y, x)) continue;
2062
2063                                                         /* Important -- Skip "quake" grids */
2064                                                         if (map[16+y-cy][16+x-cx]) continue;
2065
2066                                                         if (cave[y][x].m_idx) continue;
2067                                                         if (player_bold(y, x)) continue;
2068
2069                                                         /* Count "safe" grids */
2070                                                         sn++;
2071
2072                                                         /* Randomize choice */
2073                                                         if (randint0(sn) > 0) continue;
2074
2075                                                         /* Save the safe grid */
2076                                                         sy = y; sx = x;
2077                                                 }
2078                                         }
2079
2080                                         /* Describe the monster */
2081                                         monster_desc(m_name, m_ptr, 0);
2082
2083                                         /* Scream in pain */
2084                                         if (!ignore_unview || is_seen(m_ptr)) msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
2085
2086                                         /* Take damage from the quake */
2087                                         damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
2088
2089                                         /* Monster is certainly awake */
2090                                         (void)set_monster_csleep(c_ptr->m_idx, 0);
2091
2092                                         /* Apply damage directly */
2093                                         m_ptr->hp -= damage;
2094
2095                                         /* Delete (not kill) "dead" monsters */
2096                                         if (m_ptr->hp < 0)
2097                                         {
2098                                                 if (!ignore_unview || is_seen(m_ptr)) 
2099                                                         msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
2100
2101                                                 if (c_ptr->m_idx)
2102                                                 {
2103                                                         if (record_named_pet && is_pet(&m_list[c_ptr->m_idx]) && m_list[c_ptr->m_idx].nickname)
2104                                                         {
2105                                                                 char m2_name[80];
2106
2107                                                                 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
2108                                                                 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
2109                                                         }
2110                                                 }
2111
2112                                                 /* Delete the monster */
2113                                                 delete_monster(yy, xx);
2114
2115                                                 /* No longer safe */
2116                                                 sn = 0;
2117                                         }
2118
2119                                         /* Hack -- Escape from the rock */
2120                                         if (sn)
2121                                         {
2122                                                 IDX m_idx_aux = cave[yy][xx].m_idx;
2123
2124                                                 /* Update the old location */
2125                                                 cave[yy][xx].m_idx = 0;
2126
2127                                                 /* Update the new location */
2128                                                 cave[sy][sx].m_idx = m_idx_aux;
2129
2130                                                 /* Move the monster */
2131                                                 m_ptr->fy = sy;
2132                                                 m_ptr->fx = sx;
2133
2134                                                 /* Update the monster (new location) */
2135                                                 update_mon(m_idx, TRUE);
2136
2137                                                 /* Redraw the old grid */
2138                                                 lite_spot(yy, xx);
2139
2140                                                 /* Redraw the new grid */
2141                                                 lite_spot(sy, sx);
2142                                         }
2143                                 }
2144                         }
2145                 }
2146         }
2147
2148         /* Lose monster light */
2149         clear_mon_lite();
2150
2151         /* Examine the quaked region */
2152         for (dy = -r; dy <= r; dy++)
2153         {
2154                 for (dx = -r; dx <= r; dx++)
2155                 {
2156                         /* Extract the location */
2157                         yy = cy + dy;
2158                         xx = cx + dx;
2159
2160                         /* Skip unaffected grids */
2161                         if (!map[16+yy-cy][16+xx-cx]) continue;
2162
2163                         /* Access the cave grid */
2164                         c_ptr = &cave[yy][xx];
2165
2166                         /* Paranoia -- never affect player */
2167 /*                      if (player_bold(yy, xx)) continue; */
2168
2169                         /* Destroy location (if valid) */
2170                         if (cave_valid_bold(yy, xx))
2171                         {
2172                                 /* Delete objects */
2173                                 delete_object(yy, xx);
2174
2175                                 /* Wall (or floor) type */
2176                                 t = cave_have_flag_bold(yy, xx, FF_PROJECT) ? randint0(100) : 200;
2177
2178                                 /* Granite */
2179                                 if (t < 20)
2180                                 {
2181                                         /* Create granite wall */
2182                                         cave_set_feat(yy, xx, feat_granite);
2183                                 }
2184
2185                                 /* Quartz */
2186                                 else if (t < 70)
2187                                 {
2188                                         /* Create quartz vein */
2189                                         cave_set_feat(yy, xx, feat_quartz_vein);
2190                                 }
2191
2192                                 /* Magma */
2193                                 else if (t < 100)
2194                                 {
2195                                         /* Create magma vein */
2196                                         cave_set_feat(yy, xx, feat_magma_vein);
2197                                 }
2198
2199                                 /* Floor */
2200                                 else
2201                                 {
2202                                         /* Create floor */
2203                                         cave_set_feat(yy, xx, floor_type[randint0(100)]);
2204                                 }
2205                         }
2206                 }
2207         }
2208
2209
2210         /* Process "re-glowing" */
2211         for (dy = -r; dy <= r; dy++)
2212         {
2213                 for (dx = -r; dx <= r; dx++)
2214                 {
2215                         /* Extract the location */
2216                         yy = cy + dy;
2217                         xx = cx + dx;
2218
2219                         /* Skip illegal grids */
2220                         if (!in_bounds(yy, xx)) continue;
2221
2222                         /* Skip distant grids */
2223                         if (distance(cy, cx, yy, xx) > r) continue;
2224
2225                         /* Access the grid */
2226                         c_ptr = &cave[yy][xx];
2227
2228                         if (is_mirror_grid(c_ptr)) c_ptr->info |= CAVE_GLOW;
2229                         else if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
2230                         {
2231                                 int ii, yyy, xxx;
2232                                 cave_type *cc_ptr;
2233
2234                                 for (ii = 0; ii < 9; ii++)
2235                                 {
2236                                         yyy = yy + ddy_ddd[ii];
2237                                         xxx = xx + ddx_ddd[ii];
2238                                         if (!in_bounds2(yyy, xxx)) continue;
2239                                         cc_ptr = &cave[yyy][xxx];
2240                                         if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
2241                                         {
2242                                                 c_ptr->info |= CAVE_GLOW;
2243                                                 break;
2244                                         }
2245                                 }
2246                         }
2247                 }
2248         }
2249
2250
2251         /* Mega-Hack -- Forget the view and lite */
2252         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2253
2254         /* Update stuff */
2255         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
2256
2257         /* Update the health bar */
2258         p_ptr->redraw |= (PR_HEALTH | PR_UHEALTH);
2259
2260         /* Redraw map */
2261         p_ptr->redraw |= (PR_MAP);
2262
2263         /* Window stuff */
2264         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2265
2266         if (p_ptr->special_defense & NINJA_S_STEALTH)
2267         {
2268                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
2269         }
2270
2271         /* Success */
2272         return (TRUE);
2273 }
2274
2275 /*!
2276  * @brief 地震処理(プレイヤーの中心発動) /
2277  * Induce an "earthquake" of the given radius at the given location.
2278  * @return 効力があった場合TRUEを返す
2279  * @param cy 中心Y座標
2280  * @param cx 中心X座標
2281  * @param r 効果半径
2282  */
2283 bool earthquake(POSITION cy, POSITION cx, POSITION r)
2284 {
2285         return earthquake_aux(cy, cx, r, 0);
2286 }
2287
2288 /*!
2289  * @brief ペット爆破処理 /
2290  * @return なし
2291  */
2292 void discharge_minion(void)
2293 {
2294         MONSTER_IDX i;
2295         bool okay = TRUE;
2296
2297         for (i = 1; i < m_max; i++)
2298         {
2299                 monster_type *m_ptr = &m_list[i];
2300                 if (!m_ptr->r_idx || !is_pet(m_ptr)) continue;
2301                 if (m_ptr->nickname) okay = FALSE;
2302         }
2303         if (!okay || p_ptr->riding)
2304         {
2305                 if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? ")))
2306                         return;
2307         }
2308         for (i = 1; i < m_max; i++)
2309         {
2310                 HIT_POINT dam;
2311                 monster_type *m_ptr = &m_list[i];
2312                 monster_race *r_ptr;
2313
2314                 if (!m_ptr->r_idx || !is_pet(m_ptr)) continue;
2315                 r_ptr = &r_info[m_ptr->r_idx];
2316
2317                 /* Uniques resist discharging */
2318                 if (r_ptr->flags1 & RF1_UNIQUE)
2319                 {
2320                         char m_name[80];
2321                         monster_desc(m_name, m_ptr, 0x00);
2322                         msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists to be blasted, and run away."), m_name);
2323                         delete_monster_idx(i);
2324                         continue;
2325                 }
2326                 dam = m_ptr->maxhp / 2;
2327                 if (dam > 100) dam = (dam-100)/2 + 100;
2328                 if (dam > 400) dam = (dam-400)/2 + 400;
2329                 if (dam > 800) dam = 800;
2330                 project(i, 2+(r_ptr->level/20), m_ptr->fy,
2331                         m_ptr->fx, dam, GF_PLASMA, 
2332                         PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
2333
2334                 if (record_named_pet && m_ptr->nickname)
2335                 {
2336                         char m_name[80];
2337
2338                         monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2339                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name);
2340                 }
2341
2342                 delete_monster_idx(i);
2343         }
2344 }
2345
2346
2347 /*!
2348  * @brief 部屋全体を照らすサブルーチン
2349  * @return なし
2350  * @details
2351  * <pre>
2352  * This routine clears the entire "temp" set.
2353  * This routine will Perma-Lite all "temp" grids.
2354  * This routine is used (only) by "lite_room()"
2355  * Dark grids are illuminated.
2356  * Also, process all affected monsters.
2357  *
2358  * SMART monsters always wake up when illuminated
2359  * NORMAL monsters wake up 1/4 the time when illuminated
2360  * STUPID monsters wake up 1/10 the time when illuminated
2361  * </pre>
2362  */
2363 static void cave_temp_room_lite(void)
2364 {
2365         int i;
2366
2367         /* Clear them all */
2368         for (i = 0; i < temp_n; i++)
2369         {
2370                 POSITION y = temp_y[i];
2371                 POSITION x = temp_x[i];
2372
2373                 cave_type *c_ptr = &cave[y][x];
2374
2375                 /* No longer in the array */
2376                 c_ptr->info &= ~(CAVE_TEMP);
2377
2378                 /* Update only non-CAVE_GLOW grids */
2379                 /* if (c_ptr->info & (CAVE_GLOW)) continue; */
2380
2381                 /* Perma-Lite */
2382                 c_ptr->info |= (CAVE_GLOW);
2383
2384                 /* Process affected monsters */
2385                 if (c_ptr->m_idx)
2386                 {
2387                         int chance = 25;
2388
2389                         monster_type    *m_ptr = &m_list[c_ptr->m_idx];
2390
2391                         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
2392
2393                         /* Update the monster */
2394                         update_mon(c_ptr->m_idx, FALSE);
2395
2396                         /* Stupid monsters rarely wake up */
2397                         if (r_ptr->flags2 & (RF2_STUPID)) chance = 10;
2398
2399                         /* Smart monsters always wake up */
2400                         if (r_ptr->flags2 & (RF2_SMART)) chance = 100;
2401
2402                         /* Sometimes monsters wake up */
2403                         if (MON_CSLEEP(m_ptr) && (randint0(100) < chance))
2404                         {
2405                                 /* Wake up! */
2406                                 (void)set_monster_csleep(c_ptr->m_idx, 0);
2407
2408                                 /* Notice the "waking up" */
2409                                 if (m_ptr->ml)
2410                                 {
2411                                         char m_name[80];
2412
2413                                         /* Acquire the monster name */
2414                                         monster_desc(m_name, m_ptr, 0);
2415
2416                                         /* Dump a message */
2417                                         msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
2418                                 }
2419                         }
2420                 }
2421
2422                 /* Note */
2423                 note_spot(y, x);
2424
2425                 /* Redraw */
2426                 lite_spot(y, x);
2427
2428                 update_local_illumination(y, x);
2429         }
2430
2431         /* None left */
2432         temp_n = 0;
2433 }
2434
2435
2436
2437 /*!
2438  * @brief 部屋全体を暗くするサブルーチン
2439  * @return なし
2440  * @details
2441  * <pre>
2442  * This routine clears the entire "temp" set.
2443  * This routine will "darken" all "temp" grids.
2444  * In addition, some of these grids will be "unmarked".
2445  * This routine is used (only) by "unlite_room()"
2446  * Also, process all affected monsters
2447  * </pre>
2448  */
2449 static void cave_temp_room_unlite(void)
2450 {
2451         int i;
2452
2453         /* Clear them all */
2454         for (i = 0; i < temp_n; i++)
2455         {
2456                 POSITION y = temp_y[i];
2457                 POSITION x = temp_x[i];
2458                 int j;
2459
2460                 cave_type *c_ptr = &cave[y][x];
2461                 bool do_dark = !is_mirror_grid(c_ptr);
2462
2463                 /* No longer in the array */
2464                 c_ptr->info &= ~(CAVE_TEMP);
2465
2466                 /* Darken the grid */
2467                 if (do_dark)
2468                 {
2469                         if (dun_level || !is_daytime())
2470                         {
2471                                 for (j = 0; j < 9; j++)
2472                                 {
2473                                         int by = y + ddy_ddd[j];
2474                                         int bx = x + ddx_ddd[j];
2475
2476                                         if (in_bounds2(by, bx))
2477                                         {
2478                                                 cave_type *cc_ptr = &cave[by][bx];
2479
2480                                                 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
2481                                                 {
2482                                                         do_dark = FALSE;
2483                                                         break;
2484                                                 }
2485                                         }
2486                                 }
2487
2488                                 if (!do_dark) continue;
2489                         }
2490
2491                         c_ptr->info &= ~(CAVE_GLOW);
2492
2493                         /* Hack -- Forget "boring" grids */
2494                         if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_REMEMBER))
2495                         {
2496                                 /* Forget the grid */
2497                                 if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
2498
2499                                 /* Notice */
2500                                 note_spot(y, x);
2501                         }
2502
2503                         /* Process affected monsters */
2504                         if (c_ptr->m_idx)
2505                         {
2506                                 /* Update the monster */
2507                                 update_mon(c_ptr->m_idx, FALSE);
2508                         }
2509
2510                         /* Redraw */
2511                         lite_spot(y, x);
2512
2513                         update_local_illumination(y, x);
2514                 }
2515         }
2516
2517         /* None left */
2518         temp_n = 0;
2519 }
2520
2521
2522 /*!
2523  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2524  * @param cy Y座標
2525  * @param cx X座標
2526  * @param pass_bold 地形条件を返す関数ポインタ
2527  * @return 該当地形の数
2528  */
2529 static int next_to_open(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2530 {
2531         int i;
2532         POSITION y, x;
2533         int len = 0;
2534         int blen = 0;
2535
2536         for (i = 0; i < 16; i++)
2537         {
2538                 y = cy + ddy_cdd[i % 8];
2539                 x = cx + ddx_cdd[i % 8];
2540
2541                 /* Found a wall, break the length */
2542                 if (!pass_bold(y, x))
2543                 {
2544                         /* Track best length */
2545                         if (len > blen)
2546                         {
2547                                 blen = len;
2548                         }
2549
2550                         len = 0;
2551                 }
2552                 else
2553                 {
2554                         len++;
2555                 }
2556         }
2557
2558         return (MAX(len, blen));
2559 }
2560
2561 /*!
2562  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2563  * @param cy Y座標
2564  * @param cx X座標
2565  * @param pass_bold 地形条件を返す関数ポインタ
2566  * @return 該当地形の数
2567  */
2568 static int next_to_walls_adj(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2569 {
2570         DIRECTION i;
2571         POSITION y, x;
2572         int c = 0;
2573
2574         for (i = 0; i < 8; i++)
2575         {
2576                 y = cy + ddy_ddd[i];
2577                 x = cx + ddx_ddd[i];
2578
2579                 if (!pass_bold(y, x)) c++;
2580         }
2581
2582         return c;
2583 }
2584
2585
2586 /*!
2587  * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数temp_nに返す / Aux function -- see below
2588  * @param y 部屋内のy座標1点
2589  * @param x 部屋内のx座標1点
2590  * @param only_room 部屋内地形のみをチェック対象にするならば TRUE
2591  * @param pass_bold 地形条件を返す関数ポインタ
2592  * @return 該当地形の数
2593  */
2594 static void cave_temp_room_aux(POSITION y, POSITION x, bool only_room, bool (*pass_bold)(POSITION, POSITION))
2595 {
2596         cave_type *c_ptr;
2597
2598         /* Get the grid */
2599         c_ptr = &cave[y][x];
2600
2601         /* Avoid infinite recursion */
2602         if (c_ptr->info & (CAVE_TEMP)) return;
2603
2604         /* Do not "leave" the current room */
2605         if (!(c_ptr->info & (CAVE_ROOM)))
2606         {
2607                 if (only_room) return;
2608
2609                 /* Verify */
2610                 if (!in_bounds2(y, x)) return;
2611
2612                 /* Do not exceed the maximum spell range */
2613                 if (distance(p_ptr->y, p_ptr->x, y, x) > MAX_RANGE) return;
2614
2615                 /* Verify this grid */
2616                 /*
2617                  * The reason why it is ==6 instead of >5 is that 8 is impossible
2618                  * due to the check for cave_bold above.
2619                  * 7 lights dead-end corridors (you need to do this for the
2620                  * checkboard interesting rooms, so that the boundary is lit
2621                  * properly.
2622                  * This leaves only a check for 6 bounding walls!
2623                  */
2624                 if (in_bounds(y, x) && pass_bold(y, x) &&
2625                     (next_to_walls_adj(y, x, pass_bold) == 6) && (next_to_open(y, x, pass_bold) <= 1)) return;
2626         }
2627
2628         /* Paranoia -- verify space */
2629         if (temp_n == TEMP_MAX) return;
2630
2631         /* Mark the grid as "seen" */
2632         c_ptr->info |= (CAVE_TEMP);
2633
2634         /* Add it to the "seen" set */
2635         temp_y[temp_n] = y;
2636         temp_x[temp_n] = x;
2637         temp_n++;
2638 }
2639
2640 /*!
2641  * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
2642  * @param y 指定Y座標
2643  * @param x 指定X座標
2644  * @return 光を通すならばtrueを返す。
2645  */
2646 static bool cave_pass_lite_bold(POSITION y, POSITION x)
2647 {
2648         return cave_los_bold(y, x);
2649 }
2650
2651 /*!
2652  * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数temp_nに返す / Aux function -- see below
2653  * @param y 指定Y座標
2654  * @param x 指定X座標
2655  * @return なし
2656  */
2657 static void cave_temp_lite_room_aux(POSITION y, POSITION x)
2658 {
2659         cave_temp_room_aux(y, x, FALSE, cave_pass_lite_bold);
2660 }
2661
2662 /*!
2663  * @brief 指定のマスが光を通さず射線のみを通すかを返す。 / Aux function -- see below
2664  * @param y 指定Y座標
2665  * @param x 指定X座標
2666  * @return 射線を通すならばtrueを返す。
2667  */
2668 static bool cave_pass_dark_bold(POSITION y, POSITION x)
2669 {
2670         return cave_have_flag_bold(y, x, FF_PROJECT);
2671 }
2672
2673
2674 /*!
2675  * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数temp_nに返す / Aux function -- see below
2676  * @param y 指定Y座標
2677  * @param x 指定X座標
2678  * @return なし
2679  */
2680 static void cave_temp_unlite_room_aux(POSITION y, POSITION x)
2681 {
2682         cave_temp_room_aux(y, x, TRUE, cave_pass_dark_bold);
2683 }
2684
2685
2686 /*!
2687  * @brief 指定された部屋内を照らす / Illuminate any room containing the given location.
2688  * @param y1 指定Y座標
2689  * @param x1 指定X座標
2690  * @return なし
2691  */
2692 void lite_room(POSITION y1, POSITION x1)
2693 {
2694         int i;
2695         POSITION x, y;
2696
2697         /* Add the initial grid */
2698         cave_temp_lite_room_aux(y1, x1);
2699
2700         /* While grids are in the queue, add their neighbors */
2701         for (i = 0; i < temp_n; i++)
2702         {
2703                 x = temp_x[i], y = temp_y[i];
2704
2705                 /* Walls get lit, but stop light */
2706                 if (!cave_pass_lite_bold(y, x)) continue;
2707
2708                 /* Spread adjacent */
2709                 cave_temp_lite_room_aux(y + 1, x);
2710                 cave_temp_lite_room_aux(y - 1, x);
2711                 cave_temp_lite_room_aux(y, x + 1);
2712                 cave_temp_lite_room_aux(y, x - 1);
2713
2714                 /* Spread diagonal */
2715                 cave_temp_lite_room_aux(y + 1, x + 1);
2716                 cave_temp_lite_room_aux(y - 1, x - 1);
2717                 cave_temp_lite_room_aux(y - 1, x + 1);
2718                 cave_temp_lite_room_aux(y + 1, x - 1);
2719         }
2720
2721         /* Now, lite them all up at once */
2722         cave_temp_room_lite();
2723
2724         if (p_ptr->special_defense & NINJA_S_STEALTH)
2725         {
2726                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
2727         }
2728 }
2729
2730
2731 /*!
2732  * @brief 指定された部屋内を暗くする / Darken all rooms containing the given location
2733  * @param y1 指定Y座標
2734  * @param x1 指定X座標
2735  * @return なし
2736  */
2737 void unlite_room(POSITION y1, POSITION x1)
2738 {
2739         int i;
2740         POSITION x, y;
2741
2742         /* Add the initial grid */
2743         cave_temp_unlite_room_aux(y1, x1);
2744
2745         /* Spread, breadth first */
2746         for (i = 0; i < temp_n; i++)
2747         {
2748                 x = temp_x[i], y = temp_y[i];
2749
2750                 /* Walls get dark, but stop darkness */
2751                 if (!cave_pass_dark_bold(y, x)) continue;
2752
2753                 /* Spread adjacent */
2754                 cave_temp_unlite_room_aux(y + 1, x);
2755                 cave_temp_unlite_room_aux(y - 1, x);
2756                 cave_temp_unlite_room_aux(y, x + 1);
2757                 cave_temp_unlite_room_aux(y, x - 1);
2758
2759                 /* Spread diagonal */
2760                 cave_temp_unlite_room_aux(y + 1, x + 1);
2761                 cave_temp_unlite_room_aux(y - 1, x - 1);
2762                 cave_temp_unlite_room_aux(y - 1, x + 1);
2763                 cave_temp_unlite_room_aux(y + 1, x - 1);
2764         }
2765
2766         /* Now, darken them all at once */
2767         cave_temp_room_unlite();
2768 }
2769
2770
2771
2772 /*!
2773  * @brief プレイヤー位置を中心にLITE_WEAK属性を通じた照明処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2774  * @param dam 威力
2775  * @param rad 効果半径
2776  * @return 作用が実際にあった場合TRUEを返す
2777  */
2778 bool lite_area(HIT_POINT dam, POSITION rad)
2779 {
2780         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2781
2782         if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
2783         {
2784                 msg_print(_("ダンジョンが光を吸収した。", "The darkness of this dungeon absorb your light."));
2785                 return FALSE;
2786         }
2787
2788         /* Hack -- Message */
2789         if (!p_ptr->blind)
2790         {
2791                 msg_print(_("白い光が辺りを覆った。", "You are surrounded by a white light."));
2792         }
2793
2794         /* Hook into the "project()" function */
2795         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_LITE_WEAK, flg, -1);
2796
2797         /* Lite up the room */
2798         lite_room(p_ptr->y, p_ptr->x);
2799
2800         /* Assume seen */
2801         return (TRUE);
2802 }
2803
2804
2805 /*!
2806  * @brief プレイヤー位置を中心にLITE_DARK属性を通じた消灯処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2807  * @param dam 威力
2808  * @param rad 効果半径
2809  * @return 作用が実際にあった場合TRUEを返す
2810  */
2811 bool unlite_area(HIT_POINT dam, POSITION rad)
2812 {
2813         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2814
2815         /* Hack -- Message */
2816         if (!p_ptr->blind)
2817         {
2818                 msg_print(_("暗闇が辺りを覆った。", "Darkness surrounds you."));
2819         }
2820
2821         /* Hook into the "project()" function */
2822         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_DARK_WEAK, flg, -1);
2823
2824         /* Lite up the room */
2825         unlite_room(p_ptr->y, p_ptr->x);
2826
2827         /* Assume seen */
2828         return (TRUE);
2829 }
2830
2831
2832
2833 /*!
2834  * @brief ボール系スペルの発動 / Cast a ball spell
2835  * @param typ 効果属性
2836  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2837  * @param dam 威力
2838  * @param rad 半径
2839  * @return 作用が実際にあった場合TRUEを返す
2840  * @details
2841  * <pre>
2842  * Stop if we hit a monster, act as a "ball"
2843  * Allow "target" mode to pass over monsters
2844  * Affect grids, objects, and monsters
2845  * </pre>
2846  */
2847 bool fire_ball(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2848 {
2849         POSITION tx, ty;
2850
2851         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2852
2853         if (typ == GF_CHARM_LIVING) flg|= PROJECT_HIDE;
2854         /* Use the given direction */
2855         tx = p_ptr->x + 99 * ddx[dir];
2856         ty = p_ptr->y + 99 * ddy[dir];
2857
2858         /* Hack -- Use an actual "target" */
2859         if ((dir == 5) && target_okay())
2860         {
2861                 flg &= ~(PROJECT_STOP);
2862                 tx = target_col;
2863                 ty = target_row;
2864         }
2865
2866         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2867         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2868 }
2869
2870 /*!
2871 * @brief ブレス系スペルの発動 / Cast a breath spell
2872 * @param typ 効果属性
2873 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2874 * @param dam 威力
2875 * @param rad 半径
2876 * @return 作用が実際にあった場合TRUEを返す
2877 * @details
2878 * <pre>
2879 * Stop if we hit a monster, act as a "ball"
2880 * Allow "target" mode to pass over monsters
2881 * Affect grids, objects, and monsters
2882 * </pre>
2883 */
2884 bool fire_breath(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2885 {
2886         return fire_ball(typ, dir, dam, -rad);
2887 }
2888
2889
2890 /*!
2891  * @brief ロケット系スペルの発動(詳細な差は確認中) / Cast a ball 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_rocket(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2905 {
2906         POSITION tx, ty;
2907         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2908
2909         /* Use the given direction */
2910         tx = p_ptr->x + 99 * ddx[dir];
2911         ty = p_ptr->y + 99 * ddy[dir];
2912
2913         /* Hack -- Use an actual "target" */
2914         if ((dir == 5) && target_okay())
2915         {
2916                 tx = target_col;
2917                 ty = target_row;
2918         }
2919
2920         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2921         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2922 }
2923
2924
2925 /*!
2926  * @brief ボール(ハイド)系スペルの発動 / Cast a ball spell
2927  * @param typ 効果属性
2928  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2929  * @param dam 威力
2930  * @param rad 半径
2931  * @return 作用が実際にあった場合TRUEを返す
2932  * @details
2933  * <pre>
2934  * Stop if we hit a monster, act as a "ball"
2935  * Allow "target" mode to pass over monsters
2936  * Affect grids, objects, and monsters
2937  * </pre>
2938  */
2939 bool fire_ball_hide(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2940 {
2941         POSITION tx, ty;
2942         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE;
2943
2944         /* Use the given direction */
2945         tx = p_ptr->x + 99 * ddx[dir];
2946         ty = p_ptr->y + 99 * ddy[dir];
2947
2948         /* Hack -- Use an actual "target" */
2949         if ((dir == 5) && target_okay())
2950         {
2951                 flg &= ~(PROJECT_STOP);
2952                 tx = target_col;
2953                 ty = target_row;
2954         }
2955
2956         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2957         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2958 }
2959
2960
2961 /*!
2962  * @brief メテオ系スペルの発動 / Cast a meteor spell
2963  * @param who スぺル詠唱者のモンスターID(0=プレイヤー)
2964  * @param typ 効果属性
2965  * @param dam 威力
2966  * @param rad 半径
2967  * @param y 中心点Y座標
2968  * @param x 中心点X座標
2969  * @return 作用が実際にあった場合TRUEを返す
2970  * @details
2971  * <pre>
2972  * Cast a meteor spell, defined as a ball spell cast by an arbitary monster, 
2973  * player, or outside source, that starts out at an arbitrary location, and 
2974  * leaving no trail from the "caster" to the target.  This function is 
2975  * especially useful for bombardments and similar. -LM-
2976  * Option to hurt the player.
2977  * </pre>
2978  */
2979 bool fire_meteor(MONSTER_IDX who, EFFECT_ID typ, POSITION y, POSITION x, HIT_POINT dam, POSITION rad)
2980 {
2981         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2982
2983         /* Analyze the "target" and the caster. */
2984         return (project(who, rad, y, x, dam, typ, flg, -1));
2985 }
2986
2987
2988 /*!
2989  * @brief ブラスト系スペルの発動 / Cast a blast spell
2990  * @param typ 効果属性
2991  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2992  * @param dd 威力ダイス数
2993  * @param ds 威力ダイス目
2994  * @param num 基本回数
2995  * @param dev 回数分散
2996  * @return 作用が実際にあった場合TRUEを返す
2997  */
2998 bool fire_blast(EFFECT_ID typ, DIRECTION dir, int dd, int ds, int num, int dev)
2999 {
3000         POSITION ly, lx;
3001         int ld;
3002         POSITION ty, tx, y, x;
3003         int i;
3004
3005         BIT_FLAGS flg = PROJECT_FAST | PROJECT_THRU | PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE | PROJECT_GRID;
3006
3007         /* Assume okay */
3008         bool result = TRUE;
3009
3010         /* Use the given direction */
3011         if (dir != 5)
3012         {
3013                 ly = ty = p_ptr->y + 20 * ddy[dir];
3014                 lx = tx = p_ptr->x + 20 * ddx[dir];
3015         }
3016
3017         /* Use an actual "target" */
3018         else /* if (dir == 5) */
3019         {
3020                 tx = target_col;
3021                 ty = target_row;
3022
3023                 lx = 20 * (tx - p_ptr->x) + p_ptr->x;
3024                 ly = 20 * (ty - p_ptr->y) + p_ptr->y;
3025         }
3026
3027         ld = distance(p_ptr->y, p_ptr->x, ly, lx);
3028
3029         /* Blast */
3030         for (i = 0; i < num; i++)
3031         {
3032                 while (1)
3033                 {
3034                         /* Get targets for some bolts */
3035                         y = rand_spread(ly, ld * dev / 20);
3036                         x = rand_spread(lx, ld * dev / 20);
3037
3038                         if (distance(ly, lx, y, x) <= ld * dev / 20) break;
3039                 }
3040
3041                 /* Analyze the "dir" and the "target". */
3042                 if (!project(0, 0, y, x, damroll(dd, ds), typ, flg, -1))
3043                 {
3044                         result = FALSE;
3045                 }
3046         }
3047
3048         return (result);
3049 }
3050
3051
3052 /*!
3053  * @brief モンスターとの位置交換処理 / Switch position with a monster.
3054  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3055  * @return 作用が実際にあった場合TRUEを返す
3056  */
3057 bool teleport_swap(DIRECTION dir)
3058 {
3059         POSITION tx, ty;
3060         cave_type* c_ptr;
3061         monster_type* m_ptr;
3062         monster_race* r_ptr;
3063
3064         if ((dir == 5) && target_okay())
3065         {
3066                 tx = target_col;
3067                 ty = target_row;
3068         }
3069         else
3070         {
3071                 tx = p_ptr->x + ddx[dir];
3072                 ty = p_ptr->y + ddy[dir];
3073         }
3074         c_ptr = &cave[ty][tx];
3075
3076         if (p_ptr->anti_tele)
3077         {
3078                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
3079                 return FALSE;
3080         }
3081
3082         if (!c_ptr->m_idx || (c_ptr->m_idx == p_ptr->riding))
3083         {
3084                 msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
3085
3086                 /* Failure */
3087                 return FALSE;
3088         }
3089
3090         if ((c_ptr->info & CAVE_ICKY) || (distance(ty, tx, p_ptr->y, p_ptr->x) > p_ptr->lev * 3 / 2 + 10))
3091         {
3092                 msg_print(_("失敗した。", "Failed to swap."));
3093
3094                 /* Failure */
3095                 return FALSE;
3096         }
3097
3098         m_ptr = &m_list[c_ptr->m_idx];
3099         r_ptr = &r_info[m_ptr->r_idx];
3100
3101         (void)set_monster_csleep(c_ptr->m_idx, 0);
3102
3103         if (r_ptr->flagsr & RFR_RES_TELE)
3104         {
3105                 msg_print(_("テレポートを邪魔された!", "Your teleportation is blocked!"));
3106
3107                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3108
3109                 /* Failure */
3110                 return FALSE;
3111         }
3112
3113         sound(SOUND_TELEPORT);
3114
3115         /* Swap the player and monster */
3116         (void)move_player_effect(ty, tx, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
3117
3118         /* Success */
3119         return TRUE;
3120 }
3121
3122
3123 /*!
3124  * @brief 指定方向に飛び道具を飛ばす(フラグ任意指定) / Hack -- apply a "projection()" in a direction (or at the target)
3125  * @param typ 効果属性
3126  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3127  * @param dam 威力
3128  * @param flg フラグ
3129  * @return 作用が実際にあった場合TRUEを返す
3130  */
3131 bool project_hook(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, BIT_FLAGS flg)
3132 {
3133         int tx, ty;
3134
3135         /* Pass through the target if needed */
3136         flg |= (PROJECT_THRU);
3137
3138         /* Use the given direction */
3139         tx = p_ptr->x + ddx[dir];
3140         ty = p_ptr->y + ddy[dir];
3141
3142         /* Hack -- Use an actual "target" */
3143         if ((dir == 5) && target_okay())
3144         {
3145                 tx = target_col;
3146                 ty = target_row;
3147         }
3148
3149         /* Analyze the "dir" and the "target", do NOT explode */
3150         return (project(0, 0, ty, tx, dam, typ, flg, -1));
3151 }
3152
3153
3154 /*!
3155  * @brief ボルト系スペルの発動 / Cast a bolt spell.
3156  * @param typ 効果属性
3157  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3158  * @param dam 威力
3159  * @return 作用が実際にあった場合TRUEを返す
3160  * @details
3161  * <pre>
3162  * Stop if we hit a monster, as a "bolt".
3163  * Affect monsters and grids (not objects).
3164  * </pre>
3165  */
3166 bool fire_bolt(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3167 {
3168         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_GRID;
3169         if (typ != GF_ARROW) flg |= PROJECT_REFLECTABLE;
3170         return (project_hook(typ, dir, dam, flg));
3171 }
3172
3173
3174 /*!
3175  * @brief ビーム系スペルの発動 / Cast a beam spell.
3176  * @param typ 効果属性
3177  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3178  * @param dam 威力
3179  * @return 作用が実際にあった場合TRUEを返す
3180  * @details
3181  * <pre>
3182  * Pass through monsters, as a "beam".
3183  * Affect monsters, grids and objects.
3184  * </pre>
3185  */
3186 bool fire_beam(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3187 {
3188         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM;
3189         return (project_hook(typ, dir, dam, flg));
3190 }
3191
3192
3193 /*!
3194  * @brief 確率に応じたボルト系/ビーム系スペルの発動 / Cast a bolt spell, or rarely, a beam spell.
3195  * @param prob ビーム化する確率(%)
3196  * @param typ 効果属性
3197  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3198  * @param dam 威力
3199  * @return 作用が実際にあった場合TRUEを返す
3200  * @details
3201  * <pre>
3202  * Pass through monsters, as a "beam".
3203  * Affect monsters, grids and objects.
3204  * </pre>
3205  */
3206 bool fire_bolt_or_beam(PERCENTAGE prob, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3207 {
3208         if (randint0(100) < prob)
3209         {
3210                 return (fire_beam(typ, dir, dam));
3211         }
3212         else
3213         {
3214                 return (fire_bolt(typ, dir, dam));
3215         }
3216 }
3217
3218 /*!
3219  * @brief LITE_WEAK属性による光源ビーム処理
3220  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3221  * @param dam 威力
3222  * @return 作用が実際にあった場合TRUEを返す
3223  */
3224 bool lite_line(DIRECTION dir, HIT_POINT dam)
3225 {
3226         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_KILL;
3227         return (project_hook(GF_LITE_WEAK, dir, dam, flg));
3228 }
3229
3230 /*!
3231  * @brief 衰弱ボルト処理
3232  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3233  * @param dam 威力
3234  * @return 作用が実際にあった場合TRUEを返す
3235  */
3236 bool hypodynamic_bolt(DIRECTION dir, HIT_POINT dam)
3237 {
3238         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3239         return (project_hook(GF_HYPODYNAMIA, dir, dam, flg));
3240 }
3241
3242 /*!
3243  * @brief 岩石溶解処理
3244  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3245  * @param dam 威力
3246  * @return 作用が実際にあった場合TRUEを返す
3247  */
3248 bool wall_to_mud(DIRECTION dir, HIT_POINT dam)
3249 {
3250         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3251         return (project_hook(GF_KILL_WALL, dir, dam, flg));
3252 }
3253
3254 /*!
3255  * @brief 魔法の施錠処理
3256  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3257  * @return 作用が実際にあった場合TRUEを返す
3258  */
3259 bool wizard_lock(DIRECTION dir)
3260 {
3261         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3262         return (project_hook(GF_JAM_DOOR, dir, 20 + randint1(30), flg));
3263 }
3264
3265 /*!
3266  * @brief ドア破壊処理
3267  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3268  * @return 作用が実際にあった場合TRUEを返す
3269  */
3270 bool destroy_door(DIRECTION dir)
3271 {
3272         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3273         return (project_hook(GF_KILL_DOOR, dir, 0, flg));
3274 }
3275
3276 /*!
3277  * @brief トラップ解除処理
3278  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3279  * @return 作用が実際にあった場合TRUEを返す
3280  */
3281 bool disarm_trap(DIRECTION dir)
3282 {
3283         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3284         return (project_hook(GF_KILL_TRAP, dir, 0, flg));
3285 }
3286
3287 /*!
3288  * @brief モンスター回復処理
3289  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3290  * @param dam 威力
3291  * @return 作用が実際にあった場合TRUEを返す
3292  */
3293 bool heal_monster(DIRECTION dir, HIT_POINT dam)
3294 {
3295         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3296         return (project_hook(GF_OLD_HEAL, dir, dam, flg));
3297 }
3298
3299 /*!
3300  * @brief モンスター加速処理
3301  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3302  * @param power 効力
3303  * @return 作用が実際にあった場合TRUEを返す
3304  */
3305 bool speed_monster(DIRECTION dir, int power)
3306 {
3307         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3308         return (project_hook(GF_OLD_SPEED, dir, power, flg));
3309 }
3310
3311 /*!
3312  * @brief モンスター減速処理
3313  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3314  * @param power 効力
3315  * @return 作用が実際にあった場合TRUEを返す
3316  */
3317 bool slow_monster(DIRECTION dir, int power)
3318 {
3319         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3320         return (project_hook(GF_OLD_SLOW, dir, power, flg));
3321 }
3322
3323 /*!
3324  * @brief モンスター催眠処理
3325  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3326  * @param power 効力
3327  * @return 作用が実際にあった場合TRUEを返す
3328  */
3329 bool sleep_monster(DIRECTION dir, int power)
3330 {
3331         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3332         return (project_hook(GF_OLD_SLEEP, dir, power, flg));
3333 }
3334
3335 /*!
3336  * @brief モンスター拘束(STASIS)処理
3337  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3338  * @return 作用が実際にあった場合TRUEを返す
3339  * @details 威力はプレイヤーレベル*2に固定
3340  */
3341 bool stasis_monster(DIRECTION dir)
3342 {
3343         return (fire_ball_hide(GF_STASIS, dir, p_ptr->lev*2, 0));
3344 }
3345
3346 /*!
3347  * @brief 邪悪なモンスター拘束(STASIS)処理
3348  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3349  * @return 作用が実際にあった場合TRUEを返す
3350  * @details 威力はプレイヤーレベル*2に固定
3351  */
3352 bool stasis_evil(DIRECTION dir)
3353 {
3354         return (fire_ball_hide(GF_STASIS_EVIL, dir, p_ptr->lev*2, 0));
3355 }
3356
3357 /*!
3358  * @brief モンスター混乱処理
3359  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3360  * @param plev プレイヤーレベル(=効力)
3361  * @return 作用が実際にあった場合TRUEを返す
3362  */
3363 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
3364 {
3365         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3366         return (project_hook(GF_OLD_CONF, dir, plev, flg));
3367 }
3368
3369 /*!
3370  * @brief モンスター朦朧処理
3371  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3372  * @param plev プレイヤーレベル(=効力)
3373  * @return 作用が実際にあった場合TRUEを返す
3374  */
3375 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
3376 {
3377         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3378         return (project_hook(GF_STUN, dir, plev, flg));
3379 }
3380
3381 /*!
3382  * @brief チェンジモンスター処理
3383  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3384  * @param power 効力
3385  * @return 作用が実際にあった場合TRUEを返す
3386  */
3387 bool poly_monster(DIRECTION dir, int power)
3388 {
3389         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3390         bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
3391         if (tester)
3392                 chg_virtue(V_CHANCE, 1);
3393         return(tester);
3394 }
3395
3396 /*!
3397  * @brief クローンモンスター処理
3398  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3399  * @return 作用が実際にあった場合TRUEを返す
3400  */
3401 bool clone_monster(DIRECTION dir)
3402 {
3403         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3404         return (project_hook(GF_OLD_CLONE, dir, 0, flg));
3405 }
3406
3407 /*!
3408  * @brief モンスター恐慌処理
3409  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3410  * @param plev プレイヤーレベル(=効力)
3411  * @return 作用が実際にあった場合TRUEを返す
3412  */
3413 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
3414 {
3415         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3416         return (project_hook(GF_TURN_ALL, dir, plev, flg));
3417 }
3418
3419 /*!
3420  * @brief 死の光線処理
3421  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3422  * @param plev プレイヤーレベル(効力はplev*200)
3423  * @return 作用が実際にあった場合TRUEを返す
3424  */
3425 bool death_ray(DIRECTION dir, PLAYER_LEVEL plev)
3426 {
3427         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3428         return (project_hook(GF_DEATH_RAY, dir, plev * 200, flg));
3429 }
3430
3431 /*!
3432  * @brief モンスター用テレポート処理
3433  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3434  * @param distance 移動距離
3435  * @return 作用が実際にあった場合TRUEを返す
3436  */
3437 bool teleport_monster(DIRECTION dir, int distance)
3438 {
3439         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL;
3440         return (project_hook(GF_AWAY_ALL, dir, distance, flg));
3441 }
3442
3443 /*!
3444  * @brief ドア生成処理(プレイヤー中心に周囲1マス) / Hooks -- affect adjacent grids (radius 1 ball attack)
3445  * @return 作用が実際にあった場合TRUEを返す
3446  */
3447 bool door_creation(void)
3448 {
3449         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3450         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_DOOR, flg, -1));
3451 }
3452
3453 /*!
3454  * @brief トラップ生成処理(起点から周囲1マス)
3455  * @param y 起点Y座標
3456  * @param x 起点X座標
3457  * @return 作用が実際にあった場合TRUEを返す
3458  */
3459 bool trap_creation(POSITION y, POSITION x)
3460 {
3461         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3462         return (project(0, 1, y, x, 0, GF_MAKE_TRAP, flg, -1));
3463 }
3464
3465 /*!
3466  * @brief 森林生成処理(プレイヤー中心に周囲1マス)
3467  * @return 作用が実際にあった場合TRUEを返す
3468  */
3469 bool tree_creation(void)
3470 {
3471         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3472         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_TREE, flg, -1));
3473 }
3474
3475 /*!
3476  * @brief 魔法のルーン生成処理(プレイヤー中心に周囲1マス)
3477  * @return 作用が実際にあった場合TRUEを返す
3478  */
3479 bool glyph_creation(void)
3480 {
3481         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM;
3482         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_GLYPH, flg, -1));
3483 }
3484
3485 /*!
3486  * @brief 壁生成処理(プレイヤー中心に周囲1マス)
3487  * @return 作用が実際にあった場合TRUEを返す
3488  */
3489 bool wall_stone(void)
3490 {
3491         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3492
3493         bool dummy = (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_STONE_WALL, flg, -1));
3494
3495         /* Update stuff */
3496         p_ptr->update |= (PU_FLOW);
3497
3498         /* Redraw map */
3499         p_ptr->redraw |= (PR_MAP);
3500
3501         return dummy;
3502 }
3503
3504 /*!
3505  * @brief ドア破壊処理(プレイヤー中心に周囲1マス)
3506  * @return 作用が実際にあった場合TRUEを返す
3507  */
3508 bool destroy_doors_touch(void)
3509 {
3510         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3511         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_DOOR, flg, -1));
3512 }
3513
3514 /*!
3515  * @brief トラップ解除処理(プレイヤー中心に周囲1マス)
3516  * @return 作用が実際にあった場合TRUEを返す
3517  */
3518 bool disarm_traps_touch(void)
3519 {
3520         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3521         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_TRAP, flg, -1));
3522 }
3523
3524 /*!
3525  * @brief スリープモンスター処理(プレイヤー中心に周囲1マス)
3526  * @return 作用が実際にあった場合TRUEを返す
3527  */
3528 bool sleep_monsters_touch(void)
3529 {
3530         BIT_FLAGS flg = PROJECT_KILL | PROJECT_HIDE;
3531         return (project(0, 1, p_ptr->y, p_ptr->x, p_ptr->lev, GF_OLD_SLEEP, flg, -1));
3532 }
3533
3534
3535 /*!
3536  * @brief 死者復活処理(起点より周囲5マス)
3537  * @param who 術者モンスターID(0ならばプレイヤー)
3538  * @param y 起点Y座標
3539  * @param x 起点X座標
3540  * @return 作用が実際にあった場合TRUEを返す
3541  */
3542 bool animate_dead(MONSTER_IDX who, POSITION y, POSITION x)
3543 {
3544         BIT_FLAGS flg = PROJECT_ITEM | PROJECT_HIDE;
3545         return (project(who, 5, y, x, 0, GF_ANIM_DEAD, flg, -1));
3546 }
3547
3548 /*!
3549  * @brief 混沌招来処理
3550  * @return 作用が実際にあった場合TRUEを返す
3551  */
3552 void call_chaos(void)
3553 {
3554         int Chaos_type, dummy, dir;
3555         PLAYER_LEVEL plev = p_ptr->lev;
3556         bool line_chaos = FALSE;
3557
3558         int hurt_types[31] =
3559         {
3560                 GF_ELEC,      GF_POIS,    GF_ACID,    GF_COLD,
3561                 GF_FIRE,      GF_MISSILE, GF_ARROW,   GF_PLASMA,
3562                 GF_HOLY_FIRE, GF_WATER,   GF_LITE,    GF_DARK,
3563                 GF_FORCE,     GF_INERTIAL, GF_MANA,    GF_METEOR,
3564                 GF_ICE,       GF_CHAOS,   GF_NETHER,  GF_DISENCHANT,
3565                 GF_SHARDS,    GF_SOUND,   GF_NEXUS,   GF_CONFUSION,
3566                 GF_TIME,      GF_GRAVITY, GF_ROCKET,  GF_NUKE,
3567                 GF_HELL_FIRE, GF_DISINTEGRATE, GF_PSY_SPEAR
3568         };
3569
3570         Chaos_type = hurt_types[randint0(31)];
3571         if (one_in_(4)) line_chaos = TRUE;
3572
3573         if (one_in_(6))
3574         {
3575                 for (dummy = 1; dummy < 10; dummy++)
3576                 {
3577                         if (dummy - 5)
3578                         {
3579                                 if (line_chaos)
3580                                         fire_beam(Chaos_type, dummy, 150);
3581                                 else
3582                                         fire_ball(Chaos_type, dummy, 150, 2);
3583                         }
3584                 }
3585         }
3586         else if (one_in_(3))
3587         {
3588                 fire_ball(Chaos_type, 0, 500, 8);
3589         }
3590         else
3591         {
3592                 if (!get_aim_dir(&dir)) return;
3593                 if (line_chaos)
3594                         fire_beam(Chaos_type, dir, 250);
3595                 else
3596                         fire_ball(Chaos_type, dir, 250, 3 + (plev / 35));
3597         }
3598 }
3599
3600 /*!
3601  * @brief TY_CURSE処理発動 / Activate the evil Topi Ylinen curse
3602  * @param stop_ty 再帰処理停止フラグ
3603  * @param count 発動回数
3604  * @return 作用が実際にあった場合TRUEを返す
3605  * @details
3606  * <pre>
3607  * rr9: Stop the nasty things when a Cyberdemon is summoned
3608  * or the player gets paralyzed.
3609  * </pre>
3610  */
3611 bool activate_ty_curse(bool stop_ty, int *count)
3612 {
3613         int     i = 0;
3614
3615         BIT_FLAGS flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3616
3617         do
3618         {
3619                 switch (randint1(34))
3620                 {
3621                 case 28: case 29:
3622                         if (!(*count))
3623                         {
3624                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
3625                                 earthquake(p_ptr->y, p_ptr->x, 5 + randint0(10));
3626                                 if (!one_in_(6)) break;
3627                         }
3628                 case 30: case 31:
3629                         if (!(*count))
3630                         {
3631                                 HIT_POINT dam = damroll(10, 10);
3632                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3633                                 project(0, 8, p_ptr->y, p_ptr->x, dam, GF_MANA, flg, -1);
3634                                 take_hit(DAMAGE_NOESCAPE, dam, _("純粋な魔力の解放", "released pure mana"), -1);
3635                                 if (!one_in_(6)) break;
3636                         }
3637                 case 32: case 33:
3638                         if (!(*count))
3639                         {
3640                                 msg_print(_("周囲の空間が歪んだ!", "Space warps about you!"));
3641                                 teleport_player(damroll(10, 10), TELEPORT_PASSIVE);
3642                                 if (randint0(13)) (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3643                                 if (!one_in_(6)) break;
3644                         }
3645                 case 34:
3646                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3647                         wall_breaker();
3648                         if (!randint0(7))
3649                         {
3650                                 project(0, 7, p_ptr->y, p_ptr->x, 50, GF_KILL_WALL, flg, -1);
3651                                 take_hit(DAMAGE_NOESCAPE, 50, _("エネルギーのうねり", "surge of energy"), -1);
3652                         }
3653                         if (!one_in_(6)) break;
3654                 case 1: case 2: case 3: case 16: case 17:
3655                         aggravate_monsters(0);
3656                         if (!one_in_(6)) break;
3657                 case 4: case 5: case 6:
3658                         (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3659                         if (!one_in_(6)) break;
3660                 case 7: case 8: case 9: case 18:
3661                         (*count) += summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
3662                         if (!one_in_(6)) break;
3663                 case 10: case 11: case 12:
3664                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3665                         lose_exp(p_ptr->exp / 16);
3666                         if (!one_in_(6)) break;
3667                 case 13: case 14: case 15: case 19: case 20:
3668                         if (stop_ty || (p_ptr->free_act && (randint1(125) < p_ptr->skill_sav)) || (p_ptr->pclass == CLASS_BERSERKER))
3669                         {
3670                                 /* Do nothing */ ;
3671                         }
3672                         else
3673                         {
3674                                 msg_print(_("彫像になった気分だ!", "You feel like a statue!"));
3675                                 if (p_ptr->free_act)
3676                                         set_paralyzed(p_ptr->paralyzed + randint1(3));
3677                                 else
3678                                         set_paralyzed(p_ptr->paralyzed + randint1(13));
3679                                 stop_ty = TRUE;
3680                         }
3681                         if (!one_in_(6)) break;
3682                 case 21: case 22: case 23:
3683                         (void)do_dec_stat(randint0(6));
3684                         if (!one_in_(6)) break;
3685                 case 24:
3686                         msg_print(_("ほえ?私は誰?ここで何してる?", "Huh? Who am I? What am I doing here?"));
3687                         lose_all_info();
3688                         if (!one_in_(6)) break;
3689                 case 25:
3690                         /*
3691                          * Only summon Cyberdemons deep in the dungeon.
3692                          */
3693                         if ((dun_level > 65) && !stop_ty)
3694                         {
3695                                 (*count) += summon_cyber(-1, p_ptr->y, p_ptr->x);
3696                                 stop_ty = TRUE;
3697                                 break;
3698                         }
3699                         if (!one_in_(6)) break;
3700                 default:
3701                         while (i < 6)
3702                         {
3703                                 do
3704                                 {
3705                                         (void)do_dec_stat(i);
3706                                 }
3707                                 while (one_in_(2));
3708
3709                                 i++;
3710                         }
3711                 }
3712         }
3713         while (one_in_(3) && !stop_ty);
3714
3715         return stop_ty;
3716 }
3717
3718 /*!
3719  * @brief HI_SUMMON(上級召喚)処理発動
3720  * @param y 召喚位置Y座標
3721  * @param x 召喚位置X座標
3722  * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする
3723  * @return 作用が実際にあった場合TRUEを返す
3724  */
3725 int activate_hi_summon(POSITION y, POSITION x, bool can_pet)
3726 {
3727         int i;
3728         int count = 0;
3729         DEPTH summon_lev;
3730         BIT_FLAGS mode = PM_ALLOW_GROUP;
3731         bool pet = FALSE;
3732
3733         if (can_pet)
3734         {
3735                 if (one_in_(4))
3736                 {
3737                         mode |= PM_FORCE_FRIENDLY;
3738                 }
3739                 else
3740                 {
3741                         mode |= PM_FORCE_PET;
3742                         pet = TRUE;
3743                 }
3744         }
3745
3746         if (!pet) mode |= PM_NO_PET;
3747
3748         summon_lev = (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : dun_level);
3749
3750         for (i = 0; i < (randint1(7) + (dun_level / 40)); i++)
3751         {
3752                 switch (randint1(25) + (dun_level / 20))
3753                 {
3754                         case 1: case 2:
3755                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode);
3756                                 break;
3757                         case 3: case 4:
3758                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode);
3759                                 break;
3760                         case 5: case 6:
3761                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode);
3762                                 break;
3763                         case 7: case 8:
3764                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode);
3765                                 break;
3766                         case 9: case 10:
3767                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode);
3768                                 break;
3769                         case 11: case 12:
3770                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode);
3771                                 break;
3772                         case 13: case 14:
3773                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode);
3774                                 break;
3775                         case 15: case 16:
3776                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode);
3777                                 break;
3778                         case 17:
3779                                 if (can_pet) break;
3780                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
3781                                 break;
3782                         case 18: case 19:
3783                                 if (can_pet) break;
3784                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE));
3785                                 break;
3786                         case 20: case 21:
3787                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3788                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode);
3789                                 break;
3790                         case 22: case 23:
3791                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3792                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode);
3793                                 break;
3794                         case 24:
3795                                 count += summon_specific((pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode);
3796                                 break;
3797                         default:
3798                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3799                                 count += summon_specific((pet ? -1 : 0), y, x,pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode);
3800                 }
3801         }
3802
3803         return count;
3804 }
3805
3806
3807 /*!
3808  * @brief サイバーデーモンの召喚
3809  * @param who 召喚主のモンスターID(0ならばプレイヤー)
3810  * @param y 召喚位置Y座標
3811  * @param x 召喚位置X座標
3812  * @return 作用が実際にあった場合TRUEを返す
3813  */
3814 int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
3815 {
3816         int i;
3817         int max_cyber = (easy_band ? 1 : (dun_level / 50) + randint1(2));
3818         int count = 0;
3819         BIT_FLAGS mode = PM_ALLOW_GROUP;
3820
3821         /* Summoned by a monster */
3822         if (who > 0)
3823         {
3824                 monster_type *m_ptr = &m_list[who];
3825                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3826         }
3827
3828         if (max_cyber > 4) max_cyber = 4;
3829
3830         for (i = 0; i < max_cyber; i++)
3831         {
3832                 count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode);
3833         }
3834
3835         return count;
3836 }
3837
3838 /*!
3839  * @brief 周辺破壊効果(プレイヤー中心)
3840  * @return 作用が実際にあった場合TRUEを返す
3841  */
3842 void wall_breaker(void)
3843 {
3844         int i;
3845         POSITION y = 0, x = 0;
3846         int attempts = 1000;
3847
3848         if (randint1(80 + p_ptr->lev) < 70)
3849         {
3850                 while (attempts--)
3851                 {
3852                         scatter(&y, &x, p_ptr->y, p_ptr->x, 4, 0);
3853
3854                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
3855
3856                         if (!player_bold(y, x)) break;
3857                 }
3858
3859                 project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3860                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3861         }
3862         else if (randint1(100) > 30)
3863         {
3864                 earthquake(p_ptr->y, p_ptr->x, 1);
3865         }
3866         else
3867         {
3868                 int num = damroll(5, 3);
3869
3870                 for (i = 0; i < num; i++)
3871                 {
3872                         while (1)
3873                         {
3874                                 scatter(&y, &x, p_ptr->y, p_ptr->x, 10, 0);
3875
3876                                 if (!player_bold(y, x)) break;
3877                         }
3878
3879                         project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3880                                           (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3881                 }
3882         }
3883 }
3884
3885
3886 /*!
3887  * @brief パニック・モンスター効果(プレイヤー視界範囲内) / Confuse monsters
3888  * @param dam 効力
3889  * @return 作用が実際にあった場合TRUEを返す
3890  */
3891 bool confuse_monsters(HIT_POINT dam)
3892 {
3893         return (project_hack(GF_OLD_CONF, dam));
3894 }
3895
3896
3897 /*!
3898  * @brief チャーム・モンスター効果(プレイヤー視界範囲内) / Charm monsters
3899  * @param dam 効力
3900  * @return 作用が実際にあった場合TRUEを返す
3901  */
3902 bool charm_monsters(HIT_POINT dam)
3903 {
3904         return (project_hack(GF_CHARM, dam));
3905 }
3906
3907
3908 /*!
3909  * @brief 動物魅了効果(プレイヤー視界範囲内) / Charm Animals
3910  * @param dam 効力
3911  * @return 作用が実際にあった場合TRUEを返す
3912  */
3913 bool charm_animals(HIT_POINT dam)
3914 {
3915         return (project_hack(GF_CONTROL_ANIMAL, dam));
3916 }
3917
3918
3919 /*!
3920  * @brief モンスター朦朧効果(プレイヤー視界範囲内) / Stun monsters
3921  * @param dam 効力
3922  * @return 作用が実際にあった場合TRUEを返す
3923  */
3924 bool stun_monsters(HIT_POINT dam)
3925 {
3926         return (project_hack(GF_STUN, dam));
3927 }
3928
3929
3930 /*!
3931  * @brief モンスター停止効果(プレイヤー視界範囲内) / Stasis monsters
3932  * @param dam 効力
3933  * @return 作用が実際にあった場合TRUEを返す
3934  */
3935 bool stasis_monsters(HIT_POINT dam)
3936 {
3937         return (project_hack(GF_STASIS, dam));
3938 }
3939
3940
3941 /*!
3942  * @brief モンスター精神攻撃効果(プレイヤー視界範囲内) / Mindblast monsters
3943  * @param dam 効力
3944  * @return 作用が実際にあった場合TRUEを返す
3945  */
3946 bool mindblast_monsters(HIT_POINT dam)
3947 {
3948         return (project_hack(GF_PSI, dam));
3949 }
3950
3951
3952 /*!
3953  * @brief モンスター追放効果(プレイヤー視界範囲内) / Banish all monsters
3954  * @param dist 効力(距離)
3955  * @return 作用が実際にあった場合TRUEを返す
3956  */
3957 bool banish_monsters(int dist)
3958 {
3959         return (project_hack(GF_AWAY_ALL, dist));
3960 }
3961
3962
3963 /*!
3964  * @brief 邪悪退散効果(プレイヤー視界範囲内) / Turn evil
3965  * @param dam 効力
3966  * @return 作用が実際にあった場合TRUEを返す
3967  */
3968 bool turn_evil(HIT_POINT dam)
3969 {
3970         return (project_hack(GF_TURN_EVIL, dam));
3971 }
3972
3973
3974 /*!
3975  * @brief 全モンスター退散効果(プレイヤー視界範囲内) / Turn everyone
3976  * @param dam 効力
3977  * @return 作用が実際にあった場合TRUEを返す
3978  */
3979 bool turn_monsters(HIT_POINT dam)
3980 {
3981         return (project_hack(GF_TURN_ALL, dam));
3982 }
3983
3984
3985 /*!
3986  * @brief 死の光線(プレイヤー視界範囲内) / Death-ray all monsters (note: OBSCENELY powerful)
3987  * @return 作用が実際にあった場合TRUEを返す
3988  */
3989 bool deathray_monsters(void)
3990 {
3991         return (project_hack(GF_DEATH_RAY, p_ptr->lev * 200));
3992 }
3993
3994 /*!
3995  * @brief チャーム・モンスター(1体)
3996  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3997  * @param plev パワー
3998  * @return 作用が実際にあった場合TRUEを返す
3999  */
4000 bool charm_monster(DIRECTION dir, PLAYER_LEVEL plev)
4001 {
4002         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
4003         return (project_hook(GF_CHARM, dir, plev, flg));
4004 }
4005
4006 /*!
4007  * @brief アンデッド支配(1体)
4008  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
4009  * @param plev パワー
4010  * @return 作用が実際にあった場合TRUEを返す
4011  */
4012 bool control_one_undead(DIRECTION dir, PLAYER_LEVEL plev)
4013 {
4014         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
4015         return (project_hook(GF_CONTROL_UNDEAD, dir, plev, flg));
4016 }
4017
4018 /*!
4019  * @brief 悪魔支配(1体)
4020  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
4021  * @param plev パワー
4022  * @return 作用が実際にあった場合TRUEを返す
4023  */
4024 bool control_one_demon(DIRECTION dir, PLAYER_LEVEL plev)
4025 {
4026         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
4027         return (project_hook(GF_CONTROL_DEMON, dir, plev, flg));
4028 }
4029
4030 /*!
4031  * @brief 動物支配(1体)
4032  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
4033  * @param plev パワー
4034  * @return 作用が実際にあった場合TRUEを返す
4035  */
4036 bool charm_animal(DIRECTION dir, PLAYER_LEVEL plev)
4037 {
4038         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
4039         return (project_hook(GF_CONTROL_ANIMAL, dir, plev, flg));
4040 }
4041
4042
4043 /*!
4044  * @brief 変わり身処理
4045  * @param success 判定成功上の処理ならばTRUE
4046  * @return 作用が実際にあった場合TRUEを返す
4047  */
4048 bool kawarimi(bool success)
4049 {
4050         object_type forge;
4051         object_type *q_ptr = &forge;
4052         POSITION y, x;
4053
4054         if (p_ptr->is_dead) return FALSE;
4055         if (p_ptr->confused || p_ptr->blind || p_ptr->paralyzed || p_ptr->image) return FALSE;
4056         if (randint0(200) < p_ptr->stun) return FALSE;
4057
4058         if (!success && one_in_(3))
4059         {
4060                 msg_print(_("失敗!逃げられなかった。", "Failed! You couldn't run away."));
4061                 p_ptr->special_defense &= ~(NINJA_KAWARIMI);
4062                 p_ptr->redraw |= (PR_STATUS);
4063                 return FALSE;
4064         }
4065
4066         y = p_ptr->y;
4067         x = p_ptr->x;
4068
4069         teleport_player(10 + randint1(90), 0L);
4070
4071         object_wipe(q_ptr);
4072
4073         object_prep(q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE));
4074
4075         q_ptr->pval = MON_NINJA;
4076
4077         /* Drop it in the dungeon */
4078         (void)drop_near(q_ptr, -1, y, x);
4079
4080 #ifdef JP
4081         if (success) msg_print("攻撃を受ける前に素早く身をひるがえした。");
4082         else msg_print("失敗!攻撃を受けてしまった。");
4083 #else
4084         if (success) msg_print("You have turned around just before the attack hit you.");
4085         else msg_print("Failed! You are hit by the attack.");
4086 #endif
4087
4088         p_ptr->special_defense &= ~(NINJA_KAWARIMI);
4089         p_ptr->redraw |= (PR_STATUS);
4090
4091         /* Teleported */
4092         return TRUE;
4093 }
4094
4095
4096 /*!
4097  * @brief 入身処理 / "Rush Attack" routine for Samurai or Ninja
4098  * @param mdeath 目標モンスターが死亡したかを返す
4099  * @return 作用が実際にあった場合TRUEを返す /  Return value is for checking "done"
4100  */
4101 bool rush_attack(bool *mdeath)
4102 {
4103         DIRECTION dir;
4104         int tx, ty;
4105         int tm_idx = 0;
4106         u16b path_g[32];
4107         int path_n, i;
4108         bool tmp_mdeath = FALSE;
4109         bool moved = FALSE;
4110
4111         if (mdeath) *mdeath = FALSE;
4112
4113         project_length = 5;
4114         if (!get_aim_dir(&dir)) return FALSE;
4115
4116         /* Use the given direction */
4117         tx = p_ptr->x + project_length * ddx[dir];
4118         ty = p_ptr->y + project_length * ddy[dir];
4119
4120         /* Hack -- Use an actual "target" */
4121         if ((dir == 5) && target_okay())
4122         {
4123                 tx = target_col;
4124                 ty = target_row;
4125         }
4126
4127         if (in_bounds(ty, tx)) tm_idx = cave[ty][tx].m_idx;
4128
4129         path_n = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_STOP | PROJECT_KILL);
4130         project_length = 0;
4131
4132         /* No need to move */
4133         if (!path_n) return TRUE;
4134
4135         /* Use ty and tx as to-move point */
4136         ty = p_ptr->y;
4137         tx = p_ptr->x;
4138
4139         /* Project along the path */
4140         for (i = 0; i < path_n; i++)
4141         {
4142                 monster_type *m_ptr;
4143
4144                 int ny = GRID_Y(path_g[i]);
4145                 int nx = GRID_X(path_g[i]);
4146
4147                 if (cave_empty_bold(ny, nx) && player_can_enter(cave[ny][nx].feat, 0))
4148                 {
4149                         ty = ny;
4150                         tx = nx;
4151
4152                         /* Go to next grid */
4153                         continue;
4154                 }
4155
4156                 if (!cave[ny][nx].m_idx)
4157                 {
4158                         if (tm_idx)
4159                         {
4160                                 msg_print(_("失敗!", "Failed!"));
4161                         }
4162                         else
4163                         {
4164                                 msg_print(_("ここには入身では入れない。", "You can't move to that place."));
4165                         }
4166
4167                         /* Exit loop */
4168                         break;
4169                 }
4170
4171                 /* Move player before updating the monster */
4172                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4173
4174                 /* Update the monster */
4175                 update_mon(cave[ny][nx].m_idx, TRUE);
4176
4177                 /* Found a monster */
4178                 m_ptr = &m_list[cave[ny][nx].m_idx];
4179
4180                 if (tm_idx != cave[ny][nx].m_idx)
4181                 {
4182 #ifdef JP
4183                         msg_format("%s%sが立ちふさがっている!", tm_idx ? "別の" : "",
4184                                    m_ptr->ml ? "モンスター" : "何か");
4185 #else
4186                         msg_format("There is %s in the way!", m_ptr->ml ? (tm_idx ? "another monster" : "a monster") : "someone");
4187 #endif
4188                 }
4189                 else if (!player_bold(ty, tx))
4190                 {
4191                         /* Hold the monster name */
4192                         char m_name[80];
4193
4194                         /* Get the monster name (BEFORE polymorphing) */
4195                         monster_desc(m_name, m_ptr, 0);
4196                         msg_format(_("素早く%sの懐に入り込んだ!", "You quickly jump in and attack %s!"), m_name);
4197                 }
4198
4199                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4200                 moved = TRUE;
4201                 tmp_mdeath = py_attack(ny, nx, HISSATSU_NYUSIN);
4202
4203                 break;
4204         }
4205
4206         if (!moved && !player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4207
4208         if (mdeath) *mdeath = tmp_mdeath;
4209         return TRUE;
4210 }
4211
4212
4213 /*!
4214  * @brief 全鏡の消去 / Remove all mirrors in this floor
4215  * @param explode 爆発処理を伴うならばTRUE
4216  * @return なし
4217  */
4218 void remove_all_mirrors(bool explode)
4219 {
4220         POSITION x, y;
4221
4222         for (x = 0; x < cur_wid; x++)
4223         {
4224                 for (y = 0; y < cur_hgt; y++)
4225                 {
4226                         if (is_mirror_grid(&cave[y][x]))
4227                         {
4228                                 remove_mirror(y, x);
4229                                 if (explode)
4230                                         project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS,
4231                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
4232                         }
4233                 }
4234         }
4235 }
4236
4237 /*!
4238  * @brief 『一つの指輪』の効果処理 /
4239  * Hack -- activate the ring of power
4240  * @param dir 発動の方向ID
4241  * @return なし
4242  */
4243 void ring_of_power(DIRECTION dir)
4244 {
4245         /* Pick a random effect */
4246         switch (randint1(10))
4247         {
4248         case 1:
4249         case 2:
4250         {
4251                 msg_print(_("あなたは悪性のオーラに包み込まれた。", "You are surrounded by a malignant aura."));
4252                 sound(SOUND_EVIL);
4253
4254                 /* Decrease all stats (permanently) */
4255                 (void)dec_stat(A_STR, 50, TRUE);
4256                 (void)dec_stat(A_INT, 50, TRUE);
4257                 (void)dec_stat(A_WIS, 50, TRUE);
4258                 (void)dec_stat(A_DEX, 50, TRUE);
4259                 (void)dec_stat(A_CON, 50, TRUE);
4260                 (void)dec_stat(A_CHR, 50, TRUE);
4261
4262                 /* Lose some experience (permanently) */
4263                 p_ptr->exp -= (p_ptr->exp / 4);
4264                 p_ptr->max_exp -= (p_ptr->exp / 4);
4265                 check_experience();
4266
4267                 break;
4268         }
4269
4270         case 3:
4271         {
4272                 msg_print(_("あなたは強力なオーラに包み込まれた。", "You are surrounded by a powerful aura."));
4273
4274                 /* Dispel monsters */
4275                 dispel_monsters(1000);
4276
4277                 break;
4278         }
4279
4280         case 4:
4281         case 5:
4282         case 6:
4283         {
4284                 /* Mana Ball */
4285                 fire_ball(GF_MANA, dir, 600, 3);
4286
4287                 break;
4288         }
4289
4290         case 7:
4291         case 8:
4292         case 9:
4293         case 10:
4294         {
4295                 /* Mana Bolt */
4296                 fire_bolt(GF_MANA, dir, 500);
4297
4298                 break;
4299         }
4300         }
4301 }
4302
4303 /*!
4304 * @brief 運命の輪、並びにカオス的な効果の発動
4305 * @param spell ランダムな効果を選択するための基準ID
4306 * @return なし
4307 */
4308 void wild_magic(int spell)
4309 {
4310         int counter = 0;
4311         int type = SUMMON_MOLD + randint0(6);
4312
4313         if (type < SUMMON_MOLD) type = SUMMON_MOLD;
4314         else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
4315
4316         switch (randint1(spell) + randint1(8) + 1)
4317         {
4318         case 1:
4319         case 2:
4320         case 3:
4321                 teleport_player(10, TELEPORT_PASSIVE);
4322                 break;
4323         case 4:
4324         case 5:
4325         case 6:
4326                 teleport_player(100, TELEPORT_PASSIVE);
4327                 break;
4328         case 7:
4329         case 8:
4330                 teleport_player(200, TELEPORT_PASSIVE);
4331                 break;
4332         case 9:
4333         case 10:
4334         case 11:
4335                 unlite_area(10, 3);
4336                 break;
4337         case 12:
4338         case 13:
4339         case 14:
4340                 lite_area(damroll(2, 3), 2);
4341                 break;
4342         case 15:
4343                 destroy_doors_touch();
4344                 break;
4345         case 16: case 17:
4346                 wall_breaker();
4347         case 18:
4348                 sleep_monsters_touch();
4349                 break;
4350         case 19:
4351         case 20:
4352                 trap_creation(p_ptr->y, p_ptr->x);
4353                 break;
4354         case 21:
4355         case 22:
4356                 door_creation();
4357                 break;
4358         case 23:
4359         case 24:
4360         case 25:
4361                 aggravate_monsters(0);
4362                 break;
4363         case 26:
4364                 earthquake(p_ptr->y, p_ptr->x, 5);
4365                 break;
4366         case 27:
4367         case 28:
4368                 (void)gain_random_mutation(0);
4369                 break;
4370         case 29:
4371         case 30:
4372                 apply_disenchant(1);
4373                 break;
4374         case 31:
4375                 lose_all_info();
4376                 break;
4377         case 32:
4378                 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
4379                 break;
4380         case 33:
4381                 wall_stone();
4382                 break;
4383         case 34:
4384         case 35:
4385                 while (counter++ < 8)
4386                 {
4387                         (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
4388                 }
4389                 break;
4390         case 36:
4391         case 37:
4392                 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4393                 break;
4394         case 38:
4395                 (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
4396                 break;
4397         default:
4398         {
4399                 int count = 0;
4400                 (void)activate_ty_curse(FALSE, &count);
4401                 break;
4402         }
4403         }
4404
4405         return;
4406 }
4407
4408 /*!
4409 * @brief カオス魔法「流星群」の処理としてプレイヤーを中心に隕石落下処理を10+1d10回繰り返す。
4410 * / Drop 10+1d10 meteor ball at random places near the player
4411 * @param dam ダメージ
4412 * @param rad 効力の半径
4413 * @return なし
4414 */
4415 void cast_meteor(HIT_POINT dam, POSITION rad)
4416 {
4417         int i;
4418         int b = 10 + randint1(10);
4419
4420         for (i = 0; i < b; i++)
4421         {
4422                 POSITION y = 0, x = 0;
4423                 int count;
4424
4425                 for (count = 0; count <= 20; count++)
4426                 {
4427                         int dy, dx, d;
4428
4429                         x = p_ptr->x - 8 + randint0(17);
4430                         y = p_ptr->y - 8 + randint0(17);
4431
4432                         dx = (p_ptr->x > x) ? (p_ptr->x - x) : (x - p_ptr->x);
4433                         dy = (p_ptr->y > y) ? (p_ptr->y - y) : (y - p_ptr->y);
4434
4435                         /* Approximate distance */
4436                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4437
4438                         if (d >= 9) continue;
4439
4440                         if (!in_bounds(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)
4441                                 || !cave_have_flag_bold(y, x, FF_PROJECT)) continue;
4442
4443                         /* Valid position */
4444                         break;
4445                 }
4446
4447                 if (count > 20) continue;
4448
4449                 project(0, rad, y, x, dam, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
4450         }
4451 }
4452
4453
4454 /*!
4455 * @brief 破邪魔法「神の怒り」の処理としてターゲットを指定した後分解のボールを最大20回発生させる。
4456 * @param dam ダメージ
4457 * @param rad 効力の半径
4458 * @return ターゲットを指定し、実行したならばTRUEを返す。
4459 */
4460 bool cast_wrath_of_the_god(HIT_POINT dam, POSITION rad)
4461 {
4462         POSITION x, y, tx, ty;
4463         POSITION nx, ny;
4464         DIRECTION dir;
4465         int i;
4466         int b = 10 + randint1(10);
4467
4468         if (!get_aim_dir(&dir)) return FALSE;
4469
4470         /* Use the given direction */
4471         tx = p_ptr->x + 99 * ddx[dir];
4472         ty = p_ptr->y + 99 * ddy[dir];
4473
4474         /* Hack -- Use an actual "target" */
4475         if ((dir == 5) && target_okay())
4476         {
4477                 tx = target_col;
4478                 ty = target_row;
4479         }
4480
4481         x = p_ptr->x;
4482         y = p_ptr->y;
4483
4484         while (1)
4485         {
4486                 /* Hack -- Stop at the target */
4487                 if ((y == ty) && (x == tx)) break;
4488
4489                 ny = y;
4490                 nx = x;
4491                 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
4492
4493                 /* Stop at maximum range */
4494                 if (MAX_RANGE <= distance(p_ptr->y, p_ptr->x, ny, nx)) break;
4495
4496                 /* Stopped by walls/doors */
4497                 if (!cave_have_flag_bold(ny, nx, FF_PROJECT)) break;
4498
4499                 /* Stopped by monsters */
4500                 if ((dir != 5) && cave[ny][nx].m_idx != 0) break;
4501
4502                 /* Save the new location */
4503                 x = nx;
4504                 y = ny;
4505         }
4506         tx = x;
4507         ty = y;
4508
4509         for (i = 0; i < b; i++)
4510         {
4511                 int count = 20, d = 0;
4512
4513                 while (count--)
4514                 {
4515                         int dx, dy;
4516
4517                         x = tx - 5 + randint0(11);
4518                         y = ty - 5 + randint0(11);
4519
4520                         dx = (tx > x) ? (tx - x) : (x - tx);
4521                         dy = (ty > y) ? (ty - y) : (y - ty);
4522
4523                         /* Approximate distance */
4524                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4525                         /* Within the radius */
4526                         if (d < 5) break;
4527                 }
4528
4529                 if (count < 0) continue;
4530
4531                 /* Cannot penetrate perm walls */
4532                 if (!in_bounds(y, x) ||
4533                         cave_stop_disintegration(y, x) ||
4534                         !in_disintegration_range(ty, tx, y, x))
4535                         continue;
4536
4537                 project(0, rad, y, x, dam, GF_DISINTEGRATE, PROJECT_JUMP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
4538         }
4539
4540         return TRUE;
4541 }
4542
4543 /*!
4544 * @brief 「ワンダー」のランダムな効果を決定して処理する。
4545 * @param dir 方向ID
4546 * @return なし
4547 * @details
4548 * This spell should become more useful (more controlled) as the\n
4549 * player gains experience levels.  Thus, add 1/5 of the player's\n
4550 * level to the die roll.  This eliminates the worst effects later on,\n
4551 * while keeping the results quite random.  It also allows some potent\n
4552 * effects only at high level.
4553 */
4554 void cast_wonder(DIRECTION dir)
4555 {
4556         PLAYER_LEVEL plev = p_ptr->lev;
4557         int die = randint1(100) + plev / 5;
4558         int vir = virtue_number(V_CHANCE);
4559
4560         if (vir)
4561         {
4562                 if (p_ptr->virtues[vir - 1] > 0)
4563                 {
4564                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4565                 }
4566                 else
4567                 {
4568                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4569                 }
4570         }
4571
4572         if (die < 26)
4573                 chg_virtue(V_CHANCE, 1);
4574
4575         if (die > 100)
4576         {
4577                 msg_print(_("あなたは力がみなぎるのを感じた!", "You feel a surge of power!"));
4578         }
4579
4580         if (die < 8) clone_monster(dir);
4581         else if (die < 14) speed_monster(dir, plev);
4582         else if (die < 26) heal_monster(dir, damroll(4, 6));
4583         else if (die < 31) poly_monster(dir, plev);
4584         else if (die < 36)
4585                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4586                         damroll(3 + ((plev - 1) / 5), 4));
4587         else if (die < 41) confuse_monster(dir, plev);
4588         else if (die < 46) fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4589         else if (die < 51) (void)lite_line(dir, damroll(6, 8));
4590         else if (die < 56)
4591                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4592                         damroll(3 + ((plev - 5) / 4), 8));
4593         else if (die < 61)
4594                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4595                         damroll(5 + ((plev - 5) / 4), 8));
4596         else if (die < 66)
4597                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4598                         damroll(6 + ((plev - 5) / 4), 8));
4599         else if (die < 71)
4600                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4601                         damroll(8 + ((plev - 5) / 4), 8));
4602         else if (die < 76) hypodynamic_bolt(dir, 75);
4603         else if (die < 81) fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4604         else if (die < 86) fire_ball(GF_ACID, dir, 40 + plev, 2);
4605         else if (die < 91) fire_ball(GF_ICE, dir, 70 + plev, 3);
4606         else if (die < 96) fire_ball(GF_FIRE, dir, 80 + plev, 3);
4607         else if (die < 101) hypodynamic_bolt(dir, 100 + plev);
4608         else if (die < 104)
4609         {
4610                 earthquake(p_ptr->y, p_ptr->x, 12);
4611         }
4612         else if (die < 106)
4613         {
4614                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4615         }
4616         else if (die < 108)
4617         {
4618                 symbol_genocide(plev + 50, TRUE);
4619         }
4620         else if (die < 110) dispel_monsters(120);
4621         else /* RARE */
4622         {
4623                 dispel_monsters(150);
4624                 slow_monsters(plev);
4625                 sleep_monsters(plev);
4626                 hp_player(300);
4627         }
4628 }
4629
4630
4631 /*!
4632 * @brief 「悪霊召喚」のランダムな効果を決定して処理する。
4633 * @param dir 方向ID
4634 * @return なし
4635 */
4636 void cast_invoke_spirits(DIRECTION dir)
4637 {
4638         PLAYER_LEVEL plev = p_ptr->lev;
4639         int die = randint1(100) + plev / 5;
4640         int vir = virtue_number(V_CHANCE);
4641
4642         if (vir)
4643         {
4644                 if (p_ptr->virtues[vir - 1] > 0)
4645                 {
4646                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4647                 }
4648                 else
4649                 {
4650                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4651                 }
4652         }
4653
4654         msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead..."));
4655         if (die < 26)
4656                 chg_virtue(V_CHANCE, 1);
4657
4658         if (die > 100)
4659         {
4660                 msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!"));
4661         }
4662
4663         if (die < 8)
4664         {
4665                 msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!",
4666                         "Oh no! Mouldering forms rise from the earth around you!"));
4667
4668                 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4669                 chg_virtue(V_UNLIFE, 1);
4670         }
4671         else if (die < 14)
4672         {
4673                 msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind..."));
4674
4675                 set_afraid(p_ptr->afraid + randint1(4) + 4);
4676         }
4677         else if (die < 26)
4678         {
4679                 msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...",
4680                         "Your head is invaded by a horde of gibbering spectral voices..."));
4681
4682                 set_confused(p_ptr->confused + randint1(4) + 4);
4683         }
4684         else if (die < 31)
4685         {
4686                 poly_monster(dir, plev);
4687         }
4688         else if (die < 36)
4689         {
4690                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4691                         damroll(3 + ((plev - 1) / 5), 4));
4692         }
4693         else if (die < 41)
4694         {
4695                 confuse_monster(dir, plev);
4696         }
4697         else if (die < 46)
4698         {
4699                 fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4700         }
4701         else if (die < 51)
4702         {
4703                 (void)lite_line(dir, damroll(6, 8));
4704         }
4705         else if (die < 56)
4706         {
4707                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4708                         damroll(3 + ((plev - 5) / 4), 8));
4709         }
4710         else if (die < 61)
4711         {
4712                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4713                         damroll(5 + ((plev - 5) / 4), 8));
4714         }
4715         else if (die < 66)
4716         {
4717                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4718                         damroll(6 + ((plev - 5) / 4), 8));
4719         }
4720         else if (die < 71)
4721         {
4722                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4723                         damroll(8 + ((plev - 5) / 4), 8));
4724         }
4725         else if (die < 76)
4726         {
4727                 hypodynamic_bolt(dir, 75);
4728         }
4729         else if (die < 81)
4730         {
4731                 fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4732         }
4733         else if (die < 86)
4734         {
4735                 fire_ball(GF_ACID, dir, 40 + plev, 2);
4736         }
4737         else if (die < 91)
4738         {
4739                 fire_ball(GF_ICE, dir, 70 + plev, 3);
4740         }
4741         else if (die < 96)
4742         {
4743                 fire_ball(GF_FIRE, dir, 80 + plev, 3);
4744         }
4745         else if (die < 101)
4746         {
4747                 hypodynamic_bolt(dir, 100 + plev);
4748         }
4749         else if (die < 104)
4750         {
4751                 earthquake(p_ptr->y, p_ptr->x, 12);
4752         }
4753         else if (die < 106)
4754         {
4755                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4756         }
4757         else if (die < 108)
4758         {
4759                 symbol_genocide(plev + 50, TRUE);
4760         }
4761         else if (die < 110)
4762         {
4763                 dispel_monsters(120);
4764         }
4765         else
4766         { /* RARE */
4767                 dispel_monsters(150);
4768                 slow_monsters(plev);
4769                 sleep_monsters(plev);
4770                 hp_player(300);
4771         }
4772
4773         if (die < 31)
4774         {
4775                 msg_print(_("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」",
4776                         "Sepulchral voices chuckle. 'Soon you will join us, mortal.'"));
4777         }
4778 }
4779
4780 /*!
4781 * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。
4782 * @return なし
4783 */
4784 void cast_shuffle(void)
4785 {
4786         PLAYER_LEVEL plev = p_ptr->lev;
4787         DIRECTION dir;
4788         int die;
4789         int vir = virtue_number(V_CHANCE);
4790         int i;
4791
4792         /* Card sharks and high mages get a level bonus */
4793         if ((p_ptr->pclass == CLASS_ROGUE) ||
4794                 (p_ptr->pclass == CLASS_HIGH_MAGE) ||
4795                 (p_ptr->pclass == CLASS_SORCERER))
4796                 die = (randint1(110)) + plev / 5;
4797         else
4798                 die = randint1(120);
4799
4800
4801         if (vir)
4802         {
4803                 if (p_ptr->virtues[vir - 1] > 0)
4804                 {
4805                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4806                 }
4807                 else
4808                 {
4809                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4810                 }
4811         }
4812
4813         msg_print(_("あなたはカードを切って一枚引いた...", "You shuffle the deck and draw a card..."));
4814
4815         if (die < 30)
4816                 chg_virtue(V_CHANCE, 1);
4817
4818         if (die < 7)
4819         {
4820                 msg_print(_("なんてこった!《死》だ!", "Oh no! It's Death!"));
4821
4822                 for (i = 0; i < randint1(3); i++)
4823                         activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4824         }
4825         else if (die < 14)
4826         {
4827                 msg_print(_("なんてこった!《悪魔》だ!", "Oh no! It's the Devil!"));
4828                 summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4829         }
4830         else if (die < 18)
4831         {
4832                 int count = 0;
4833                 msg_print(_("なんてこった!《吊られた男》だ!", "Oh no! It's the Hanged Man."));
4834                 activate_ty_curse(FALSE, &count);
4835         }
4836         else if (die < 22)
4837         {
4838                 msg_print(_("《不調和の剣》だ。", "It's the swords of discord."));
4839                 aggravate_monsters(0);
4840         }
4841         else if (die < 26)
4842         {
4843                 msg_print(_("《愚者》だ。", "It's the Fool."));
4844                 do_dec_stat(A_INT);
4845                 do_dec_stat(A_WIS);
4846         }
4847         else if (die < 30)
4848         {
4849                 msg_print(_("奇妙なモンスターの絵だ。", "It's the picture of a strange monster."));
4850                 trump_summoning(1, FALSE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), (32 + randint1(6)), PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
4851         }
4852         else if (die < 33)
4853         {
4854                 msg_print(_("《月》だ。", "It's the Moon."));
4855                 unlite_area(10, 3);
4856         }
4857         else if (die < 38)
4858         {
4859                 msg_print(_("《運命の輪》だ。", "It's the Wheel of Fortune."));
4860                 wild_magic(randint0(32));
4861         }
4862         else if (die < 40)
4863         {
4864                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4865                 teleport_player(10, TELEPORT_PASSIVE);
4866         }
4867         else if (die < 42)
4868         {
4869                 msg_print(_("《正義》だ。", "It's Justice."));
4870                 set_blessed(p_ptr->lev, FALSE);
4871         }
4872         else if (die < 47)
4873         {
4874                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4875                 teleport_player(100, TELEPORT_PASSIVE);
4876         }
4877         else if (die < 52)
4878         {
4879                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4880                 teleport_player(200, TELEPORT_PASSIVE);
4881         }
4882         else if (die < 60)
4883         {
4884                 msg_print(_("《塔》だ。", "It's the Tower."));
4885                 wall_breaker();
4886         }
4887         else if (die < 72)
4888         {
4889                 msg_print(_("《節制》だ。", "It's Temperance."));
4890                 sleep_monsters_touch();
4891         }
4892         else if (die < 80)
4893         {
4894                 msg_print(_("《塔》だ。", "It's the Tower."));
4895
4896                 earthquake(p_ptr->y, p_ptr->x, 5);
4897         }
4898         else if (die < 82)
4899         {
4900                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4901                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_MOLD, 0L);
4902         }
4903         else if (die < 84)
4904         {
4905                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4906                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_BAT, 0L);
4907         }
4908         else if (die < 86)
4909         {
4910                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4911                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_VORTEX, 0L);
4912         }
4913         else if (die < 88)
4914         {
4915                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4916                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_COIN_MIMIC, 0L);
4917         }
4918         else if (die < 96)
4919         {
4920                 msg_print(_("《恋人》だ。", "It's the Lovers."));
4921
4922                 if (get_aim_dir(&dir))
4923                         charm_monster(dir, MIN(p_ptr->lev, 20));
4924         }
4925         else if (die < 101)
4926         {
4927                 msg_print(_("《隠者》だ。", "It's the Hermit."));
4928                 wall_stone();
4929         }
4930         else if (die < 111)
4931         {
4932                 msg_print(_("《審判》だ。", "It's the Judgement."));
4933                 do_cmd_rerate(FALSE);
4934                 lose_all_mutations();
4935         }
4936         else if (die < 120)
4937         {
4938                 msg_print(_("《太陽》だ。", "It's the Sun."));
4939                 chg_virtue(V_KNOWLEDGE, 1);
4940                 chg_virtue(V_ENLIGHTEN, 1);
4941                 wiz_lite(FALSE);
4942         }
4943         else
4944         {
4945                 msg_print(_("《世界》だ。", "It's the World."));
4946                 if (p_ptr->exp < PY_MAX_EXP)
4947                 {
4948                         s32b ee = (p_ptr->exp / 25) + 1;
4949                         if (ee > 5000) ee = 5000;
4950                         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4951                         gain_exp(ee);
4952                 }
4953         }
4954 }
4955
4956 bool_hack life_stream(bool_hack message, bool_hack virtue)
4957 {
4958         if(virtue)
4959         {
4960                 chg_virtue(V_VITALITY, 1);
4961                 chg_virtue(V_UNLIFE, -5);
4962         }
4963         if(message)
4964         {
4965                 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
4966         }
4967         restore_level();
4968         (void)set_poisoned(0);
4969         (void)set_blind(0);
4970         (void)set_confused(0);
4971         (void)set_image(0);
4972         (void)set_stun(0);
4973         (void)set_cut(0);
4974         (void)restore_all_status();
4975         (void)set_shero(0, TRUE);
4976         update_stuff();
4977         hp_player(5000);
4978
4979         return TRUE;
4980 }
4981
4982 bool_hack heroism(int base)
4983 {
4984         bool_hack ident = FALSE;
4985         if(set_afraid(0)) ident = TRUE;
4986         if(set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4987         if(hp_player(10)) ident = TRUE;
4988         return ident;
4989 }
4990
4991 bool_hack berserk(int base)
4992 {
4993         bool_hack ident = FALSE;
4994         if (set_afraid(0)) ident = TRUE;
4995         if (set_shero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4996         if (hp_player(30)) ident = TRUE;
4997         return ident;
4998 }
4999
5000 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
5001 {
5002         bool_hack ident = FALSE;
5003         if (hp_player(damroll(dice, sides))) ident = TRUE;
5004         if (set_blind(0)) ident = TRUE;
5005         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
5006         if (set_shero(0, TRUE)) ident = TRUE;
5007         return ident;
5008 }
5009
5010 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
5011 {
5012         bool_hack ident = FALSE;
5013         if (hp_player(damroll(dice, sides))) ident = TRUE;
5014         if (set_blind(0)) ident = TRUE;
5015         if (set_confused(0)) ident = TRUE;
5016         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
5017         if (set_shero(0, TRUE)) ident = TRUE;
5018         return ident;
5019 }
5020
5021 bool_hack cure_critical_wounds(HIT_POINT pow)
5022 {
5023         bool_hack ident = FALSE;
5024         if (hp_player(pow)) ident = TRUE;
5025         if (set_blind(0)) ident = TRUE;
5026         if (set_confused(0)) ident = TRUE;
5027         if (set_poisoned(0)) ident = TRUE;
5028         if (set_stun(0)) ident = TRUE;
5029         if (set_cut(0)) ident = TRUE;
5030         if (set_shero(0, TRUE)) ident = TRUE;
5031         return ident;
5032 }
5033
5034 bool_hack true_healing(HIT_POINT pow)
5035 {
5036         bool_hack ident = FALSE;
5037         if (hp_player(pow)) ident = TRUE;
5038         if (set_blind(0)) ident = TRUE;
5039         if (set_confused(0)) ident = TRUE;
5040         if (set_poisoned(0)) ident = TRUE;
5041         if (set_stun(0)) ident = TRUE;
5042         if (set_cut(0)) ident = TRUE;
5043         if (set_image(0)) ident = TRUE;
5044         return ident;
5045 }
5046
5047 bool_hack restore_mana(bool_hack magic_eater)
5048 {
5049         bool_hack ident = FALSE;
5050
5051         if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
5052         {
5053                 int i;
5054                 for (i = 0; i < EATER_EXT * 2; i++)
5055                 {
5056                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
5057                         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;
5058                 }
5059                 for (; i < EATER_EXT * 3; i++)
5060                 {
5061                         KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
5062                         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;
5063                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
5064                 }
5065                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
5066                 p_ptr->window |= (PW_PLAYER);
5067                 ident = TRUE;
5068         }
5069         else if (p_ptr->csp < p_ptr->msp)
5070         {
5071                 p_ptr->csp = p_ptr->msp;
5072                 p_ptr->csp_frac = 0;
5073                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
5074                 p_ptr->redraw |= (PR_MANA);
5075                 p_ptr->window |= (PW_PLAYER);
5076                 p_ptr->window |= (PW_SPELL);
5077                 ident = TRUE;
5078         }
5079
5080         return ident;
5081 }
5082
5083 bool restore_all_status(void)
5084 {
5085         bool ident = FALSE; 
5086         if (do_res_stat(A_STR)) ident = TRUE;
5087         if (do_res_stat(A_INT)) ident = TRUE;
5088         if (do_res_stat(A_WIS)) ident = TRUE;
5089         if (do_res_stat(A_DEX)) ident = TRUE;
5090         if (do_res_stat(A_CON)) ident = TRUE;
5091         if (do_res_stat(A_CHR)) ident = TRUE;
5092         return ident;
5093 }
5094
5095 /*!
5096  * @brief 口を使う継続的な処理を中断する
5097  * @return なし
5098  */
5099 void stop_mouth(void)
5100 {
5101         if (music_singing_any()) stop_singing();
5102         if (hex_spelling_any()) stop_hex_spell_all();
5103 }
5104
5105
5106 bool_hack vampirism(void)
5107 {
5108         DIRECTION dir;
5109         POSITION x, y;
5110         int dummy;
5111         cave_type *c_ptr;
5112
5113         if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
5114         {
5115                 msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking."));
5116                 return FALSE;
5117         }
5118
5119         /* Only works on adjacent monsters */
5120         if (!get_rep_dir2(&dir)) return FALSE;
5121         y = p_ptr->y + ddy[dir];
5122         x = p_ptr->x + ddx[dir];
5123         c_ptr = &cave[y][x];
5124
5125         stop_mouth();
5126
5127         if (!(c_ptr->m_idx))
5128         {
5129                 msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
5130                 return FALSE;
5131         }
5132
5133         msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
5134
5135         dummy = p_ptr->lev * 2;
5136
5137         if (hypodynamic_bolt(dir, dummy))
5138         {
5139                 if (p_ptr->food < PY_FOOD_FULL)
5140                         /* No heal if we are "full" */
5141                         (void)hp_player(dummy);
5142                 else
5143                         msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
5144
5145                 /* Gain nutritional sustenance: 150/hp drained */
5146                 /* A Food ration gives 5000 food points (by contrast) */
5147                 /* Don't ever get more than "Full" this way */
5148                 /* But if we ARE Gorged,  it won't cure us */
5149                 dummy = p_ptr->food + MIN(5000, 100 * dummy);
5150                 if (p_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
5151                         (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
5152         }
5153         else
5154                 msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
5155         return TRUE;
5156 }
5157
5158 bool panic_hit(void)
5159 {
5160         DIRECTION dir;
5161         POSITION x, y;
5162
5163         if (!get_rep_dir2(&dir)) return FALSE;
5164         y = p_ptr->y + ddy[dir];
5165         x = p_ptr->x + ddx[dir];
5166         if (cave[y][x].m_idx)
5167         {
5168                 py_attack(y, x, 0);
5169                 if (randint0(p_ptr->skill_dis) < 7)
5170                         msg_print(_("うまく逃げられなかった。", "You failed to run away."));
5171                 else
5172                         teleport_player(30, 0L);
5173                 return TRUE;
5174         }
5175         else
5176         {
5177                 msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
5178                 msg_print(NULL);
5179                 return FALSE;
5180         }
5181
5182 }
5183
5184 /*!
5185 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
5186 * @return なし
5187 * @note
5188 * currently this function allows pseudo-id of any object,
5189 * including silly ones like potions & scrolls, which always
5190 * get '{average}'. This should be changed, either to stop such
5191 * items from being pseudo-id'd, or to allow psychometry to
5192 * detect whether the unidentified potion/scroll/etc is
5193 * good (Cure Light Wounds, Restore Strength, etc) or
5194 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
5195 */
5196 bool psychometry(void)
5197 {
5198         OBJECT_IDX      item;
5199         object_type     *o_ptr;
5200         char            o_name[MAX_NLEN];
5201         byte            feel;
5202         cptr            q, s;
5203         bool okay = FALSE;
5204
5205         item_tester_no_ryoute = TRUE;
5206         /* Get an item */
5207         q = _("どのアイテムを調べますか?", "Meditate on which item? ");
5208         s = _("調べるアイテムがありません。", "You have nothing appropriate.");
5209
5210         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
5211
5212         /* Get the item (in the pack) */
5213         if (item >= 0)
5214         {
5215                 o_ptr = &inventory[item];
5216         }
5217
5218         /* Get the item (on the floor) */
5219         else
5220         {
5221                 o_ptr = &o_list[0 - item];
5222         }
5223
5224         /* It is fully known, no information needed */
5225         if (object_is_known(o_ptr))
5226         {
5227                 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
5228                 return TRUE;
5229         }
5230
5231         /* Check for a feeling */
5232         feel = value_check_aux1(o_ptr);
5233
5234         /* Get an object description */
5235         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5236
5237         /* Skip non-feelings */
5238         if (!feel)
5239         {
5240                 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
5241                 return TRUE;
5242         }
5243
5244 #ifdef JP
5245         msg_format("%sは%sという感じがする...",
5246                 o_name, game_inscriptions[feel]);
5247 #else
5248         msg_format("You feel that the %s %s %s...",
5249                 o_name, ((o_ptr->number == 1) ? "is" : "are"),
5250                 game_inscriptions[feel]);
5251 #endif
5252
5253
5254         /* We have "felt" it */
5255         o_ptr->ident |= (IDENT_SENSE);
5256
5257         /* "Inscribe" it */
5258         o_ptr->feeling = feel;
5259
5260         /* Player touches it */
5261         o_ptr->marked |= OM_TOUCHED;
5262
5263         /* Combine / Reorder the pack (later) */
5264         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5265
5266         /* Window stuff */
5267         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5268
5269         /* Valid "tval" codes */
5270         switch (o_ptr->tval)
5271         {
5272         case TV_SHOT:
5273         case TV_ARROW:
5274         case TV_BOLT:
5275         case TV_BOW:
5276         case TV_DIGGING:
5277         case TV_HAFTED:
5278         case TV_POLEARM:
5279         case TV_SWORD:
5280         case TV_BOOTS:
5281         case TV_GLOVES:
5282         case TV_HELM:
5283         case TV_CROWN:
5284         case TV_SHIELD:
5285         case TV_CLOAK:
5286         case TV_SOFT_ARMOR:
5287         case TV_HARD_ARMOR:
5288         case TV_DRAG_ARMOR:
5289         case TV_CARD:
5290         case TV_RING:
5291         case TV_AMULET:
5292         case TV_LITE:
5293         case TV_FIGURINE:
5294                 okay = TRUE;
5295                 break;
5296         }
5297
5298         /* Auto-inscription/destroy */
5299         autopick_alter_item(item, (bool)(okay && destroy_feeling));
5300
5301         /* Something happened */
5302         return (TRUE);
5303 }