OSDN Git Service

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