OSDN Git Service

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