OSDN Git Service

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