OSDN Git Service

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