OSDN Git Service

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