OSDN Git Service

[Refactor] #37353 PROJECT_* 定義を新規ファイル projection.h へ移動。 / Move PROJECT_* definition...
[hengband/hengband.git] / src / spells1.c
1 /*!
2  * @file spells1.c
3  * @brief 魔法による遠隔処理の実装 / Spell projection
4  * @date 2014/07/10
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * </pre>
12  */
13
14 #include "angband.h"
15 #include "cmd-pet.h"
16 #include "trap.h"
17 #include "object-curse.h"
18 #include "player-damage.h"
19 #include "monsterrace-hook.h"
20 #include "melee.h"
21 #include "world.h"
22 #include "projection.h"
23
24
25 static int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
26 static int rakubadam_p; /*!< 落馬した際のダメージ量 */
27
28 int project_length = 0; /*!< 投射の射程距離 */
29
30
31 /*!
32  * @brief モンスター魅了用セービングスロー共通部(汎用系)
33  * @param pow 魅了パワー
34  * @param m_ptr 対象モンスター
35  * @return 魅了に抵抗したらTRUE
36  */
37 static bool_hack common_saving_throw_charm(player_type *player_ptr, HIT_POINT pow, monster_type *m_ptr)
38 {
39         monster_race *r_ptr = &r_info[m_ptr->r_idx];
40
41         if(p_ptr->inside_arena) return TRUE;
42
43         /* Memorize a flag */
44         if (r_ptr->flagsr & RFR_RES_ALL)
45         {
46                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
47                 return TRUE;
48         }
49
50         if (r_ptr->flags3 & RF3_NO_CONF)
51         {
52                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
53                 return TRUE;
54         }
55
56         if (r_ptr->flags1 & RF1_QUESTOR || m_ptr->mflag2 & MFLAG2_NOPET) return TRUE;
57
58         pow += (adj_chr_chm[player_ptr->stat_ind[A_CHR]] - 1);
59         if((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) pow = pow * 2 / 3;
60         return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
61 }
62
63 /*!
64  * @brief モンスター服従用セービングスロー共通部(部族依存系)
65  * @param pow 服従パワー
66  * @param m_ptr 対象モンスター
67  * @return 服従に抵抗したらTRUE
68  */
69 static bool_hack common_saving_throw_control(player_type *player_ptr, HIT_POINT pow, monster_type *m_ptr)
70 {
71         monster_race *r_ptr = &r_info[m_ptr->r_idx];
72
73         if (p_ptr->inside_arena) return TRUE;
74
75         /* Memorize a flag */
76         if (r_ptr->flagsr & RFR_RES_ALL)
77         {
78                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
79                 return TRUE;
80         }
81
82         if (r_ptr->flags1 & RF1_QUESTOR || m_ptr->mflag2 & MFLAG2_NOPET) return TRUE;
83
84         pow += adj_chr_chm[player_ptr->stat_ind[A_CHR]] - 1;
85         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) pow = pow * 2 / 3;
86         return (r_ptr->level > randint1((pow - 10) < 1 ? 1 : (pow - 10)) + 5);
87 }
88
89 /*!
90 * @brief 一部ボルト魔法のビーム化確率を算出する / Prepare standard probability to become beam for fire_bolt_or_beam()
91 * @return ビーム化確率(%)
92 * @details
93 * ハードコーティングによる実装が行われている。
94 * メイジは(レベル)%、ハイメイジ、スペルマスターは(レベル)%、それ以外の職業は(レベル/2)%
95 */
96 PERCENTAGE beam_chance(void)
97 {
98         if (p_ptr->pclass == CLASS_MAGE)
99                 return (PERCENTAGE)(p_ptr->lev);
100         if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)
101                 return (PERCENTAGE)(p_ptr->lev + 10);
102
103         return (PERCENTAGE)(p_ptr->lev / 2);
104 }
105
106
107 /*!
108  * @brief 配置した鏡リストの次を取得する /
109  * Get another mirror. for SEEKER 
110  * @param next_y 次の鏡のy座標を返す参照ポインタ
111  * @param next_x 次の鏡のx座標を返す参照ポインタ
112  * @param cury 現在の鏡のy座標
113  * @param curx 現在の鏡のx座標
114  */
115 static void next_mirror(int* next_y, int* next_x, int cury, int curx)
116 {
117         int mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
118         int mirror_num = 0;                       /* 鏡の数 */
119         POSITION x, y;
120         int num;
121
122         for (x = 0; x < cur_wid; x++)
123         {
124                 for (y = 0; y < cur_hgt; y++)
125                 {
126                         if (is_mirror_grid(&cave[y][x])) {
127                                 mirror_y[mirror_num] = y;
128                                 mirror_x[mirror_num] = x;
129                                 mirror_num++;
130                         }
131                 }
132         }
133         if (mirror_num)
134         {
135                 num = randint0(mirror_num);
136                 *next_y = mirror_y[num];
137                 *next_x = mirror_x[num];
138                 return;
139         }
140         *next_y = cury + randint0(5) - 2;
141         *next_x = curx + randint0(5) - 2;
142         return;
143 }
144                 
145 /*!
146  * @brief 万色表現用にランダムな色を選択する関数 /
147  * Get a legal "multi-hued" color for drawing "spells"
148  * @param max 色IDの最大値
149  * @return 選択した色ID
150  */
151 static TERM_COLOR mh_attr(int max)
152 {
153         switch (randint1(max))
154         {
155                 case  1: return (TERM_RED);
156                 case  2: return (TERM_GREEN);
157                 case  3: return (TERM_BLUE);
158                 case  4: return (TERM_YELLOW);
159                 case  5: return (TERM_ORANGE);
160                 case  6: return (TERM_VIOLET);
161                 case  7: return (TERM_L_RED);
162                 case  8: return (TERM_L_GREEN);
163                 case  9: return (TERM_L_BLUE);
164                 case 10: return (TERM_UMBER);
165                 case 11: return (TERM_L_UMBER);
166                 case 12: return (TERM_SLATE);
167                 case 13: return (TERM_WHITE);
168                 case 14: return (TERM_L_WHITE);
169                 case 15: return (TERM_L_DARK);
170         }
171
172         return (TERM_WHITE);
173 }
174
175
176 /*!
177  * @brief 魔法属性に応じたエフェクトの色を返す /
178  * Return a color to use for the bolt/ball spells
179  * @param type 魔法属性
180  * @return 対応する色ID
181  */
182 static TERM_COLOR spell_color(int type)
183 {
184         /* Check if A.B.'s new graphics should be used (rr9) */
185         if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2"))
186         {
187                 /* Analyze */
188                 switch (type)
189                 {
190                         case GF_PSY_SPEAR:              return (0x06);
191                         case GF_MISSILE:                return (0x0F);
192                         case GF_ACID:                   return (0x04);
193                         case GF_ELEC:                   return (0x02);
194                         case GF_FIRE:                   return (0x00);
195                         case GF_COLD:                   return (0x01);
196                         case GF_POIS:                   return (0x03);
197                         case GF_HOLY_FIRE:              return (0x00);
198                         case GF_HELL_FIRE:              return (0x00);
199                         case GF_MANA:                   return (0x0E);
200                           /* by henkma */
201                         case GF_SEEKER:                 return (0x0E);
202                         case GF_SUPER_RAY:              return (0x0E);
203
204                         case GF_ARROW:                  return (0x0F);
205                         case GF_WATER:                  return (0x04);
206                         case GF_NETHER:                 return (0x07);
207                         case GF_CHAOS:                  return (mh_attr(15));
208                         case GF_DISENCHANT:             return (0x05);
209                         case GF_NEXUS:                  return (0x0C);
210                         case GF_CONFUSION:              return (mh_attr(4));
211                         case GF_SOUND:                  return (0x09);
212                         case GF_SHARDS:                 return (0x08);
213                         case GF_FORCE:                  return (0x09);
214                         case GF_INERTIAL:               return (0x09);
215                         case GF_GRAVITY:                return (0x09);
216                         case GF_TIME:                   return (0x09);
217                         case GF_LITE_WEAK:              return (0x06);
218                         case GF_LITE:                   return (0x06);
219                         case GF_DARK_WEAK:              return (0x07);
220                         case GF_DARK:                   return (0x07);
221                         case GF_PLASMA:                 return (0x0B);
222                         case GF_METEOR:                 return (0x00);
223                         case GF_ICE:                    return (0x01);
224                         case GF_ROCKET:                 return (0x0F);
225                         case GF_DEATH_RAY:              return (0x07);
226                         case GF_NUKE:                   return (mh_attr(2));
227                         case GF_DISINTEGRATE:   return (0x05);
228                         case GF_PSI:
229                         case GF_PSI_DRAIN:
230                         case GF_TELEKINESIS:
231                         case GF_DOMINATION:
232                         case GF_DRAIN_MANA:
233                         case GF_MIND_BLAST:
234                         case GF_BRAIN_SMASH:
235                                 return (0x09);
236                         case GF_CAUSE_1:
237                         case GF_CAUSE_2:
238                         case GF_CAUSE_3:
239                         case GF_CAUSE_4:                return (0x0E);
240                         case GF_HAND_DOOM:              return (0x07);
241                         case GF_CAPTURE  :              return (0x0E);
242                         case GF_IDENTIFY:               return (0x01);
243                         case GF_ATTACK:                 return (0x0F);
244                         case GF_PHOTO   :               return (0x06);
245                 }
246         }
247         /* Normal tiles or ASCII */
248         else
249         {
250                 TERM_COLOR a;
251                 SYMBOL_CODE c;
252
253                 /* Lookup the default colors for this type */
254                 concptr s = quark_str(gf_color[type]);
255
256                 if (!s) return (TERM_WHITE);
257
258                 /* Pick a random color */
259                 c = s[randint0(strlen(s))];
260
261                 /* Lookup this color */
262                 a = my_strchr(color_char, c) - color_char;
263
264                 /* Invalid color (note check for < 0 removed, gave a silly
265                  * warning because bytes are always >= 0 -- RG) */
266                 if (a > 15) return (TERM_WHITE);
267
268                 /* Use this color */
269                 return (a);
270         }
271
272         /* Standard "color" */
273         return (TERM_WHITE);
274 }
275
276
277 /*!
278  * @brief 始点から終点にかけた方向毎にボルトのキャラクタを返す /
279  * Find the attr/char pair to use for a spell effect
280  * @param y 始点Y座標
281  * @param x 始点X座標
282  * @param ny 終点Y座標
283  * @param nx 終点X座標
284  * @param typ 魔法の効果属性
285  * @return 方向キャラID
286  * @details
287  * <pre>
288  * It is moving (or has moved) from (x,y) to (nx,ny).
289  * If the distance is not "one", we (may) return "*".
290  * </pre>
291  */
292 u16b bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, EFFECT_ID typ)
293 {
294         int base;
295
296         byte k;
297
298         TERM_COLOR a;
299         SYMBOL_CODE c;
300
301         /* No motion (*) */
302         if ((ny == y) && (nx == x)) base = 0x30;
303
304         /* Vertical (|) */
305         else if (nx == x) base = 0x40;
306
307         /* Horizontal (-) */
308         else if (ny == y) base = 0x50;
309
310         /* Diagonal (/) */
311         else if ((ny - y) == (x - nx)) base = 0x60;
312
313         /* Diagonal (\) */
314         else if ((ny - y) == (nx - x)) base = 0x70;
315
316         /* Weird (*) */
317         else base = 0x30;
318
319         /* Basic spell color */
320         k = spell_color(typ);
321
322         /* Obtain attr/char */
323         a = misc_to_attr[base + k];
324         c = misc_to_char[base + k];
325
326         /* Create pict */
327         return (PICT(a, c));
328 }
329
330
331 /*!
332  * @brief 始点から終点への経路を返す /
333  * Determine the path taken by a projection.
334  * @param gp 経路座標リストを返す参照ポインタ
335  * @param range 距離
336  * @param y1 始点Y座標
337  * @param x1 始点X座標
338  * @param y2 終点Y座標
339  * @param x2 終点X座標
340  * @param flg フラグID
341  * @return リストの長さ
342  * @details
343  * <pre>
344  * The projection will always start from the grid (y1,x1), and will travel
345  * towards the grid (y2,x2), touching one grid per unit of distance along
346  * the major axis, and stopping when it enters the destination grid or a
347  * wall grid, or has travelled the maximum legal distance of "range".
348  *
349  * Note that "distance" in this function (as in the "update_view()" code)
350  * is defined as "MAX(dy,dx) + MIN(dy,dx)/2", which means that the player
351  * actually has an "octagon of projection" not a "circle of projection".
352  *
353  * The path grids are saved into the grid array pointed to by "gp", and
354  * there should be room for at least "range" grids in "gp".  Note that
355  * due to the way in which distance is calculated, this function normally
356  * uses fewer than "range" grids for the projection path, so the result
357  * of this function should never be compared directly to "range".  Note
358  * that the initial grid (y1,x1) is never saved into the grid array, not
359  * even if the initial grid is also the final grid.  
360  *
361  * The "flg" flags can be used to modify the behavior of this function.
362  *
363  * In particular, the "PROJECT_STOP" and "PROJECT_THRU" flags have the same
364  * semantics as they do for the "project" function, namely, that the path
365  * will stop as soon as it hits a monster, or that the path will continue
366  * through the destination grid, respectively.
367  *
368  * The "PROJECT_JUMP" flag, which for the "project()" function means to
369  * start at a special grid (which makes no sense in this function), means
370  * that the path should be "angled" slightly if needed to avoid any wall
371  * grids, allowing the player to "target" any grid which is in "view".
372  * This flag is non-trivial and has not yet been implemented, but could
373  * perhaps make use of the "vinfo" array (above).  
374  *
375  * This function returns the number of grids (if any) in the path.  This
376  * function will return zero if and only if (y1,x1) and (y2,x2) are equal.
377  *
378  * This algorithm is similar to, but slightly different from, the one used
379  * by "update_view_los()", and very different from the one used by "los()".
380  * </pre>
381  */
382 sint project_path(u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg)
383 {
384         POSITION y, x;
385
386         int n = 0;
387         int k = 0;
388
389         /* Absolute */
390         POSITION ay, ax;
391
392         /* Offsets */
393         POSITION sy, sx;
394
395         /* Fractions */
396         int frac;
397
398         /* Scale factors */
399         int full, half;
400
401         /* Slope */
402         int m;
403
404         /* No path necessary (or allowed) */
405         if ((x1 == x2) && (y1 == y2)) return (0);
406
407
408         /* Analyze "dy" */
409         if (y2 < y1)
410         {
411                 ay = (y1 - y2);
412                 sy = -1;
413         }
414         else
415         {
416                 ay = (y2 - y1);
417                 sy = 1;
418         }
419
420         /* Analyze "dx" */
421         if (x2 < x1)
422         {
423                 ax = (x1 - x2);
424                 sx = -1;
425         }
426         else
427         {
428                 ax = (x2 - x1);
429                 sx = 1;
430         }
431
432
433         /* Number of "units" in one "half" grid */
434         half = (ay * ax);
435
436         /* Number of "units" in one "full" grid */
437         full = half << 1;
438
439         /* Vertical */
440         if (ay > ax)
441         {
442                 /* Let m = ((dx/dy) * full) = (dx * dx * 2) */
443                 m = ax * ax * 2;
444
445                 /* Start */
446                 y = y1 + sy;
447                 x = x1;
448
449                 frac = m;
450
451                 if (frac > half)
452                 {
453                         /* Advance (X) part 2 */
454                         x += sx;
455
456                         /* Advance (X) part 3 */
457                         frac -= full;
458
459                         /* Track distance */
460                         k++;
461                 }
462
463                 /* Create the projection path */
464                 while (1)
465                 {
466                         /* Save grid */
467                         gp[n++] = GRID(y, x);
468
469                         /* Hack -- Check maximum range */
470                         if ((n + (k >> 1)) >= range) break;
471
472                         /* Sometimes stop at destination grid */
473                         if (!(flg & (PROJECT_THRU)))
474                         {
475                                 if ((x == x2) && (y == y2)) break;
476                         }
477
478                         if (flg & (PROJECT_DISI))
479                         {
480                                 if ((n > 0) && cave_stop_disintegration(y, x)) break;
481                         }
482                         else if (flg & (PROJECT_LOS))
483                         {
484                                 if ((n > 0) && !cave_los_bold(y, x)) break;
485                         }
486                         else if (!(flg & (PROJECT_PATH)))
487                         {
488                                 /* Always stop at non-initial wall grids */
489                                 if ((n > 0) && !cave_have_flag_bold(y, x, FF_PROJECT)) break;
490                         }
491
492                         /* Sometimes stop at non-initial monsters/players */
493                         if (flg & (PROJECT_STOP))
494                         {
495                                 if ((n > 0) &&
496                                         (player_bold(y, x) || cave[y][x].m_idx != 0))
497                                         break;
498                         }
499
500                         if (!in_bounds(y, x)) break;
501
502                         /* Slant */
503                         if (m)
504                         {
505                                 /* Advance (X) part 1 */
506                                 frac += m;
507
508                                 /* Horizontal change */
509                                 if (frac > half)
510                                 {
511                                         /* Advance (X) part 2 */
512                                         x += sx;
513
514                                         /* Advance (X) part 3 */
515                                         frac -= full;
516
517                                         /* Track distance */
518                                         k++;
519                                 }
520                         }
521
522                         /* Advance (Y) */
523                         y += sy;
524                 }
525         }
526
527         /* Horizontal */
528         else if (ax > ay)
529         {
530                 /* Let m = ((dy/dx) * full) = (dy * dy * 2) */
531                 m = ay * ay * 2;
532
533                 /* Start */
534                 y = y1;
535                 x = x1 + sx;
536
537                 frac = m;
538
539                 /* Vertical change */
540                 if (frac > half)
541                 {
542                         /* Advance (Y) part 2 */
543                         y += sy;
544
545                         /* Advance (Y) part 3 */
546                         frac -= full;
547
548                         /* Track distance */
549                         k++;
550                 }
551
552                 /* Create the projection path */
553                 while (1)
554                 {
555                         /* Save grid */
556                         gp[n++] = GRID(y, x);
557
558                         /* Hack -- Check maximum range */
559                         if ((n + (k >> 1)) >= range) break;
560
561                         /* Sometimes stop at destination grid */
562                         if (!(flg & (PROJECT_THRU)))
563                         {
564                                 if ((x == x2) && (y == y2)) break;
565                         }
566
567                         if (flg & (PROJECT_DISI))
568                         {
569                                 if ((n > 0) && cave_stop_disintegration(y, x)) break;
570                         }
571                         else if (flg & (PROJECT_LOS))
572                         {
573                                 if ((n > 0) && !cave_los_bold(y, x)) break;
574                         }
575                         else if (!(flg & (PROJECT_PATH)))
576                         {
577                                 /* Always stop at non-initial wall grids */
578                                 if ((n > 0) && !cave_have_flag_bold(y, x, FF_PROJECT)) break;
579                         }
580
581                         /* Sometimes stop at non-initial monsters/players */
582                         if (flg & (PROJECT_STOP))
583                         {
584                                 if ((n > 0) &&
585                                         (player_bold(y, x) || cave[y][x].m_idx != 0))
586                                         break;
587                         }
588
589                         if (!in_bounds(y, x)) break;
590
591                         /* Slant */
592                         if (m)
593                         {
594                                 /* Advance (Y) part 1 */
595                                 frac += m;
596
597                                 /* Vertical change */
598                                 if (frac > half)
599                                 {
600                                         /* Advance (Y) part 2 */
601                                         y += sy;
602
603                                         /* Advance (Y) part 3 */
604                                         frac -= full;
605
606                                         /* Track distance */
607                                         k++;
608                                 }
609                         }
610
611                         /* Advance (X) */
612                         x += sx;
613                 }
614         }
615
616         /* Diagonal */
617         else
618         {
619                 /* Start */
620                 y = y1 + sy;
621                 x = x1 + sx;
622
623                 /* Create the projection path */
624                 while (1)
625                 {
626                         /* Save grid */
627                         gp[n++] = GRID(y, x);
628
629                         /* Hack -- Check maximum range */
630                         if ((n + (n >> 1)) >= range) break;
631
632                         /* Sometimes stop at destination grid */
633                         if (!(flg & (PROJECT_THRU)))
634                         {
635                                 if ((x == x2) && (y == y2)) break;
636                         }
637
638                         if (flg & (PROJECT_DISI))
639                         {
640                                 if ((n > 0) && cave_stop_disintegration(y, x)) break;
641                         }
642                         else if (flg & (PROJECT_LOS))
643                         {
644                                 if ((n > 0) && !cave_los_bold(y, x)) break;
645                         }
646                         else if (!(flg & (PROJECT_PATH)))
647                         {
648                                 /* Always stop at non-initial wall grids */
649                                 if ((n > 0) && !cave_have_flag_bold(y, x, FF_PROJECT)) break;
650                         }
651
652                         /* Sometimes stop at non-initial monsters/players */
653                         if (flg & (PROJECT_STOP))
654                         {
655                                 if ((n > 0) &&
656                                         (player_bold(y, x) || cave[y][x].m_idx != 0))
657                                         break;
658                         }
659
660                         if (!in_bounds(y, x)) break;
661
662                         /* Advance (Y) */
663                         y += sy;
664
665                         /* Advance (X) */
666                         x += sx;
667                 }
668         }
669
670         /* Length */
671         return (n);
672 }
673
674
675
676 /*
677  * Mega-Hack -- track "affected" monsters (see "project()" comments)
678  */
679 static int project_m_n; /*!< 魔法効果範囲内にいるモンスターの数 */
680 static POSITION project_m_x; /*!< 処理中のモンスターX座標 */
681 static POSITION project_m_y; /*!< 処理中のモンスターY座標 */
682 /* Mega-Hack -- monsters target */
683 static POSITION monster_target_x; /*!< モンスターの攻撃目標X座標 */
684 static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */
685
686
687 /*!
688  * @brief 汎用的なビーム/ボルト/ボール系による地形効果処理 / We are called from "project()" to "damage" terrain features
689  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
690  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
691  * @param y 目標Y座標 / Target y location (or location to travel "towards")
692  * @param x 目標X座標 / Target x location (or location to travel "towards")
693  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
694  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
695  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
696  * @details
697  * <pre>
698  * We are called both for "beam" effects and "ball" effects.
699  *
700  * The "r" parameter is the "distance from ground zero".
701  *
702  * Note that we determine if the player can "see" anything that happens
703  * by taking into account: blindness, line-of-sight, and illumination.
704  *
705  * We return "TRUE" if the effect of the projection is "obvious".
706  *
707  * We also "see" grids which are "memorized", probably a hack
708  *
709  * Perhaps we should affect doors?
710  * </pre>
711  */
712 static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
713 {
714         cave_type *c_ptr = &cave[y][x];
715         feature_type *f_ptr = &f_info[c_ptr->feat];
716
717         bool obvious = FALSE;
718         bool known = player_has_los_bold(y, x);
719
720
721         who = who ? who : 0;
722
723         /* Reduce damage by distance */
724         dam = (dam + r) / (r + 1);
725
726
727         if (have_flag(f_ptr->flags, FF_TREE))
728         {
729                 concptr message;
730                 switch (typ)
731                 {
732                 case GF_POIS:
733                 case GF_NUKE:
734                 case GF_DEATH_RAY:
735                         message = _("枯れた", "was blasted."); break;
736                 case GF_TIME:
737                         message = _("縮んだ", "shrank."); break;
738                 case GF_ACID:
739                         message = _("溶けた", "melted."); break;
740                 case GF_COLD:
741                 case GF_ICE:
742                         message = _("凍り、砕け散った", "was frozen and smashed."); break;
743                 case GF_FIRE:
744                 case GF_ELEC:
745                 case GF_PLASMA:
746                         message = _("燃えた", "burns up!"); break;
747                 case GF_METEOR:
748                 case GF_CHAOS:
749                 case GF_MANA:
750                 case GF_SEEKER:
751                 case GF_SUPER_RAY:
752                 case GF_SHARDS:
753                 case GF_ROCKET:
754                 case GF_SOUND:
755                 case GF_DISENCHANT:
756                 case GF_FORCE:
757                 case GF_GRAVITY:
758                         message = _("粉砕された", "was crushed."); break;
759                 default:
760                         message = NULL; break;
761                 }
762                 if (message)
763                 {
764                         msg_format(_("木は%s。", "A tree %s"), message);
765                         cave_set_feat(y, x, one_in_(3) ? feat_brake : feat_grass);
766
767                         /* Observe */
768                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
769                 }
770         }
771
772         /* Analyze the type */
773         switch (typ)
774         {
775                 /* Ignore most effects */
776                 case GF_CAPTURE:
777                 case GF_HAND_DOOM:
778                 case GF_CAUSE_1:
779                 case GF_CAUSE_2:
780                 case GF_CAUSE_3:
781                 case GF_CAUSE_4:
782                 case GF_MIND_BLAST:
783                 case GF_BRAIN_SMASH:
784                 case GF_DRAIN_MANA:
785                 case GF_PSY_SPEAR:
786                 case GF_FORCE:
787                 case GF_HOLY_FIRE:
788                 case GF_HELL_FIRE:
789                 case GF_PSI:
790                 case GF_PSI_DRAIN:
791                 case GF_TELEKINESIS:
792                 case GF_DOMINATION:
793                 case GF_IDENTIFY:
794                 case GF_ATTACK:
795                 case GF_ACID:
796                 case GF_ELEC:
797                 case GF_COLD:
798                 case GF_ICE:
799                 case GF_FIRE:
800                 case GF_PLASMA:
801                 case GF_METEOR:
802                 case GF_CHAOS:
803                 case GF_MANA:
804                 case GF_SEEKER:
805                 case GF_SUPER_RAY:
806                 {
807                         break;
808                 }
809
810                 /* Destroy Traps (and Locks) */
811                 case GF_KILL_TRAP:
812                 {
813                         /* Reveal secret doors */
814                         if (is_hidden_door(c_ptr))
815                         {
816                                 /* Pick a door */
817                                 disclose_grid(y, x);
818
819                                 /* Check line of sight */
820                                 if (known)
821                                 {
822                                         obvious = TRUE;
823                                 }
824                         }
825
826                         /* Destroy traps */
827                         if (is_trap(c_ptr->feat))
828                         {
829                                 /* Check line of sight */
830                                 if (known)
831                                 {
832                                         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
833                                         obvious = TRUE;
834                                 }
835
836                                 /* Destroy the trap */
837                                 cave_alter_feat(y, x, FF_DISARM);
838                         }
839
840                         /* Locked doors are unlocked */
841                         if (is_closed_door(c_ptr->feat) && f_ptr->power && have_flag(f_ptr->flags, FF_OPEN))
842                         {
843                                 s16b old_feat = c_ptr->feat;
844
845                                 /* Unlock the door */
846                                 cave_alter_feat(y, x, FF_DISARM);
847
848                                 /* Check line of sound */
849                                 if (known && (old_feat != c_ptr->feat))
850                                 {
851                                         msg_print(_("カチッと音がした!", "Click!"));
852                                         obvious = TRUE;
853                                 }
854                         }
855
856                         /* Remove "unsafe" flag if player is not blind */
857                         if (!p_ptr->blind && player_has_los_bold(y, x))
858                         {
859                                 c_ptr->info &= ~(CAVE_UNSAFE);
860                                 lite_spot(y, x);
861                                 obvious = TRUE;
862                         }
863
864                         break;
865                 }
866
867                 /* Destroy Doors (and traps) */
868                 case GF_KILL_DOOR:
869                 {
870                         /* Destroy all doors and traps */
871                         if (is_trap(c_ptr->feat) || have_flag(f_ptr->flags, FF_DOOR))
872                         {
873                                 /* Check line of sight */
874                                 if (known)
875                                 {
876                                         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
877                                         obvious = TRUE;
878                                 }
879
880                                 /* Destroy the feature */
881                                 cave_alter_feat(y, x, FF_TUNNEL);
882                         }
883
884                         /* Remove "unsafe" flag if player is not blind */
885                         if (!p_ptr->blind && player_has_los_bold(y, x))
886                         {
887                                 c_ptr->info &= ~(CAVE_UNSAFE);
888                                 lite_spot(y, x);
889                                 obvious = TRUE;
890                         }
891
892                         break;
893                 }
894
895                 case GF_JAM_DOOR: /* Jams a door (as if with a spike) */
896                 {
897                         if (have_flag(f_ptr->flags, FF_SPIKE))
898                         {
899                                 s16b old_mimic = c_ptr->mimic;
900                                 feature_type *mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
901
902                                 cave_alter_feat(y, x, FF_SPIKE);
903                                 c_ptr->mimic = old_mimic;
904
905                                 note_spot(y, x);
906                                 lite_spot(y, x);
907
908                                 /* Check line of sight */
909                                 if (known && have_flag(mimic_f_ptr->flags, FF_OPEN))
910                                 {
911                                         msg_format(_("%sに何かがつっかえて開かなくなった。", "The %s seems stuck."), f_name + mimic_f_ptr->name);
912                                         obvious = TRUE;
913                                 }
914                         }
915                         break;
916                 }
917
918                 /* Destroy walls (and doors) */
919                 case GF_KILL_WALL:
920                 {
921                         if (have_flag(f_ptr->flags, FF_HURT_ROCK))
922                         {
923                                 if (known && (c_ptr->info & (CAVE_MARK)))
924                                 {
925                                         msg_format(_("%sが溶けて泥になった!", "The %s turns into mud!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
926                                         obvious = TRUE;
927                                 }
928
929                                 /* Destroy the wall */
930                                 cave_alter_feat(y, x, FF_HURT_ROCK);
931
932                                 /* Update some things */
933                                 p_ptr->update |= (PU_FLOW);
934                         }
935
936                         break;
937                 }
938
939                 /* Make doors */
940                 case GF_MAKE_DOOR:
941                 {
942                         /* Require a "naked" floor grid */
943                         if (!cave_naked_bold(y, x)) break;
944
945                         /* Not on the player */
946                         if (player_bold(y, x)) break;
947
948                         /* Create a closed door */
949                         cave_set_feat(y, x, feat_door[DOOR_DOOR].closed);
950
951                         /* Observe */
952                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
953
954                         break;
955                 }
956
957                 /* Make traps */
958                 case GF_MAKE_TRAP:
959                 {
960                         /* Place a trap */
961                         place_trap(y, x);
962
963                         break;
964                 }
965
966                 /* Make doors */
967                 case GF_MAKE_TREE:
968                 {
969                         /* Require a "naked" floor grid */
970                         if (!cave_naked_bold(y, x)) break;
971
972                         /* Not on the player */
973                         if (player_bold(y, x)) break;
974
975                         /* Create a closed door */
976                         cave_set_feat(y, x, feat_tree);
977
978                         /* Observe */
979                         if (c_ptr->info & (CAVE_MARK)) obvious = TRUE;
980
981
982                         break;
983                 }
984
985                 case GF_MAKE_GLYPH:
986                 {
987                         /* Require a "naked" floor grid */
988                         if (!cave_naked_bold(y, x)) break;
989
990                         /* Create a glyph */
991                         c_ptr->info |= CAVE_OBJECT;
992                         c_ptr->mimic = feat_glyph;
993
994                         note_spot(y, x);
995
996                         lite_spot(y, x);
997
998                         break;
999                 }
1000
1001                 case GF_STONE_WALL:
1002                 {
1003                         /* Require a "naked" floor grid */
1004                         if (!cave_naked_bold(y, x)) break;
1005
1006                         /* Not on the player */
1007                         if (player_bold(y, x)) break;
1008
1009                         /* Place a wall */
1010                         cave_set_feat(y, x, feat_granite);
1011
1012                         break;
1013                 }
1014
1015
1016                 case GF_LAVA_FLOW:
1017                 {
1018                         /* Ignore permanent grid */
1019                         if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
1020
1021                         /* Shallow Lava */
1022                         if (dam == 1)
1023                         {
1024                                 /* Ignore grid without enough space */
1025                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
1026
1027                                 /* Place a shallow lava */
1028                                 cave_set_feat(y, x, feat_shallow_lava);
1029                         }
1030                         /* Deep Lava */
1031                         else if (dam)
1032                         {
1033                                 /* Place a deep lava */
1034                                 cave_set_feat(y, x, feat_deep_lava);
1035                         }
1036                         break;
1037                 }
1038
1039                 case GF_WATER_FLOW:
1040                 {
1041                         /* Ignore permanent grid */
1042                         if (have_flag(f_ptr->flags, FF_PERMANENT)) break;
1043
1044                         /* Shallow Water */
1045                         if (dam == 1)
1046                         {
1047                                 /* Ignore grid without enough space */
1048                                 if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
1049
1050                                 /* Place a shallow water */
1051                                 cave_set_feat(y, x, feat_shallow_water);
1052                         }
1053                         /* Deep Water */
1054                         else if (dam)
1055                         {
1056                                 /* Place a deep water */
1057                                 cave_set_feat(y, x, feat_deep_water);
1058                         }
1059                         break;
1060                 }
1061
1062                 /* Lite up the grid */
1063                 case GF_LITE_WEAK:
1064                 case GF_LITE:
1065                 {
1066                         /* Turn on the light */
1067                         if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
1068                         {
1069                                 c_ptr->info |= (CAVE_GLOW);
1070                                 note_spot(y, x);
1071                                 lite_spot(y, x);
1072                                 update_local_illumination(y, x);
1073
1074                                 /* Observe */
1075                                 if (player_can_see_bold(y, x)) obvious = TRUE;
1076
1077                                 /* Mega-Hack -- Update the monster in the affected grid */
1078                                 /* This allows "spear of light" (etc) to work "correctly" */
1079                                 if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
1080
1081                                 if (p_ptr->special_defense & NINJA_S_STEALTH)
1082                                 {
1083                                         if (player_bold(y, x)) set_superstealth(FALSE);
1084                                 }
1085                         }
1086
1087                         break;
1088                 }
1089
1090                 /* Darken the grid */
1091                 case GF_DARK_WEAK:
1092                 case GF_DARK:
1093                 {
1094                         bool do_dark = !p_ptr->inside_battle && !is_mirror_grid(c_ptr);
1095                         int j;
1096
1097                         /* Turn off the light. */
1098                         if (do_dark)
1099                         {
1100                                 if (dun_level || !is_daytime())
1101                                 {
1102                                         for (j = 0; j < 9; j++)
1103                                         {
1104                                                 int by = y + ddy_ddd[j];
1105                                                 int bx = x + ddx_ddd[j];
1106
1107                                                 if (in_bounds2(by, bx))
1108                                                 {
1109                                                         cave_type *cc_ptr = &cave[by][bx];
1110
1111                                                         if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1112                                                         {
1113                                                                 do_dark = FALSE;
1114                                                                 break;
1115                                                         }
1116                                                 }
1117                                         }
1118
1119                                         if (!do_dark) break;
1120                                 }
1121
1122                                 c_ptr->info &= ~(CAVE_GLOW);
1123
1124                                 /* Hack -- Forget "boring" grids */
1125                                 if (!have_flag(f_ptr->flags, FF_REMEMBER))
1126                                 {
1127                                         /* Forget */
1128                                         c_ptr->info &= ~(CAVE_MARK);
1129
1130                                         note_spot(y, x);
1131                                 }
1132
1133                                 lite_spot(y, x);
1134
1135                                 update_local_illumination(y, x);
1136
1137                                 if (player_can_see_bold(y, x)) obvious = TRUE;
1138
1139                                 /* Mega-Hack -- Update the monster in the affected grid */
1140                                 /* This allows "spear of light" (etc) to work "correctly" */
1141                                 if (c_ptr->m_idx) update_monster(c_ptr->m_idx, FALSE);
1142                         }
1143
1144                         /* All done */
1145                         break;
1146                 }
1147
1148                 case GF_SHARDS:
1149                 case GF_ROCKET:
1150                 {
1151                         if (is_mirror_grid(c_ptr))
1152                         {
1153                                 msg_print(_("鏡が割れた!", "The mirror was crashed!"));
1154                                 sound(SOUND_GLASS);
1155                                 remove_mirror(y, x);
1156                                 project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
1157                         }
1158
1159                         if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 50))
1160                         {
1161                                 if (known && (c_ptr->info & CAVE_MARK))
1162                                 {
1163                                         msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
1164                                         sound(SOUND_GLASS);
1165                                 }
1166
1167                                 /* Destroy the wall */
1168                                 cave_alter_feat(y, x, FF_HURT_ROCK);
1169
1170                                 /* Update some things */
1171                                 p_ptr->update |= (PU_FLOW);
1172                         }
1173                         break;
1174                 }
1175
1176                 case GF_SOUND:
1177                 {
1178                         if (is_mirror_grid(c_ptr) && p_ptr->lev < 40)
1179                         {
1180                                 msg_print(_("鏡が割れた!", "The mirror was crashed!"));
1181                                 sound(SOUND_GLASS);
1182                                 remove_mirror(y, x);
1183                                 project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
1184                         }
1185
1186                         if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 200))
1187                         {
1188                                 if (known && (c_ptr->info & CAVE_MARK))
1189                                 {
1190                                         msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(c_ptr)].name);
1191                                         sound(SOUND_GLASS);
1192                                 }
1193
1194                                 /* Destroy the wall */
1195                                 cave_alter_feat(y, x, FF_HURT_ROCK);
1196
1197                                 /* Update some things */
1198                                 p_ptr->update |= (PU_FLOW);
1199                         }
1200                         break;
1201                 }
1202
1203                 case GF_DISINTEGRATE:
1204                 {
1205                         /* Destroy mirror/glyph */
1206                         if (is_mirror_grid(c_ptr) || is_glyph_grid(c_ptr) || is_explosive_rune_grid(c_ptr))
1207                                 remove_mirror(y, x);
1208
1209                         /* Permanent features don't get effect */
1210                         /* But not protect monsters and other objects */
1211                         if (have_flag(f_ptr->flags, FF_HURT_DISI) && !have_flag(f_ptr->flags, FF_PERMANENT))
1212                         {
1213                                 cave_alter_feat(y, x, FF_HURT_DISI);
1214
1215                                 /* Update some things -- similar to GF_KILL_WALL */
1216                                 p_ptr->update |= (PU_FLOW);
1217                         }
1218                         break;
1219                 }
1220         }
1221
1222         lite_spot(y, x);
1223         /* Return "Anything seen?" */
1224         return (obvious);
1225 }
1226
1227
1228
1229 /*!
1230  * @brief 汎用的なビーム/ボルト/ボール系によるアイテムオブジェクトへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
1231  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
1232  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
1233  * @param y 目標Y座標 / Target y location (or location to travel "towards")
1234  * @param x 目標X座標 / Target x location (or location to travel "towards")
1235  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
1236  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
1237  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
1238  * @details
1239  * <pre>
1240  * We are called from "project()" to "damage" objects
1241  *
1242  * We are called both for "beam" effects and "ball" effects.
1243  *
1244  * Perhaps we should only SOMETIMES damage things on the ground.
1245  *
1246  * The "r" parameter is the "distance from ground zero".
1247  *
1248  * Note that we determine if the player can "see" anything that happens
1249  * by taking into account: blindness, line-of-sight, and illumination.
1250  *
1251  * We also "see" grids which are "memorized", probably a hack
1252  *
1253  * We return "TRUE" if the effect of the projection is "obvious".
1254  * </pre>
1255  */
1256 static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
1257 {
1258         cave_type *c_ptr = &cave[y][x];
1259
1260         OBJECT_IDX this_o_idx, next_o_idx = 0;
1261
1262         bool obvious = FALSE;
1263         bool known = player_has_los_bold(y, x);
1264
1265         BIT_FLAGS flgs[TR_FLAG_SIZE];
1266
1267         GAME_TEXT o_name[MAX_NLEN];
1268
1269         KIND_OBJECT_IDX k_idx = 0;
1270         bool is_potion = FALSE;
1271
1272
1273         who = who ? who : 0;
1274
1275         /* Reduce damage by distance */
1276         dam = (dam + r) / (r + 1);
1277
1278
1279         /* Scan all objects in the grid */
1280         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1281         {
1282                 object_type *o_ptr = &o_list[this_o_idx];
1283
1284                 bool is_art = FALSE;
1285                 bool ignore = FALSE;
1286                 bool do_kill = FALSE;
1287
1288                 concptr note_kill = NULL;
1289
1290 #ifndef JP
1291                 /* Get the "plural"-ness */
1292                 bool plural = (o_ptr->number > 1);
1293 #endif
1294
1295                 /* Acquire next object */
1296                 next_o_idx = o_ptr->next_o_idx;
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         GAME_TEXT m_name[MAX_NLEN];
1690         char m_poss[10];
1691
1692         PARAMETER_VALUE photo = 0;
1693
1694         /* Assume no note */
1695         concptr note = NULL;
1696
1697         /* Assume a default death */
1698         concptr 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                                 concptr str = (p_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
2570                                 concptr 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                                                         monster_desc(killer, caster_ptr, 0);
4037                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), killer);
4038                                                 }
4039                                         }
4040                                 }
4041                                 else
4042                                 {
4043                                         msg_format(_("%sから精神エネルギーを吸いとった。", "You draw psychic energy from %s."), m_name);
4044                                         (void)hp_player(dam);
4045                                 }
4046                         }
4047                         else
4048                         {
4049                                 if (see_s_msg) msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
4050                         }
4051                         dam = 0;
4052                         break;
4053                 }
4054
4055                 /* Mind blast */
4056                 case GF_MIND_BLAST:
4057                 {
4058                         if (seen) obvious = TRUE;
4059                         if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
4060
4061                         if (r_ptr->flagsr & RFR_RES_ALL)
4062                         {
4063                                 note = _("には完全な耐性がある!", " is immune.");
4064                                 skipped = TRUE;
4065                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4066                                 break;
4067                         }
4068
4069                         /* Attempt a saving throw */
4070                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
4071                                  (r_ptr->flags3 & RF3_NO_CONF) ||
4072                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
4073                         {
4074                                 /* Memorize a flag */
4075                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4076                                 {
4077                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
4078                                 }
4079                                 note = _("には効果がなかった。", " is unaffected.");
4080                                 dam = 0;
4081                         }
4082                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
4083                         {
4084                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4085                                 note = _("には完全な耐性がある!", " is immune.");
4086                                 dam = 0;
4087                         }
4088                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
4089                         {
4090                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
4091                                 note = _("には耐性がある。", " resists.");
4092                                 dam /= 3;
4093                         }
4094                         else
4095                         {
4096                                 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
4097                                 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
4098
4099                                 if (who > 0) do_conf = randint0(4) + 4;
4100                                 else do_conf = randint0(8) + 8;
4101                         }
4102                         break;
4103                 }
4104
4105                 /* Brain smash */
4106                 case GF_BRAIN_SMASH:
4107                 {
4108                         if (seen) obvious = TRUE;
4109                         if (!who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), m_name);
4110
4111                         if (r_ptr->flagsr & RFR_RES_ALL)
4112                         {
4113                                 note = _("には完全な耐性がある!", " is immune.");
4114                                 skipped = TRUE;
4115                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4116                                 break;
4117                         }
4118
4119                         /* Attempt a saving throw */
4120                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
4121                                  (r_ptr->flags3 & RF3_NO_CONF) ||
4122                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
4123                         {
4124                                 /* Memorize a flag */
4125                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4126                                 {
4127                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
4128                                 }
4129                                 note = _("には効果がなかった。", " is unaffected.");
4130                                 dam = 0;
4131                         }
4132                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
4133                         {
4134                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4135                                 note = _("には完全な耐性がある!", " is immune.");
4136                                 dam = 0;
4137                         }
4138                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
4139                         {
4140                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
4141                                 note = _("には耐性がある!", " resists!");
4142                                 dam /= 3;
4143                         }
4144                         else
4145                         {
4146                                 note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
4147                                 note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
4148
4149                                 if (who > 0)
4150                                 {
4151                                         do_conf = randint0(4) + 4;
4152                                         do_stun = randint0(4) + 4;
4153                                 }
4154                                 else
4155                                 {
4156                                         do_conf = randint0(8) + 8;
4157                                         do_stun = randint0(8) + 8;
4158                                 }
4159                                 (void)set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 10);
4160                         }
4161                         break;
4162                 }
4163
4164                 /* CAUSE_1 */
4165                 case GF_CAUSE_1:
4166                 {
4167                         if (seen) obvious = TRUE;
4168                         if (!who) msg_format(_("%sを指差して呪いをかけた。", "You point at %s and curse."), m_name);
4169
4170                         if (r_ptr->flagsr & RFR_RES_ALL)
4171                         {
4172                                 note = _("には完全な耐性がある!", " is immune.");
4173                                 skipped = TRUE;
4174                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4175                                 break;
4176                         }
4177
4178                         /* Attempt a saving throw */
4179                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
4180                         {
4181                                 note = _("には効果がなかった。", " is unaffected.");
4182                                 dam = 0;
4183                         }
4184                         break;
4185                 }
4186
4187                 /* CAUSE_2 */
4188                 case GF_CAUSE_2:
4189                 {
4190                         if (seen) obvious = TRUE;
4191                         if (!who) msg_format(_("%sを指差して恐ろしげに呪いをかけた。", "You point at %s and curse horribly."), m_name);
4192
4193                         if (r_ptr->flagsr & RFR_RES_ALL)
4194                         {
4195                                 note = _("には完全な耐性がある!", " is immune.");
4196                                 skipped = TRUE;
4197                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4198                                 break;
4199                         }
4200
4201                         /* Attempt a saving throw */
4202                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
4203                         {
4204                                 note = _("には効果がなかった。", " is unaffected.");
4205                                 dam = 0;
4206                         }
4207                         break;
4208                 }
4209
4210                 /* CAUSE_3 */
4211                 case GF_CAUSE_3:
4212                 {
4213                         if (seen) obvious = TRUE;
4214                         if (!who) msg_format(_("%sを指差し、恐ろしげに呪文を唱えた!", "You point at %s, incanting terribly!"), m_name);
4215
4216                         if (r_ptr->flagsr & RFR_RES_ALL)
4217                         {
4218                                 note = _("には完全な耐性がある!", " is immune.");
4219                                 skipped = TRUE;
4220                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4221                                 break;
4222                         }
4223
4224                         /* Attempt a saving throw */
4225                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
4226                         {
4227                                 note = _("には効果がなかった。", " is unaffected.");
4228                                 dam = 0;
4229                         }
4230                         break;
4231                 }
4232
4233                 /* CAUSE_4 */
4234                 case GF_CAUSE_4:
4235                 {
4236                         if (seen) obvious = TRUE;
4237                         if (!who) 
4238                                 msg_format(_("%sの秘孔を突いて、「お前は既に死んでいる」と叫んだ。", 
4239                                                          "You point at %s, screaming the word, 'DIE!'."), m_name);
4240
4241                         if (r_ptr->flagsr & RFR_RES_ALL)
4242                         {
4243                                 note = _("には完全な耐性がある!", " is immune.");
4244                                 skipped = TRUE;
4245                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4246                                 break;
4247                         }
4248
4249                         /* Attempt a saving throw */
4250                         if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (caster_ptr->r_idx != MON_KENSHIROU)))
4251                         {
4252                                 note = _("には効果がなかった。", " is unaffected.");
4253                                 dam = 0;
4254                         }
4255                         break;
4256                 }
4257
4258                 /* HAND_DOOM */
4259                 case GF_HAND_DOOM:
4260                 {
4261                         if (seen) obvious = TRUE;
4262
4263                         if (r_ptr->flagsr & RFR_RES_ALL)
4264                         {
4265                                 note = _("には完全な耐性がある!", " is immune.");
4266                                 skipped = TRUE;
4267                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4268                                 break;
4269                         }
4270
4271                         if (r_ptr->flags1 & RF1_UNIQUE)
4272                         {
4273                                 note = _("には効果がなかった。", " is unaffected.");
4274                                 dam = 0;
4275                         }
4276                         else
4277                         {
4278                                 if ((who > 0) ? ((caster_lev + randint1(dam)) > (r_ptr->level + 10 + randint1(20))) :
4279                                    (((caster_lev / 2) + randint1(dam)) > (r_ptr->level + randint1(200))))
4280                                 {
4281                                         dam = ((40 + randint1(20)) * m_ptr->hp) / 100;
4282
4283                                         if (m_ptr->hp < dam) dam = m_ptr->hp - 1;
4284                                 }
4285                                 else
4286                                 {
4287                                         note = _("は耐性を持っている!", "resists!");
4288                                         dam = 0;
4289                                 }
4290                         }
4291                         break;
4292                 }
4293
4294                 /* Capture monster */
4295                 case GF_CAPTURE:
4296                 {
4297                         int nokori_hp;
4298                         if ((p_ptr->inside_quest && (quest[p_ptr->inside_quest].type == QUEST_TYPE_KILL_ALL) && !is_pet(m_ptr)) ||
4299                                 (r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_NAZGUL)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (r_ptr->flags1 & RF1_QUESTOR) || m_ptr->parent_m_idx)
4300                         {
4301                                 msg_format(_("%sには効果がなかった。", "%s is unaffected."), m_name);
4302                                 skipped = TRUE;
4303                                 break;
4304                         }
4305
4306                         if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
4307                         else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(m_ptr->r_idx))
4308                                 nokori_hp = m_ptr->maxhp * 3 / 10;
4309                         else
4310                                 nokori_hp = m_ptr->maxhp * 3 / 20;
4311
4312                         if (m_ptr->hp >= nokori_hp)
4313                         {
4314                                 msg_format(_("もっと弱らせないと。", "You need to weaken %s more."), m_name);
4315                                 skipped = TRUE;
4316                         }
4317                         else if (m_ptr->hp < randint0(nokori_hp))
4318                         {
4319                                 if (m_ptr->mflag2 & MFLAG2_CHAMELEON) choose_new_monster(c_ptr->m_idx, FALSE, MON_CHAMELEON);
4320                                 msg_format(_("%sを捕えた!", "You capture %^s!"), m_name);
4321                                 cap_mon = m_ptr->r_idx;
4322                                 cap_mspeed = m_ptr->mspeed;
4323                                 cap_hp = m_ptr->hp;
4324                                 cap_maxhp = m_ptr->max_maxhp;
4325                                 cap_nickname = m_ptr->nickname; /* Quark transfer */
4326                                 if (c_ptr->m_idx == p_ptr->riding)
4327                                 {
4328                                         if (rakuba(-1, FALSE))
4329                                         {
4330                                                 msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
4331                                         }
4332                                 }
4333
4334                                 delete_monster_idx(c_ptr->m_idx);
4335
4336                                 return (TRUE);
4337                         }
4338                         else
4339                         {
4340                                 msg_format(_("うまく捕まえられなかった。", "You failed to capture %s."), m_name);
4341                                 skipped = TRUE;
4342                         }
4343                         break;
4344                 }
4345
4346                 /* Attack (Use "dam" as attack type) */
4347                 case GF_ATTACK:
4348                 {
4349                         /* Return this monster's death */
4350                         return py_attack(y, x, dam);
4351                 }
4352
4353                 /* Sleep (Use "dam" as "power") */
4354                 case GF_ENGETSU:
4355                 {
4356                         int effect = 0;
4357                         bool done = TRUE;
4358
4359                         if (seen) obvious = TRUE;
4360
4361                         if (r_ptr->flagsr & RFR_RES_ALL)
4362                         {
4363                                 note = _("には効果がなかった。", " is unaffected.");
4364                                 dam = 0;
4365                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4366                                 break;
4367                         }
4368                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
4369                         {
4370                                 note = _("には効果がなかった。", " is unaffected.");
4371                                 dam = 0;
4372                                 skipped = TRUE;
4373                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
4374                                 break;
4375                         }
4376                         if (MON_CSLEEP(m_ptr))
4377                         {
4378                                 note = _("には効果がなかった。", " is unaffected.");
4379                                 dam = 0;
4380                                 skipped = TRUE;
4381                                 break;
4382                         }
4383
4384                         if (one_in_(5)) effect = 1;
4385                         else if (one_in_(4)) effect = 2;
4386                         else if (one_in_(3)) effect = 3;
4387                         else done = FALSE;
4388
4389                         if (effect == 1)
4390                         {
4391                                 /* Powerful monsters can resist */
4392                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4393                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4394                                 {
4395                                         note = _("には効果がなかった。", " is unaffected.");
4396                                         obvious = FALSE;
4397                                 }
4398
4399                                 /* Normal monsters slow down */
4400                                 else
4401                                 {
4402                                         if (set_monster_slow(c_ptr->m_idx, MON_SLOW(m_ptr) + 50))
4403                                         {
4404                                                 note = _("の動きが遅くなった。", " starts moving slower.");
4405                                         }
4406                                 }
4407                         }
4408
4409                         else if (effect == 2)
4410                         {
4411                                 do_stun = damroll((p_ptr->lev / 10) + 3 , (dam)) + 1;
4412
4413                                 /* Attempt a saving throw */
4414                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4415                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4416                                 {
4417                                         /* Resist */
4418                                         do_stun = 0;
4419
4420                                         /* No obvious effect */
4421                                         note = _("には効果がなかった。", " is unaffected.");
4422                                         obvious = FALSE;
4423                                 }
4424                         }
4425
4426                         else if (effect == 3)
4427                         {
4428                                 /* Attempt a saving throw */
4429                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4430                                         (r_ptr->flags3 & RF3_NO_SLEEP) ||
4431                                         (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4432                                 {
4433                                         /* Memorize a flag */
4434                                         if (r_ptr->flags3 & RF3_NO_SLEEP)
4435                                         {
4436                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
4437                                         }
4438
4439                                         /* No obvious effect */
4440                                         note = _("には効果がなかった。", " is unaffected.");
4441                                         obvious = FALSE;
4442                                 }
4443                                 else
4444                                 {
4445                                         /* Go to sleep (much) later */
4446                                         note = _("は眠り込んでしまった!", " falls asleep!");
4447                                         do_sleep = 500;
4448                                 }
4449                         }
4450
4451                         if (!done)
4452                         {
4453                                 note = _("には効果がなかった。", " is unaffected.");
4454                         }
4455
4456                         /* No "real" damage */
4457                         dam = 0;
4458                         break;
4459                 }
4460
4461                 /* GENOCIDE */
4462                 case GF_GENOCIDE:
4463                 {
4464                         if (seen) obvious = TRUE;
4465
4466                         if (r_ptr->flagsr & RFR_RES_ALL)
4467                         {
4468                                 note = _("には効果がなかった。", " is unaffected.");
4469                                 skipped = TRUE;
4470                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4471                                 break;
4472                         }
4473
4474                         if (genocide_aux(c_ptr->m_idx, dam, !who, (r_ptr->level + 1) / 2, _("モンスター消滅", "Genocide One")))
4475                         {
4476                                 if (seen_msg) msg_format(_("%sは消滅した!", "%^s disappered!"), m_name);
4477                                 chg_virtue(V_VITALITY, -1);
4478                                 return TRUE;
4479                         }
4480
4481                         skipped = TRUE;
4482                         break;
4483                 }
4484
4485                 case GF_PHOTO:
4486                 {
4487                         if (!who) msg_format(_("%sを写真に撮った。", "You take a photograph of %s."), m_name);
4488                         /* Hurt by light */
4489                         if (r_ptr->flags3 & (RF3_HURT_LITE))
4490                         {
4491                                 /* Obvious effect */
4492                                 if (seen) obvious = TRUE;
4493
4494                                 /* Memorize the effects */
4495                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4496
4497                                 /* Special effect */
4498                                 note = _("は光に身をすくめた!", " cringes from the light!");
4499                                 note_dies = _("は光を受けてしぼんでしまった!", " shrivels away in the light!");
4500                         }
4501
4502                         /* Normally no damage */
4503                         else
4504                         {
4505                                 /* No damage */
4506                                 dam = 0;
4507                         }
4508
4509                         photo = m_ptr->r_idx;
4510
4511                         break;
4512                 }
4513
4514
4515                 /* blood curse */
4516                 case GF_BLOOD_CURSE:
4517                 {
4518                         if (seen) obvious = TRUE;
4519
4520                         if (r_ptr->flagsr & RFR_RES_ALL)
4521                         {
4522                                 note = _("には完全な耐性がある!", " is immune.");
4523                                 dam = 0;
4524                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4525                                 break;
4526                         }
4527                         break;
4528                 }
4529
4530                 case GF_CRUSADE:
4531                 {
4532                         bool success = FALSE;
4533                         if (seen) obvious = TRUE;
4534
4535                         if ((r_ptr->flags3 & (RF3_GOOD)) && !p_ptr->inside_arena)
4536                         {
4537                                 if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 50;
4538                                 if (dam < 1) dam = 1;
4539
4540                                 /* No need to tame your pet */
4541                                 if (is_pet(m_ptr))
4542                                 {
4543                                         note = _("の動きが速くなった。", " starts moving faster.");
4544                                         (void)set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100);
4545                                         success = TRUE;
4546                                 }
4547
4548                                 /* Attempt a saving throw */
4549                                 else if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
4550                                         (r_ptr->flags1 & (RF1_UNIQUE)) ||
4551                                         (m_ptr->mflag2 & MFLAG2_NOPET) ||
4552                                         (p_ptr->cursed & TRC_AGGRAVATE) ||
4553                                          ((r_ptr->level+10) > randint1(dam)))
4554                                 {
4555                                         /* Resist */
4556                                         if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4557                                 }
4558                                 else
4559                                 {
4560                                         note = _("を支配した。", " is tamed!");
4561                                         set_pet(m_ptr);
4562                                         (void)set_monster_fast(c_ptr->m_idx, MON_FAST(m_ptr) + 100);
4563
4564                                         /* Learn about type */
4565                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
4566                                         success = TRUE;
4567                                 }
4568                         }
4569
4570                         if (!success)
4571                         {
4572                                 if (!(r_ptr->flags3 & RF3_NO_FEAR))
4573                                 {
4574                                         do_fear = randint1(90)+10;
4575                                 }
4576                                 else if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_FEAR);
4577                         }
4578
4579                         /* No "real" damage */
4580                         dam = 0;
4581                         break;
4582                 }
4583
4584                 case GF_WOUNDS:
4585                 {
4586                         if (seen) obvious = TRUE;
4587
4588                         if (r_ptr->flagsr & RFR_RES_ALL)
4589                         {
4590                                 note = _("には完全な耐性がある!", " is immune.");
4591                                 skipped = TRUE;
4592                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4593                                 break;
4594                         }
4595
4596                         /* Attempt a saving throw */
4597                         if (randint0(100 + dam) < (r_ptr->level + 50))
4598                         {
4599                                 note = _("には効果がなかった。", " is unaffected.");
4600                                 dam = 0;
4601                         }
4602                         break;
4603                 }
4604
4605                 /* Default */
4606                 default:
4607                 {
4608                         /* Irrelevant */
4609                         skipped = TRUE;
4610
4611                         /* No damage */
4612                         dam = 0;
4613
4614                         break;
4615                 }
4616         }
4617
4618
4619         /* Absolutely no effect */
4620         if (skipped) return (FALSE);
4621
4622         /* "Unique" monsters cannot be polymorphed */
4623         if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
4624
4625         /* Quest monsters cannot be polymorphed */
4626         if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
4627
4628         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_poly = FALSE;
4629
4630         /* "Unique" and "quest" monsters can only be "killed" by the player. */
4631         if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle)
4632         {
4633                 if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
4634         }
4635
4636         if (!who && slept)
4637         {
4638                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
4639                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
4640         }
4641
4642         /* Modify the damage */
4643         tmp = dam;
4644         dam = mon_damage_mod(m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
4645         if ((tmp > 0) && (dam == 0)) note = _("はダメージを受けていない。", " is unharmed.");
4646
4647         /* Check for death */
4648         if (dam > m_ptr->hp)
4649         {
4650                 /* Extract method of death */
4651                 note = note_dies;
4652         }
4653         else
4654         {
4655                 /* Sound and Impact resisters never stun */
4656                 if (do_stun &&
4657                         !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
4658                         !(r_ptr->flags3 & RF3_NO_STUN))
4659                 {
4660                         if (seen) obvious = TRUE;
4661
4662                         /* Get stunned */
4663                         if (MON_STUNNED(m_ptr))
4664                         {
4665                                 note = _("はひどくもうろうとした。", " is more dazed.");
4666                                 tmp = MON_STUNNED(m_ptr) + (do_stun / 2);
4667                         }
4668                         else
4669                         {
4670                                 note = _("はもうろうとした。", " is dazed.");
4671                                 tmp = do_stun;
4672                         }
4673
4674                         /* Apply stun */
4675                         (void)set_monster_stunned(c_ptr->m_idx, tmp);
4676
4677                         /* Get angry */
4678                         get_angry = TRUE;
4679                 }
4680
4681                 /* Confusion and Chaos resisters (and sleepers) never confuse */
4682                 if (do_conf &&
4683                          !(r_ptr->flags3 & RF3_NO_CONF) &&
4684                          !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
4685                 {
4686                         if (seen) obvious = TRUE;
4687
4688                         /* Already partially confused */
4689                         if (MON_CONFUSED(m_ptr))
4690                         {
4691                                 note = _("はさらに混乱したようだ。", " looks more confused.");
4692                                 tmp = MON_CONFUSED(m_ptr) + (do_conf / 2);
4693                         }
4694
4695                         /* Was not confused */
4696                         else
4697                         {
4698                                 note = _("は混乱したようだ。", " looks confused.");
4699                                 tmp = do_conf;
4700                         }
4701
4702                         /* Apply confusion */
4703                         (void)set_monster_confused(c_ptr->m_idx, tmp);
4704
4705                         /* Get angry */
4706                         get_angry = TRUE;
4707                 }
4708
4709                 if (do_time)
4710                 {
4711                         if (seen) obvious = TRUE;
4712
4713                         if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp - 1;
4714
4715                         if (do_time)
4716                         {
4717                                 note = _("は弱くなったようだ。", " seems weakened.");
4718                                 m_ptr->maxhp -= do_time;
4719                                 if ((m_ptr->hp - dam) > m_ptr->maxhp) dam = m_ptr->hp - m_ptr->maxhp;
4720                         }
4721                         get_angry = TRUE;
4722                 }
4723
4724                 /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
4725                 if (do_poly && (randint1(90) > r_ptr->level))
4726                 {
4727                         if (polymorph_monster(y, x))
4728                         {
4729                                 if (seen) obvious = TRUE;
4730
4731                                 /* Monster polymorphs */
4732                                 note = _("が変身した!", " changes!");
4733
4734                                 /* Turn off the damage */
4735                                 dam = 0;
4736                         }
4737                         else
4738                         {
4739                                 /* No polymorph */
4740                                 note = _("には効果がなかった。", " is unaffected.");
4741                         }
4742
4743                         /* Hack -- Get new monster */
4744                         m_ptr = &m_list[c_ptr->m_idx];
4745
4746                         /* Hack -- Get new race */
4747                         r_ptr = &r_info[m_ptr->r_idx];
4748                 }
4749
4750                 /* Handle "teleport" */
4751                 if (do_dist)
4752                 {
4753                         if (seen) obvious = TRUE;
4754
4755                         note = _("が消え去った!", " disappears!");
4756
4757                         if (!who) chg_virtue(V_VALOUR, -1);
4758
4759                         /* Teleport */
4760                         teleport_away(c_ptr->m_idx, do_dist,
4761                                                 (!who ? TELEPORT_DEC_VALOUR : 0L) | TELEPORT_PASSIVE);
4762
4763                         /* Hack -- get new location */
4764                         y = m_ptr->fy;
4765                         x = m_ptr->fx;
4766
4767                         /* Hack -- get new grid */
4768                         c_ptr = &cave[y][x];
4769                 }
4770
4771                 /* Fear */
4772                 if (do_fear)
4773                 {
4774                         /* Set fear */
4775                         (void)set_monster_monfear(c_ptr->m_idx, MON_MONFEAR(m_ptr) + do_fear);
4776
4777                         /* Get angry */
4778                         get_angry = TRUE;
4779                 }
4780         }
4781
4782         if (typ == GF_DRAIN_MANA)
4783         {
4784                 /* Drain mana does nothing */
4785         }
4786
4787         /* If another monster did the damage, hurt the monster by hand */
4788         else if (who)
4789         {
4790                 /* Redraw (later) if needed */
4791                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
4792                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
4793
4794                 /* Wake the monster up */
4795                 (void)set_monster_csleep(c_ptr->m_idx, 0);
4796
4797                 /* Hurt the monster */
4798                 m_ptr->hp -= dam;
4799
4800                 /* Dead monster */
4801                 if (m_ptr->hp < 0)
4802                 {
4803                         bool sad = FALSE;
4804
4805                         if (is_pet(m_ptr) && !(m_ptr->ml))
4806                                 sad = TRUE;
4807
4808                         /* Give detailed messages if destroyed */
4809                         if (known && note)
4810                         {
4811                                 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
4812                                 if (see_s_msg)
4813                                 {
4814                                         msg_format("%^s%s", m_name, note);
4815                                 }
4816                                 else
4817                                 {
4818                                         mon_fight = TRUE;
4819                                 }
4820                         }
4821
4822                         if (who > 0) monster_gain_exp(who, m_ptr->r_idx);
4823
4824                         /* Generate treasure, etc */
4825                         monster_death(c_ptr->m_idx, FALSE);
4826
4827
4828                         delete_monster_idx(c_ptr->m_idx);
4829
4830                         if (sad)
4831                         {
4832                                 msg_print(_("少し悲しい気分がした。", "You feel sad for a moment."));
4833                         }
4834                 }
4835
4836                 /* Damaged monster */
4837                 else
4838                 {
4839                         /* Give detailed messages if visible or destroyed */
4840                         if (note && seen_msg) msg_format("%^s%s", m_name, note);
4841
4842                         /* Hack -- Pain message */
4843                         else if (see_s_msg)
4844                         {
4845                                 message_pain(c_ptr->m_idx, dam);
4846                         }
4847                         else
4848                         {
4849                                 mon_fight = TRUE;
4850                         }
4851
4852                         /* Hack -- handle sleep */
4853                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4854                 }
4855         }
4856
4857         else if (heal_leper)
4858         {
4859                 if (seen_msg) msg_print(_("不潔な病人は病気が治った!", "The Mangy looking leper is healed!"));
4860
4861                 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
4862                 {
4863                         char m2_name[MAX_NLEN];
4864
4865                         monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
4866                         do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
4867                 }
4868
4869                 delete_monster_idx(c_ptr->m_idx);
4870         }
4871
4872         /* If the player did it, give him experience, check fear */
4873         else
4874         {
4875                 bool fear = FALSE;
4876
4877                 /* Hurt the monster, check for fear and death */
4878                 if (mon_take_hit(c_ptr->m_idx, dam, &fear, note_dies))
4879                 {
4880                         /* Dead monster */
4881                 }
4882
4883                 /* Damaged monster */
4884                 else
4885                 {
4886                         /* HACK - anger the monster before showing the sleep message */
4887                         if (do_sleep) anger_monster(m_ptr);
4888
4889                         /* Give detailed messages if visible or destroyed */
4890                         if (note && seen_msg)
4891                                 msg_format(_("%s%s", "%^s%s"), m_name, note);
4892
4893                         /* Hack -- Pain message */
4894                         else if (known && (dam || !do_fear))
4895                         {
4896                                 message_pain(c_ptr->m_idx, dam);
4897                         }
4898
4899                         /* Anger monsters */
4900                         if (((dam > 0) || get_angry) && !do_sleep)
4901                                 anger_monster(m_ptr);
4902
4903                         if ((fear || do_fear) && seen)
4904                         {
4905                                 sound(SOUND_FLEE);
4906                                 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4907                         }
4908
4909                         /* Hack -- handle sleep */
4910                         if (do_sleep) (void)set_monster_csleep(c_ptr->m_idx, do_sleep);
4911                 }
4912         }
4913
4914         if ((typ == GF_BLOOD_CURSE) && one_in_(4))
4915         {
4916                 int curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
4917                 int count = 0;
4918                 do
4919                 {
4920                         switch (randint1(28))
4921                         {
4922                         case 1: case 2:
4923                                 if (!count)
4924                                 {
4925                                         msg_print(_("地面が揺れた...", "The ground trembles..."));
4926                                         earthquake(ty, tx, 4 + randint0(4));
4927                                         if (!one_in_(6)) break;
4928                                 }
4929                         case 3: case 4: case 5: case 6:
4930                                 if (!count)
4931                                 {
4932                                         int extra_dam = damroll(10, 10);
4933                                         msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
4934
4935                                         project(0, 8, ty, tx, extra_dam, GF_MANA, curse_flg, -1);
4936                                         if (!one_in_(6)) break;
4937                                 }
4938                         case 7: case 8:
4939                                 if (!count)
4940                                 {
4941                                         msg_print(_("空間が歪んだ!", "Space warps about you!"));
4942
4943                                         if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
4944                                         if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
4945                                         if (!one_in_(6)) break;
4946                                 }
4947                         case 9: case 10: case 11:
4948                                 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
4949                                 project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
4950                                 if (!one_in_(6)) break;
4951                         case 12: case 13: case 14: case 15: case 16:
4952                                 aggravate_monsters(0);
4953                                 if (!one_in_(6)) break;
4954                         case 17: case 18:
4955                                 count += activate_hi_summon(ty, tx, TRUE);
4956                                 if (!one_in_(6)) break;
4957                         case 19: case 20: case 21: case 22:
4958                         {
4959                                 bool pet = !one_in_(3);
4960                                 BIT_FLAGS mode = PM_ALLOW_GROUP;
4961
4962                                 if (pet) mode |= PM_FORCE_PET;
4963                                 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
4964
4965                                 count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev*2/3+randint1(p_ptr->lev/2) : dun_level), 0, mode, '\0');
4966                                 if (!one_in_(6)) break;
4967                         }
4968                         case 23: case 24: case 25:
4969                                 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
4970                                 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
4971
4972                                 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
4973                                 else lose_exp(p_ptr->exp / 16);
4974                                 if (!one_in_(6)) break;
4975                         case 26: case 27: case 28:
4976                         {
4977                                 int i = 0;
4978                                 if (one_in_(13))
4979                                 {
4980                                         while (i < A_MAX)
4981                                         {
4982                                                 do
4983                                                 {
4984                                                         (void)do_dec_stat(i);
4985                                                 }
4986                                                 while (one_in_(2));
4987
4988                                                 i++;
4989                                         }
4990                                 }
4991                                 else
4992                                 {
4993                                         (void)do_dec_stat(randint0(6));
4994                                 }
4995                                 break;
4996                         }
4997                         }
4998                 }
4999                 while (one_in_(5));
5000         }
5001
5002         if (p_ptr->inside_battle)
5003         {
5004                 p_ptr->health_who = c_ptr->m_idx;
5005                 p_ptr->redraw |= (PR_HEALTH);
5006                 handle_stuff();
5007         }
5008
5009         /* Verify this code */
5010         if (m_ptr->r_idx) update_monster(c_ptr->m_idx, FALSE);
5011
5012         /* Redraw the monster grid */
5013         lite_spot(y, x);
5014
5015
5016         /* Update monster recall window */
5017         if ((p_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
5018         {
5019                 p_ptr->window |= (PW_MONSTER);
5020         }
5021
5022         if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
5023         {
5024                 if (!who)
5025                 {
5026                         if (!(flg & PROJECT_NO_HANGEKI))
5027                         {
5028                                 set_target(m_ptr, monster_target_y, monster_target_x);
5029                         }
5030                 }
5031                 else if ((who > 0) && is_pet(caster_ptr) && !player_bold(m_ptr->target_y, m_ptr->target_x))
5032                 {
5033                         set_target(m_ptr, caster_ptr->fy, caster_ptr->fx);
5034                 }
5035         }
5036
5037         if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx) && (dam > 0))
5038         {
5039                 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
5040                 rakubadam_m = (dam > 200) ? 200 : dam;
5041         }
5042
5043
5044         if (photo)
5045         {
5046                 object_type *q_ptr;
5047                 object_type forge;
5048                 q_ptr = &forge;
5049
5050                 /* Prepare to make a Blade of Chaos */
5051                 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
5052
5053                 q_ptr->pval = photo;
5054
5055                 /* Mark the item as fully known */
5056                 q_ptr->ident |= (IDENT_MENTAL);
5057                 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
5058         }
5059
5060         /* Track it */
5061         project_m_n++;
5062         project_m_x = x;
5063         project_m_y = y;
5064
5065         /* Return "Anything seen?" */
5066         return (obvious);
5067 }
5068
5069 /*!
5070  * @brief 汎用的なビーム/ボルト/ボール系によるプレイヤーへの効果処理 / Helper function for "project()" below.
5071  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
5072  * @param who_name 効果を起こしたモンスターの名前
5073  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
5074  * @param y 目標Y座標 / Target y location (or location to travel "towards")
5075  * @param x 目標X座標 / Target x location (or location to travel "towards")
5076  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
5077  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
5078  * @param flg 効果フラグ
5079  * @param monspell 効果元のモンスター魔法ID
5080  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
5081  * @details
5082  * Handle a beam/bolt/ball causing damage to the player.
5083  * This routine takes a "source monster" (by index), a "distance", a default
5084  * "damage", and a "damage type".  See "project_m()" above.
5085  * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
5086  * is reduced (see "project_m()" above).  This can happen if a monster breathes
5087  * at the player and hits a wall instead.
5088  * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
5089  * to know if this is actually a ball or a bolt spell
5090  * We return "TRUE" if any "obvious" effects were observed.  XXX XXX Actually,
5091  * we just assume that the effects were obvious, for historical reasons.
5092  */
5093 static bool project_p(MONSTER_IDX who, concptr who_name, int r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
5094 {
5095         int k = 0;
5096         DEPTH rlev = 0;
5097
5098         /* Hack -- assume obvious */
5099         bool obvious = TRUE;
5100
5101         /* Player blind-ness */
5102         bool blind = (p_ptr->blind ? TRUE : FALSE);
5103
5104         /* Player needs a "description" (he is blind) */
5105         bool fuzzy = FALSE;
5106
5107         /* Source monster */
5108         monster_type *m_ptr = NULL;
5109
5110         /* Monster name (for attacks) */
5111         GAME_TEXT m_name[MAX_NLEN];
5112
5113         /* Monster name (for damage) */
5114         char killer[80];
5115
5116         /* Hack -- messages */
5117         concptr act = NULL;
5118
5119         int get_damage = 0;
5120
5121
5122         /* Player is not here */
5123         if (!player_bold(y, x)) return (FALSE);
5124
5125         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (p_ptr->lev*3/5+20)) && who && (who != p_ptr->riding))
5126         {
5127                 if (kawarimi(TRUE)) return FALSE;
5128         }
5129
5130         /* Player cannot hurt himself */
5131         if (!who) return (FALSE);
5132         if (who == p_ptr->riding) return (FALSE);
5133
5134         if ((p_ptr->reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
5135         {
5136                 POSITION t_y, t_x;
5137                 int max_attempts = 10;
5138                 sound(SOUND_REFLECT);
5139
5140                 if (blind) 
5141                         msg_print(_("何かが跳ね返った!", "Something bounces!"));
5142                 else if (p_ptr->special_defense & KATA_FUUJIN) 
5143                         msg_print(_("風の如く武器を振るって弾き返した!", "The attack bounces!"));
5144                 else 
5145                         msg_print(_("攻撃が跳ね返った!", "The attack bounces!"));
5146
5147
5148                 /* Choose 'new' target */
5149                 if (who > 0)
5150                 {
5151                         do
5152                         {
5153                                 t_y = m_list[who].fy - 1 + randint1(3);
5154                                 t_x = m_list[who].fx - 1 + randint1(3);
5155                                 max_attempts--;
5156                         }
5157                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(p_ptr->y, p_ptr->x, t_y, t_x));
5158
5159                         if (max_attempts < 1)
5160                         {
5161                                 t_y = m_list[who].fy;
5162                                 t_x = m_list[who].fx;
5163                         }
5164                 }
5165                 else
5166                 {
5167                         t_y = p_ptr->y - 1 + randint1(3);
5168                         t_x = p_ptr->x - 1 + randint1(3);
5169                 }
5170
5171                 project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL|PROJECT_REFLECTABLE), monspell);
5172
5173                 disturb(TRUE, TRUE);
5174                 return TRUE;
5175         }
5176
5177         /* Limit maximum damage */
5178         if (dam > 1600) dam = 1600;
5179
5180         /* Reduce damage by distance */
5181         dam = (dam + r) / (r + 1);
5182
5183
5184         /* If the player is blind, be more descriptive */
5185         if (blind) fuzzy = TRUE;
5186
5187
5188         if (who > 0)
5189         {
5190                 m_ptr = &m_list[who];
5191                 rlev = (((&r_info[m_ptr->r_idx])->level >= 1) ? (&r_info[m_ptr->r_idx])->level : 1);
5192                 monster_desc(m_name, m_ptr, 0);
5193
5194                 /* Get the monster's real name (gotten before polymorph!) */
5195                 strcpy(killer, who_name);
5196         }
5197         else
5198         {
5199                 switch (who)
5200                 {
5201                 case PROJECT_WHO_UNCTRL_POWER:
5202                         strcpy(killer, _("制御できない力の氾流", "uncontrollable power storm"));
5203                         break;
5204
5205                 case PROJECT_WHO_GLASS_SHARDS:
5206                         strcpy(killer, _("ガラスの破片", "shards of glass"));
5207                         break;
5208
5209                 default:
5210                         strcpy(killer, _("罠", "a trap"));
5211                         break;
5212                 }
5213
5214                 /* Paranoia */
5215                 strcpy(m_name, killer);
5216         }
5217
5218         /* Analyze the damage */
5219         switch (typ)
5220         {
5221                 /* Standard damage -- hurts inventory too */
5222                 case GF_ACID:
5223                 {
5224                         if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));                    
5225                         get_damage = acid_dam(dam, killer, monspell, FALSE);
5226                         break;
5227                 }
5228
5229                 /* Standard damage -- hurts inventory too */
5230                 case GF_FIRE:
5231                 {
5232                         if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
5233                         get_damage = fire_dam(dam, killer, monspell, FALSE);
5234                         break;
5235                 }
5236
5237                 /* Standard damage -- hurts inventory too */
5238                 case GF_COLD:
5239                 {
5240                         if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
5241                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5242                         break;
5243                 }
5244
5245                 /* Standard damage -- hurts inventory too */
5246                 case GF_ELEC:
5247                 {
5248                         if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
5249                         get_damage = elec_dam(dam, killer, monspell, FALSE);
5250                         break;
5251                 }
5252
5253                 /* Standard damage -- also poisons player */
5254                 case GF_POIS:
5255                 {
5256                         bool double_resist = IS_OPPOSE_POIS();
5257                         if (fuzzy) msg_print(_("毒で攻撃された!", "You are hit by poison!"));
5258
5259                         if (p_ptr->resist_pois) dam = (dam + 2) / 3;
5260                         if (double_resist) dam = (dam + 2) / 3;
5261
5262                         if ((!(double_resist || p_ptr->resist_pois)) && one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
5263                         {
5264                                 do_dec_stat(A_CON);
5265                         }
5266
5267                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5268
5269                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
5270                         {
5271                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
5272                         }
5273                         break;
5274                 }
5275
5276                 /* Standard damage -- also poisons / mutates player */
5277                 case GF_NUKE:
5278                 {
5279                         bool double_resist = IS_OPPOSE_POIS();
5280                         if (fuzzy) msg_print(_("放射能で攻撃された!", "You are hit by radiation!"));
5281
5282                         if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
5283                         if (double_resist) dam = (2 * dam + 2) / 5;
5284                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5285                         if (!(double_resist || p_ptr->resist_pois) && !CHECK_MULTISHADOW())
5286                         {
5287                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
5288
5289                                 if (one_in_(5)) /* 6 */
5290                                 {
5291                                         msg_print(_("奇形的な変身を遂げた!", "You undergo a freakish metamorphosis!"));
5292                                         if (one_in_(4)) /* 4 */
5293                                                 do_poly_self();
5294                                         else
5295                                                 mutate_player();
5296                                 }
5297
5298                                 if (one_in_(6))
5299                                 {
5300                                         inven_damage(set_acid_destroy, 2);
5301                                 }
5302                         }
5303                         break;
5304                 }
5305
5306                 /* Standard damage */
5307                 case GF_MISSILE:
5308                 {
5309                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5310                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5311                         break;
5312                 }
5313
5314                 /* Holy Orb -- Player only takes partial damage */
5315                 case GF_HOLY_FIRE:
5316                 {
5317                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5318                         if (p_ptr->align > 10)
5319                                 dam /= 2;
5320                         else if (p_ptr->align < -10)
5321                                 dam *= 2;
5322                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5323                         break;
5324                 }
5325
5326                 case GF_HELL_FIRE:
5327                 {
5328                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5329                         if (p_ptr->align > 10)
5330                                 dam *= 2;
5331                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5332                         break;
5333                 }
5334
5335                 /* Arrow -- XXX no dodging */
5336                 case GF_ARROW:
5337                 {
5338                         if (fuzzy)
5339                         {
5340                                 msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5341                         }
5342                         else if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
5343                         {
5344                                 msg_print(_("矢を斬り捨てた!", "You cut down the arrow!"));
5345                                 break;
5346                         }
5347                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5348                         break;
5349                 }
5350
5351                 /* Plasma -- XXX No resist */
5352                 case GF_PLASMA:
5353                 {
5354                         if (fuzzy) msg_print(_("何かとても熱いもので攻撃された!", "You are hit by something *HOT*!"));
5355                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5356
5357                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5358                         {
5359                                 int plus_stun = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
5360                                 (void)set_stun(p_ptr->stun + plus_stun);
5361                         }
5362
5363                         if (!(p_ptr->resist_fire || IS_OPPOSE_FIRE() || p_ptr->immune_fire))
5364                         {
5365                                 inven_damage(set_acid_destroy, 3);
5366                         }
5367
5368                         break;
5369                 }
5370
5371                 /* Nether -- drain experience */
5372                 case GF_NETHER:
5373                 {
5374                         if (fuzzy) msg_print(_("地獄の力で攻撃された!", "You are hit by nether forces!"));
5375                         if (p_ptr->resist_neth)
5376                         {
5377                                 if (!prace_is_(RACE_SPECTRE))
5378                                 {
5379                                         dam *= 6; dam /= (randint1(4) + 7);
5380                                 }
5381                         }
5382                         else if (!CHECK_MULTISHADOW()) drain_exp(200 + (p_ptr->exp / 100), 200 + (p_ptr->exp / 1000), 75);
5383
5384                         if (prace_is_(RACE_SPECTRE) && !CHECK_MULTISHADOW())
5385                         {
5386                                 msg_print(_("気分がよくなった。", "You feel invigorated!"));
5387                                 hp_player(dam / 4);
5388                                 learn_spell(monspell);
5389                         }
5390                         else
5391                         {
5392                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5393                         }
5394
5395                         break;
5396                 }
5397
5398                 /* Water -- stun/confuse */
5399                 case GF_WATER:
5400                 {
5401                         if (fuzzy) msg_print(_("何か湿ったもので攻撃された!", "You are hit by something wet!"));
5402                         if (!CHECK_MULTISHADOW())
5403                         {
5404                                 if (!p_ptr->resist_sound && !p_ptr->resist_water)
5405                                 {
5406                                         set_stun(p_ptr->stun + randint1(40));
5407                                 }
5408                                 if (!p_ptr->resist_conf && !p_ptr->resist_water)
5409                                 {
5410                                         set_confused(p_ptr->confused + randint1(5) + 5);
5411                                 }
5412
5413                                 if (one_in_(5) && !p_ptr->resist_water)
5414                                 {
5415                                         inven_damage(set_cold_destroy, 3);
5416                                 }
5417
5418                                 if (p_ptr->resist_water) get_damage /= 4;
5419                         }
5420
5421                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5422                         break;
5423                 }
5424
5425                 /* Chaos -- many effects */
5426                 case GF_CHAOS:
5427                 {
5428                         if (fuzzy) msg_print(_("無秩序の波動で攻撃された!", "You are hit by a wave of anarchy!"));
5429                         if (p_ptr->resist_chaos)
5430                         {
5431                                 dam *= 6; dam /= (randint1(4) + 7);
5432                         }
5433
5434                         if (!CHECK_MULTISHADOW())
5435                         {
5436                                 if (!p_ptr->resist_conf)
5437                                 {
5438                                         (void)set_confused(p_ptr->confused + randint0(20) + 10);
5439                                 }
5440                                 if (!p_ptr->resist_chaos)
5441                                 {
5442                                         (void)set_image(p_ptr->image + randint1(10));
5443                                         if (one_in_(3))
5444                                         {
5445                                                 msg_print(_("あなたの身体はカオスの力で捻じ曲げられた!", "Your body is twisted by chaos!"));
5446                                                 (void)gain_random_mutation(0);
5447                                         }
5448                                 }
5449                                 if (!p_ptr->resist_neth && !p_ptr->resist_chaos)
5450                                 {
5451                                         drain_exp(5000 + (p_ptr->exp / 100), 500 + (p_ptr->exp / 1000), 75);
5452                                 }
5453
5454                                 if (!p_ptr->resist_chaos || one_in_(9))
5455                                 {
5456                                         inven_damage(set_elec_destroy, 2);
5457                                         inven_damage(set_fire_destroy, 2);
5458                                 }
5459                         }
5460
5461                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5462                         break;
5463                 }
5464
5465                 /* Shards -- mostly cutting */
5466                 case GF_SHARDS:
5467                 {
5468                         if (fuzzy) msg_print(_("何か鋭いもので攻撃された!", "You are hit by something sharp!"));
5469                         if (p_ptr->resist_shard)
5470                         {
5471                                 dam *= 6; dam /= (randint1(4) + 7);
5472                         }
5473                         else if (!CHECK_MULTISHADOW())
5474                         {
5475                                 (void)set_cut(p_ptr->cut + dam);
5476                         }
5477
5478                         if (!p_ptr->resist_shard || one_in_(13))
5479                         {
5480                                 inven_damage(set_cold_destroy, 2);
5481                         }
5482
5483                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5484                         break;
5485                 }
5486
5487                 /* Sound -- mostly stunning */
5488                 case GF_SOUND:
5489                 {
5490                         if (fuzzy) msg_print(_("轟音で攻撃された!", "You are hit by a loud noise!"));
5491                         if (p_ptr->resist_sound)
5492                         {
5493                                 dam *= 5; dam /= (randint1(4) + 7);
5494                         }
5495                         else if (!CHECK_MULTISHADOW())
5496                         {
5497                                 int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5498                                 (void)set_stun(p_ptr->stun + plus_stun);
5499                         }
5500
5501                         if (!p_ptr->resist_sound || one_in_(13))
5502                         {
5503                                 inven_damage(set_cold_destroy, 2);
5504                         }
5505
5506                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5507                         break;
5508                 }
5509
5510                 /* Pure confusion */
5511                 case GF_CONFUSION:
5512                 {
5513                         if (fuzzy) msg_print(_("何か混乱するもので攻撃された!", "You are hit by something puzzling!"));
5514                         if (p_ptr->resist_conf)
5515                         {
5516                                 dam *= 5; dam /= (randint1(4) + 7);
5517                         }
5518                         else if (!CHECK_MULTISHADOW())
5519                         {
5520                                 (void)set_confused(p_ptr->confused + randint1(20) + 10);
5521                         }
5522                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5523                         break;
5524                 }
5525
5526                 /* Disenchantment -- see above */
5527                 case GF_DISENCHANT:
5528                 {
5529                         if (fuzzy) msg_print(_("何かさえないもので攻撃された!", "You are hit by something static!"));
5530                         if (p_ptr->resist_disen)
5531                         {
5532                                 dam *= 6; dam /= (randint1(4) + 7);
5533                         }
5534                         else if (!CHECK_MULTISHADOW())
5535                         {
5536                                 (void)apply_disenchant(0);
5537                         }
5538                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5539                         break;
5540                 }
5541
5542                 /* Nexus -- see above */
5543                 case GF_NEXUS:
5544                 {
5545                         if (fuzzy) msg_print(_("何か奇妙なもので攻撃された!", "You are hit by something strange!"));
5546                         if (p_ptr->resist_nexus)
5547                         {
5548                                 dam *= 6; dam /= (randint1(4) + 7);
5549                         }
5550                         else if (!CHECK_MULTISHADOW())
5551                         {
5552                                 apply_nexus(m_ptr);
5553                         }
5554                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5555                         break;
5556                 }
5557
5558                 /* Force -- mostly stun */
5559                 case GF_FORCE:
5560                 {
5561                         if (fuzzy) msg_print(_("運動エネルギーで攻撃された!", "You are hit by kinetic force!"));
5562                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5563                         {
5564                                 (void)set_stun(p_ptr->stun + randint1(20));
5565                         }
5566                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5567                         break;
5568                 }
5569
5570
5571                 /* Rocket -- stun, cut */
5572                 case GF_ROCKET:
5573                 {
5574                         if (fuzzy) msg_print(_("爆発があった!", "There is an explosion!"));
5575                         if (!p_ptr->resist_sound && !CHECK_MULTISHADOW())
5576                         {
5577                                 (void)set_stun(p_ptr->stun + randint1(20));
5578                         }
5579
5580                         if (p_ptr->resist_shard)
5581                         {
5582                                 dam /= 2;
5583                         }
5584                         else if (!CHECK_MULTISHADOW())
5585                         {
5586                                 (void)set_cut(p_ptr->cut + (dam / 2));
5587                         }
5588
5589                         if (!p_ptr->resist_shard || one_in_(12))
5590                         {
5591                                 inven_damage(set_cold_destroy, 3);
5592                         }
5593
5594                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5595                         break;
5596                 }
5597
5598                 /* Inertia -- slowness */
5599                 case GF_INERTIAL:
5600                 {
5601                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5602                         if (!CHECK_MULTISHADOW()) (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5603                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5604                         break;
5605                 }
5606
5607                 /* Lite -- blinding */
5608                 case GF_LITE:
5609                 {
5610                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5611                         if (p_ptr->resist_lite)
5612                         {
5613                                 dam *= 4; dam /= (randint1(4) + 7);
5614                         }
5615                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5616                         {
5617                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5618                         }
5619
5620                         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
5621                         {
5622                                 if (!CHECK_MULTISHADOW()) msg_print(_("光で肉体が焦がされた!", "The light scorches your flesh!"));
5623                                 dam *= 2;
5624                         }
5625                         else if (prace_is_(RACE_S_FAIRY))
5626                         {
5627                                 dam = dam * 4 / 3;
5628                         }
5629
5630                         if (p_ptr->wraith_form) dam *= 2;
5631                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5632
5633                         if (p_ptr->wraith_form && !CHECK_MULTISHADOW())
5634                         {
5635                                 p_ptr->wraith_form = 0;
5636                                 msg_print(_("閃光のため非物質的な影の存在でいられなくなった。",
5637                                         "The light forces you out of your incorporeal shadow form."));
5638
5639                                 p_ptr->redraw |= (PR_MAP | PR_STATUS);
5640                                 p_ptr->update |= (PU_MONSTERS);
5641                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5642                         }
5643
5644                         break;
5645                 }
5646
5647                 /* Dark -- blinding */
5648                 case GF_DARK:
5649                 {
5650                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5651                         if (p_ptr->resist_dark)
5652                         {
5653                                 dam *= 4; dam /= (randint1(4) + 7);
5654
5655                                 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
5656                         }
5657                         else if (!blind && !p_ptr->resist_blind && !CHECK_MULTISHADOW())
5658                         {
5659                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
5660                         }
5661                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5662                         break;
5663                 }
5664
5665                 /* Time -- bolt fewer effects XXX */
5666                 case GF_TIME:
5667                 {
5668                         if (fuzzy) msg_print(_("過去からの衝撃に攻撃された!", "You are hit by a blast from the past!"));
5669                         if (p_ptr->resist_time)
5670                         {
5671                                 dam *= 4;
5672                                 dam /= (randint1(4) + 7);
5673                                 msg_print(_("時間が通り過ぎていく気がする。", "You feel as if time is passing you by."));
5674                         }
5675                         else if (!CHECK_MULTISHADOW())
5676                         {
5677                                 switch (randint1(10))
5678                                 {
5679                                         case 1: case 2: case 3: case 4: case 5:
5680                                         {
5681                                                 if (p_ptr->prace == RACE_ANDROID) break;
5682                                                 msg_print(_("人生が逆戻りした気がする。", "You feel life has clocked back."));
5683                                                 lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
5684                                                 break;
5685                                         }
5686
5687                                         case 6: case 7: case 8: case 9:
5688                                         {
5689                                                 switch (randint1(6))
5690                                                 {
5691                                                         case 1: k = A_STR; act = _("強く", "strong"); break;
5692                                                         case 2: k = A_INT; act = _("聡明で", "bright"); break;
5693                                                         case 3: k = A_WIS; act = _("賢明で", "wise"); break;
5694                                                         case 4: k = A_DEX; act = _("器用で", "agile"); break;
5695                                                         case 5: k = A_CON; act = _("健康で", "hale"); break;
5696                                                         case 6: k = A_CHR; act = _("美しく", "beautiful"); break;
5697                                                 }
5698
5699                                                 msg_format(_("あなたは以前ほど%sなくなってしまった...。", 
5700                                                                          "You're not as %s as you used to be..."), act);
5701
5702                                                 p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
5703                                                 if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5704                                                 p_ptr->update |= (PU_BONUS);
5705                                                 break;
5706                                         }
5707
5708                                         case 10:
5709                                         {
5710                                                 msg_print(_("あなたは以前ほど力強くなくなってしまった...。", 
5711                                                                         "You're not as powerful as you used to be..."));
5712
5713                                                 for (k = 0; k < A_MAX; k++)
5714                                                 {
5715                                                         p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
5716                                                         if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
5717                                                 }
5718                                                 p_ptr->update |= (PU_BONUS);
5719                                                 break;
5720                                         }
5721                                 }
5722                         }
5723
5724                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5725                         break;
5726                 }
5727
5728                 /* Gravity -- stun plus slowness plus teleport */
5729                 case GF_GRAVITY:
5730                 {
5731                         if (fuzzy) msg_print(_("何か重いもので攻撃された!", "You are hit by something heavy!"));
5732                                 msg_print(_("周辺の重力がゆがんだ。", "Gravity warps around you."));
5733
5734                         if (!CHECK_MULTISHADOW())
5735                         {
5736                                 teleport_player(5, TELEPORT_PASSIVE);
5737                                 if (!p_ptr->levitation)
5738                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5739                                 if (!(p_ptr->resist_sound || p_ptr->levitation))
5740                                 {
5741                                         int plus_stun = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
5742                                         (void)set_stun(p_ptr->stun + plus_stun);
5743                                 }
5744                         }
5745                         if (p_ptr->levitation)
5746                         {
5747                                 dam = (dam * 2) / 3;
5748                         }
5749
5750                         if (!p_ptr->levitation || one_in_(13))
5751                         {
5752                                 inven_damage(set_cold_destroy, 2);
5753                         }
5754
5755                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5756                         break;
5757                 }
5758
5759                 /* Standard damage */
5760                 case GF_DISINTEGRATE:
5761                 {
5762                         if (fuzzy) msg_print(_("純粋なエネルギーで攻撃された!", "You are hit by pure energy!"));
5763
5764                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5765                         break;
5766                 }
5767
5768                 case GF_OLD_HEAL:
5769                 {
5770                         if (fuzzy) msg_print(_("何らかの攻撃によって気分がよくなった。", "You are hit by something invigorating!"));
5771
5772                         (void)hp_player(dam);
5773                         dam = 0;
5774                         break;
5775                 }
5776
5777                 case GF_OLD_SPEED:
5778                 {
5779                         if (fuzzy) msg_print(_("何かで攻撃された!", "You are hit by something!"));
5780                         (void)set_fast(p_ptr->fast + randint1(5), FALSE);
5781                         dam = 0;
5782                         break;
5783                 }
5784
5785                 case GF_OLD_SLOW:
5786                 {
5787                         if (fuzzy) msg_print(_("何か遅いもので攻撃された!", "You are hit by something slow!"));
5788                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
5789                         break;
5790                 }
5791
5792                 case GF_OLD_SLEEP:
5793                 {
5794                         if (p_ptr->free_act)  break;
5795                         if (fuzzy) msg_print(_("眠ってしまった!", "You fall asleep!"));
5796
5797                         if (ironman_nightmare)
5798                         {
5799                                 msg_print(_("恐ろしい光景が頭に浮かんできた。", "A horrible vision enters your mind."));
5800                                 /* Have some nightmares */
5801                                 sanity_blast(NULL, FALSE);
5802                         }
5803
5804                         set_paralyzed(p_ptr->paralyzed + dam);
5805                         dam = 0;
5806                         break;
5807                 }
5808
5809                 /* Pure damage */
5810                 case GF_MANA:
5811                 case GF_SEEKER:
5812                 case GF_SUPER_RAY:
5813                 {
5814                         if (fuzzy) msg_print(_("魔法のオーラで攻撃された!", "You are hit by an aura of magic!"));
5815                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5816                         break;
5817                 }
5818
5819                 /* Pure damage */
5820                 case GF_PSY_SPEAR:
5821                 {
5822                         if (fuzzy) msg_print(_("エネルギーの塊で攻撃された!", "You are hit by an energy!"));
5823                         get_damage = take_hit(DAMAGE_FORCE, dam, killer, monspell);
5824                         break;
5825                 }
5826
5827                 /* Pure damage */
5828                 case GF_METEOR:
5829                 {
5830                         if (fuzzy) msg_print(_("何かが空からあなたの頭上に落ちてきた!", "Something falls from the sky on you!"));
5831
5832                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5833                         if (!p_ptr->resist_shard || one_in_(13))
5834                         {
5835                                 if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
5836                                 inven_damage(set_cold_destroy, 2);
5837                         }
5838
5839                         break;
5840                 }
5841
5842                 /* Ice -- cold plus stun plus cuts */
5843                 case GF_ICE:
5844                 {
5845                         if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
5846                         get_damage = cold_dam(dam, killer, monspell, FALSE);
5847                         if (!CHECK_MULTISHADOW())
5848                         {
5849                                 if (!p_ptr->resist_shard)
5850                                 {
5851                                         (void)set_cut(p_ptr->cut + damroll(5, 8));
5852                                 }
5853                                 if (!p_ptr->resist_sound)
5854                                 {
5855                                         (void)set_stun(p_ptr->stun + randint1(15));
5856                                 }
5857
5858                                 if ((!(p_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
5859                                 {
5860                                         if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
5861                                 }
5862                         }
5863
5864                         break;
5865                 }
5866
5867                 /* Death Ray */
5868                 case GF_DEATH_RAY:
5869                 {
5870                         if (fuzzy) msg_print(_("何か非常に冷たいもので攻撃された!", "You are hit by something extremely cold!"));
5871
5872                         if (p_ptr->mimic_form)
5873                         {
5874                                 if (!(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
5875                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5876                         }
5877                         else
5878                         {
5879
5880                         switch (p_ptr->prace)
5881                         {
5882                                 /* Some races are immune */
5883                                 case RACE_GOLEM:
5884                                 case RACE_SKELETON:
5885                                 case RACE_ZOMBIE:
5886                                 case RACE_VAMPIRE:
5887                                 case RACE_DEMON:
5888                                 case RACE_SPECTRE:
5889                                 {
5890                                         dam = 0;
5891                                         break;
5892                                 }
5893                                 /* Hurt a lot */
5894                                 default:
5895                                 {
5896                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5897                                         break;
5898                                 }
5899                         }
5900                         }
5901
5902                         break;
5903                 }
5904
5905                 /* Drain mana */
5906                 case GF_DRAIN_MANA:
5907                 {
5908                         if (CHECK_MULTISHADOW())
5909                         {
5910                                 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, you are unharmed!"));
5911                         }
5912                         else if (p_ptr->csp)
5913                         {
5914                                 /* Basic message */
5915                                 if (who > 0) 
5916                                         msg_format(_("%^sに精神エネルギーを吸い取られてしまった!", "%^s draws psychic energy from you!"), m_name);
5917                                 else 
5918                                         msg_print(_("精神エネルギーを吸い取られてしまった!", "Your psychic energy is drawn!"));
5919
5920                                 /* Full drain */
5921                                 if (dam >= p_ptr->csp)
5922                                 {
5923                                         dam = p_ptr->csp;
5924                                         p_ptr->csp = 0;
5925                                         p_ptr->csp_frac = 0;
5926                                 }
5927
5928                                 /* Partial drain */
5929                                 else
5930                                 {
5931                                         p_ptr->csp -= dam;
5932                                 }
5933
5934                                 learn_spell(monspell);
5935                                 p_ptr->redraw |= (PR_MANA);
5936                                 p_ptr->window |= (PW_PLAYER | PW_SPELL);
5937
5938                                 if (who > 0)
5939                                 {
5940                                         /* Heal the monster */
5941                                         if (m_ptr->hp < m_ptr->maxhp)
5942                                         {
5943                                                 /* Heal */
5944                                                 m_ptr->hp += dam;
5945                                                 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
5946
5947                                                 /* Redraw (later) if needed */
5948                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
5949                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
5950
5951                                                 /* Special message */
5952                                                 if (m_ptr->ml)
5953                                                 {
5954                                                         msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), m_name);
5955                                                 }
5956                                         }
5957                                 }
5958                         }
5959
5960                         dam = 0;
5961                         break;
5962                 }
5963
5964                 /* Mind blast */
5965                 case GF_MIND_BLAST:
5966                 {
5967                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
5968                         {
5969                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
5970                                 learn_spell(monspell);
5971                         }
5972                         else
5973                         {
5974                                 if (!CHECK_MULTISHADOW())
5975                                 {
5976                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
5977
5978                                         if (!p_ptr->resist_conf)
5979                                         {
5980                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
5981                                         }
5982
5983                                         if (!p_ptr->resist_chaos && one_in_(3))
5984                                         {
5985                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
5986                                         }
5987
5988                                         p_ptr->csp -= 50;
5989                                         if (p_ptr->csp < 0)
5990                                         {
5991                                                 p_ptr->csp = 0;
5992                                                 p_ptr->csp_frac = 0;
5993                                         }
5994                                         p_ptr->redraw |= PR_MANA;
5995                                 }
5996
5997                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
5998                         }
5999                         break;
6000                 }
6001
6002                 /* Brain smash */
6003                 case GF_BRAIN_SMASH:
6004                 {
6005                         if ((randint0(100 + rlev / 2) < MAX(5, p_ptr->skill_sav)) && !CHECK_MULTISHADOW())
6006                         {
6007                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6008                                 learn_spell(monspell);
6009                         }
6010                         else
6011                         {
6012                                 if (!CHECK_MULTISHADOW())
6013                                 {
6014                                         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psyonic energy."));
6015
6016                                         p_ptr->csp -= 100;
6017                                         if (p_ptr->csp < 0)
6018                                         {
6019                                                 p_ptr->csp = 0;
6020                                                 p_ptr->csp_frac = 0;
6021                                         }
6022                                         p_ptr->redraw |= PR_MANA;
6023                                 }
6024
6025                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6026                                 if (!CHECK_MULTISHADOW())
6027                                 {
6028                                         if (!p_ptr->resist_blind)
6029                                         {
6030                                                 (void)set_blind(p_ptr->blind + 8 + randint0(8));
6031                                         }
6032                                         if (!p_ptr->resist_conf)
6033                                         {
6034                                                 (void)set_confused(p_ptr->confused + randint0(4) + 4);
6035                                         }
6036                                         if (!p_ptr->free_act)
6037                                         {
6038                                                 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
6039                                         }
6040                                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
6041
6042                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
6043                                                 (void)do_dec_stat(A_INT);
6044                                         while (randint0(100 + rlev / 2) > (MAX(5, p_ptr->skill_sav)))
6045                                                 (void)do_dec_stat(A_WIS);
6046
6047                                         if (!p_ptr->resist_chaos)
6048                                         {
6049                                                 (void)set_image(p_ptr->image + randint0(250) + 150);
6050                                         }
6051                                 }
6052                         }
6053                         break;
6054                 }
6055
6056                 /* cause 1 */
6057                 case GF_CAUSE_1:
6058                 {
6059                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6060                         {
6061                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6062                                 learn_spell(monspell);
6063                         }
6064                         else
6065                         {
6066                                 if (!CHECK_MULTISHADOW()) curse_equipment(15, 0);
6067                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6068                         }
6069                         break;
6070                 }
6071
6072                 /* cause 2 */
6073                 case GF_CAUSE_2:
6074                 {
6075                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6076                         {
6077                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6078                                 learn_spell(monspell);
6079                         }
6080                         else
6081                         {
6082                                 if (!CHECK_MULTISHADOW()) curse_equipment(25, MIN(rlev / 2 - 15, 5));
6083                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6084                         }
6085                         break;
6086                 }
6087
6088                 /* cause 3 */
6089                 case GF_CAUSE_3:
6090                 {
6091                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6092                         {
6093                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6094                                 learn_spell(monspell);
6095                         }
6096                         else
6097                         {
6098                                 if (!CHECK_MULTISHADOW()) curse_equipment(33, MIN(rlev / 2 - 15, 15));
6099                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6100                         }
6101                         break;
6102                 }
6103
6104                 /* cause 4 */
6105                 case GF_CAUSE_4:
6106                 {
6107                         if ((randint0(100 + rlev / 2) < p_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU) && !CHECK_MULTISHADOW())
6108                         {
6109                                 msg_print(_("しかし秘孔を跳ね返した!", "You resist the effects!"));
6110                                 learn_spell(monspell);
6111                         }
6112                         else
6113                         {
6114                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6115                                 if (!CHECK_MULTISHADOW()) (void)set_cut(p_ptr->cut + damroll(10, 10));
6116                         }
6117                         break;
6118                 }
6119
6120                 /* Hand of Doom */
6121                 case GF_HAND_DOOM:
6122                 {
6123                         if ((randint0(100 + rlev/2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW())
6124                         {
6125                                 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
6126                                 learn_spell(monspell);
6127                         }
6128                         else
6129                         {
6130                                 if (!CHECK_MULTISHADOW())
6131                                 {
6132                                         msg_print(_("あなたは命が薄まっていくように感じた!", "You feel your life fade away!"));
6133                                         curse_equipment(40, 20);
6134                                 }
6135
6136                                 get_damage = take_hit(DAMAGE_ATTACK, dam, m_name, monspell);
6137
6138                                 if (p_ptr->chp < 1) p_ptr->chp = 1; /* Paranoia */
6139                         }
6140                         break;
6141                 }
6142
6143                 /* Default */
6144                 default:
6145                 {
6146                         /* No damage */
6147                         dam = 0;
6148
6149                         break;
6150                 }
6151         }
6152
6153         /* Hex - revenge damage stored */
6154         revenge_store(get_damage);
6155
6156         if ((p_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
6157                 && (get_damage > 0) && !p_ptr->is_dead && (who > 0))
6158         {
6159                 GAME_TEXT m_name_self[80];
6160
6161                 /* hisself */
6162                 monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
6163
6164                 msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
6165                 project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
6166                 if (p_ptr->tim_eyeeye) set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
6167         }
6168
6169         if (p_ptr->riding && dam > 0)
6170         {
6171                 rakubadam_p = (dam > 200) ? 200 : dam;
6172         }
6173
6174
6175         disturb(TRUE, TRUE);
6176
6177
6178         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
6179         {
6180                 (void)kawarimi(FALSE);
6181         }
6182
6183         /* Return "Anything seen?" */
6184         return (obvious);
6185 }
6186
6187
6188 /*
6189  * Find the distance from (x, y) to a line.
6190  */
6191 POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
6192 {
6193         /* Vector from (x, y) to (x1, y1) */
6194         POSITION py = y1 - y;
6195         POSITION px = x1 - x;
6196
6197         /* Normal vector */
6198         POSITION ny = x2 - x1;
6199         POSITION nx = y1 - y2;
6200
6201         /* Length of N */
6202         POSITION pd = distance(y1, x1, y, x);
6203         POSITION nd = distance(y1, x1, y2, x2);
6204
6205         if (pd > nd) return distance(y, x, y2, x2);
6206
6207         /* Component of P on N */
6208         nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
6209
6210         /* Absolute value */
6211         return((nd >= 0) ? nd : 0 - nd);
6212 }
6213
6214
6215
6216 /*
6217  * 
6218  * Modified version of los() for calculation of disintegration balls.
6219  * Disintegration effects are stopped by permanent walls.
6220  */
6221 bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
6222 {
6223         POSITION dx, dy; /* Delta */
6224         POSITION ax, ay; /* Absolute */
6225         POSITION sx, sy; /* Signs */
6226         POSITION qx, qy; /* Fractions */
6227         POSITION tx, ty; /* Scanners */
6228         POSITION f1, f2; /* Scale factors */
6229         POSITION m; /* Slope, or 1/Slope, of LOS */
6230
6231         /* Extract the offset */
6232         dy = y2 - y1;
6233         dx = x2 - x1;
6234
6235         /* Extract the absolute offset */
6236         ay = ABS(dy);
6237         ax = ABS(dx);
6238
6239         /* Handle adjacent (or identical) grids */
6240         if ((ax < 2) && (ay < 2)) return (TRUE);
6241
6242         /* Paranoia -- require "safe" origin */
6243         /* if (!in_bounds(y1, x1)) return (FALSE); */
6244
6245         /* Directly South/North */
6246         if (!dx)
6247         {
6248                 /* South -- check for walls */
6249                 if (dy > 0)
6250                 {
6251                         for (ty = y1 + 1; ty < y2; ty++)
6252                         {
6253                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
6254                         }
6255                 }
6256
6257                 /* North -- check for walls */
6258                 else
6259                 {
6260                         for (ty = y1 - 1; ty > y2; ty--)
6261                         {
6262                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
6263                         }
6264                 }
6265
6266                 /* Assume los */
6267                 return (TRUE);
6268         }
6269
6270         /* Directly East/West */
6271         if (!dy)
6272         {
6273                 /* East -- check for walls */
6274                 if (dx > 0)
6275                 {
6276                         for (tx = x1 + 1; tx < x2; tx++)
6277                         {
6278                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
6279                         }
6280                 }
6281
6282                 /* West -- check for walls */
6283                 else
6284                 {
6285                         for (tx = x1 - 1; tx > x2; tx--)
6286                         {
6287                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
6288                         }
6289                 }
6290
6291                 /* Assume los */
6292                 return (TRUE);
6293         }
6294
6295         /* Extract some signs */
6296         sx = (dx < 0) ? -1 : 1;
6297         sy = (dy < 0) ? -1 : 1;
6298
6299         /* Vertical "knights" */
6300         if (ax == 1)
6301         {
6302                 if (ay == 2)
6303                 {
6304                         if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
6305                 }
6306         }
6307
6308         /* Horizontal "knights" */
6309         else if (ay == 1)
6310         {
6311                 if (ax == 2)
6312                 {
6313                         if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
6314                 }
6315         }
6316
6317         /* Calculate scale factor div 2 */
6318         f2 = (ax * ay);
6319
6320         /* Calculate scale factor */
6321         f1 = f2 << 1;
6322
6323
6324         /* Travel horizontally */
6325         if (ax >= ay)
6326         {
6327                 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
6328                 qy = ay * ay;
6329                 m = qy << 1;
6330
6331                 tx = x1 + sx;
6332
6333                 /* Consider the special case where slope == 1. */
6334                 if (qy == f2)
6335                 {
6336                         ty = y1 + sy;
6337                         qy -= f1;
6338                 }
6339                 else
6340                 {
6341                         ty = y1;
6342                 }
6343
6344                 /* Note (below) the case (qy == f2), where */
6345                 /* the LOS exactly meets the corner of a tile. */
6346                 while (x2 - tx)
6347                 {
6348                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6349
6350                         qy += m;
6351
6352                         if (qy < f2)
6353                         {
6354                                 tx += sx;
6355                         }
6356                         else if (qy > f2)
6357                         {
6358                                 ty += sy;
6359                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6360                                 qy -= f1;
6361                                 tx += sx;
6362                         }
6363                         else
6364                         {
6365                                 ty += sy;
6366                                 qy -= f1;
6367                                 tx += sx;
6368                         }
6369                 }
6370         }
6371
6372         /* Travel vertically */
6373         else
6374         {
6375                 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
6376                 qx = ax * ax;
6377                 m = qx << 1;
6378
6379                 ty = y1 + sy;
6380
6381                 if (qx == f2)
6382                 {
6383                         tx = x1 + sx;
6384                         qx -= f1;
6385                 }
6386                 else
6387                 {
6388                         tx = x1;
6389                 }
6390
6391                 /* Note (below) the case (qx == f2), where */
6392                 /* the LOS exactly meets the corner of a tile. */
6393                 while (y2 - ty)
6394                 {
6395                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
6396
6397                         qx += m;
6398
6399                         if (qx < f2)
6400                         {
6401                                 ty += sy;
6402                         }
6403                         else if (qx > f2)
6404                         {
6405                                 tx += sx;
6406                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
6407                                 qx -= f1;
6408                                 ty += sy;
6409                         }
6410                         else
6411                         {
6412                                 tx += sx;
6413                                 qx -= f1;
6414                                 ty += sy;
6415                         }
6416                 }
6417         }
6418
6419         /* Assume los */
6420         return (TRUE);
6421 }
6422
6423
6424 /*
6425  * breath shape
6426  */
6427 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)
6428 {
6429         POSITION by = y1;
6430         POSITION bx = x1;
6431         int brad = 0;
6432         int brev = rad * rad / dist;
6433         int bdis = 0;
6434         int cdis;
6435         int path_n = 0;
6436         int mdis = distance(y1, x1, y2, x2) + rad;
6437
6438         while (bdis <= mdis)
6439         {
6440                 POSITION x, y;
6441
6442                 if ((0 < dist) && (path_n < dist))
6443                 {
6444                         POSITION ny = GRID_Y(path_g[path_n]);
6445                         POSITION nx = GRID_X(path_g[path_n]);
6446                         POSITION nd = distance(ny, nx, y1, x1);
6447
6448                         /* Get next base point */
6449                         if (bdis >= nd)
6450                         {
6451                                 by = ny;
6452                                 bx = nx;
6453                                 path_n++;
6454                         }
6455                 }
6456
6457                 /* Travel from center outward */
6458                 for (cdis = 0; cdis <= brad; cdis++)
6459                 {
6460                         /* Scan the maximal blast area of radius "cdis" */
6461                         for (y = by - cdis; y <= by + cdis; y++)
6462                         {
6463                                 for (x = bx - cdis; x <= bx + cdis; x++)
6464                                 {
6465                                         /* Ignore "illegal" locations */
6466                                         if (!in_bounds(y, x)) continue;
6467
6468                                         /* Enforce a circular "ripple" */
6469                                         if (distance(y1, x1, y, x) != bdis) continue;
6470
6471                                         /* Enforce an arc */
6472                                         if (distance(by, bx, y, x) != cdis) continue;
6473
6474                                         switch (typ)
6475                                         {
6476                                         case GF_LITE:
6477                                         case GF_LITE_WEAK:
6478                                                 /* Lights are stopped by opaque terrains */
6479                                                 if (!los(by, bx, y, x)) continue;
6480                                                 break;
6481                                         case GF_DISINTEGRATE:
6482                                                 /* Disintegration are stopped only by perma-walls */
6483                                                 if (!in_disintegration_range(by, bx, y, x)) continue;
6484                                                 break;
6485                                         default:
6486                                                 /* Ball explosions are stopped by walls */
6487                                                 if (!projectable(by, bx, y, x)) continue;
6488                                                 break;
6489                                         }
6490
6491                                         /* Save this grid */
6492                                         gy[*pgrids] = y;
6493                                         gx[*pgrids] = x;
6494                                         (*pgrids)++;
6495                                 }
6496                         }
6497                 }
6498
6499                 /* Encode some more "radius" info */
6500                 gm[bdis + 1] = *pgrids;
6501
6502                 /* Increase the size */
6503                 brad = rad * (path_n + brev) / (dist + brev);
6504
6505                 /* Find the next ripple */
6506                 bdis++;
6507         }
6508
6509         /* Store the effect size */
6510         *pgm_rad = bdis;
6511 }
6512
6513
6514 /*!
6515  * @brief 汎用的なビーム/ボルト/ボール系処理のルーチン Generic "beam"/"bolt"/"ball" projection routine.
6516  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
6517  * @param rad 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
6518  * @param y 目標Y座標 / Target y location (or location to travel "towards")
6519  * @param x 目標X座標 / Target x location (or location to travel "towards")
6520  * @param dam 基本威力 / Base damage roll to apply to affected monsters (or player)
6521  * @param typ 効果属性 / Type of damage to apply to monsters (and objects)
6522  * @param flg 効果フラグ / Extra bit flags (see PROJECT_xxxx in "defines.h")
6523  * @param monspell 効果元のモンスター魔法ID
6524  * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE
6525  * @details
6526  * <pre>
6527  * Allows a monster (or player) to project a beam/bolt/ball of a given kind
6528  * towards a given location (optionally passing over the heads of interposing
6529  * monsters), and have it do a given amount of damage to the monsters (and
6530  * optionally objects) within the given radius of the final location.
6531  *
6532  * A "bolt" travels from source to target and affects only the target grid.
6533  * A "beam" travels from source to target, affecting all grids passed through.
6534  * A "ball" travels from source to the target, exploding at the target, and
6535  *   affecting everything within the given radius of the target location.
6536  *
6537  * Traditionally, a "bolt" does not affect anything on the ground, and does
6538  * not pass over the heads of interposing monsters, much like a traditional
6539  * missile, and will "stop" abruptly at the "target" even if no monster is
6540  * positioned there, while a "ball", on the other hand, passes over the heads
6541  * of monsters between the source and target, and affects everything except
6542  * the source monster which lies within the final radius, while a "beam"
6543  * affects every monster between the source and target, except for the casting
6544  * monster (or player), and rarely affects things on the ground.
6545  *
6546  * Two special flags allow us to use this function in special ways, the
6547  * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
6548  * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
6549  * actually projecting from the source monster (or player).
6550  *
6551  * The player will only get "experience" for monsters killed by himself
6552  * Unique monsters can only be destroyed by attacks from the player
6553  *
6554  * Only 256 grids can be affected per projection, limiting the effective
6555  * "radius" of standard ball attacks to nine units (diameter nineteen).
6556  *
6557  * One can project in a given "direction" by combining PROJECT_THRU with small
6558  * offsets to the initial location (see "line_spell()"), or by calculating
6559  * "virtual targets" far away from the player.
6560  *
6561  * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
6562  * continuing until it actually hits somethings (useful for "stone to mud").
6563  *
6564  * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
6565  *
6566  * Balls must explode BEFORE hitting walls, or they would affect monsters
6567  * on both sides of a wall.  Some bug reports indicate that this is still
6568  * happening in 2.7.8 for Windows, though it appears to be impossible.
6569  *
6570  * We "pre-calculate" the blast area only in part for efficiency.
6571  * More importantly, this lets us do "explosions" from the "inside" out.
6572  * This results in a more logical distribution of "blast" treasure.
6573  * It also produces a better (in my opinion) animation of the explosion.
6574  * It could be (but is not) used to have the treasure dropped by monsters
6575  * in the middle of the explosion fall "outwards", and then be damaged by
6576  * the blast as it spreads outwards towards the treasure drop location.
6577  *
6578  * Walls and doors are included in the blast area, so that they can be
6579  * "burned" or "melted" in later versions.
6580  *
6581  * This algorithm is intended to maximize simplicity, not necessarily
6582  * efficiency, since this function is not a bottleneck in the code.
6583  *
6584  * We apply the blast effect from ground zero outwards, in several passes,
6585  * first affecting features, then objects, then monsters, then the player.
6586  * This allows walls to be removed before checking the object or monster
6587  * in the wall, and protects objects which are dropped by monsters killed
6588  * in the blast, and allows the player to see all affects before he is
6589  * killed or teleported away.  The semantics of this method are open to
6590  * various interpretations, but they seem to work well in practice.
6591  *
6592  * We process the blast area from ground-zero outwards to allow for better
6593  * distribution of treasure dropped by monsters, and because it provides a
6594  * pleasing visual effect at low cost.
6595  *
6596  * Note that the damage done by "ball" explosions decreases with distance.
6597  * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
6598  *
6599  * Notice the "napalm" effect of "beam" weapons.  First they "project" to
6600  * the target, and then the damage "flows" along this beam of destruction.
6601  * The damage at every grid is the same as at the "center" of a "ball"
6602  * explosion, since the "beam" grids are treated as if they ARE at the
6603  * center of a "ball" explosion.
6604  *
6605  * Currently, specifying "beam" plus "ball" means that locations which are
6606  * covered by the initial "beam", and also covered by the final "ball", except
6607  * for the final grid (the epicenter of the ball), will be "hit twice", once
6608  * by the initial beam, and once by the exploding ball.  For the grid right
6609  * next to the epicenter, this results in 150% damage being done.  The center
6610  * does not have this problem, for the same reason the final grid in a "beam"
6611  * plus "bolt" does not -- it is explicitly removed.  Simply removing "beam"
6612  * grids which are covered by the "ball" will NOT work, as then they will
6613  * receive LESS damage than they should.  Do not combine "beam" with "ball".
6614  *
6615  * The array "gy[],gx[]" with current size "grids" is used to hold the
6616  * collected locations of all grids in the "blast area" plus "beam path".
6617  *
6618  * Note the rather complex usage of the "gm[]" array.  First, gm[0] is always
6619  * zero.  Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
6620  * first blast grid (see above) with radius "N" from the blast center.  Note
6621  * that only the first gm[1] grids in the blast area thus take full damage.
6622  * Also, note that gm[rad+1] is always equal to "grids", which is the total
6623  * number of blast grids.
6624  *
6625  * Note that once the projection is complete, (y2,x2) holds the final location
6626  * of bolts/beams, and the "epicenter" of balls.
6627  *
6628  * Note also that "rad" specifies the "inclusive" radius of projection blast,
6629  * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
6630  * implementation of the "distance" function.  Also, a bolt can be properly
6631  * viewed as a "ball" with a "rad" of "zero".
6632  *
6633  * Note that if no "target" is reached before the beam/bolt/ball travels the
6634  * maximum distance allowed (MAX_RANGE), no "blast" will be induced.  This
6635  * may be relevant even for bolts, since they have a "1x1" mini-blast.
6636  *
6637  * Note that for consistency, we "pretend" that the bolt actually takes "time"
6638  * to move from point A to point B, even if the player cannot see part of the
6639  * projection path.  Note that in general, the player will *always* see part
6640  * of the path, since it either starts at the player or ends on the player.
6641  *
6642  * Hack -- we assume that every "projection" is "self-illuminating".
6643  *
6644  * Hack -- when only a single monster is affected, we automatically track
6645  * (and recall) that monster, unless "PROJECT_JUMP" is used.
6646  *
6647  * Note that all projections now "explode" at their final destination, even
6648  * if they were being projected at a more distant destination.  This means
6649  * that "ball" spells will *always* explode.
6650  *
6651  * Note that we must call "handle_stuff()" after affecting terrain features
6652  * in the blast radius, in case the "illumination" of the grid was changed,
6653  * and "update_view()" and "update_monsters()" need to be called.
6654  * </pre>
6655  */
6656 bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
6657 {
6658         int i, t, dist;
6659
6660         POSITION y1, x1;
6661         POSITION y2, x2;
6662         POSITION by, bx;
6663
6664         int dist_hack = 0;
6665
6666         POSITION y_saver, x_saver; /* For reflecting monsters */
6667
6668         int msec = delay_factor * delay_factor * delay_factor;
6669
6670         /* Assume the player sees nothing */
6671         bool notice = FALSE;
6672
6673         /* Assume the player has seen nothing */
6674         bool visual = FALSE;
6675
6676         /* Assume the player has seen no blast grids */
6677         bool drawn = FALSE;
6678
6679         /* Assume to be a normal ball spell */
6680         bool breath = FALSE;
6681
6682         /* Is the player blind? */
6683         bool blind = (p_ptr->blind ? TRUE : FALSE);
6684
6685         bool old_hide = FALSE;
6686
6687         /* Number of grids in the "path" */
6688         int path_n = 0;
6689
6690         /* Actual grids in the "path" */
6691         u16b path_g[512];
6692
6693         /* Number of grids in the "blast area" (including the "beam" path) */
6694         int grids = 0;
6695
6696         /* Coordinates of the affected grids */
6697         POSITION gx[1024], gy[1024];
6698
6699         /* Encoded "radius" info (see above) */
6700         POSITION gm[32];
6701
6702         /* Actual radius encoded in gm[] */
6703         POSITION gm_rad = rad;
6704
6705         bool jump = FALSE;
6706
6707         /* Attacker's name (prepared before polymorph)*/
6708         GAME_TEXT who_name[MAX_NLEN];
6709
6710         /* Can the player see the source of this effect? */
6711         bool see_s_msg = TRUE;
6712
6713         /* Initialize by null string */
6714         who_name[0] = '\0';
6715
6716         rakubadam_p = 0;
6717         rakubadam_m = 0;
6718
6719         /* Default target of monsterspell is player */
6720         monster_target_y = p_ptr->y;
6721         monster_target_x = p_ptr->x;
6722
6723         /* Hack -- Jump to target */
6724         if (flg & (PROJECT_JUMP))
6725         {
6726                 x1 = x;
6727                 y1 = y;
6728
6729                 /* Clear the flag */
6730                 flg &= ~(PROJECT_JUMP);
6731
6732                 jump = TRUE;
6733         }
6734
6735         /* Start at player */
6736         else if (who <= 0)
6737         {
6738                 x1 = p_ptr->x;
6739                 y1 = p_ptr->y;
6740         }
6741
6742         /* Start at monster */
6743         else if (who > 0)
6744         {
6745                 x1 = m_list[who].fx;
6746                 y1 = m_list[who].fy;
6747                 monster_desc(who_name, &m_list[who], MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
6748         }
6749
6750         else
6751         {
6752                 x1 = x;
6753                 y1 = y;
6754         }
6755
6756         y_saver = y1;
6757         x_saver = x1;
6758
6759         /* Default "destination" */
6760         y2 = y;
6761         x2 = x;
6762
6763
6764         /* Hack -- verify stuff */
6765         if (flg & (PROJECT_THRU))
6766         {
6767                 if ((x1 == x2) && (y1 == y2))
6768                 {
6769                         flg &= ~(PROJECT_THRU);
6770                 }
6771         }
6772
6773         /* Handle a breath attack */
6774         if (rad < 0)
6775         {
6776                 rad = 0 - rad;
6777                 breath = TRUE;
6778                 if (flg & PROJECT_HIDE) old_hide = TRUE;
6779                 flg |= PROJECT_HIDE;
6780         }
6781
6782
6783         /* Hack -- Assume there will be no blast (max radius 32) */
6784         for (dist = 0; dist < 32; dist++) gm[dist] = 0;
6785
6786
6787         /* Initial grid */
6788         y = y1;
6789         x = x1;
6790         dist = 0;
6791
6792         /* Collect beam grids */
6793         if (flg & (PROJECT_BEAM))
6794         {
6795                 gy[grids] = y;
6796                 gx[grids] = x;
6797                 grids++;
6798         }
6799
6800         switch (typ)
6801         {
6802         case GF_LITE:
6803         case GF_LITE_WEAK:
6804                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_LOS);
6805                 break;
6806         case GF_DISINTEGRATE:
6807                 flg |= (PROJECT_GRID);
6808                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_DISI);
6809                 break;
6810         }
6811
6812         /* Calculate the projection path */
6813
6814         path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
6815         handle_stuff();
6816
6817         /* Giga-Hack SEEKER & SUPER_RAY */
6818
6819         if( typ == GF_SEEKER )
6820         {
6821                 int j;
6822                 int last_i=0;
6823
6824                 /* Mega-Hack */
6825                 project_m_n = 0;
6826                 project_m_x = 0;
6827                 project_m_y = 0;
6828
6829                 for (i = 0; i < path_n; ++i)
6830                 {
6831                         int oy = y;
6832                         int ox = x;
6833
6834                         int ny = GRID_Y(path_g[i]);
6835                         int nx = GRID_X(path_g[i]);
6836
6837                         /* Advance */
6838                         y = ny;
6839                         x = nx;
6840
6841                         gy[grids] = y;
6842                         gx[grids] = x;
6843                         grids++;
6844
6845
6846                         /* Only do visuals if requested */
6847                         if (!blind && !(flg & (PROJECT_HIDE)))
6848                         {
6849                                 /* Only do visuals if the player can "see" the bolt */
6850                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6851                                 {
6852                                         u16b p;
6853
6854                                         TERM_COLOR a;
6855                                         SYMBOL_CODE c;
6856
6857                                         /* Obtain the bolt pict */
6858                                         p = bolt_pict(oy, ox, y, x, typ);
6859
6860                                         /* Extract attr/char */
6861                                         a = PICT_A(p);
6862                                         c = PICT_C(p);
6863
6864                                         /* Visual effects */
6865                                         print_rel(c, a, y, x);
6866                                         move_cursor_relative(y, x);
6867                                         /*if (fresh_before)*/ Term_fresh();
6868                                         Term_xtra(TERM_XTRA_DELAY, msec);
6869                                         lite_spot(y, x);
6870                                         /*if (fresh_before)*/ Term_fresh();
6871
6872                                         /* Display "beam" grids */
6873                                         if (flg & (PROJECT_BEAM))
6874                                         {
6875                                                 /* Obtain the explosion pict */
6876                                                 p = bolt_pict(y, x, y, x, typ);
6877
6878                                                 /* Extract attr/char */
6879                                                 a = PICT_A(p);
6880                                                 c = PICT_C(p);
6881
6882                                                 /* Visual effects */
6883                                                 print_rel(c, a, y, x);
6884                                         }
6885
6886                                         /* Hack -- Activate delay */
6887                                         visual = TRUE;
6888                                 }
6889
6890                                 /* Hack -- delay anyway for consistency */
6891                                 else if (visual)
6892                                 {
6893                                         /* Delay for consistency */
6894                                         Term_xtra(TERM_XTRA_DELAY, msec);
6895                                 }
6896                         }
6897                         if (project_o(0, 0, y, x, dam, GF_SEEKER))notice = TRUE;
6898                         if (is_mirror_grid(&cave[y][x]))
6899                         {
6900                                 /* The target of monsterspell becomes tha mirror(broken) */
6901                                 monster_target_y = y;
6902                                 monster_target_x = x;
6903
6904                                 remove_mirror(y, x);
6905                                 next_mirror(&oy, &ox, y, x);
6906
6907                                 path_n = i + project_path(&(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
6908                                 for (j = last_i; j <= i; j++)
6909                                 {
6910                                         y = GRID_Y(path_g[j]);
6911                                         x = GRID_X(path_g[j]);
6912                                         if (project_m(0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice = TRUE;
6913                                         if (!who && (project_m_n == 1) && !jump) {
6914                                                 if (cave[project_m_y][project_m_x].m_idx > 0) {
6915                                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
6916
6917                                                         if (m_ptr->ml)
6918                                                         {
6919                                                                 /* Hack -- auto-recall */
6920                                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
6921
6922                                                                 /* Hack - auto-track */
6923                                                                 health_track(cave[project_m_y][project_m_x].m_idx);
6924                                                         }
6925                                                 }
6926                                         }
6927                                         (void)project_f(0, 0, y, x, dam, GF_SEEKER);
6928                                 }
6929                                 last_i = i;
6930                         }
6931                 }
6932                 for(i = last_i ; i < path_n ; i++)
6933                 {
6934                         POSITION py, px;
6935                         py = GRID_Y(path_g[i]);
6936                         px = GRID_X(path_g[i]);
6937                         if (project_m(0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
6938                                 notice = TRUE;
6939                         if (!who && (project_m_n == 1) && !jump) {
6940                                 if (cave[project_m_y][project_m_x].m_idx > 0)
6941                                 {
6942                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
6943
6944                                         if (m_ptr->ml)
6945                                         {
6946                                                 /* Hack -- auto-recall */
6947                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
6948
6949                                                 /* Hack - auto-track */
6950                                                 health_track(cave[project_m_y][project_m_x].m_idx);
6951                                         }
6952                                 }
6953                         }
6954                         (void)project_f(0, 0, py, px, dam, GF_SEEKER);
6955                 }
6956                 return notice;
6957         }
6958         else if(typ == GF_SUPER_RAY){
6959                 int j;
6960                 int second_step = 0;
6961
6962                 /* Mega-Hack */
6963                 project_m_n = 0;
6964                 project_m_x = 0;
6965                 project_m_y = 0;
6966
6967                 for (i = 0; i < path_n; ++i)
6968                 {
6969                         POSITION oy = y;
6970                         POSITION ox = x;
6971
6972                         POSITION ny = GRID_Y(path_g[i]);
6973                         POSITION nx = GRID_X(path_g[i]);
6974
6975                         /* Advance */
6976                         y = ny;
6977                         x = nx;
6978
6979                         gy[grids] = y;
6980                         gx[grids] = x;
6981                         grids++;
6982
6983
6984                         /* Only do visuals if requested */
6985                         if (!blind && !(flg & (PROJECT_HIDE)))
6986                         {
6987                                 /* Only do visuals if the player can "see" the bolt */
6988                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
6989                                 {
6990                                         u16b p;
6991
6992                                         TERM_COLOR a;
6993                                         SYMBOL_CODE c;
6994
6995                                         /* Obtain the bolt pict */
6996                                         p = bolt_pict(oy, ox, y, x, typ);
6997
6998                                         /* Extract attr/char */
6999                                         a = PICT_A(p);
7000                                         c = PICT_C(p);
7001
7002                                         /* Visual effects */
7003                                         print_rel(c, a, y, x);
7004                                         move_cursor_relative(y, x);
7005                                         /*if (fresh_before)*/ Term_fresh();
7006                                         Term_xtra(TERM_XTRA_DELAY, msec);
7007                                         lite_spot(y, x);
7008                                         /*if (fresh_before)*/ Term_fresh();
7009
7010                                         /* Display "beam" grids */
7011                                         if (flg & (PROJECT_BEAM))
7012                                         {
7013                                                 /* Obtain the explosion pict */
7014                                                 p = bolt_pict(y, x, y, x, typ);
7015
7016                                                 /* Extract attr/char */
7017                                                 a = PICT_A(p);
7018                                                 c = PICT_C(p);
7019
7020                                                 /* Visual effects */
7021                                                 print_rel(c, a, y, x);
7022                                         }
7023
7024                                         /* Hack -- Activate delay */
7025                                         visual = TRUE;
7026                                 }
7027
7028                                 /* Hack -- delay anyway for consistency */
7029                                 else if (visual)
7030                                 {
7031                                         /* Delay for consistency */
7032                                         Term_xtra(TERM_XTRA_DELAY, msec);
7033                                 }
7034                         }
7035                         if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
7036                         if (!cave_have_flag_bold(y, x, FF_PROJECT))
7037                         {
7038                                 if( second_step )continue;
7039                                 break;
7040                         }
7041                         if( is_mirror_grid(&cave[y][x]) && !second_step )
7042                         {
7043                           /* The target of monsterspell becomes tha mirror(broken) */
7044                                 monster_target_y=(s16b)y;
7045                                 monster_target_x=(s16b)x;
7046
7047                                 remove_mirror(y,x);
7048                                 for( j = 0; j <=i ; j++ )
7049                                 {
7050                                         y = GRID_Y(path_g[j]);
7051                                         x = GRID_X(path_g[j]);
7052                                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
7053                                 }
7054                                 path_n = i;
7055                                 second_step =i+1;
7056                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
7057                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
7058                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
7059                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x-1, flg);
7060                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x+1, flg);
7061                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x-1, flg);
7062                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
7063                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
7064                         }
7065                 }
7066                 for( i = 0; i < path_n ; i++ )
7067                 {
7068                         POSITION py, px;
7069                         py = GRID_Y(path_g[i]);
7070                         px = GRID_X(path_g[i]);
7071                         (void)project_m(0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
7072                         if(!who && (project_m_n == 1) && !jump){
7073                                 if(cave[project_m_y][project_m_x].m_idx >0 ){
7074                                         monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
7075
7076                                         if (m_ptr->ml)
7077                                         {
7078                                                 /* Hack -- auto-recall */
7079                                                 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7080
7081                                                 /* Hack - auto-track */
7082                                                 health_track(cave[project_m_y][project_m_x].m_idx);
7083                                         }
7084                                 }
7085                         }
7086                         (void)project_f(0, 0, py, px, dam, GF_SUPER_RAY);
7087                 }
7088                 return notice;
7089         }
7090
7091         /* Project along the path */
7092         for (i = 0; i < path_n; ++i)
7093         {
7094                 POSITION oy = y;
7095                 POSITION ox = x;
7096
7097                 POSITION ny = GRID_Y(path_g[i]);
7098                 POSITION nx = GRID_X(path_g[i]);
7099
7100                 if (flg & PROJECT_DISI)
7101                 {
7102                         /* Hack -- Balls explode before reaching walls */
7103                         if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
7104                 }
7105                 else if (flg & PROJECT_LOS)
7106                 {
7107                         /* Hack -- Balls explode before reaching walls */
7108                         if (!cave_los_bold(ny, nx) && (rad > 0)) break;
7109                 }
7110                 else
7111                 {
7112                         /* Hack -- Balls explode before reaching walls */
7113                         if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && (rad > 0)) break;
7114                 }
7115
7116                 /* Advance */
7117                 y = ny;
7118                 x = nx;
7119
7120                 /* Collect beam grids */
7121                 if (flg & (PROJECT_BEAM))
7122                 {
7123                         gy[grids] = y;
7124                         gx[grids] = x;
7125                         grids++;
7126                 }
7127
7128                 /* Only do visuals if requested */
7129                 if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
7130                 {
7131                         /* Only do visuals if the player can "see" the bolt */
7132                         if (panel_contains(y, x) && player_has_los_bold(y, x))
7133                         {
7134                                 u16b p;
7135
7136                                 TERM_COLOR a;
7137                                 SYMBOL_CODE c;
7138
7139                                 /* Obtain the bolt pict */
7140                                 p = bolt_pict(oy, ox, y, x, typ);
7141
7142                                 /* Extract attr/char */
7143                                 a = PICT_A(p);
7144                                 c = PICT_C(p);
7145
7146                                 /* Visual effects */
7147                                 print_rel(c, a, y, x);
7148                                 move_cursor_relative(y, x);
7149                                 /*if (fresh_before)*/ Term_fresh();
7150                                 Term_xtra(TERM_XTRA_DELAY, msec);
7151                                 lite_spot(y, x);
7152                                 /*if (fresh_before)*/ Term_fresh();
7153
7154                                 /* Display "beam" grids */
7155                                 if (flg & (PROJECT_BEAM))
7156                                 {
7157                                         /* Obtain the explosion pict */
7158                                         p = bolt_pict(y, x, y, x, typ);
7159
7160                                         /* Extract attr/char */
7161                                         a = PICT_A(p);
7162                                         c = PICT_C(p);
7163
7164                                         /* Visual effects */
7165                                         print_rel(c, a, y, x);
7166                                 }
7167
7168                                 /* Hack -- Activate delay */
7169                                 visual = TRUE;
7170                         }
7171
7172                         /* Hack -- delay anyway for consistency */
7173                         else if (visual)
7174                         {
7175                                 /* Delay for consistency */
7176                                 Term_xtra(TERM_XTRA_DELAY, msec);
7177                         }
7178                 }
7179         }
7180
7181         path_n = i;
7182
7183         /* Save the "blast epicenter" */
7184         by = y;
7185         bx = x;
7186
7187         if (breath && !path_n)
7188         {
7189                 breath = FALSE;
7190                 gm_rad = rad;
7191                 if (!old_hide)
7192                 {
7193                         flg &= ~(PROJECT_HIDE);
7194                 }
7195         }
7196
7197         /* Start the "explosion" */
7198         gm[0] = 0;
7199
7200         /* Hack -- make sure beams get to "explode" */
7201         gm[1] = grids;
7202
7203         dist = path_n;
7204         dist_hack = dist;
7205
7206         project_length = 0;
7207
7208         /* If we found a "target", explode there */
7209         if (dist <= MAX_RANGE)
7210         {
7211                 /* Mega-Hack -- remove the final "beam" grid */
7212                 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
7213
7214                 /*
7215                  * Create a conical breath attack
7216                  *
7217                  *       ***
7218                  *   ********
7219                  * D********@**
7220                  *   ********
7221                  *       ***
7222                  */
7223
7224                 if (breath)
7225                 {
7226                         flg &= ~(PROJECT_HIDE);
7227
7228                         breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
7229                 }
7230                 else
7231                 {
7232                         /* Determine the blast area, work from the inside out */
7233                         for (dist = 0; dist <= rad; dist++)
7234                         {
7235                                 /* Scan the maximal blast area of radius "dist" */
7236                                 for (y = by - dist; y <= by + dist; y++)
7237                                 {
7238                                         for (x = bx - dist; x <= bx + dist; x++)
7239                                         {
7240                                                 /* Ignore "illegal" locations */
7241                                                 if (!in_bounds2(y, x)) continue;
7242
7243                                                 /* Enforce a "circular" explosion */
7244                                                 if (distance(by, bx, y, x) != dist) continue;
7245
7246                                                 switch (typ)
7247                                                 {
7248                                                 case GF_LITE:
7249                                                 case GF_LITE_WEAK:
7250                                                         /* Lights are stopped by opaque terrains */
7251                                                         if (!los(by, bx, y, x)) continue;
7252                                                         break;
7253                                                 case GF_DISINTEGRATE:
7254                                                         /* Disintegration are stopped only by perma-walls */
7255                                                         if (!in_disintegration_range(by, bx, y, x)) continue;
7256                                                         break;
7257                                                 default:
7258                                                         /* Ball explosions are stopped by walls */
7259                                                         if (!projectable(by, bx, y, x)) continue;
7260                                                         break;
7261                                                 }
7262
7263                                                 /* Save this grid */
7264                                                 gy[grids] = y;
7265                                                 gx[grids] = x;
7266                                                 grids++;
7267                                         }
7268                                 }
7269
7270                                 /* Encode some more "radius" info */
7271                                 gm[dist+1] = grids;
7272                         }
7273                 }
7274         }
7275
7276         /* Speed -- ignore "non-explosions" */
7277         if (!grids) return (FALSE);
7278
7279
7280         /* Display the "blast area" if requested */
7281         if (!blind && !(flg & (PROJECT_HIDE)))
7282         {
7283                 /* Then do the "blast", from inside out */
7284                 for (t = 0; t <= gm_rad; t++)
7285                 {
7286                         /* Dump everything with this radius */
7287                         for (i = gm[t]; i < gm[t+1]; i++)
7288                         {
7289                                 /* Extract the location */
7290                                 y = gy[i];
7291                                 x = gx[i];
7292
7293                                 /* Only do visuals if the player can "see" the blast */
7294                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7295                                 {
7296                                         u16b p;
7297
7298                                         TERM_COLOR a;
7299                                         SYMBOL_CODE c;
7300
7301                                         drawn = TRUE;
7302
7303                                         /* Obtain the explosion pict */
7304                                         p = bolt_pict(y, x, y, x, typ);
7305
7306                                         /* Extract attr/char */
7307                                         a = PICT_A(p);
7308                                         c = PICT_C(p);
7309
7310                                         /* Visual effects -- Display */
7311                                         print_rel(c, a, y, x);
7312                                 }
7313                         }
7314
7315                         /* Hack -- center the cursor */
7316                         move_cursor_relative(by, bx);
7317
7318                         /* Flush each "radius" seperately */
7319                         /*if (fresh_before)*/ Term_fresh();
7320
7321                         /* Delay (efficiently) */
7322                         if (visual || drawn)
7323                         {
7324                                 Term_xtra(TERM_XTRA_DELAY, msec);
7325                         }
7326                 }
7327
7328                 /* Flush the erasing */
7329                 if (drawn)
7330                 {
7331                         /* Erase the explosion drawn above */
7332                         for (i = 0; i < grids; i++)
7333                         {
7334                                 /* Extract the location */
7335                                 y = gy[i];
7336                                 x = gx[i];
7337
7338                                 /* Hack -- Erase if needed */
7339                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
7340                                 {
7341                                         lite_spot(y, x);
7342                                 }
7343                         }
7344
7345                         /* Hack -- center the cursor */
7346                         move_cursor_relative(by, bx);
7347
7348                         /* Flush the explosion */
7349                         /*if (fresh_before)*/ Term_fresh();
7350                 }
7351         }
7352
7353         update_creature(p_ptr);
7354
7355         if (flg & PROJECT_KILL)
7356         {
7357                 see_s_msg = (who > 0) ? is_seen(&m_list[who]) :
7358                         (!who ? TRUE : (player_can_see_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)));
7359         }
7360
7361
7362         /* Check features */
7363         if (flg & (PROJECT_GRID))
7364         {
7365                 /* Start with "dist" of zero */
7366                 dist = 0;
7367
7368                 /* Scan for features */
7369                 for (i = 0; i < grids; i++)
7370                 {
7371                         /* Hack -- Notice new "dist" values */
7372                         if (gm[dist+1] == i) dist++;
7373
7374                         /* Get the grid location */
7375                         y = gy[i];
7376                         x = gx[i];
7377
7378                         /* Find the closest point in the blast */
7379                         if (breath)
7380                         {
7381                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7382
7383                                 /* Affect the grid */
7384                                 if (project_f(who, d, y, x, dam, typ)) notice = TRUE;
7385                         }
7386                         else
7387                         {
7388                                 /* Affect the grid */
7389                                 if (project_f(who, dist, y, x, dam, typ)) notice = TRUE;
7390                         }
7391                 }
7392         }
7393
7394         update_creature(p_ptr);
7395
7396         /* Check objects */
7397         if (flg & (PROJECT_ITEM))
7398         {
7399                 /* Start with "dist" of zero */
7400                 dist = 0;
7401
7402                 /* Scan for objects */
7403                 for (i = 0; i < grids; i++)
7404                 {
7405                         /* Hack -- Notice new "dist" values */
7406                         if (gm[dist+1] == i) dist++;
7407
7408                         /* Get the grid location */
7409                         y = gy[i];
7410                         x = gx[i];
7411
7412                         /* Find the closest point in the blast */
7413                         if (breath)
7414                         {
7415                                 int d = dist_to_line(y, x, y1, x1, by, bx);
7416
7417                                 /* Affect the object in the grid */
7418                                 if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
7419                         }
7420                         else
7421                         {
7422                                 /* Affect the object in the grid */
7423                                 if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
7424                         }
7425                 }
7426         }
7427
7428
7429         /* Check monsters */
7430         if (flg & (PROJECT_KILL))
7431         {
7432                 /* Mega-Hack */
7433                 project_m_n = 0;
7434                 project_m_x = 0;
7435                 project_m_y = 0;
7436
7437                 /* Start with "dist" of zero */
7438                 dist = 0;
7439
7440                 /* Scan for monsters */
7441                 for (i = 0; i < grids; i++)
7442                 {
7443                         int effective_dist;
7444
7445                         /* Hack -- Notice new "dist" values */
7446                         if (gm[dist + 1] == i) dist++;
7447
7448                         /* Get the grid location */
7449                         y = gy[i];
7450                         x = gx[i];
7451
7452                         /* A single bolt may be reflected */
7453                         if (grids <= 1)
7454                         {
7455                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7456                                 monster_race *ref_ptr = &r_info[m_ptr->r_idx];
7457
7458                                 if ((flg & PROJECT_REFLECTABLE) && cave[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
7459                                         ((cave[y][x].m_idx != p_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
7460                                         (!who || dist_hack > 1) && !one_in_(10))
7461                                 {
7462                                         POSITION t_y, t_x;
7463                                         int max_attempts = 10;
7464
7465                                         /* Choose 'new' target */
7466                                         do
7467                                         {
7468                                                 t_y = y_saver - 1 + randint1(3);
7469                                                 t_x = x_saver - 1 + randint1(3);
7470                                                 max_attempts--;
7471                                         }
7472                                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(y, x, t_y, t_x));
7473
7474                                         if (max_attempts < 1)
7475                                         {
7476                                                 t_y = y_saver;
7477                                                 t_x = x_saver;
7478                                         }
7479
7480                                         sound(SOUND_REFLECT);
7481                                         if (is_seen(m_ptr))
7482                                         {
7483                                                 if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
7484                                                         msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!"));
7485                                                 else if (m_ptr->r_idx == MON_DIO) 
7486                                                         msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!"));
7487                                                 else 
7488                                                         msg_print(_("攻撃は跳ね返った!", "The attack bounces!"));
7489                                         }
7490                                         if (is_original_ap_and_seen(m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
7491
7492                                         /* Reflected bolts randomly target either one */
7493                                         if (player_bold(y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
7494                                         else flg |= PROJECT_PLAYER;
7495
7496                                         /* The bolt is reflected */
7497                                         project(cave[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
7498
7499                                         /* Don't affect the monster any longer */
7500                                         continue;
7501                                 }
7502                         }
7503
7504
7505                         /* Find the closest point in the blast */
7506                         if (breath)
7507                         {
7508                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7509                         }
7510                         else
7511                         {
7512                                 effective_dist = dist;
7513                         }
7514
7515
7516                         /* There is the riding player on this monster */
7517                         if (p_ptr->riding && player_bold(y, x))
7518                         {
7519                                 /* Aimed on the player */
7520                                 if (flg & PROJECT_PLAYER)
7521                                 {
7522                                         if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7523                                         {
7524                                                 /*
7525                                                  * A beam or bolt is well aimed
7526                                                  * at the PLAYER!
7527                                                  * So don't affects the mount.
7528                                                  */
7529                                                 continue;
7530                                         }
7531                                         else
7532                                         {
7533                                                 /*
7534                                                  * The spell is not well aimed, 
7535                                                  * So partly affect the mount too.
7536                                                  */
7537                                                 effective_dist++;
7538                                         }
7539                                 }
7540
7541                                 /*
7542                                  * This grid is the original target.
7543                                  * Or aimed on your horse.
7544                                  */
7545                                 else if (((y == y2) && (x == x2)) || (flg & PROJECT_AIMED))
7546                                 {
7547                                         /* Hit the mount with full damage */
7548                                 }
7549
7550                                 /*
7551                                  * Otherwise this grid is not the
7552                                  * original target, it means that line
7553                                  * of fire is obstructed by this
7554                                  * monster.
7555                                  */
7556                                 /*
7557                                  * A beam or bolt will hit either
7558                                  * player or mount.  Choose randomly.
7559                                  */
7560                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
7561                                 {
7562                                         if (one_in_(2))
7563                                         {
7564                                                 /* Hit the mount with full damage */
7565                                         }
7566                                         else
7567                                         {
7568                                                 /* Hit the player later */
7569                                                 flg |= PROJECT_PLAYER;
7570
7571                                                 /* Don't affect the mount */
7572                                                 continue;
7573                                         }
7574                                 }
7575
7576                                 /*
7577                                  * The spell is not well aimed, so
7578                                  * partly affect both player and
7579                                  * mount.
7580                                  */
7581                                 else
7582                                 {
7583                                         effective_dist++;
7584                                 }
7585                         }
7586
7587                         /* Affect the monster in the grid */
7588                         if (project_m(who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
7589                 }
7590
7591
7592                 /* Player affected one monster (without "jumping") */
7593                 if (!who && (project_m_n == 1) && !jump)
7594                 {
7595                         x = project_m_x;
7596                         y = project_m_y;
7597
7598                         /* Track if possible */
7599                         if (cave[y][x].m_idx > 0)
7600                         {
7601                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
7602
7603                                 if (m_ptr->ml)
7604                                 {
7605                                         /* Hack -- auto-recall */
7606                                         if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
7607
7608                                         /* Hack - auto-track */
7609                                         if (m_ptr->ml) health_track(cave[y][x].m_idx);
7610                                 }
7611                         }
7612                 }
7613         }
7614
7615
7616         /* Check player */
7617         if (flg & (PROJECT_KILL))
7618         {
7619                 /* Start with "dist" of zero */
7620                 dist = 0;
7621
7622                 /* Scan for player */
7623                 for (i = 0; i < grids; i++)
7624                 {
7625                         int effective_dist;
7626
7627                         /* Hack -- Notice new "dist" values */
7628                         if (gm[dist+1] == i) dist++;
7629
7630                         /* Get the grid location */
7631                         y = gy[i];
7632                         x = gx[i];
7633
7634                         /* Affect the player? */
7635                         if (!player_bold(y, x)) continue;
7636
7637                         /* Find the closest point in the blast */
7638                         if (breath)
7639                         {
7640                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
7641                         }
7642                         else
7643                         {
7644                                 effective_dist = dist;
7645                         }
7646
7647                         /* Target may be your horse */
7648                         if (p_ptr->riding)
7649                         {
7650                                 /* Aimed on the player */
7651                                 if (flg & PROJECT_PLAYER)
7652                                 {
7653                                         /* Hit the player with full damage */
7654                                 }
7655
7656                                 /*
7657                                  * Hack -- When this grid was not the
7658                                  * original target, a beam or bolt
7659                                  * would hit either player or mount,
7660                                  * and should be choosen randomly.
7661                                  *
7662                                  * But already choosen to hit the
7663                                  * mount at this point.
7664                                  *
7665                                  * Or aimed on your horse.
7666                                  */
7667                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
7668                                 {
7669                                         /*
7670                                          * A beam or bolt is well aimed
7671                                          * at the mount!
7672                                          * So don't affects the player.
7673                                          */
7674                                         continue;
7675                                 }
7676                                 else
7677                                 {
7678                                         /*
7679                                          * The spell is not well aimed, 
7680                                          * So partly affect the player too.
7681                                          */
7682                                         effective_dist++;
7683                                 }
7684                         }
7685
7686                         /* Affect the player */
7687                         if (project_p(who, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
7688                 }
7689         }
7690
7691         if (p_ptr->riding)
7692         {
7693                 GAME_TEXT m_name[MAX_NLEN];
7694
7695                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
7696
7697                 if (rakubadam_m > 0)
7698                 {
7699                         if (rakuba(rakubadam_m, FALSE))
7700                         {
7701                                 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
7702                         }
7703                 }
7704                 if (p_ptr->riding && rakubadam_p > 0)
7705                 {
7706                         if(rakuba(rakubadam_p, FALSE))
7707                         {
7708                                 msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name);
7709                         }
7710                 }
7711         }
7712
7713         /* Return "something was noticed" */
7714         return (notice);
7715 }
7716
7717 /*!
7718  * @brief 鏡魔法「封魔結界」の効果処理
7719  * @param dam ダメージ量
7720  * @return 効果があったらTRUEを返す
7721  */
7722 bool binding_field(HIT_POINT dam)
7723 {
7724         POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
7725         int mirror_num = 0;                       /* 鏡の数 */
7726         POSITION x, y;
7727         POSITION centersign;
7728         POSITION x1, x2, y1, y2;
7729         u16b p;
7730         int msec = delay_factor*delay_factor*delay_factor;
7731
7732         /* 三角形の頂点 */
7733         POSITION point_x[3];
7734         POSITION point_y[3];
7735
7736         /* Default target of monsterspell is player */
7737         monster_target_y = p_ptr->y;
7738         monster_target_x = p_ptr->x;
7739
7740         for (x = 0; x < cur_wid; x++)
7741         {
7742                 for (y = 0; y < cur_hgt; y++)
7743                 {
7744                         if (is_mirror_grid(&cave[y][x]) &&
7745                                 distance(p_ptr->y, p_ptr->x, y, x) <= MAX_RANGE &&
7746                                 distance(p_ptr->y, p_ptr->x, y, x) != 0 &&
7747                                 player_has_los_bold(y, x) &&
7748                                 projectable(p_ptr->y, p_ptr->x, y, x)
7749                                 ) {
7750                                 mirror_y[mirror_num] = y;
7751                                 mirror_x[mirror_num] = x;
7752                                 mirror_num++;
7753                         }
7754                 }
7755         }
7756
7757         if (mirror_num < 2)return FALSE;
7758
7759         point_x[0] = randint0(mirror_num);
7760         do {
7761                 point_x[1] = randint0(mirror_num);
7762         } while (point_x[0] == point_x[1]);
7763
7764         point_y[0] = mirror_y[point_x[0]];
7765         point_x[0] = mirror_x[point_x[0]];
7766         point_y[1] = mirror_y[point_x[1]];
7767         point_x[1] = mirror_x[point_x[1]];
7768         point_y[2] = p_ptr->y;
7769         point_x[2] = p_ptr->x;
7770
7771         x = point_x[0] + point_x[1] + point_x[2];
7772         y = point_y[0] + point_y[1] + point_y[2];
7773
7774         centersign = (point_x[0] * 3 - x)*(point_y[1] * 3 - y)
7775                 - (point_y[0] * 3 - y)*(point_x[1] * 3 - x);
7776         if (centersign == 0)return FALSE;
7777
7778         x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
7779         x1 = x1 < point_x[2] ? x1 : point_x[2];
7780         y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
7781         y1 = y1 < point_y[2] ? y1 : point_y[2];
7782
7783         x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
7784         x2 = x2 > point_x[2] ? x2 : point_x[2];
7785         y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
7786         y2 = y2 > point_y[2] ? y2 : point_y[2];
7787
7788         for (y = y1; y <= y2; y++) {
7789                 for (x = x1; x <= x2; x++) {
7790                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7791                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7792                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7793                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7794                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7795                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7796                         {
7797                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7798                                         /* Visual effects */
7799                                         if (!(p_ptr->blind)
7800                                                 && panel_contains(y, x)) {
7801                                                 p = bolt_pict(y, x, y, x, GF_MANA);
7802                                                 print_rel(PICT_C(p), PICT_A(p), y, x);
7803                                                 move_cursor_relative(y, x);
7804                                                 /*if (fresh_before)*/ Term_fresh();
7805                                                 Term_xtra(TERM_XTRA_DELAY, msec);
7806                                         }
7807                                 }
7808                         }
7809                 }
7810         }
7811         for (y = y1; y <= y2; y++) {
7812                 for (x = x1; x <= x2; x++) {
7813                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7814                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7815                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7816                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7817                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7818                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7819                         {
7820                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7821                                         (void)project_f(0, 0, y, x, dam, GF_MANA);
7822                                 }
7823                         }
7824                 }
7825         }
7826         for (y = y1; y <= y2; y++) {
7827                 for (x = x1; x <= x2; x++) {
7828                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7829                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7830                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7831                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7832                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7833                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7834                         {
7835                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7836                                         (void)project_o(0, 0, y, x, dam, GF_MANA);
7837                                 }
7838                         }
7839                 }
7840         }
7841         for (y = y1; y <= y2; y++) {
7842                 for (x = x1; x <= x2; x++) {
7843                         if (centersign*((point_x[0] - x)*(point_y[1] - y)
7844                                 - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
7845                                 centersign*((point_x[1] - x)*(point_y[2] - y)
7846                                         - (point_y[1] - y)*(point_x[2] - x)) >= 0 &&
7847                                 centersign*((point_x[2] - x)*(point_y[0] - y)
7848                                         - (point_y[2] - y)*(point_x[0] - x)) >= 0)
7849                         {
7850                                 if (player_has_los_bold(y, x) && projectable(p_ptr->y, p_ptr->x, y, x)) {
7851                                         (void)project_m(0, 0, y, x, dam, GF_MANA,
7852                                                 (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
7853                                 }
7854                         }
7855                 }
7856         }
7857         if (one_in_(7)) {
7858                 msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
7859                 remove_mirror(point_y[0], point_x[0]);
7860         }
7861
7862         return TRUE;
7863 }
7864
7865 /*!
7866  * @brief 鏡魔法「鏡の封印」の効果処理
7867  * @param dam ダメージ量
7868  * @return 効果があったらTRUEを返す
7869  */
7870 void seal_of_mirror(HIT_POINT dam)
7871 {
7872         POSITION x, y;
7873
7874         for (x = 0; x < cur_wid; x++)
7875         {
7876                 for (y = 0; y < cur_hgt; y++)
7877                 {
7878                         if (is_mirror_grid(&cave[y][x]))
7879                         {
7880                                 if (project_m(0, 0, y, x, dam, GF_GENOCIDE,
7881                                         (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
7882                                 {
7883                                         if (!cave[y][x].m_idx)
7884                                         {
7885                                                 remove_mirror(y, x);
7886                                         }
7887                                 }
7888                         }
7889                 }
7890         }
7891         return;
7892 }
7893