OSDN Git Service

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