OSDN Git Service

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