OSDN Git Service

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