OSDN Git Service

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