OSDN Git Service

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