OSDN Git Service

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