OSDN Git Service

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