OSDN Git Service

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