OSDN Git Service

[Refactor] #37353 メッセージ整理。
[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                                 /* Notice */
2466                                 note_spot(y, x);
2467                         }
2468
2469                         /* Process affected monsters */
2470                         if (c_ptr->m_idx)
2471                         {
2472                                 /* Update the monster */
2473                                 update_mon(c_ptr->m_idx, FALSE);
2474                         }
2475
2476                         /* Redraw */
2477                         lite_spot(y, x);
2478
2479                         update_local_illumination(y, x);
2480                 }
2481         }
2482
2483         /* None left */
2484         temp_n = 0;
2485 }
2486
2487
2488 /*!
2489  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2490  * @param cy Y座標
2491  * @param cx X座標
2492  * @param pass_bold 地形条件を返す関数ポインタ
2493  * @return 該当地形の数
2494  */
2495 static int next_to_open(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2496 {
2497         int i;
2498         POSITION y, x;
2499         int len = 0;
2500         int blen = 0;
2501
2502         for (i = 0; i < 16; i++)
2503         {
2504                 y = cy + ddy_cdd[i % 8];
2505                 x = cx + ddx_cdd[i % 8];
2506
2507                 /* Found a wall, break the length */
2508                 if (!pass_bold(y, x))
2509                 {
2510                         /* Track best length */
2511                         if (len > blen)
2512                         {
2513                                 blen = len;
2514                         }
2515
2516                         len = 0;
2517                 }
2518                 else
2519                 {
2520                         len++;
2521                 }
2522         }
2523
2524         return (MAX(len, blen));
2525 }
2526
2527 /*!
2528  * @brief 周辺に関数ポインタの条件に該当する地形がいくつあるかを計算する / Determine how much contiguous open space this grid is next to
2529  * @param cy Y座標
2530  * @param cx X座標
2531  * @param pass_bold 地形条件を返す関数ポインタ
2532  * @return 該当地形の数
2533  */
2534 static int next_to_walls_adj(POSITION cy, POSITION cx, bool (*pass_bold)(POSITION, POSITION))
2535 {
2536         DIRECTION i;
2537         POSITION y, x;
2538         int c = 0;
2539
2540         for (i = 0; i < 8; i++)
2541         {
2542                 y = cy + ddy_ddd[i];
2543                 x = cx + ddx_ddd[i];
2544
2545                 if (!pass_bold(y, x)) c++;
2546         }
2547
2548         return c;
2549 }
2550
2551
2552 /*!
2553  * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数temp_nに返す / Aux function -- see below
2554  * @param y 部屋内のy座標1点
2555  * @param x 部屋内のx座標1点
2556  * @param only_room 部屋内地形のみをチェック対象にするならば TRUE
2557  * @param pass_bold 地形条件を返す関数ポインタ
2558  * @return 該当地形の数
2559  */
2560 static void cave_temp_room_aux(POSITION y, POSITION x, bool only_room, bool (*pass_bold)(POSITION, POSITION))
2561 {
2562         cave_type *c_ptr;
2563
2564         /* Get the grid */
2565         c_ptr = &cave[y][x];
2566
2567         /* Avoid infinite recursion */
2568         if (c_ptr->info & (CAVE_TEMP)) return;
2569
2570         /* Do not "leave" the current room */
2571         if (!(c_ptr->info & (CAVE_ROOM)))
2572         {
2573                 if (only_room) return;
2574
2575                 /* Verify */
2576                 if (!in_bounds2(y, x)) return;
2577
2578                 /* Do not exceed the maximum spell range */
2579                 if (distance(p_ptr->y, p_ptr->x, y, x) > MAX_RANGE) return;
2580
2581                 /* Verify this grid */
2582                 /*
2583                  * The reason why it is ==6 instead of >5 is that 8 is impossible
2584                  * due to the check for cave_bold above.
2585                  * 7 lights dead-end corridors (you need to do this for the
2586                  * checkboard interesting rooms, so that the boundary is lit
2587                  * properly.
2588                  * This leaves only a check for 6 bounding walls!
2589                  */
2590                 if (in_bounds(y, x) && pass_bold(y, x) &&
2591                     (next_to_walls_adj(y, x, pass_bold) == 6) && (next_to_open(y, x, pass_bold) <= 1)) return;
2592         }
2593
2594         /* Paranoia -- verify space */
2595         if (temp_n == TEMP_MAX) return;
2596
2597         /* Mark the grid as "seen" */
2598         c_ptr->info |= (CAVE_TEMP);
2599
2600         /* Add it to the "seen" set */
2601         temp_y[temp_n] = y;
2602         temp_x[temp_n] = x;
2603         temp_n++;
2604 }
2605
2606 /*!
2607  * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
2608  * @param y 指定Y座標
2609  * @param x 指定X座標
2610  * @return 光を通すならばtrueを返す。
2611  */
2612 static bool cave_pass_lite_bold(POSITION y, POSITION x)
2613 {
2614         return cave_los_bold(y, x);
2615 }
2616
2617 /*!
2618  * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数temp_nに返す / Aux function -- see below
2619  * @param y 指定Y座標
2620  * @param x 指定X座標
2621  * @return なし
2622  */
2623 static void cave_temp_lite_room_aux(POSITION y, POSITION x)
2624 {
2625         cave_temp_room_aux(y, x, FALSE, cave_pass_lite_bold);
2626 }
2627
2628 /*!
2629  * @brief 指定のマスが光を通さず射線のみを通すかを返す。 / Aux function -- see below
2630  * @param y 指定Y座標
2631  * @param x 指定X座標
2632  * @return 射線を通すならばtrueを返す。
2633  */
2634 static bool cave_pass_dark_bold(POSITION y, POSITION x)
2635 {
2636         return cave_have_flag_bold(y, x, FF_PROJECT);
2637 }
2638
2639
2640 /*!
2641  * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数temp_nに返す / Aux function -- see below
2642  * @param y 指定Y座標
2643  * @param x 指定X座標
2644  * @return なし
2645  */
2646 static void cave_temp_unlite_room_aux(POSITION y, POSITION x)
2647 {
2648         cave_temp_room_aux(y, x, TRUE, cave_pass_dark_bold);
2649 }
2650
2651
2652 /*!
2653  * @brief 指定された部屋内を照らす / Illuminate any room containing the given location.
2654  * @param y1 指定Y座標
2655  * @param x1 指定X座標
2656  * @return なし
2657  */
2658 void lite_room(POSITION y1, POSITION x1)
2659 {
2660         int i;
2661         POSITION x, y;
2662
2663         /* Add the initial grid */
2664         cave_temp_lite_room_aux(y1, x1);
2665
2666         /* While grids are in the queue, add their neighbors */
2667         for (i = 0; i < temp_n; i++)
2668         {
2669                 x = temp_x[i], y = temp_y[i];
2670
2671                 /* Walls get lit, but stop light */
2672                 if (!cave_pass_lite_bold(y, x)) continue;
2673
2674                 /* Spread adjacent */
2675                 cave_temp_lite_room_aux(y + 1, x);
2676                 cave_temp_lite_room_aux(y - 1, x);
2677                 cave_temp_lite_room_aux(y, x + 1);
2678                 cave_temp_lite_room_aux(y, x - 1);
2679
2680                 /* Spread diagonal */
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                 cave_temp_lite_room_aux(y + 1, x - 1);
2685         }
2686
2687         /* Now, lite them all up at once */
2688         cave_temp_room_lite();
2689
2690         if (p_ptr->special_defense & NINJA_S_STEALTH)
2691         {
2692                 if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
2693         }
2694 }
2695
2696
2697 /*!
2698  * @brief 指定された部屋内を暗くする / Darken all rooms containing the given location
2699  * @param y1 指定Y座標
2700  * @param x1 指定X座標
2701  * @return なし
2702  */
2703 void unlite_room(POSITION y1, POSITION x1)
2704 {
2705         int i;
2706         POSITION x, y;
2707
2708         /* Add the initial grid */
2709         cave_temp_unlite_room_aux(y1, x1);
2710
2711         /* Spread, breadth first */
2712         for (i = 0; i < temp_n; i++)
2713         {
2714                 x = temp_x[i], y = temp_y[i];
2715
2716                 /* Walls get dark, but stop darkness */
2717                 if (!cave_pass_dark_bold(y, x)) continue;
2718
2719                 /* Spread adjacent */
2720                 cave_temp_unlite_room_aux(y + 1, x);
2721                 cave_temp_unlite_room_aux(y - 1, x);
2722                 cave_temp_unlite_room_aux(y, x + 1);
2723                 cave_temp_unlite_room_aux(y, x - 1);
2724
2725                 /* Spread diagonal */
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                 cave_temp_unlite_room_aux(y + 1, x - 1);
2730         }
2731
2732         /* Now, darken them all at once */
2733         cave_temp_room_unlite();
2734 }
2735
2736
2737
2738 /*!
2739  * @brief プレイヤー位置を中心にLITE_WEAK属性を通じた照明処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2740  * @param dam 威力
2741  * @param rad 効果半径
2742  * @return 作用が実際にあった場合TRUEを返す
2743  */
2744 bool lite_area(HIT_POINT dam, POSITION rad)
2745 {
2746         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2747
2748         if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
2749         {
2750                 msg_print(_("ダンジョンが光を吸収した。", "The darkness of this dungeon absorb your light."));
2751                 return FALSE;
2752         }
2753
2754         /* Hack -- Message */
2755         if (!p_ptr->blind)
2756         {
2757                 msg_print(_("白い光が辺りを覆った。", "You are surrounded by a white light."));
2758         }
2759
2760         /* Hook into the "project()" function */
2761         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_LITE_WEAK, flg, -1);
2762
2763         /* Lite up the room */
2764         lite_room(p_ptr->y, p_ptr->x);
2765
2766         /* Assume seen */
2767         return (TRUE);
2768 }
2769
2770
2771 /*!
2772  * @brief プレイヤー位置を中心にLITE_DARK属性を通じた消灯処理を行う / Hack -- call light around the player Affect all monsters in the projection radius
2773  * @param dam 威力
2774  * @param rad 効果半径
2775  * @return 作用が実際にあった場合TRUEを返す
2776  */
2777 bool unlite_area(HIT_POINT dam, POSITION rad)
2778 {
2779         BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
2780
2781         /* Hack -- Message */
2782         if (!p_ptr->blind)
2783         {
2784                 msg_print(_("暗闇が辺りを覆った。", "Darkness surrounds you."));
2785         }
2786
2787         /* Hook into the "project()" function */
2788         (void)project(0, rad, p_ptr->y, p_ptr->x, dam, GF_DARK_WEAK, flg, -1);
2789
2790         /* Lite up the room */
2791         unlite_room(p_ptr->y, p_ptr->x);
2792
2793         /* Assume seen */
2794         return (TRUE);
2795 }
2796
2797
2798
2799 /*!
2800  * @brief ボール系スペルの発動 / Cast a ball spell
2801  * @param typ 効果属性
2802  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2803  * @param dam 威力
2804  * @param rad 半径
2805  * @return 作用が実際にあった場合TRUEを返す
2806  * @details
2807  * <pre>
2808  * Stop if we hit a monster, act as a "ball"
2809  * Allow "target" mode to pass over monsters
2810  * Affect grids, objects, and monsters
2811  * </pre>
2812  */
2813 bool fire_ball(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2814 {
2815         POSITION tx, ty;
2816
2817         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2818
2819         if (typ == GF_CHARM_LIVING) flg|= PROJECT_HIDE;
2820         /* Use the given direction */
2821         tx = p_ptr->x + 99 * ddx[dir];
2822         ty = p_ptr->y + 99 * ddy[dir];
2823
2824         /* Hack -- Use an actual "target" */
2825         if ((dir == 5) && target_okay())
2826         {
2827                 flg &= ~(PROJECT_STOP);
2828                 tx = target_col;
2829                 ty = target_row;
2830         }
2831
2832         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2833         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2834 }
2835
2836 /*!
2837 * @brief ブレス系スペルの発動 / Cast a breath spell
2838 * @param typ 効果属性
2839 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2840 * @param dam 威力
2841 * @param rad 半径
2842 * @return 作用が実際にあった場合TRUEを返す
2843 * @details
2844 * <pre>
2845 * Stop if we hit a monster, act as a "ball"
2846 * Allow "target" mode to pass over monsters
2847 * Affect grids, objects, and monsters
2848 * </pre>
2849 */
2850 bool fire_breath(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2851 {
2852         return fire_ball(typ, dir, dam, -rad);
2853 }
2854
2855
2856 /*!
2857  * @brief ロケット系スペルの発動(詳細な差は確認中) / Cast a ball spell
2858  * @param typ 効果属性
2859  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2860  * @param dam 威力
2861  * @param rad 半径
2862  * @return 作用が実際にあった場合TRUEを返す
2863  * @details
2864  * <pre>
2865  * Stop if we hit a monster, act as a "ball"
2866  * Allow "target" mode to pass over monsters
2867  * Affect grids, objects, and monsters
2868  * </pre>
2869  */
2870 bool fire_rocket(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2871 {
2872         POSITION tx, ty;
2873         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2874
2875         /* Use the given direction */
2876         tx = p_ptr->x + 99 * ddx[dir];
2877         ty = p_ptr->y + 99 * ddy[dir];
2878
2879         /* Hack -- Use an actual "target" */
2880         if ((dir == 5) && target_okay())
2881         {
2882                 tx = target_col;
2883                 ty = target_row;
2884         }
2885
2886         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2887         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2888 }
2889
2890
2891 /*!
2892  * @brief ボール(ハイド)系スペルの発動 / Cast a ball spell
2893  * @param typ 効果属性
2894  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2895  * @param dam 威力
2896  * @param rad 半径
2897  * @return 作用が実際にあった場合TRUEを返す
2898  * @details
2899  * <pre>
2900  * Stop if we hit a monster, act as a "ball"
2901  * Allow "target" mode to pass over monsters
2902  * Affect grids, objects, and monsters
2903  * </pre>
2904  */
2905 bool fire_ball_hide(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
2906 {
2907         POSITION tx, ty;
2908         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE;
2909
2910         /* Use the given direction */
2911         tx = p_ptr->x + 99 * ddx[dir];
2912         ty = p_ptr->y + 99 * ddy[dir];
2913
2914         /* Hack -- Use an actual "target" */
2915         if ((dir == 5) && target_okay())
2916         {
2917                 flg &= ~(PROJECT_STOP);
2918                 tx = target_col;
2919                 ty = target_row;
2920         }
2921
2922         /* Analyze the "dir" and the "target".  Hurt items on floor. */
2923         return (project(0, rad, ty, tx, dam, typ, flg, -1));
2924 }
2925
2926
2927 /*!
2928  * @brief メテオ系スペルの発動 / Cast a meteor spell
2929  * @param who スぺル詠唱者のモンスターID(0=プレイヤー)
2930  * @param typ 効果属性
2931  * @param dam 威力
2932  * @param rad 半径
2933  * @param y 中心点Y座標
2934  * @param x 中心点X座標
2935  * @return 作用が実際にあった場合TRUEを返す
2936  * @details
2937  * <pre>
2938  * Cast a meteor spell, defined as a ball spell cast by an arbitary monster, 
2939  * player, or outside source, that starts out at an arbitrary location, and 
2940  * leaving no trail from the "caster" to the target.  This function is 
2941  * especially useful for bombardments and similar. -LM-
2942  * Option to hurt the player.
2943  * </pre>
2944  */
2945 bool fire_meteor(MONSTER_IDX who, EFFECT_ID typ, POSITION y, POSITION x, HIT_POINT dam, POSITION rad)
2946 {
2947         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2948
2949         /* Analyze the "target" and the caster. */
2950         return (project(who, rad, y, x, dam, typ, flg, -1));
2951 }
2952
2953
2954 /*!
2955  * @brief ブラスト系スペルの発動 / Cast a blast spell
2956  * @param typ 効果属性
2957  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
2958  * @param dd 威力ダイス数
2959  * @param ds 威力ダイス目
2960  * @param num 基本回数
2961  * @param dev 回数分散
2962  * @return 作用が実際にあった場合TRUEを返す
2963  */
2964 bool fire_blast(EFFECT_ID typ, DIRECTION dir, int dd, int ds, int num, int dev)
2965 {
2966         POSITION ly, lx;
2967         int ld;
2968         POSITION ty, tx, y, x;
2969         int i;
2970
2971         BIT_FLAGS flg = PROJECT_FAST | PROJECT_THRU | PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE | PROJECT_GRID;
2972
2973         /* Assume okay */
2974         bool result = TRUE;
2975
2976         /* Use the given direction */
2977         if (dir != 5)
2978         {
2979                 ly = ty = p_ptr->y + 20 * ddy[dir];
2980                 lx = tx = p_ptr->x + 20 * ddx[dir];
2981         }
2982
2983         /* Use an actual "target" */
2984         else /* if (dir == 5) */
2985         {
2986                 tx = target_col;
2987                 ty = target_row;
2988
2989                 lx = 20 * (tx - p_ptr->x) + p_ptr->x;
2990                 ly = 20 * (ty - p_ptr->y) + p_ptr->y;
2991         }
2992
2993         ld = distance(p_ptr->y, p_ptr->x, ly, lx);
2994
2995         /* Blast */
2996         for (i = 0; i < num; i++)
2997         {
2998                 while (1)
2999                 {
3000                         /* Get targets for some bolts */
3001                         y = rand_spread(ly, ld * dev / 20);
3002                         x = rand_spread(lx, ld * dev / 20);
3003
3004                         if (distance(ly, lx, y, x) <= ld * dev / 20) break;
3005                 }
3006
3007                 /* Analyze the "dir" and the "target". */
3008                 if (!project(0, 0, y, x, damroll(dd, ds), typ, flg, -1))
3009                 {
3010                         result = FALSE;
3011                 }
3012         }
3013
3014         return (result);
3015 }
3016
3017
3018 /*!
3019  * @brief モンスターとの位置交換処理 / Switch position with a monster.
3020  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3021  * @return 作用が実際にあった場合TRUEを返す
3022  */
3023 bool teleport_swap(DIRECTION dir)
3024 {
3025         POSITION tx, ty;
3026         cave_type* c_ptr;
3027         monster_type* m_ptr;
3028         monster_race* r_ptr;
3029
3030         if ((dir == 5) && target_okay())
3031         {
3032                 tx = target_col;
3033                 ty = target_row;
3034         }
3035         else
3036         {
3037                 tx = p_ptr->x + ddx[dir];
3038                 ty = p_ptr->y + ddy[dir];
3039         }
3040         c_ptr = &cave[ty][tx];
3041
3042         if (p_ptr->anti_tele)
3043         {
3044                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
3045                 return FALSE;
3046         }
3047
3048         if (!c_ptr->m_idx || (c_ptr->m_idx == p_ptr->riding))
3049         {
3050                 msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
3051
3052                 /* Failure */
3053                 return FALSE;
3054         }
3055
3056         if ((c_ptr->info & CAVE_ICKY) || (distance(ty, tx, p_ptr->y, p_ptr->x) > p_ptr->lev * 3 / 2 + 10))
3057         {
3058                 msg_print(_("失敗した。", "Failed to swap."));
3059
3060                 /* Failure */
3061                 return FALSE;
3062         }
3063
3064         m_ptr = &m_list[c_ptr->m_idx];
3065         r_ptr = &r_info[m_ptr->r_idx];
3066
3067         (void)set_monster_csleep(c_ptr->m_idx, 0);
3068
3069         if (r_ptr->flagsr & RFR_RES_TELE)
3070         {
3071                 msg_print(_("テレポートを邪魔された!", "Your teleportation is blocked!"));
3072
3073                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3074
3075                 /* Failure */
3076                 return FALSE;
3077         }
3078
3079         sound(SOUND_TELEPORT);
3080
3081         /* Swap the player and monster */
3082         (void)move_player_effect(ty, tx, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
3083
3084         /* Success */
3085         return TRUE;
3086 }
3087
3088
3089 /*!
3090  * @brief 指定方向に飛び道具を飛ばす(フラグ任意指定) / Hack -- apply a "projection()" in a direction (or at the target)
3091  * @param typ 効果属性
3092  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3093  * @param dam 威力
3094  * @param flg フラグ
3095  * @return 作用が実際にあった場合TRUEを返す
3096  */
3097 bool project_hook(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, BIT_FLAGS flg)
3098 {
3099         int tx, ty;
3100
3101         /* Pass through the target if needed */
3102         flg |= (PROJECT_THRU);
3103
3104         /* Use the given direction */
3105         tx = p_ptr->x + ddx[dir];
3106         ty = p_ptr->y + ddy[dir];
3107
3108         /* Hack -- Use an actual "target" */
3109         if ((dir == 5) && target_okay())
3110         {
3111                 tx = target_col;
3112                 ty = target_row;
3113         }
3114
3115         /* Analyze the "dir" and the "target", do NOT explode */
3116         return (project(0, 0, ty, tx, dam, typ, flg, -1));
3117 }
3118
3119
3120 /*!
3121  * @brief ボルト系スペルの発動 / Cast a bolt spell.
3122  * @param typ 効果属性
3123  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3124  * @param dam 威力
3125  * @return 作用が実際にあった場合TRUEを返す
3126  * @details
3127  * <pre>
3128  * Stop if we hit a monster, as a "bolt".
3129  * Affect monsters and grids (not objects).
3130  * </pre>
3131  */
3132 bool fire_bolt(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3133 {
3134         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_GRID;
3135         if (typ != GF_ARROW) flg |= PROJECT_REFLECTABLE;
3136         return (project_hook(typ, dir, dam, flg));
3137 }
3138
3139
3140 /*!
3141  * @brief ビーム系スペルの発動 / Cast a beam spell.
3142  * @param typ 効果属性
3143  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3144  * @param dam 威力
3145  * @return 作用が実際にあった場合TRUEを返す
3146  * @details
3147  * <pre>
3148  * Pass through monsters, as a "beam".
3149  * Affect monsters, grids and objects.
3150  * </pre>
3151  */
3152 bool fire_beam(EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3153 {
3154         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM;
3155         return (project_hook(typ, dir, dam, flg));
3156 }
3157
3158
3159 /*!
3160  * @brief 確率に応じたボルト系/ビーム系スペルの発動 / Cast a bolt spell, or rarely, a beam spell.
3161  * @param prob ビーム化する確率(%)
3162  * @param typ 効果属性
3163  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3164  * @param dam 威力
3165  * @return 作用が実際にあった場合TRUEを返す
3166  * @details
3167  * <pre>
3168  * Pass through monsters, as a "beam".
3169  * Affect monsters, grids and objects.
3170  * </pre>
3171  */
3172 bool fire_bolt_or_beam(PERCENTAGE prob, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
3173 {
3174         if (randint0(100) < prob)
3175         {
3176                 return (fire_beam(typ, dir, dam));
3177         }
3178         else
3179         {
3180                 return (fire_bolt(typ, dir, dam));
3181         }
3182 }
3183
3184 /*!
3185  * @brief LITE_WEAK属性による光源ビーム処理
3186  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3187  * @param dam 威力
3188  * @return 作用が実際にあった場合TRUEを返す
3189  */
3190 bool lite_line(DIRECTION dir, HIT_POINT dam)
3191 {
3192         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_KILL;
3193         return (project_hook(GF_LITE_WEAK, dir, dam, flg));
3194 }
3195
3196 /*!
3197  * @brief 衰弱ボルト処理
3198  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3199  * @param dam 威力
3200  * @return 作用が実際にあった場合TRUEを返す
3201  */
3202 bool hypodynamic_bolt(DIRECTION dir, HIT_POINT dam)
3203 {
3204         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3205         return (project_hook(GF_HYPODYNAMIA, dir, dam, flg));
3206 }
3207
3208 /*!
3209  * @brief 岩石溶解処理
3210  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3211  * @param dam 威力
3212  * @return 作用が実際にあった場合TRUEを返す
3213  */
3214 bool wall_to_mud(DIRECTION dir, HIT_POINT dam)
3215 {
3216         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3217         return (project_hook(GF_KILL_WALL, dir, dam, flg));
3218 }
3219
3220 /*!
3221  * @brief 魔法の施錠処理
3222  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3223  * @return 作用が実際にあった場合TRUEを返す
3224  */
3225 bool wizard_lock(DIRECTION dir)
3226 {
3227         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3228         return (project_hook(GF_JAM_DOOR, dir, 20 + randint1(30), flg));
3229 }
3230
3231 /*!
3232  * @brief ドア破壊処理
3233  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3234  * @return 作用が実際にあった場合TRUEを返す
3235  */
3236 bool destroy_door(DIRECTION dir)
3237 {
3238         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3239         return (project_hook(GF_KILL_DOOR, dir, 0, flg));
3240 }
3241
3242 /*!
3243  * @brief トラップ解除処理
3244  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3245  * @return 作用が実際にあった場合TRUEを返す
3246  */
3247 bool disarm_trap(DIRECTION dir)
3248 {
3249         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_GRID | PROJECT_ITEM;
3250         return (project_hook(GF_KILL_TRAP, dir, 0, flg));
3251 }
3252
3253 /*!
3254  * @brief モンスター回復処理
3255  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3256  * @param dam 威力
3257  * @return 作用が実際にあった場合TRUEを返す
3258  */
3259 bool heal_monster(DIRECTION dir, HIT_POINT dam)
3260 {
3261         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3262         return (project_hook(GF_OLD_HEAL, dir, dam, flg));
3263 }
3264
3265 /*!
3266  * @brief モンスター加速処理
3267  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3268  * @param power 効力
3269  * @return 作用が実際にあった場合TRUEを返す
3270  */
3271 bool speed_monster(DIRECTION dir, int power)
3272 {
3273         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3274         return (project_hook(GF_OLD_SPEED, dir, power, flg));
3275 }
3276
3277 /*!
3278  * @brief モンスター減速処理
3279  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3280  * @param power 効力
3281  * @return 作用が実際にあった場合TRUEを返す
3282  */
3283 bool slow_monster(DIRECTION dir, int power)
3284 {
3285         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3286         return (project_hook(GF_OLD_SLOW, dir, power, flg));
3287 }
3288
3289 /*!
3290  * @brief モンスター催眠処理
3291  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3292  * @param power 効力
3293  * @return 作用が実際にあった場合TRUEを返す
3294  */
3295 bool sleep_monster(DIRECTION dir, int power)
3296 {
3297         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3298         return (project_hook(GF_OLD_SLEEP, dir, power, flg));
3299 }
3300
3301 /*!
3302  * @brief モンスター拘束(STASIS)処理
3303  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3304  * @return 作用が実際にあった場合TRUEを返す
3305  * @details 威力はプレイヤーレベル*2に固定
3306  */
3307 bool stasis_monster(DIRECTION dir)
3308 {
3309         return (fire_ball_hide(GF_STASIS, dir, p_ptr->lev*2, 0));
3310 }
3311
3312 /*!
3313  * @brief 邪悪なモンスター拘束(STASIS)処理
3314  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3315  * @return 作用が実際にあった場合TRUEを返す
3316  * @details 威力はプレイヤーレベル*2に固定
3317  */
3318 bool stasis_evil(DIRECTION dir)
3319 {
3320         return (fire_ball_hide(GF_STASIS_EVIL, dir, p_ptr->lev*2, 0));
3321 }
3322
3323 /*!
3324  * @brief モンスター混乱処理
3325  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3326  * @param plev プレイヤーレベル(=効力)
3327  * @return 作用が実際にあった場合TRUEを返す
3328  */
3329 bool confuse_monster(DIRECTION dir, PLAYER_LEVEL plev)
3330 {
3331         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3332         return (project_hook(GF_OLD_CONF, dir, plev, flg));
3333 }
3334
3335 /*!
3336  * @brief モンスター朦朧処理
3337  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3338  * @param plev プレイヤーレベル(=効力)
3339  * @return 作用が実際にあった場合TRUEを返す
3340  */
3341 bool stun_monster(DIRECTION dir, PLAYER_LEVEL plev)
3342 {
3343         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3344         return (project_hook(GF_STUN, dir, plev, flg));
3345 }
3346
3347 /*!
3348  * @brief チェンジモンスター処理
3349  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3350  * @param power 効力
3351  * @return 作用が実際にあった場合TRUEを返す
3352  */
3353 bool poly_monster(DIRECTION dir, int power)
3354 {
3355         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3356         bool tester = (project_hook(GF_OLD_POLY, dir, power, flg));
3357         if (tester)
3358                 chg_virtue(V_CHANCE, 1);
3359         return(tester);
3360 }
3361
3362 /*!
3363  * @brief クローンモンスター処理
3364  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3365  * @return 作用が実際にあった場合TRUEを返す
3366  */
3367 bool clone_monster(DIRECTION dir)
3368 {
3369         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3370         return (project_hook(GF_OLD_CLONE, dir, 0, flg));
3371 }
3372
3373 /*!
3374  * @brief モンスター恐慌処理
3375  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3376  * @param plev プレイヤーレベル(=効力)
3377  * @return 作用が実際にあった場合TRUEを返す
3378  */
3379 bool fear_monster(DIRECTION dir, PLAYER_LEVEL plev)
3380 {
3381         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3382         return (project_hook(GF_TURN_ALL, dir, plev, flg));
3383 }
3384
3385 /*!
3386  * @brief 死の光線処理
3387  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3388  * @param plev プレイヤーレベル(効力はplev*200)
3389  * @return 作用が実際にあった場合TRUEを返す
3390  */
3391 bool death_ray(DIRECTION dir, PLAYER_LEVEL plev)
3392 {
3393         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
3394         return (project_hook(GF_DEATH_RAY, dir, plev * 200, flg));
3395 }
3396
3397 /*!
3398  * @brief モンスター用テレポート処理
3399  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3400  * @param distance 移動距離
3401  * @return 作用が実際にあった場合TRUEを返す
3402  */
3403 bool teleport_monster(DIRECTION dir, int distance)
3404 {
3405         BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL;
3406         return (project_hook(GF_AWAY_ALL, dir, distance, flg));
3407 }
3408
3409 /*!
3410  * @brief ドア生成処理(プレイヤー中心に周囲1マス) / Hooks -- affect adjacent grids (radius 1 ball attack)
3411  * @return 作用が実際にあった場合TRUEを返す
3412  */
3413 bool door_creation(void)
3414 {
3415         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3416         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_DOOR, flg, -1));
3417 }
3418
3419 /*!
3420  * @brief トラップ生成処理(起点から周囲1マス)
3421  * @param y 起点Y座標
3422  * @param x 起点X座標
3423  * @return 作用が実際にあった場合TRUEを返す
3424  */
3425 bool trap_creation(POSITION y, POSITION x)
3426 {
3427         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3428         return (project(0, 1, y, x, 0, GF_MAKE_TRAP, flg, -1));
3429 }
3430
3431 /*!
3432  * @brief 森林生成処理(プレイヤー中心に周囲1マス)
3433  * @return 作用が実際にあった場合TRUEを返す
3434  */
3435 bool tree_creation(void)
3436 {
3437         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3438         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_TREE, flg, -1));
3439 }
3440
3441 /*!
3442  * @brief 魔法のルーン生成処理(プレイヤー中心に周囲1マス)
3443  * @return 作用が実際にあった場合TRUEを返す
3444  */
3445 bool glyph_creation(void)
3446 {
3447         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM;
3448         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_MAKE_GLYPH, flg, -1));
3449 }
3450
3451 /*!
3452  * @brief 壁生成処理(プレイヤー中心に周囲1マス)
3453  * @return 作用が実際にあった場合TRUEを返す
3454  */
3455 bool wall_stone(void)
3456 {
3457         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3458
3459         bool dummy = (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_STONE_WALL, flg, -1));
3460
3461         p_ptr->update |= (PU_FLOW);
3462
3463         /* Redraw map */
3464         p_ptr->redraw |= (PR_MAP);
3465
3466         return dummy;
3467 }
3468
3469 /*!
3470  * @brief ドア破壊処理(プレイヤー中心に周囲1マス)
3471  * @return 作用が実際にあった場合TRUEを返す
3472  */
3473 bool destroy_doors_touch(void)
3474 {
3475         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3476         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_DOOR, flg, -1));
3477 }
3478
3479 /*!
3480  * @brief トラップ解除処理(プレイヤー中心に周囲1マス)
3481  * @return 作用が実際にあった場合TRUEを返す
3482  */
3483 bool disarm_traps_touch(void)
3484 {
3485         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
3486         return (project(0, 1, p_ptr->y, p_ptr->x, 0, GF_KILL_TRAP, flg, -1));
3487 }
3488
3489 /*!
3490  * @brief スリープモンスター処理(プレイヤー中心に周囲1マス)
3491  * @return 作用が実際にあった場合TRUEを返す
3492  */
3493 bool sleep_monsters_touch(void)
3494 {
3495         BIT_FLAGS flg = PROJECT_KILL | PROJECT_HIDE;
3496         return (project(0, 1, p_ptr->y, p_ptr->x, p_ptr->lev, GF_OLD_SLEEP, flg, -1));
3497 }
3498
3499
3500 /*!
3501  * @brief 死者復活処理(起点より周囲5マス)
3502  * @param who 術者モンスターID(0ならばプレイヤー)
3503  * @param y 起点Y座標
3504  * @param x 起点X座標
3505  * @return 作用が実際にあった場合TRUEを返す
3506  */
3507 bool animate_dead(MONSTER_IDX who, POSITION y, POSITION x)
3508 {
3509         BIT_FLAGS flg = PROJECT_ITEM | PROJECT_HIDE;
3510         return (project(who, 5, y, x, 0, GF_ANIM_DEAD, flg, -1));
3511 }
3512
3513 /*!
3514  * @brief 混沌招来処理
3515  * @return 作用が実際にあった場合TRUEを返す
3516  */
3517 void call_chaos(void)
3518 {
3519         int Chaos_type, dummy, dir;
3520         PLAYER_LEVEL plev = p_ptr->lev;
3521         bool line_chaos = FALSE;
3522
3523         int hurt_types[31] =
3524         {
3525                 GF_ELEC,      GF_POIS,    GF_ACID,    GF_COLD,
3526                 GF_FIRE,      GF_MISSILE, GF_ARROW,   GF_PLASMA,
3527                 GF_HOLY_FIRE, GF_WATER,   GF_LITE,    GF_DARK,
3528                 GF_FORCE,     GF_INERTIAL, GF_MANA,    GF_METEOR,
3529                 GF_ICE,       GF_CHAOS,   GF_NETHER,  GF_DISENCHANT,
3530                 GF_SHARDS,    GF_SOUND,   GF_NEXUS,   GF_CONFUSION,
3531                 GF_TIME,      GF_GRAVITY, GF_ROCKET,  GF_NUKE,
3532                 GF_HELL_FIRE, GF_DISINTEGRATE, GF_PSY_SPEAR
3533         };
3534
3535         Chaos_type = hurt_types[randint0(31)];
3536         if (one_in_(4)) line_chaos = TRUE;
3537
3538         if (one_in_(6))
3539         {
3540                 for (dummy = 1; dummy < 10; dummy++)
3541                 {
3542                         if (dummy - 5)
3543                         {
3544                                 if (line_chaos)
3545                                         fire_beam(Chaos_type, dummy, 150);
3546                                 else
3547                                         fire_ball(Chaos_type, dummy, 150, 2);
3548                         }
3549                 }
3550         }
3551         else if (one_in_(3))
3552         {
3553                 fire_ball(Chaos_type, 0, 500, 8);
3554         }
3555         else
3556         {
3557                 if (!get_aim_dir(&dir)) return;
3558                 if (line_chaos)
3559                         fire_beam(Chaos_type, dir, 250);
3560                 else
3561                         fire_ball(Chaos_type, dir, 250, 3 + (plev / 35));
3562         }
3563 }
3564
3565 /*!
3566  * @brief TY_CURSE処理発動 / Activate the evil Topi Ylinen curse
3567  * @param stop_ty 再帰処理停止フラグ
3568  * @param count 発動回数
3569  * @return 作用が実際にあった場合TRUEを返す
3570  * @details
3571  * <pre>
3572  * rr9: Stop the nasty things when a Cyberdemon is summoned
3573  * or the player gets paralyzed.
3574  * </pre>
3575  */
3576 bool activate_ty_curse(bool stop_ty, int *count)
3577 {
3578         int     i = 0;
3579
3580         BIT_FLAGS flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3581
3582         do
3583         {
3584                 switch (randint1(34))
3585                 {
3586                 case 28: case 29:
3587                         if (!(*count))
3588                         {
3589                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
3590                                 earthquake(p_ptr->y, p_ptr->x, 5 + randint0(10));
3591                                 if (!one_in_(6)) break;
3592                         }
3593                 case 30: case 31:
3594                         if (!(*count))
3595                         {
3596                                 HIT_POINT dam = damroll(10, 10);
3597                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3598                                 project(0, 8, p_ptr->y, p_ptr->x, dam, GF_MANA, flg, -1);
3599                                 take_hit(DAMAGE_NOESCAPE, dam, _("純粋な魔力の解放", "released pure mana"), -1);
3600                                 if (!one_in_(6)) break;
3601                         }
3602                 case 32: case 33:
3603                         if (!(*count))
3604                         {
3605                                 msg_print(_("周囲の空間が歪んだ!", "Space warps about you!"));
3606                                 teleport_player(damroll(10, 10), TELEPORT_PASSIVE);
3607                                 if (randint0(13)) (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3608                                 if (!one_in_(6)) break;
3609                         }
3610                 case 34:
3611                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3612                         wall_breaker();
3613                         if (!randint0(7))
3614                         {
3615                                 project(0, 7, p_ptr->y, p_ptr->x, 50, GF_KILL_WALL, flg, -1);
3616                                 take_hit(DAMAGE_NOESCAPE, 50, _("エネルギーのうねり", "surge of energy"), -1);
3617                         }
3618                         if (!one_in_(6)) break;
3619                 case 1: case 2: case 3: case 16: case 17:
3620                         aggravate_monsters(0);
3621                         if (!one_in_(6)) break;
3622                 case 4: case 5: case 6:
3623                         (*count) += activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3624                         if (!one_in_(6)) break;
3625                 case 7: case 8: case 9: case 18:
3626                         (*count) += summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
3627                         if (!one_in_(6)) break;
3628                 case 10: case 11: case 12:
3629                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3630                         lose_exp(p_ptr->exp / 16);
3631                         if (!one_in_(6)) break;
3632                 case 13: case 14: case 15: case 19: case 20:
3633                         if (stop_ty || (p_ptr->free_act && (randint1(125) < p_ptr->skill_sav)) || (p_ptr->pclass == CLASS_BERSERKER))
3634                         {
3635                                 /* Do nothing */ ;
3636                         }
3637                         else
3638                         {
3639                                 msg_print(_("彫像になった気分だ!", "You feel like a statue!"));
3640                                 if (p_ptr->free_act)
3641                                         set_paralyzed(p_ptr->paralyzed + randint1(3));
3642                                 else
3643                                         set_paralyzed(p_ptr->paralyzed + randint1(13));
3644                                 stop_ty = TRUE;
3645                         }
3646                         if (!one_in_(6)) break;
3647                 case 21: case 22: case 23:
3648                         (void)do_dec_stat(randint0(6));
3649                         if (!one_in_(6)) break;
3650                 case 24:
3651                         msg_print(_("ほえ?私は誰?ここで何してる?", "Huh? Who am I? What am I doing here?"));
3652                         lose_all_info();
3653                         if (!one_in_(6)) break;
3654                 case 25:
3655                         /*
3656                          * Only summon Cyberdemons deep in the dungeon.
3657                          */
3658                         if ((dun_level > 65) && !stop_ty)
3659                         {
3660                                 (*count) += summon_cyber(-1, p_ptr->y, p_ptr->x);
3661                                 stop_ty = TRUE;
3662                                 break;
3663                         }
3664                         if (!one_in_(6)) break;
3665                 default:
3666                         while (i < 6)
3667                         {
3668                                 do
3669                                 {
3670                                         (void)do_dec_stat(i);
3671                                 }
3672                                 while (one_in_(2));
3673
3674                                 i++;
3675                         }
3676                 }
3677         }
3678         while (one_in_(3) && !stop_ty);
3679
3680         return stop_ty;
3681 }
3682
3683 /*!
3684  * @brief HI_SUMMON(上級召喚)処理発動
3685  * @param y 召喚位置Y座標
3686  * @param x 召喚位置X座標
3687  * @param can_pet プレイヤーのペットとなる可能性があるならばTRUEにする
3688  * @return 作用が実際にあった場合TRUEを返す
3689  */
3690 int activate_hi_summon(POSITION y, POSITION x, bool can_pet)
3691 {
3692         int i;
3693         int count = 0;
3694         DEPTH summon_lev;
3695         BIT_FLAGS mode = PM_ALLOW_GROUP;
3696         bool pet = FALSE;
3697
3698         if (can_pet)
3699         {
3700                 if (one_in_(4))
3701                 {
3702                         mode |= PM_FORCE_FRIENDLY;
3703                 }
3704                 else
3705                 {
3706                         mode |= PM_FORCE_PET;
3707                         pet = TRUE;
3708                 }
3709         }
3710
3711         if (!pet) mode |= PM_NO_PET;
3712
3713         summon_lev = (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : dun_level);
3714
3715         for (i = 0; i < (randint1(7) + (dun_level / 40)); i++)
3716         {
3717                 switch (randint1(25) + (dun_level / 20))
3718                 {
3719                         case 1: case 2:
3720                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANT, mode);
3721                                 break;
3722                         case 3: case 4:
3723                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_SPIDER, mode);
3724                                 break;
3725                         case 5: case 6:
3726                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HOUND, mode);
3727                                 break;
3728                         case 7: case 8:
3729                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HYDRA, mode);
3730                                 break;
3731                         case 9: case 10:
3732                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_ANGEL, mode);
3733                                 break;
3734                         case 11: case 12:
3735                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNDEAD, mode);
3736                                 break;
3737                         case 13: case 14:
3738                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DRAGON, mode);
3739                                 break;
3740                         case 15: case 16:
3741                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_DEMON, mode);
3742                                 break;
3743                         case 17:
3744                                 if (can_pet) break;
3745                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_AMBERITES, (mode | PM_ALLOW_UNIQUE));
3746                                 break;
3747                         case 18: case 19:
3748                                 if (can_pet) break;
3749                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_UNIQUE, (mode | PM_ALLOW_UNIQUE));
3750                                 break;
3751                         case 20: case 21:
3752                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3753                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_UNDEAD, mode);
3754                                 break;
3755                         case 22: case 23:
3756                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3757                                 count += summon_specific((pet ? -1 : 0), y, x, summon_lev, SUMMON_HI_DRAGON, mode);
3758                                 break;
3759                         case 24:
3760                                 count += summon_specific((pet ? -1 : 0), y, x, 100, SUMMON_CYBER, mode);
3761                                 break;
3762                         default:
3763                                 if (!can_pet) mode |= PM_ALLOW_UNIQUE;
3764                                 count += summon_specific((pet ? -1 : 0), y, x,pet ? summon_lev : (((summon_lev * 3) / 2) + 5), 0, mode);
3765                 }
3766         }
3767
3768         return count;
3769 }
3770
3771
3772 /*!
3773  * @brief サイバーデーモンの召喚
3774  * @param who 召喚主のモンスターID(0ならばプレイヤー)
3775  * @param y 召喚位置Y座標
3776  * @param x 召喚位置X座標
3777  * @return 作用が実際にあった場合TRUEを返す
3778  */
3779 int summon_cyber(MONSTER_IDX who, POSITION y, POSITION x)
3780 {
3781         int i;
3782         int max_cyber = (easy_band ? 1 : (dun_level / 50) + randint1(2));
3783         int count = 0;
3784         BIT_FLAGS mode = PM_ALLOW_GROUP;
3785
3786         /* Summoned by a monster */
3787         if (who > 0)
3788         {
3789                 monster_type *m_ptr = &m_list[who];
3790                 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3791         }
3792
3793         if (max_cyber > 4) max_cyber = 4;
3794
3795         for (i = 0; i < max_cyber; i++)
3796         {
3797                 count += summon_specific(who, y, x, 100, SUMMON_CYBER, mode);
3798         }
3799
3800         return count;
3801 }
3802
3803 /*!
3804  * @brief 周辺破壊効果(プレイヤー中心)
3805  * @return 作用が実際にあった場合TRUEを返す
3806  */
3807 void wall_breaker(void)
3808 {
3809         int i;
3810         POSITION y = 0, x = 0;
3811         int attempts = 1000;
3812
3813         if (randint1(80 + p_ptr->lev) < 70)
3814         {
3815                 while (attempts--)
3816                 {
3817                         scatter(&y, &x, p_ptr->y, p_ptr->x, 4, 0);
3818
3819                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
3820
3821                         if (!player_bold(y, x)) break;
3822                 }
3823
3824                 project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3825                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3826         }
3827         else if (randint1(100) > 30)
3828         {
3829                 earthquake(p_ptr->y, p_ptr->x, 1);
3830         }
3831         else
3832         {
3833                 int num = damroll(5, 3);
3834
3835                 for (i = 0; i < num; i++)
3836                 {
3837                         while (1)
3838                         {
3839                                 scatter(&y, &x, p_ptr->y, p_ptr->x, 10, 0);
3840
3841                                 if (!player_bold(y, x)) break;
3842                         }
3843
3844                         project(0, 0, y, x, 20 + randint1(30), GF_KILL_WALL,
3845                                           (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
3846                 }
3847         }
3848 }
3849
3850
3851 /*!
3852  * @brief パニック・モンスター効果(プレイヤー視界範囲内) / Confuse monsters
3853  * @param dam 効力
3854  * @return 作用が実際にあった場合TRUEを返す
3855  */
3856 bool confuse_monsters(HIT_POINT dam)
3857 {
3858         return (project_hack(GF_OLD_CONF, dam));
3859 }
3860
3861
3862 /*!
3863  * @brief チャーム・モンスター効果(プレイヤー視界範囲内) / Charm monsters
3864  * @param dam 効力
3865  * @return 作用が実際にあった場合TRUEを返す
3866  */
3867 bool charm_monsters(HIT_POINT dam)
3868 {
3869         return (project_hack(GF_CHARM, dam));
3870 }
3871
3872
3873 /*!
3874  * @brief 動物魅了効果(プレイヤー視界範囲内) / Charm Animals
3875  * @param dam 効力
3876  * @return 作用が実際にあった場合TRUEを返す
3877  */
3878 bool charm_animals(HIT_POINT dam)
3879 {
3880         return (project_hack(GF_CONTROL_ANIMAL, dam));
3881 }
3882
3883
3884 /*!
3885  * @brief モンスター朦朧効果(プレイヤー視界範囲内) / Stun monsters
3886  * @param dam 効力
3887  * @return 作用が実際にあった場合TRUEを返す
3888  */
3889 bool stun_monsters(HIT_POINT dam)
3890 {
3891         return (project_hack(GF_STUN, dam));
3892 }
3893
3894
3895 /*!
3896  * @brief モンスター停止効果(プレイヤー視界範囲内) / Stasis monsters
3897  * @param dam 効力
3898  * @return 作用が実際にあった場合TRUEを返す
3899  */
3900 bool stasis_monsters(HIT_POINT dam)
3901 {
3902         return (project_hack(GF_STASIS, dam));
3903 }
3904
3905
3906 /*!
3907  * @brief モンスター精神攻撃効果(プレイヤー視界範囲内) / Mindblast monsters
3908  * @param dam 効力
3909  * @return 作用が実際にあった場合TRUEを返す
3910  */
3911 bool mindblast_monsters(HIT_POINT dam)
3912 {
3913         return (project_hack(GF_PSI, dam));
3914 }
3915
3916
3917 /*!
3918  * @brief モンスター追放効果(プレイヤー視界範囲内) / Banish all monsters
3919  * @param dist 効力(距離)
3920  * @return 作用が実際にあった場合TRUEを返す
3921  */
3922 bool banish_monsters(int dist)
3923 {
3924         return (project_hack(GF_AWAY_ALL, dist));
3925 }
3926
3927
3928 /*!
3929  * @brief 邪悪退散効果(プレイヤー視界範囲内) / Turn evil
3930  * @param dam 効力
3931  * @return 作用が実際にあった場合TRUEを返す
3932  */
3933 bool turn_evil(HIT_POINT dam)
3934 {
3935         return (project_hack(GF_TURN_EVIL, dam));
3936 }
3937
3938
3939 /*!
3940  * @brief 全モンスター退散効果(プレイヤー視界範囲内) / Turn everyone
3941  * @param dam 効力
3942  * @return 作用が実際にあった場合TRUEを返す
3943  */
3944 bool turn_monsters(HIT_POINT dam)
3945 {
3946         return (project_hack(GF_TURN_ALL, dam));
3947 }
3948
3949
3950 /*!
3951  * @brief 死の光線(プレイヤー視界範囲内) / Death-ray all monsters (note: OBSCENELY powerful)
3952  * @return 作用が実際にあった場合TRUEを返す
3953  */
3954 bool deathray_monsters(void)
3955 {
3956         return (project_hack(GF_DEATH_RAY, p_ptr->lev * 200));
3957 }
3958
3959 /*!
3960  * @brief チャーム・モンスター(1体)
3961  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3962  * @param plev パワー
3963  * @return 作用が実際にあった場合TRUEを返す
3964  */
3965 bool charm_monster(DIRECTION dir, PLAYER_LEVEL plev)
3966 {
3967         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3968         return (project_hook(GF_CHARM, dir, plev, flg));
3969 }
3970
3971 /*!
3972  * @brief アンデッド支配(1体)
3973  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3974  * @param plev パワー
3975  * @return 作用が実際にあった場合TRUEを返す
3976  */
3977 bool control_one_undead(DIRECTION dir, PLAYER_LEVEL plev)
3978 {
3979         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3980         return (project_hook(GF_CONTROL_UNDEAD, dir, plev, flg));
3981 }
3982
3983 /*!
3984  * @brief 悪魔支配(1体)
3985  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3986  * @param plev パワー
3987  * @return 作用が実際にあった場合TRUEを返す
3988  */
3989 bool control_one_demon(DIRECTION dir, PLAYER_LEVEL plev)
3990 {
3991         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
3992         return (project_hook(GF_CONTROL_DEMON, dir, plev, flg));
3993 }
3994
3995 /*!
3996  * @brief 動物支配(1体)
3997  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
3998  * @param plev パワー
3999  * @return 作用が実際にあった場合TRUEを返す
4000  */
4001 bool charm_animal(DIRECTION dir, PLAYER_LEVEL plev)
4002 {
4003         BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL;
4004         return (project_hook(GF_CONTROL_ANIMAL, dir, plev, flg));
4005 }
4006
4007
4008 /*!
4009  * @brief 変わり身処理
4010  * @param success 判定成功上の処理ならばTRUE
4011  * @return 作用が実際にあった場合TRUEを返す
4012  */
4013 bool kawarimi(bool success)
4014 {
4015         object_type forge;
4016         object_type *q_ptr = &forge;
4017         POSITION y, x;
4018
4019         if (p_ptr->is_dead) return FALSE;
4020         if (p_ptr->confused || p_ptr->blind || p_ptr->paralyzed || p_ptr->image) return FALSE;
4021         if (randint0(200) < p_ptr->stun) return FALSE;
4022
4023         if (!success && one_in_(3))
4024         {
4025                 msg_print(_("失敗!逃げられなかった。", "Failed! You couldn't run away."));
4026                 p_ptr->special_defense &= ~(NINJA_KAWARIMI);
4027                 p_ptr->redraw |= (PR_STATUS);
4028                 return FALSE;
4029         }
4030
4031         y = p_ptr->y;
4032         x = p_ptr->x;
4033
4034         teleport_player(10 + randint1(90), 0L);
4035
4036         object_wipe(q_ptr);
4037
4038         object_prep(q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE));
4039
4040         q_ptr->pval = MON_NINJA;
4041
4042         /* Drop it in the dungeon */
4043         (void)drop_near(q_ptr, -1, y, x);
4044
4045 #ifdef JP
4046         if (success) msg_print("攻撃を受ける前に素早く身をひるがえした。");
4047         else msg_print("失敗!攻撃を受けてしまった。");
4048 #else
4049         if (success) msg_print("You have turned around just before the attack hit you.");
4050         else msg_print("Failed! You are hit by the attack.");
4051 #endif
4052
4053         p_ptr->special_defense &= ~(NINJA_KAWARIMI);
4054         p_ptr->redraw |= (PR_STATUS);
4055
4056         /* Teleported */
4057         return TRUE;
4058 }
4059
4060
4061 /*!
4062  * @brief 入身処理 / "Rush Attack" routine for Samurai or Ninja
4063  * @param mdeath 目標モンスターが死亡したかを返す
4064  * @return 作用が実際にあった場合TRUEを返す /  Return value is for checking "done"
4065  */
4066 bool rush_attack(bool *mdeath)
4067 {
4068         DIRECTION dir;
4069         int tx, ty;
4070         int tm_idx = 0;
4071         u16b path_g[32];
4072         int path_n, i;
4073         bool tmp_mdeath = FALSE;
4074         bool moved = FALSE;
4075
4076         if (mdeath) *mdeath = FALSE;
4077
4078         project_length = 5;
4079         if (!get_aim_dir(&dir)) return FALSE;
4080
4081         /* Use the given direction */
4082         tx = p_ptr->x + project_length * ddx[dir];
4083         ty = p_ptr->y + project_length * ddy[dir];
4084
4085         /* Hack -- Use an actual "target" */
4086         if ((dir == 5) && target_okay())
4087         {
4088                 tx = target_col;
4089                 ty = target_row;
4090         }
4091
4092         if (in_bounds(ty, tx)) tm_idx = cave[ty][tx].m_idx;
4093
4094         path_n = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_STOP | PROJECT_KILL);
4095         project_length = 0;
4096
4097         /* No need to move */
4098         if (!path_n) return TRUE;
4099
4100         /* Use ty and tx as to-move point */
4101         ty = p_ptr->y;
4102         tx = p_ptr->x;
4103
4104         /* Project along the path */
4105         for (i = 0; i < path_n; i++)
4106         {
4107                 monster_type *m_ptr;
4108
4109                 int ny = GRID_Y(path_g[i]);
4110                 int nx = GRID_X(path_g[i]);
4111
4112                 if (cave_empty_bold(ny, nx) && player_can_enter(cave[ny][nx].feat, 0))
4113                 {
4114                         ty = ny;
4115                         tx = nx;
4116
4117                         /* Go to next grid */
4118                         continue;
4119                 }
4120
4121                 if (!cave[ny][nx].m_idx)
4122                 {
4123                         if (tm_idx)
4124                         {
4125                                 msg_print(_("失敗!", "Failed!"));
4126                         }
4127                         else
4128                         {
4129                                 msg_print(_("ここには入身では入れない。", "You can't move to that place."));
4130                         }
4131
4132                         /* Exit loop */
4133                         break;
4134                 }
4135
4136                 /* Move player before updating the monster */
4137                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4138
4139                 /* Update the monster */
4140                 update_mon(cave[ny][nx].m_idx, TRUE);
4141
4142                 /* Found a monster */
4143                 m_ptr = &m_list[cave[ny][nx].m_idx];
4144
4145                 if (tm_idx != cave[ny][nx].m_idx)
4146                 {
4147 #ifdef JP
4148                         msg_format("%s%sが立ちふさがっている!", tm_idx ? "別の" : "",
4149                                    m_ptr->ml ? "モンスター" : "何か");
4150 #else
4151                         msg_format("There is %s in the way!", m_ptr->ml ? (tm_idx ? "another monster" : "a monster") : "someone");
4152 #endif
4153                 }
4154                 else if (!player_bold(ty, tx))
4155                 {
4156                         /* Hold the monster name */
4157                         char m_name[80];
4158
4159                         /* Get the monster name (BEFORE polymorphing) */
4160                         monster_desc(m_name, m_ptr, 0);
4161                         msg_format(_("素早く%sの懐に入り込んだ!", "You quickly jump in and attack %s!"), m_name);
4162                 }
4163
4164                 if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4165                 moved = TRUE;
4166                 tmp_mdeath = py_attack(ny, nx, HISSATSU_NYUSIN);
4167
4168                 break;
4169         }
4170
4171         if (!moved && !player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
4172
4173         if (mdeath) *mdeath = tmp_mdeath;
4174         return TRUE;
4175 }
4176
4177
4178 /*!
4179  * @brief 全鏡の消去 / Remove all mirrors in this floor
4180  * @param explode 爆発処理を伴うならばTRUE
4181  * @return なし
4182  */
4183 void remove_all_mirrors(bool explode)
4184 {
4185         POSITION x, y;
4186
4187         for (x = 0; x < cur_wid; x++)
4188         {
4189                 for (y = 0; y < cur_hgt; y++)
4190                 {
4191                         if (is_mirror_grid(&cave[y][x]))
4192                         {
4193                                 remove_mirror(y, x);
4194                                 if (explode)
4195                                         project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS,
4196                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
4197                         }
4198                 }
4199         }
4200 }
4201
4202 /*!
4203  * @brief 『一つの指輪』の効果処理 /
4204  * Hack -- activate the ring of power
4205  * @param dir 発動の方向ID
4206  * @return なし
4207  */
4208 void ring_of_power(DIRECTION dir)
4209 {
4210         /* Pick a random effect */
4211         switch (randint1(10))
4212         {
4213         case 1:
4214         case 2:
4215         {
4216                 msg_print(_("あなたは悪性のオーラに包み込まれた。", "You are surrounded by a malignant aura."));
4217                 sound(SOUND_EVIL);
4218
4219                 /* Decrease all stats (permanently) */
4220                 (void)dec_stat(A_STR, 50, TRUE);
4221                 (void)dec_stat(A_INT, 50, TRUE);
4222                 (void)dec_stat(A_WIS, 50, TRUE);
4223                 (void)dec_stat(A_DEX, 50, TRUE);
4224                 (void)dec_stat(A_CON, 50, TRUE);
4225                 (void)dec_stat(A_CHR, 50, TRUE);
4226
4227                 /* Lose some experience (permanently) */
4228                 p_ptr->exp -= (p_ptr->exp / 4);
4229                 p_ptr->max_exp -= (p_ptr->exp / 4);
4230                 check_experience();
4231
4232                 break;
4233         }
4234
4235         case 3:
4236         {
4237                 msg_print(_("あなたは強力なオーラに包み込まれた。", "You are surrounded by a powerful aura."));
4238
4239                 /* Dispel monsters */
4240                 dispel_monsters(1000);
4241
4242                 break;
4243         }
4244
4245         case 4:
4246         case 5:
4247         case 6:
4248         {
4249                 /* Mana Ball */
4250                 fire_ball(GF_MANA, dir, 600, 3);
4251
4252                 break;
4253         }
4254
4255         case 7:
4256         case 8:
4257         case 9:
4258         case 10:
4259         {
4260                 /* Mana Bolt */
4261                 fire_bolt(GF_MANA, dir, 500);
4262
4263                 break;
4264         }
4265         }
4266 }
4267
4268 /*!
4269 * @brief 運命の輪、並びにカオス的な効果の発動
4270 * @param spell ランダムな効果を選択するための基準ID
4271 * @return なし
4272 */
4273 void wild_magic(int spell)
4274 {
4275         int counter = 0;
4276         int type = SUMMON_MOLD + randint0(6);
4277
4278         if (type < SUMMON_MOLD) type = SUMMON_MOLD;
4279         else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
4280
4281         switch (randint1(spell) + randint1(8) + 1)
4282         {
4283         case 1:
4284         case 2:
4285         case 3:
4286                 teleport_player(10, TELEPORT_PASSIVE);
4287                 break;
4288         case 4:
4289         case 5:
4290         case 6:
4291                 teleport_player(100, TELEPORT_PASSIVE);
4292                 break;
4293         case 7:
4294         case 8:
4295                 teleport_player(200, TELEPORT_PASSIVE);
4296                 break;
4297         case 9:
4298         case 10:
4299         case 11:
4300                 unlite_area(10, 3);
4301                 break;
4302         case 12:
4303         case 13:
4304         case 14:
4305                 lite_area(damroll(2, 3), 2);
4306                 break;
4307         case 15:
4308                 destroy_doors_touch();
4309                 break;
4310         case 16: case 17:
4311                 wall_breaker();
4312         case 18:
4313                 sleep_monsters_touch();
4314                 break;
4315         case 19:
4316         case 20:
4317                 trap_creation(p_ptr->y, p_ptr->x);
4318                 break;
4319         case 21:
4320         case 22:
4321                 door_creation();
4322                 break;
4323         case 23:
4324         case 24:
4325         case 25:
4326                 aggravate_monsters(0);
4327                 break;
4328         case 26:
4329                 earthquake(p_ptr->y, p_ptr->x, 5);
4330                 break;
4331         case 27:
4332         case 28:
4333                 (void)gain_random_mutation(0);
4334                 break;
4335         case 29:
4336         case 30:
4337                 apply_disenchant(1);
4338                 break;
4339         case 31:
4340                 lose_all_info();
4341                 break;
4342         case 32:
4343                 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
4344                 break;
4345         case 33:
4346                 wall_stone();
4347                 break;
4348         case 34:
4349         case 35:
4350                 while (counter++ < 8)
4351                 {
4352                         (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
4353                 }
4354                 break;
4355         case 36:
4356         case 37:
4357                 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4358                 break;
4359         case 38:
4360                 (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
4361                 break;
4362         default:
4363         {
4364                 int count = 0;
4365                 (void)activate_ty_curse(FALSE, &count);
4366                 break;
4367         }
4368         }
4369
4370         return;
4371 }
4372
4373 /*!
4374 * @brief カオス魔法「流星群」の処理としてプレイヤーを中心に隕石落下処理を10+1d10回繰り返す。
4375 * / Drop 10+1d10 meteor ball at random places near the player
4376 * @param dam ダメージ
4377 * @param rad 効力の半径
4378 * @return なし
4379 */
4380 void cast_meteor(HIT_POINT dam, POSITION rad)
4381 {
4382         int i;
4383         int b = 10 + randint1(10);
4384
4385         for (i = 0; i < b; i++)
4386         {
4387                 POSITION y = 0, x = 0;
4388                 int count;
4389
4390                 for (count = 0; count <= 20; count++)
4391                 {
4392                         int dy, dx, d;
4393
4394                         x = p_ptr->x - 8 + randint0(17);
4395                         y = p_ptr->y - 8 + randint0(17);
4396
4397                         dx = (p_ptr->x > x) ? (p_ptr->x - x) : (x - p_ptr->x);
4398                         dy = (p_ptr->y > y) ? (p_ptr->y - y) : (y - p_ptr->y);
4399
4400                         /* Approximate distance */
4401                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4402
4403                         if (d >= 9) continue;
4404
4405                         if (!in_bounds(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)
4406                                 || !cave_have_flag_bold(y, x, FF_PROJECT)) continue;
4407
4408                         /* Valid position */
4409                         break;
4410                 }
4411
4412                 if (count > 20) continue;
4413
4414                 project(0, rad, y, x, dam, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
4415         }
4416 }
4417
4418
4419 /*!
4420 * @brief 破邪魔法「神の怒り」の処理としてターゲットを指定した後分解のボールを最大20回発生させる。
4421 * @param dam ダメージ
4422 * @param rad 効力の半径
4423 * @return ターゲットを指定し、実行したならばTRUEを返す。
4424 */
4425 bool cast_wrath_of_the_god(HIT_POINT dam, POSITION rad)
4426 {
4427         POSITION x, y, tx, ty;
4428         POSITION nx, ny;
4429         DIRECTION dir;
4430         int i;
4431         int b = 10 + randint1(10);
4432
4433         if (!get_aim_dir(&dir)) return FALSE;
4434
4435         /* Use the given direction */
4436         tx = p_ptr->x + 99 * ddx[dir];
4437         ty = p_ptr->y + 99 * ddy[dir];
4438
4439         /* Hack -- Use an actual "target" */
4440         if ((dir == 5) && target_okay())
4441         {
4442                 tx = target_col;
4443                 ty = target_row;
4444         }
4445
4446         x = p_ptr->x;
4447         y = p_ptr->y;
4448
4449         while (1)
4450         {
4451                 /* Hack -- Stop at the target */
4452                 if ((y == ty) && (x == tx)) break;
4453
4454                 ny = y;
4455                 nx = x;
4456                 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
4457
4458                 /* Stop at maximum range */
4459                 if (MAX_RANGE <= distance(p_ptr->y, p_ptr->x, ny, nx)) break;
4460
4461                 /* Stopped by walls/doors */
4462                 if (!cave_have_flag_bold(ny, nx, FF_PROJECT)) break;
4463
4464                 /* Stopped by monsters */
4465                 if ((dir != 5) && cave[ny][nx].m_idx != 0) break;
4466
4467                 /* Save the new location */
4468                 x = nx;
4469                 y = ny;
4470         }
4471         tx = x;
4472         ty = y;
4473
4474         for (i = 0; i < b; i++)
4475         {
4476                 int count = 20, d = 0;
4477
4478                 while (count--)
4479                 {
4480                         int dx, dy;
4481
4482                         x = tx - 5 + randint0(11);
4483                         y = ty - 5 + randint0(11);
4484
4485                         dx = (tx > x) ? (tx - x) : (x - tx);
4486                         dy = (ty > y) ? (ty - y) : (y - ty);
4487
4488                         /* Approximate distance */
4489                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4490                         /* Within the radius */
4491                         if (d < 5) break;
4492                 }
4493
4494                 if (count < 0) continue;
4495
4496                 /* Cannot penetrate perm walls */
4497                 if (!in_bounds(y, x) ||
4498                         cave_stop_disintegration(y, x) ||
4499                         !in_disintegration_range(ty, tx, y, x))
4500                         continue;
4501
4502                 project(0, rad, y, x, dam, GF_DISINTEGRATE, PROJECT_JUMP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
4503         }
4504
4505         return TRUE;
4506 }
4507
4508 /*!
4509 * @brief 「ワンダー」のランダムな効果を決定して処理する。
4510 * @param dir 方向ID
4511 * @return なし
4512 * @details
4513 * This spell should become more useful (more controlled) as the\n
4514 * player gains experience levels.  Thus, add 1/5 of the player's\n
4515 * level to the die roll.  This eliminates the worst effects later on,\n
4516 * while keeping the results quite random.  It also allows some potent\n
4517 * effects only at high level.
4518 */
4519 void cast_wonder(DIRECTION dir)
4520 {
4521         PLAYER_LEVEL plev = p_ptr->lev;
4522         int die = randint1(100) + plev / 5;
4523         int vir = virtue_number(V_CHANCE);
4524
4525         if (vir)
4526         {
4527                 if (p_ptr->virtues[vir - 1] > 0)
4528                 {
4529                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4530                 }
4531                 else
4532                 {
4533                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4534                 }
4535         }
4536
4537         if (die < 26)
4538                 chg_virtue(V_CHANCE, 1);
4539
4540         if (die > 100)
4541         {
4542                 msg_print(_("あなたは力がみなぎるのを感じた!", "You feel a surge of power!"));
4543         }
4544
4545         if (die < 8) clone_monster(dir);
4546         else if (die < 14) speed_monster(dir, plev);
4547         else if (die < 26) heal_monster(dir, damroll(4, 6));
4548         else if (die < 31) poly_monster(dir, plev);
4549         else if (die < 36)
4550                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4551                         damroll(3 + ((plev - 1) / 5), 4));
4552         else if (die < 41) confuse_monster(dir, plev);
4553         else if (die < 46) fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4554         else if (die < 51) (void)lite_line(dir, damroll(6, 8));
4555         else if (die < 56)
4556                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4557                         damroll(3 + ((plev - 5) / 4), 8));
4558         else if (die < 61)
4559                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4560                         damroll(5 + ((plev - 5) / 4), 8));
4561         else if (die < 66)
4562                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4563                         damroll(6 + ((plev - 5) / 4), 8));
4564         else if (die < 71)
4565                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4566                         damroll(8 + ((plev - 5) / 4), 8));
4567         else if (die < 76) hypodynamic_bolt(dir, 75);
4568         else if (die < 81) fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4569         else if (die < 86) fire_ball(GF_ACID, dir, 40 + plev, 2);
4570         else if (die < 91) fire_ball(GF_ICE, dir, 70 + plev, 3);
4571         else if (die < 96) fire_ball(GF_FIRE, dir, 80 + plev, 3);
4572         else if (die < 101) hypodynamic_bolt(dir, 100 + plev);
4573         else if (die < 104)
4574         {
4575                 earthquake(p_ptr->y, p_ptr->x, 12);
4576         }
4577         else if (die < 106)
4578         {
4579                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4580         }
4581         else if (die < 108)
4582         {
4583                 symbol_genocide(plev + 50, TRUE);
4584         }
4585         else if (die < 110) dispel_monsters(120);
4586         else /* RARE */
4587         {
4588                 dispel_monsters(150);
4589                 slow_monsters(plev);
4590                 sleep_monsters(plev);
4591                 hp_player(300);
4592         }
4593 }
4594
4595
4596 /*!
4597 * @brief 「悪霊召喚」のランダムな効果を決定して処理する。
4598 * @param dir 方向ID
4599 * @return なし
4600 */
4601 void cast_invoke_spirits(DIRECTION dir)
4602 {
4603         PLAYER_LEVEL plev = p_ptr->lev;
4604         int die = randint1(100) + plev / 5;
4605         int vir = virtue_number(V_CHANCE);
4606
4607         if (vir)
4608         {
4609                 if (p_ptr->virtues[vir - 1] > 0)
4610                 {
4611                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4612                 }
4613                 else
4614                 {
4615                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4616                 }
4617         }
4618
4619         msg_print(_("あなたは死者たちの力を招集した...", "You call on the power of the dead..."));
4620         if (die < 26)
4621                 chg_virtue(V_CHANCE, 1);
4622
4623         if (die > 100)
4624         {
4625                 msg_print(_("あなたはおどろおどろしい力のうねりを感じた!", "You feel a surge of eldritch force!"));
4626         }
4627
4628         if (die < 8)
4629         {
4630                 msg_print(_("なんてこった!あなたの周りの地面から朽ちた人影が立ち上がってきた!",
4631                         "Oh no! Mouldering forms rise from the earth around you!"));
4632
4633                 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4634                 chg_virtue(V_UNLIFE, 1);
4635         }
4636         else if (die < 14)
4637         {
4638                 msg_print(_("名状し難い邪悪な存在があなたの心を通り過ぎて行った...", "An unnamable evil brushes against your mind..."));
4639
4640                 set_afraid(p_ptr->afraid + randint1(4) + 4);
4641         }
4642         else if (die < 26)
4643         {
4644                 msg_print(_("あなたの頭に大量の幽霊たちの騒々しい声が押し寄せてきた...",
4645                         "Your head is invaded by a horde of gibbering spectral voices..."));
4646
4647                 set_confused(p_ptr->confused + randint1(4) + 4);
4648         }
4649         else if (die < 31)
4650         {
4651                 poly_monster(dir, plev);
4652         }
4653         else if (die < 36)
4654         {
4655                 fire_bolt_or_beam(beam_chance() - 10, GF_MISSILE, dir,
4656                         damroll(3 + ((plev - 1) / 5), 4));
4657         }
4658         else if (die < 41)
4659         {
4660                 confuse_monster(dir, plev);
4661         }
4662         else if (die < 46)
4663         {
4664                 fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
4665         }
4666         else if (die < 51)
4667         {
4668                 (void)lite_line(dir, damroll(6, 8));
4669         }
4670         else if (die < 56)
4671         {
4672                 fire_bolt_or_beam(beam_chance() - 10, GF_ELEC, dir,
4673                         damroll(3 + ((plev - 5) / 4), 8));
4674         }
4675         else if (die < 61)
4676         {
4677                 fire_bolt_or_beam(beam_chance() - 10, GF_COLD, dir,
4678                         damroll(5 + ((plev - 5) / 4), 8));
4679         }
4680         else if (die < 66)
4681         {
4682                 fire_bolt_or_beam(beam_chance(), GF_ACID, dir,
4683                         damroll(6 + ((plev - 5) / 4), 8));
4684         }
4685         else if (die < 71)
4686         {
4687                 fire_bolt_or_beam(beam_chance(), GF_FIRE, dir,
4688                         damroll(8 + ((plev - 5) / 4), 8));
4689         }
4690         else if (die < 76)
4691         {
4692                 hypodynamic_bolt(dir, 75);
4693         }
4694         else if (die < 81)
4695         {
4696                 fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
4697         }
4698         else if (die < 86)
4699         {
4700                 fire_ball(GF_ACID, dir, 40 + plev, 2);
4701         }
4702         else if (die < 91)
4703         {
4704                 fire_ball(GF_ICE, dir, 70 + plev, 3);
4705         }
4706         else if (die < 96)
4707         {
4708                 fire_ball(GF_FIRE, dir, 80 + plev, 3);
4709         }
4710         else if (die < 101)
4711         {
4712                 hypodynamic_bolt(dir, 100 + plev);
4713         }
4714         else if (die < 104)
4715         {
4716                 earthquake(p_ptr->y, p_ptr->x, 12);
4717         }
4718         else if (die < 106)
4719         {
4720                 (void)destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE);
4721         }
4722         else if (die < 108)
4723         {
4724                 symbol_genocide(plev + 50, TRUE);
4725         }
4726         else if (die < 110)
4727         {
4728                 dispel_monsters(120);
4729         }
4730         else
4731         { /* RARE */
4732                 dispel_monsters(150);
4733                 slow_monsters(plev);
4734                 sleep_monsters(plev);
4735                 hp_player(300);
4736         }
4737
4738         if (die < 31)
4739         {
4740                 msg_print(_("陰欝な声がクスクス笑う。「もうすぐおまえは我々の仲間になるだろう。弱き者よ。」",
4741                         "Sepulchral voices chuckle. 'Soon you will join us, mortal.'"));
4742         }
4743 }
4744
4745 /*!
4746 * @brief トランプ領域の「シャッフル」の効果をランダムに決めて処理する。
4747 * @return なし
4748 */
4749 void cast_shuffle(void)
4750 {
4751         PLAYER_LEVEL plev = p_ptr->lev;
4752         DIRECTION dir;
4753         int die;
4754         int vir = virtue_number(V_CHANCE);
4755         int i;
4756
4757         /* Card sharks and high mages get a level bonus */
4758         if ((p_ptr->pclass == CLASS_ROGUE) ||
4759                 (p_ptr->pclass == CLASS_HIGH_MAGE) ||
4760                 (p_ptr->pclass == CLASS_SORCERER))
4761                 die = (randint1(110)) + plev / 5;
4762         else
4763                 die = randint1(120);
4764
4765
4766         if (vir)
4767         {
4768                 if (p_ptr->virtues[vir - 1] > 0)
4769                 {
4770                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
4771                 }
4772                 else
4773                 {
4774                         while (randint1(400) < (0 - p_ptr->virtues[vir - 1])) die--;
4775                 }
4776         }
4777
4778         msg_print(_("あなたはカードを切って一枚引いた...", "You shuffle the deck and draw a card..."));
4779
4780         if (die < 30)
4781                 chg_virtue(V_CHANCE, 1);
4782
4783         if (die < 7)
4784         {
4785                 msg_print(_("なんてこった!《死》だ!", "Oh no! It's Death!"));
4786
4787                 for (i = 0; i < randint1(3); i++)
4788                         activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4789         }
4790         else if (die < 14)
4791         {
4792                 msg_print(_("なんてこった!《悪魔》だ!", "Oh no! It's the Devil!"));
4793                 summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4794         }
4795         else if (die < 18)
4796         {
4797                 int count = 0;
4798                 msg_print(_("なんてこった!《吊られた男》だ!", "Oh no! It's the Hanged Man."));
4799                 activate_ty_curse(FALSE, &count);
4800         }
4801         else if (die < 22)
4802         {
4803                 msg_print(_("《不調和の剣》だ。", "It's the swords of discord."));
4804                 aggravate_monsters(0);
4805         }
4806         else if (die < 26)
4807         {
4808                 msg_print(_("《愚者》だ。", "It's the Fool."));
4809                 do_dec_stat(A_INT);
4810                 do_dec_stat(A_WIS);
4811         }
4812         else if (die < 30)
4813         {
4814                 msg_print(_("奇妙なモンスターの絵だ。", "It's the picture of a strange monster."));
4815                 trump_summoning(1, FALSE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), (32 + randint1(6)), PM_ALLOW_GROUP | PM_ALLOW_UNIQUE);
4816         }
4817         else if (die < 33)
4818         {
4819                 msg_print(_("《月》だ。", "It's the Moon."));
4820                 unlite_area(10, 3);
4821         }
4822         else if (die < 38)
4823         {
4824                 msg_print(_("《運命の輪》だ。", "It's the Wheel of Fortune."));
4825                 wild_magic(randint0(32));
4826         }
4827         else if (die < 40)
4828         {
4829                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4830                 teleport_player(10, TELEPORT_PASSIVE);
4831         }
4832         else if (die < 42)
4833         {
4834                 msg_print(_("《正義》だ。", "It's Justice."));
4835                 set_blessed(p_ptr->lev, FALSE);
4836         }
4837         else if (die < 47)
4838         {
4839                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4840                 teleport_player(100, TELEPORT_PASSIVE);
4841         }
4842         else if (die < 52)
4843         {
4844                 msg_print(_("テレポート・カードだ。", "It's a teleport trump card."));
4845                 teleport_player(200, TELEPORT_PASSIVE);
4846         }
4847         else if (die < 60)
4848         {
4849                 msg_print(_("《塔》だ。", "It's the Tower."));
4850                 wall_breaker();
4851         }
4852         else if (die < 72)
4853         {
4854                 msg_print(_("《節制》だ。", "It's Temperance."));
4855                 sleep_monsters_touch();
4856         }
4857         else if (die < 80)
4858         {
4859                 msg_print(_("《塔》だ。", "It's the Tower."));
4860
4861                 earthquake(p_ptr->y, p_ptr->x, 5);
4862         }
4863         else if (die < 82)
4864         {
4865                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4866                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_MOLD, 0L);
4867         }
4868         else if (die < 84)
4869         {
4870                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4871                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_BAT, 0L);
4872         }
4873         else if (die < 86)
4874         {
4875                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4876                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_VORTEX, 0L);
4877         }
4878         else if (die < 88)
4879         {
4880                 msg_print(_("友好的なモンスターの絵だ。", "It's the picture of a friendly monster."));
4881                 trump_summoning(1, TRUE, p_ptr->y, p_ptr->x, (dun_level * 3 / 2), SUMMON_COIN_MIMIC, 0L);
4882         }
4883         else if (die < 96)
4884         {
4885                 msg_print(_("《恋人》だ。", "It's the Lovers."));
4886
4887                 if (get_aim_dir(&dir))
4888                         charm_monster(dir, MIN(p_ptr->lev, 20));
4889         }
4890         else if (die < 101)
4891         {
4892                 msg_print(_("《隠者》だ。", "It's the Hermit."));
4893                 wall_stone();
4894         }
4895         else if (die < 111)
4896         {
4897                 msg_print(_("《審判》だ。", "It's the Judgement."));
4898                 do_cmd_rerate(FALSE);
4899                 lose_all_mutations();
4900         }
4901         else if (die < 120)
4902         {
4903                 msg_print(_("《太陽》だ。", "It's the Sun."));
4904                 chg_virtue(V_KNOWLEDGE, 1);
4905                 chg_virtue(V_ENLIGHTEN, 1);
4906                 wiz_lite(FALSE);
4907         }
4908         else
4909         {
4910                 msg_print(_("《世界》だ。", "It's the World."));
4911                 if (p_ptr->exp < PY_MAX_EXP)
4912                 {
4913                         s32b ee = (p_ptr->exp / 25) + 1;
4914                         if (ee > 5000) ee = 5000;
4915                         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4916                         gain_exp(ee);
4917                 }
4918         }
4919 }
4920
4921 bool_hack life_stream(bool_hack message, bool_hack virtue)
4922 {
4923         if(virtue)
4924         {
4925                 chg_virtue(V_VITALITY, 1);
4926                 chg_virtue(V_UNLIFE, -5);
4927         }
4928         if(message)
4929         {
4930                 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
4931         }
4932         restore_level();
4933         (void)set_poisoned(0);
4934         (void)set_blind(0);
4935         (void)set_confused(0);
4936         (void)set_image(0);
4937         (void)set_stun(0);
4938         (void)set_cut(0);
4939         (void)restore_all_status();
4940         (void)set_shero(0, TRUE);
4941         update_stuff();
4942         hp_player(5000);
4943
4944         return TRUE;
4945 }
4946
4947 bool_hack heroism(int base)
4948 {
4949         bool_hack ident = FALSE;
4950         if(set_afraid(0)) ident = TRUE;
4951         if(set_hero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4952         if(hp_player(10)) ident = TRUE;
4953         return ident;
4954 }
4955
4956 bool_hack berserk(int base)
4957 {
4958         bool_hack ident = FALSE;
4959         if (set_afraid(0)) ident = TRUE;
4960         if (set_shero(p_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
4961         if (hp_player(30)) ident = TRUE;
4962         return ident;
4963 }
4964
4965 bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides)
4966 {
4967         bool_hack ident = FALSE;
4968         if (hp_player(damroll(dice, sides))) ident = TRUE;
4969         if (set_blind(0)) ident = TRUE;
4970         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
4971         if (set_shero(0, TRUE)) ident = TRUE;
4972         return ident;
4973 }
4974
4975 bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides)
4976 {
4977         bool_hack ident = FALSE;
4978         if (hp_player(damroll(dice, sides))) ident = TRUE;
4979         if (set_blind(0)) ident = TRUE;
4980         if (set_confused(0)) ident = TRUE;
4981         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
4982         if (set_shero(0, TRUE)) ident = TRUE;
4983         return ident;
4984 }
4985
4986 bool_hack cure_critical_wounds(HIT_POINT pow)
4987 {
4988         bool_hack ident = FALSE;
4989         if (hp_player(pow)) ident = TRUE;
4990         if (set_blind(0)) ident = TRUE;
4991         if (set_confused(0)) ident = TRUE;
4992         if (set_poisoned(0)) ident = TRUE;
4993         if (set_stun(0)) ident = TRUE;
4994         if (set_cut(0)) ident = TRUE;
4995         if (set_shero(0, TRUE)) ident = TRUE;
4996         return ident;
4997 }
4998
4999 bool_hack true_healing(HIT_POINT pow)
5000 {
5001         bool_hack ident = FALSE;
5002         if (hp_player(pow)) ident = TRUE;
5003         if (set_blind(0)) ident = TRUE;
5004         if (set_confused(0)) ident = TRUE;
5005         if (set_poisoned(0)) ident = TRUE;
5006         if (set_stun(0)) ident = TRUE;
5007         if (set_cut(0)) ident = TRUE;
5008         if (set_image(0)) ident = TRUE;
5009         return ident;
5010 }
5011
5012 bool_hack restore_mana(bool_hack magic_eater)
5013 {
5014         bool_hack ident = FALSE;
5015
5016         if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
5017         {
5018                 int i;
5019                 for (i = 0; i < EATER_EXT * 2; i++)
5020                 {
5021                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
5022                         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;
5023                 }
5024                 for (; i < EATER_EXT * 3; i++)
5025                 {
5026                         KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
5027                         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;
5028                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
5029                 }
5030                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
5031                 p_ptr->window |= (PW_PLAYER);
5032                 ident = TRUE;
5033         }
5034         else if (p_ptr->csp < p_ptr->msp)
5035         {
5036                 p_ptr->csp = p_ptr->msp;
5037                 p_ptr->csp_frac = 0;
5038                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
5039                 p_ptr->redraw |= (PR_MANA);
5040                 p_ptr->window |= (PW_PLAYER);
5041                 p_ptr->window |= (PW_SPELL);
5042                 ident = TRUE;
5043         }
5044
5045         return ident;
5046 }
5047
5048 bool restore_all_status(void)
5049 {
5050         bool ident = FALSE; 
5051         if (do_res_stat(A_STR)) ident = TRUE;
5052         if (do_res_stat(A_INT)) ident = TRUE;
5053         if (do_res_stat(A_WIS)) ident = TRUE;
5054         if (do_res_stat(A_DEX)) ident = TRUE;
5055         if (do_res_stat(A_CON)) ident = TRUE;
5056         if (do_res_stat(A_CHR)) ident = TRUE;
5057         return ident;
5058 }
5059
5060 /*!
5061  * @brief 口を使う継続的な処理を中断する
5062  * @return なし
5063  */
5064 void stop_mouth(void)
5065 {
5066         if (music_singing_any()) stop_singing();
5067         if (hex_spelling_any()) stop_hex_spell_all();
5068 }
5069
5070
5071 bool_hack vampirism(void)
5072 {
5073         DIRECTION dir;
5074         POSITION x, y;
5075         int dummy;
5076         cave_type *c_ptr;
5077
5078         if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
5079         {
5080                 msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking."));
5081                 return FALSE;
5082         }
5083
5084         /* Only works on adjacent monsters */
5085         if (!get_rep_dir2(&dir)) return FALSE;
5086         y = p_ptr->y + ddy[dir];
5087         x = p_ptr->x + ddx[dir];
5088         c_ptr = &cave[y][x];
5089
5090         stop_mouth();
5091
5092         if (!(c_ptr->m_idx))
5093         {
5094                 msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
5095                 return FALSE;
5096         }
5097
5098         msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
5099
5100         dummy = p_ptr->lev * 2;
5101
5102         if (hypodynamic_bolt(dir, dummy))
5103         {
5104                 if (p_ptr->food < PY_FOOD_FULL)
5105                         /* No heal if we are "full" */
5106                         (void)hp_player(dummy);
5107                 else
5108                         msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
5109
5110                 /* Gain nutritional sustenance: 150/hp drained */
5111                 /* A Food ration gives 5000 food points (by contrast) */
5112                 /* Don't ever get more than "Full" this way */
5113                 /* But if we ARE Gorged,  it won't cure us */
5114                 dummy = p_ptr->food + MIN(5000, 100 * dummy);
5115                 if (p_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
5116                         (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
5117         }
5118         else
5119                 msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
5120         return TRUE;
5121 }
5122
5123 bool panic_hit(void)
5124 {
5125         DIRECTION dir;
5126         POSITION x, y;
5127
5128         if (!get_rep_dir2(&dir)) return FALSE;
5129         y = p_ptr->y + ddy[dir];
5130         x = p_ptr->x + ddx[dir];
5131         if (cave[y][x].m_idx)
5132         {
5133                 py_attack(y, x, 0);
5134                 if (randint0(p_ptr->skill_dis) < 7)
5135                         msg_print(_("うまく逃げられなかった。", "You failed to run away."));
5136                 else
5137                         teleport_player(30, 0L);
5138                 return TRUE;
5139         }
5140         else
5141         {
5142                 msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
5143                 msg_print(NULL);
5144                 return FALSE;
5145         }
5146
5147 }
5148
5149 /*!
5150 * @brief 超能力者のサイコメトリー処理/ Forcibly pseudo-identify an object in the inventory (or on the floor)
5151 * @return なし
5152 * @note
5153 * currently this function allows pseudo-id of any object,
5154 * including silly ones like potions & scrolls, which always
5155 * get '{average}'. This should be changed, either to stop such
5156 * items from being pseudo-id'd, or to allow psychometry to
5157 * detect whether the unidentified potion/scroll/etc is
5158 * good (Cure Light Wounds, Restore Strength, etc) or
5159 * bad (Poison, Weakness etc) or 'useless' (Slime Mold Juice, etc).
5160 */
5161 bool psychometry(void)
5162 {
5163         OBJECT_IDX      item;
5164         object_type     *o_ptr;
5165         char            o_name[MAX_NLEN];
5166         byte            feel;
5167         cptr            q, s;
5168         bool okay = FALSE;
5169
5170         item_tester_no_ryoute = TRUE;
5171         q = _("どのアイテムを調べますか?", "Meditate on which item? ");
5172         s = _("調べるアイテムがありません。", "You have nothing appropriate.");
5173
5174         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
5175
5176         /* Get the item (in the pack) */
5177         if (item >= 0)
5178         {
5179                 o_ptr = &inventory[item];
5180         }
5181
5182         /* Get the item (on the floor) */
5183         else
5184         {
5185                 o_ptr = &o_list[0 - item];
5186         }
5187
5188         /* It is fully known, no information needed */
5189         if (object_is_known(o_ptr))
5190         {
5191                 msg_print(_("何も新しいことは判らなかった。", "You cannot find out anything more about that."));
5192                 return TRUE;
5193         }
5194
5195         /* Check for a feeling */
5196         feel = value_check_aux1(o_ptr);
5197
5198         /* Get an object description */
5199         object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5200
5201         /* Skip non-feelings */
5202         if (!feel)
5203         {
5204                 msg_format(_("%sからは特に変わった事は感じとれなかった。", "You do not perceive anything unusual about the %s."), o_name);
5205                 return TRUE;
5206         }
5207
5208 #ifdef JP
5209         msg_format("%sは%sという感じがする...",
5210                 o_name, game_inscriptions[feel]);
5211 #else
5212         msg_format("You feel that the %s %s %s...",
5213                 o_name, ((o_ptr->number == 1) ? "is" : "are"),
5214                 game_inscriptions[feel]);
5215 #endif
5216
5217
5218         /* We have "felt" it */
5219         o_ptr->ident |= (IDENT_SENSE);
5220
5221         /* "Inscribe" it */
5222         o_ptr->feeling = feel;
5223
5224         /* Player touches it */
5225         o_ptr->marked |= OM_TOUCHED;
5226
5227         /* Combine / Reorder the pack (later) */
5228         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5229
5230         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5231
5232         /* Valid "tval" codes */
5233         switch (o_ptr->tval)
5234         {
5235         case TV_SHOT:
5236         case TV_ARROW:
5237         case TV_BOLT:
5238         case TV_BOW:
5239         case TV_DIGGING:
5240         case TV_HAFTED:
5241         case TV_POLEARM:
5242         case TV_SWORD:
5243         case TV_BOOTS:
5244         case TV_GLOVES:
5245         case TV_HELM:
5246         case TV_CROWN:
5247         case TV_SHIELD:
5248         case TV_CLOAK:
5249         case TV_SOFT_ARMOR:
5250         case TV_HARD_ARMOR:
5251         case TV_DRAG_ARMOR:
5252         case TV_CARD:
5253         case TV_RING:
5254         case TV_AMULET:
5255         case TV_LITE:
5256         case TV_FIGURINE:
5257                 okay = TRUE;
5258                 break;
5259         }
5260
5261         /* Auto-inscription/destroy */
5262         autopick_alter_item(item, (bool)(okay && destroy_feeling));
5263
5264         /* Something happened */
5265         return (TRUE);
5266 }