OSDN Git Service

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