OSDN Git Service

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