OSDN Git Service

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