OSDN Git Service

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