OSDN Git Service

e8d6f547d3849492f0d39c939c2a780f1abbd4df
[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(SOUND_FLEE);
4968
4969                                 /* Message */
4970                                 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4971                         }
4972
4973                         /* Hack -- handle sleep */
4974                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4975                 }
4976         }
4977
4978         if ((typ == GF_BLOOD_CURSE) && one_in_(4))
4979         {
4980                 int curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
4981                 int count = 0;
4982                 do
4983                 {
4984                         switch (randint1(28))
4985                         {
4986                         case 1: case 2:
4987                                 if (!count)
4988                                 {
4989                                         msg_print(_("地面が揺れた...", "The ground trembles..."));
4990                                         earthquake(ty, tx, 4 + randint0(4));
4991                                         if (!one_in_(6)) break;
4992                                 }
4993                         case 3: case 4: case 5: case 6:
4994                                 if (!count)
4995                                 {
4996                                         int extra_dam = damroll(10, 10);
4997                                         msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
4998
4999                                         project(0, 8, ty, tx, extra_dam, GF_MANA, curse_flg, -1);
5000                                         if (!one_in_(6)) break;
5001                                 }
5002                         case 7: case 8:
5003                                 if (!count)
5004                                 {
5005                                         msg_print(_("空間が歪んだ!", "Space warps about you!"));
5006
5007                                         if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
5008                                         if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
5009                                         if (!one_in_(6)) break;
5010                                 }
5011                         case 9: case 10: case 11:
5012                                 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
5013                                 project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
5014                                 if (!one_in_(6)) break;
5015                         case 12: case 13: case 14: case 15: case 16:
5016                                 aggravate_monsters(0);
5017                                 if (!one_in_(6)) break;
5018                         case 17: case 18:
5019                                 count += activate_hi_summon(ty, tx, TRUE);
5020                                 if (!one_in_(6)) break;
5021                         case 19: case 20: case 21: case 22:
5022                         {
5023                                 bool pet = !one_in_(3);
5024                                 BIT_FLAGS mode = PM_ALLOW_GROUP;
5025
5026                                 if (pet) mode |= PM_FORCE_PET;
5027                                 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
5028
5029                                 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);
5030                                 if (!one_in_(6)) break;
5031                         }
5032                         case 23: case 24: case 25:
5033                                 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
5034                                 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
5035
5036                                 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
5037                                 else lose_exp(p_ptr->exp / 16);
5038                                 if (!one_in_(6)) break;
5039                         case 26: case 27: case 28:
5040                         {
5041                                 int i = 0;
5042                                 if (one_in_(13))
5043                                 {
5044                                         while (i < 6)
5045                                         {
5046                                                 do
5047                                                 {
5048                                                         (void)do_dec_stat(i);
5049                                                 }
5050                                                 while (one_in_(2));
5051
5052                                                 i++;
5053                                         }
5054                                 }
5055                                 else
5056                                 {
5057                                         (void)do_dec_stat(randint0(6));
5058                                 }
5059                                 break;
5060                         }
5061                         }
5062                 }
5063                 while (one_in_(5));
5064         }
5065
5066         if (p_ptr->inside_battle)
5067         {
5068                 p_ptr->health_who = c_ptr->m_idx;
5069                 p_ptr->redraw |= (PR_HEALTH);
5070                 redraw_stuff();
5071         }
5072
5073         /* XXX XXX XXX Verify this code */
5074
5075         /* Update the monster */
5076         if (m_ptr->r_idx) update_mon(c_ptr->m_idx, FALSE);
5077
5078         /* Redraw the monster grid */
5079         lite_spot(y, x);
5080
5081
5082         /* Update monster recall window */
5083         if ((p_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
5084         {
5085                 /* Window stuff */
5086                 p_ptr->window |= (PW_MONSTER);
5087         }
5088
5089         if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
5090         {
5091                 if (!who)
5092                 {
5093                         if (!(flg & PROJECT_NO_HANGEKI))
5094                         {
5095                                 set_target(m_ptr, monster_target_y, monster_target_x);
5096                         }
5097                 }
5098                 else if ((who > 0) && is_pet(caster_ptr) && !player_bold(m_ptr->target_y, m_ptr->target_x))
5099                 {
5100                         set_target(m_ptr, caster_ptr->fy, caster_ptr->fx);
5101                 }
5102         }
5103
5104         if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx) && (dam > 0))
5105         {
5106                 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
5107                 rakubadam_m = (dam > 200) ? 200 : dam;
5108         }
5109
5110
5111         if (photo)
5112         {
5113                 object_type *q_ptr;
5114                 object_type forge;
5115
5116                 /* Get local object */
5117                 q_ptr = &forge;
5118
5119                 /* Prepare to make a Blade of Chaos */
5120                 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
5121
5122                 q_ptr->pval = photo;
5123
5124                 /* Mark the item as fully known */
5125                 q_ptr->ident |= (IDENT_MENTAL);
5126
5127                 /* Drop it in the dungeon */
5128                 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
5129         }
5130
5131         /* Track it */
5132         project_m_n++;
5133         project_m_x = x;
5134         project_m_y = y;
5135
5136         /* Return "Anything seen?" */
5137         return (obvious);
5138 }
5139
5140 /*!
5141  * @brief 汎用的なビーム/ボルト/ボール系によるプレイヤーへの効果処理 / Helper function for "project()" below.
5142  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
5143  * @param who_name 効果を起こしたモンスターの名前
5144  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
5145  * @param y 目標Y座標 / Target y location (or location to travel "towards")
5146  * @param x 目標X座標 / Target x location (or location to travel "towards")
5147  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
5148  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
5149  * @param flg 効果フラグ
5150  * @param monspell 効果元のモンスター魔法ID
5151  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
5152  * @details
5153  * Handle a beam/bolt/ball causing damage to the player.
5154  * This routine takes a "source monster" (by index), a "distance", a default
5155  * "damage", and a "damage type".  See "project_m()" above.
5156  * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
5157  * is reduced (see "project_m()" above).  This can happen if a monster breathes
5158  * at the player and hits a wall instead.
5159  * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
5160  * to know if this is actually a ball or a bolt spell
5161  * We return "TRUE" if any "obvious" effects were observed.  XXX XXX Actually,
5162  * we just assume that the effects were obvious, for historical reasons.
5163  */
5164 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)
5165 {
5166         int k = 0;
5167         int rlev = 0;
5168
5169         /* Hack -- assume obvious */
5170         bool obvious = TRUE;
5171
5172         /* Player blind-ness */
5173         bool blind = (p_ptr->blind ? TRUE : FALSE);
5174
5175         /* Player needs a "description" (he is blind) */
5176         bool fuzzy = FALSE;
5177
5178         /* Source monster */
5179         monster_type *m_ptr = NULL;
5180
5181         /* Monster name (for attacks) */
5182         char m_name[80];
5183
5184         /* Monster name (for damage) */
5185         char killer[80];
5186
5187         /* Hack -- messages */
5188         cptr act = NULL;
5189
5190         int get_damage = 0;
5191
5192
5193         /* Player is not here */
5194         if (!player_bold(y, x)) return (FALSE);
5195
5196         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (p_ptr->lev*3/5+20)) && who && (who != p_ptr->riding))
5197         {
5198                 if (kawarimi(TRUE)) return FALSE;
5199         }
5200
5201         /* Player cannot hurt himself */
5202         if (!who) return (FALSE);
5203         if (who == p_ptr->riding) return (FALSE);
5204
5205         if ((p_ptr->reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
5206         {
5207                 POSITION t_y, t_x;
5208                 int max_attempts = 10;
5209                 sound(SOUND_REFLECT);
5210
5211                 if (blind) 
5212                         msg_print(_("何かが跳ね返った!", "Something bounces!"));
5213                 else if (p_ptr->special_defense & KATA_FUUJIN) 
5214                         msg_print(_("風の如く武器を振るって弾き返した!", "The attack bounces!"));
5215                 else 
5216                         msg_print(_("攻撃が跳ね返った!", "The attack bounces!"));
5217
5218
5219                 /* Choose 'new' target */
5220                 if (who > 0)
5221                 {
5222                         do
5223                         {
5224                                 t_y = m_list[who].fy - 1 + randint1(3);
5225                                 t_x = m_list[who].fx - 1 + randint1(3);
5226                                 max_attempts--;
5227                         }
5228                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(p_ptr->y, p_ptr->x, t_y, t_x));
5229
5230                         if (max_attempts < 1)
5231                         {
5232                                 t_y = m_list[who].fy;
5233                                 t_x = m_list[who].fx;
5234                         }
5235                 }
5236                 else
5237                 {
5238                         t_y = p_ptr->y - 1 + randint1(3);
5239                         t_x = p_ptr->x - 1 + randint1(3);
5240                 }
5241
5242                 project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL|PROJECT_REFLECTABLE), monspell);
5243
5244                 disturb(1, 1);
5245                 return TRUE;
5246         }
5247
5248         /* XXX XXX XXX */
5249         /* Limit maximum damage */
5250         if (dam > 1600) dam = 1600;
5251
5252         /* Reduce damage by distance */
5253         dam = (dam + r) / (r + 1);
5254
5255
5256         /* If the player is blind, be more descriptive */
5257         if (blind) fuzzy = TRUE;
5258
5259
5260         if (who > 0)
5261         {
5262                 /* Get the source monster */
5263                 m_ptr = &m_list[who];
5264                 /* Extract the monster level */
5265                 rlev = (((&r_info[m_ptr->r_idx])->level >= 1) ? (&r_info[m_ptr->r_idx])->level : 1);
5266
5267                 /* Get the monster name */
5268                 monster_desc(m_name, m_ptr, 0);
5269
5270                 /* Get the monster's real name (gotten before polymorph!) */
5271                 strcpy(killer, who_name);
5272         }
5273         else
5274         {
5275                 switch (who)
5276                 {
5277                 case PROJECT_WHO_UNCTRL_POWER:
5278                         strcpy(killer, _("制御できない力の氾流", "uncontrollable power storm"));
5279                         break;
5280
5281                 case PROJECT_WHO_GLASS_SHARDS:
5282                         strcpy(killer, _("ガラスの破片", "shards of glass"));
5283                         break;
5284
5285                 default:
5286                         strcpy(killer, _("罠", "a trap"));
5287                         break;
5288                 }
5289
5290                 /* Paranoia */
5291                 strcpy(m_name, killer);
5292         }
5293
5294         /* Analyze the damage */
5295         switch (typ)
5296         {
5297                 /* Standard damage -- hurts inventory too */
5298                 case GF_ACID:
5299                 {
5300                         if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));                    
5301                         get_damage = acid_dam(dam, killer, monspell, FALSE);
5302                         break;
5303                 }
5304
5305                 /* Standard damage -- hurts inventory too */
5306                 case GF_FIRE:
5307                 {
5308                         if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
5309                         get_damage = fire_dam(dam, killer, monspell, FALSE);
5310                         break;
5311                 }
5312
5313                 /* Standard damage -- hurts inventory too */
5314                 case GF_COLD:
5315                 {
5316                         if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
5317                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5318                         break;
5319                 }
5320
5321                 /* Standard damage -- hurts inventory too */
5322                 case GF_ELEC:
5323                 {
5324                         if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
5325                         get_damage = elec_dam(dam, killer, monspell, FALSE);
5326                         break;
5327                 }
5328
5329                 /* Standard damage -- also poisons player */
5330                 case GF_POIS:
5331                 {
5332                         bool double_resist = IS_OPPOSE_POIS();
5333                         if (fuzzy) msg_print(_("毒で攻撃された!", "You are hit by poison!"));
5334
5335                         if (p_ptr->resist_pois) dam = (dam + 2) / 3;
5336                         if (double_resist) dam = (dam + 2) / 3;
5337
5338                         if ((!(double_resist || p_ptr->resist_pois)) &&
5339                                  one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
5340                         {
5341                                 do_dec_stat(A_CON);
5342                         }
5343
5344                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5345
5346                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
5347                         {
5348                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
5349                         }
5350                         break;
5351                 }
5352
5353                 /* Standard damage -- also poisons / mutates player */
5354                 case GF_NUKE:
5355                 {
5356                         bool double_resist = IS_OPPOSE_POIS();
5357                         if (fuzzy) msg_print(_("放射能で攻撃された!", "You are hit by radiation!"));
5358
5359                         if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
5360                         if (double_resist) dam = (2 * dam + 2) / 5;
5361                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5362                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
5363                         {
5364                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
5365
5366                                 if (one_in_(5)) /* 6 */
5367                                 {
5368                                         msg_print(_("奇形的な変身を遂げた!", "You undergo a freakish metamorphosis!"));
5369                                         if (one_in_(4)) /* 4 */
5370                                                 do_poly_self();
5371                                         else
5372                                                 mutate_player();
5373                                 }
5374
5375                                 if (one_in_(6))
5376                                 {
5377                                         inven_damage(set_acid_destroy, 2);
5378                                 }
5379                         }
5380                         break;
5381                 }
5382
5383                 /* Standard damage */
5384                 case GF_MISSILE:
5385                 {
5386                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5387                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5388                         break;
5389                 }
5390
5391                 /* Holy Orb -- Player only takes partial damage */
5392                 case GF_HOLY_FIRE:
5393                 {
5394                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5395                         if (p_ptr->align > 10)
5396                                 dam /= 2;
5397                         else if (p_ptr->align < -10)
5398                                 dam *= 2;
5399                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5400                         break;
5401                 }
5402
5403                 case GF_HELL_FIRE:
5404                 {
5405                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5406                         if (p_ptr->align > 10)
5407                                 dam *= 2;
5408                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5409                         break;
5410                 }
5411
5412                 /* Arrow -- XXX no dodging */
5413                 case GF_ARROW:
5414                 {
5415                         if (fuzzy)
5416                         {
5417                                 msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5418                         }
5419                         else if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
5420                         {
5421                                 msg_print(_("矢を斬り捨てた!", "You cut down the arrow!"));
5422                                 break;
5423                         }
5424                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5425                         break;
5426                 }
5427
5428                 /* Plasma -- XXX No resist */
5429                 case GF_PLASMA:
5430                 {
5431                         if (fuzzy) msg_print(_("何かとても熱いもので攻撃された!", "You are hit by something *HOT*!"));
5432                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5433
5434                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5435                         {
5436                                 int plus_stun = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
5437                                 (void)set_stun(p_ptr->stun + plus_stun);
5438                         }
5439
5440                         if (!(p_ptr->resist_fire ||
5441                                 IS_OPPOSE_FIRE() ||
5442                                 p_ptr->immune_fire))
5443                         {
5444                                 inven_damage(set_acid_destroy, 3);
5445                         }
5446
5447                         break;
5448                 }
5449
5450                 /* Nether -- drain experience */
5451                 case GF_NETHER:
5452                 {
5453                         if (fuzzy) msg_print(_("地獄の力で攻撃された!", "You are hit by nether forces!"));
5454                         if (p_ptr->resist_neth)
5455                         {
5456                                 if (!prace_is_(RACE_SPECTRE))
5457                                 {
5458                                         dam *= 6; dam /= (randint1(4) + 7);
5459                                 }
5460                         }
5461                         else if (!CHECK_MULTISHADOW()) drain_exp(200 + (p_ptr->exp / 100), 200 + (p_ptr->exp / 1000), 75);
5462
5463                         if (prace_is_(RACE_SPECTRE) && !CHECK_MULTISHADOW())
5464                         {
5465                                 msg_print(_("気分がよくなった。", "You feel invigorated!"));
5466                                 hp_player(dam / 4);
5467                                 learn_spell(monspell);
5468                         }
5469                         else
5470                         {
5471                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5472                         }
5473
5474                         break;
5475                 }
5476
5477                 /* Water -- stun/confuse */
5478                 case GF_WATER:
5479                 {
5480                         if (fuzzy) msg_print(_("何か湿ったもので攻撃された!", "You are hit by something wet!"));
5481                         if (!CHECK_MULTISHADOW())
5482                         {
5483                                 if (!p_ptr->resist_sound)
5484                                 {
5485                                         set_stun(p_ptr->stun + randint1(40));
5486                                 }
5487                                 if (!p_ptr->resist_conf)
5488                                 {
5489                                         set_confused(p_ptr->confused + randint1(5) + 5);
5490                                 }
5491
5492                                 if (one_in_(5))
5493                                 {
5494                                         inven_damage(set_cold_destroy, 3);
5495                                 }
5496                         }
5497
5498                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5499                         break;
5500                 }
5501
5502                 /* Chaos -- many effects */
5503                 case GF_CHAOS:
5504                 {
5505                         if (fuzzy) msg_print(_("無秩序の波動で攻撃された!", "You are hit by a wave of anarchy!"));
5506                         if (p_ptr->resist_chaos)
5507                         {
5508                                 dam *= 6; dam /= (randint1(4) + 7);
5509                         }
5510
5511                         if (!CHECK_MULTISHADOW())
5512                         {
5513                                 if (!p_ptr->resist_conf)
5514                                 {
5515                                         (void)set_confused(p_ptr->confused + randint0(20) + 10);
5516                                 }
5517                                 if (!p_ptr->resist_chaos)
5518                                 {
5519                                         (void)set_image(p_ptr->image + randint1(10));
5520                                         if (one_in_(3))
5521                                         {
5522                                                 msg_print(_("あなたの身体はカオスの力で捻じ曲げられた!", "Your body is twisted by chaos!"));
5523                                                 (void)gain_random_mutation(0);
5524                                         }
5525                                 }
5526                                 if (!p_ptr->resist_neth && !p_ptr->resist_chaos)
5527                                 {
5528                                         drain_exp(5000 + (p_ptr->exp / 100), 500 + (p_ptr->exp / 1000), 75);
5529                                 }
5530
5531                                 if (!p_ptr->resist_chaos || one_in_(9))
5532                                 {
5533                                         inven_damage(set_elec_destroy, 2);
5534                                         inven_damage(set_fire_destroy, 2);
5535                                 }
5536                         }
5537
5538                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5539                         break;
5540                 }
5541
5542                 /* Shards -- mostly cutting */
5543                 case GF_SHARDS:
5544                 {
5545                         if (fuzzy) msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5546                         if (p_ptr->resist_shard)
5547                         {
5548                                 dam *= 6; dam /= (randint1(4) + 7);
5549                         }
5550                         else if (!CHECK_MULTISHADOW())
5551                         {
5552                                 (void)set_cut(p_ptr->cut + dam);
5553                         }
5554
5555                         if (!p_ptr->resist_shard || one_in_(13))
5556                         {
5557                                 inven_damage(set_cold_destroy, 2);
5558                         }
5559
5560                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5561                         break;
5562                 }
5563
5564                 /* Sound -- mostly stunning */
5565                 case GF_SOUND:
5566                 {
5567                         if (fuzzy) msg_print(_("轟音で攻撃された!", "You are hit by a loud noise!"));
5568                         if (p_ptr->resist_sound)
5569                         {
5570                                 dam *= 5; dam /= (randint1(4) + 7);
5571                         }
5572                         else if (!CHECK_MULTISHADOW())
5573                         {
5574                                 int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5575                                 (void)set_stun(p_ptr->stun + plus_stun);
5576                         }
5577
5578                         if (!p_ptr->resist_sound || one_in_(13))
5579                         {
5580                                 inven_damage(set_cold_destroy, 2);
5581                         }
5582
5583                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5584                         break;
5585                 }
5586
5587                 /* Pure confusion */
5588                 case GF_CONFUSION:
5589                 {
5590                         if (fuzzy) msg_print(_("何か混乱するもので攻撃された!", "You are hit by something puzzling!"));
5591                         if (p_ptr->resist_conf)
5592                         {
5593                                 dam *= 5; dam /= (randint1(4) + 7);
5594                         }
5595                         else if (!CHECK_MULTISHADOW())
5596                         {
5597                                 (void)set_confused(p_ptr->confused + randint1(20) + 10);
5598                         }
5599                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5600                         break;
5601                 }
5602
5603                 /* Disenchantment -- see above */
5604                 case GF_DISENCHANT:
5605                 {
5606                         if (fuzzy) msg_print(_("何かさえないもので攻撃された!", "You are hit by something static!"));
5607                         if (p_ptr->resist_disen)
5608                         {
5609                                 dam *= 6; dam /= (randint1(4) + 7);
5610                         }
5611                         else if (!CHECK_MULTISHADOW())
5612                         {
5613                                 (void)apply_disenchant(0);
5614                         }
5615                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5616                         break;
5617                 }
5618
5619                 /* Nexus -- see above */
5620                 case GF_NEXUS:
5621                 {
5622                         if (fuzzy) msg_print(_("何か奇妙なもので攻撃された!", "You are hit by something strange!"));
5623                         if (p_ptr->resist_nexus)
5624                         {
5625                                 dam *= 6; dam /= (randint1(4) + 7);
5626                         }
5627                         else if (!CHECK_MULTISHADOW())
5628                         {
5629                                 apply_nexus(m_ptr);
5630                         }
5631                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5632                         break;
5633                 }
5634
5635                 /* Force -- mostly stun */
5636                 case GF_FORCE:
5637                 {
5638                         if (fuzzy) msg_print(_("運動エネルギーで攻撃された!", "You are hit by kinetic force!"));
5639                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5640                         {
5641                                 (void)set_stun(p_ptr->stun + randint1(20));
5642                         }
5643                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5644                         break;
5645                 }
5646
5647
5648                 /* Rocket -- stun, cut */
5649                 case GF_ROCKET:
5650                 {
5651                         if (fuzzy) msg_print(_("爆発があった!", "There is an explosion!"));
5652                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5653                         {
5654                                 (void)set_stun(p_ptr->stun + randint1(20));
5655                         }
5656
5657                         if (p_ptr->resist_shard)
5658                         {
5659                                 dam /= 2;
5660                         }
5661                         else if (!CHECK_MULTISHADOW())
5662                         {
5663                                 (void)set_cut(p_ptr->cut + (dam / 2));
5664                         }
5665
5666                         if (!p_ptr->resist_shard || one_in_(12))
5667                         {
5668                                 inven_damage(set_cold_destroy, 3);
5669                         }
5670
5671                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5672                         break;
5673                 }
5674
5675                 /* Inertia -- slowness */
5676                 case GF_INERTIAL:
5677                 {
5678                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5679                         if (!CHECK_MULTISHADOW()) (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5680                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5681                         break;
5682                 }
5683
5684                 /* Lite -- blinding */
5685                 case GF_LITE:
5686                 {
5687                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5688                         if (p_ptr->resist_lite)
5689                         {
5690                                 dam *= 4; dam /= (randint1(4) + 7);
5691                         }
5692                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5693                         {
5694                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5695                         }
5696
5697                         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
5698                         {
5699                                 if (!CHECK_MULTISHADOW()) msg_print(_("光で肉体が焦がされた!", "The light scorches your flesh!"));
5700                                 dam *= 2;
5701                         }
5702                         else if (prace_is_(RACE_S_FAIRY))
5703                         {
5704                                 dam = dam * 4 / 3;
5705                         }
5706
5707                         if (p_ptr->wraith_form) dam *= 2;
5708                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5709
5710                         if (p_ptr->wraith_form && !CHECK_MULTISHADOW())
5711                         {
5712                                 p_ptr->wraith_form = 0;
5713                                 msg_print(_("閃光のため非物質的な影の存在でいられなくなった。",
5714                                         "The light forces you out of your incorporeal shadow form."));
5715
5716                                 p_ptr->redraw |= PR_MAP;
5717                                 /* Update monsters */
5718                                 p_ptr->update |= (PU_MONSTERS);
5719                                 /* Window stuff */
5720                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5721
5722                                 /* Redraw status bar */
5723                                 p_ptr->redraw |= (PR_STATUS);
5724
5725                         }
5726
5727                         break;
5728                 }
5729
5730                 /* Dark -- blinding */
5731                 case GF_DARK:
5732                 {
5733                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5734                         if (p_ptr->resist_dark)
5735                         {
5736                                 dam *= 4; dam /= (randint1(4) + 7);
5737
5738                                 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
5739                         }
5740                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5741                         {
5742                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5743                         }
5744                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5745                         break;
5746                 }
5747
5748                 /* Time -- bolt fewer effects XXX */
5749                 case GF_TIME:
5750                 {
5751                         if (fuzzy) msg_print(_("過去からの衝撃に攻撃された!", "You are hit by a blast from the past!"));
5752                         if (p_ptr->resist_time)
5753                         {
5754                                 dam *= 4;
5755                                 dam /= (randint1(4) + 7);
5756                                 msg_print(_("時間が通り過ぎていく気がする。", "You feel as if time is passing you by."));
5757                         }
5758                         else if (!CHECK_MULTISHADOW())
5759                         {
5760                                 switch (randint1(10))
5761                                 {
5762                                         case 1: case 2: case 3: case 4: case 5:
5763                                         {
5764                                                 if (p_ptr->prace == RACE_ANDROID) break;
5765                                                 msg_print(_("人生が逆戻りした気がする。", "You feel life has clocked back."));
5766                                                 lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
5767                                                 break;
5768                                         }
5769
5770                                         case 6: case 7: case 8: case 9:
5771                                         {
5772                                                 switch (randint1(6))
5773                                                 {
5774                                                         case 1: k = A_STR; act = _("強く", "strong"); break;
5775                                                         case 2: k = A_INT; act = _("聡明で", "bright"); break;
5776                                                         case 3: k = A_WIS; act = _("賢明で", "wise"); break;
5777                                                         case 4: k = A_DEX; act = _("器用で", "agile"); break;
5778                                                         case 5: k = A_CON; act = _("健康で", "hale"); break;
5779                                                         case 6: k = A_CHR; act = _("美しく", "beautiful"); break;
5780                                                 }
5781
5782                                                 msg_format(_("あなたは以前ほど%sなくなってしまった...。", 
5783                                                                          "You're not as %s as you used to be..."), act);
5784
5785                                                 p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
5786                                                 if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5787                                                 p_ptr->update |= (PU_BONUS);
5788                                                 break;
5789                                         }
5790
5791                                         case 10:
5792                                         {
5793                                                 msg_print(_("あなたは以前ほど力強くなくなってしまった...。", 
5794                                                                         "You're not as powerful as you used to be..."));
5795
5796                                                 for (k = 0; k < 6; k++)
5797                                                 {
5798                                                         p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
5799                                                         if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5800                                                 }
5801                                                 p_ptr->update |= (PU_BONUS);
5802                                                 break;
5803                                         }
5804                                 }
5805                         }
5806
5807                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5808                         break;
5809                 }
5810
5811                 /* Gravity -- stun plus slowness plus teleport */
5812                 case GF_GRAVITY:
5813                 {
5814                         if (fuzzy) msg_print(_("何か重いもので攻撃された!", "You are hit by something heavy!"));
5815                                 msg_print(_("周辺の重力がゆがんだ。", "Gravity warps around you."));
5816
5817                         if (!CHECK_MULTISHADOW())
5818                         {
5819                                 teleport_player(5, TELEPORT_PASSIVE);
5820                                 if (!p_ptr->levitation)
5821                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5822                                 if (!(p_ptr->resist_sound || p_ptr->levitation))
5823                                 {
5824                                         int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5825                                         (void)set_stun(p_ptr->stun + plus_stun);
5826                                 }
5827                         }
5828                         if (p_ptr->levitation)
5829                         {
5830                                 dam = (dam * 2) / 3;
5831                         }
5832
5833                         if (!p_ptr->levitation || one_in_(13))
5834                         {
5835                                 inven_damage(set_cold_destroy, 2);
5836                         }
5837
5838                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5839                         break;
5840                 }
5841
5842                 /* Standard damage */
5843                 case GF_DISINTEGRATE:
5844                 {
5845                         if (fuzzy) msg_print(_("純粋なエネルギーで攻撃された!", "You are hit by pure energy!"));
5846
5847                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5848                         break;
5849                 }
5850
5851                 case GF_OLD_HEAL:
5852                 {
5853                         if (fuzzy) msg_print(_("何らかの攻撃によって気分がよくなった。", "You are hit by something invigorating!"));
5854
5855                         (void)hp_player(dam);
5856                         dam = 0;
5857                         break;
5858                 }
5859
5860                 case GF_OLD_SPEED:
5861                 {
5862                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5863                         (void)set_fast(p_ptr->fast + randint1(5), FALSE);
5864                         dam = 0;
5865                         break;
5866                 }
5867
5868                 case GF_OLD_SLOW:
5869                 {
5870                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5871                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5872                         break;
5873                 }
5874
5875                 case GF_OLD_SLEEP:
5876                 {
5877                         if (p_ptr->free_act)  break;
5878                         if (fuzzy) msg_print(_("眠ってしまった!", "You fall asleep!"));
5879
5880                         if (ironman_nightmare)
5881                         {
5882                                 msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
5883                                 /* Have some nightmares */
5884                                 sanity_blast(NULL, FALSE);
5885                         }
5886
5887                         set_paralyzed(p_ptr->paralyzed + dam);
5888                         dam = 0;
5889                         break;
5890                 }
5891
5892                 /* Pure damage */
5893                 case GF_MANA:
5894                 case GF_SEEKER:
5895                 case GF_SUPER_RAY:
5896                 {
5897                         if (fuzzy) msg_print(_("魔法のオーラで攻撃された!", "You are hit by an aura of magic!"));
5898                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5899                         break;
5900                 }
5901
5902                 /* Pure damage */
5903                 case GF_PSY_SPEAR:
5904                 {
5905                         if (fuzzy) msg_print(_("エネルギーの塊で攻撃された!", "You are hit by an energy!"));
5906                         get_damage = take_hit(DAMAGE_FORCE, dam, killer, monspell);
5907                         break;
5908                 }
5909
5910                 /* Pure damage */
5911                 case GF_METEOR:
5912                 {
5913                         if (fuzzy) msg_print(_("何かが空からあなたの頭上に落ちてきた!", "Something falls from the sky on you!"));
5914
5915                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5916                         if (!p_ptr->resist_shard || one_in_(13))
5917                         {
5918                                 if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
5919                                 inven_damage(set_cold_destroy, 2);
5920                         }
5921
5922                         break;
5923                 }
5924
5925                 /* Ice -- cold plus stun plus cuts */
5926                 case GF_ICE:
5927                 {
5928                         if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
5929                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5930                         if (!CHECK_MULTISHADOW())
5931                         {
5932                                 if (!p_ptr->resist_shard)
5933                                 {
5934                                         (void)set_cut(p_ptr->cut + damroll(5, 8));
5935                                 }
5936                                 if (!p_ptr->resist_sound)
5937                                 {
5938                                         (void)set_stun(p_ptr->stun + randint1(15));
5939                                 }
5940
5941                                 if ((!(p_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
5942                                 {
5943                                         if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
5944                                 }
5945                         }
5946
5947                         break;
5948                 }
5949
5950                 /* Death Ray */
5951                 case GF_DEATH_RAY:
5952                 {
5953                         if (fuzzy) msg_print(_("何か非常に冷たいもので攻撃された!", "You are hit by something extremely cold!"));
5954
5955                         if (p_ptr->mimic_form)
5956                         {
5957                                 if (!(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
5958                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5959                         }
5960                         else
5961                         {
5962
5963                         switch (p_ptr->prace)
5964                         {
5965                                 /* Some races are immune */
5966                                 case RACE_GOLEM:
5967                                 case RACE_SKELETON:
5968                                 case RACE_ZOMBIE:
5969                                 case RACE_VAMPIRE:
5970                                 case RACE_DEMON:
5971                                 case RACE_SPECTRE:
5972                                 {
5973                                         dam = 0;
5974                                         break;
5975                                 }
5976                                 /* Hurt a lot */
5977                                 default:
5978                                 {
5979                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5980                                         break;
5981                                 }
5982                         }
5983                         }
5984
5985                         break;
5986                 }
5987
5988                 /* Drain mana */
5989                 case GF_DRAIN_MANA:
5990                 {
5991                         if (CHECK_MULTISHADOW())
5992                         {
5993                                 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, you are unharmed!"));
5994                         }
5995                         else if (p_ptr->csp)
5996                         {
5997                                 /* Basic message */
5998                                 if (who > 0) 
5999                                         msg_format(_("%^sに精神エネルギーを吸い取られてしまった!", "%^s draws psychic energy from you!"), m_name);
6000                                 else 
6001                                         msg_print(_("精神エネルギーを吸い取られてしまった!", "Your psychic energy is drawn!"));
6002
6003                                 /* Full drain */
6004                                 if (dam >= p_ptr->csp)
6005                                 {
6006                                         dam = p_ptr->csp;
6007                                         p_ptr->csp = 0;
6008                                         p_ptr->csp_frac = 0;
6009                                 }
6010
6011                                 /* Partial drain */
6012                                 else
6013                                 {
6014                                         p_ptr->csp -= dam;
6015                                 }
6016
6017                                 learn_spell(monspell);
6018
6019                                 /* Redraw mana */
6020                                 p_ptr->redraw |= (PR_MANA);
6021
6022                                 /* Window stuff */
6023                                 p_ptr->window |= (PW_PLAYER);
6024                                 p_ptr->window |= (PW_SPELL);
6025
6026                                 if (who > 0)
6027                                 {
6028                                         /* Heal the monster */
6029                                         if (m_ptr->hp < m_ptr->maxhp)
6030                                         {
6031                                                 /* Heal */
6032                                                 m_ptr->hp += dam;
6033                                                 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
6034
6035                                                 /* Redraw (later) if needed */
6036                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
6037                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
6038
6039                                                 /* Special message */
6040                                                 if (m_ptr->ml)
6041                                                 {
6042                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), m_name);
6043                                                 }
6044                                         }
6045                                 }
6046                         }
6047
6048                         dam = 0;
6049                         break;
6050                 }
6051
6052                 /* Mind blast */
6053                 case GF_MIND_BLAST:
6054                 {
6055                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
6056                         {
6057                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6058                                 learn_spell(monspell);
6059                         }
6060                         else
6061                         {
6062                                 if (!CHECK_MULTISHADOW())
6063                                 {
6064                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
6065
6066                                         if (!p_ptr->resist_conf)
6067                                         {
6068                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
6069                                         }
6070
6071                                         if (!p_ptr->resist_chaos && one_in_(3))
6072                                         {
6073                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
6074                                         }
6075
6076                                         p_ptr->csp -= 50;
6077                                         if (p_ptr->csp < 0)
6078                                         {
6079                                                 p_ptr->csp = 0;
6080                                                 p_ptr->csp_frac = 0;
6081                                         }
6082                                         p_ptr->redraw |= PR_MANA;
6083                                 }
6084
6085                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6086                         }
6087                         break;
6088                 }
6089
6090                 /* Brain smash */
6091                 case GF_BRAIN_SMASH:
6092                 {
6093                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
6094                         {
6095                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6096                                 learn_spell(monspell);
6097                         }
6098                         else
6099                         {
6100                                 if (!CHECK_MULTISHADOW())
6101                                 {
6102                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
6103
6104                                         p_ptr->csp -= 100;
6105                                         if (p_ptr->csp < 0)
6106                                         {
6107                                                 p_ptr->csp = 0;
6108                                                 p_ptr->csp_frac = 0;
6109                                         }
6110                                         p_ptr->redraw |= PR_MANA;
6111                                 }
6112
6113                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6114                                 if (!CHECK_MULTISHADOW())
6115                                 {
6116                                         if (!p_ptr->resist_blind)
6117                                         {
6118                                                 (void)set_blind(p_ptr->blind + 8 + randint0(8));
6119                                         }
6120                                         if (!p_ptr->resist_conf)
6121                                         {
6122                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
6123                                         }
6124                                         if (!p_ptr->free_act)
6125                                         {
6126                                                 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
6127                                         }
6128                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
6129
6130                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
6131                                                 (void)do_dec_stat(A_INT);
6132                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
6133                                                 (void)do_dec_stat(A_WIS);
6134
6135                                         if (!p_ptr->resist_chaos)
6136                                         {
6137                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
6138                                         }
6139                                 }
6140                         }
6141                         break;
6142                 }
6143
6144                 /* cause 1 */
6145                 case GF_CAUSE_1:
6146                 {
6147                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6148                         {
6149                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6150                                 learn_spell(monspell);
6151                         }
6152                         else
6153                         {
6154                                 if (!CHECK_MULTISHADOW()) curse_equipment(15, 0);
6155                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6156                         }
6157                         break;
6158                 }
6159
6160                 /* cause 2 */
6161                 case GF_CAUSE_2:
6162                 {
6163                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6164                         {
6165                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6166                                 learn_spell(monspell);
6167                         }
6168                         else
6169                         {
6170                                 if (!CHECK_MULTISHADOW()) curse_equipment(25, MIN(rlev / 2 - 15, 5));
6171                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6172                         }
6173                         break;
6174                 }
6175
6176                 /* cause 3 */
6177                 case GF_CAUSE_3:
6178                 {
6179                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6180                         {
6181                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6182                                 learn_spell(monspell);
6183                         }
6184                         else
6185                         {
6186                                 if (!CHECK_MULTISHADOW()) curse_equipment(33, MIN(rlev / 2 - 15, 15));
6187                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6188                         }
6189                         break;
6190                 }
6191
6192                 /* cause 4 */
6193                 case GF_CAUSE_4:
6194                 {
6195                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU) && !CHECK_MULTISHADOW())
6196                         {
6197                                 msg_print(_("しかし秘孔を跳ね返した!", "You resist the effects!"));
6198                                 learn_spell(monspell);
6199                         }
6200                         else
6201                         {
6202                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6203                                 if (!CHECK_MULTISHADOW()) (void)set_cut(p_ptr->cut + damroll(10, 10));
6204                         }
6205                         break;
6206                 }
6207
6208                 /* Hand of Doom */
6209                 case GF_HAND_DOOM:
6210                 {
6211                         if ((randint0(100 + rlev/2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6212                         {
6213                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6214                                 learn_spell(monspell);
6215                         }
6216                         else
6217                         {
6218                                 if (!CHECK_MULTISHADOW())
6219                                 {
6220                                         msg_print(_("あなたは命が薄まっていくように感じた!", "You feel your life fade away!"));
6221                                         curse_equipment(40, 20);
6222                                 }
6223
6224                                 get_damage = take_hit(DAMAGE_ATTACK, dam, m_name, monspell);
6225
6226                                 if (p_ptr->chp < 1) p_ptr->chp = 1; /* Paranoia */
6227                         }
6228                         break;
6229                 }
6230
6231                 /* Default */
6232                 default:
6233                 {
6234                         /* No damage */
6235                         dam = 0;
6236
6237                         break;
6238                 }
6239         }
6240
6241         /* Hex - revenge damage stored */
6242         revenge_store(get_damage);
6243
6244         if ((p_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
6245                 && (get_damage > 0) && !p_ptr->is_dead && (who > 0))
6246         {
6247                 char m_name_self[80];
6248
6249                 /* hisself */
6250                 monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
6251
6252                 msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
6253                 project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
6254                 if (p_ptr->tim_eyeeye) set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
6255         }
6256
6257         if (p_ptr->riding && dam > 0)
6258         {
6259                 rakubadam_p = (dam > 200) ? 200 : dam;
6260         }
6261
6262
6263         /* Disturb */
6264         disturb(1, 1);
6265
6266
6267         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
6268         {
6269                 (void)kawarimi(FALSE);
6270         }
6271
6272         /* Return "Anything seen?" */
6273         return (obvious);
6274 }
6275
6276
6277 /*
6278  * Find the distance from (x, y) to a line.
6279  */
6280 POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
6281 {
6282         /* Vector from (x, y) to (x1, y1) */
6283         POSITION py = y1 - y;
6284         POSITION px = x1 - x;
6285
6286         /* Normal vector */
6287         POSITION ny = x2 - x1;
6288         POSITION nx = y1 - y2;
6289
6290         /* Length of N */
6291         POSITION pd = distance(y1, x1, y, x);
6292         POSITION nd = distance(y1, x1, y2, x2);
6293
6294         if (pd > nd) return distance(y, x, y2, x2);
6295
6296         /* Component of P on N */
6297         nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
6298
6299         /* Absolute value */
6300         return((nd >= 0) ? nd : 0 - nd);
6301 }
6302
6303
6304
6305 /*
6306  * XXX XXX XXX
6307  * Modified version of los() for calculation of disintegration balls.
6308  * Disintegration effects are stopped by permanent walls.
6309  */
6310 bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
6311 {
6312         /* Delta */
6313         POSITION dx, dy;
6314
6315         /* Absolute */
6316         POSITION ax, ay;
6317
6318         /* Signs */
6319         POSITION sx, sy;
6320
6321         /* Fractions */
6322         POSITION qx, qy;
6323
6324         /* Scanners */
6325         POSITION tx, ty;
6326
6327         /* Scale factors */
6328         POSITION f1, f2;
6329
6330         /* Slope, or 1/Slope, of LOS */
6331         POSITION m;
6332
6333
6334         /* Extract the offset */
6335         dy = y2 - y1;
6336         dx = x2 - x1;
6337
6338         /* Extract the absolute offset */
6339         ay = ABS(dy);
6340         ax = ABS(dx);
6341
6342
6343         /* Handle adjacent (or identical) grids */
6344         if ((ax < 2) && (ay < 2)) return (TRUE);
6345
6346
6347         /* Paranoia -- require "safe" origin */
6348         /* if (!in_bounds(y1, x1)) return (FALSE); */
6349
6350
6351         /* Directly South/North */
6352         if (!dx)
6353         {
6354                 /* South -- check for walls */
6355                 if (dy > 0)
6356                 {
6357                         for (ty = y1 + 1; ty < y2; ty++)
6358                         {
6359                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
6360                         }
6361                 }
6362
6363                 /* North -- check for walls */
6364                 else
6365                 {
6366                         for (ty = y1 - 1; ty > y2; ty--)
6367                         {
6368                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
6369                         }
6370                 }
6371
6372                 /* Assume los */
6373                 return (TRUE);
6374         }
6375
6376         /* Directly East/West */
6377         if (!dy)
6378         {
6379                 /* East -- check for walls */
6380                 if (dx > 0)
6381                 {
6382                         for (tx = x1 + 1; tx < x2; tx++)
6383                         {
6384                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
6385                         }
6386                 }
6387
6388                 /* West -- check for walls */
6389                 else
6390                 {
6391                         for (tx = x1 - 1; tx > x2; tx--)
6392                         {
6393                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
6394                         }
6395                 }
6396
6397                 /* Assume los */
6398                 return (TRUE);
6399         }
6400
6401
6402         /* Extract some signs */
6403         sx = (dx < 0) ? -1 : 1;
6404         sy = (dy < 0) ? -1 : 1;
6405
6406
6407         /* Vertical "knights" */
6408         if (ax == 1)
6409         {
6410                 if (ay == 2)
6411                 {
6412                         if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
6413                 }
6414         }
6415
6416         /* Horizontal "knights" */
6417         else if (ay == 1)
6418         {
6419                 if (ax == 2)
6420                 {
6421                         if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
6422                 }
6423         }
6424
6425
6426         /* Calculate scale factor div 2 */
6427         f2 = (ax * ay);
6428
6429         /* Calculate scale factor */
6430         f1 = f2 << 1;
6431
6432
6433         /* Travel horizontally */
6434         if (ax >= ay)
6435         {
6436                 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
6437                 qy = ay * ay;
6438                 m = qy << 1;
6439
6440                 tx = x1 + sx;
6441
6442                 /* Consider the special case where slope == 1. */
6443                 if (qy == f2)
6444                 {
6445                         ty = y1 + sy;
6446                         qy -= f1;
6447                 }
6448                 else
6449                 {
6450                         ty = y1;
6451                 }
6452
6453                 /* Note (below) the case (qy == f2), where */
6454                 /* the LOS exactly meets the corner of a tile. */
6455                 while (x2 - tx)
6456                 {
6457                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6458
6459                         qy += m;
6460
6461                         if (qy < f2)
6462                         {
6463                                 tx += sx;
6464                         }
6465                         else if (qy > f2)
6466                         {
6467                                 ty += sy;
6468                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6469                                 qy -= f1;
6470                                 tx += sx;
6471                         }
6472                         else
6473                         {
6474                                 ty += sy;
6475                                 qy -= f1;
6476                                 tx += sx;
6477                         }
6478                 }
6479         }
6480
6481         /* Travel vertically */
6482         else
6483         {
6484                 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
6485                 qx = ax * ax;
6486                 m = qx << 1;
6487
6488                 ty = y1 + sy;
6489
6490                 if (qx == f2)
6491                 {
6492                         tx = x1 + sx;
6493                         qx -= f1;
6494                 }
6495                 else
6496                 {
6497                         tx = x1;
6498                 }
6499
6500                 /* Note (below) the case (qx == f2), where */
6501                 /* the LOS exactly meets the corner of a tile. */
6502                 while (y2 - ty)
6503                 {
6504                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6505
6506                         qx += m;
6507
6508                         if (qx < f2)
6509                         {
6510                                 ty += sy;
6511                         }
6512                         else if (qx > f2)
6513                         {
6514                                 tx += sx;
6515                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6516                                 qx -= f1;
6517                                 ty += sy;
6518                         }
6519                         else
6520                         {
6521                                 tx += sx;
6522                                 qx -= f1;
6523                                 ty += sy;
6524                         }
6525                 }
6526         }
6527
6528         /* Assume los */
6529         return (TRUE);
6530 }
6531
6532
6533 /*
6534  * breath shape
6535  */
6536 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)
6537 {
6538         POSITION by = y1;
6539         POSITION bx = x1;
6540         int brad = 0;
6541         int brev = rad * rad / dist;
6542         int bdis = 0;
6543         int cdis;
6544         int path_n = 0;
6545         int mdis = distance(y1, x1, y2, x2) + rad;
6546
6547         while (bdis <= mdis)
6548         {
6549                 int x, y;
6550
6551                 if ((0 < dist) && (path_n < dist))
6552                 {
6553                         int ny = GRID_Y(path_g[path_n]);
6554                         int nx = GRID_X(path_g[path_n]);
6555                         int nd = distance(ny, nx, y1, x1);
6556
6557                         /* Get next base point */
6558                         if (bdis >= nd)
6559                         {
6560                                 by = ny;
6561                                 bx = nx;
6562                                 path_n++;
6563                         }
6564                 }
6565
6566                 /* Travel from center outward */
6567                 for (cdis = 0; cdis <= brad; cdis++)
6568                 {
6569                         /* Scan the maximal blast area of radius "cdis" */
6570                         for (y = by - cdis; y <= by + cdis; y++)
6571                         {
6572                                 for (x = bx - cdis; x <= bx + cdis; x++)
6573                                 {
6574                                         /* Ignore "illegal" locations */
6575                                         if (!in_bounds(y, x)) continue;
6576
6577                                         /* Enforce a circular "ripple" */
6578                                         if (distance(y1, x1, y, x) != bdis) continue;
6579
6580                                         /* Enforce an arc */
6581                                         if (distance(by, bx, y, x) != cdis) continue;
6582
6583                                         switch (typ)
6584                                         {
6585                                         case GF_LITE:
6586                                         case GF_LITE_WEAK:
6587                                                 /* Lights are stopped by opaque terrains */
6588                                                 if (!los(by, bx, y, x)) continue;
6589                                                 break;
6590                                         case GF_DISINTEGRATE:
6591                                                 /* Disintegration are stopped only by perma-walls */
6592                                                 if (!in_disintegration_range(by, bx, y, x)) continue;
6593                                                 break;
6594                                         default:
6595                                                 /* Ball explosions are stopped by walls */
6596                                                 if (!projectable(by, bx, y, x)) continue;
6597                                                 break;
6598                                         }
6599
6600                                         /* Save this grid */
6601                                         gy[*pgrids] = y;
6602                                         gx[*pgrids] = x;
6603                                         (*pgrids)++;
6604                                 }
6605                         }
6606                 }
6607
6608                 /* Encode some more "radius" info */
6609                 gm[bdis + 1] = *pgrids;
6610
6611                 /* Increase the size */
6612                 brad = rad * (path_n + brev) / (dist + brev);
6613
6614                 /* Find the next ripple */
6615                 bdis++;
6616         }
6617
6618         /* Store the effect size */
6619         *pgm_rad = bdis;
6620 }
6621
6622
6623 /*!
6624  * @brief 汎用的なビーム/ボルト/ボール系処理のルーチン Generic "beam"/"bolt"/"ball" projection routine.
6625  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
6626  * @param rad 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
6627  * @param y 目標Y座標 / Target y location (or location to travel "towards")
6628  * @param x 目標X座標 / Target x location (or location to travel "towards")
6629  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
6630  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
6631  * @param flg 効果フラグ / Extra bit flags (see PROJECT_xxxx in "defines.h")
6632  * @param monspell 効果元のモンスター魔法ID
6633  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
6634  * @details
6635  * <pre>
6636  * Allows a monster (or player) to project a beam/bolt/ball of a given kind
6637  * towards a given location (optionally passing over the heads of interposing
6638  * monsters), and have it do a given amount of damage to the monsters (and
6639  * optionally objects) within the given radius of the final location.
6640  *
6641  * A "bolt" travels from source to target and affects only the target grid.
6642  * A "beam" travels from source to target, affecting all grids passed through.
6643  * A "ball" travels from source to the target, exploding at the target, and
6644  *   affecting everything within the given radius of the target location.
6645  *
6646  * Traditionally, a "bolt" does not affect anything on the ground, and does
6647  * not pass over the heads of interposing monsters, much like a traditional
6648  * missile, and will "stop" abruptly at the "target" even if no monster is
6649  * positioned there, while a "ball", on the other hand, passes over the heads
6650  * of monsters between the source and target, and affects everything except
6651  * the source monster which lies within the final radius, while a "beam"
6652  * affects every monster between the source and target, except for the casting
6653  * monster (or player), and rarely affects things on the ground.
6654  *
6655  * Two special flags allow us to use this function in special ways, the
6656  * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
6657  * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
6658  * actually projecting from the source monster (or player).
6659  *
6660  * The player will only get "experience" for monsters killed by himself
6661  * Unique monsters can only be destroyed by attacks from the player
6662  *
6663  * Only 256 grids can be affected per projection, limiting the effective
6664  * "radius" of standard ball attacks to nine units (diameter nineteen).
6665  *
6666  * One can project in a given "direction" by combining PROJECT_THRU with small
6667  * offsets to the initial location (see "line_spell()"), or by calculating
6668  * "virtual targets" far away from the player.
6669  *
6670  * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
6671  * continuing until it actually hits somethings (useful for "stone to mud").
6672  *
6673  * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
6674  *
6675  * Balls must explode BEFORE hitting walls, or they would affect monsters
6676  * on both sides of a wall.  Some bug reports indicate that this is still
6677  * happening in 2.7.8 for Windows, though it appears to be impossible.
6678  *
6679  * We "pre-calculate" the blast area only in part for efficiency.
6680  * More importantly, this lets us do "explosions" from the "inside" out.
6681  * This results in a more logical distribution of "blast" treasure.
6682  * It also produces a better (in my opinion) animation of the explosion.
6683  * It could be (but is not) used to have the treasure dropped by monsters
6684  * in the middle of the explosion fall "outwards", and then be damaged by
6685  * the blast as it spreads outwards towards the treasure drop location.
6686  *
6687  * Walls and doors are included in the blast area, so that they can be
6688  * "burned" or "melted" in later versions.
6689  *
6690  * This algorithm is intended to maximize simplicity, not necessarily
6691  * efficiency, since this function is not a bottleneck in the code.
6692  *
6693  * We apply the blast effect from ground zero outwards, in several passes,
6694  * first affecting features, then objects, then monsters, then the player.
6695  * This allows walls to be removed before checking the object or monster
6696  * in the wall, and protects objects which are dropped by monsters killed
6697  * in the blast, and allows the player to see all affects before he is
6698  * killed or teleported away.  The semantics of this method are open to
6699  * various interpretations, but they seem to work well in practice.
6700  *
6701  * We process the blast area from ground-zero outwards to allow for better
6702  * distribution of treasure dropped by monsters, and because it provides a
6703  * pleasing visual effect at low cost.
6704  *
6705  * Note that the damage done by "ball" explosions decreases with distance.
6706  * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
6707  *
6708  * Notice the "napalm" effect of "beam" weapons.  First they "project" to
6709  * the target, and then the damage "flows" along this beam of destruction.
6710  * The damage at every grid is the same as at the "center" of a "ball"
6711  * explosion, since the "beam" grids are treated as if they ARE at the
6712  * center of a "ball" explosion.
6713  *
6714  * Currently, specifying "beam" plus "ball" means that locations which are
6715  * covered by the initial "beam", and also covered by the final "ball", except
6716  * for the final grid (the epicenter of the ball), will be "hit twice", once
6717  * by the initial beam, and once by the exploding ball.  For the grid right
6718  * next to the epicenter, this results in 150% damage being done.  The center
6719  * does not have this problem, for the same reason the final grid in a "beam"
6720  * plus "bolt" does not -- it is explicitly removed.  Simply removing "beam"
6721  * grids which are covered by the "ball" will NOT work, as then they will
6722  * receive LESS damage than they should.  Do not combine "beam" with "ball".
6723  *
6724  * The array "gy[],gx[]" with current size "grids" is used to hold the
6725  * collected locations of all grids in the "blast area" plus "beam path".
6726  *
6727  * Note the rather complex usage of the "gm[]" array.  First, gm[0] is always
6728  * zero.  Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
6729  * first blast grid (see above) with radius "N" from the blast center.  Note
6730  * that only the first gm[1] grids in the blast area thus take full damage.
6731  * Also, note that gm[rad+1] is always equal to "grids", which is the total
6732  * number of blast grids.
6733  *
6734  * Note that once the projection is complete, (y2,x2) holds the final location
6735  * of bolts/beams, and the "epicenter" of balls.
6736  *
6737  * Note also that "rad" specifies the "inclusive" radius of projection blast,
6738  * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
6739  * implementation of the "distance" function.  Also, a bolt can be properly
6740  * viewed as a "ball" with a "rad" of "zero".
6741  *
6742  * Note that if no "target" is reached before the beam/bolt/ball travels the
6743  * maximum distance allowed (MAX_RANGE), no "blast" will be induced.  This
6744  * may be relevant even for bolts, since they have a "1x1" mini-blast.
6745  *
6746  * Note that for consistency, we "pretend" that the bolt actually takes "time"
6747  * to move from point A to point B, even if the player cannot see part of the
6748  * projection path.  Note that in general, the player will *always* see part
6749  * of the path, since it either starts at the player or ends on the player.
6750  *
6751  * Hack -- we assume that every "projection" is "self-illuminating".
6752  *
6753  * Hack -- when only a single monster is affected, we automatically track
6754  * (and recall) that monster, unless "PROJECT_JUMP" is used.
6755  *
6756  * Note that all projections now "explode" at their final destination, even
6757  * if they were being projected at a more distant destination.  This means
6758  * that "ball" spells will *always* explode.
6759  *
6760  * Note that we must call "handle_stuff()" after affecting terrain features
6761  * in the blast radius, in case the "illumination" of the grid was changed,
6762  * and "update_view()" and "update_monsters()" need to be called.
6763  * </pre>
6764  */
6765 bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, int typ, BIT_FLAGS flg, int monspell)
6766 {
6767         int i, t, dist;
6768
6769         POSITION y1, x1;
6770         POSITION y2, x2;
6771         POSITION by, bx;
6772
6773         int dist_hack = 0;
6774
6775         POSITION y_saver, x_saver; /* For reflecting monsters */
6776
6777         int msec = delay_factor * delay_factor * delay_factor;
6778
6779         /* Assume the player sees nothing */
6780         bool notice = FALSE;
6781
6782         /* Assume the player has seen nothing */
6783         bool visual = FALSE;
6784
6785         /* Assume the player has seen no blast grids */
6786         bool drawn = FALSE;
6787
6788         /* Assume to be a normal ball spell */
6789         bool breath = FALSE;
6790
6791         /* Is the player blind? */
6792         bool blind = (p_ptr->blind ? TRUE : FALSE);
6793
6794         bool old_hide = FALSE;
6795
6796         /* Number of grids in the "path" */
6797         int path_n = 0;
6798
6799         /* Actual grids in the "path" */
6800         u16b path_g[512];
6801
6802         /* Number of grids in the "blast area" (including the "beam" path) */
6803         int grids = 0;
6804
6805         /* Coordinates of the affected grids */
6806         POSITION gx[1024], gy[1024];
6807
6808         /* Encoded "radius" info (see above) */
6809         POSITION gm[32];
6810
6811         /* Actual radius encoded in gm[] */
6812         POSITION gm_rad = rad;
6813
6814         bool jump = FALSE;
6815
6816         /* Attacker's name (prepared before polymorph)*/
6817         char who_name[80];
6818
6819         /* Can the player see the source of this effect? */
6820         bool see_s_msg = TRUE;
6821
6822         /* Initialize by null string */
6823         who_name[0] = '\0';
6824
6825         rakubadam_p = 0;
6826         rakubadam_m = 0;
6827
6828         /* Default target of monsterspell is player */
6829         monster_target_y = p_ptr->y;
6830         monster_target_x = p_ptr->x;
6831
6832         /* Hack -- Jump to target */
6833         if (flg & (PROJECT_JUMP))
6834         {
6835                 x1 = x;
6836                 y1 = y;
6837
6838                 /* Clear the flag */
6839                 flg &= ~(PROJECT_JUMP);
6840
6841                 jump = TRUE;
6842         }
6843
6844         /* Start at player */
6845         else if (who <= 0)
6846         {
6847                 x1 = p_ptr->x;
6848                 y1 = p_ptr->y;
6849         }
6850
6851         /* Start at monster */
6852         else if (who > 0)
6853         {
6854                 x1 = m_list[who].fx;
6855                 y1 = m_list[who].fy;
6856                 monster_desc(who_name, &m_list[who], MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
6857         }
6858
6859         /* Oops */
6860         else
6861         {
6862                 x1 = x;
6863                 y1 = y;
6864         }
6865
6866         y_saver = y1;
6867         x_saver = x1;
6868
6869         /* Default "destination" */
6870         y2 = y;
6871         x2 = x;
6872
6873
6874         /* Hack -- verify stuff */
6875         if (flg & (PROJECT_THRU))
6876         {
6877                 if ((x1 == x2) && (y1 == y2))
6878                 {
6879                         flg &= ~(PROJECT_THRU);
6880                 }
6881         }
6882
6883         /* Handle a breath attack */
6884         if (rad < 0)
6885         {
6886                 rad = 0 - rad;
6887                 breath = TRUE;
6888                 if (flg & PROJECT_HIDE) old_hide = TRUE;
6889                 flg |= PROJECT_HIDE;
6890         }
6891
6892
6893         /* Hack -- Assume there will be no blast (max radius 32) */
6894         for (dist = 0; dist < 32; dist++) gm[dist] = 0;
6895
6896
6897         /* Initial grid */
6898         y = y1;
6899         x = x1;
6900         dist = 0;
6901
6902         /* Collect beam grids */
6903         if (flg & (PROJECT_BEAM))
6904         {
6905                 gy[grids] = y;
6906                 gx[grids] = x;
6907                 grids++;
6908         }
6909
6910         switch (typ)
6911         {
6912         case GF_LITE:
6913         case GF_LITE_WEAK:
6914                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_LOS);
6915                 break;
6916         case GF_DISINTEGRATE:
6917                 flg |= (PROJECT_GRID);
6918                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_DISI);
6919                 break;
6920         }
6921
6922         /* Calculate the projection path */
6923
6924         path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
6925
6926         /* Hack -- Handle stuff */
6927         handle_stuff();
6928
6929         /* Giga-Hack SEEKER & SUPER_RAY */
6930
6931         if( typ == GF_SEEKER )
6932         {
6933                 int j;
6934                 int last_i=0;
6935
6936                 /* Mega-Hack */
6937                 project_m_n = 0;
6938                 project_m_x = 0;
6939                 project_m_y = 0;
6940
6941                 for (i = 0; i < path_n; ++i)
6942                 {
6943                         int oy = y;
6944                         int ox = x;
6945
6946                         int ny = GRID_Y(path_g[i]);
6947                         int nx = GRID_X(path_g[i]);
6948
6949                         /* Advance */
6950                         y = ny;
6951                         x = nx;
6952
6953                         gy[grids] = y;
6954                         gx[grids] = x;
6955                         grids++;
6956
6957
6958                         /* Only do visuals if requested */
6959                         if (!blind && !(flg & (PROJECT_HIDE)))
6960                         {
6961                                 /* Only do visuals if the player can "see" the bolt */
6962                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6963                                 {
6964                                         u16b p;
6965
6966                                         byte a;
6967                                         char c;
6968
6969                                         /* Obtain the bolt pict */
6970                                         p = bolt_pict(oy, ox, y, x, typ);
6971
6972                                         /* Extract attr/char */
6973                                         a = PICT_A(p);
6974                                         c = PICT_C(p);
6975
6976                                         /* Visual effects */
6977                                         print_rel(c, a, y, x);
6978                                         move_cursor_relative(y, x);
6979                                         /*if (fresh_before)*/ Term_fresh();
6980                                         Term_xtra(TERM_XTRA_DELAY, msec);
6981                                         lite_spot(y, x);
6982                                         /*if (fresh_before)*/ Term_fresh();
6983
6984                                         /* Display "beam" grids */
6985                                         if (flg & (PROJECT_BEAM))
6986                                         {
6987                                                 /* Obtain the explosion pict */
6988                                                 p = bolt_pict(y, x, y, x, typ);
6989
6990                                                 /* Extract attr/char */
6991                                                 a = PICT_A(p);
6992                                                 c = PICT_C(p);
6993
6994                                                 /* Visual effects */
6995                                                 print_rel(c, a, y, x);
6996                                         }
6997
6998                                         /* Hack -- Activate delay */
6999                                         visual = TRUE;
7000                                 }
7001
7002                                 /* Hack -- delay anyway for consistency */
7003                                 else if (visual)
7004                                 {
7005                                         /* Delay for consistency */
7006                                         Term_xtra(TERM_XTRA_DELAY, msec);
7007                                 }
7008                         }
7009                         if(project_o(0,0,y,x,dam,GF_SEEKER))notice=TRUE;
7010                         if( is_mirror_grid(&cave[y][x]))
7011                         {
7012                           /* The target of monsterspell becomes tha mirror(broken) */
7013                                 monster_target_y=(s16b)y;
7014                                 monster_target_x=(s16b)x;
7015
7016                                 remove_mirror(y, x);
7017                                 next_mirror(&oy, &ox, y, x);
7018
7019                                 path_n = i+project_path(&(path_g[i+1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
7020                                 for(j = last_i; j <= i; j++)
7021                                 {
7022                                         y = GRID_Y(path_g[j]);
7023                                         x = GRID_X(path_g[j]);
7024                                         if(project_m(0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice=TRUE;
7025                                         if(!who && (project_m_n==1) && !jump ){
7026                                           if(cave[project_m_y][project_m_x].m_idx >0 ){
7027                                                 monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
7028
7029                                                 if (m_ptr->ml)
7030                                                 {
7031                                                   /* Hack -- auto-recall */
7032                                                   if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7033
7034                                                   /* Hack - auto-track */
7035                                                   health_track(cave[project_m_y][project_m_x].m_idx);
7036                                                 }
7037                                           }
7038                                         }
7039                                         (void)project_f(0,0,y,x,dam,GF_SEEKER);
7040                                 }
7041                                 last_i = i;
7042                         }
7043                 }
7044                 for(i = last_i ; i < path_n ; i++)
7045                 {
7046                         int py, px;
7047                         py = GRID_Y(path_g[i]);
7048                         px = GRID_X(path_g[i]);
7049                         if(project_m(0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
7050                                 notice = TRUE;
7051                         if(!who && (project_m_n==1) && !jump ){
7052                                 if(cave[project_m_y][project_m_x].m_idx > 0)
7053                                 {
7054                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
7055
7056                                         if (m_ptr->ml)
7057                                         {
7058                                                 /* Hack -- auto-recall */
7059                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7060
7061                                                 /* Hack - auto-track */
7062                                                 health_track(cave[project_m_y][project_m_x].m_idx);
7063                                         }
7064                                 }
7065                         }
7066                         (void)project_f(0, 0, py, px, dam, GF_SEEKER);
7067                 }
7068                 return notice;
7069         }
7070         else if(typ == GF_SUPER_RAY){
7071                 int j;
7072                 int second_step = 0;
7073
7074                 /* Mega-Hack */
7075                 project_m_n = 0;
7076                 project_m_x = 0;
7077                 project_m_y = 0;
7078
7079                 for (i = 0; i < path_n; ++i)
7080                 {
7081                         int oy = y;
7082                         int ox = x;
7083
7084                         int ny = GRID_Y(path_g[i]);
7085                         int nx = GRID_X(path_g[i]);
7086
7087                         /* Advance */
7088                         y = ny;
7089                         x = nx;
7090
7091                         gy[grids] = y;
7092                         gx[grids] = x;
7093                         grids++;
7094
7095
7096                         /* Only do visuals if requested */
7097                         if (!blind && !(flg & (PROJECT_HIDE)))
7098                         {
7099                                 /* Only do visuals if the player can "see" the bolt */
7100                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7101                                 {
7102                                         u16b p;
7103
7104                                         byte a;
7105                                         char c;
7106
7107                                         /* Obtain the bolt pict */
7108                                         p = bolt_pict(oy, ox, y, x, typ);
7109
7110                                         /* Extract attr/char */
7111                                         a = PICT_A(p);
7112                                         c = PICT_C(p);
7113
7114                                         /* Visual effects */
7115                                         print_rel(c, a, y, x);
7116                                         move_cursor_relative(y, x);
7117                                         /*if (fresh_before)*/ Term_fresh();
7118                                         Term_xtra(TERM_XTRA_DELAY, msec);
7119                                         lite_spot(y, x);
7120                                         /*if (fresh_before)*/ Term_fresh();
7121
7122                                         /* Display "beam" grids */
7123                                         if (flg & (PROJECT_BEAM))
7124                                         {
7125                                                 /* Obtain the explosion pict */
7126                                                 p = bolt_pict(y, x, y, x, typ);
7127
7128                                                 /* Extract attr/char */
7129                                                 a = PICT_A(p);
7130                                                 c = PICT_C(p);
7131
7132                                                 /* Visual effects */
7133                                                 print_rel(c, a, y, x);
7134                                         }
7135
7136                                         /* Hack -- Activate delay */
7137                                         visual = TRUE;
7138                                 }
7139
7140                                 /* Hack -- delay anyway for consistency */
7141                                 else if (visual)
7142                                 {
7143                                         /* Delay for consistency */
7144                                         Term_xtra(TERM_XTRA_DELAY, msec);
7145                                 }
7146                         }
7147                         if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
7148                         if (!cave_have_flag_bold(y, x, FF_PROJECT))
7149                         {
7150                                 if( second_step )continue;
7151                                 break;
7152                         }
7153                         if( is_mirror_grid(&cave[y][x]) && !second_step )
7154                         {
7155                           /* The target of monsterspell becomes tha mirror(broken) */
7156                                 monster_target_y=(s16b)y;
7157                                 monster_target_x=(s16b)x;
7158
7159                                 remove_mirror(y,x);
7160                                 for( j = 0; j <=i ; j++ )
7161                                 {
7162                                         y = GRID_Y(path_g[j]);
7163                                         x = GRID_X(path_g[j]);
7164                                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
7165                                 }
7166                                 path_n = i;
7167                                 second_step =i+1;
7168                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
7169                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
7170                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
7171                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , 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+1, x-1, flg);
7174                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
7175                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
7176                         }
7177                 }
7178                 for( i = 0; i < path_n ; i++ )
7179                 {
7180                         int py, px;
7181                         py = GRID_Y(path_g[i]);
7182                         px = GRID_X(path_g[i]);
7183                         (void)project_m(0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
7184                         if(!who && (project_m_n == 1) && !jump){
7185                                 if(cave[project_m_y][project_m_x].m_idx >0 ){
7186                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
7187
7188                                         if (m_ptr->ml)
7189                                         {
7190                                                 /* Hack -- auto-recall */
7191                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7192
7193                                                 /* Hack - auto-track */
7194                                                 health_track(cave[project_m_y][project_m_x].m_idx);
7195                                         }
7196                                 }
7197                         }
7198                         (void)project_f(0, 0, py, px, dam, GF_SUPER_RAY);
7199                 }
7200                 return notice;
7201         }
7202
7203         /* Project along the path */
7204         for (i = 0; i < path_n; ++i)
7205         {
7206                 int oy = y;
7207                 int ox = x;
7208
7209                 int ny = GRID_Y(path_g[i]);
7210                 int nx = GRID_X(path_g[i]);
7211
7212                 if (flg & PROJECT_DISI)
7213                 {
7214                         /* Hack -- Balls explode before reaching walls */
7215                         if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
7216                 }
7217                 else if (flg & PROJECT_LOS)
7218                 {
7219                         /* Hack -- Balls explode before reaching walls */
7220                         if (!cave_los_bold(ny, nx) && (rad > 0)) break;
7221                 }
7222                 else
7223                 {
7224                         /* Hack -- Balls explode before reaching walls */
7225                         if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && (rad > 0)) break;
7226                 }
7227
7228                 /* Advance */
7229                 y = ny;
7230                 x = nx;
7231
7232                 /* Collect beam grids */
7233                 if (flg & (PROJECT_BEAM))
7234                 {
7235                         gy[grids] = y;
7236                         gx[grids] = x;
7237                         grids++;
7238                 }
7239
7240                 /* Only do visuals if requested */
7241                 if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
7242                 {
7243                         /* Only do visuals if the player can "see" the bolt */
7244                         if (panel_contains(y, x) && player_has_los_bold(y, x))
7245                         {
7246                                 u16b p;
7247
7248                                 byte a;
7249                                 char c;
7250
7251                                 /* Obtain the bolt pict */
7252                                 p = bolt_pict(oy, ox, y, x, typ);
7253
7254                                 /* Extract attr/char */
7255                                 a = PICT_A(p);
7256                                 c = PICT_C(p);
7257
7258                                 /* Visual effects */
7259                                 print_rel(c, a, y, x);
7260                                 move_cursor_relative(y, x);
7261                                 /*if (fresh_before)*/ Term_fresh();
7262                                 Term_xtra(TERM_XTRA_DELAY, msec);
7263                                 lite_spot(y, x);
7264                                 /*if (fresh_before)*/ Term_fresh();
7265
7266                                 /* Display "beam" grids */
7267                                 if (flg & (PROJECT_BEAM))
7268                                 {
7269                                         /* Obtain the explosion pict */
7270                                         p = bolt_pict(y, x, y, x, typ);
7271
7272                                         /* Extract attr/char */
7273                                         a = PICT_A(p);
7274                                         c = PICT_C(p);
7275
7276                                         /* Visual effects */
7277                                         print_rel(c, a, y, x);
7278                                 }
7279
7280                                 /* Hack -- Activate delay */
7281                                 visual = TRUE;
7282                         }
7283
7284                         /* Hack -- delay anyway for consistency */
7285                         else if (visual)
7286                         {
7287                                 /* Delay for consistency */
7288                                 Term_xtra(TERM_XTRA_DELAY, msec);
7289                         }
7290                 }
7291         }
7292
7293         path_n = i;
7294
7295         /* Save the "blast epicenter" */
7296         by = y;
7297         bx = x;
7298
7299         if (breath && !path_n)
7300         {
7301                 breath = FALSE;
7302                 gm_rad = rad;
7303                 if (!old_hide)
7304                 {
7305                         flg &= ~(PROJECT_HIDE);
7306                 }
7307         }
7308
7309         /* Start the "explosion" */
7310         gm[0] = 0;
7311
7312         /* Hack -- make sure beams get to "explode" */
7313         gm[1] = grids;
7314
7315         dist = path_n;
7316         dist_hack = dist;
7317
7318         project_length = 0;
7319
7320         /* If we found a "target", explode there */
7321         if (dist <= MAX_RANGE)
7322         {
7323                 /* Mega-Hack -- remove the final "beam" grid */
7324                 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
7325
7326                 /*
7327                  * Create a conical breath attack
7328                  *
7329                  *       ***
7330                  *   ********
7331                  * D********@**
7332                  *   ********
7333                  *       ***
7334                  */
7335
7336                 if (breath)
7337                 {
7338                         flg &= ~(PROJECT_HIDE);
7339
7340                         breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
7341                 }
7342                 else
7343                 {
7344                         /* Determine the blast area, work from the inside out */
7345                         for (dist = 0; dist <= rad; dist++)
7346                         {
7347                                 /* Scan the maximal blast area of radius "dist" */
7348                                 for (y = by - dist; y <= by + dist; y++)
7349                                 {
7350                                         for (x = bx - dist; x <= bx + dist; x++)
7351                                         {
7352                                                 /* Ignore "illegal" locations */
7353                                                 if (!in_bounds2(y, x)) continue;
7354
7355                                                 /* Enforce a "circular" explosion */
7356                                                 if (distance(by, bx, y, x) != dist) continue;
7357
7358                                                 switch (typ)
7359                                                 {
7360                                                 case GF_LITE:
7361                                                 case GF_LITE_WEAK:
7362                                                         /* Lights are stopped by opaque terrains */
7363                                                         if (!los(by, bx, y, x)) continue;
7364                                                         break;
7365                                                 case GF_DISINTEGRATE:
7366                                                         /* Disintegration are stopped only by perma-walls */
7367                                                         if (!in_disintegration_range(by, bx, y, x)) continue;
7368                                                         break;
7369                                                 default:
7370                                                         /* Ball explosions are stopped by walls */
7371                                                         if (!projectable(by, bx, y, x)) continue;
7372                                                         break;
7373                                                 }
7374
7375                                                 /* Save this grid */
7376                                                 gy[grids] = y;
7377                                                 gx[grids] = x;
7378                                                 grids++;
7379                                         }
7380                                 }
7381
7382                                 /* Encode some more "radius" info */
7383                                 gm[dist+1] = grids;
7384                         }
7385                 }
7386         }
7387
7388         /* Speed -- ignore "non-explosions" */
7389         if (!grids) return (FALSE);
7390
7391
7392         /* Display the "blast area" if requested */
7393         if (!blind && !(flg & (PROJECT_HIDE)))
7394         {
7395                 /* Then do the "blast", from inside out */
7396                 for (t = 0; t <= gm_rad; t++)
7397                 {
7398                         /* Dump everything with this radius */
7399                         for (i = gm[t]; i < gm[t+1]; i++)
7400                         {
7401                                 /* Extract the location */
7402                                 y = gy[i];
7403                                 x = gx[i];
7404
7405                                 /* Only do visuals if the player can "see" the blast */
7406                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7407                                 {
7408                                         u16b p;
7409
7410                                         byte a;
7411                                         char c;
7412
7413                                         drawn = TRUE;
7414
7415                                         /* Obtain the explosion pict */
7416                                         p = bolt_pict(y, x, y, x, typ);
7417
7418                                         /* Extract attr/char */
7419                                         a = PICT_A(p);
7420                                         c = PICT_C(p);
7421
7422                                         /* Visual effects -- Display */
7423                                         print_rel(c, a, y, x);
7424                                 }
7425                         }
7426
7427                         /* Hack -- center the cursor */
7428                         move_cursor_relative(by, bx);
7429
7430                         /* Flush each "radius" seperately */
7431                         /*if (fresh_before)*/ Term_fresh();
7432
7433                         /* Delay (efficiently) */
7434                         if (visual || drawn)
7435                         {
7436                                 Term_xtra(TERM_XTRA_DELAY, msec);
7437                         }
7438                 }
7439
7440                 /* Flush the erasing */
7441                 if (drawn)
7442                 {
7443                         /* Erase the explosion drawn above */
7444                         for (i = 0; i < grids; i++)
7445                         {
7446                                 /* Extract the location */
7447                                 y = gy[i];
7448                                 x = gx[i];
7449
7450                                 /* Hack -- Erase if needed */
7451                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7452                                 {
7453                                         lite_spot(y, x);
7454                                 }
7455                         }
7456
7457                         /* Hack -- center the cursor */
7458                         move_cursor_relative(by, bx);
7459
7460                         /* Flush the explosion */
7461                         /*if (fresh_before)*/ Term_fresh();
7462                 }
7463         }
7464
7465
7466         /* Update stuff if needed */
7467         if (p_ptr->update) update_stuff();
7468
7469
7470         if (flg & PROJECT_KILL)
7471         {
7472                 see_s_msg = (who > 0) ? is_seen(&m_list[who]) :
7473                         (!who ? TRUE : (player_can_see_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)));
7474         }
7475
7476
7477         /* Check features */
7478         if (flg & (PROJECT_GRID))
7479         {
7480                 /* Start with "dist" of zero */
7481                 dist = 0;
7482
7483                 /* Scan for features */
7484                 for (i = 0; i < grids; i++)
7485                 {
7486                         /* Hack -- Notice new "dist" values */
7487                         if (gm[dist+1] == i) dist++;
7488
7489                         /* Get the grid location */
7490                         y = gy[i];
7491                         x = gx[i];
7492
7493                         /* Find the closest point in the blast */
7494                         if (breath)
7495                         {
7496                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7497
7498                                 /* Affect the grid */
7499                                 if (project_f(who, d, y, x, dam, typ)) notice = TRUE;
7500                         }
7501                         else
7502                         {
7503                                 /* Affect the grid */
7504                                 if (project_f(who, dist, y, x, dam, typ)) notice = TRUE;
7505                         }
7506                 }
7507         }
7508
7509         /* Update stuff if needed */
7510         if (p_ptr->update) update_stuff();
7511
7512         /* Check objects */
7513         if (flg & (PROJECT_ITEM))
7514         {
7515                 /* Start with "dist" of zero */
7516                 dist = 0;
7517
7518                 /* Scan for objects */
7519                 for (i = 0; i < grids; i++)
7520                 {
7521                         /* Hack -- Notice new "dist" values */
7522                         if (gm[dist+1] == i) dist++;
7523
7524                         /* Get the grid location */
7525                         y = gy[i];
7526                         x = gx[i];
7527
7528                         /* Find the closest point in the blast */
7529                         if (breath)
7530                         {
7531                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7532
7533                                 /* Affect the object in the grid */
7534                                 if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
7535                         }
7536                         else
7537                         {
7538                                 /* Affect the object in the grid */
7539                                 if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
7540                         }
7541                 }
7542         }
7543
7544
7545         /* Check monsters */
7546         if (flg & (PROJECT_KILL))
7547         {
7548                 /* Mega-Hack */
7549                 project_m_n = 0;
7550                 project_m_x = 0;
7551                 project_m_y = 0;
7552
7553                 /* Start with "dist" of zero */
7554                 dist = 0;
7555
7556                 /* Scan for monsters */
7557                 for (i = 0; i < grids; i++)
7558                 {
7559                         int effective_dist;
7560
7561                         /* Hack -- Notice new "dist" values */
7562                         if (gm[dist + 1] == i) dist++;
7563
7564                         /* Get the grid location */
7565                         y = gy[i];
7566                         x = gx[i];
7567
7568                         /* A single bolt may be reflected */
7569                         if (grids <= 1)
7570                         {
7571                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7572                                 monster_race *ref_ptr = &r_info[m_ptr->r_idx];
7573
7574                                 if ((flg & PROJECT_REFLECTABLE) && cave[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
7575                                         ((cave[y][x].m_idx != p_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
7576                                         (!who || dist_hack > 1) && !one_in_(10))
7577                                 {
7578                                         POSITION t_y, t_x;
7579                                         int max_attempts = 10;
7580
7581                                         /* Choose 'new' target */
7582                                         do
7583                                         {
7584                                                 t_y = y_saver - 1 + randint1(3);
7585                                                 t_x = x_saver - 1 + randint1(3);
7586                                                 max_attempts--;
7587                                         }
7588                                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(y, x, t_y, t_x));
7589
7590                                         if (max_attempts < 1)
7591                                         {
7592                                                 t_y = y_saver;
7593                                                 t_x = x_saver;
7594                                         }
7595
7596                                         sound(SOUND_REFLECT);
7597                                         if (is_seen(m_ptr))
7598                                         {
7599                                                 if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
7600                                                         msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!"));
7601                                                 else if (m_ptr->r_idx == MON_DIO) 
7602                                                         msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!"));
7603                                                 else 
7604                                                         msg_print(_("攻撃は跳ね返った!", "The attack bounces!"));
7605                                         }
7606                                         if (is_original_ap_and_seen(m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
7607
7608                                         /* Reflected bolts randomly target either one */
7609                                         if (player_bold(y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
7610                                         else flg |= PROJECT_PLAYER;
7611
7612                                         /* The bolt is reflected */
7613                                         project(cave[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
7614
7615                                         /* Don't affect the monster any longer */
7616                                         continue;
7617                                 }
7618                         }
7619
7620
7621                         /* Find the closest point in the blast */
7622                         if (breath)
7623                         {
7624                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7625                         }
7626                         else
7627                         {
7628                                 effective_dist = dist;
7629                         }
7630
7631
7632                         /* There is the riding player on this monster */
7633                         if (p_ptr->riding && player_bold(y, x))
7634                         {
7635                                 /* Aimed on the player */
7636                                 if (flg & PROJECT_PLAYER)
7637                                 {
7638                                         if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7639                                         {
7640                                                 /*
7641                                                  * A beam or bolt is well aimed
7642                                                  * at the PLAYER!
7643                                                  * So don't affects the mount.
7644                                                  */
7645                                                 continue;
7646                                         }
7647                                         else
7648                                         {
7649                                                 /*
7650                                                  * The spell is not well aimed, 
7651                                                  * So partly affect the mount too.
7652                                                  */
7653                                                 effective_dist++;
7654                                         }
7655                                 }
7656
7657                                 /*
7658                                  * This grid is the original target.
7659                                  * Or aimed on your horse.
7660                                  */
7661                                 else if (((y == y2) && (x == x2)) || (flg & PROJECT_AIMED))
7662                                 {
7663                                         /* Hit the mount with full damage */
7664                                 }
7665
7666                                 /*
7667                                  * Otherwise this grid is not the
7668                                  * original target, it means that line
7669                                  * of fire is obstructed by this
7670                                  * monster.
7671                                  */
7672                                 /*
7673                                  * A beam or bolt will hit either
7674                                  * player or mount.  Choose randomly.
7675                                  */
7676                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
7677                                 {
7678                                         if (one_in_(2))
7679                                         {
7680                                                 /* Hit the mount with full damage */
7681                                         }
7682                                         else
7683                                         {
7684                                                 /* Hit the player later */
7685                                                 flg |= PROJECT_PLAYER;
7686
7687                                                 /* Don't affect the mount */
7688                                                 continue;
7689                                         }
7690                                 }
7691
7692                                 /*
7693                                  * The spell is not well aimed, so
7694                                  * partly affect both player and
7695                                  * mount.
7696                                  */
7697                                 else
7698                                 {
7699                                         effective_dist++;
7700                                 }
7701                         }
7702
7703                         /* Affect the monster in the grid */
7704                         if (project_m(who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
7705                 }
7706
7707
7708                 /* Player affected one monster (without "jumping") */
7709                 if (!who && (project_m_n == 1) && !jump)
7710                 {
7711                         /* Location */
7712                         x = project_m_x;
7713                         y = project_m_y;
7714
7715                         /* Track if possible */
7716                         if (cave[y][x].m_idx > 0)
7717                         {
7718                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7719
7720                                 if (m_ptr->ml)
7721                                 {
7722                                         /* Hack -- auto-recall */
7723                                         if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7724
7725                                         /* Hack - auto-track */
7726                                         if (m_ptr->ml) health_track(cave[y][x].m_idx);
7727                                 }
7728                         }
7729                 }
7730         }
7731
7732
7733         /* Check player */
7734         if (flg & (PROJECT_KILL))
7735         {
7736                 /* Start with "dist" of zero */
7737                 dist = 0;
7738
7739                 /* Scan for player */
7740                 for (i = 0; i < grids; i++)
7741                 {
7742                         int effective_dist;
7743
7744                         /* Hack -- Notice new "dist" values */
7745                         if (gm[dist+1] == i) dist++;
7746
7747                         /* Get the grid location */
7748                         y = gy[i];
7749                         x = gx[i];
7750
7751                         /* Affect the player? */
7752                         if (!player_bold(y, x)) continue;
7753
7754                         /* Find the closest point in the blast */
7755                         if (breath)
7756                         {
7757                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7758                         }
7759                         else
7760                         {
7761                                 effective_dist = dist;
7762                         }
7763
7764                         /* Target may be your horse */
7765                         if (p_ptr->riding)
7766                         {
7767                                 /* Aimed on the player */
7768                                 if (flg & PROJECT_PLAYER)
7769                                 {
7770                                         /* Hit the player with full damage */
7771                                 }
7772
7773                                 /*
7774                                  * Hack -- When this grid was not the
7775                                  * original target, a beam or bolt
7776                                  * would hit either player or mount,
7777                                  * and should be choosen randomly.
7778                                  *
7779                                  * But already choosen to hit the
7780                                  * mount at this point.
7781                                  *
7782                                  * Or aimed on your horse.
7783                                  */
7784                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7785                                 {
7786                                         /*
7787                                          * A beam or bolt is well aimed
7788                                          * at the mount!
7789                                          * So don't affects the player.
7790                                          */
7791                                         continue;
7792                                 }
7793                                 else
7794                                 {
7795                                         /*
7796                                          * The spell is not well aimed, 
7797                                          * So partly affect the player too.
7798                                          */
7799                                         effective_dist++;
7800                                 }
7801                         }
7802
7803                         /* Affect the player */
7804                         if (project_p(who, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
7805                 }
7806         }
7807
7808         if (p_ptr->riding)
7809         {
7810                 char m_name[80];
7811
7812                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
7813
7814                 if (rakubadam_m > 0)
7815                 {
7816                         if (rakuba(rakubadam_m, FALSE))
7817                         {
7818                                 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
7819                         }
7820                 }
7821                 if (p_ptr->riding && rakubadam_p > 0)
7822                 {
7823                         if(rakuba(rakubadam_p, FALSE))
7824                         {
7825                                 msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name);
7826                         }
7827                 }
7828         }
7829
7830         /* Return "something was noticed" */
7831         return (notice);
7832 }
7833
7834 /*!
7835  * @brief 鏡魔法「封魔結界」の効果処理
7836  * @param dam ダメージ量
7837  * @return 効果があったらTRUEを返す
7838  */
7839 bool binding_field( HIT_POINT dam )
7840 {
7841         int mirror_x[10],mirror_y[10]; /* 鏡はもっと少ない */
7842         int mirror_num=0;                         /* 鏡の数 */
7843         int x,y;
7844         int centersign;
7845         int x1,x2,y1,y2;
7846         u16b p;
7847         int msec= delay_factor*delay_factor*delay_factor;
7848
7849         /* 三角形の頂点 */
7850         int point_x[3];
7851         int point_y[3];
7852
7853         /* Default target of monsterspell is player */
7854         monster_target_y=p_ptr->y;
7855         monster_target_x=p_ptr->x;
7856
7857         for( x=0 ; x < cur_wid ; x++ )
7858         {
7859                 for( y=0 ; y < cur_hgt ; y++ )
7860                 {
7861                         if( is_mirror_grid(&cave[y][x]) &&
7862                                 distance(p_ptr->y,p_ptr->x,y,x) <= MAX_RANGE &&
7863                                 distance(p_ptr->y,p_ptr->x,y,x) != 0 &&
7864                                 player_has_los_bold(y,x) &&
7865                                 projectable(p_ptr->y, p_ptr->x, y, x)
7866                                 ){
7867                                 mirror_y[mirror_num]=y;
7868                                 mirror_x[mirror_num]=x;
7869                                 mirror_num++;
7870                         }
7871                 }
7872         }
7873
7874         if( mirror_num < 2 )return FALSE;
7875
7876         point_x[0] = randint0( mirror_num );
7877         do {
7878           point_x[1] = randint0( mirror_num );
7879         }
7880         while( point_x[0] == point_x[1] );
7881
7882         point_y[0]=mirror_y[point_x[0]];
7883         point_x[0]=mirror_x[point_x[0]];
7884         point_y[1]=mirror_y[point_x[1]];
7885         point_x[1]=mirror_x[point_x[1]];
7886         point_y[2]=p_ptr->y;
7887         point_x[2]=p_ptr->x;
7888
7889         x=point_x[0]+point_x[1]+point_x[2];
7890         y=point_y[0]+point_y[1]+point_y[2];
7891
7892         centersign = (point_x[0]*3-x)*(point_y[1]*3-y)
7893                 - (point_y[0]*3-y)*(point_x[1]*3-x);
7894         if( centersign == 0 )return FALSE;
7895                                 
7896         x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
7897         x1 = x1 < point_x[2] ? x1 : point_x[2];
7898         y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
7899         y1 = y1 < point_y[2] ? y1 : point_y[2];
7900
7901         x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
7902         x2 = x2 > point_x[2] ? x2 : point_x[2];
7903         y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
7904         y2 = y2 > point_y[2] ? y2 : point_y[2];
7905
7906         for( y=y1 ; y <=y2 ; y++ ){
7907                 for( x=x1 ; x <=x2 ; x++ ){
7908                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
7909                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
7910                                 centersign*( (point_x[1]-x)*(point_y[2]-y)
7911                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
7912                                 centersign*( (point_x[2]-x)*(point_y[0]-y)
7913                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
7914                         {
7915                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7916                                         /* Visual effects */
7917                                         if(!(p_ptr->blind)
7918                                            && panel_contains(y,x)){
7919                                           p = bolt_pict(y,x,y,x, GF_MANA );
7920                                           print_rel(PICT_C(p), PICT_A(p),y,x);
7921                                           move_cursor_relative(y, x);
7922                                           /*if (fresh_before)*/ Term_fresh();
7923                                           Term_xtra(TERM_XTRA_DELAY, msec);
7924                                         }
7925                                 }
7926                         }
7927                 }
7928         }
7929         for( y=y1 ; y <=y2 ; y++ ){
7930                 for( x=x1 ; x <=x2 ; x++ ){
7931                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
7932                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
7933                                 centersign*( (point_x[1]-x)*(point_y[2]-y)
7934                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
7935                                 centersign*( (point_x[2]-x)*(point_y[0]-y)
7936                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
7937                         {
7938                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7939                                         (void)project_f(0,0,y,x,dam,GF_MANA); 
7940                                 }
7941                         }
7942                 }
7943         }
7944         for( y=y1 ; y <=y2 ; y++ ){
7945                 for( x=x1 ; x <=x2 ; x++ ){
7946                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
7947                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
7948                                 centersign*( (point_x[1]-x)*(point_y[2]-y)
7949                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
7950                                 centersign*( (point_x[2]-x)*(point_y[0]-y)
7951                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
7952                         {
7953                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7954                                         (void)project_o(0,0,y,x,dam,GF_MANA); 
7955                                 }
7956                         }
7957                 }
7958         }
7959         for( y=y1 ; y <=y2 ; y++ ){
7960                 for( x=x1 ; x <=x2 ; x++ ){
7961                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
7962                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
7963                                 centersign*( (point_x[1]-x)*(point_y[2]-y)
7964                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
7965                                 centersign*( (point_x[2]-x)*(point_y[0]-y)
7966                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
7967                         {
7968                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7969                                         (void)project_m(0,0,y,x,dam,GF_MANA,
7970                                           (PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP),TRUE);
7971                                 }
7972                         }
7973                 }
7974         }
7975         if( one_in_(7) ){
7976                 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
7977                 remove_mirror(point_y[0],point_x[0]);
7978         }
7979
7980         return TRUE;
7981 }
7982
7983 /*!
7984  * @brief 鏡魔法「鏡の封印」の効果処理
7985  * @param dam ダメージ量
7986  * @return 効果があったらTRUEを返す
7987  */
7988 void seal_of_mirror( HIT_POINT dam )
7989 {
7990         int x,y;
7991
7992         for( x = 0 ; x < cur_wid ; x++ )
7993         {
7994                 for( y = 0 ; y < cur_hgt ; y++ )
7995                 {
7996                         if( is_mirror_grid(&cave[y][x]))
7997                         {
7998                                 if(project_m(0,0,y,x,dam,GF_GENOCIDE,
7999                                                          (PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP),TRUE))
8000                                 {
8001                                         if( !cave[y][x].m_idx )
8002                                         {
8003                                                 remove_mirror(y,x);
8004                                         }
8005                                 }
8006                         }
8007                 }
8008         }
8009         return;
8010 }
8011