OSDN Git Service

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