OSDN Git Service

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