OSDN Git Service

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