OSDN Git Service

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