OSDN Git Service

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