OSDN Git Service

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