OSDN Git Service

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