OSDN Git Service

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