OSDN Git Service

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