OSDN Git Service

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