OSDN Git Service

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