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