OSDN Git Service

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