OSDN Git Service

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