OSDN Git Service

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