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