OSDN Git Service

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