OSDN Git Service

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