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