OSDN Git Service

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