OSDN Git Service

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