OSDN Git Service

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