OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / spells1.c
1 /*!
2  * @file spells1.c
3  * @brief 魔法による遠隔処理の実装 / Spell projection
4  * @date 2014/07/10
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 "trap.h"
17 #include "object-curse.h"
18
19
20 static int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
21 static int rakubadam_p; /*!< 落馬した際のダメージ量 */
22
23 int project_length = 0; /*!< 投射の射程距離 */
24
25
26 /*!
27  * @brief モンスター魅了用セービングスロー共通部(汎用系)
28  * @param pow 魅了パワー
29  * @param m_ptr 対象モンスター
30  * @return 魅了に抵抗したらTRUE
31  */
32 static bool_hack common_saving_throw_charm(player_type *player_ptr, HIT_POINT pow, monster_type *m_ptr)
33 {
34         monster_race *r_ptr = &r_info[m_ptr->r_idx];
35
36         if(p_ptr->inside_arena) return TRUE;
37
38         /* Memorize a flag */
39         if (r_ptr->flagsr & RFR_RES_ALL)
40         {
41                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
42                 return TRUE;
43         }
44
45         if (r_ptr->flags3 & RF3_NO_CONF)
46         {
47                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
48                 return TRUE;
49         }
50
51         if (r_ptr->flags1 & RF1_QUESTOR || m_ptr->mflag2 & MFLAG2_NOPET) return TRUE;
52
53         pow += (adj_chr_chm[player_ptr->stat_ind[A_CHR]] - 1);
54         if((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) pow = pow * 2 / 3;
55         return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
56 }
57
58 /*!
59  * @brief モンスター服従用セービングスロー共通部(部族依存系)
60  * @param pow 服従パワー
61  * @param m_ptr 対象モンスター
62  * @return 服従に抵抗したらTRUE
63  */
64 static bool_hack common_saving_throw_control(player_type *player_ptr, HIT_POINT pow, monster_type *m_ptr)
65 {
66         monster_race *r_ptr = &r_info[m_ptr->r_idx];
67
68         if (p_ptr->inside_arena) return TRUE;
69
70         /* Memorize a flag */
71         if (r_ptr->flagsr & RFR_RES_ALL)
72         {
73                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
74                 return TRUE;
75         }
76
77         if (r_ptr->flags1 & RF1_QUESTOR || m_ptr->mflag2 & MFLAG2_NOPET) return TRUE;
78
79         pow += adj_chr_chm[player_ptr->stat_ind[A_CHR]] - 1;
80         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) pow = pow * 2 / 3;
81         return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
82 }
83
84 /*!
85 * @brief 一部ボルト魔法のビーム化確率を算出する / Prepare standard probability to become beam for fire_bolt_or_beam()
86 * @return ビーム化確率(%)
87 * @details
88 * ハードコーティングによる実装が行われている。
89 * メイジは(レベル)%、ハイメイジ、スペルマスターは(レベル)%、それ以外の職業は(レベル/2)%
90 */
91 PERCENTAGE beam_chance(void)
92 {
93         if (p_ptr->pclass == CLASS_MAGE)
94                 return (PERCENTAGE)(p_ptr->lev);
95         if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)
96                 return (PERCENTAGE)(p_ptr->lev + 10);
97
98         return (PERCENTAGE)(p_ptr->lev / 2);
99 }
100
101
102 /*!
103  * @brief 配置した鏡リストの次を取得する /
104  * Get another mirror. for SEEKER 
105  * @param next_y 次の鏡のy座標を返す参照ポインタ
106  * @param next_x 次の鏡のx座標を返す参照ポインタ
107  * @param cury 現在の鏡のy座標
108  * @param curx 現在の鏡のx座標
109  */
110 static void next_mirror(int* next_y, int* next_x, int cury, int curx)
111 {
112         int mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
113         int mirror_num = 0;                       /* 鏡の数 */
114         POSITION x, y;
115         int num;
116
117         for (x = 0; x < cur_wid; x++)
118         {
119                 for (y = 0; y < cur_hgt; y++)
120                 {
121                         if (is_mirror_grid(&cave[y][x])) {
122                                 mirror_y[mirror_num] = y;
123                                 mirror_x[mirror_num] = x;
124                                 mirror_num++;
125                         }
126                 }
127         }
128         if (mirror_num)
129         {
130                 num = randint0(mirror_num);
131                 *next_y = mirror_y[num];
132                 *next_x = mirror_x[num];
133                 return;
134         }
135         *next_y = cury + randint0(5) - 2;
136         *next_x = curx + randint0(5) - 2;
137         return;
138 }
139                 
140 /*!
141  * @brief 万色表現用にランダムな色を選択する関数 /
142  * Get a legal "multi-hued" color for drawing "spells"
143  * @param max 色IDの最大値
144  * @return 選択した色ID
145  */
146 static byte mh_attr(int max)
147 {
148         switch (randint1(max))
149         {
150                 case  1: return (TERM_RED);
151                 case  2: return (TERM_GREEN);
152                 case  3: return (TERM_BLUE);
153                 case  4: return (TERM_YELLOW);
154                 case  5: return (TERM_ORANGE);
155                 case  6: return (TERM_VIOLET);
156                 case  7: return (TERM_L_RED);
157                 case  8: return (TERM_L_GREEN);
158                 case  9: return (TERM_L_BLUE);
159                 case 10: return (TERM_UMBER);
160                 case 11: return (TERM_L_UMBER);
161                 case 12: return (TERM_SLATE);
162                 case 13: return (TERM_WHITE);
163                 case 14: return (TERM_L_WHITE);
164                 case 15: return (TERM_L_DARK);
165         }
166
167         return (TERM_WHITE);
168 }
169
170
171 /*!
172  * @brief 魔法属性に応じたエフェクトの色を返す /
173  * Return a color to use for the bolt/ball spells
174  * @param type 魔法属性
175  * @return 対応する色ID
176  */
177 static byte spell_color(int type)
178 {
179         /* Check if A.B.'s new graphics should be used (rr9) */
180         if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2"))
181         {
182                 /* Analyze */
183                 switch (type)
184                 {
185                         case GF_PSY_SPEAR:              return (0x06);
186                         case GF_MISSILE:                return (0x0F);
187                         case GF_ACID:                   return (0x04);
188                         case GF_ELEC:                   return (0x02);
189                         case GF_FIRE:                   return (0x00);
190                         case GF_COLD:                   return (0x01);
191                         case GF_POIS:                   return (0x03);
192                         case GF_HOLY_FIRE:              return (0x00);
193                         case GF_HELL_FIRE:              return (0x00);
194                         case GF_MANA:                   return (0x0E);
195                           /* by henkma */
196                         case GF_SEEKER:                 return (0x0E);
197                         case GF_SUPER_RAY:              return (0x0E);
198
199                         case GF_ARROW:                  return (0x0F);
200                         case GF_WATER:                  return (0x04);
201                         case GF_NETHER:                 return (0x07);
202                         case GF_CHAOS:                  return (mh_attr(15));
203                         case GF_DISENCHANT:             return (0x05);
204                         case GF_NEXUS:                  return (0x0C);
205                         case GF_CONFUSION:              return (mh_attr(4));
206                         case GF_SOUND:                  return (0x09);
207                         case GF_SHARDS:                 return (0x08);
208                         case GF_FORCE:                  return (0x09);
209                         case GF_INERTIAL:               return (0x09);
210                         case GF_GRAVITY:                return (0x09);
211                         case GF_TIME:                   return (0x09);
212                         case GF_LITE_WEAK:              return (0x06);
213                         case GF_LITE:                   return (0x06);
214                         case GF_DARK_WEAK:              return (0x07);
215                         case GF_DARK:                   return (0x07);
216                         case GF_PLASMA:                 return (0x0B);
217                         case GF_METEOR:                 return (0x00);
218                         case GF_ICE:                    return (0x01);
219                         case GF_ROCKET:                 return (0x0F);
220                         case GF_DEATH_RAY:              return (0x07);
221                         case GF_NUKE:                   return (mh_attr(2));
222                         case GF_DISINTEGRATE:   return (0x05);
223                         case GF_PSI:
224                         case GF_PSI_DRAIN:
225                         case GF_TELEKINESIS:
226                         case GF_DOMINATION:
227                         case GF_DRAIN_MANA:
228                         case GF_MIND_BLAST:
229                         case GF_BRAIN_SMASH:
230                                 return (0x09);
231                         case GF_CAUSE_1:
232                         case GF_CAUSE_2:
233                         case GF_CAUSE_3:
234                         case GF_CAUSE_4:                return (0x0E);
235                         case GF_HAND_DOOM:              return (0x07);
236                         case GF_CAPTURE  :              return (0x0E);
237                         case GF_IDENTIFY:               return (0x01);
238                         case GF_ATTACK:                 return (0x0F);
239                         case GF_PHOTO   :               return (0x06);
240                 }
241         }
242         /* Normal tiles or ASCII */
243         else
244         {
245                 byte a;
246                 char c;
247
248                 /* Lookup the default colors for this type */
249                 cptr s = quark_str(gf_color[type]);
250
251                 if (!s) return (TERM_WHITE);
252
253                 /* Pick a random color */
254                 c = s[randint0(strlen(s))];
255
256                 /* Lookup this color */
257                 a = my_strchr(color_char, c) - color_char;
258
259                 /* Invalid color (note check for < 0 removed, gave a silly
260                  * warning because bytes are always >= 0 -- RG) */
261                 if (a > 15) return (TERM_WHITE);
262
263                 /* Use this color */
264                 return (a);
265         }
266
267         /* Standard "color" */
268         return (TERM_WHITE);
269 }
270
271
272 /*!
273  * @brief 始点から終点にかけた方向毎にボルトのキャラクタを返す /
274  * Find the attr/char pair to use for a spell effect
275  * @param y 始点Y座標
276  * @param x 始点X座標
277  * @param ny 終点Y座標
278  * @param nx 終点X座標
279  * @param typ 魔法の効果属性
280  * @return 方向キャラID
281  * @details
282  * <pre>
283  * It is moving (or has moved) from (x,y) to (nx,ny).
284  * If the distance is not "one", we (may) return "*".
285  * </pre>
286  */
287 u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
288 {
289         int base;
290
291         byte k;
292
293         TERM_COLOR a;
294         char c;
295
296         /* No motion (*) */
297         if ((ny == y) && (nx == x)) base = 0x30;
298
299         /* Vertical (|) */
300         else if (nx == x) base = 0x40;
301
302         /* Horizontal (-) */
303         else if (ny == y) base = 0x50;
304
305         /* Diagonal (/) */
306         else if ((ny - y) == (x - nx)) base = 0x60;
307
308         /* Diagonal (\) */
309         else if ((ny - y) == (nx - x)) base = 0x70;
310
311         /* Weird (*) */
312         else base = 0x30;
313
314         /* Basic spell color */
315         k = spell_color(typ);
316
317         /* Obtain attr/char */
318         a = misc_to_attr[base + k];
319         c = misc_to_char[base + k];
320
321         /* Create pict */
322         return (PICT(a, c));
323 }
324
325
326 /*!
327  * @brief 始点から終点への経路を返す /
328  * Determine the path taken by a projection.
329  * @param gp 経路座標リストを返す参照ポインタ
330  * @param range 距離
331  * @param y1 始点Y座標
332  * @param x1 始点X座標
333  * @param y2 終点Y座標
334  * @param x2 終点X座標
335  * @param flg フラグID
336  * @return リストの長さ
337  * @details
338  * <pre>
339  * The projection will always start from the grid (y1,x1), and will travel
340  * towards the grid (y2,x2), touching one grid per unit of distance along
341  * the major axis, and stopping when it enters the destination grid or a
342  * wall grid, or has travelled the maximum legal distance of "range".
343  *
344  * Note that "distance" in this function (as in the "update_view()" code)
345  * is defined as "MAX(dy,dx) + MIN(dy,dx)/2", which means that the player
346  * actually has an "octagon of projection" not a "circle of projection".
347  *
348  * The path grids are saved into the grid array pointed to by "gp", and
349  * there should be room for at least "range" grids in "gp".  Note that
350  * due to the way in which distance is calculated, this function normally
351  * uses fewer than "range" grids for the projection path, so the result
352  * of this function should never be compared directly to "range".  Note
353  * that the initial grid (y1,x1) is never saved into the grid array, not
354  * even if the initial grid is also the final grid.  
355  *
356  * The "flg" flags can be used to modify the behavior of this function.
357  *
358  * In particular, the "PROJECT_STOP" and "PROJECT_THRU" flags have the same
359  * semantics as they do for the "project" function, namely, that the path
360  * will stop as soon as it hits a monster, or that the path will continue
361  * through the destination grid, respectively.
362  *
363  * The "PROJECT_JUMP" flag, which for the "project()" function means to
364  * start at a special grid (which makes no sense in this function), means
365  * that the path should be "angled" slightly if needed to avoid any wall
366  * grids, allowing the player to "target" any grid which is in "view".
367  * This flag is non-trivial and has not yet been implemented, but could
368  * perhaps make use of the "vinfo" array (above).  
369  *
370  * This function returns the number of grids (if any) in the path.  This
371  * function will return zero if and only if (y1,x1) and (y2,x2) are equal.
372  *
373  * This algorithm is similar to, but slightly different from, the one used
374  * by "update_view_los()", and very different from the one used by "los()".
375  * </pre>
376  */
377 sint project_path(u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg)
378 {
379         int y, x;
380
381         int n = 0;
382         int k = 0;
383
384         /* Absolute */
385         int ay, ax;
386
387         /* Offsets */
388         int sy, sx;
389
390         /* Fractions */
391         int frac;
392
393         /* Scale factors */
394         int full, half;
395
396         /* Slope */
397         int m;
398
399         /* No path necessary (or allowed) */
400         if ((x1 == x2) && (y1 == y2)) return (0);
401
402
403         /* Analyze "dy" */
404         if (y2 < y1)
405         {
406                 ay = (y1 - y2);
407                 sy = -1;
408         }
409         else
410         {
411                 ay = (y2 - y1);
412                 sy = 1;
413         }
414
415         /* Analyze "dx" */
416         if (x2 < x1)
417         {
418                 ax = (x1 - x2);
419                 sx = -1;
420         }
421         else
422         {
423                 ax = (x2 - x1);
424                 sx = 1;
425         }
426
427
428         /* Number of "units" in one "half" grid */
429         half = (ay * ax);
430
431         /* Number of "units" in one "full" grid */
432         full = half << 1;
433
434         /* Vertical */
435         if (ay > ax)
436         {
437                 /* Let m = ((dx/dy) * full) = (dx * dx * 2) */
438                 m = ax * ax * 2;
439
440                 /* Start */
441                 y = y1 + sy;
442                 x = x1;
443
444                 frac = m;
445
446                 if (frac > half)
447                 {
448                         /* Advance (X) part 2 */
449                         x += sx;
450
451                         /* Advance (X) part 3 */
452                         frac -= full;
453
454                         /* Track distance */
455                         k++;
456                 }
457
458                 /* Create the projection path */
459                 while (1)
460                 {
461                         /* Save grid */
462                         gp[n++] = GRID(y, x);
463
464                         /* Hack -- Check maximum range */
465                         if ((n + (k >> 1)) >= range) break;
466
467                         /* Sometimes stop at destination grid */
468                         if (!(flg & (PROJECT_THRU)))
469                         {
470                                 if ((x == x2) && (y == y2)) break;
471                         }
472
473                         if (flg & (PROJECT_DISI))
474                         {
475                                 if ((n > 0) && cave_stop_disintegration(y, x)) break;
476                         }
477                         else if (flg & (PROJECT_LOS))
478                         {
479                                 if ((n > 0) && !cave_los_bold(y, x)) break;
480                         }
481                         else if (!(flg & (PROJECT_PATH)))
482                         {
483                                 /* Always stop at non-initial wall grids */
484                                 if ((n > 0) && !cave_have_flag_bold(y, x, FF_PROJECT)) break;
485                         }
486
487                         /* Sometimes stop at non-initial monsters/players */
488                         if (flg & (PROJECT_STOP))
489                         {
490                                 if ((n > 0) &&
491                                         (player_bold(y, x) || cave[y][x].m_idx != 0))
492                                         break;
493                         }
494
495                         if (!in_bounds(y, x)) break;
496
497                         /* Slant */
498                         if (m)
499                         {
500                                 /* Advance (X) part 1 */
501                                 frac += m;
502
503                                 /* Horizontal change */
504                                 if (frac > half)
505                                 {
506                                         /* Advance (X) part 2 */
507                                         x += sx;
508
509                                         /* Advance (X) part 3 */
510                                         frac -= full;
511
512                                         /* Track distance */
513                                         k++;
514                                 }
515                         }
516
517                         /* Advance (Y) */
518                         y += sy;
519                 }
520         }
521
522         /* Horizontal */
523         else if (ax > ay)
524         {
525                 /* Let m = ((dy/dx) * full) = (dy * dy * 2) */
526                 m = ay * ay * 2;
527
528                 /* Start */
529                 y = y1;
530                 x = x1 + sx;
531
532                 frac = m;
533
534                 /* Vertical change */
535                 if (frac > half)
536                 {
537                         /* Advance (Y) part 2 */
538                         y += sy;
539
540                         /* Advance (Y) part 3 */
541                         frac -= full;
542
543                         /* Track distance */
544                         k++;
545                 }
546
547                 /* Create the projection path */
548                 while (1)
549                 {
550                         /* Save grid */
551                         gp[n++] = GRID(y, x);
552
553                         /* Hack -- Check maximum range */
554                         if ((n + (k >> 1)) >= range) break;
555
556                         /* Sometimes stop at destination grid */
557                         if (!(flg & (PROJECT_THRU)))
558                         {
559                                 if ((x == x2) && (y == y2)) break;
560                         }
561
562                         if (flg & (PROJECT_DISI))
563                         {
564                                 if ((n > 0) && cave_stop_disintegration(y, x)) break;
565                         }
566                         else if (flg & (PROJECT_LOS))
567                         {
568                                 if ((n > 0) && !cave_los_bold(y, x)) break;
569                         }
570                         else if (!(flg & (PROJECT_PATH)))
571                         {
572                                 /* Always stop at non-initial wall grids */
573                                 if ((n > 0) && !cave_have_flag_bold(y, x, FF_PROJECT)) break;
574                         }
575
576                         /* Sometimes stop at non-initial monsters/players */
577                         if (flg & (PROJECT_STOP))
578                         {
579                                 if ((n > 0) &&
580                                         (player_bold(y, x) || cave[y][x].m_idx != 0))
581                                         break;
582                         }
583
584                         if (!in_bounds(y, x)) break;
585
586                         /* Slant */
587                         if (m)
588                         {
589                                 /* Advance (Y) part 1 */
590                                 frac += m;
591
592                                 /* Vertical change */
593                                 if (frac > half)
594                                 {
595                                         /* Advance (Y) part 2 */
596                                         y += sy;
597
598                                         /* Advance (Y) part 3 */
599                                         frac -= full;
600
601                                         /* Track distance */
602                                         k++;
603                                 }
604                         }
605
606                         /* Advance (X) */
607                         x += sx;
608                 }
609         }
610
611         /* Diagonal */
612         else
613         {
614                 /* Start */
615                 y = y1 + sy;
616                 x = x1 + sx;
617
618                 /* Create the projection path */
619                 while (1)
620                 {
621                         /* Save grid */
622                         gp[n++] = GRID(y, x);
623
624                         /* Hack -- Check maximum range */
625                         if ((n + (n >> 1)) >= range) break;
626
627                         /* Sometimes stop at destination grid */
628                         if (!(flg & (PROJECT_THRU)))
629                         {
630                                 if ((x == x2) && (y == y2)) break;
631                         }
632
633                         if (flg & (PROJECT_DISI))
634                         {
635                                 if ((n > 0) && cave_stop_disintegration(y, x)) break;
636                         }
637                         else if (flg & (PROJECT_LOS))
638                         {
639                                 if ((n > 0) && !cave_los_bold(y, x)) break;
640                         }
641                         else if (!(flg & (PROJECT_PATH)))
642                         {
643                                 /* Always stop at non-initial wall grids */
644                                 if ((n > 0) && !cave_have_flag_bold(y, x, FF_PROJECT)) break;
645                         }
646
647                         /* Sometimes stop at non-initial monsters/players */
648                         if (flg & (PROJECT_STOP))
649                         {
650                                 if ((n > 0) &&
651                                         (player_bold(y, x) || cave[y][x].m_idx != 0))
652                                         break;
653                         }
654
655                         if (!in_bounds(y, x)) break;
656
657                         /* Advance (Y) */
658                         y += sy;
659
660                         /* Advance (X) */
661                         x += sx;
662                 }
663         }
664
665         /* Length */
666         return (n);
667 }
668
669
670
671 /*
672  * Mega-Hack -- track "affected" monsters (see "project()" comments)
673  */
674 static int project_m_n; /*!< 魔法効果範囲内にいるモンスターの数 */
675 static POSITION project_m_x; /*!< 処理中のモンスターX座標 */
676 static POSITION project_m_y; /*!< 処理中のモンスターY座標 */
677 /* Mega-Hack -- monsters target */
678 static POSITION monster_target_x; /*!< モンスターの攻撃目標X座標 */
679 static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */
680
681
682 /*!
683  * @brief 汎用的なビーム/ボルト/ボール系による地形効果処理 / We are called from "project()" to "damage" terrain features
684  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
685  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
686  * @param y 目標Y座標 / Target y location (or location to travel "towards")
687  * @param x 目標X座標 / Target x location (or location to travel "towards")
688  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
689  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
690  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
691  * @details
692  * <pre>
693  * We are called both for "beam" effects and "ball" effects.
694  *
695  * The "r" parameter is the "distance from ground zero".
696  *
697  * Note that we determine if the player can "see" anything that happens
698  * by taking into account: blindness, line-of-sight, and illumination.
699  *
700  * We return "TRUE" if the effect of the projection is "obvious".
701  *
702  * We also "see" grids which are "memorized", probably a hack
703  *
704  * Perhaps we should affect doors?
705  * </pre>
706  */
707 static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
708 {
709         cave_type *c_ptr = &cave[y][x];
710         feature_type *f_ptr = &f_info[c_ptr->feat];
711
712         bool obvious = FALSE;
713         bool known = player_has_los_bold(y, x);
714
715
716         who = who ? who : 0;
717
718         /* Reduce damage by distance */
719         dam = (dam + r) / (r + 1);
720
721
722         if (have_flag(f_ptr->flags, FF_TREE))
723         {
724                 cptr message;
725                 switch (typ)
726                 {
727                 case GF_POIS:
728                 case GF_NUKE:
729                 case GF_DEATH_RAY:
730                         message = _("枯れた", "was blasted."); break;
731                 case GF_TIME:
732                         message = _("縮んだ", "shrank."); break;
733                 case GF_ACID:
734                         message = _("溶けた", "melted."); break;
735                 case GF_COLD:
736                 case GF_ICE:
737                         message = _("凍り、砕け散った", "was frozen and smashed."); break;
738                 case GF_FIRE:
739                 case GF_ELEC:
740                 case GF_PLASMA:
741                         message = _("燃えた", "burns up!"); break;
742                 case GF_METEOR:
743                 case GF_CHAOS:
744                 case GF_MANA:
745                 case GF_SEEKER:
746                 case GF_SUPER_RAY:
747                 case GF_SHARDS:
748                 case GF_ROCKET:
749                 case GF_SOUND:
750                 case GF_DISENCHANT:
751                 case GF_FORCE:
752                 case GF_GRAVITY:
753                         message = _("粉砕された", "was crushed."); break;
754                 default:
755                         message = NULL;break;
756                 }
757                 if (message)
758                 {
759                         msg_format(_("木は%s。", "A tree %s"), message);
760                         cave_set_feat(y, x, one_in_(3) ? feat_brake : feat_grass);
761
762                         /* Observe */
763                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
764                 }
765         }
766
767         /* Analyze the type */
768         switch (typ)
769         {
770                 /* Ignore most effects */
771                 case GF_CAPTURE:
772                 case GF_HAND_DOOM:
773                 case GF_CAUSE_1:
774                 case GF_CAUSE_2:
775                 case GF_CAUSE_3:
776                 case GF_CAUSE_4:
777                 case GF_MIND_BLAST:
778                 case GF_BRAIN_SMASH:
779                 case GF_DRAIN_MANA:
780                 case GF_PSY_SPEAR:
781                 case GF_FORCE:
782                 case GF_HOLY_FIRE:
783                 case GF_HELL_FIRE:
784                 case GF_PSI:
785                 case GF_PSI_DRAIN:
786                 case GF_TELEKINESIS:
787                 case GF_DOMINATION:
788                 case GF_IDENTIFY:
789                 case GF_ATTACK:
790                 case GF_ACID:
791                 case GF_ELEC:
792                 case GF_COLD:
793                 case GF_ICE:
794                 case GF_FIRE:
795                 case GF_PLASMA:
796                 case GF_METEOR:
797                 case GF_CHAOS:
798                 case GF_MANA:
799                 case GF_SEEKER:
800                 case GF_SUPER_RAY:
801                 {
802                         break;
803                 }
804
805                 /* Destroy Traps (and Locks) */
806                 case GF_KILL_TRAP:
807                 {
808                         /* Reveal secret doors */
809                         if (is_hidden_door(c_ptr))
810                         {
811                                 /* Pick a door */
812                                 disclose_grid(y, x);
813
814                                 /* Check line of sight */
815                                 if (known)
816                                 {
817                                         obvious = TRUE;
818                                 }
819                         }
820
821                         /* Destroy traps */
822                         if (is_trap(c_ptr->feat))
823                         {
824                                 /* Check line of sight */
825                                 if (known)
826                                 {
827                                         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
828                                         obvious = TRUE;
829                                 }
830
831                                 /* Destroy the trap */
832                                 cave_alter_feat(y, x, FF_DISARM);
833                         }
834
835                         /* Locked doors are unlocked */
836                         if (is_closed_door(c_ptr->feat) && f_ptr->power && have_flag(f_ptr->flags, FF_OPEN))
837                         {
838                                 s16b old_feat = c_ptr->feat;
839
840                                 /* Unlock the door */
841                                 cave_alter_feat(y, x, FF_DISARM);
842
843                                 /* Check line of sound */
844                                 if (known && (old_feat != c_ptr->feat))
845                                 {
846                                         msg_print(_("カチッと音がした!", "Click!"));
847                                         obvious = TRUE;
848                                 }
849                         }
850
851                         /* Remove "unsafe" flag if player is not blind */
852                         if (!p_ptr->blind && player_has_los_bold(y, x))
853                         {
854                                 c_ptr->info &= ~(CAVE_UNSAFE);
855
856                                 /* Redraw */
857                                 lite_spot(y, x);
858
859                                 obvious = TRUE;
860                         }
861
862                         break;
863                 }
864
865                 /* Destroy Doors (and traps) */
866                 case GF_KILL_DOOR:
867                 {
868                         /* Destroy all doors and traps */
869                         if (is_trap(c_ptr->feat) || have_flag(f_ptr->flags, FF_DOOR))
870                         {
871                                 /* Check line of sight */
872                                 if (known)
873                                 {
874                                         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
875                                         obvious = TRUE;
876                                 }
877
878                                 /* Destroy the feature */
879                                 cave_alter_feat(y, x, FF_TUNNEL);
880                         }
881
882                         /* Remove "unsafe" flag if player is not blind */
883                         if (!p_ptr->blind && player_has_los_bold(y, x))
884                         {
885                                 c_ptr->info &= ~(CAVE_UNSAFE);
886
887                                 /* Redraw */
888                                 lite_spot(y, x);
889
890                                 obvious = TRUE;
891                         }
892
893                         break;
894                 }
895
896                 case GF_JAM_DOOR: /* Jams a door (as if with a spike) */
897                 {
898                         if (have_flag(f_ptr->flags, FF_SPIKE))
899                         {
900                                 s16b old_mimic = c_ptr->mimic;
901                                 feature_type *mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
902
903                                 cave_alter_feat(y, x, FF_SPIKE);
904
905                                 c_ptr->mimic = old_mimic;
906
907                                 note_spot(y, x);
908
909                                 /* Redraw */
910                                 lite_spot(y, x);
911
912                                 /* Check line of sight */
913                                 if (known && have_flag(mimic_f_ptr->flags, FF_OPEN))
914                                 {
915                                         msg_format(_("%sに何かがつっかえて開かなくなった。", "The %s seems stuck."), f_name + mimic_f_ptr->name);
916                                         obvious = TRUE;
917                                 }
918                         }
919                         break;
920                 }
921
922                 /* Destroy walls (and doors) */
923                 case GF_KILL_WALL:
924                 {
925                         if (have_flag(f_ptr->flags, FF_HURT_ROCK))
926                         {
927                                 if (known && (c_ptr->info & (CAVE_MARK)))
928                                 {
929                                         msg_format(_("%sが溶けて泥になった!", "The %s turns into mud!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
930                                         obvious = TRUE;
931                                 }
932
933                                 /* Destroy the wall */
934                                 cave_alter_feat(y, x, FF_HURT_ROCK);
935
936                                 /* Update some things */
937                                 p_ptr->update |= (PU_FLOW);
938                         }
939
940                         break;
941                 }
942
943                 /* Make doors */
944                 case GF_MAKE_DOOR:
945                 {
946                         /* Require a "naked" floor grid */
947                         if (!cave_naked_bold(y, x)) break;
948
949                         /* Not on the player */
950                         if (player_bold(y, x)) break;
951
952                         /* Create a closed door */
953                         cave_set_feat(y, x, feat_door[DOOR_DOOR].closed);
954
955                         /* Observe */
956                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
957
958                         break;
959                 }
960
961                 /* Make traps */
962                 case GF_MAKE_TRAP:
963                 {
964                         /* Place a trap */
965                         place_trap(y, x);
966
967                         break;
968                 }
969
970                 /* Make doors */
971                 case GF_MAKE_TREE:
972                 {
973                         /* Require a "naked" floor grid */
974                         if (!cave_naked_bold(y, x)) break;
975
976                         /* Not on the player */
977                         if (player_bold(y, x)) break;
978
979                         /* Create a closed door */
980                         cave_set_feat(y, x, feat_tree);
981
982                         /* Observe */
983                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
984
985
986                         break;
987                 }
988
989                 case GF_MAKE_GLYPH:
990                 {
991                         /* Require a "naked" floor grid */
992                         if (!cave_naked_bold(y, x)) break;
993
994                         /* Create a glyph */
995                         c_ptr->info |= CAVE_OBJECT;
996                         c_ptr->mimic = feat_glyph;
997
998                         note_spot(y, x);
999
1000                         /* Redraw */
1001                         lite_spot(y, x);
1002
1003                         break;
1004                 }
1005
1006                 case GF_STONE_WALL:
1007                 {
1008                         /* Require a "naked" floor grid */
1009                         if (!cave_naked_bold(y, x)) break;
1010
1011                         /* Not on the player */
1012                         if (player_bold(y, x)) break;
1013
1014                         /* Place a wall */
1015                         cave_set_feat(y, x, feat_granite);
1016
1017                         break;
1018                 }
1019
1020
1021                 case GF_LAVA_FLOW:
1022                 {
1023                         /* Ignore permanent grid */
1024                         if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
1025
1026                         /* Shallow Lava */
1027                         if (dam == 1)
1028                         {
1029                                 /* Ignore grid without enough space */
1030                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
1031
1032                                 /* Place a shallow lava */
1033                                 cave_set_feat(y, x, feat_shallow_lava);
1034                         }
1035                         /* Deep Lava */
1036                         else if (dam)
1037                         {
1038                                 /* Place a deep lava */
1039                                 cave_set_feat(y, x, feat_deep_lava);
1040                         }
1041                         break;
1042                 }
1043
1044                 case GF_WATER_FLOW:
1045                 {
1046                         /* Ignore permanent grid */
1047                         if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
1048
1049                         /* Shallow Water */
1050                         if (dam == 1)
1051                         {
1052                                 /* Ignore grid without enough space */
1053                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
1054
1055                                 /* Place a shallow water */
1056                                 cave_set_feat(y, x, feat_shallow_water);
1057                         }
1058                         /* Deep Water */
1059                         else if (dam)
1060                         {
1061                                 /* Place a deep water */
1062                                 cave_set_feat(y, x, feat_deep_water);
1063                         }
1064                         break;
1065                 }
1066
1067                 /* Lite up the grid */
1068                 case GF_LITE_WEAK:
1069                 case GF_LITE:
1070                 {
1071                         /* Turn on the light */
1072                         if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
1073                         {
1074                                 c_ptr->info |= (CAVE_GLOW);
1075
1076                                 note_spot(y, x);
1077
1078                                 /* Redraw */
1079                                 lite_spot(y, x);
1080
1081                                 update_local_illumination(y, x);
1082
1083                                 /* Observe */
1084                                 if (player_can_see_bold(y, x)) obvious = TRUE;
1085
1086                                 /* Mega-Hack -- Update the monster in the affected grid */
1087                                 /* This allows "spear of light" (etc) to work "correctly" */
1088                                 if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
1089
1090                                 if (p_ptr->special_defense & NINJA_S_STEALTH)
1091                                 {
1092                                         if (player_bold(y, x)) set_superstealth(FALSE);
1093                                 }
1094                         }
1095
1096                         break;
1097                 }
1098
1099                 /* Darken the grid */
1100                 case GF_DARK_WEAK:
1101                 case GF_DARK:
1102                 {
1103                         bool do_dark = !p_ptr->inside_battle && !is_mirror_grid(c_ptr);
1104                         int j;
1105
1106                         /* Turn off the light. */
1107                         if (do_dark)
1108                         {
1109                                 if (dun_level || !is_daytime())
1110                                 {
1111                                         for (j = 0; j < 9; j++)
1112                                         {
1113                                                 int by = y + ddy_ddd[j];
1114                                                 int bx = x + ddx_ddd[j];
1115
1116                                                 if (in_bounds2(by, bx))
1117                                                 {
1118                                                         cave_type *cc_ptr = &cave[by][bx];
1119
1120                                                         if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1121                                                         {
1122                                                                 do_dark = FALSE;
1123                                                                 break;
1124                                                         }
1125                                                 }
1126                                         }
1127
1128                                         if (!do_dark) break;
1129                                 }
1130
1131                                 c_ptr->info &= ~(CAVE_GLOW);
1132
1133                                 /* Hack -- Forget "boring" grids */
1134                                 if (!have_flag(f_ptr->flags, FF_REMEMBER))
1135                                 {
1136                                         /* Forget */
1137                                         c_ptr->info &= ~(CAVE_MARK);
1138
1139                                         note_spot(y, x);
1140                                 }
1141
1142                                 /* Redraw */
1143                                 lite_spot(y, x);
1144
1145                                 update_local_illumination(y, x);
1146
1147                                 if (player_can_see_bold(y, x)) obvious = TRUE;
1148
1149                                 /* Mega-Hack -- Update the monster in the affected grid */
1150                                 /* This allows "spear of light" (etc) to work "correctly" */
1151                                 if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
1152                         }
1153
1154                         /* All done */
1155                         break;
1156                 }
1157
1158                 case GF_SHARDS:
1159                 case GF_ROCKET:
1160                 {
1161                         if (is_mirror_grid(c_ptr))
1162                         {
1163                                 msg_print(_("鏡が割れた!", "The mirror was crashed!"));
1164                                 sound(SOUND_GLASS);
1165                                 remove_mirror(y, x);
1166                                 project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
1167                         }
1168
1169                         if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 50))
1170                         {
1171                                 if (known && (c_ptr->info & CAVE_MARK))
1172                                 {
1173                                         msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
1174                                         sound(SOUND_GLASS);
1175                                 }
1176
1177                                 /* Destroy the wall */
1178                                 cave_alter_feat(y, x, FF_HURT_ROCK);
1179
1180                                 /* Update some things */
1181                                 p_ptr->update |= (PU_FLOW);
1182                         }
1183                         break;
1184                 }
1185
1186                 case GF_SOUND:
1187                 {
1188                         if (is_mirror_grid(c_ptr) && p_ptr->lev < 40)
1189                         {
1190                                 msg_print(_("鏡が割れた!", "The mirror was crashed!"));
1191                                 sound(SOUND_GLASS);
1192                                 remove_mirror(y, x);
1193                                 project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
1194                         }
1195
1196                         if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 200))
1197                         {
1198                                 if (known && (c_ptr->info & CAVE_MARK))
1199                                 {
1200                                         msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
1201                                         sound(SOUND_GLASS);
1202                                 }
1203
1204                                 /* Destroy the wall */
1205                                 cave_alter_feat(y, x, FF_HURT_ROCK);
1206
1207                                 /* Update some things */
1208                                 p_ptr->update |= (PU_FLOW);
1209                         }
1210                         break;
1211                 }
1212
1213                 case GF_DISINTEGRATE:
1214                 {
1215                         /* Destroy mirror/glyph */
1216                         if (is_mirror_grid(c_ptr) || is_glyph_grid(c_ptr) || is_explosive_rune_grid(c_ptr))
1217                                 remove_mirror(y, x);
1218
1219                         /* Permanent features don't get effect */
1220                         /* But not protect monsters and other objects */
1221                         if (have_flag(f_ptr->flags, FF_HURT_DISI) && !have_flag(f_ptr->flags, FF_PERMANENT))
1222                         {
1223                                 cave_alter_feat(y, x, FF_HURT_DISI);
1224
1225                                 /* Update some things -- similar to GF_KILL_WALL */
1226                                 p_ptr->update |= (PU_FLOW);
1227                         }
1228                         break;
1229                 }
1230         }
1231
1232         lite_spot(y, x);
1233         /* Return "Anything seen?" */
1234         return (obvious);
1235 }
1236
1237
1238
1239 /*!
1240  * @brief 汎用的なビーム/ボルト/ボール系によるアイテムオブジェクトへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
1241  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
1242  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
1243  * @param y 目標Y座標 / Target y location (or location to travel "towards")
1244  * @param x 目標X座標 / Target x location (or location to travel "towards")
1245  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
1246  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
1247  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
1248  * @details
1249  * <pre>
1250  * We are called from "project()" to "damage" objects
1251  *
1252  * We are called both for "beam" effects and "ball" effects.
1253  *
1254  * Perhaps we should only SOMETIMES damage things on the ground.
1255  *
1256  * The "r" parameter is the "distance from ground zero".
1257  *
1258  * Note that we determine if the player can "see" anything that happens
1259  * by taking into account: blindness, line-of-sight, and illumination.
1260  *
1261  * We also "see" grids which are "memorized", probably a hack
1262  *
1263  * We return "TRUE" if the effect of the projection is "obvious".
1264  * </pre>
1265  */
1266 static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
1267 {
1268         cave_type *c_ptr = &cave[y][x];
1269
1270         OBJECT_IDX this_o_idx, next_o_idx = 0;
1271
1272         bool obvious = FALSE;
1273         bool known = player_has_los_bold(y, x);
1274
1275         BIT_FLAGS flgs[TR_FLAG_SIZE];
1276
1277         char o_name[MAX_NLEN];
1278
1279         KIND_OBJECT_IDX k_idx = 0;
1280         bool is_potion = FALSE;
1281
1282
1283         who = who ? who : 0;
1284
1285         /* Reduce damage by distance */
1286         dam = (dam + r) / (r + 1);
1287
1288
1289         /* Scan all objects in the grid */
1290         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1291         {
1292                 /* Acquire object */
1293                 object_type *o_ptr = &o_list[this_o_idx];
1294
1295                 bool is_art = FALSE;
1296                 bool ignore = FALSE;
1297                 bool do_kill = FALSE;
1298
1299                 cptr note_kill = NULL;
1300
1301 #ifndef JP
1302                 /* Get the "plural"-ness */
1303                 bool plural = (o_ptr->number > 1);
1304 #endif
1305
1306                 /* Acquire next object */
1307                 next_o_idx = o_ptr->next_o_idx;
1308
1309                 /* Extract the flags */
1310                 object_flags(o_ptr, flgs);
1311
1312                 /* Check for artifact */
1313                 if (object_is_artifact(o_ptr)) is_art = TRUE;
1314
1315                 /* Analyze the type */
1316                 switch (typ)
1317                 {
1318                         /* Acid -- Lots of things */
1319                         case GF_ACID:
1320                         {
1321                                 if (hates_acid(o_ptr))
1322                                 {
1323                                         do_kill = TRUE;
1324                                         note_kill = _("融けてしまった!", (plural ? " melt!" : " melts!"));
1325                                         if (have_flag(flgs, TR_IGNORE_ACID)) ignore = TRUE;
1326                                 }
1327                                 break;
1328                         }
1329
1330                         /* Elec -- Rings and Wands */
1331                         case GF_ELEC:
1332                         {
1333                                 if (hates_elec(o_ptr))
1334                                 {
1335                                         do_kill = TRUE;
1336                                         note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1337                                         if (have_flag(flgs, TR_IGNORE_ELEC)) ignore = TRUE;
1338                                 }
1339                                 break;
1340                         }
1341
1342                         /* Fire -- Flammable objects */
1343                         case GF_FIRE:
1344                         {
1345                                 if (hates_fire(o_ptr))
1346                                 {
1347                                         do_kill = TRUE;
1348                                         note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
1349                                         if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
1350                                 }
1351                                 break;
1352                         }
1353
1354                         /* Cold -- potions and flasks */
1355                         case GF_COLD:
1356                         {
1357                                 if (hates_cold(o_ptr))
1358                                 {
1359                                         note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
1360                                         do_kill = TRUE;
1361                                         if (have_flag(flgs, TR_IGNORE_COLD)) ignore = TRUE;
1362                                 }
1363                                 break;
1364                         }
1365
1366                         /* Fire + Elec */
1367                         case GF_PLASMA:
1368                         {
1369                                 if (hates_fire(o_ptr))
1370                                 {
1371                                         do_kill = TRUE;
1372                                         note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
1373                                         if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
1374                                 }
1375                                 if (hates_elec(o_ptr))
1376                                 {
1377                                         ignore = FALSE;
1378                                         do_kill = TRUE;
1379                                         note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1380                                         if (have_flag(flgs, TR_IGNORE_ELEC)) ignore = TRUE;
1381                                 }
1382                                 break;
1383                         }
1384
1385                         /* Fire + Cold */
1386                         case GF_METEOR:
1387                         {
1388                                 if (hates_fire(o_ptr))
1389                                 {
1390                                         do_kill = TRUE;
1391                                         note_kill = _("燃えてしまった!", (plural ? " burn up!" : " burns up!"));
1392                                         if (have_flag(flgs, TR_IGNORE_FIRE)) ignore = TRUE;
1393                                 }
1394                                 if (hates_cold(o_ptr))
1395                                 {
1396                                         ignore = FALSE;
1397                                         do_kill = TRUE;
1398                                         note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
1399                                         if (have_flag(flgs, TR_IGNORE_COLD)) ignore = TRUE;
1400                                 }
1401                                 break;
1402                         }
1403
1404                         /* Hack -- break potions and such */
1405                         case GF_ICE:
1406                         case GF_SHARDS:
1407                         case GF_FORCE:
1408                         case GF_SOUND:
1409                         {
1410                                 if (hates_cold(o_ptr))
1411                                 {
1412                                         note_kill = _("砕け散ってしまった!", (plural ? " shatter!" : " shatters!"));
1413                                         do_kill = TRUE;
1414                                 }
1415                                 break;
1416                         }
1417
1418                         /* Mana and Chaos -- destroy everything */
1419                         case GF_MANA:
1420                         case GF_SEEKER:
1421                         case GF_SUPER_RAY:
1422                         {
1423                                 do_kill = TRUE;
1424                                 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1425                                 break;
1426                         }
1427
1428                         case GF_DISINTEGRATE:
1429                         {
1430                                 do_kill = TRUE;
1431                                 note_kill = _("蒸発してしまった!", (plural ? " evaporate!" : " evaporates!"));
1432                                 break;
1433                         }
1434
1435                         case GF_CHAOS:
1436                         {
1437                                 do_kill = TRUE;
1438                                 note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1439                                 if (have_flag(flgs, TR_RES_CHAOS)) ignore = TRUE;
1440                                 else if ((o_ptr->tval == TV_SCROLL) && (o_ptr->sval == SV_SCROLL_CHAOS)) ignore = TRUE;
1441                                 break;
1442                         }
1443
1444                         /* Holy Fire and Hell Fire -- destroys cursed non-artifacts */
1445                         case GF_HOLY_FIRE:
1446                         case GF_HELL_FIRE:
1447                         {
1448                                 if (object_is_cursed(o_ptr))
1449                                 {
1450                                         do_kill = TRUE;
1451                                         note_kill = _("壊れてしまった!", (plural ? " are destroyed!" : " is destroyed!"));
1452                                 }
1453                                 break;
1454                         }
1455
1456                         case GF_IDENTIFY:
1457                         {
1458                                 identify_item(o_ptr);
1459
1460                                 /* Auto-inscription */
1461                                 autopick_alter_item((-this_o_idx), FALSE);
1462                                 break;
1463                         }
1464
1465                         /* Unlock chests */
1466                         case GF_KILL_TRAP:
1467                         case GF_KILL_DOOR:
1468                         {
1469                                 /* Chests are noticed only if trapped or locked */
1470                                 if (o_ptr->tval == TV_CHEST)
1471                                 {
1472                                         /* Disarm/Unlock traps */
1473                                         if (o_ptr->pval > 0)
1474                                         {
1475                                                 /* Disarm or Unlock */
1476                                                 o_ptr->pval = (0 - o_ptr->pval);
1477
1478                                                 /* Identify */
1479                                                 object_known(o_ptr);
1480
1481                                                 if (known && (o_ptr->marked & OM_FOUND))
1482                                                 {
1483                                                         msg_print(_("カチッと音がした!", "Click!"));
1484                                                         obvious = TRUE;
1485                                                 }
1486                                         }
1487                                 }
1488
1489                                 break;
1490                         }
1491                         case GF_ANIM_DEAD:
1492                         {
1493                                 if (o_ptr->tval == TV_CORPSE)
1494                                 {
1495                                         int i;
1496                                         BIT_FLAGS mode = 0L;
1497
1498                                         if (!who || is_pet(&m_list[who]))
1499                                                 mode |= PM_FORCE_PET;
1500
1501                                         for (i = 0; i < o_ptr->number ; i++)
1502                                         {
1503                                                 if (((o_ptr->sval == SV_CORPSE) && (randint1(100) > 80)) ||
1504                                                         ((o_ptr->sval == SV_SKELETON) && (randint1(100) > 60)))
1505                                                 {
1506                                                         if (!note_kill)
1507                                                         {
1508                                                                 note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
1509                                                         }
1510                                                         continue;
1511                                                 }
1512                                                 else if (summon_named_creature(who, y, x, o_ptr->pval, mode))
1513                                                 {
1514                                                         note_kill = _("生き返った。", " revived.");
1515                                                 }
1516                                                 else if (!note_kill)
1517                                                 {
1518                                                         note_kill = _("灰になった。", (plural ? " become dust." : " becomes dust."));
1519                                                 }
1520                                         }
1521                                         do_kill = TRUE;
1522                                         obvious = TRUE;
1523                                 }
1524                                 break;
1525                         }
1526                 }
1527
1528
1529                 /* Attempt to destroy the object */
1530                 if (do_kill)
1531                 {
1532                         /* Effect "observed" */
1533                         if (known && (o_ptr->marked & OM_FOUND))
1534                         {
1535                                 obvious = TRUE;
1536                                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1537                         }
1538
1539                         /* Artifacts, and other objects, get to resist */
1540                         if (is_art || ignore)
1541                         {
1542                                 /* Observe the resist */
1543                                 if (known && (o_ptr->marked & OM_FOUND))
1544                                 {
1545                                         msg_format(_("%sは影響を受けない!", 
1546                                            (plural ? "The %s are unaffected!" : "The %s is unaffected!")), o_name);
1547                                 }
1548                         }
1549
1550                         /* Kill it */
1551                         else
1552                         {
1553                                 /* Describe if needed */
1554                                 if (known && (o_ptr->marked & OM_FOUND) && note_kill)
1555                                 {
1556                                         msg_format(_("%sは%s", "The %s%s"), o_name, note_kill);
1557                                 }
1558
1559                                 k_idx = o_ptr->k_idx;
1560                                 is_potion = object_is_potion(o_ptr);
1561
1562
1563                                 /* Delete the object */
1564                                 delete_object_idx(this_o_idx);
1565
1566                                 /* Potions produce effects when 'shattered' */
1567                                 if (is_potion)
1568                                 {
1569                                         (void)potion_smash_effect(who, y, x, k_idx);
1570                                 }
1571
1572                                 /* Redraw */
1573                                 lite_spot(y, x);
1574                         }
1575                 }
1576         }
1577
1578         /* Return "Anything seen?" */
1579         return (obvious);
1580 }
1581
1582
1583 /*!
1584  * @brief 汎用的なビーム/ボルト/ボール系によるモンスターへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
1585  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
1586  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
1587  * @param y 目標Y座標 / Target y location (or location to travel "towards")
1588  * @param x 目標X座標 / Target x location (or location to travel "towards")
1589  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
1590  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
1591  * @param flg 効果フラグ
1592  * @param see_s_msg TRUEならばメッセージを表示する
1593  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
1594  * @details
1595  * <pre>
1596  * This routine takes a "source monster" (by index) which is mostly used to
1597  * determine if the player is causing the damage, and a "radius" (see below),
1598  * which is used to decrease the power of explosions with distance, and a
1599  * location, via integers which are modified by certain types of attacks
1600  * (polymorph and teleport being the obvious ones), a default damage, which
1601  * is modified as needed based on various properties, and finally a "damage
1602  * type" (see below).
1603  * </pre>
1604  * <pre>
1605  * Note that this routine can handle "no damage" attacks (like teleport) by
1606  * taking a "zero" damage, and can even take "parameters" to attacks (like
1607  * confuse) by accepting a "damage", using it to calculate the effect, and
1608  * then setting the damage to zero.  Note that the "damage" parameter is
1609  * divided by the radius, so monsters not at the "epicenter" will not take
1610  * as much damage (or whatever)...
1611  * </pre>
1612  * <pre>
1613  * Note that "polymorph" is dangerous, since a failure in "place_monster()"'
1614  * may result in a dereference of an invalid pointer.  
1615  * </pre>
1616  * <pre>
1617  * Various messages are produced, and damage is applied.
1618  * </pre>
1619  * <pre>
1620  * Just "casting" a substance (i.e. plasma) does not make you immune, you must
1621  * actually be "made" of that substance, or "breathe" big balls of it.
1622  * We assume that "Plasma" monsters, and "Plasma" breathers, are immune
1623  * to plasma.
1624  * We assume "Nether" is an evil, necromantic force, so it doesn't hurt undead,
1625  * and hurts evil less.  If can breath nether, then it resists it as well.
1626  * </pre>
1627  * <pre>
1628  * Damage reductions use the following formulas:
1629  *   Note that "dam = dam * 6 / (randint1(6) + 6);"
1630  *       gives avg damage of .655, ranging from .858 to .500
1631  *   Note that "dam = dam * 5 / (randint1(6) + 6);"
1632  *       gives avg damage of .544, ranging from .714 to .417
1633  *   Note that "dam = dam * 4 / (randint1(6) + 6);"
1634  *       gives avg damage of .444, ranging from .556 to .333
1635  *   Note that "dam = dam * 3 / (randint1(6) + 6);"
1636  *       gives avg damage of .327, ranging from .427 to .250
1637  *   Note that "dam = dam * 2 / (randint1(6) + 6);"
1638  *       gives something simple.
1639  * </pre>
1640  * <pre>
1641  * In this function, "result" messages are postponed until the end, where
1642  * the "note" string is appended to the monster name, if not NULL.  So,
1643  * to make a spell have "no effect" just set "note" to NULL.  You should
1644  * also set "notice" to FALSE, or the player will learn what the spell does.
1645  * </pre>
1646  * <pre>
1647  * We attempt to return "TRUE" if the player saw anything "useful" happen.
1648  * "flg" was added.
1649  * </pre>
1650  */
1651 static bool project_m(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, bool see_s_msg)
1652 {
1653         int tmp;
1654
1655         cave_type *c_ptr = &cave[y][x];
1656
1657         monster_type *m_ptr = &m_list[c_ptr->m_idx];
1658         monster_type *caster_ptr = (who > 0) ? &m_list[who] : NULL;
1659
1660         monster_race *r_ptr = &r_info[m_ptr->r_idx];
1661
1662         char killer[80];
1663
1664         /* Is the monster "seen"? */
1665         bool seen = m_ptr->ml;
1666         bool seen_msg = is_seen(m_ptr);
1667
1668         bool slept = (bool)MON_CSLEEP(m_ptr);
1669
1670         /* Were the effects "obvious" (if seen)? */
1671         bool obvious = FALSE;
1672
1673         /* Can the player know about this effect? */
1674         bool known = ((m_ptr->cdis <= MAX_SIGHT) || p_ptr->inside_battle);
1675
1676         /* Were the effects "irrelevant"? */
1677         bool skipped = FALSE;
1678
1679         /* Gets the monster angry at the source of the effect? */
1680         bool get_angry = FALSE;
1681
1682         /* Polymorph setting (true or false) */
1683         bool do_poly = FALSE;
1684
1685         /* Teleport setting (max distance) */
1686         int do_dist = 0;
1687
1688         /* Confusion setting (amount to confuse) */
1689         int do_conf = 0;
1690
1691         /* Stunning setting (amount to stun) */
1692         int do_stun = 0;
1693
1694         /* Sleep amount (amount to sleep) */
1695         int do_sleep = 0;
1696
1697         /* Fear amount (amount to fear) */
1698         int do_fear = 0;
1699
1700         /* Time amount (amount to time) */
1701         int do_time = 0;
1702
1703         bool heal_leper = FALSE;
1704
1705         /* Hold the monster name */
1706         char m_name[80];
1707         char m_poss[10];
1708
1709         PARAMETER_VALUE photo = 0;
1710
1711         /* Assume no note */
1712         cptr note = NULL;
1713
1714         /* Assume a default death */
1715         cptr note_dies = extract_note_dies(real_r_ptr(m_ptr));
1716
1717         int ty = m_ptr->fy;
1718         int tx = m_ptr->fx;
1719
1720         int caster_lev = (who > 0) ? r_info[caster_ptr->r_idx].level : (p_ptr->lev * 2);
1721
1722         /* Nobody here */
1723         if (!c_ptr->m_idx) return (FALSE);
1724
1725         /* Never affect projector */
1726         if (who && (c_ptr->m_idx == who)) return (FALSE);
1727         if ((c_ptr->m_idx == p_ptr->riding) && !who && !(typ == GF_OLD_HEAL) && !(typ == GF_OLD_SPEED) && !(typ == GF_STAR_HEAL)) return (FALSE);
1728         if (sukekaku && ((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) return FALSE;
1729
1730         /* Don't affect already death monsters */
1731         /* Prevents problems with chain reactions of exploding monsters */
1732         if (m_ptr->hp < 0) return (FALSE);
1733
1734         /* Reduce damage by distance */
1735         dam = (dam + r) / (r + 1);
1736
1737
1738         /* Get the monster name (BEFORE polymorphing) */
1739         monster_desc(m_name, m_ptr, 0);
1740
1741         /* Get the monster possessive ("his"/"her"/"its") */
1742         monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
1743
1744         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
1745
1746         /* Analyze the damage type */
1747         switch (typ)
1748         {
1749                 /* Magic Missile -- pure damage */
1750                 case GF_MISSILE:
1751                 {
1752                         if (seen) obvious = TRUE;
1753
1754                         if (r_ptr->flagsr & RFR_RES_ALL)
1755                         {
1756                                 note = _("には完全な耐性がある!", " is immune.");
1757                                 dam = 0;
1758                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1759                                 break;
1760                         }
1761                         break;
1762                 }
1763
1764                 /* Acid */
1765                 case GF_ACID:
1766                 {
1767                         if (seen) obvious = TRUE;
1768
1769                         if (r_ptr->flagsr & RFR_RES_ALL)
1770                         {
1771                                 note = _("には完全な耐性がある!", " is immune.");
1772                                 dam = 0;
1773                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1774                                 break;
1775                         }
1776                         if (r_ptr->flagsr & RFR_IM_ACID)
1777                         {
1778                                 note = _("にはかなり耐性がある!", " resists a lot.");
1779                                 dam /= 9;
1780                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_ACID);
1781                         }
1782                         break;
1783                 }
1784
1785                 /* Electricity */
1786                 case GF_ELEC:
1787                 {
1788                         if (seen) obvious = TRUE;
1789
1790                         if (r_ptr->flagsr & RFR_RES_ALL)
1791                         {
1792                                 note = _("には完全な耐性がある!", " is immune.");
1793                                 dam = 0;
1794                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1795                                 break;
1796                         }
1797                         if (r_ptr->flagsr & RFR_IM_ELEC)
1798                         {
1799                                 note = _("にはかなり耐性がある!", " resists a lot.");
1800                                 dam /= 9;
1801                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_ELEC);
1802                         }
1803                         break;
1804                 }
1805
1806                 /* Fire damage */
1807                 case GF_FIRE:
1808                 {
1809                         if (seen) obvious = TRUE;
1810
1811                         if (r_ptr->flagsr & RFR_RES_ALL)
1812                         {
1813                                 note = _("には完全な耐性がある!", " is immune.");
1814                                 dam = 0;
1815                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1816                                 break;
1817                         }
1818                         if (r_ptr->flagsr & RFR_IM_FIRE)
1819                         {
1820                                 note = _("にはかなり耐性がある!", " resists a lot.");
1821                                 dam /= 9;
1822                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_FIRE);
1823                         }
1824                         else if (r_ptr->flags3 & (RF3_HURT_FIRE))
1825                         {
1826                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1827                                 dam *= 2;
1828                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_FIRE);
1829                         }
1830                         break;
1831                 }
1832
1833                 /* Cold */
1834                 case GF_COLD:
1835                 {
1836                         if (seen) obvious = TRUE;
1837
1838                         if (r_ptr->flagsr & RFR_RES_ALL)
1839                         {
1840                                 note = _("には完全な耐性がある!", " is immune.");
1841                                 dam = 0;
1842                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1843                                 break;
1844                         }
1845                         if (r_ptr->flagsr & RFR_IM_COLD)
1846                         {
1847                                 note = _("にはかなり耐性がある!", " resists a lot.");
1848                                 dam /= 9;
1849                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_COLD);
1850                         }
1851                         else if (r_ptr->flags3 & (RF3_HURT_COLD))
1852                         {
1853                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1854                                 dam *= 2;
1855                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_COLD);
1856                         }
1857                         break;
1858                 }
1859
1860                 /* Poison */
1861                 case GF_POIS:
1862                 {
1863                         if (seen) obvious = TRUE;
1864
1865                         if (r_ptr->flagsr & RFR_RES_ALL)
1866                         {
1867                                 note = _("には完全な耐性がある!", " is immune.");
1868                                 dam = 0;
1869                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1870                                 break;
1871                         }
1872                         if (r_ptr->flagsr & RFR_IM_POIS)
1873                         {
1874                                 note = _("にはかなり耐性がある!", " resists a lot.");
1875                                 dam /= 9;
1876                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_POIS);
1877                         }
1878                         break;
1879                 }
1880
1881                 /* Nuclear waste */
1882                 case GF_NUKE:
1883                 {
1884                         if (seen) obvious = TRUE;
1885
1886                         if (r_ptr->flagsr & RFR_RES_ALL)
1887                         {
1888                                 note = _("には完全な耐性がある!", " is immune.");
1889                                 dam = 0;
1890                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1891                                 break;
1892                         }
1893                         if (r_ptr->flagsr & RFR_IM_POIS)
1894                         {
1895                                 note = _("には耐性がある。", " resists.");
1896                                 dam *= 3; dam /= randint1(6) + 6;
1897                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_POIS);
1898                         }
1899                         else if (one_in_(3)) do_poly = TRUE;
1900                         break;
1901                 }
1902
1903                 /* Hellfire -- hurts Evil */
1904                 case GF_HELL_FIRE:
1905                 {
1906                         if (seen) obvious = TRUE;
1907
1908                         if (r_ptr->flagsr & RFR_RES_ALL)
1909                         {
1910                                 note = _("には完全な耐性がある!", " is immune.");
1911                                 dam = 0;
1912                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1913                                 break;
1914                         }
1915                         if (r_ptr->flags3 & RF3_GOOD)
1916                         {
1917                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1918                                 dam *= 2;
1919                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
1920                         }
1921                         break;
1922                 }
1923
1924                 /* Holy Fire -- hurts Evil, Good are immune, others _resist_ */
1925                 case GF_HOLY_FIRE:
1926                 {
1927                         if (seen) obvious = TRUE;
1928
1929                         if (r_ptr->flagsr & RFR_RES_ALL)
1930                         {
1931                                 note = _("には完全な耐性がある!", " is immune.");
1932                                 dam = 0;
1933                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1934                                 break;
1935                         }
1936                         if (r_ptr->flags3 & RF3_GOOD)
1937                         {
1938                                 note = _("には完全な耐性がある!", " is immune.");
1939                                 dam = 0;
1940                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= RF3_GOOD;
1941                         }
1942                         else if (r_ptr->flags3 & RF3_EVIL)
1943                         {
1944                                 dam *= 2;
1945                                 note = _("はひどい痛手をうけた。", " is hit hard.");
1946                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= RF3_EVIL;
1947                         }
1948                         else
1949                         {
1950                                 note = _("には耐性がある。", " resists.");
1951                                 dam *= 3; dam /= randint1(6) + 6;
1952                         }
1953                         break;
1954                 }
1955
1956                 /* Arrow -- XXX no defense */
1957                 case GF_ARROW:
1958                 {
1959                         if (seen) obvious = TRUE;
1960
1961                         if (r_ptr->flagsr & RFR_RES_ALL)
1962                         {
1963                                 note = _("には完全な耐性がある!", " is immune.");
1964                                 dam = 0;
1965                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1966                                 break;
1967                         }
1968                         break;
1969                 }
1970
1971                 /* Plasma -- XXX perhaps check ELEC or FIRE */
1972                 case GF_PLASMA:
1973                 {
1974                         if (seen) obvious = TRUE;
1975
1976                         if (r_ptr->flagsr & RFR_RES_ALL)
1977                         {
1978                                 note = _("には完全な耐性がある!", " is immune.");
1979                                 dam = 0;
1980                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
1981                                 break;
1982                         }
1983                         if (r_ptr->flagsr & RFR_RES_PLAS)
1984                         {
1985                                 note = _("には耐性がある。", " resists.");
1986                                 dam *= 3; dam /= randint1(6) + 6;
1987                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_PLAS);
1988                         }
1989                         break;
1990                 }
1991
1992                 /* Nether -- see above */
1993                 case GF_NETHER:
1994                 {
1995                         if (seen) obvious = TRUE;
1996
1997                         if (r_ptr->flagsr & RFR_RES_ALL)
1998                         {
1999                                 note = _("には完全な耐性がある!", " is immune.");
2000                                 dam = 0;
2001                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2002                                 break;
2003                         }
2004                         if (r_ptr->flagsr & RFR_RES_NETH)
2005                         {
2006                                 if (r_ptr->flags3 & RF3_UNDEAD)
2007                                 {
2008                                         note = _("には完全な耐性がある!", " is immune.");
2009                                         dam = 0;
2010                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
2011                                 }
2012                                 else
2013                                 {
2014                                         note = _("には耐性がある。", " resists.");
2015                                         dam *= 3; dam /= randint1(6) + 6;
2016                                 }
2017                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_NETH);
2018                         }
2019                         else if (r_ptr->flags3 & RF3_EVIL)
2020                         {
2021                                 note = _("はいくらか耐性を示した。", " resists somewhat.");
2022                                 dam /= 2;
2023                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
2024                         }
2025                         break;
2026                 }
2027
2028                 /* Water (acid) damage -- Water spirits/elementals are immune */
2029                 case GF_WATER:
2030                 {
2031                         if (seen) obvious = TRUE;
2032
2033                         if (r_ptr->flagsr & RFR_RES_ALL)
2034                         {
2035                                 note = _("には完全な耐性がある!", " is immune.");
2036                                 dam = 0;
2037                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2038                                 break;
2039                         }
2040                         if (r_ptr->flagsr & RFR_RES_WATE)
2041                         {
2042                                 if ((m_ptr->r_idx == MON_WATER_ELEM) || (m_ptr->r_idx == MON_UNMAKER))
2043                                 {
2044                                         note = _("には完全な耐性がある!", " is immune.");
2045                                         dam = 0;
2046                                 }
2047                                 else
2048                                 {
2049                                         note = _("には耐性がある。", " resists.");
2050                                         dam *= 3; dam /= randint1(6) + 6;
2051                                 }
2052                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_WATE);
2053                         }
2054                         break;
2055                 }
2056
2057                 /* Chaos -- Chaos breathers resist */
2058                 case GF_CHAOS:
2059                 {
2060                         if (seen) obvious = TRUE;
2061
2062                         if (r_ptr->flagsr & RFR_RES_ALL)
2063                         {
2064                                 note = _("には完全な耐性がある!", " is immune.");
2065                                 dam = 0;
2066                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2067                                 break;
2068                         }
2069                         if (r_ptr->flagsr & RFR_RES_CHAO)
2070                         {
2071                                 note = _("には耐性がある。", " resists.");
2072                                 dam *= 3; dam /= randint1(6) + 6;
2073                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_CHAO);
2074                         }
2075                         else if ((r_ptr->flags3 & RF3_DEMON) && one_in_(3))
2076                         {
2077                                 note = _("はいくらか耐性を示した。", " resists somewhat.");
2078                                 dam *= 3; dam /= randint1(6) + 6;
2079                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
2080                         }
2081                         else
2082                         {
2083                                 do_poly = TRUE;
2084                                 do_conf = (5 + randint1(11) + r) / (r + 1);
2085                         }
2086                         break;
2087                 }
2088
2089                 /* Shards -- Shard breathers resist */
2090                 case GF_SHARDS:
2091                 {
2092                         if (seen) obvious = TRUE;
2093
2094                         if (r_ptr->flagsr & RFR_RES_ALL)
2095                         {
2096                                 note = _("には完全な耐性がある!", " is immune.");
2097                                 dam = 0;
2098                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2099                                 break;
2100                         }
2101                         if (r_ptr->flagsr & RFR_RES_SHAR)
2102                         {
2103                                 note = _("には耐性がある。", " resists.");
2104                                 dam *= 3; dam /= randint1(6) + 6;
2105                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SHAR);
2106                         }
2107                         break;
2108                 }
2109
2110                 /* Rocket: Shard resistance helps */
2111                 case GF_ROCKET:
2112                 {
2113                         if (seen) obvious = TRUE;
2114
2115                         if (r_ptr->flagsr & RFR_RES_ALL)
2116                         {
2117                                 note = _("には完全な耐性がある!", " is immune.");
2118                                 dam = 0;
2119                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2120                                 break;
2121                         }
2122                         if (r_ptr->flagsr & RFR_RES_SHAR)
2123                         {
2124                                 note = _("はいくらか耐性を示した。", " resists somewhat.");
2125                                 dam /= 2;
2126                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SHAR);
2127                         }
2128                         break;
2129                 }
2130
2131
2132                 /* Sound -- Sound breathers resist */
2133                 case GF_SOUND:
2134                 {
2135                         if (seen) obvious = TRUE;
2136
2137                         if (r_ptr->flagsr & RFR_RES_ALL)
2138                         {
2139                                 note = _("には完全な耐性がある!", " is immune.");
2140                                 dam = 0;
2141                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2142                                 break;
2143                         }
2144                         if (r_ptr->flagsr & RFR_RES_SOUN)
2145                         {
2146                                 note = _("には耐性がある。", " resists.");
2147                                 dam *= 2; dam /= randint1(6) + 6;
2148                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_SOUN);
2149                         }
2150                         else do_stun = (10 + randint1(15) + r) / (r + 1);
2151                         break;
2152                 }
2153
2154                 /* Confusion */
2155                 case GF_CONFUSION:
2156                 {
2157                         if (seen) obvious = TRUE;
2158
2159                         if (r_ptr->flagsr & RFR_RES_ALL)
2160                         {
2161                                 note = _("には完全な耐性がある!", " is immune.");
2162                                 dam = 0;
2163                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2164                                 break;
2165                         }
2166                         if (r_ptr->flags3 & RF3_NO_CONF)
2167                         {
2168                                 note = _("には耐性がある。", " resists.");
2169                                 dam *= 3; dam /= randint1(6) + 6;
2170                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
2171                         }
2172                         else do_conf = (10 + randint1(15) + r) / (r + 1);
2173                         break;
2174                 }
2175
2176                 /* Disenchantment -- Breathers and Disenchanters resist */
2177                 case GF_DISENCHANT:
2178                 {
2179                         if (seen) obvious = TRUE;
2180
2181                         if (r_ptr->flagsr & RFR_RES_ALL)
2182                         {
2183                                 note = _("には完全な耐性がある!", " is immune.");
2184                                 dam = 0;
2185                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2186                                 break;
2187                         }
2188                         if (r_ptr->flagsr & RFR_RES_DISE)
2189                         {
2190                                 note = _("には耐性がある。", " resists.");
2191                                 dam *= 3; dam /= randint1(6) + 6;
2192                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DISE);
2193                         }
2194                         break;
2195                 }
2196
2197                 /* Nexus -- Breathers and Existers resist */
2198                 case GF_NEXUS:
2199                 {
2200                         if (seen) obvious = TRUE;
2201
2202                         if (r_ptr->flagsr & RFR_RES_ALL)
2203                         {
2204                                 note = _("には完全な耐性がある!", " is immune.");
2205                                 dam = 0;
2206                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2207                                 break;
2208                         }
2209                         if (r_ptr->flagsr & RFR_RES_NEXU)
2210                         {
2211                                 note = _("には耐性がある。", " resists.");
2212                                 dam *= 3; dam /= randint1(6) + 6;
2213                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_NEXU);
2214                         }
2215                         break;
2216                 }
2217
2218                 /* Force */
2219                 case GF_FORCE:
2220                 {
2221                         if (seen) obvious = TRUE;
2222
2223                         if (r_ptr->flagsr & RFR_RES_ALL)
2224                         {
2225                                 note = _("には完全な耐性がある!", " is immune.");
2226                                 dam = 0;
2227                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2228                                 break;
2229                         }
2230                         if (r_ptr->flagsr & RFR_RES_WALL)
2231                         {
2232                                 note = _("には耐性がある。", " resists.");
2233                                 dam *= 3; dam /= randint1(6) + 6;
2234                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_WALL);
2235                         }
2236                         else do_stun = (randint1(15) + r) / (r + 1);
2237                         break;
2238                 }
2239
2240                 /* Inertia -- breathers resist */
2241                 case GF_INERTIAL:
2242                 {
2243                         if (seen) obvious = TRUE;
2244
2245                         if (r_ptr->flagsr & RFR_RES_ALL)
2246                         {
2247                                 note = _("には完全な耐性がある!", " is immune.");
2248                                 dam = 0;
2249                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2250                                 break;
2251                         }
2252                         if (r_ptr->flagsr & RFR_RES_INER)
2253                         {
2254                                 note = _("には耐性がある。", " resists.");
2255                                 dam *= 3; dam /= randint1(6) + 6;
2256                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_INER);
2257                         }
2258                         else
2259                         {
2260                                 /* Powerful monsters can resist */
2261                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2262                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2263                                 {
2264                                         obvious = FALSE;
2265                                 }
2266                                 /* Normal monsters slow down */
2267                                 else
2268                                 {
2269                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
2270                                         {
2271                                                 note = _("の動きが遅くなった。", " starts moving slower.");
2272                                         }
2273                                 }
2274                         }
2275                         break;
2276                 }
2277
2278                 /* Time -- breathers resist */
2279                 case GF_TIME:
2280                 {
2281                         if (seen) obvious = TRUE;
2282
2283                         if (r_ptr->flagsr & RFR_RES_ALL)
2284                         {
2285                                 note = _("には完全な耐性がある!", " is immune.");
2286                                 dam = 0;
2287                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2288                                 break;
2289                         }
2290                         if (r_ptr->flagsr & RFR_RES_TIME)
2291                         {
2292                                 note = _("には耐性がある。", " resists.");
2293                                 dam *= 3; dam /= randint1(6) + 6;
2294                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_TIME);
2295                         }
2296                         else do_time = (dam + 1) / 2;
2297                         break;
2298                 }
2299
2300                 /* Gravity -- breathers resist */
2301                 case GF_GRAVITY:
2302                 {
2303                         bool resist_tele = FALSE;
2304
2305                         if (seen) obvious = TRUE;
2306
2307                         if (r_ptr->flagsr & RFR_RES_ALL)
2308                         {
2309                                 note = _("には完全な耐性がある!", " is immune.");
2310                                 dam = 0;
2311                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2312                                 break;
2313                         }
2314                         if (r_ptr->flagsr & RFR_RES_TELE)
2315                         {
2316                                 if (r_ptr->flags1 & (RF1_UNIQUE))
2317                                 {
2318                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2319                                         note = _("には効果がなかった。", " is unaffected!");
2320                                         resist_tele = TRUE;
2321                                 }
2322                                 else if (r_ptr->level > randint1(100))
2323                                 {
2324                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2325                                         note = _("には耐性がある!", " resists!");
2326                                         resist_tele = TRUE;
2327                                 }
2328                         }
2329
2330                         if (!resist_tele) do_dist = 10;
2331                         else do_dist = 0;
2332                         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_dist = 0;
2333
2334                         if (r_ptr->flagsr & RFR_RES_GRAV)
2335                         {
2336                                 note = _("には耐性がある!", " resists!");
2337                                 dam *= 3; dam /= randint1(6) + 6;
2338                                 do_dist = 0;
2339                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_GRAV);
2340                         }
2341                         else
2342                         {
2343                                 /* 1. slowness */
2344                                 /* Powerful monsters can resist */
2345                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2346                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2347                                 {
2348                                         obvious = FALSE;
2349                                 }
2350                                 /* Normal monsters slow down */
2351                                 else
2352                                 {
2353                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
2354                                         {
2355                                                 note = _("の動きが遅くなった。", " starts moving slower.");
2356                                         }
2357                                 }
2358
2359                                 /* 2. stun */
2360                                 do_stun = damroll((caster_lev / 20) + 3 , (dam)) + 1;
2361
2362                                 /* Attempt a saving throw */
2363                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
2364                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2365                                 {
2366                                         /* Resist */
2367                                         do_stun = 0;
2368                                         /* No obvious effect */
2369                                         note = _("には効果がなかった。", " is unaffected!");
2370                                         obvious = FALSE;
2371                                 }
2372                         }
2373                         break;
2374                 }
2375
2376                 /* Pure damage */
2377                 case GF_MANA:
2378                 case GF_SEEKER:
2379                 case GF_SUPER_RAY:
2380                 {
2381                         if (seen) obvious = TRUE;
2382
2383                         if (r_ptr->flagsr & RFR_RES_ALL)
2384                         {
2385                                 note = _("には完全な耐性がある!", " is immune.");
2386                                 dam = 0;
2387                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2388                                 break;
2389                         }
2390                         break;
2391                 }
2392
2393
2394                 /* Pure damage */
2395                 case GF_DISINTEGRATE:
2396                 {
2397                         if (seen) obvious = TRUE;
2398
2399                         if (r_ptr->flagsr & RFR_RES_ALL)
2400                         {
2401                                 note = _("には完全な耐性がある!", " is immune.");
2402                                 dam = 0;
2403                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2404                                 break;
2405                         }
2406                         if (r_ptr->flags3 & RF3_HURT_ROCK)
2407                         {
2408                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
2409                                 note = _("の皮膚がただれた!", " loses some skin!");
2410                                 note_dies = _("は蒸発した!", " evaporates!");
2411                                 dam *= 2;
2412                         }
2413                         break;
2414                 }
2415
2416                 case GF_PSI:
2417                 {
2418                         if (seen) obvious = TRUE;
2419
2420                         /* PSI only works if the monster can see you! -- RG */
2421                         if (!(los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)))
2422                         {
2423                                 if (seen_msg) 
2424                                         msg_format(_("%sはあなたが見えないので影響されない!", "%^s can't see you, and isn't affected!"), m_name);
2425                                 skipped = TRUE;
2426                                 break;
2427                         }
2428
2429                         if (r_ptr->flagsr & RFR_RES_ALL)
2430                         {
2431                                 note = _("には完全な耐性がある!", " is immune.");
2432                                 dam = 0;
2433                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2434                                 break;
2435                         }
2436                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
2437                         {
2438                                 dam = 0;
2439                                 note = _("には完全な耐性がある!", " is immune.");
2440                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2441
2442                         }
2443                         else if ((r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
2444                                          (r_ptr->flags3 & RF3_ANIMAL) ||
2445                                          (r_ptr->level > randint1(3 * dam)))
2446                         {
2447                                 note = _("には耐性がある!", " resists!");
2448                                 dam /= 3;
2449
2450                                 /*
2451                                  * Powerful demons & undead can turn a mindcrafter's
2452                                  * attacks back on them
2453                                  */
2454                                 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
2455                                         (r_ptr->level > p_ptr->lev / 2) &&
2456                                         one_in_(2))
2457                                 {
2458                                         note = NULL;
2459                                         msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!", 
2460                                                 (seen ? "%^s's corrupted mind backlashes your attack!" : 
2461                                                                 "%^ss corrupted mind backlashes your attack!")), m_name);
2462
2463                                         /* Saving throw */
2464                                         if ((randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
2465                                         {
2466                                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
2467                                         }
2468                                         else
2469                                         {
2470                                                 /* Injure +/- confusion */
2471                                                 monster_desc(killer, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
2472                                                 take_hit(DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
2473                                                 if (one_in_(4) && !CHECK_MULTISHADOW())
2474                                                 {
2475                                                         switch (randint1(4))
2476                                                         {
2477                                                                 case 1:
2478                                                                         set_confused(p_ptr->confused + 3 + randint1(dam));
2479                                                                         break;
2480                                                                 case 2:
2481                                                                         set_stun(p_ptr->stun + randint1(dam));
2482                                                                         break;
2483                                                                 case 3:
2484                                                                 {
2485                                                                         if (r_ptr->flags3 & RF3_NO_FEAR)
2486                                                                                 note = _("には効果がなかった。", " is unaffected.");
2487                                                                         else
2488                                                                                 set_afraid(p_ptr->afraid + 3 + randint1(dam));
2489                                                                         break;
2490                                                                 }
2491                                                                 default:
2492                                                                         if (!p_ptr->free_act)
2493                                                                                 (void)set_paralyzed(p_ptr->paralyzed + randint1(dam));
2494                                                                         break;
2495                                                         }
2496                                                 }
2497                                         }
2498                                         dam = 0;
2499                                 }
2500                         }
2501
2502                         if ((dam > 0) && one_in_(4))
2503                         {
2504                                 switch (randint1(4))
2505                                 {
2506                                         case 1:
2507                                                 do_conf = 3 + randint1(dam);
2508                                                 break;
2509                                         case 2:
2510                                                 do_stun = 3 + randint1(dam);
2511                                                 break;
2512                                         case 3:
2513                                                 do_fear = 3 + randint1(dam);
2514                                                 break;
2515                                         default:
2516                                                 note = _("は眠り込んでしまった!", " falls asleep!");
2517                                                 do_sleep = 3 + randint1(dam);
2518                                                 break;
2519                                 }
2520                         }
2521
2522                         note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
2523                         break;
2524                 }
2525
2526                 case GF_PSI_DRAIN:
2527                 {
2528                         if (seen) obvious = TRUE;
2529
2530                         if (r_ptr->flagsr & RFR_RES_ALL)
2531                         {
2532                                 note = _("には完全な耐性がある!", " is immune.");
2533                                 dam = 0;
2534                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2535                                 break;
2536                         }
2537                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
2538                         {
2539                                 dam = 0;
2540                                 note = _("には完全な耐性がある!", " is immune.");
2541                         }
2542                         else if ((r_ptr->flags2 & (RF2_STUPID | RF2_WEIRD_MIND)) ||
2543                                          (r_ptr->flags3 & RF3_ANIMAL) ||
2544                                          (r_ptr->level > randint1(3 * dam)))
2545                         {
2546                                 note = _("には耐性がある!", " resists!");
2547                                 dam /= 3;
2548
2549                                 /*
2550                                  * Powerful demons & undead can turn a mindcrafter's
2551                                  * attacks back on them
2552                                  */
2553                                 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
2554                                          (r_ptr->level > p_ptr->lev / 2) &&
2555                                          (one_in_(2)))
2556                                 {
2557                                         note = NULL;
2558                                         msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!", 
2559                                                 (seen ? "%^s's corrupted mind backlashes your attack!" : 
2560                                                                 "%^ss corrupted mind backlashes your attack!")), m_name);
2561                                         /* Saving throw */
2562                                         if ((randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
2563                                         {
2564                                                 msg_print(_("あなたは効力を跳ね返した!", "You resist the effects!"));
2565                                         }
2566                                         else
2567                                         {
2568                                                 /* Injure + mana drain */
2569                                                 monster_desc(killer, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
2570                                                 if (!CHECK_MULTISHADOW())
2571                                                 {
2572                                                         msg_print(_("超能力パワーを吸いとられた!", "Your psychic energy is drained!"));
2573                                                         p_ptr->csp -= damroll(5, dam) / 2;
2574                                                         if (p_ptr->csp < 0) p_ptr->csp = 0;
2575                                                         p_ptr->redraw |= PR_MANA;
2576                                                         p_ptr->window |= (PW_SPELL);
2577                                                 }
2578                                                 take_hit(DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
2579                                         }
2580                                         dam = 0;
2581                                 }
2582                         }
2583                         else if (dam > 0)
2584                         {
2585                                 int b = damroll(5, dam) / 4;
2586                                 cptr str = (p_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
2587                                 cptr msg = _("あなたは%sの苦痛を%sに変換した!", 
2588                                          (seen ? "You convert %s's pain into %s!" : 
2589                                                          "You convert %ss pain into %s!"));
2590                                 msg_format(msg, m_name, str);
2591
2592                                 b = MIN(p_ptr->msp, p_ptr->csp + b);
2593                                 p_ptr->csp = b;
2594                                 p_ptr->redraw |= PR_MANA;
2595                                 p_ptr->window |= (PW_SPELL);
2596                         }
2597                         note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
2598                         break;
2599                 }
2600
2601                 case GF_TELEKINESIS:
2602                 {
2603                         if (seen) obvious = TRUE;
2604
2605                         if (r_ptr->flagsr & RFR_RES_ALL)
2606                         {
2607                                 note = _("には完全な耐性がある!", " is immune.");
2608                                 dam = 0;
2609                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2610                                 break;
2611                         }
2612                         if (one_in_(4))
2613                         {
2614                                 if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_dist = 0;
2615                                 else do_dist = 7;
2616                         }
2617
2618                         /* 1. stun */
2619                         do_stun = damroll((caster_lev / 20) + 3 , dam) + 1;
2620
2621                         /* Attempt a saving throw */
2622                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2623                                 (r_ptr->level > 5 + randint1(dam)))
2624                         {
2625                                 /* Resist */
2626                                 do_stun = 0;
2627                                 /* No obvious effect */
2628                                 obvious = FALSE;
2629                         }
2630                         break;
2631                 }
2632
2633                 /* Psycho-spear -- powerful magic missile */
2634                 case GF_PSY_SPEAR:
2635                 {
2636                         if (seen) obvious = TRUE;
2637
2638                         if (r_ptr->flagsr & RFR_RES_ALL)
2639                         {
2640                                 note = _("には完全な耐性がある!", " is immune.");
2641                                 dam = 0;
2642                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2643                                 break;
2644                         }
2645                         break;
2646                 }
2647
2648                 /* Meteor -- powerful magic missile */
2649                 case GF_METEOR:
2650                 {
2651                         if (seen) obvious = TRUE;
2652
2653                         if (r_ptr->flagsr & RFR_RES_ALL)
2654                         {
2655                                 note = _("には完全な耐性がある!", " is immune.");
2656                                 dam = 0;
2657                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2658                                 break;
2659                         }
2660                         break;
2661                 }
2662
2663                 case GF_DOMINATION:
2664                 {
2665                         if (!is_hostile(m_ptr)) break;
2666
2667                         if (seen) obvious = TRUE;
2668
2669                         if (r_ptr->flagsr & RFR_RES_ALL)
2670                         {
2671                                 note = _("には効果がなかった!", " is immune.");
2672                                 dam = 0;
2673                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2674                                 break;
2675                         }
2676                         /* Attempt a saving throw */
2677                         if ((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
2678                                 (r_ptr->flags3 & RF3_NO_CONF) ||
2679                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2680                         {
2681                                 /* Memorize a flag */
2682                                 if (r_ptr->flags3 & RF3_NO_CONF)
2683                                 {
2684                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
2685                                 }
2686
2687                                 /* Resist */
2688                                 do_conf = 0;
2689
2690                                 /*
2691                                  * Powerful demons & undead can turn a mindcrafter's
2692                                  * attacks back on them
2693                                  */
2694                                 if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
2695                                         (r_ptr->level > p_ptr->lev / 2) &&
2696                                         (one_in_(2)))
2697                                 {
2698                                         note = NULL;
2699                                         msg_format(_("%^sの堕落した精神は攻撃を跳ね返した!",
2700                                                 (seen ? "%^s's corrupted mind backlashes your attack!" :
2701                                                 "%^ss corrupted mind backlashes your attack!")), m_name);
2702
2703                                         /* Saving throw */
2704                                         if (randint0(100 + r_ptr->level/2) < p_ptr->skill_sav)
2705                                         {
2706                                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
2707                                         }
2708                                         else
2709                                         {
2710                                                 /* Confuse, stun, terrify */
2711                                                 switch (randint1(4))
2712                                                 {
2713                                                         case 1:
2714                                                                 set_stun(p_ptr->stun + dam / 2);
2715                                                                 break;
2716                                                         case 2:
2717                                                                 set_confused(p_ptr->confused + dam / 2);
2718                                                                 break;
2719                                                         default:
2720                                                         {
2721                                                                 if (r_ptr->flags3 & RF3_NO_FEAR)
2722                                                                         note = _("には効果がなかった。", " is unaffected.");
2723                                                                 else
2724                                                                         set_afraid(p_ptr->afraid + dam);
2725                                                         }
2726                                                 }
2727                                         }
2728                                 }
2729                                 else
2730                                 {
2731                                         /* No obvious effect */
2732                                         note = _("には効果がなかった。", " is unaffected.");
2733                                         obvious = FALSE;
2734                                 }
2735                         }
2736                         else
2737                         {
2738                                 if (!common_saving_throw_charm(p_ptr, dam, m_ptr))
2739                                 {
2740                                         note = _("があなたに隷属した。", " is in your thrall!");
2741                                         set_pet(m_ptr);
2742                                 }
2743                                 else
2744                                 {
2745                                         switch (randint1(4))
2746                                         {
2747                                                 case 1:
2748                                                         do_stun = dam / 2;
2749                                                         break;
2750                                                 case 2:
2751                                                         do_conf = dam / 2;
2752                                                         break;
2753                                                 default:
2754                                                         do_fear = dam;
2755                                         }
2756                                 }
2757                         }
2758
2759                         /* No "real" damage */
2760                         dam = 0;
2761                         break;
2762                 }
2763
2764
2765
2766                 /* Ice -- Cold + Cuts + Stun */
2767                 case GF_ICE:
2768                 {
2769                         if (seen) obvious = TRUE;
2770
2771                         if (r_ptr->flagsr & RFR_RES_ALL)
2772                         {
2773                                 note = _("には完全な耐性がある!", " is immune.");
2774                                 dam = 0;
2775                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2776                                 break;
2777                         }
2778                         do_stun = (randint1(15) + 1) / (r + 1);
2779                         if (r_ptr->flagsr & RFR_IM_COLD)
2780                         {
2781                                 note = _("にはかなり耐性がある!", " resists a lot.");
2782                                 dam /= 9;
2783                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_IM_COLD);
2784                         }
2785                         else if (r_ptr->flags3 & (RF3_HURT_COLD))
2786                         {
2787                                 note = _("はひどい痛手をうけた。", " is hit hard.");
2788                                 dam *= 2;
2789                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_COLD);
2790                         }
2791                         break;
2792                 }
2793
2794
2795                 /* Drain Life */
2796                 case GF_HYPODYNAMIA:
2797                 {
2798                         if (seen) obvious = TRUE;
2799
2800                         if (r_ptr->flagsr & RFR_RES_ALL)
2801                         {
2802                                 note = _("には完全な耐性がある!", " is immune.");
2803                                 dam = 0;
2804                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2805                                 break;
2806                         }
2807                         if (!monster_living(r_ptr))
2808                         {
2809                                 if (is_original_ap_and_seen(m_ptr))
2810                                 {
2811                                         if (r_ptr->flags3 & RF3_DEMON) r_ptr->r_flags3 |= (RF3_DEMON);
2812                                         if (r_ptr->flags3 & RF3_UNDEAD) r_ptr->r_flags3 |= (RF3_UNDEAD);
2813                                         if (r_ptr->flags3 & RF3_NONLIVING) r_ptr->r_flags3 |= (RF3_NONLIVING);
2814                                 }
2815                                 note = _("には効果がなかった。", " is unaffected.");
2816                                 obvious = FALSE;
2817                                 dam = 0;
2818                         }
2819                         else do_time = (dam+7)/8;
2820
2821                         break;
2822                 }
2823
2824                 /* Death Ray */
2825                 case GF_DEATH_RAY:
2826                 {
2827                         if (seen) obvious = TRUE;
2828
2829                         if (r_ptr->flagsr & RFR_RES_ALL)
2830                         {
2831                                 note = _("には完全な耐性がある!", " is immune.");
2832                                 dam = 0;
2833                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2834                                 break;
2835                         }
2836                         if (!monster_living(r_ptr))
2837                         {
2838                                 if (is_original_ap_and_seen(m_ptr))
2839                                 {
2840                                         if (r_ptr->flags3 & RF3_DEMON) r_ptr->r_flags3 |= (RF3_DEMON);
2841                                         if (r_ptr->flags3 & RF3_UNDEAD) r_ptr->r_flags3 |= (RF3_UNDEAD);
2842                                         if (r_ptr->flags3 & RF3_NONLIVING) r_ptr->r_flags3 |= (RF3_NONLIVING);
2843                                 }
2844                                 note = _("には完全な耐性がある!", " is immune.");
2845                                 obvious = FALSE;
2846                                 dam = 0;
2847                         }
2848                         else if (((r_ptr->flags1 & RF1_UNIQUE) &&
2849                                  (randint1(888) != 666)) ||
2850                                  (((r_ptr->level + randint1(20)) > randint1((caster_lev / 2) + randint1(10))) &&
2851                                  randint1(100) != 66))
2852                         {
2853                                 note = _("には耐性がある!", " resists!");
2854                                 obvious = FALSE;
2855                                 dam = 0;
2856                         }
2857
2858                         break;
2859                 }
2860
2861                 /* Polymorph monster (Use "dam" as "power") */
2862                 case GF_OLD_POLY:
2863                 {
2864                         if (seen) obvious = TRUE;
2865
2866                         if (r_ptr->flagsr & RFR_RES_ALL)
2867                         {
2868                                 note = _("には効果がなかった。", " is unaffected.");
2869                                 dam = 0;
2870                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
2871                                 break;
2872                         }
2873                         /* Attempt to polymorph (see below) */
2874                         do_poly = TRUE;
2875
2876                         /* Powerful monsters can resist */
2877                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
2878                                 (r_ptr->flags1 & RF1_QUESTOR) ||
2879                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
2880                         {
2881                                 note = _("には効果がなかった。", " is unaffected.");
2882                                 do_poly = FALSE;
2883                                 obvious = FALSE;
2884                         }
2885
2886                         /* No "real" damage */
2887                         dam = 0;
2888
2889                         break;
2890                 }
2891
2892
2893                 /* Clone monsters (Ignore "dam") */
2894                 case GF_OLD_CLONE:
2895                 {
2896                         if (seen) obvious = TRUE;
2897
2898                         if ((p_ptr->inside_arena) || is_pet(m_ptr) || (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)))
2899                         {
2900                                 note = _("には効果がなかった。", " is unaffected.");
2901                         }
2902                         else
2903                         {
2904                                 /* Heal fully */
2905                                 m_ptr->hp = m_ptr->maxhp;
2906
2907                                 /* Attempt to clone. */
2908                                 if (multiply_monster(c_ptr->m_idx, TRUE, 0L))
2909                                 {
2910                                         note = _("が分裂した!", " spawns!");
2911                                 }
2912                         }
2913
2914                         /* No "real" damage */
2915                         dam = 0;
2916
2917                         break;
2918                 }
2919
2920
2921                 /* Heal Monster (use "dam" as amount of healing) */
2922                 case GF_STAR_HEAL:
2923                 {
2924                         if (seen) obvious = TRUE;
2925
2926                         /* Wake up */
2927                         (void)set_monster_csleep(c_ptr->m_idx, 0);
2928
2929                         if (m_ptr->maxhp < m_ptr->max_maxhp)
2930                         {
2931                                 if (seen_msg) msg_format(_("%^sの強さが戻った。", "%^s recovers %s vitality."), m_name, m_poss);
2932                                 m_ptr->maxhp = m_ptr->max_maxhp;
2933                         }
2934
2935                         if (!dam)
2936                         {
2937                                 /* Redraw (later) if needed */
2938                                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
2939                                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
2940                                 break;
2941                         }
2942
2943                         /* Fall through */
2944                 }
2945                 case GF_OLD_HEAL:
2946                 {
2947                         if (seen) obvious = TRUE;
2948
2949                         /* Wake up */
2950                         (void)set_monster_csleep(c_ptr->m_idx, 0);
2951                         if (MON_STUNNED(m_ptr))
2952                         {
2953                                 if (seen_msg) msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), m_name);
2954                                 (void)set_monster_stunned(c_ptr->m_idx, 0);
2955                         }
2956                         if (MON_CONFUSED(m_ptr))
2957                         {
2958                                 if (seen_msg) msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), m_name);
2959                                 (void)set_monster_confused(c_ptr->m_idx, 0);
2960                         }
2961                         if (MON_MONFEAR(m_ptr))
2962                         {
2963                                 if (seen_msg) msg_format(_("%^sは勇気を取り戻した。", "%^s recovers %s courage."), m_name);
2964                                 (void)set_monster_monfear(c_ptr->m_idx, 0);
2965                         }
2966
2967                         /* Heal */
2968                         if (m_ptr->hp < 30000) m_ptr->hp += dam;
2969
2970                         /* No overflow */
2971                         if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
2972
2973                         if (!who)
2974                         {
2975                                 chg_virtue(V_VITALITY, 1);
2976
2977                                 if (r_ptr->flags1 & RF1_UNIQUE)
2978                                         chg_virtue(V_INDIVIDUALISM, 1);
2979
2980                                 if (is_friendly(m_ptr))
2981                                         chg_virtue(V_HONOUR, 1);
2982                                 else if (!(r_ptr->flags3 & RF3_EVIL))
2983                                 {
2984                                         if (r_ptr->flags3 & RF3_GOOD)
2985                                                 chg_virtue(V_COMPASSION, 2);
2986                                         else
2987                                                 chg_virtue(V_COMPASSION, 1);
2988                                 }
2989
2990                                 if (r_ptr->flags3 & RF3_ANIMAL)
2991                                         chg_virtue(V_NATURE, 1);
2992                         }
2993
2994                         if (m_ptr->r_idx == MON_LEPER)
2995                         {
2996                                 heal_leper = TRUE;
2997                                 if (!who) chg_virtue(V_COMPASSION, 5);
2998                         }
2999
3000                         /* Redraw (later) if needed */
3001                         if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
3002                         if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
3003
3004                         note = _("は体力を回復したようだ。", " looks healthier.");
3005
3006                         /* No "real" damage */
3007                         dam = 0;
3008                         break;
3009                 }
3010
3011
3012                 /* Speed Monster (Ignore "dam") */
3013                 case GF_OLD_SPEED:
3014                 {
3015                         if (seen) obvious = TRUE;
3016
3017                         /* Speed up */
3018                         if (set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100))
3019                         {
3020                                 note = _("の動きが速くなった。", " starts moving faster.");
3021                         }
3022
3023                         if (!who)
3024                         {
3025                                 if (r_ptr->flags1 & RF1_UNIQUE)
3026                                         chg_virtue(V_INDIVIDUALISM, 1);
3027                                 if (is_friendly(m_ptr))
3028                                         chg_virtue(V_HONOUR, 1);
3029                         }
3030
3031                         /* No "real" damage */
3032                         dam = 0;
3033                         break;
3034                 }
3035
3036
3037                 /* Slow Monster (Use "dam" as "power") */
3038                 case GF_OLD_SLOW:
3039                 {
3040                         if (seen) obvious = TRUE;
3041
3042                         if (r_ptr->flagsr & RFR_RES_ALL)
3043                         {
3044                                 note = _("には効果がなかった。", " is unaffected.");
3045                                 dam = 0;
3046                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3047                                 break;
3048                         }
3049                         /* Powerful monsters can resist */
3050                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3051                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3052                         {
3053                                 note = _("には効果がなかった。", " is unaffected.");
3054                                 obvious = FALSE;
3055                         }
3056
3057                         /* Normal monsters slow down */
3058                         else
3059                         {
3060                                 if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
3061                                 {
3062                                         note = _("の動きが遅くなった。", " starts moving slower.");
3063                                 }
3064                         }
3065
3066                         /* No "real" damage */
3067                         dam = 0;
3068                         break;
3069                 }
3070
3071
3072                 /* Sleep (Use "dam" as "power") */
3073                 case GF_OLD_SLEEP:
3074                 {
3075                         if (seen) obvious = TRUE;
3076
3077                         if (r_ptr->flagsr & RFR_RES_ALL)
3078                         {
3079                                 note = _("には効果がなかった。", " is unaffected.");
3080                                 dam = 0;
3081                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3082                                 break;
3083                         }
3084                         /* Attempt a saving throw */
3085                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3086                                 (r_ptr->flags3 & RF3_NO_SLEEP) ||
3087                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3088                         {
3089                                 /* Memorize a flag */
3090                                 if (r_ptr->flags3 & RF3_NO_SLEEP)
3091                                 {
3092                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
3093                                 }
3094                                 /* No obvious effect */
3095                                 note = _("には効果がなかった。", " is unaffected.");
3096                                 obvious = FALSE;
3097                         }
3098                         else
3099                         {
3100                                 /* Go to sleep (much) later */
3101                                 note = _("は眠り込んでしまった!", " falls asleep!");
3102                                 do_sleep = 500;
3103                         }
3104
3105                         /* No "real" damage */
3106                         dam = 0;
3107                         break;
3108                 }
3109
3110
3111                 /* Sleep (Use "dam" as "power") */
3112                 case GF_STASIS_EVIL:
3113                 {
3114                         if (seen) obvious = TRUE;
3115
3116                         if (r_ptr->flagsr & RFR_RES_ALL)
3117                         {
3118                                 note = _("には効果がなかった!", " is immune.");
3119                                 dam = 0;
3120                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3121                                 break;
3122                         }
3123                         /* Attempt a saving throw */
3124                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3125                                 !(r_ptr->flags3 & RF3_EVIL) ||
3126                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3127                         {
3128                                 note = _("には効果がなかった。", " is unaffected.");
3129                                 obvious = FALSE;
3130                         }
3131                         else
3132                         {
3133                                 /* Go to sleep (much) later */
3134                                 note = _("は動けなくなった!", " is suspended!");
3135                                 do_sleep = 500;
3136                         }
3137
3138                         /* No "real" damage */
3139                         dam = 0;
3140                         break;
3141                 }
3142
3143                 /* Sleep (Use "dam" as "power") */
3144                 case GF_STASIS:
3145                 {
3146                         if (seen) obvious = TRUE;
3147
3148                         if (r_ptr->flagsr & RFR_RES_ALL)
3149                         {
3150                                 note = _("には効果がなかった。", " is unaffected.");
3151                                 dam = 0;
3152                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3153                                 break;
3154                         }
3155                         /* Attempt a saving throw */
3156                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3157                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3158                         {
3159                                 note = _("には効果がなかった。", " is unaffected.");
3160                                 obvious = FALSE;
3161                         }
3162                         else
3163                         {
3164                                 /* Go to sleep (much) later */
3165                                 note = _("は動けなくなった!", " is suspended!");
3166                                 do_sleep = 500;
3167                         }
3168
3169                         /* No "real" damage */
3170                         dam = 0;
3171                         break;
3172                 }
3173
3174                 /* Charm monster */
3175                 case GF_CHARM:
3176                 {
3177                         int vir;
3178                         vir = virtue_number(V_HARMONY);
3179                         if (vir)
3180                         {
3181                                 dam += p_ptr->virtues[vir-1]/10;
3182                         }
3183
3184                         vir = virtue_number(V_INDIVIDUALISM);
3185                         if (vir)
3186                         {
3187                                 dam -= p_ptr->virtues[vir-1]/20;
3188                         }
3189
3190                         if (seen) obvious = TRUE;
3191
3192                         /* Attempt a saving throw */
3193                         if (common_saving_throw_charm(p_ptr, dam, m_ptr))
3194                         {
3195
3196                                 /* Resist */
3197                                 /* No obvious effect */
3198                                 note = _("には効果がなかった。", " is unaffected.");
3199                                 obvious = FALSE;
3200
3201                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3202                         }
3203                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3204                         {
3205                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
3206                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3207                         }
3208                         else
3209                         {
3210                                 note = _("は突然友好的になったようだ!", " suddenly seems friendly!");
3211                                 set_pet(m_ptr);
3212
3213                                 chg_virtue(V_INDIVIDUALISM, -1);
3214                                 if (r_ptr->flags3 & RF3_ANIMAL)
3215                                         chg_virtue(V_NATURE, 1);
3216                         }
3217
3218                         /* No "real" damage */
3219                         dam = 0;
3220                         break;
3221                 }
3222
3223                 /* Control undead */
3224                 case GF_CONTROL_UNDEAD:
3225                 {
3226                         int vir;
3227                         if (seen) obvious = TRUE;
3228
3229                         vir = virtue_number(V_UNLIFE);
3230                         if (vir)
3231                         {
3232                                 dam += p_ptr->virtues[vir-1]/10;
3233                         }
3234
3235                         vir = virtue_number(V_INDIVIDUALISM);
3236                         if (vir)
3237                         {
3238                                 dam -= p_ptr->virtues[vir-1]/20;
3239                         }
3240
3241                         /* Attempt a saving throw */
3242                         if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
3243                                 !(r_ptr->flags3 & RF3_UNDEAD))
3244                         {
3245                                 /* No obvious effect */
3246                                 note = _("には効果がなかった。", " is unaffected.");
3247                                 obvious = FALSE;
3248                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3249                         }
3250                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3251                         {
3252                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
3253                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3254                         }
3255                         else
3256                         {
3257                                 note = _("は既にあなたの奴隷だ!", " is in your thrall!");
3258                                 set_pet(m_ptr);
3259                         }
3260
3261                         /* No "real" damage */
3262                         dam = 0;
3263                         break;
3264                 }
3265
3266                 /* Control demon */
3267                 case GF_CONTROL_DEMON:
3268                 {
3269                         int vir;
3270                         if (seen) obvious = TRUE;
3271
3272                         vir = virtue_number(V_UNLIFE);
3273                         if (vir)
3274                         {
3275                                 dam += p_ptr->virtues[vir-1]/10;
3276                         }
3277
3278                         vir = virtue_number(V_INDIVIDUALISM);
3279                         if (vir)
3280                         {
3281                                 dam -= p_ptr->virtues[vir-1]/20;
3282                         }
3283
3284                         /* Attempt a saving throw */
3285                         if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
3286                                 !(r_ptr->flags3 & RF3_DEMON))
3287                         {
3288                                 /* No obvious effect */
3289                                 note = _("には効果がなかった。", " is unaffected.");
3290                                 obvious = FALSE;
3291                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3292                         }
3293                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3294                         {
3295                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
3296                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3297                         }
3298                         else
3299                         {
3300                                 note = _("は既にあなたの奴隷だ!", " is in your thrall!");
3301                                 set_pet(m_ptr);
3302                         }
3303
3304                         /* No "real" damage */
3305                         dam = 0;
3306                         break;
3307                 }
3308
3309                 /* Tame animal */
3310                 case GF_CONTROL_ANIMAL:
3311                 {
3312                         int vir;
3313                         if (seen) obvious = TRUE;
3314
3315                         vir = virtue_number(V_NATURE);
3316                         if (vir)
3317                         {
3318                                 dam += p_ptr->virtues[vir-1]/10;
3319                         }
3320
3321                         vir = virtue_number(V_INDIVIDUALISM);
3322                         if (vir)
3323                         {
3324                                 dam -= p_ptr->virtues[vir-1]/20;
3325                         }
3326
3327                         /* Attempt a saving throw */
3328                         if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
3329                                 !(r_ptr->flags3 & RF3_ANIMAL))
3330                         {
3331                                 /* Resist */
3332                                 /* No obvious effect */
3333                                 note = _("には効果がなかった。", " is unaffected.");
3334                                 obvious = FALSE;
3335                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3336                         }
3337                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3338                         {
3339                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
3340                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3341                         }
3342                         else
3343                         {
3344                                 note = _("はなついた。", " is tamed!");
3345                                 set_pet(m_ptr);
3346                                 if (r_ptr->flags3 & RF3_ANIMAL)
3347                                         chg_virtue(V_NATURE, 1);
3348                         }
3349
3350                         /* No "real" damage */
3351                         dam = 0;
3352                         break;
3353                 }
3354
3355                 /* Tame animal */
3356                 case GF_CHARM_LIVING:
3357                 {
3358                         int vir;
3359
3360                         vir = virtue_number(V_UNLIFE);
3361                         if (seen) obvious = TRUE;
3362
3363                         vir = virtue_number(V_UNLIFE);
3364                         if (vir)
3365                         {
3366                                 dam -= p_ptr->virtues[vir-1]/10;
3367                         }
3368
3369                         vir = virtue_number(V_INDIVIDUALISM);
3370                         if (vir)
3371                         {
3372                                 dam -= p_ptr->virtues[vir-1]/20;
3373                         }
3374
3375                         msg_format(_("%sを見つめた。", "You stare into %s."), m_name);
3376
3377                         /* Attempt a saving throw */
3378                         if (common_saving_throw_charm(p_ptr, dam, m_ptr) ||
3379                                 !monster_living(r_ptr))
3380                         {
3381                                 /* Resist */
3382                                 /* No obvious effect */
3383                                 note = _("には効果がなかった。", " is unaffected.");
3384                                 obvious = FALSE;
3385                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3386                         }
3387                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3388                         {
3389                                 note = _("はあなたに敵意を抱いている!", " hates you too much!");
3390                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3391                         }
3392                         else
3393                         {
3394                                 note = _("を支配した。", " is tamed!");
3395                                 set_pet(m_ptr);
3396                                 if (r_ptr->flags3 & RF3_ANIMAL)
3397                                         chg_virtue(V_NATURE, 1);
3398                         }
3399
3400                         /* No "real" damage */
3401                         dam = 0;
3402                         break;
3403                 }
3404
3405                 /* Confusion (Use "dam" as "power") */
3406                 case GF_OLD_CONF:
3407                 {
3408                         if (seen) obvious = TRUE;
3409
3410                         if (r_ptr->flagsr & RFR_RES_ALL)
3411                         {
3412                                 note = _("には効果がなかった。", " is unaffected.");
3413                                 dam = 0;
3414                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3415                                 break;
3416                         }
3417                         /* Get confused later */
3418                         do_conf = damroll(3, (dam / 2)) + 1;
3419
3420                         /* Attempt a saving throw */
3421                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3422                                 (r_ptr->flags3 & (RF3_NO_CONF)) ||
3423                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3424                         {
3425                                 /* Memorize a flag */
3426                                 if (r_ptr->flags3 & (RF3_NO_CONF))
3427                                 {
3428                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3429                                 }
3430
3431                                 /* Resist */
3432                                 do_conf = 0;
3433
3434                                 /* No obvious effect */
3435                                 note = _("には効果がなかった。", " is unaffected.");
3436                                 obvious = FALSE;
3437                         }
3438
3439                         /* No "real" damage */
3440                         dam = 0;
3441                         break;
3442                 }
3443
3444                 case GF_STUN:
3445                 {
3446                         if (seen) obvious = TRUE;
3447
3448                         if (r_ptr->flagsr & RFR_RES_ALL)
3449                         {
3450                                 note = _("には効果がなかった。", " is unaffected.");
3451                                 dam = 0;
3452                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3453                                 break;
3454                         }
3455                         do_stun = damroll((caster_lev / 20) + 3 , (dam)) + 1;
3456
3457                         /* Attempt a saving throw */
3458                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3459                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3460                         {
3461                                 /* Resist */
3462                                 do_stun = 0;
3463
3464                                 /* No obvious effect */
3465                                 note = _("には効果がなかった。", " is unaffected.");
3466                                 obvious = FALSE;
3467                         }
3468
3469                         /* No "real" damage */
3470                         dam = 0;
3471                         break;
3472                 }
3473
3474
3475
3476
3477                 /* Lite, but only hurts susceptible creatures */
3478                 case GF_LITE_WEAK:
3479                 {
3480                         if (!dam)
3481                         {
3482                                 skipped = TRUE;
3483                                 break;
3484                         }
3485                         if (r_ptr->flagsr & RFR_RES_ALL)
3486                         {
3487                                 dam = 0;
3488                                 break;
3489                         }
3490                         /* Hurt by light */
3491                         if (r_ptr->flags3 & (RF3_HURT_LITE))
3492                         {
3493                                 /* Obvious effect */
3494                                 if (seen) obvious = TRUE;
3495
3496                                 /* Memorize the effects */
3497                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
3498
3499                                 /* Special effect */
3500                                 note = _("は光に身をすくめた!", " cringes from the light!");
3501                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
3502                         }
3503
3504                         /* Normally no damage */
3505                         else
3506                         {
3507                                 /* No damage */
3508                                 dam = 0;
3509                         }
3510
3511                         break;
3512                 }
3513
3514
3515
3516                 /* Lite -- opposite of Dark */
3517                 case GF_LITE:
3518                 {
3519                         if (seen) obvious = TRUE;
3520
3521                         if (r_ptr->flagsr & RFR_RES_ALL)
3522                         {
3523                                 note = _("には完全な耐性がある!", " is immune.");
3524                                 dam = 0;
3525                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3526                                 break;
3527                         }
3528                         if (r_ptr->flagsr & RFR_RES_LITE)
3529                         {
3530                                 note = _("には耐性がある!", " resists!");
3531                                 dam *= 2; dam /= (randint1(6)+6);
3532                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_LITE);
3533                         }
3534                         else if (r_ptr->flags3 & (RF3_HURT_LITE))
3535                         {
3536                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
3537                                 note = _("は光に身をすくめた!", " cringes from the light!");
3538                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
3539                                 dam *= 2;
3540                         }
3541                         break;
3542                 }
3543
3544
3545                 /* Dark -- opposite of Lite */
3546                 case GF_DARK:
3547                 {
3548                         if (seen) obvious = TRUE;
3549
3550                         if (r_ptr->flagsr & RFR_RES_ALL)
3551                         {
3552                                 note = _("には完全な耐性がある!", " is immune.");
3553                                 dam = 0;
3554                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3555                                 break;
3556                         }
3557                         if (r_ptr->flagsr & RFR_RES_DARK)
3558                         {
3559                                 note = _("には耐性がある!", " resists!");
3560                                 dam *= 2; dam /= (randint1(6)+6);
3561                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DARK);
3562                         }
3563                         break;
3564                 }
3565
3566
3567                 /* Stone to Mud */
3568                 case GF_KILL_WALL:
3569                 {
3570                         if (r_ptr->flagsr & RFR_RES_ALL)
3571                         {
3572                                 dam = 0;
3573                                 break;
3574                         }
3575                         /* Hurt by rock remover */
3576                         if (r_ptr->flags3 & (RF3_HURT_ROCK))
3577                         {
3578                                 /* Notice effect */
3579                                 if (seen) obvious = TRUE;
3580
3581                                 /* Memorize the effects */
3582                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
3583
3584                                 /* Cute little message */
3585                                 note = _("の皮膚がただれた!", " loses some skin!");
3586                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3587                         }
3588
3589                         /* Usually, ignore the effects */
3590                         else
3591                         {
3592                                 /* No damage */
3593                                 dam = 0;
3594                         }
3595
3596                         break;
3597                 }
3598
3599
3600                 /* Teleport undead (Use "dam" as "power") */
3601                 case GF_AWAY_UNDEAD:
3602                 {
3603                         /* Only affect undead */
3604                         if (r_ptr->flags3 & (RF3_UNDEAD))
3605                         {
3606                                 bool resists_tele = FALSE;
3607
3608                                 if (r_ptr->flagsr & RFR_RES_TELE)
3609                                 {
3610                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
3611                                         {
3612                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3613                                                 note = _("には効果がなかった。", " is unaffected.");
3614                                                 resists_tele = TRUE;
3615                                         }
3616                                         else if (r_ptr->level > randint1(100))
3617                                         {
3618                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3619                                                 note = _("には耐性がある!", " resists!");
3620                                                 resists_tele = TRUE;
3621                                         }
3622                                 }
3623
3624                                 if (!resists_tele)
3625                                 {
3626                                         if (seen) obvious = TRUE;
3627                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
3628                                         do_dist = dam;
3629                                 }
3630                         }
3631
3632                         /* Others ignore */
3633                         else
3634                         {
3635                                 /* Irrelevant */
3636                                 skipped = TRUE;
3637                         }
3638
3639                         /* No "real" damage */
3640                         dam = 0;
3641                         break;
3642                 }
3643
3644
3645                 /* Teleport evil (Use "dam" as "power") */
3646                 case GF_AWAY_EVIL:
3647                 {
3648                         /* Only affect evil */
3649                         if (r_ptr->flags3 & (RF3_EVIL))
3650                         {
3651                                 bool resists_tele = FALSE;
3652
3653                                 if (r_ptr->flagsr & RFR_RES_TELE)
3654                                 {
3655                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
3656                                         {
3657                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3658                                                 note = _("には効果がなかった。", " is unaffected.");
3659                                                 resists_tele = TRUE;
3660                                         }
3661                                         else if (r_ptr->level > randint1(100))
3662                                         {
3663                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3664                                                 note = _("には耐性がある!", " resists!");
3665                                                 resists_tele = TRUE;
3666                                         }
3667                                 }
3668
3669                                 if (!resists_tele)
3670                                 {
3671                                         if (seen) obvious = TRUE;
3672                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
3673                                         do_dist = dam;
3674                                 }
3675                         }
3676
3677                         /* Others ignore */
3678                         else
3679                         {
3680                                 /* Irrelevant */
3681                                 skipped = TRUE;
3682                         }
3683
3684                         /* No "real" damage */
3685                         dam = 0;
3686                         break;
3687                 }
3688
3689
3690                 /* Teleport monster (Use "dam" as "power") */
3691                 case GF_AWAY_ALL:
3692                 {
3693                         bool resists_tele = FALSE;
3694                         if (r_ptr->flagsr & RFR_RES_TELE)
3695                         {
3696                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
3697                                 {
3698                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3699                                         note = _("には効果がなかった。", " is unaffected.");
3700                                         resists_tele = TRUE;
3701                                 }
3702                                 else if (r_ptr->level > randint1(100))
3703                                 {
3704                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
3705                                         note = _("には耐性がある!", " resists!");
3706                                         resists_tele = TRUE;
3707                                 }
3708                         }
3709
3710                         if (!resists_tele)
3711                         {
3712                                 /* Obvious */
3713                                 if (seen) obvious = TRUE;
3714
3715                                 /* Prepare to teleport */
3716                                 do_dist = dam;
3717                         }
3718
3719                         /* No "real" damage */
3720                         dam = 0;
3721                         break;
3722                 }
3723
3724
3725                 /* Turn undead (Use "dam" as "power") */
3726                 case GF_TURN_UNDEAD:
3727                 {
3728                         if (r_ptr->flagsr & RFR_RES_ALL)
3729                         {
3730                                 skipped = TRUE;
3731                                 break;
3732                         }
3733                         /* Only affect undead */
3734                         if (r_ptr->flags3 & (RF3_UNDEAD))
3735                         {
3736                                 /* Obvious */
3737                                 if (seen) obvious = TRUE;
3738
3739                                 /* Learn about type */
3740                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
3741
3742                                 /* Apply some fear */
3743                                 do_fear = damroll(3, (dam / 2)) + 1;
3744
3745                                 /* Attempt a saving throw */
3746                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
3747                                 {
3748                                         /* No obvious effect */
3749                                         note = _("には効果がなかった。", " is unaffected.");
3750                                         obvious = FALSE;
3751                                         do_fear = 0;
3752                                 }
3753                         }
3754
3755                         /* Others ignore */
3756                         else
3757                         {
3758                                 /* Irrelevant */
3759                                 skipped = TRUE;
3760                         }
3761
3762                         /* No "real" damage */
3763                         dam = 0;
3764                         break;
3765                 }
3766
3767
3768                 /* Turn evil (Use "dam" as "power") */
3769                 case GF_TURN_EVIL:
3770                 {
3771                         if (r_ptr->flagsr & RFR_RES_ALL)
3772                         {
3773                                 skipped = TRUE;
3774                                 break;
3775                         }
3776                         /* Only affect evil */
3777                         if (r_ptr->flags3 & (RF3_EVIL))
3778                         {
3779                                 /* Obvious */
3780                                 if (seen) obvious = TRUE;
3781
3782                                 /* Learn about type */
3783                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
3784
3785                                 /* Apply some fear */
3786                                 do_fear = damroll(3, (dam / 2)) + 1;
3787
3788                                 /* Attempt a saving throw */
3789                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
3790                                 {
3791                                         /* No obvious effect */
3792                                         note = _("には効果がなかった。", " is unaffected.");
3793                                         obvious = FALSE;
3794                                         do_fear = 0;
3795                                 }
3796                         }
3797
3798                         /* Others ignore */
3799                         else
3800                         {
3801                                 /* Irrelevant */
3802                                 skipped = TRUE;
3803                         }
3804
3805                         /* No "real" damage */
3806                         dam = 0;
3807                         break;
3808                 }
3809
3810
3811                 /* Turn monster (Use "dam" as "power") */
3812                 case GF_TURN_ALL:
3813                 {
3814                         if (r_ptr->flagsr & RFR_RES_ALL)
3815                         {
3816                                 skipped = TRUE;
3817                                 break;
3818                         }
3819                         /* Obvious */
3820                         if (seen) obvious = TRUE;
3821
3822                         /* Apply some fear */
3823                         do_fear = damroll(3, (dam / 2)) + 1;
3824
3825                         /* Attempt a saving throw */
3826                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
3827                                 (r_ptr->flags3 & (RF3_NO_FEAR)) ||
3828                                 (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3829                         {
3830                                 /* No obvious effect */
3831                                 note = _("には効果がなかった。", " is unaffected.");
3832                                 obvious = FALSE;
3833                                 do_fear = 0;
3834                         }
3835
3836                         /* No "real" damage */
3837                         dam = 0;
3838                         break;
3839                 }
3840
3841
3842                 /* Dispel undead */
3843                 case GF_DISP_UNDEAD:
3844                 {
3845                         if (r_ptr->flagsr & RFR_RES_ALL)
3846                         {
3847                                 skipped = TRUE;
3848                                 dam = 0;
3849                                 break;
3850                         }
3851                         /* Only affect undead */
3852                         if (r_ptr->flags3 & (RF3_UNDEAD))
3853                         {
3854                                 /* Obvious */
3855                                 if (seen) obvious = TRUE;
3856
3857                                 /* Learn about type */
3858                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
3859
3860                                 note = _("は身震いした。", " shudders.");
3861                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3862                         }
3863
3864                         /* Others ignore */
3865                         else
3866                         {
3867                                 /* Irrelevant */
3868                                 skipped = TRUE;
3869
3870                                 /* No damage */
3871                                 dam = 0;
3872                         }
3873
3874                         break;
3875                 }
3876
3877
3878                 /* Dispel evil */
3879                 case GF_DISP_EVIL:
3880                 {
3881                         if (r_ptr->flagsr & RFR_RES_ALL)
3882                         {
3883                                 skipped = TRUE;
3884                                 dam = 0;
3885                                 break;
3886                         }
3887                         /* Only affect evil */
3888                         if (r_ptr->flags3 & (RF3_EVIL))
3889                         {
3890                                 /* Obvious */
3891                                 if (seen) obvious = TRUE;
3892
3893                                 /* Learn about type */
3894                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
3895
3896                                 note = _("は身震いした。", " shudders.");
3897                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3898                         }
3899
3900                         /* Others ignore */
3901                         else
3902                         {
3903                                 /* Irrelevant */
3904                                 skipped = TRUE;
3905
3906                                 /* No damage */
3907                                 dam = 0;
3908                         }
3909
3910                         break;
3911                 }
3912
3913                 /* Dispel good */
3914                 case GF_DISP_GOOD:
3915                 {
3916                         if (r_ptr->flagsr & RFR_RES_ALL)
3917                         {
3918                                 skipped = TRUE;
3919                                 dam = 0;
3920                                 break;
3921                         }
3922                         /* Only affect good */
3923                         if (r_ptr->flags3 & (RF3_GOOD))
3924                         {
3925                                 /* Obvious */
3926                                 if (seen) obvious = TRUE;
3927
3928                                 /* Learn about type */
3929                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
3930
3931                                 note = _("は身震いした。", " shudders.");
3932                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3933                         }
3934
3935                         /* Others ignore */
3936                         else
3937                         {
3938                                 /* Irrelevant */
3939                                 skipped = TRUE;
3940
3941                                 /* No damage */
3942                                 dam = 0;
3943                         }
3944
3945                         break;
3946                 }
3947
3948                 /* Dispel living */
3949                 case GF_DISP_LIVING:
3950                 {
3951                         if (r_ptr->flagsr & RFR_RES_ALL)
3952                         {
3953                                 skipped = TRUE;
3954                                 dam = 0;
3955                                 break;
3956                         }
3957                         /* Only affect non-undead */
3958                         if (monster_living(r_ptr))
3959                         {
3960                                 /* Obvious */
3961                                 if (seen) obvious = TRUE;
3962
3963                                 note = _("は身震いした。", " shudders.");
3964                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
3965                         }
3966
3967                         /* Others ignore */
3968                         else
3969                         {
3970                                 /* Irrelevant */
3971                                 skipped = TRUE;
3972
3973                                 /* No damage */
3974                                 dam = 0;
3975                         }
3976
3977                         break;
3978                 }
3979
3980                 /* Dispel demons */
3981                 case GF_DISP_DEMON:
3982                 {
3983                         if (r_ptr->flagsr & RFR_RES_ALL)
3984                         {
3985                                 skipped = TRUE;
3986                                 dam = 0;
3987                                 break;
3988                         }
3989                         /* Only affect demons */
3990                         if (r_ptr->flags3 & (RF3_DEMON))
3991                         {
3992                                 /* Obvious */
3993                                 if (seen) obvious = TRUE;
3994
3995                                 /* Learn about type */
3996                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
3997
3998                                 note = _("は身震いした。", " shudders.");
3999                                 note_dies = _("はドロドロに溶けた!", " dissolves!");
4000                         }
4001
4002                         /* Others ignore */
4003                         else
4004                         {
4005                                 /* Irrelevant */
4006                                 skipped = TRUE;
4007
4008                                 /* No damage */
4009                                 dam = 0;
4010                         }
4011
4012                         break;
4013                 }
4014
4015                 /* Dispel monster */
4016                 case GF_DISP_ALL:
4017                 {
4018                         if (r_ptr->flagsr & RFR_RES_ALL)
4019                         {
4020                                 skipped = TRUE;
4021                                 dam = 0;
4022                                 break;
4023                         }
4024                         /* Obvious */
4025                         if (seen) obvious = TRUE;
4026
4027                         note = _("は身震いした。", " shudders.");
4028                         note_dies = _("はドロドロに溶けた!", " dissolves!");
4029                         break;
4030                 }
4031
4032                 /* Drain mana */
4033                 case GF_DRAIN_MANA:
4034                 {
4035                         if (seen) obvious = TRUE;
4036
4037                         if (r_ptr->flagsr & RFR_RES_ALL)
4038                         {
4039                                 note = _("には完全な耐性がある!", " is immune.");
4040                                 skipped = TRUE;
4041                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4042                                 break;
4043                         }
4044
4045                         if ((r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) || (r_ptr->a_ability_flags1 & ~(RF5_NOMAGIC_MASK)) || (r_ptr->a_ability_flags2 & ~(RF6_NOMAGIC_MASK)))
4046                         {
4047                                 if (who > 0)
4048                                 {
4049                                         /* Heal the monster */
4050                                         if (caster_ptr->hp < caster_ptr->maxhp)
4051                                         {
4052                                                 /* Heal */
4053                                                 caster_ptr->hp += dam;
4054                                                 if (caster_ptr->hp > caster_ptr->maxhp) caster_ptr->hp = caster_ptr->maxhp;
4055
4056                                                 /* Redraw (later) if needed */
4057                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
4058                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
4059
4060                                                 /* Special message */
4061                                                 if (see_s_msg)
4062                                                 {
4063                                                         /* Get the monster name */
4064                                                         monster_desc(killer, caster_ptr, 0);
4065                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), killer);
4066                                                 }
4067                                         }
4068                                 }
4069                                 else
4070                                 {
4071                                         msg_format(_("%sから精神エネルギーを吸いとった。", "You draw psychic energy from %s."), m_name);
4072                                         (void)hp_player(dam);
4073                                 }
4074                         }
4075                         else
4076                         {
4077                                 if (see_s_msg) msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
4078                         }
4079                         dam = 0;
4080                         break;
4081                 }
4082
4083                 /* Mind blast */
4084                 case GF_MIND_BLAST:
4085                 {
4086                         if (seen) obvious = TRUE;
4087                         if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
4088
4089                         if (r_ptr->flagsr & RFR_RES_ALL)
4090                         {
4091                                 note = _("には完全な耐性がある!", " is immune.");
4092                                 skipped = TRUE;
4093                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4094                                 break;
4095                         }
4096
4097                         /* Attempt a saving throw */
4098                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
4099                                  (r_ptr->flags3 & RF3_NO_CONF) ||
4100                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
4101                         {
4102                                 /* Memorize a flag */
4103                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4104                                 {
4105                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
4106                                 }
4107                                 note = _("には効果がなかった。", " is unaffected.");
4108                                 dam = 0;
4109                         }
4110                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
4111                         {
4112                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4113                                 note = _("には完全な耐性がある!", " is immune.");
4114                                 dam = 0;
4115                         }
4116                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
4117                         {
4118                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
4119                                 note = _("には耐性がある。", " resists.");
4120                                 dam /= 3;
4121                         }
4122                         else
4123                         {
4124                                 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
4125                                 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
4126
4127                                 if (who > 0) do_conf = randint0(4) + 4;
4128                                 else do_conf = randint0(8) + 8;
4129                         }
4130                         break;
4131                 }
4132
4133                 /* Brain smash */
4134                 case GF_BRAIN_SMASH:
4135                 {
4136                         if (seen) obvious = TRUE;
4137                         if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
4138
4139                         if (r_ptr->flagsr & RFR_RES_ALL)
4140                         {
4141                                 note = _("には完全な耐性がある!", " is immune.");
4142                                 skipped = TRUE;
4143                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4144                                 break;
4145                         }
4146
4147                         /* Attempt a saving throw */
4148                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
4149                                  (r_ptr->flags3 & RF3_NO_CONF) ||
4150                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
4151                         {
4152                                 /* Memorize a flag */
4153                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4154                                 {
4155                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
4156                                 }
4157                                 note = _("には効果がなかった。", " is unaffected.");
4158                                 dam = 0;
4159                         }
4160                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
4161                         {
4162                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4163                                 note = _("には完全な耐性がある!", " is immune.");
4164                                 dam = 0;
4165                         }
4166                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
4167                         {
4168                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
4169                                 note = _("には耐性がある!", " resists!");
4170                                 dam /= 3;
4171                         }
4172                         else
4173                         {
4174                                 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
4175                                 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
4176
4177                                 if (who > 0)
4178                                 {
4179                                         do_conf = randint0(4) + 4;
4180                                         do_stun = randint0(4) + 4;
4181                                 }
4182                                 else
4183                                 {
4184                                         do_conf = randint0(8) + 8;
4185                                         do_stun = randint0(8) + 8;
4186                                 }
4187                                 (void)set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 10);
4188                         }
4189                         break;
4190                 }
4191
4192                 /* CAUSE_1 */
4193                 case GF_CAUSE_1:
4194                 {
4195                         if (seen) obvious = TRUE;
4196                         if (!who) msg_format(_("%sを指差して呪いをかけた。", "You point at %s and curse."), m_name);
4197
4198                         if (r_ptr->flagsr & RFR_RES_ALL)
4199                         {
4200                                 note = _("には完全な耐性がある!", " is immune.");
4201                                 skipped = TRUE;
4202                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4203                                 break;
4204                         }
4205
4206                         /* Attempt a saving throw */
4207                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
4208                         {
4209                                 note = _("には効果がなかった。", " is unaffected.");
4210                                 dam = 0;
4211                         }
4212                         break;
4213                 }
4214
4215                 /* CAUSE_2 */
4216                 case GF_CAUSE_2:
4217                 {
4218                         if (seen) obvious = TRUE;
4219                         if (!who) msg_format(_("%sを指差して恐ろしげに呪いをかけた。", "You point at %s and curse horribly."), m_name);
4220
4221                         if (r_ptr->flagsr & RFR_RES_ALL)
4222                         {
4223                                 note = _("には完全な耐性がある!", " is immune.");
4224                                 skipped = TRUE;
4225                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4226                                 break;
4227                         }
4228
4229                         /* Attempt a saving throw */
4230                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
4231                         {
4232                                 note = _("には効果がなかった。", " is unaffected.");
4233                                 dam = 0;
4234                         }
4235                         break;
4236                 }
4237
4238                 /* CAUSE_3 */
4239                 case GF_CAUSE_3:
4240                 {
4241                         if (seen) obvious = TRUE;
4242                         if (!who) msg_format(_("%sを指差し、恐ろしげに呪文を唱えた!", "You point at %s, incanting terribly!"), m_name);
4243
4244                         if (r_ptr->flagsr & RFR_RES_ALL)
4245                         {
4246                                 note = _("には完全な耐性がある!", " is immune.");
4247                                 skipped = TRUE;
4248                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4249                                 break;
4250                         }
4251
4252                         /* Attempt a saving throw */
4253                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
4254                         {
4255                                 note = _("には効果がなかった。", " is unaffected.");
4256                                 dam = 0;
4257                         }
4258                         break;
4259                 }
4260
4261                 /* CAUSE_4 */
4262                 case GF_CAUSE_4:
4263                 {
4264                         if (seen) obvious = TRUE;
4265                         if (!who) 
4266                                 msg_format(_("%sの秘孔を突いて、「お前は既に死んでいる」と叫んだ。", 
4267                                                          "You point at %s, screaming the word, 'DIE!'."), m_name);
4268
4269                         if (r_ptr->flagsr & RFR_RES_ALL)
4270                         {
4271                                 note = _("には完全な耐性がある!", " is immune.");
4272                                 skipped = TRUE;
4273                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4274                                 break;
4275                         }
4276
4277                         /* Attempt a saving throw */
4278                         if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (caster_ptr->r_idx != MON_KENSHIROU)))
4279                         {
4280                                 note = _("には効果がなかった。", " is unaffected.");
4281                                 dam = 0;
4282                         }
4283                         break;
4284                 }
4285
4286                 /* HAND_DOOM */
4287                 case GF_HAND_DOOM:
4288                 {
4289                         if (seen) obvious = TRUE;
4290
4291                         if (r_ptr->flagsr & RFR_RES_ALL)
4292                         {
4293                                 note = _("には完全な耐性がある!", " is immune.");
4294                                 skipped = TRUE;
4295                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4296                                 break;
4297                         }
4298
4299                         if (r_ptr->flags1 & RF1_UNIQUE)
4300                         {
4301                                 note = _("には効果がなかった。", " is unaffected.");
4302                                 dam = 0;
4303                         }
4304                         else
4305                         {
4306                                 if ((who > 0) ? ((caster_lev + randint1(dam)) > (r_ptr->level + 10 + randint1(20))) :
4307                                    (((caster_lev / 2) + randint1(dam)) > (r_ptr->level + randint1(200))))
4308                                 {
4309                                         dam = ((40 + randint1(20)) * m_ptr->hp) / 100;
4310
4311                                         if (m_ptr->hp < dam) dam = m_ptr->hp - 1;
4312                                 }
4313                                 else
4314                                 {
4315                                         note = _("は耐性を持っている!", "resists!");
4316                                         dam = 0;
4317                                 }
4318                         }
4319                         break;
4320                 }
4321
4322                 /* Capture monster */
4323                 case GF_CAPTURE:
4324                 {
4325                         int nokori_hp;
4326                         if ((p_ptr->inside_quest && (quest[p_ptr->inside_quest].type == QUEST_TYPE_KILL_ALL) && !is_pet(m_ptr)) ||
4327                                 (r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_NAZGUL)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (r_ptr->flags1 & RF1_QUESTOR) || m_ptr->parent_m_idx)
4328                         {
4329                                 msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
4330                                 skipped = TRUE;
4331                                 break;
4332                         }
4333
4334                         if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
4335                         else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(r_ptr))
4336                                 nokori_hp = m_ptr->maxhp * 3 / 10;
4337                         else
4338                                 nokori_hp = m_ptr->maxhp * 3 / 20;
4339
4340                         if (m_ptr->hp >= nokori_hp)
4341                         {
4342                                 msg_format(_("もっと弱らせないと。", "You need to weaken %s more."), m_name);
4343                                 skipped = TRUE;
4344                         }
4345                         else if (m_ptr->hp < randint0(nokori_hp))
4346                         {
4347                                 if (m_ptr->mflag2 & MFLAG2_CHAMELEON) choose_new_monster(c_ptr->m_idx, FALSE, MON_CHAMELEON);
4348                                 msg_format(_("%sを捕えた!", "You capture %^s!"), m_name);
4349                                 cap_mon = m_ptr->r_idx;
4350                                 cap_mspeed = m_ptr->mspeed;
4351                                 cap_hp = m_ptr->hp;
4352                                 cap_maxhp = m_ptr->max_maxhp;
4353                                 cap_nickname = m_ptr->nickname; /* Quark transfer */
4354                                 if (c_ptr->m_idx == p_ptr->riding)
4355                                 {
4356                                         if (rakuba(-1, FALSE))
4357                                         {
4358                                                 msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
4359                                         }
4360                                 }
4361
4362                                 delete_monster_idx(c_ptr->m_idx);
4363
4364                                 return (TRUE);
4365                         }
4366                         else
4367                         {
4368                                 msg_format(_("うまく捕まえられなかった。", "You failed to capture %s."), m_name);
4369                                 skipped = TRUE;
4370                         }
4371                         break;
4372                 }
4373
4374                 /* Attack (Use "dam" as attack type) */
4375                 case GF_ATTACK:
4376                 {
4377                         /* Return this monster's death */
4378                         return py_attack(y, x, dam);
4379                 }
4380
4381                 /* Sleep (Use "dam" as "power") */
4382                 case GF_ENGETSU:
4383                 {
4384                         int effect = 0;
4385                         bool done = TRUE;
4386
4387                         if (seen) obvious = TRUE;
4388
4389                         if (r_ptr->flagsr & RFR_RES_ALL)
4390                         {
4391                                 note = _("には効果がなかった。", " is unaffected.");
4392                                 dam = 0;
4393                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4394                                 break;
4395                         }
4396                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
4397                         {
4398                                 note = _("には効果がなかった。", " is unaffected.");
4399                                 dam = 0;
4400                                 skipped = TRUE;
4401                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4402                                 break;
4403                         }
4404                         if (MON_CSLEEP(m_ptr))
4405                         {
4406                                 note = _("には効果がなかった。", " is unaffected.");
4407                                 dam = 0;
4408                                 skipped = TRUE;
4409                                 break;
4410                         }
4411
4412                         if (one_in_(5)) effect = 1;
4413                         else if (one_in_(4)) effect = 2;
4414                         else if (one_in_(3)) effect = 3;
4415                         else done = FALSE;
4416
4417                         if (effect == 1)
4418                         {
4419                                 /* Powerful monsters can resist */
4420                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4421                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4422                                 {
4423                                         note = _("には効果がなかった。", " is unaffected.");
4424                                         obvious = FALSE;
4425                                 }
4426
4427                                 /* Normal monsters slow down */
4428                                 else
4429                                 {
4430                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
4431                                         {
4432                                                 note = _("の動きが遅くなった。", " starts moving slower.");
4433                                         }
4434                                 }
4435                         }
4436
4437                         else if (effect == 2)
4438                         {
4439                                 do_stun = damroll((p_ptr->lev / 10) + 3 , (dam)) + 1;
4440
4441                                 /* Attempt a saving throw */
4442                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4443                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4444                                 {
4445                                         /* Resist */
4446                                         do_stun = 0;
4447
4448                                         /* No obvious effect */
4449                                         note = _("には効果がなかった。", " is unaffected.");
4450                                         obvious = FALSE;
4451                                 }
4452                         }
4453
4454                         else if (effect == 3)
4455                         {
4456                                 /* Attempt a saving throw */
4457                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4458                                         (r_ptr->flags3 & RF3_NO_SLEEP) ||
4459                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4460                                 {
4461                                         /* Memorize a flag */
4462                                         if (r_ptr->flags3 & RF3_NO_SLEEP)
4463                                         {
4464                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
4465                                         }
4466
4467                                         /* No obvious effect */
4468                                         note = _("には効果がなかった。", " is unaffected.");
4469                                         obvious = FALSE;
4470                                 }
4471                                 else
4472                                 {
4473                                         /* Go to sleep (much) later */
4474                                         note = _("は眠り込んでしまった!", " falls asleep!");
4475                                         do_sleep = 500;
4476                                 }
4477                         }
4478
4479                         if (!done)
4480                         {
4481                                 note = _("には効果がなかった。", " is unaffected.");
4482                         }
4483
4484                         /* No "real" damage */
4485                         dam = 0;
4486                         break;
4487                 }
4488
4489                 /* GENOCIDE */
4490                 case GF_GENOCIDE:
4491                 {
4492                         if (seen) obvious = TRUE;
4493
4494                         if (r_ptr->flagsr & RFR_RES_ALL)
4495                         {
4496                                 note = _("には効果がなかった。", " is unaffected.");
4497                                 skipped = TRUE;
4498                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4499                                 break;
4500                         }
4501
4502                         if (genocide_aux(c_ptr->m_idx, dam, !who, (r_ptr->level + 1) / 2, _("モンスター消滅", "Genocide One")))
4503                         {
4504                                 if (seen_msg) msg_format(_("%sは消滅した!", "%^s disappered!"), m_name);
4505                                 chg_virtue(V_VITALITY, -1);
4506                                 return TRUE;
4507                         }
4508
4509                         skipped = TRUE;
4510                         break;
4511                 }
4512
4513                 case GF_PHOTO:
4514                 {
4515                         if (!who) msg_format(_("%sを写真に撮った。", "You take a photograph of %s."), m_name);
4516                         /* Hurt by light */
4517                         if (r_ptr->flags3 & (RF3_HURT_LITE))
4518                         {
4519                                 /* Obvious effect */
4520                                 if (seen) obvious = TRUE;
4521
4522                                 /* Memorize the effects */
4523                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4524
4525                                 /* Special effect */
4526                                 note = _("は光に身をすくめた!", " cringes from the light!");
4527                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
4528                         }
4529
4530                         /* Normally no damage */
4531                         else
4532                         {
4533                                 /* No damage */
4534                                 dam = 0;
4535                         }
4536
4537                         photo = m_ptr->r_idx;
4538
4539                         break;
4540                 }
4541
4542
4543                 /* blood curse */
4544                 case GF_BLOOD_CURSE:
4545                 {
4546                         if (seen) obvious = TRUE;
4547
4548                         if (r_ptr->flagsr & RFR_RES_ALL)
4549                         {
4550                                 note = _("には完全な耐性がある!", " is immune.");
4551                                 dam = 0;
4552                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4553                                 break;
4554                         }
4555                         break;
4556                 }
4557
4558                 case GF_CRUSADE:
4559                 {
4560                         bool success = FALSE;
4561                         if (seen) obvious = TRUE;
4562
4563                         if ((r_ptr->flags3 & (RF3_GOOD)) && !p_ptr->inside_arena)
4564                         {
4565                                 if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 50;
4566                                 if (dam < 1) dam = 1;
4567
4568                                 /* No need to tame your pet */
4569                                 if (is_pet(m_ptr))
4570                                 {
4571                                         note = _("の動きが速くなった。", " starts moving faster.");
4572                                         (void)set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100);
4573                                         success = TRUE;
4574                                 }
4575
4576                                 /* Attempt a saving throw */
4577                                 else if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
4578                                         (r_ptr->flags1 & (RF1_UNIQUE)) ||
4579                                         (m_ptr->mflag2 & MFLAG2_NOPET) ||
4580                                         (p_ptr->cursed & TRC_AGGRAVATE) ||
4581                                          ((r_ptr->level+10) > randint1(dam)))
4582                                 {
4583                                         /* Resist */
4584                                         if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4585                                 }
4586                                 else
4587                                 {
4588                                         note = _("を支配した。", " is tamed!");
4589                                         set_pet(m_ptr);
4590                                         (void)set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100);
4591
4592                                         /* Learn about type */
4593                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
4594                                         success = TRUE;
4595                                 }
4596                         }
4597
4598                         if (!success)
4599                         {
4600                                 if (!(r_ptr->flags3 & RF3_NO_FEAR))
4601                                 {
4602                                         do_fear = randint1(90)+10;
4603                                 }
4604                                 else if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_FEAR);
4605                         }
4606
4607                         /* No "real" damage */
4608                         dam = 0;
4609                         break;
4610                 }
4611
4612                 case GF_WOUNDS:
4613                 {
4614                         if (seen) obvious = TRUE;
4615
4616                         if (r_ptr->flagsr & RFR_RES_ALL)
4617                         {
4618                                 note = _("には完全な耐性がある!", " is immune.");
4619                                 skipped = TRUE;
4620                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4621                                 break;
4622                         }
4623
4624                         /* Attempt a saving throw */
4625                         if (randint0(100 + dam) < (r_ptr->level + 50))
4626                         {
4627                                 note = _("には効果がなかった。", " is unaffected.");
4628                                 dam = 0;
4629                         }
4630                         break;
4631                 }
4632
4633                 /* Default */
4634                 default:
4635                 {
4636                         /* Irrelevant */
4637                         skipped = TRUE;
4638
4639                         /* No damage */
4640                         dam = 0;
4641
4642                         break;
4643                 }
4644         }
4645
4646
4647         /* Absolutely no effect */
4648         if (skipped) return (FALSE);
4649
4650         /* "Unique" monsters cannot be polymorphed */
4651         if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
4652
4653         /* Quest monsters cannot be polymorphed */
4654         if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
4655
4656         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_poly = FALSE;
4657
4658         /* "Unique" and "quest" monsters can only be "killed" by the player. */
4659         if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle)
4660         {
4661                 if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
4662         }
4663
4664         if (!who && slept)
4665         {
4666                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
4667                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
4668         }
4669
4670         /* Modify the damage */
4671         tmp = dam;
4672         dam = mon_damage_mod(m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
4673         if ((tmp > 0) && (dam == 0)) note = _("はダメージを受けていない。", " is unharmed.");
4674
4675         /* Check for death */
4676         if (dam > m_ptr->hp)
4677         {
4678                 /* Extract method of death */
4679                 note = note_dies;
4680         }
4681         else
4682         {
4683                 /* Sound and Impact resisters never stun */
4684                 if (do_stun &&
4685                         !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
4686                         !(r_ptr->flags3 & RF3_NO_STUN))
4687                 {
4688                         /* Obvious */
4689                         if (seen) obvious = TRUE;
4690
4691                         /* Get stunned */
4692                         if (MON_STUNNED(m_ptr))
4693                         {
4694                                 note = _("はひどくもうろうとした。", " is more dazed.");
4695                                 tmp = MON_STUNNED(m_ptr) + (do_stun / 2);
4696                         }
4697                         else
4698                         {
4699                                 note = _("はもうろうとした。", " is dazed.");
4700                                 tmp = do_stun;
4701                         }
4702
4703                         /* Apply stun */
4704                         (void)set_monster_stunned(c_ptr->m_idx, tmp);
4705
4706                         /* Get angry */
4707                         get_angry = TRUE;
4708                 }
4709
4710                 /* Confusion and Chaos resisters (and sleepers) never confuse */
4711                 if (do_conf &&
4712                          !(r_ptr->flags3 & RF3_NO_CONF) &&
4713                          !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
4714                 {
4715                         /* Obvious */
4716                         if (seen) obvious = TRUE;
4717
4718                         /* Already partially confused */
4719                         if (MON_CONFUSED(m_ptr))
4720                         {
4721                                 note = _("はさらに混乱したようだ。", " looks more confused.");
4722                                 tmp = MON_CONFUSED(m_ptr) + (do_conf / 2);
4723                         }
4724
4725                         /* Was not confused */
4726                         else
4727                         {
4728                                 note = _("は混乱したようだ。", " looks confused.");
4729                                 tmp = do_conf;
4730                         }
4731
4732                         /* Apply confusion */
4733                         (void)set_monster_confused(c_ptr->m_idx, tmp);
4734
4735                         /* Get angry */
4736                         get_angry = TRUE;
4737                 }
4738
4739                 if (do_time)
4740                 {
4741                         /* Obvious */
4742                         if (seen) obvious = TRUE;
4743
4744                         if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp - 1;
4745
4746                         if (do_time)
4747                         {
4748                                 note = _("は弱くなったようだ。", " seems weakened.");
4749                                 m_ptr->maxhp -= do_time;
4750                                 if ((m_ptr->hp - dam) > m_ptr->maxhp) dam = m_ptr->hp - m_ptr->maxhp;
4751                         }
4752                         get_angry = TRUE;
4753                 }
4754
4755                 /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
4756                 if (do_poly && (randint1(90) > r_ptr->level))
4757                 {
4758                         if (polymorph_monster(y, x))
4759                         {
4760                                 /* Obvious */
4761                                 if (seen) obvious = TRUE;
4762
4763                                 /* Monster polymorphs */
4764                                 note = _("が変身した!", " changes!");
4765
4766                                 /* Turn off the damage */
4767                                 dam = 0;
4768                         }
4769                         else
4770                         {
4771                                 /* No polymorph */
4772                                 note = _("には効果がなかった。", " is unaffected.");
4773                         }
4774
4775                         /* Hack -- Get new monster */
4776                         m_ptr = &m_list[c_ptr->m_idx];
4777
4778                         /* Hack -- Get new race */
4779                         r_ptr = &r_info[m_ptr->r_idx];
4780                 }
4781
4782                 /* Handle "teleport" */
4783                 if (do_dist)
4784                 {
4785                         /* Obvious */
4786                         if (seen) obvious = TRUE;
4787
4788                         note = _("が消え去った!", " disappears!");
4789
4790                         if (!who) chg_virtue(V_VALOUR, -1);
4791
4792                         /* Teleport */
4793                         teleport_away(c_ptr->m_idx, do_dist,
4794                                                 (!who ? TELEPORT_DEC_VALOUR : 0L) | TELEPORT_PASSIVE);
4795
4796                         /* Hack -- get new location */
4797                         y = m_ptr->fy;
4798                         x = m_ptr->fx;
4799
4800                         /* Hack -- get new grid */
4801                         c_ptr = &cave[y][x];
4802                 }
4803
4804                 /* Fear */
4805                 if (do_fear)
4806                 {
4807                         /* Set fear */
4808                         (void)set_monster_monfear(c_ptr->m_idx, MON_MONFEAR(m_ptr) + do_fear);
4809
4810                         /* Get angry */
4811                         get_angry = TRUE;
4812                 }
4813         }
4814
4815         if (typ == GF_DRAIN_MANA)
4816         {
4817                 /* Drain mana does nothing */
4818         }
4819
4820         /* If another monster did the damage, hurt the monster by hand */
4821         else if (who)
4822         {
4823                 /* Redraw (later) if needed */
4824                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
4825                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
4826
4827                 /* Wake the monster up */
4828                 (void)set_monster_csleep(c_ptr->m_idx, 0);
4829
4830                 /* Hurt the monster */
4831                 m_ptr->hp -= dam;
4832
4833                 /* Dead monster */
4834                 if (m_ptr->hp < 0)
4835                 {
4836                         bool sad = FALSE;
4837
4838                         if (is_pet(m_ptr) && !(m_ptr->ml))
4839                                 sad = TRUE;
4840
4841                         /* Give detailed messages if destroyed */
4842                         if (known && note)
4843                         {
4844                                 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
4845                                 if (see_s_msg)
4846                                 {
4847                                         msg_format("%^s%s", m_name, note);
4848                                 }
4849                                 else
4850                                 {
4851                                         mon_fight = TRUE;
4852                                 }
4853                         }
4854
4855                         if (who > 0) monster_gain_exp(who, m_ptr->r_idx);
4856
4857                         /* Generate treasure, etc */
4858                         monster_death(c_ptr->m_idx, FALSE);
4859
4860
4861                         delete_monster_idx(c_ptr->m_idx);
4862
4863                         if (sad)
4864                         {
4865                                 msg_print(_("少し悲しい気分がした。", "You feel sad for a moment."));
4866                         }
4867                 }
4868
4869                 /* Damaged monster */
4870                 else
4871                 {
4872                         /* Give detailed messages if visible or destroyed */
4873                         if (note && seen_msg) msg_format("%^s%s", m_name, note);
4874
4875                         /* Hack -- Pain message */
4876                         else if (see_s_msg)
4877                         {
4878                                 message_pain(c_ptr->m_idx, dam);
4879                         }
4880                         else
4881                         {
4882                                 mon_fight = TRUE;
4883                         }
4884
4885                         /* Hack -- handle sleep */
4886                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4887                 }
4888         }
4889
4890         else if (heal_leper)
4891         {
4892                 if (seen_msg) msg_print(_("不潔な病人は病気が治った!", "The Mangy looking leper is healed!"));
4893
4894                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
4895                 {
4896                         char m2_name[80];
4897
4898                         monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
4899                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
4900                 }
4901
4902                 delete_monster_idx(c_ptr->m_idx);
4903         }
4904
4905         /* If the player did it, give him experience, check fear */
4906         else
4907         {
4908                 bool fear = FALSE;
4909
4910                 /* Hurt the monster, check for fear and death */
4911                 if (mon_take_hit(c_ptr->m_idx, dam, &fear, note_dies))
4912                 {
4913                         /* Dead monster */
4914                 }
4915
4916                 /* Damaged monster */
4917                 else
4918                 {
4919                         /* HACK - anger the monster before showing the sleep message */
4920                         if (do_sleep) anger_monster(m_ptr);
4921
4922                         /* Give detailed messages if visible or destroyed */
4923                         if (note && seen_msg)
4924                                 msg_format(_("%s%s", "%^s%s"), m_name, note);
4925
4926                         /* Hack -- Pain message */
4927                         else if (known && (dam || !do_fear))
4928                         {
4929                                 message_pain(c_ptr->m_idx, dam);
4930                         }
4931
4932                         /* Anger monsters */
4933                         if (((dam > 0) || get_angry) && !do_sleep)
4934                                 anger_monster(m_ptr);
4935
4936                         /* Take note */
4937                         if ((fear || do_fear) && seen)
4938                         {
4939                                 sound(SOUND_FLEE);
4940
4941                                 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4942                         }
4943
4944                         /* Hack -- handle sleep */
4945                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4946                 }
4947         }
4948
4949         if ((typ == GF_BLOOD_CURSE) && one_in_(4))
4950         {
4951                 int curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
4952                 int count = 0;
4953                 do
4954                 {
4955                         switch (randint1(28))
4956                         {
4957                         case 1: case 2:
4958                                 if (!count)
4959                                 {
4960                                         msg_print(_("地面が揺れた...", "The ground trembles..."));
4961                                         earthquake(ty, tx, 4 + randint0(4));
4962                                         if (!one_in_(6)) break;
4963                                 }
4964                         case 3: case 4: case 5: case 6:
4965                                 if (!count)
4966                                 {
4967                                         int extra_dam = damroll(10, 10);
4968                                         msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
4969
4970                                         project(0, 8, ty, tx, extra_dam, GF_MANA, curse_flg, -1);
4971                                         if (!one_in_(6)) break;
4972                                 }
4973                         case 7: case 8:
4974                                 if (!count)
4975                                 {
4976                                         msg_print(_("空間が歪んだ!", "Space warps about you!"));
4977
4978                                         if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
4979                                         if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
4980                                         if (!one_in_(6)) break;
4981                                 }
4982                         case 9: case 10: case 11:
4983                                 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
4984                                 project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
4985                                 if (!one_in_(6)) break;
4986                         case 12: case 13: case 14: case 15: case 16:
4987                                 aggravate_monsters(0);
4988                                 if (!one_in_(6)) break;
4989                         case 17: case 18:
4990                                 count += activate_hi_summon(ty, tx, TRUE);
4991                                 if (!one_in_(6)) break;
4992                         case 19: case 20: case 21: case 22:
4993                         {
4994                                 bool pet = !one_in_(3);
4995                                 BIT_FLAGS mode = PM_ALLOW_GROUP;
4996
4997                                 if (pet) mode |= PM_FORCE_PET;
4998                                 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
4999
5000                                 count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev*2/3+randint1(p_ptr->lev/2) : dun_level), 0, mode);
5001                                 if (!one_in_(6)) break;
5002                         }
5003                         case 23: case 24: case 25:
5004                                 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
5005                                 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
5006
5007                                 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
5008                                 else lose_exp(p_ptr->exp / 16);
5009                                 if (!one_in_(6)) break;
5010                         case 26: case 27: case 28:
5011                         {
5012                                 int i = 0;
5013                                 if (one_in_(13))
5014                                 {
5015                                         while (i < 6)
5016                                         {
5017                                                 do
5018                                                 {
5019                                                         (void)do_dec_stat(i);
5020                                                 }
5021                                                 while (one_in_(2));
5022
5023                                                 i++;
5024                                         }
5025                                 }
5026                                 else
5027                                 {
5028                                         (void)do_dec_stat(randint0(6));
5029                                 }
5030                                 break;
5031                         }
5032                         }
5033                 }
5034                 while (one_in_(5));
5035         }
5036
5037         if (p_ptr->inside_battle)
5038         {
5039                 p_ptr->health_who = c_ptr->m_idx;
5040                 p_ptr->redraw |= (PR_HEALTH);
5041                 redraw_stuff();
5042         }
5043
5044         /* Verify this code */
5045
5046         /* Update the monster */
5047         if (m_ptr->r_idx) update_mon(c_ptr->m_idx, FALSE);
5048
5049         /* Redraw the monster grid */
5050         lite_spot(y, x);
5051
5052
5053         /* Update monster recall window */
5054         if ((p_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
5055         {
5056                 p_ptr->window |= (PW_MONSTER);
5057         }
5058
5059         if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
5060         {
5061                 if (!who)
5062                 {
5063                         if (!(flg & PROJECT_NO_HANGEKI))
5064                         {
5065                                 set_target(m_ptr, monster_target_y, monster_target_x);
5066                         }
5067                 }
5068                 else if ((who > 0) && is_pet(caster_ptr) && !player_bold(m_ptr->target_y, m_ptr->target_x))
5069                 {
5070                         set_target(m_ptr, caster_ptr->fy, caster_ptr->fx);
5071                 }
5072         }
5073
5074         if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx) && (dam > 0))
5075         {
5076                 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
5077                 rakubadam_m = (dam > 200) ? 200 : dam;
5078         }
5079
5080
5081         if (photo)
5082         {
5083                 object_type *q_ptr;
5084                 object_type forge;
5085
5086                 /* Get local object */
5087                 q_ptr = &forge;
5088
5089                 /* Prepare to make a Blade of Chaos */
5090                 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
5091
5092                 q_ptr->pval = photo;
5093
5094                 /* Mark the item as fully known */
5095                 q_ptr->ident |= (IDENT_MENTAL);
5096
5097                 /* Drop it in the dungeon */
5098                 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
5099         }
5100
5101         /* Track it */
5102         project_m_n++;
5103         project_m_x = x;
5104         project_m_y = y;
5105
5106         /* Return "Anything seen?" */
5107         return (obvious);
5108 }
5109
5110 /*!
5111  * @brief 汎用的なビーム/ボルト/ボール系によるプレイヤーへの効果処理 / Helper function for "project()" below.
5112  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
5113  * @param who_name 効果を起こしたモンスターの名前
5114  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
5115  * @param y 目標Y座標 / Target y location (or location to travel "towards")
5116  * @param x 目標X座標 / Target x location (or location to travel "towards")
5117  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
5118  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
5119  * @param flg 効果フラグ
5120  * @param monspell 効果元のモンスター魔法ID
5121  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
5122  * @details
5123  * Handle a beam/bolt/ball causing damage to the player.
5124  * This routine takes a "source monster" (by index), a "distance", a default
5125  * "damage", and a "damage type".  See "project_m()" above.
5126  * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
5127  * is reduced (see "project_m()" above).  This can happen if a monster breathes
5128  * at the player and hits a wall instead.
5129  * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
5130  * to know if this is actually a ball or a bolt spell
5131  * We return "TRUE" if any "obvious" effects were observed.  XXX XXX Actually,
5132  * we just assume that the effects were obvious, for historical reasons.
5133  */
5134 static bool project_p(MONSTER_IDX who, cptr who_name, int r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
5135 {
5136         int k = 0;
5137         int rlev = 0;
5138
5139         /* Hack -- assume obvious */
5140         bool obvious = TRUE;
5141
5142         /* Player blind-ness */
5143         bool blind = (p_ptr->blind ? TRUE : FALSE);
5144
5145         /* Player needs a "description" (he is blind) */
5146         bool fuzzy = FALSE;
5147
5148         /* Source monster */
5149         monster_type *m_ptr = NULL;
5150
5151         /* Monster name (for attacks) */
5152         char m_name[80];
5153
5154         /* Monster name (for damage) */
5155         char killer[80];
5156
5157         /* Hack -- messages */
5158         cptr act = NULL;
5159
5160         int get_damage = 0;
5161
5162
5163         /* Player is not here */
5164         if (!player_bold(y, x)) return (FALSE);
5165
5166         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (p_ptr->lev*3/5+20)) && who && (who != p_ptr->riding))
5167         {
5168                 if (kawarimi(TRUE)) return FALSE;
5169         }
5170
5171         /* Player cannot hurt himself */
5172         if (!who) return (FALSE);
5173         if (who == p_ptr->riding) return (FALSE);
5174
5175         if ((p_ptr->reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
5176         {
5177                 POSITION t_y, t_x;
5178                 int max_attempts = 10;
5179                 sound(SOUND_REFLECT);
5180
5181                 if (blind) 
5182                         msg_print(_("何かが跳ね返った!", "Something bounces!"));
5183                 else if (p_ptr->special_defense & KATA_FUUJIN) 
5184                         msg_print(_("風の如く武器を振るって弾き返した!", "The attack bounces!"));
5185                 else 
5186                         msg_print(_("攻撃が跳ね返った!", "The attack bounces!"));
5187
5188
5189                 /* Choose 'new' target */
5190                 if (who > 0)
5191                 {
5192                         do
5193                         {
5194                                 t_y = m_list[who].fy - 1 + randint1(3);
5195                                 t_x = m_list[who].fx - 1 + randint1(3);
5196                                 max_attempts--;
5197                         }
5198                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(p_ptr->y, p_ptr->x, t_y, t_x));
5199
5200                         if (max_attempts < 1)
5201                         {
5202                                 t_y = m_list[who].fy;
5203                                 t_x = m_list[who].fx;
5204                         }
5205                 }
5206                 else
5207                 {
5208                         t_y = p_ptr->y - 1 + randint1(3);
5209                         t_x = p_ptr->x - 1 + randint1(3);
5210                 }
5211
5212                 project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL|PROJECT_REFLECTABLE), monspell);
5213
5214                 disturb(TRUE, TRUE);
5215                 return TRUE;
5216         }
5217
5218         /* Limit maximum damage */
5219         if (dam > 1600) dam = 1600;
5220
5221         /* Reduce damage by distance */
5222         dam = (dam + r) / (r + 1);
5223
5224
5225         /* If the player is blind, be more descriptive */
5226         if (blind) fuzzy = TRUE;
5227
5228
5229         if (who > 0)
5230         {
5231                 /* Get the source monster */
5232                 m_ptr = &m_list[who];
5233                 /* Extract the monster level */
5234                 rlev = (((&r_info[m_ptr->r_idx])->level >= 1) ? (&r_info[m_ptr->r_idx])->level : 1);
5235
5236                 /* Get the monster name */
5237                 monster_desc(m_name, m_ptr, 0);
5238
5239                 /* Get the monster's real name (gotten before polymorph!) */
5240                 strcpy(killer, who_name);
5241         }
5242         else
5243         {
5244                 switch (who)
5245                 {
5246                 case PROJECT_WHO_UNCTRL_POWER:
5247                         strcpy(killer, _("制御できない力の氾流", "uncontrollable power storm"));
5248                         break;
5249
5250                 case PROJECT_WHO_GLASS_SHARDS:
5251                         strcpy(killer, _("ガラスの破片", "shards of glass"));
5252                         break;
5253
5254                 default:
5255                         strcpy(killer, _("罠", "a trap"));
5256                         break;
5257                 }
5258
5259                 /* Paranoia */
5260                 strcpy(m_name, killer);
5261         }
5262
5263         /* Analyze the damage */
5264         switch (typ)
5265         {
5266                 /* Standard damage -- hurts inventory too */
5267                 case GF_ACID:
5268                 {
5269                         if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));                    
5270                         get_damage = acid_dam(dam, killer, monspell, FALSE);
5271                         break;
5272                 }
5273
5274                 /* Standard damage -- hurts inventory too */
5275                 case GF_FIRE:
5276                 {
5277                         if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
5278                         get_damage = fire_dam(dam, killer, monspell, FALSE);
5279                         break;
5280                 }
5281
5282                 /* Standard damage -- hurts inventory too */
5283                 case GF_COLD:
5284                 {
5285                         if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
5286                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5287                         break;
5288                 }
5289
5290                 /* Standard damage -- hurts inventory too */
5291                 case GF_ELEC:
5292                 {
5293                         if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
5294                         get_damage = elec_dam(dam, killer, monspell, FALSE);
5295                         break;
5296                 }
5297
5298                 /* Standard damage -- also poisons player */
5299                 case GF_POIS:
5300                 {
5301                         bool double_resist = IS_OPPOSE_POIS();
5302                         if (fuzzy) msg_print(_("毒で攻撃された!", "You are hit by poison!"));
5303
5304                         if (p_ptr->resist_pois) dam = (dam + 2) / 3;
5305                         if (double_resist) dam = (dam + 2) / 3;
5306
5307                         if ((!(double_resist || p_ptr->resist_pois)) &&
5308                                  one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
5309                         {
5310                                 do_dec_stat(A_CON);
5311                         }
5312
5313                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5314
5315                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
5316                         {
5317                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
5318                         }
5319                         break;
5320                 }
5321
5322                 /* Standard damage -- also poisons / mutates player */
5323                 case GF_NUKE:
5324                 {
5325                         bool double_resist = IS_OPPOSE_POIS();
5326                         if (fuzzy) msg_print(_("放射能で攻撃された!", "You are hit by radiation!"));
5327
5328                         if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
5329                         if (double_resist) dam = (2 * dam + 2) / 5;
5330                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5331                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
5332                         {
5333                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
5334
5335                                 if (one_in_(5)) /* 6 */
5336                                 {
5337                                         msg_print(_("奇形的な変身を遂げた!", "You undergo a freakish metamorphosis!"));
5338                                         if (one_in_(4)) /* 4 */
5339                                                 do_poly_self();
5340                                         else
5341                                                 mutate_player();
5342                                 }
5343
5344                                 if (one_in_(6))
5345                                 {
5346                                         inven_damage(set_acid_destroy, 2);
5347                                 }
5348                         }
5349                         break;
5350                 }
5351
5352                 /* Standard damage */
5353                 case GF_MISSILE:
5354                 {
5355                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5356                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5357                         break;
5358                 }
5359
5360                 /* Holy Orb -- Player only takes partial damage */
5361                 case GF_HOLY_FIRE:
5362                 {
5363                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5364                         if (p_ptr->align > 10)
5365                                 dam /= 2;
5366                         else if (p_ptr->align < -10)
5367                                 dam *= 2;
5368                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5369                         break;
5370                 }
5371
5372                 case GF_HELL_FIRE:
5373                 {
5374                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5375                         if (p_ptr->align > 10)
5376                                 dam *= 2;
5377                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5378                         break;
5379                 }
5380
5381                 /* Arrow -- XXX no dodging */
5382                 case GF_ARROW:
5383                 {
5384                         if (fuzzy)
5385                         {
5386                                 msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5387                         }
5388                         else if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
5389                         {
5390                                 msg_print(_("矢を斬り捨てた!", "You cut down the arrow!"));
5391                                 break;
5392                         }
5393                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5394                         break;
5395                 }
5396
5397                 /* Plasma -- XXX No resist */
5398                 case GF_PLASMA:
5399                 {
5400                         if (fuzzy) msg_print(_("何かとても熱いもので攻撃された!", "You are hit by something *HOT*!"));
5401                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5402
5403                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5404                         {
5405                                 int plus_stun = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
5406                                 (void)set_stun(p_ptr->stun + plus_stun);
5407                         }
5408
5409                         if (!(p_ptr->resist_fire ||
5410                                 IS_OPPOSE_FIRE() ||
5411                                 p_ptr->immune_fire))
5412                         {
5413                                 inven_damage(set_acid_destroy, 3);
5414                         }
5415
5416                         break;
5417                 }
5418
5419                 /* Nether -- drain experience */
5420                 case GF_NETHER:
5421                 {
5422                         if (fuzzy) msg_print(_("地獄の力で攻撃された!", "You are hit by nether forces!"));
5423                         if (p_ptr->resist_neth)
5424                         {
5425                                 if (!prace_is_(RACE_SPECTRE))
5426                                 {
5427                                         dam *= 6; dam /= (randint1(4) + 7);
5428                                 }
5429                         }
5430                         else if (!CHECK_MULTISHADOW()) drain_exp(200 + (p_ptr->exp / 100), 200 + (p_ptr->exp / 1000), 75);
5431
5432                         if (prace_is_(RACE_SPECTRE) && !CHECK_MULTISHADOW())
5433                         {
5434                                 msg_print(_("気分がよくなった。", "You feel invigorated!"));
5435                                 hp_player(dam / 4);
5436                                 learn_spell(monspell);
5437                         }
5438                         else
5439                         {
5440                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5441                         }
5442
5443                         break;
5444                 }
5445
5446                 /* Water -- stun/confuse */
5447                 case GF_WATER:
5448                 {
5449                         if (fuzzy) msg_print(_("何か湿ったもので攻撃された!", "You are hit by something wet!"));
5450                         if (!CHECK_MULTISHADOW())
5451                         {
5452                                 if (!p_ptr->resist_sound)
5453                                 {
5454                                         set_stun(p_ptr->stun + randint1(40));
5455                                 }
5456                                 if (!p_ptr->resist_conf)
5457                                 {
5458                                         set_confused(p_ptr->confused + randint1(5) + 5);
5459                                 }
5460
5461                                 if (one_in_(5))
5462                                 {
5463                                         inven_damage(set_cold_destroy, 3);
5464                                 }
5465                         }
5466
5467                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5468                         break;
5469                 }
5470
5471                 /* Chaos -- many effects */
5472                 case GF_CHAOS:
5473                 {
5474                         if (fuzzy) msg_print(_("無秩序の波動で攻撃された!", "You are hit by a wave of anarchy!"));
5475                         if (p_ptr->resist_chaos)
5476                         {
5477                                 dam *= 6; dam /= (randint1(4) + 7);
5478                         }
5479
5480                         if (!CHECK_MULTISHADOW())
5481                         {
5482                                 if (!p_ptr->resist_conf)
5483                                 {
5484                                         (void)set_confused(p_ptr->confused + randint0(20) + 10);
5485                                 }
5486                                 if (!p_ptr->resist_chaos)
5487                                 {
5488                                         (void)set_image(p_ptr->image + randint1(10));
5489                                         if (one_in_(3))
5490                                         {
5491                                                 msg_print(_("あなたの身体はカオスの力で捻じ曲げられた!", "Your body is twisted by chaos!"));
5492                                                 (void)gain_random_mutation(0);
5493                                         }
5494                                 }
5495                                 if (!p_ptr->resist_neth && !p_ptr->resist_chaos)
5496                                 {
5497                                         drain_exp(5000 + (p_ptr->exp / 100), 500 + (p_ptr->exp / 1000), 75);
5498                                 }
5499
5500                                 if (!p_ptr->resist_chaos || one_in_(9))
5501                                 {
5502                                         inven_damage(set_elec_destroy, 2);
5503                                         inven_damage(set_fire_destroy, 2);
5504                                 }
5505                         }
5506
5507                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5508                         break;
5509                 }
5510
5511                 /* Shards -- mostly cutting */
5512                 case GF_SHARDS:
5513                 {
5514                         if (fuzzy) msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5515                         if (p_ptr->resist_shard)
5516                         {
5517                                 dam *= 6; dam /= (randint1(4) + 7);
5518                         }
5519                         else if (!CHECK_MULTISHADOW())
5520                         {
5521                                 (void)set_cut(p_ptr->cut + dam);
5522                         }
5523
5524                         if (!p_ptr->resist_shard || one_in_(13))
5525                         {
5526                                 inven_damage(set_cold_destroy, 2);
5527                         }
5528
5529                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5530                         break;
5531                 }
5532
5533                 /* Sound -- mostly stunning */
5534                 case GF_SOUND:
5535                 {
5536                         if (fuzzy) msg_print(_("轟音で攻撃された!", "You are hit by a loud noise!"));
5537                         if (p_ptr->resist_sound)
5538                         {
5539                                 dam *= 5; dam /= (randint1(4) + 7);
5540                         }
5541                         else if (!CHECK_MULTISHADOW())
5542                         {
5543                                 int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5544                                 (void)set_stun(p_ptr->stun + plus_stun);
5545                         }
5546
5547                         if (!p_ptr->resist_sound || one_in_(13))
5548                         {
5549                                 inven_damage(set_cold_destroy, 2);
5550                         }
5551
5552                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5553                         break;
5554                 }
5555
5556                 /* Pure confusion */
5557                 case GF_CONFUSION:
5558                 {
5559                         if (fuzzy) msg_print(_("何か混乱するもので攻撃された!", "You are hit by something puzzling!"));
5560                         if (p_ptr->resist_conf)
5561                         {
5562                                 dam *= 5; dam /= (randint1(4) + 7);
5563                         }
5564                         else if (!CHECK_MULTISHADOW())
5565                         {
5566                                 (void)set_confused(p_ptr->confused + randint1(20) + 10);
5567                         }
5568                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5569                         break;
5570                 }
5571
5572                 /* Disenchantment -- see above */
5573                 case GF_DISENCHANT:
5574                 {
5575                         if (fuzzy) msg_print(_("何かさえないもので攻撃された!", "You are hit by something static!"));
5576                         if (p_ptr->resist_disen)
5577                         {
5578                                 dam *= 6; dam /= (randint1(4) + 7);
5579                         }
5580                         else if (!CHECK_MULTISHADOW())
5581                         {
5582                                 (void)apply_disenchant(0);
5583                         }
5584                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5585                         break;
5586                 }
5587
5588                 /* Nexus -- see above */
5589                 case GF_NEXUS:
5590                 {
5591                         if (fuzzy) msg_print(_("何か奇妙なもので攻撃された!", "You are hit by something strange!"));
5592                         if (p_ptr->resist_nexus)
5593                         {
5594                                 dam *= 6; dam /= (randint1(4) + 7);
5595                         }
5596                         else if (!CHECK_MULTISHADOW())
5597                         {
5598                                 apply_nexus(m_ptr);
5599                         }
5600                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5601                         break;
5602                 }
5603
5604                 /* Force -- mostly stun */
5605                 case GF_FORCE:
5606                 {
5607                         if (fuzzy) msg_print(_("運動エネルギーで攻撃された!", "You are hit by kinetic force!"));
5608                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5609                         {
5610                                 (void)set_stun(p_ptr->stun + randint1(20));
5611                         }
5612                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5613                         break;
5614                 }
5615
5616
5617                 /* Rocket -- stun, cut */
5618                 case GF_ROCKET:
5619                 {
5620                         if (fuzzy) msg_print(_("爆発があった!", "There is an explosion!"));
5621                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5622                         {
5623                                 (void)set_stun(p_ptr->stun + randint1(20));
5624                         }
5625
5626                         if (p_ptr->resist_shard)
5627                         {
5628                                 dam /= 2;
5629                         }
5630                         else if (!CHECK_MULTISHADOW())
5631                         {
5632                                 (void)set_cut(p_ptr->cut + (dam / 2));
5633                         }
5634
5635                         if (!p_ptr->resist_shard || one_in_(12))
5636                         {
5637                                 inven_damage(set_cold_destroy, 3);
5638                         }
5639
5640                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5641                         break;
5642                 }
5643
5644                 /* Inertia -- slowness */
5645                 case GF_INERTIAL:
5646                 {
5647                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5648                         if (!CHECK_MULTISHADOW()) (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5649                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5650                         break;
5651                 }
5652
5653                 /* Lite -- blinding */
5654                 case GF_LITE:
5655                 {
5656                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5657                         if (p_ptr->resist_lite)
5658                         {
5659                                 dam *= 4; dam /= (randint1(4) + 7);
5660                         }
5661                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5662                         {
5663                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5664                         }
5665
5666                         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
5667                         {
5668                                 if (!CHECK_MULTISHADOW()) msg_print(_("光で肉体が焦がされた!", "The light scorches your flesh!"));
5669                                 dam *= 2;
5670                         }
5671                         else if (prace_is_(RACE_S_FAIRY))
5672                         {
5673                                 dam = dam * 4 / 3;
5674                         }
5675
5676                         if (p_ptr->wraith_form) dam *= 2;
5677                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5678
5679                         if (p_ptr->wraith_form && !CHECK_MULTISHADOW())
5680                         {
5681                                 p_ptr->wraith_form = 0;
5682                                 msg_print(_("閃光のため非物質的な影の存在でいられなくなった。",
5683                                         "The light forces you out of your incorporeal shadow form."));
5684
5685                                 p_ptr->redraw |= PR_MAP;
5686                                 /* Update monsters */
5687                                 p_ptr->update |= (PU_MONSTERS);
5688                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5689
5690                                 /* Redraw status bar */
5691                                 p_ptr->redraw |= (PR_STATUS);
5692
5693                         }
5694
5695                         break;
5696                 }
5697
5698                 /* Dark -- blinding */
5699                 case GF_DARK:
5700                 {
5701                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5702                         if (p_ptr->resist_dark)
5703                         {
5704                                 dam *= 4; dam /= (randint1(4) + 7);
5705
5706                                 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
5707                         }
5708                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5709                         {
5710                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5711                         }
5712                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5713                         break;
5714                 }
5715
5716                 /* Time -- bolt fewer effects XXX */
5717                 case GF_TIME:
5718                 {
5719                         if (fuzzy) msg_print(_("過去からの衝撃に攻撃された!", "You are hit by a blast from the past!"));
5720                         if (p_ptr->resist_time)
5721                         {
5722                                 dam *= 4;
5723                                 dam /= (randint1(4) + 7);
5724                                 msg_print(_("時間が通り過ぎていく気がする。", "You feel as if time is passing you by."));
5725                         }
5726                         else if (!CHECK_MULTISHADOW())
5727                         {
5728                                 switch (randint1(10))
5729                                 {
5730                                         case 1: case 2: case 3: case 4: case 5:
5731                                         {
5732                                                 if (p_ptr->prace == RACE_ANDROID) break;
5733                                                 msg_print(_("人生が逆戻りした気がする。", "You feel life has clocked back."));
5734                                                 lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
5735                                                 break;
5736                                         }
5737
5738                                         case 6: case 7: case 8: case 9:
5739                                         {
5740                                                 switch (randint1(6))
5741                                                 {
5742                                                         case 1: k = A_STR; act = _("強く", "strong"); break;
5743                                                         case 2: k = A_INT; act = _("聡明で", "bright"); break;
5744                                                         case 3: k = A_WIS; act = _("賢明で", "wise"); break;
5745                                                         case 4: k = A_DEX; act = _("器用で", "agile"); break;
5746                                                         case 5: k = A_CON; act = _("健康で", "hale"); break;
5747                                                         case 6: k = A_CHR; act = _("美しく", "beautiful"); break;
5748                                                 }
5749
5750                                                 msg_format(_("あなたは以前ほど%sなくなってしまった...。", 
5751                                                                          "You're not as %s as you used to be..."), act);
5752
5753                                                 p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
5754                                                 if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5755                                                 p_ptr->update |= (PU_BONUS);
5756                                                 break;
5757                                         }
5758
5759                                         case 10:
5760                                         {
5761                                                 msg_print(_("あなたは以前ほど力強くなくなってしまった...。", 
5762                                                                         "You're not as powerful as you used to be..."));
5763
5764                                                 for (k = 0; k < 6; k++)
5765                                                 {
5766                                                         p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
5767                                                         if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5768                                                 }
5769                                                 p_ptr->update |= (PU_BONUS);
5770                                                 break;
5771                                         }
5772                                 }
5773                         }
5774
5775                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5776                         break;
5777                 }
5778
5779                 /* Gravity -- stun plus slowness plus teleport */
5780                 case GF_GRAVITY:
5781                 {
5782                         if (fuzzy) msg_print(_("何か重いもので攻撃された!", "You are hit by something heavy!"));
5783                                 msg_print(_("周辺の重力がゆがんだ。", "Gravity warps around you."));
5784
5785                         if (!CHECK_MULTISHADOW())
5786                         {
5787                                 teleport_player(5, TELEPORT_PASSIVE);
5788                                 if (!p_ptr->levitation)
5789                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5790                                 if (!(p_ptr->resist_sound || p_ptr->levitation))
5791                                 {
5792                                         int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5793                                         (void)set_stun(p_ptr->stun + plus_stun);
5794                                 }
5795                         }
5796                         if (p_ptr->levitation)
5797                         {
5798                                 dam = (dam * 2) / 3;
5799                         }
5800
5801                         if (!p_ptr->levitation || one_in_(13))
5802                         {
5803                                 inven_damage(set_cold_destroy, 2);
5804                         }
5805
5806                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5807                         break;
5808                 }
5809
5810                 /* Standard damage */
5811                 case GF_DISINTEGRATE:
5812                 {
5813                         if (fuzzy) msg_print(_("純粋なエネルギーで攻撃された!", "You are hit by pure energy!"));
5814
5815                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5816                         break;
5817                 }
5818
5819                 case GF_OLD_HEAL:
5820                 {
5821                         if (fuzzy) msg_print(_("何らかの攻撃によって気分がよくなった。", "You are hit by something invigorating!"));
5822
5823                         (void)hp_player(dam);
5824                         dam = 0;
5825                         break;
5826                 }
5827
5828                 case GF_OLD_SPEED:
5829                 {
5830                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5831                         (void)set_fast(p_ptr->fast + randint1(5), FALSE);
5832                         dam = 0;
5833                         break;
5834                 }
5835
5836                 case GF_OLD_SLOW:
5837                 {
5838                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5839                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5840                         break;
5841                 }
5842
5843                 case GF_OLD_SLEEP:
5844                 {
5845                         if (p_ptr->free_act)  break;
5846                         if (fuzzy) msg_print(_("眠ってしまった!", "You fall asleep!"));
5847
5848                         if (ironman_nightmare)
5849                         {
5850                                 msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
5851                                 /* Have some nightmares */
5852                                 sanity_blast(NULL, FALSE);
5853                         }
5854
5855                         set_paralyzed(p_ptr->paralyzed + dam);
5856                         dam = 0;
5857                         break;
5858                 }
5859
5860                 /* Pure damage */
5861                 case GF_MANA:
5862                 case GF_SEEKER:
5863                 case GF_SUPER_RAY:
5864                 {
5865                         if (fuzzy) msg_print(_("魔法のオーラで攻撃された!", "You are hit by an aura of magic!"));
5866                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5867                         break;
5868                 }
5869
5870                 /* Pure damage */
5871                 case GF_PSY_SPEAR:
5872                 {
5873                         if (fuzzy) msg_print(_("エネルギーの塊で攻撃された!", "You are hit by an energy!"));
5874                         get_damage = take_hit(DAMAGE_FORCE, dam, killer, monspell);
5875                         break;
5876                 }
5877
5878                 /* Pure damage */
5879                 case GF_METEOR:
5880                 {
5881                         if (fuzzy) msg_print(_("何かが空からあなたの頭上に落ちてきた!", "Something falls from the sky on you!"));
5882
5883                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5884                         if (!p_ptr->resist_shard || one_in_(13))
5885                         {
5886                                 if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
5887                                 inven_damage(set_cold_destroy, 2);
5888                         }
5889
5890                         break;
5891                 }
5892
5893                 /* Ice -- cold plus stun plus cuts */
5894                 case GF_ICE:
5895                 {
5896                         if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
5897                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5898                         if (!CHECK_MULTISHADOW())
5899                         {
5900                                 if (!p_ptr->resist_shard)
5901                                 {
5902                                         (void)set_cut(p_ptr->cut + damroll(5, 8));
5903                                 }
5904                                 if (!p_ptr->resist_sound)
5905                                 {
5906                                         (void)set_stun(p_ptr->stun + randint1(15));
5907                                 }
5908
5909                                 if ((!(p_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
5910                                 {
5911                                         if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
5912                                 }
5913                         }
5914
5915                         break;
5916                 }
5917
5918                 /* Death Ray */
5919                 case GF_DEATH_RAY:
5920                 {
5921                         if (fuzzy) msg_print(_("何か非常に冷たいもので攻撃された!", "You are hit by something extremely cold!"));
5922
5923                         if (p_ptr->mimic_form)
5924                         {
5925                                 if (!(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
5926                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5927                         }
5928                         else
5929                         {
5930
5931                         switch (p_ptr->prace)
5932                         {
5933                                 /* Some races are immune */
5934                                 case RACE_GOLEM:
5935                                 case RACE_SKELETON:
5936                                 case RACE_ZOMBIE:
5937                                 case RACE_VAMPIRE:
5938                                 case RACE_DEMON:
5939                                 case RACE_SPECTRE:
5940                                 {
5941                                         dam = 0;
5942                                         break;
5943                                 }
5944                                 /* Hurt a lot */
5945                                 default:
5946                                 {
5947                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5948                                         break;
5949                                 }
5950                         }
5951                         }
5952
5953                         break;
5954                 }
5955
5956                 /* Drain mana */
5957                 case GF_DRAIN_MANA:
5958                 {
5959                         if (CHECK_MULTISHADOW())
5960                         {
5961                                 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, you are unharmed!"));
5962                         }
5963                         else if (p_ptr->csp)
5964                         {
5965                                 /* Basic message */
5966                                 if (who > 0) 
5967                                         msg_format(_("%^sに精神エネルギーを吸い取られてしまった!", "%^s draws psychic energy from you!"), m_name);
5968                                 else 
5969                                         msg_print(_("精神エネルギーを吸い取られてしまった!", "Your psychic energy is drawn!"));
5970
5971                                 /* Full drain */
5972                                 if (dam >= p_ptr->csp)
5973                                 {
5974                                         dam = p_ptr->csp;
5975                                         p_ptr->csp = 0;
5976                                         p_ptr->csp_frac = 0;
5977                                 }
5978
5979                                 /* Partial drain */
5980                                 else
5981                                 {
5982                                         p_ptr->csp -= dam;
5983                                 }
5984
5985                                 learn_spell(monspell);
5986
5987                                 /* Redraw mana */
5988                                 p_ptr->redraw |= (PR_MANA);
5989
5990                                 p_ptr->window |= (PW_PLAYER);
5991                                 p_ptr->window |= (PW_SPELL);
5992
5993                                 if (who > 0)
5994                                 {
5995                                         /* Heal the monster */
5996                                         if (m_ptr->hp < m_ptr->maxhp)
5997                                         {
5998                                                 /* Heal */
5999                                                 m_ptr->hp += dam;
6000                                                 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
6001
6002                                                 /* Redraw (later) if needed */
6003                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
6004                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
6005
6006                                                 /* Special message */
6007                                                 if (m_ptr->ml)
6008                                                 {
6009                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), m_name);
6010                                                 }
6011                                         }
6012                                 }
6013                         }
6014
6015                         dam = 0;
6016                         break;
6017                 }
6018
6019                 /* Mind blast */
6020                 case GF_MIND_BLAST:
6021                 {
6022                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
6023                         {
6024                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6025                                 learn_spell(monspell);
6026                         }
6027                         else
6028                         {
6029                                 if (!CHECK_MULTISHADOW())
6030                                 {
6031                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
6032
6033                                         if (!p_ptr->resist_conf)
6034                                         {
6035                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
6036                                         }
6037
6038                                         if (!p_ptr->resist_chaos && one_in_(3))
6039                                         {
6040                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
6041                                         }
6042
6043                                         p_ptr->csp -= 50;
6044                                         if (p_ptr->csp < 0)
6045                                         {
6046                                                 p_ptr->csp = 0;
6047                                                 p_ptr->csp_frac = 0;
6048                                         }
6049                                         p_ptr->redraw |= PR_MANA;
6050                                 }
6051
6052                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6053                         }
6054                         break;
6055                 }
6056
6057                 /* Brain smash */
6058                 case GF_BRAIN_SMASH:
6059                 {
6060                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
6061                         {
6062                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6063                                 learn_spell(monspell);
6064                         }
6065                         else
6066                         {
6067                                 if (!CHECK_MULTISHADOW())
6068                                 {
6069                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
6070
6071                                         p_ptr->csp -= 100;
6072                                         if (p_ptr->csp < 0)
6073                                         {
6074                                                 p_ptr->csp = 0;
6075                                                 p_ptr->csp_frac = 0;
6076                                         }
6077                                         p_ptr->redraw |= PR_MANA;
6078                                 }
6079
6080                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6081                                 if (!CHECK_MULTISHADOW())
6082                                 {
6083                                         if (!p_ptr->resist_blind)
6084                                         {
6085                                                 (void)set_blind(p_ptr->blind + 8 + randint0(8));
6086                                         }
6087                                         if (!p_ptr->resist_conf)
6088                                         {
6089                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
6090                                         }
6091                                         if (!p_ptr->free_act)
6092                                         {
6093                                                 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
6094                                         }
6095                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
6096
6097                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
6098                                                 (void)do_dec_stat(A_INT);
6099                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
6100                                                 (void)do_dec_stat(A_WIS);
6101
6102                                         if (!p_ptr->resist_chaos)
6103                                         {
6104                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
6105                                         }
6106                                 }
6107                         }
6108                         break;
6109                 }
6110
6111                 /* cause 1 */
6112                 case GF_CAUSE_1:
6113                 {
6114                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6115                         {
6116                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6117                                 learn_spell(monspell);
6118                         }
6119                         else
6120                         {
6121                                 if (!CHECK_MULTISHADOW()) curse_equipment(15, 0);
6122                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6123                         }
6124                         break;
6125                 }
6126
6127                 /* cause 2 */
6128                 case GF_CAUSE_2:
6129                 {
6130                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6131                         {
6132                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6133                                 learn_spell(monspell);
6134                         }
6135                         else
6136                         {
6137                                 if (!CHECK_MULTISHADOW()) curse_equipment(25, MIN(rlev / 2 - 15, 5));
6138                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6139                         }
6140                         break;
6141                 }
6142
6143                 /* cause 3 */
6144                 case GF_CAUSE_3:
6145                 {
6146                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6147                         {
6148                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6149                                 learn_spell(monspell);
6150                         }
6151                         else
6152                         {
6153                                 if (!CHECK_MULTISHADOW()) curse_equipment(33, MIN(rlev / 2 - 15, 15));
6154                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6155                         }
6156                         break;
6157                 }
6158
6159                 /* cause 4 */
6160                 case GF_CAUSE_4:
6161                 {
6162                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU) && !CHECK_MULTISHADOW())
6163                         {
6164                                 msg_print(_("しかし秘孔を跳ね返した!", "You resist the effects!"));
6165                                 learn_spell(monspell);
6166                         }
6167                         else
6168                         {
6169                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6170                                 if (!CHECK_MULTISHADOW()) (void)set_cut(p_ptr->cut + damroll(10, 10));
6171                         }
6172                         break;
6173                 }
6174
6175                 /* Hand of Doom */
6176                 case GF_HAND_DOOM:
6177                 {
6178                         if ((randint0(100 + rlev/2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6179                         {
6180                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6181                                 learn_spell(monspell);
6182                         }
6183                         else
6184                         {
6185                                 if (!CHECK_MULTISHADOW())
6186                                 {
6187                                         msg_print(_("あなたは命が薄まっていくように感じた!", "You feel your life fade away!"));
6188                                         curse_equipment(40, 20);
6189                                 }
6190
6191                                 get_damage = take_hit(DAMAGE_ATTACK, dam, m_name, monspell);
6192
6193                                 if (p_ptr->chp < 1) p_ptr->chp = 1; /* Paranoia */
6194                         }
6195                         break;
6196                 }
6197
6198                 /* Default */
6199                 default:
6200                 {
6201                         /* No damage */
6202                         dam = 0;
6203
6204                         break;
6205                 }
6206         }
6207
6208         /* Hex - revenge damage stored */
6209         revenge_store(get_damage);
6210
6211         if ((p_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
6212                 && (get_damage > 0) && !p_ptr->is_dead && (who > 0))
6213         {
6214                 char m_name_self[80];
6215
6216                 /* hisself */
6217                 monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
6218
6219                 msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
6220                 project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
6221                 if (p_ptr->tim_eyeeye) set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
6222         }
6223
6224         if (p_ptr->riding && dam > 0)
6225         {
6226                 rakubadam_p = (dam > 200) ? 200 : dam;
6227         }
6228
6229
6230         disturb(TRUE, TRUE);
6231
6232
6233         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
6234         {
6235                 (void)kawarimi(FALSE);
6236         }
6237
6238         /* Return "Anything seen?" */
6239         return (obvious);
6240 }
6241
6242
6243 /*
6244  * Find the distance from (x, y) to a line.
6245  */
6246 POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
6247 {
6248         /* Vector from (x, y) to (x1, y1) */
6249         POSITION py = y1 - y;
6250         POSITION px = x1 - x;
6251
6252         /* Normal vector */
6253         POSITION ny = x2 - x1;
6254         POSITION nx = y1 - y2;
6255
6256         /* Length of N */
6257         POSITION pd = distance(y1, x1, y, x);
6258         POSITION nd = distance(y1, x1, y2, x2);
6259
6260         if (pd > nd) return distance(y, x, y2, x2);
6261
6262         /* Component of P on N */
6263         nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
6264
6265         /* Absolute value */
6266         return((nd >= 0) ? nd : 0 - nd);
6267 }
6268
6269
6270
6271 /*
6272  * 
6273  * Modified version of los() for calculation of disintegration balls.
6274  * Disintegration effects are stopped by permanent walls.
6275  */
6276 bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
6277 {
6278         /* Delta */
6279         POSITION dx, dy;
6280
6281         /* Absolute */
6282         POSITION ax, ay;
6283
6284         /* Signs */
6285         POSITION sx, sy;
6286
6287         /* Fractions */
6288         POSITION qx, qy;
6289
6290         /* Scanners */
6291         POSITION tx, ty;
6292
6293         /* Scale factors */
6294         POSITION f1, f2;
6295
6296         /* Slope, or 1/Slope, of LOS */
6297         POSITION m;
6298
6299
6300         /* Extract the offset */
6301         dy = y2 - y1;
6302         dx = x2 - x1;
6303
6304         /* Extract the absolute offset */
6305         ay = ABS(dy);
6306         ax = ABS(dx);
6307
6308
6309         /* Handle adjacent (or identical) grids */
6310         if ((ax < 2) && (ay < 2)) return (TRUE);
6311
6312
6313         /* Paranoia -- require "safe" origin */
6314         /* if (!in_bounds(y1, x1)) return (FALSE); */
6315
6316
6317         /* Directly South/North */
6318         if (!dx)
6319         {
6320                 /* South -- check for walls */
6321                 if (dy > 0)
6322                 {
6323                         for (ty = y1 + 1; ty < y2; ty++)
6324                         {
6325                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
6326                         }
6327                 }
6328
6329                 /* North -- check for walls */
6330                 else
6331                 {
6332                         for (ty = y1 - 1; ty > y2; ty--)
6333                         {
6334                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
6335                         }
6336                 }
6337
6338                 /* Assume los */
6339                 return (TRUE);
6340         }
6341
6342         /* Directly East/West */
6343         if (!dy)
6344         {
6345                 /* East -- check for walls */
6346                 if (dx > 0)
6347                 {
6348                         for (tx = x1 + 1; tx < x2; tx++)
6349                         {
6350                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
6351                         }
6352                 }
6353
6354                 /* West -- check for walls */
6355                 else
6356                 {
6357                         for (tx = x1 - 1; tx > x2; tx--)
6358                         {
6359                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
6360                         }
6361                 }
6362
6363                 /* Assume los */
6364                 return (TRUE);
6365         }
6366
6367
6368         /* Extract some signs */
6369         sx = (dx < 0) ? -1 : 1;
6370         sy = (dy < 0) ? -1 : 1;
6371
6372
6373         /* Vertical "knights" */
6374         if (ax == 1)
6375         {
6376                 if (ay == 2)
6377                 {
6378                         if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
6379                 }
6380         }
6381
6382         /* Horizontal "knights" */
6383         else if (ay == 1)
6384         {
6385                 if (ax == 2)
6386                 {
6387                         if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
6388                 }
6389         }
6390
6391
6392         /* Calculate scale factor div 2 */
6393         f2 = (ax * ay);
6394
6395         /* Calculate scale factor */
6396         f1 = f2 << 1;
6397
6398
6399         /* Travel horizontally */
6400         if (ax >= ay)
6401         {
6402                 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
6403                 qy = ay * ay;
6404                 m = qy << 1;
6405
6406                 tx = x1 + sx;
6407
6408                 /* Consider the special case where slope == 1. */
6409                 if (qy == f2)
6410                 {
6411                         ty = y1 + sy;
6412                         qy -= f1;
6413                 }
6414                 else
6415                 {
6416                         ty = y1;
6417                 }
6418
6419                 /* Note (below) the case (qy == f2), where */
6420                 /* the LOS exactly meets the corner of a tile. */
6421                 while (x2 - tx)
6422                 {
6423                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6424
6425                         qy += m;
6426
6427                         if (qy < f2)
6428                         {
6429                                 tx += sx;
6430                         }
6431                         else if (qy > f2)
6432                         {
6433                                 ty += sy;
6434                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6435                                 qy -= f1;
6436                                 tx += sx;
6437                         }
6438                         else
6439                         {
6440                                 ty += sy;
6441                                 qy -= f1;
6442                                 tx += sx;
6443                         }
6444                 }
6445         }
6446
6447         /* Travel vertically */
6448         else
6449         {
6450                 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
6451                 qx = ax * ax;
6452                 m = qx << 1;
6453
6454                 ty = y1 + sy;
6455
6456                 if (qx == f2)
6457                 {
6458                         tx = x1 + sx;
6459                         qx -= f1;
6460                 }
6461                 else
6462                 {
6463                         tx = x1;
6464                 }
6465
6466                 /* Note (below) the case (qx == f2), where */
6467                 /* the LOS exactly meets the corner of a tile. */
6468                 while (y2 - ty)
6469                 {
6470                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6471
6472                         qx += m;
6473
6474                         if (qx < f2)
6475                         {
6476                                 ty += sy;
6477                         }
6478                         else if (qx > f2)
6479                         {
6480                                 tx += sx;
6481                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6482                                 qx -= f1;
6483                                 ty += sy;
6484                         }
6485                         else
6486                         {
6487                                 tx += sx;
6488                                 qx -= f1;
6489                                 ty += sy;
6490                         }
6491                 }
6492         }
6493
6494         /* Assume los */
6495         return (TRUE);
6496 }
6497
6498
6499 /*
6500  * breath shape
6501  */
6502 void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, EFFECT_ID typ)
6503 {
6504         POSITION by = y1;
6505         POSITION bx = x1;
6506         int brad = 0;
6507         int brev = rad * rad / dist;
6508         int bdis = 0;
6509         int cdis;
6510         int path_n = 0;
6511         int mdis = distance(y1, x1, y2, x2) + rad;
6512
6513         while (bdis <= mdis)
6514         {
6515                 POSITION x, y;
6516
6517                 if ((0 < dist) && (path_n < dist))
6518                 {
6519                         POSITION ny = GRID_Y(path_g[path_n]);
6520                         POSITION nx = GRID_X(path_g[path_n]);
6521                         POSITION nd = distance(ny, nx, y1, x1);
6522
6523                         /* Get next base point */
6524                         if (bdis >= nd)
6525                         {
6526                                 by = ny;
6527                                 bx = nx;
6528                                 path_n++;
6529                         }
6530                 }
6531
6532                 /* Travel from center outward */
6533                 for (cdis = 0; cdis <= brad; cdis++)
6534                 {
6535                         /* Scan the maximal blast area of radius "cdis" */
6536                         for (y = by - cdis; y <= by + cdis; y++)
6537                         {
6538                                 for (x = bx - cdis; x <= bx + cdis; x++)
6539                                 {
6540                                         /* Ignore "illegal" locations */
6541                                         if (!in_bounds(y, x)) continue;
6542
6543                                         /* Enforce a circular "ripple" */
6544                                         if (distance(y1, x1, y, x) != bdis) continue;
6545
6546                                         /* Enforce an arc */
6547                                         if (distance(by, bx, y, x) != cdis) continue;
6548
6549                                         switch (typ)
6550                                         {
6551                                         case GF_LITE:
6552                                         case GF_LITE_WEAK:
6553                                                 /* Lights are stopped by opaque terrains */
6554                                                 if (!los(by, bx, y, x)) continue;
6555                                                 break;
6556                                         case GF_DISINTEGRATE:
6557                                                 /* Disintegration are stopped only by perma-walls */
6558                                                 if (!in_disintegration_range(by, bx, y, x)) continue;
6559                                                 break;
6560                                         default:
6561                                                 /* Ball explosions are stopped by walls */
6562                                                 if (!projectable(by, bx, y, x)) continue;
6563                                                 break;
6564                                         }
6565
6566                                         /* Save this grid */
6567                                         gy[*pgrids] = y;
6568                                         gx[*pgrids] = x;
6569                                         (*pgrids)++;
6570                                 }
6571                         }
6572                 }
6573
6574                 /* Encode some more "radius" info */
6575                 gm[bdis + 1] = *pgrids;
6576
6577                 /* Increase the size */
6578                 brad = rad * (path_n + brev) / (dist + brev);
6579
6580                 /* Find the next ripple */
6581                 bdis++;
6582         }
6583
6584         /* Store the effect size */
6585         *pgm_rad = bdis;
6586 }
6587
6588
6589 /*!
6590  * @brief 汎用的なビーム/ボルト/ボール系処理のルーチン Generic "beam"/"bolt"/"ball" projection routine.
6591  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
6592  * @param rad 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
6593  * @param y 目標Y座標 / Target y location (or location to travel "towards")
6594  * @param x 目標X座標 / Target x location (or location to travel "towards")
6595  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
6596  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
6597  * @param flg 効果フラグ / Extra bit flags (see PROJECT_xxxx in "defines.h")
6598  * @param monspell 効果元のモンスター魔法ID
6599  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
6600  * @details
6601  * <pre>
6602  * Allows a monster (or player) to project a beam/bolt/ball of a given kind
6603  * towards a given location (optionally passing over the heads of interposing
6604  * monsters), and have it do a given amount of damage to the monsters (and
6605  * optionally objects) within the given radius of the final location.
6606  *
6607  * A "bolt" travels from source to target and affects only the target grid.
6608  * A "beam" travels from source to target, affecting all grids passed through.
6609  * A "ball" travels from source to the target, exploding at the target, and
6610  *   affecting everything within the given radius of the target location.
6611  *
6612  * Traditionally, a "bolt" does not affect anything on the ground, and does
6613  * not pass over the heads of interposing monsters, much like a traditional
6614  * missile, and will "stop" abruptly at the "target" even if no monster is
6615  * positioned there, while a "ball", on the other hand, passes over the heads
6616  * of monsters between the source and target, and affects everything except
6617  * the source monster which lies within the final radius, while a "beam"
6618  * affects every monster between the source and target, except for the casting
6619  * monster (or player), and rarely affects things on the ground.
6620  *
6621  * Two special flags allow us to use this function in special ways, the
6622  * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
6623  * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
6624  * actually projecting from the source monster (or player).
6625  *
6626  * The player will only get "experience" for monsters killed by himself
6627  * Unique monsters can only be destroyed by attacks from the player
6628  *
6629  * Only 256 grids can be affected per projection, limiting the effective
6630  * "radius" of standard ball attacks to nine units (diameter nineteen).
6631  *
6632  * One can project in a given "direction" by combining PROJECT_THRU with small
6633  * offsets to the initial location (see "line_spell()"), or by calculating
6634  * "virtual targets" far away from the player.
6635  *
6636  * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
6637  * continuing until it actually hits somethings (useful for "stone to mud").
6638  *
6639  * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
6640  *
6641  * Balls must explode BEFORE hitting walls, or they would affect monsters
6642  * on both sides of a wall.  Some bug reports indicate that this is still
6643  * happening in 2.7.8 for Windows, though it appears to be impossible.
6644  *
6645  * We "pre-calculate" the blast area only in part for efficiency.
6646  * More importantly, this lets us do "explosions" from the "inside" out.
6647  * This results in a more logical distribution of "blast" treasure.
6648  * It also produces a better (in my opinion) animation of the explosion.
6649  * It could be (but is not) used to have the treasure dropped by monsters
6650  * in the middle of the explosion fall "outwards", and then be damaged by
6651  * the blast as it spreads outwards towards the treasure drop location.
6652  *
6653  * Walls and doors are included in the blast area, so that they can be
6654  * "burned" or "melted" in later versions.
6655  *
6656  * This algorithm is intended to maximize simplicity, not necessarily
6657  * efficiency, since this function is not a bottleneck in the code.
6658  *
6659  * We apply the blast effect from ground zero outwards, in several passes,
6660  * first affecting features, then objects, then monsters, then the player.
6661  * This allows walls to be removed before checking the object or monster
6662  * in the wall, and protects objects which are dropped by monsters killed
6663  * in the blast, and allows the player to see all affects before he is
6664  * killed or teleported away.  The semantics of this method are open to
6665  * various interpretations, but they seem to work well in practice.
6666  *
6667  * We process the blast area from ground-zero outwards to allow for better
6668  * distribution of treasure dropped by monsters, and because it provides a
6669  * pleasing visual effect at low cost.
6670  *
6671  * Note that the damage done by "ball" explosions decreases with distance.
6672  * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
6673  *
6674  * Notice the "napalm" effect of "beam" weapons.  First they "project" to
6675  * the target, and then the damage "flows" along this beam of destruction.
6676  * The damage at every grid is the same as at the "center" of a "ball"
6677  * explosion, since the "beam" grids are treated as if they ARE at the
6678  * center of a "ball" explosion.
6679  *
6680  * Currently, specifying "beam" plus "ball" means that locations which are
6681  * covered by the initial "beam", and also covered by the final "ball", except
6682  * for the final grid (the epicenter of the ball), will be "hit twice", once
6683  * by the initial beam, and once by the exploding ball.  For the grid right
6684  * next to the epicenter, this results in 150% damage being done.  The center
6685  * does not have this problem, for the same reason the final grid in a "beam"
6686  * plus "bolt" does not -- it is explicitly removed.  Simply removing "beam"
6687  * grids which are covered by the "ball" will NOT work, as then they will
6688  * receive LESS damage than they should.  Do not combine "beam" with "ball".
6689  *
6690  * The array "gy[],gx[]" with current size "grids" is used to hold the
6691  * collected locations of all grids in the "blast area" plus "beam path".
6692  *
6693  * Note the rather complex usage of the "gm[]" array.  First, gm[0] is always
6694  * zero.  Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
6695  * first blast grid (see above) with radius "N" from the blast center.  Note
6696  * that only the first gm[1] grids in the blast area thus take full damage.
6697  * Also, note that gm[rad+1] is always equal to "grids", which is the total
6698  * number of blast grids.
6699  *
6700  * Note that once the projection is complete, (y2,x2) holds the final location
6701  * of bolts/beams, and the "epicenter" of balls.
6702  *
6703  * Note also that "rad" specifies the "inclusive" radius of projection blast,
6704  * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
6705  * implementation of the "distance" function.  Also, a bolt can be properly
6706  * viewed as a "ball" with a "rad" of "zero".
6707  *
6708  * Note that if no "target" is reached before the beam/bolt/ball travels the
6709  * maximum distance allowed (MAX_RANGE), no "blast" will be induced.  This
6710  * may be relevant even for bolts, since they have a "1x1" mini-blast.
6711  *
6712  * Note that for consistency, we "pretend" that the bolt actually takes "time"
6713  * to move from point A to point B, even if the player cannot see part of the
6714  * projection path.  Note that in general, the player will *always* see part
6715  * of the path, since it either starts at the player or ends on the player.
6716  *
6717  * Hack -- we assume that every "projection" is "self-illuminating".
6718  *
6719  * Hack -- when only a single monster is affected, we automatically track
6720  * (and recall) that monster, unless "PROJECT_JUMP" is used.
6721  *
6722  * Note that all projections now "explode" at their final destination, even
6723  * if they were being projected at a more distant destination.  This means
6724  * that "ball" spells will *always* explode.
6725  *
6726  * Note that we must call "handle_stuff()" after affecting terrain features
6727  * in the blast radius, in case the "illumination" of the grid was changed,
6728  * and "update_view()" and "update_monsters()" need to be called.
6729  * </pre>
6730  */
6731 bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
6732 {
6733         int i, t, dist;
6734
6735         POSITION y1, x1;
6736         POSITION y2, x2;
6737         POSITION by, bx;
6738
6739         int dist_hack = 0;
6740
6741         POSITION y_saver, x_saver; /* For reflecting monsters */
6742
6743         int msec = delay_factor * delay_factor * delay_factor;
6744
6745         /* Assume the player sees nothing */
6746         bool notice = FALSE;
6747
6748         /* Assume the player has seen nothing */
6749         bool visual = FALSE;
6750
6751         /* Assume the player has seen no blast grids */
6752         bool drawn = FALSE;
6753
6754         /* Assume to be a normal ball spell */
6755         bool breath = FALSE;
6756
6757         /* Is the player blind? */
6758         bool blind = (p_ptr->blind ? TRUE : FALSE);
6759
6760         bool old_hide = FALSE;
6761
6762         /* Number of grids in the "path" */
6763         int path_n = 0;
6764
6765         /* Actual grids in the "path" */
6766         u16b path_g[512];
6767
6768         /* Number of grids in the "blast area" (including the "beam" path) */
6769         int grids = 0;
6770
6771         /* Coordinates of the affected grids */
6772         POSITION gx[1024], gy[1024];
6773
6774         /* Encoded "radius" info (see above) */
6775         POSITION gm[32];
6776
6777         /* Actual radius encoded in gm[] */
6778         POSITION gm_rad = rad;
6779
6780         bool jump = FALSE;
6781
6782         /* Attacker's name (prepared before polymorph)*/
6783         char who_name[80];
6784
6785         /* Can the player see the source of this effect? */
6786         bool see_s_msg = TRUE;
6787
6788         /* Initialize by null string */
6789         who_name[0] = '\0';
6790
6791         rakubadam_p = 0;
6792         rakubadam_m = 0;
6793
6794         /* Default target of monsterspell is player */
6795         monster_target_y = p_ptr->y;
6796         monster_target_x = p_ptr->x;
6797
6798         /* Hack -- Jump to target */
6799         if (flg & (PROJECT_JUMP))
6800         {
6801                 x1 = x;
6802                 y1 = y;
6803
6804                 /* Clear the flag */
6805                 flg &= ~(PROJECT_JUMP);
6806
6807                 jump = TRUE;
6808         }
6809
6810         /* Start at player */
6811         else if (who <= 0)
6812         {
6813                 x1 = p_ptr->x;
6814                 y1 = p_ptr->y;
6815         }
6816
6817         /* Start at monster */
6818         else if (who > 0)
6819         {
6820                 x1 = m_list[who].fx;
6821                 y1 = m_list[who].fy;
6822                 monster_desc(who_name, &m_list[who], MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
6823         }
6824
6825         else
6826         {
6827                 x1 = x;
6828                 y1 = y;
6829         }
6830
6831         y_saver = y1;
6832         x_saver = x1;
6833
6834         /* Default "destination" */
6835         y2 = y;
6836         x2 = x;
6837
6838
6839         /* Hack -- verify stuff */
6840         if (flg & (PROJECT_THRU))
6841         {
6842                 if ((x1 == x2) && (y1 == y2))
6843                 {
6844                         flg &= ~(PROJECT_THRU);
6845                 }
6846         }
6847
6848         /* Handle a breath attack */
6849         if (rad < 0)
6850         {
6851                 rad = 0 - rad;
6852                 breath = TRUE;
6853                 if (flg & PROJECT_HIDE) old_hide = TRUE;
6854                 flg |= PROJECT_HIDE;
6855         }
6856
6857
6858         /* Hack -- Assume there will be no blast (max radius 32) */
6859         for (dist = 0; dist < 32; dist++) gm[dist] = 0;
6860
6861
6862         /* Initial grid */
6863         y = y1;
6864         x = x1;
6865         dist = 0;
6866
6867         /* Collect beam grids */
6868         if (flg & (PROJECT_BEAM))
6869         {
6870                 gy[grids] = y;
6871                 gx[grids] = x;
6872                 grids++;
6873         }
6874
6875         switch (typ)
6876         {
6877         case GF_LITE:
6878         case GF_LITE_WEAK:
6879                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_LOS);
6880                 break;
6881         case GF_DISINTEGRATE:
6882                 flg |= (PROJECT_GRID);
6883                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_DISI);
6884                 break;
6885         }
6886
6887         /* Calculate the projection path */
6888
6889         path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
6890
6891         /* Hack -- Handle stuff */
6892         handle_stuff();
6893
6894         /* Giga-Hack SEEKER & SUPER_RAY */
6895
6896         if( typ == GF_SEEKER )
6897         {
6898                 int j;
6899                 int last_i=0;
6900
6901                 /* Mega-Hack */
6902                 project_m_n = 0;
6903                 project_m_x = 0;
6904                 project_m_y = 0;
6905
6906                 for (i = 0; i < path_n; ++i)
6907                 {
6908                         int oy = y;
6909                         int ox = x;
6910
6911                         int ny = GRID_Y(path_g[i]);
6912                         int nx = GRID_X(path_g[i]);
6913
6914                         /* Advance */
6915                         y = ny;
6916                         x = nx;
6917
6918                         gy[grids] = y;
6919                         gx[grids] = x;
6920                         grids++;
6921
6922
6923                         /* Only do visuals if requested */
6924                         if (!blind && !(flg & (PROJECT_HIDE)))
6925                         {
6926                                 /* Only do visuals if the player can "see" the bolt */
6927                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6928                                 {
6929                                         u16b p;
6930
6931                                         byte a;
6932                                         char c;
6933
6934                                         /* Obtain the bolt pict */
6935                                         p = bolt_pict(oy, ox, y, x, typ);
6936
6937                                         /* Extract attr/char */
6938                                         a = PICT_A(p);
6939                                         c = PICT_C(p);
6940
6941                                         /* Visual effects */
6942                                         print_rel(c, a, y, x);
6943                                         move_cursor_relative(y, x);
6944                                         /*if (fresh_before)*/ Term_fresh();
6945                                         Term_xtra(TERM_XTRA_DELAY, msec);
6946                                         lite_spot(y, x);
6947                                         /*if (fresh_before)*/ Term_fresh();
6948
6949                                         /* Display "beam" grids */
6950                                         if (flg & (PROJECT_BEAM))
6951                                         {
6952                                                 /* Obtain the explosion pict */
6953                                                 p = bolt_pict(y, x, y, x, typ);
6954
6955                                                 /* Extract attr/char */
6956                                                 a = PICT_A(p);
6957                                                 c = PICT_C(p);
6958
6959                                                 /* Visual effects */
6960                                                 print_rel(c, a, y, x);
6961                                         }
6962
6963                                         /* Hack -- Activate delay */
6964                                         visual = TRUE;
6965                                 }
6966
6967                                 /* Hack -- delay anyway for consistency */
6968                                 else if (visual)
6969                                 {
6970                                         /* Delay for consistency */
6971                                         Term_xtra(TERM_XTRA_DELAY, msec);
6972                                 }
6973                         }
6974                         if(project_o(0,0,y,x,dam,GF_SEEKER))notice=TRUE;
6975                         if( is_mirror_grid(&cave[y][x]))
6976                         {
6977                           /* The target of monsterspell becomes tha mirror(broken) */
6978                                 monster_target_y=(s16b)y;
6979                                 monster_target_x=(s16b)x;
6980
6981                                 remove_mirror(y, x);
6982                                 next_mirror(&oy, &ox, y, x);
6983
6984                                 path_n = i+project_path(&(path_g[i+1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
6985                                 for(j = last_i; j <= i; j++)
6986                                 {
6987                                         y = GRID_Y(path_g[j]);
6988                                         x = GRID_X(path_g[j]);
6989                                         if(project_m(0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice=TRUE;
6990                                         if(!who && (project_m_n==1) && !jump ){
6991                                           if(cave[project_m_y][project_m_x].m_idx >0 ){
6992                                                 monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
6993
6994                                                 if (m_ptr->ml)
6995                                                 {
6996                                                   /* Hack -- auto-recall */
6997                                                   if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
6998
6999                                                   /* Hack - auto-track */
7000                                                   health_track(cave[project_m_y][project_m_x].m_idx);
7001                                                 }
7002                                           }
7003                                         }
7004                                         (void)project_f(0,0,y,x,dam,GF_SEEKER);
7005                                 }
7006                                 last_i = i;
7007                         }
7008                 }
7009                 for(i = last_i ; i < path_n ; i++)
7010                 {
7011                         int py, px;
7012                         py = GRID_Y(path_g[i]);
7013                         px = GRID_X(path_g[i]);
7014                         if(project_m(0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
7015                                 notice = TRUE;
7016                         if(!who && (project_m_n==1) && !jump ){
7017                                 if(cave[project_m_y][project_m_x].m_idx > 0)
7018                                 {
7019                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
7020
7021                                         if (m_ptr->ml)
7022                                         {
7023                                                 /* Hack -- auto-recall */
7024                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7025
7026                                                 /* Hack - auto-track */
7027                                                 health_track(cave[project_m_y][project_m_x].m_idx);
7028                                         }
7029                                 }
7030                         }
7031                         (void)project_f(0, 0, py, px, dam, GF_SEEKER);
7032                 }
7033                 return notice;
7034         }
7035         else if(typ == GF_SUPER_RAY){
7036                 int j;
7037                 int second_step = 0;
7038
7039                 /* Mega-Hack */
7040                 project_m_n = 0;
7041                 project_m_x = 0;
7042                 project_m_y = 0;
7043
7044                 for (i = 0; i < path_n; ++i)
7045                 {
7046                         int oy = y;
7047                         int ox = x;
7048
7049                         int ny = GRID_Y(path_g[i]);
7050                         int nx = GRID_X(path_g[i]);
7051
7052                         /* Advance */
7053                         y = ny;
7054                         x = nx;
7055
7056                         gy[grids] = y;
7057                         gx[grids] = x;
7058                         grids++;
7059
7060
7061                         /* Only do visuals if requested */
7062                         if (!blind && !(flg & (PROJECT_HIDE)))
7063                         {
7064                                 /* Only do visuals if the player can "see" the bolt */
7065                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7066                                 {
7067                                         u16b p;
7068
7069                                         byte a;
7070                                         char c;
7071
7072                                         /* Obtain the bolt pict */
7073                                         p = bolt_pict(oy, ox, y, x, typ);
7074
7075                                         /* Extract attr/char */
7076                                         a = PICT_A(p);
7077                                         c = PICT_C(p);
7078
7079                                         /* Visual effects */
7080                                         print_rel(c, a, y, x);
7081                                         move_cursor_relative(y, x);
7082                                         /*if (fresh_before)*/ Term_fresh();
7083                                         Term_xtra(TERM_XTRA_DELAY, msec);
7084                                         lite_spot(y, x);
7085                                         /*if (fresh_before)*/ Term_fresh();
7086
7087                                         /* Display "beam" grids */
7088                                         if (flg & (PROJECT_BEAM))
7089                                         {
7090                                                 /* Obtain the explosion pict */
7091                                                 p = bolt_pict(y, x, y, x, typ);
7092
7093                                                 /* Extract attr/char */
7094                                                 a = PICT_A(p);
7095                                                 c = PICT_C(p);
7096
7097                                                 /* Visual effects */
7098                                                 print_rel(c, a, y, x);
7099                                         }
7100
7101                                         /* Hack -- Activate delay */
7102                                         visual = TRUE;
7103                                 }
7104
7105                                 /* Hack -- delay anyway for consistency */
7106                                 else if (visual)
7107                                 {
7108                                         /* Delay for consistency */
7109                                         Term_xtra(TERM_XTRA_DELAY, msec);
7110                                 }
7111                         }
7112                         if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
7113                         if (!cave_have_flag_bold(y, x, FF_PROJECT))
7114                         {
7115                                 if( second_step )continue;
7116                                 break;
7117                         }
7118                         if( is_mirror_grid(&cave[y][x]) && !second_step )
7119                         {
7120                           /* The target of monsterspell becomes tha mirror(broken) */
7121                                 monster_target_y=(s16b)y;
7122                                 monster_target_x=(s16b)x;
7123
7124                                 remove_mirror(y,x);
7125                                 for( j = 0; j <=i ; j++ )
7126                                 {
7127                                         y = GRID_Y(path_g[j]);
7128                                         x = GRID_X(path_g[j]);
7129                                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
7130                                 }
7131                                 path_n = i;
7132                                 second_step =i+1;
7133                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
7134                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
7135                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
7136                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x-1, flg);
7137                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x+1, flg);
7138                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x-1, flg);
7139                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
7140                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
7141                         }
7142                 }
7143                 for( i = 0; i < path_n ; i++ )
7144                 {
7145                         int py, px;
7146                         py = GRID_Y(path_g[i]);
7147                         px = GRID_X(path_g[i]);
7148                         (void)project_m(0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
7149                         if(!who && (project_m_n == 1) && !jump){
7150                                 if(cave[project_m_y][project_m_x].m_idx >0 ){
7151                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
7152
7153                                         if (m_ptr->ml)
7154                                         {
7155                                                 /* Hack -- auto-recall */
7156                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7157
7158                                                 /* Hack - auto-track */
7159                                                 health_track(cave[project_m_y][project_m_x].m_idx);
7160                                         }
7161                                 }
7162                         }
7163                         (void)project_f(0, 0, py, px, dam, GF_SUPER_RAY);
7164                 }
7165                 return notice;
7166         }
7167
7168         /* Project along the path */
7169         for (i = 0; i < path_n; ++i)
7170         {
7171                 int oy = y;
7172                 int ox = x;
7173
7174                 int ny = GRID_Y(path_g[i]);
7175                 int nx = GRID_X(path_g[i]);
7176
7177                 if (flg & PROJECT_DISI)
7178                 {
7179                         /* Hack -- Balls explode before reaching walls */
7180                         if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
7181                 }
7182                 else if (flg & PROJECT_LOS)
7183                 {
7184                         /* Hack -- Balls explode before reaching walls */
7185                         if (!cave_los_bold(ny, nx) && (rad > 0)) break;
7186                 }
7187                 else
7188                 {
7189                         /* Hack -- Balls explode before reaching walls */
7190                         if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && (rad > 0)) break;
7191                 }
7192
7193                 /* Advance */
7194                 y = ny;
7195                 x = nx;
7196
7197                 /* Collect beam grids */
7198                 if (flg & (PROJECT_BEAM))
7199                 {
7200                         gy[grids] = y;
7201                         gx[grids] = x;
7202                         grids++;
7203                 }
7204
7205                 /* Only do visuals if requested */
7206                 if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
7207                 {
7208                         /* Only do visuals if the player can "see" the bolt */
7209                         if (panel_contains(y, x) && player_has_los_bold(y, x))
7210                         {
7211                                 u16b p;
7212
7213                                 byte a;
7214                                 char c;
7215
7216                                 /* Obtain the bolt pict */
7217                                 p = bolt_pict(oy, ox, y, x, typ);
7218
7219                                 /* Extract attr/char */
7220                                 a = PICT_A(p);
7221                                 c = PICT_C(p);
7222
7223                                 /* Visual effects */
7224                                 print_rel(c, a, y, x);
7225                                 move_cursor_relative(y, x);
7226                                 /*if (fresh_before)*/ Term_fresh();
7227                                 Term_xtra(TERM_XTRA_DELAY, msec);
7228                                 lite_spot(y, x);
7229                                 /*if (fresh_before)*/ Term_fresh();
7230
7231                                 /* Display "beam" grids */
7232                                 if (flg & (PROJECT_BEAM))
7233                                 {
7234                                         /* Obtain the explosion pict */
7235                                         p = bolt_pict(y, x, y, x, typ);
7236
7237                                         /* Extract attr/char */
7238                                         a = PICT_A(p);
7239                                         c = PICT_C(p);
7240
7241                                         /* Visual effects */
7242                                         print_rel(c, a, y, x);
7243                                 }
7244
7245                                 /* Hack -- Activate delay */
7246                                 visual = TRUE;
7247                         }
7248
7249                         /* Hack -- delay anyway for consistency */
7250                         else if (visual)
7251                         {
7252                                 /* Delay for consistency */
7253                                 Term_xtra(TERM_XTRA_DELAY, msec);
7254                         }
7255                 }
7256         }
7257
7258         path_n = i;
7259
7260         /* Save the "blast epicenter" */
7261         by = y;
7262         bx = x;
7263
7264         if (breath && !path_n)
7265         {
7266                 breath = FALSE;
7267                 gm_rad = rad;
7268                 if (!old_hide)
7269                 {
7270                         flg &= ~(PROJECT_HIDE);
7271                 }
7272         }
7273
7274         /* Start the "explosion" */
7275         gm[0] = 0;
7276
7277         /* Hack -- make sure beams get to "explode" */
7278         gm[1] = grids;
7279
7280         dist = path_n;
7281         dist_hack = dist;
7282
7283         project_length = 0;
7284
7285         /* If we found a "target", explode there */
7286         if (dist <= MAX_RANGE)
7287         {
7288                 /* Mega-Hack -- remove the final "beam" grid */
7289                 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
7290
7291                 /*
7292                  * Create a conical breath attack
7293                  *
7294                  *       ***
7295                  *   ********
7296                  * D********@**
7297                  *   ********
7298                  *       ***
7299                  */
7300
7301                 if (breath)
7302                 {
7303                         flg &= ~(PROJECT_HIDE);
7304
7305                         breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
7306                 }
7307                 else
7308                 {
7309                         /* Determine the blast area, work from the inside out */
7310                         for (dist = 0; dist <= rad; dist++)
7311                         {
7312                                 /* Scan the maximal blast area of radius "dist" */
7313                                 for (y = by - dist; y <= by + dist; y++)
7314                                 {
7315                                         for (x = bx - dist; x <= bx + dist; x++)
7316                                         {
7317                                                 /* Ignore "illegal" locations */
7318                                                 if (!in_bounds2(y, x)) continue;
7319
7320                                                 /* Enforce a "circular" explosion */
7321                                                 if (distance(by, bx, y, x) != dist) continue;
7322
7323                                                 switch (typ)
7324                                                 {
7325                                                 case GF_LITE:
7326                                                 case GF_LITE_WEAK:
7327                                                         /* Lights are stopped by opaque terrains */
7328                                                         if (!los(by, bx, y, x)) continue;
7329                                                         break;
7330                                                 case GF_DISINTEGRATE:
7331                                                         /* Disintegration are stopped only by perma-walls */
7332                                                         if (!in_disintegration_range(by, bx, y, x)) continue;
7333                                                         break;
7334                                                 default:
7335                                                         /* Ball explosions are stopped by walls */
7336                                                         if (!projectable(by, bx, y, x)) continue;
7337                                                         break;
7338                                                 }
7339
7340                                                 /* Save this grid */
7341                                                 gy[grids] = y;
7342                                                 gx[grids] = x;
7343                                                 grids++;
7344                                         }
7345                                 }
7346
7347                                 /* Encode some more "radius" info */
7348                                 gm[dist+1] = grids;
7349                         }
7350                 }
7351         }
7352
7353         /* Speed -- ignore "non-explosions" */
7354         if (!grids) return (FALSE);
7355
7356
7357         /* Display the "blast area" if requested */
7358         if (!blind && !(flg & (PROJECT_HIDE)))
7359         {
7360                 /* Then do the "blast", from inside out */
7361                 for (t = 0; t <= gm_rad; t++)
7362                 {
7363                         /* Dump everything with this radius */
7364                         for (i = gm[t]; i < gm[t+1]; i++)
7365                         {
7366                                 /* Extract the location */
7367                                 y = gy[i];
7368                                 x = gx[i];
7369
7370                                 /* Only do visuals if the player can "see" the blast */
7371                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7372                                 {
7373                                         u16b p;
7374
7375                                         byte a;
7376                                         char c;
7377
7378                                         drawn = TRUE;
7379
7380                                         /* Obtain the explosion pict */
7381                                         p = bolt_pict(y, x, y, x, typ);
7382
7383                                         /* Extract attr/char */
7384                                         a = PICT_A(p);
7385                                         c = PICT_C(p);
7386
7387                                         /* Visual effects -- Display */
7388                                         print_rel(c, a, y, x);
7389                                 }
7390                         }
7391
7392                         /* Hack -- center the cursor */
7393                         move_cursor_relative(by, bx);
7394
7395                         /* Flush each "radius" seperately */
7396                         /*if (fresh_before)*/ Term_fresh();
7397
7398                         /* Delay (efficiently) */
7399                         if (visual || drawn)
7400                         {
7401                                 Term_xtra(TERM_XTRA_DELAY, msec);
7402                         }
7403                 }
7404
7405                 /* Flush the erasing */
7406                 if (drawn)
7407                 {
7408                         /* Erase the explosion drawn above */
7409                         for (i = 0; i < grids; i++)
7410                         {
7411                                 /* Extract the location */
7412                                 y = gy[i];
7413                                 x = gx[i];
7414
7415                                 /* Hack -- Erase if needed */
7416                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7417                                 {
7418                                         lite_spot(y, x);
7419                                 }
7420                         }
7421
7422                         /* Hack -- center the cursor */
7423                         move_cursor_relative(by, bx);
7424
7425                         /* Flush the explosion */
7426                         /*if (fresh_before)*/ Term_fresh();
7427                 }
7428         }
7429
7430
7431         /* Update stuff if needed */
7432         if (p_ptr->update) update_stuff();
7433
7434
7435         if (flg & PROJECT_KILL)
7436         {
7437                 see_s_msg = (who > 0) ? is_seen(&m_list[who]) :
7438                         (!who ? TRUE : (player_can_see_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)));
7439         }
7440
7441
7442         /* Check features */
7443         if (flg & (PROJECT_GRID))
7444         {
7445                 /* Start with "dist" of zero */
7446                 dist = 0;
7447
7448                 /* Scan for features */
7449                 for (i = 0; i < grids; i++)
7450                 {
7451                         /* Hack -- Notice new "dist" values */
7452                         if (gm[dist+1] == i) dist++;
7453
7454                         /* Get the grid location */
7455                         y = gy[i];
7456                         x = gx[i];
7457
7458                         /* Find the closest point in the blast */
7459                         if (breath)
7460                         {
7461                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7462
7463                                 /* Affect the grid */
7464                                 if (project_f(who, d, y, x, dam, typ)) notice = TRUE;
7465                         }
7466                         else
7467                         {
7468                                 /* Affect the grid */
7469                                 if (project_f(who, dist, y, x, dam, typ)) notice = TRUE;
7470                         }
7471                 }
7472         }
7473
7474         /* Update stuff if needed */
7475         if (p_ptr->update) update_stuff();
7476
7477         /* Check objects */
7478         if (flg & (PROJECT_ITEM))
7479         {
7480                 /* Start with "dist" of zero */
7481                 dist = 0;
7482
7483                 /* Scan for objects */
7484                 for (i = 0; i < grids; i++)
7485                 {
7486                         /* Hack -- Notice new "dist" values */
7487                         if (gm[dist+1] == i) dist++;
7488
7489                         /* Get the grid location */
7490                         y = gy[i];
7491                         x = gx[i];
7492
7493                         /* Find the closest point in the blast */
7494                         if (breath)
7495                         {
7496                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7497
7498                                 /* Affect the object in the grid */
7499                                 if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
7500                         }
7501                         else
7502                         {
7503                                 /* Affect the object in the grid */
7504                                 if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
7505                         }
7506                 }
7507         }
7508
7509
7510         /* Check monsters */
7511         if (flg & (PROJECT_KILL))
7512         {
7513                 /* Mega-Hack */
7514                 project_m_n = 0;
7515                 project_m_x = 0;
7516                 project_m_y = 0;
7517
7518                 /* Start with "dist" of zero */
7519                 dist = 0;
7520
7521                 /* Scan for monsters */
7522                 for (i = 0; i < grids; i++)
7523                 {
7524                         int effective_dist;
7525
7526                         /* Hack -- Notice new "dist" values */
7527                         if (gm[dist + 1] == i) dist++;
7528
7529                         /* Get the grid location */
7530                         y = gy[i];
7531                         x = gx[i];
7532
7533                         /* A single bolt may be reflected */
7534                         if (grids <= 1)
7535                         {
7536                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7537                                 monster_race *ref_ptr = &r_info[m_ptr->r_idx];
7538
7539                                 if ((flg & PROJECT_REFLECTABLE) && cave[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
7540                                         ((cave[y][x].m_idx != p_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
7541                                         (!who || dist_hack > 1) && !one_in_(10))
7542                                 {
7543                                         POSITION t_y, t_x;
7544                                         int max_attempts = 10;
7545
7546                                         /* Choose 'new' target */
7547                                         do
7548                                         {
7549                                                 t_y = y_saver - 1 + randint1(3);
7550                                                 t_x = x_saver - 1 + randint1(3);
7551                                                 max_attempts--;
7552                                         }
7553                                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(y, x, t_y, t_x));
7554
7555                                         if (max_attempts < 1)
7556                                         {
7557                                                 t_y = y_saver;
7558                                                 t_x = x_saver;
7559                                         }
7560
7561                                         sound(SOUND_REFLECT);
7562                                         if (is_seen(m_ptr))
7563                                         {
7564                                                 if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
7565                                                         msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!"));
7566                                                 else if (m_ptr->r_idx == MON_DIO) 
7567                                                         msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!"));
7568                                                 else 
7569                                                         msg_print(_("攻撃は跳ね返った!", "The attack bounces!"));
7570                                         }
7571                                         if (is_original_ap_and_seen(m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
7572
7573                                         /* Reflected bolts randomly target either one */
7574                                         if (player_bold(y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
7575                                         else flg |= PROJECT_PLAYER;
7576
7577                                         /* The bolt is reflected */
7578                                         project(cave[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
7579
7580                                         /* Don't affect the monster any longer */
7581                                         continue;
7582                                 }
7583                         }
7584
7585
7586                         /* Find the closest point in the blast */
7587                         if (breath)
7588                         {
7589                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7590                         }
7591                         else
7592                         {
7593                                 effective_dist = dist;
7594                         }
7595
7596
7597                         /* There is the riding player on this monster */
7598                         if (p_ptr->riding && player_bold(y, x))
7599                         {
7600                                 /* Aimed on the player */
7601                                 if (flg & PROJECT_PLAYER)
7602                                 {
7603                                         if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7604                                         {
7605                                                 /*
7606                                                  * A beam or bolt is well aimed
7607                                                  * at the PLAYER!
7608                                                  * So don't affects the mount.
7609                                                  */
7610                                                 continue;
7611                                         }
7612                                         else
7613                                         {
7614                                                 /*
7615                                                  * The spell is not well aimed, 
7616                                                  * So partly affect the mount too.
7617                                                  */
7618                                                 effective_dist++;
7619                                         }
7620                                 }
7621
7622                                 /*
7623                                  * This grid is the original target.
7624                                  * Or aimed on your horse.
7625                                  */
7626                                 else if (((y == y2) && (x == x2)) || (flg & PROJECT_AIMED))
7627                                 {
7628                                         /* Hit the mount with full damage */
7629                                 }
7630
7631                                 /*
7632                                  * Otherwise this grid is not the
7633                                  * original target, it means that line
7634                                  * of fire is obstructed by this
7635                                  * monster.
7636                                  */
7637                                 /*
7638                                  * A beam or bolt will hit either
7639                                  * player or mount.  Choose randomly.
7640                                  */
7641                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
7642                                 {
7643                                         if (one_in_(2))
7644                                         {
7645                                                 /* Hit the mount with full damage */
7646                                         }
7647                                         else
7648                                         {
7649                                                 /* Hit the player later */
7650                                                 flg |= PROJECT_PLAYER;
7651
7652                                                 /* Don't affect the mount */
7653                                                 continue;
7654                                         }
7655                                 }
7656
7657                                 /*
7658                                  * The spell is not well aimed, so
7659                                  * partly affect both player and
7660                                  * mount.
7661                                  */
7662                                 else
7663                                 {
7664                                         effective_dist++;
7665                                 }
7666                         }
7667
7668                         /* Affect the monster in the grid */
7669                         if (project_m(who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
7670                 }
7671
7672
7673                 /* Player affected one monster (without "jumping") */
7674                 if (!who && (project_m_n == 1) && !jump)
7675                 {
7676                         x = project_m_x;
7677                         y = project_m_y;
7678
7679                         /* Track if possible */
7680                         if (cave[y][x].m_idx > 0)
7681                         {
7682                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7683
7684                                 if (m_ptr->ml)
7685                                 {
7686                                         /* Hack -- auto-recall */
7687                                         if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7688
7689                                         /* Hack - auto-track */
7690                                         if (m_ptr->ml) health_track(cave[y][x].m_idx);
7691                                 }
7692                         }
7693                 }
7694         }
7695
7696
7697         /* Check player */
7698         if (flg & (PROJECT_KILL))
7699         {
7700                 /* Start with "dist" of zero */
7701                 dist = 0;
7702
7703                 /* Scan for player */
7704                 for (i = 0; i < grids; i++)
7705                 {
7706                         int effective_dist;
7707
7708                         /* Hack -- Notice new "dist" values */
7709                         if (gm[dist+1] == i) dist++;
7710
7711                         /* Get the grid location */
7712                         y = gy[i];
7713                         x = gx[i];
7714
7715                         /* Affect the player? */
7716                         if (!player_bold(y, x)) continue;
7717
7718                         /* Find the closest point in the blast */
7719                         if (breath)
7720                         {
7721                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7722                         }
7723                         else
7724                         {
7725                                 effective_dist = dist;
7726                         }
7727
7728                         /* Target may be your horse */
7729                         if (p_ptr->riding)
7730                         {
7731                                 /* Aimed on the player */
7732                                 if (flg & PROJECT_PLAYER)
7733                                 {
7734                                         /* Hit the player with full damage */
7735                                 }
7736
7737                                 /*
7738                                  * Hack -- When this grid was not the
7739                                  * original target, a beam or bolt
7740                                  * would hit either player or mount,
7741                                  * and should be choosen randomly.
7742                                  *
7743                                  * But already choosen to hit the
7744                                  * mount at this point.
7745                                  *
7746                                  * Or aimed on your horse.
7747                                  */
7748                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7749                                 {
7750                                         /*
7751                                          * A beam or bolt is well aimed
7752                                          * at the mount!
7753                                          * So don't affects the player.
7754                                          */
7755                                         continue;
7756                                 }
7757                                 else
7758                                 {
7759                                         /*
7760                                          * The spell is not well aimed, 
7761                                          * So partly affect the player too.
7762                                          */
7763                                         effective_dist++;
7764                                 }
7765                         }
7766
7767                         /* Affect the player */
7768                         if (project_p(who, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
7769                 }
7770         }
7771
7772         if (p_ptr->riding)
7773         {
7774                 char m_name[80];
7775
7776                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
7777
7778                 if (rakubadam_m > 0)
7779                 {
7780                         if (rakuba(rakubadam_m, FALSE))
7781                         {
7782                                 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
7783                         }
7784                 }
7785                 if (p_ptr->riding && rakubadam_p > 0)
7786                 {
7787                         if(rakuba(rakubadam_p, FALSE))
7788                         {
7789                                 msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name);
7790                         }
7791                 }
7792         }
7793
7794         /* Return "something was noticed" */
7795         return (notice);
7796 }
7797
7798 /*!
7799  * @brief 鏡魔法「封魔結界」の効果処理
7800  * @param dam ダメージ量
7801  * @return 効果があったらTRUEを返す
7802  */
7803 bool binding_field(HIT_POINT dam)
7804 {
7805         POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
7806         int mirror_num = 0;                       /* 鏡の数 */
7807         POSITION x, y;
7808         POSITION centersign;
7809         POSITION x1, x2, y1, y2;
7810         u16b p;
7811         int msec = delay_factor*delay_factor*delay_factor;
7812
7813         /* 三角形の頂点 */
7814         POSITION point_x[3];
7815         POSITION point_y[3];
7816
7817         /* Default target of monsterspell is player */
7818         monster_target_y = p_ptr->y;
7819         monster_target_x = p_ptr->x;
7820
7821         for (x = 0; x < cur_wid; x++)
7822         {
7823                 for (y = 0; y < cur_hgt; y++)
7824                 {
7825                         if (is_mirror_grid(&cave[y][x]) &&
7826                                 distance(p_ptr->y, p_ptr->x, y, x) <= MAX_RANGE &&
7827                                 distance(p_ptr->y, p_ptr->x, y, x) != 0 &&
7828                                 player_has_los_bold(y, x) &&
7829                                 projectable(p_ptr->y, p_ptr->x, y, x)
7830                                 ) {
7831                                 mirror_y[mirror_num] = y;
7832                                 mirror_x[mirror_num] = x;
7833                                 mirror_num++;
7834                         }
7835                 }
7836         }
7837
7838         if (mirror_num < 2)return FALSE;
7839
7840         point_x[0] = randint0(mirror_num);
7841         do {
7842                 point_x[1] = randint0(mirror_num);
7843         } while (point_x[0] == point_x[1]);
7844
7845         point_y[0] = mirror_y[point_x[0]];
7846         point_x[0] = mirror_x[point_x[0]];
7847         point_y[1] = mirror_y[point_x[1]];
7848         point_x[1] = mirror_x[point_x[1]];
7849         point_y[2] = p_ptr->y;
7850         point_x[2] = p_ptr->x;
7851
7852         x = point_x[0] + point_x[1] + point_x[2];
7853         y = point_y[0] + point_y[1] + point_y[2];
7854
7855         centersign = (point_x[0] * 3 - x)*(point_y[1] * 3 - y)
7856                 - (point_y[0] * 3 - y)*(point_x[1] * 3 - x);
7857         if (centersign == 0)return FALSE;
7858
7859         x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
7860         x1 = x1 < point_x[2] ? x1 : point_x[2];
7861         y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
7862         y1 = y1 < point_y[2] ? y1 : point_y[2];
7863
7864         x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
7865         x2 = x2 > point_x[2] ? x2 : point_x[2];
7866         y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
7867         y2 = y2 > point_y[2] ? y2 : point_y[2];
7868
7869         for (y = y1; y <= y2; y++) {
7870                 for (x = x1; x <= x2; x++) {
7871                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7872                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7873                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7874                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7875                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7876                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7877                         {
7878                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7879                                         /* Visual effects */
7880                                         if (!(p_ptr->blind)
7881                                                 && panel_contains(y, x)) {
7882                                                 p = bolt_pict(y, x, y, x, GF_MANA);
7883                                                 print_rel(PICT_C(p), PICT_A(p), y, x);
7884                                                 move_cursor_relative(y, x);
7885                                                 /*if (fresh_before)*/ Term_fresh();
7886                                                 Term_xtra(TERM_XTRA_DELAY, msec);
7887                                         }
7888                                 }
7889                         }
7890                 }
7891         }
7892         for (y = y1; y <= y2; y++) {
7893                 for (x = x1; x <= x2; x++) {
7894                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7895                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7896                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7897                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7898                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7899                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7900                         {
7901                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7902                                         (void)project_f(0, 0, y, x, dam, GF_MANA);
7903                                 }
7904                         }
7905                 }
7906         }
7907         for (y = y1; y <= y2; y++) {
7908                 for (x = x1; x <= x2; x++) {
7909                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7910                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7911                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7912                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7913                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7914                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7915                         {
7916                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7917                                         (void)project_o(0, 0, y, x, dam, GF_MANA);
7918                                 }
7919                         }
7920                 }
7921         }
7922         for (y = y1; y <= y2; y++) {
7923                 for (x = x1; x <= x2; x++) {
7924                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7925                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7926                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7927                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7928                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7929                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7930                         {
7931                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7932                                         (void)project_m(0, 0, y, x, dam, GF_MANA,
7933                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
7934                                 }
7935                         }
7936                 }
7937         }
7938         if (one_in_(7)) {
7939                 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
7940                 remove_mirror(point_y[0], point_x[0]);
7941         }
7942
7943         return TRUE;
7944 }
7945
7946 /*!
7947  * @brief 鏡魔法「鏡の封印」の効果処理
7948  * @param dam ダメージ量
7949  * @return 効果があったらTRUEを返す
7950  */
7951 void seal_of_mirror(HIT_POINT dam)
7952 {
7953         POSITION x, y;
7954
7955         for (x = 0; x < cur_wid; x++)
7956         {
7957                 for (y = 0; y < cur_hgt; y++)
7958                 {
7959                         if (is_mirror_grid(&cave[y][x]))
7960                         {
7961                                 if (project_m(0, 0, y, x, dam, GF_GENOCIDE,
7962                                         (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
7963                                 {
7964                                         if (!cave[y][x].m_idx)
7965                                         {
7966                                                 remove_mirror(y, x);
7967                                         }
7968                                 }
7969                         }
7970                 }
7971         }
7972         return;
7973 }
7974