OSDN Git Service

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