OSDN Git Service

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