OSDN Git Service

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