OSDN Git Service

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