OSDN Git Service

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