OSDN Git Service

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