OSDN Git Service

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