OSDN Git Service

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