OSDN Git Service

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