OSDN Git Service

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