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                         if (!dam) break;
3394                 }
3395                 case GF_OLD_HEAL:
3396                 {
3397                         if (seen) obvious = TRUE;
3398
3399                         /* Wake up */
3400                         m_ptr->csleep = 0;
3401
3402                         if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
3403
3404                         if (m_ptr->stunned)
3405                         {
3406 #ifdef JP
3407                                 if (seen_msg) msg_format("%^s¤ÏÛ¯Û°¾õÂÖ¤«¤éΩ¤Áľ¤Ã¤¿¡£", m_name);
3408 #else
3409                                 if (seen_msg) msg_format("%^s is no longer stunned.", m_name);
3410 #endif
3411                                 m_ptr->stunned = 0;
3412                         }
3413                         if (m_ptr->confused)
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 confused.", m_name);
3419 #endif
3420                                 m_ptr->confused = 0;
3421                         }
3422                         if (m_ptr->monfear)
3423                         {
3424 #ifdef JP
3425                                 if (seen_msg) msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
3426 #else
3427                                 if (seen_msg) msg_format("%^s recovers %s courage.", m_name, m_poss);
3428 #endif
3429                                 m_ptr->monfear = 0;
3430                         }
3431
3432                         /* Heal */
3433                         if (m_ptr->hp < 30000) m_ptr->hp += dam;
3434
3435                         /* No overflow */
3436                         if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
3437
3438                         if (!who)
3439                         {
3440                                 chg_virtue(V_VITALITY, 1);
3441
3442                                 if (r_ptr->flags1 & RF1_UNIQUE)
3443                                         chg_virtue(V_INDIVIDUALISM, 1);
3444
3445                                 if (is_friendly(m_ptr))
3446                                         chg_virtue(V_HONOUR, 1);
3447                                 else if (!(r_ptr->flags3 & RF3_EVIL))
3448                                 {
3449                                         if (r_ptr->flags3 & RF3_GOOD)
3450                                                 chg_virtue(V_COMPASSION, 2);
3451                                         else
3452                                                 chg_virtue(V_COMPASSION, 1);
3453                                 }
3454
3455                                 if (r_ptr->flags3 & RF3_ANIMAL)
3456                                         chg_virtue(V_NATURE, 1);
3457                         }
3458
3459                         if (m_ptr->r_idx == MON_LEPER)
3460                         {
3461                                 heal_leper = TRUE;
3462                                 if (!who) chg_virtue(V_COMPASSION, 5);
3463                         }
3464
3465                         /* Redraw (later) if needed */
3466                         if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
3467                         if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
3468
3469                         /* Message */
3470 #ifdef JP
3471 note = "¤ÏÂÎÎϤò²óÉü¤·¤¿¤è¤¦¤À¡£";
3472 #else
3473                         note = " looks healthier.";
3474 #endif
3475
3476
3477                         /* No "real" damage */
3478                         dam = 0;
3479                         break;
3480                 }
3481
3482
3483                 /* Speed Monster (Ignore "dam") */
3484                 case GF_OLD_SPEED:
3485                 {
3486                         if (seen) obvious = TRUE;
3487
3488                         /* Speed up */
3489                         if (!m_ptr->fast)
3490                         {
3491 #ifdef JP
3492 note = "¤ÎÆ°¤­¤¬Â®¤¯¤Ê¤Ã¤¿¡£";
3493 #else
3494                                 note = " starts moving faster.";
3495 #endif
3496                         }
3497                         m_ptr->fast = MIN(200, m_ptr->fast + 100);
3498
3499                         if (c_ptr->m_idx == p_ptr->riding)
3500                                 p_ptr->update |= (PU_BONUS);
3501
3502                         if (!who)
3503                         {
3504                                 if (r_ptr->flags1 & RF1_UNIQUE)
3505                                         chg_virtue(V_INDIVIDUALISM, 1);
3506                                 if (is_friendly(m_ptr))
3507                                         chg_virtue(V_HONOUR, 1);
3508                         }
3509
3510                         /* No "real" damage */
3511                         dam = 0;
3512                         break;
3513                 }
3514
3515
3516                 /* Slow Monster (Use "dam" as "power") */
3517                 case GF_OLD_SLOW:
3518                 {
3519                         if (seen) obvious = TRUE;
3520
3521                         if (r_ptr->flagsr & RFR_RES_ALL)
3522                         {
3523 #ifdef JP
3524                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3525 #else
3526                                 note = " is immune.";
3527 #endif
3528                                 dam = 0;
3529                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3530                                 break;
3531                         }
3532                         /* Powerful monsters can resist */
3533                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3534                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3535                         {
3536 #ifdef JP
3537 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3538 #else
3539                                 note = " is unaffected!";
3540 #endif
3541
3542                                 obvious = FALSE;
3543                         }
3544
3545                         /* Normal monsters slow down */
3546                         else
3547                         {
3548                                 if (!m_ptr->slow)
3549                                 {
3550 #ifdef JP
3551 note = "¤ÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤¿¡£";
3552 #else
3553                                         note = " starts moving slower.";
3554 #endif
3555                                 }
3556                                 m_ptr->slow = MIN(200, m_ptr->slow + 50);
3557
3558                                 if (c_ptr->m_idx == p_ptr->riding)
3559                                         p_ptr->update |= (PU_BONUS);
3560                         }
3561
3562                         /* No "real" damage */
3563                         dam = 0;
3564                         break;
3565                 }
3566
3567
3568                 /* Sleep (Use "dam" as "power") */
3569                 case GF_OLD_SLEEP:
3570                 {
3571                         if (seen) obvious = TRUE;
3572
3573                         if (r_ptr->flagsr & RFR_RES_ALL)
3574                         {
3575 #ifdef JP
3576                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3577 #else
3578                                 note = " is immune.";
3579 #endif
3580                                 dam = 0;
3581                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3582                                 break;
3583                         }
3584                         /* Attempt a saving throw */
3585                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3586                             (r_ptr->flags3 & RF3_NO_SLEEP) ||
3587                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3588                         {
3589                                 /* Memorize a flag */
3590                                 if (r_ptr->flags3 & RF3_NO_SLEEP)
3591                                 {
3592                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
3593                                 }
3594
3595                                 /* No obvious effect */
3596 #ifdef JP
3597 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3598 #else
3599                                 note = " is unaffected!";
3600 #endif
3601
3602                                 obvious = FALSE;
3603                         }
3604                         else
3605                         {
3606                                 /* Go to sleep (much) later */
3607 #ifdef JP
3608 note = "¤Ï̲¤ê¹þ¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
3609 #else
3610                                 note = " falls asleep!";
3611 #endif
3612
3613                                 do_sleep = 500;
3614                         }
3615
3616                         /* No "real" damage */
3617                         dam = 0;
3618                         break;
3619                 }
3620
3621
3622                 /* Sleep (Use "dam" as "power") */
3623                 case GF_STASIS_EVIL:
3624                 {
3625                         if (seen) obvious = TRUE;
3626
3627                         if (r_ptr->flagsr & RFR_RES_ALL)
3628                         {
3629 #ifdef JP
3630                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3631 #else
3632                                 note = " is immune.";
3633 #endif
3634                                 dam = 0;
3635                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3636                                 break;
3637                         }
3638                         /* Attempt a saving throw */
3639                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3640                             !(r_ptr->flags3 & RF3_EVIL) ||
3641                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3642                         {
3643 #ifdef JP
3644 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3645 #else
3646                                 note = " is unaffected!";
3647 #endif
3648
3649                                 obvious = FALSE;
3650                         }
3651                         else
3652                         {
3653                                 /* Go to sleep (much) later */
3654 #ifdef JP
3655 note = "¤ÏÆ°¤±¤Ê¤¯¤Ê¤Ã¤¿¡ª";
3656 #else
3657                                 note = " is suspended!";
3658 #endif
3659
3660                                 do_sleep = 500;
3661                         }
3662
3663                         /* No "real" damage */
3664                         dam = 0;
3665                         break;
3666                 }
3667
3668                 /* Sleep (Use "dam" as "power") */
3669                 case GF_STASIS:
3670                 {
3671                         if (seen) obvious = TRUE;
3672
3673                         if (r_ptr->flagsr & RFR_RES_ALL)
3674                         {
3675 #ifdef JP
3676                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3677 #else
3678                                 note = " is immune.";
3679 #endif
3680                                 dam = 0;
3681                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3682                                 break;
3683                         }
3684                         /* Attempt a saving throw */
3685                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3686                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3687                         {
3688 #ifdef JP
3689 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3690 #else
3691                                 note = " is unaffected!";
3692 #endif
3693
3694                                 obvious = FALSE;
3695                         }
3696                         else
3697                         {
3698                                 /* Go to sleep (much) later */
3699 #ifdef JP
3700 note = "¤ÏÆ°¤±¤Ê¤¯¤Ê¤Ã¤¿¡ª";
3701 #else
3702                                 note = " is suspended!";
3703 #endif
3704
3705                                 do_sleep = 500;
3706                         }
3707
3708                         /* No "real" damage */
3709                         dam = 0;
3710                         break;
3711                 }
3712
3713                 /* Charm monster */
3714                 case GF_CHARM:
3715                 {
3716                         int vir;
3717                         dam += (adj_con_fix[p_ptr->stat_ind[A_CHR]] - 1);
3718                         vir = virtue_number(V_HARMONY);
3719                         if (vir)
3720                         {
3721                                 dam += p_ptr->virtues[vir-1]/10;
3722                         }
3723
3724                         vir = virtue_number(V_INDIVIDUALISM);
3725                         if (vir)
3726                         {
3727                                 dam -= p_ptr->virtues[vir-1]/20;
3728                         }
3729
3730                         if (seen) obvious = TRUE;
3731
3732                         if ((r_ptr->flagsr & RFR_RES_ALL) || p_ptr->inside_arena)
3733                         {
3734 #ifdef JP
3735                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3736 #else
3737                                 note = " is immune.";
3738 #endif
3739                                 dam = 0;
3740                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3741                                 break;
3742                         }
3743
3744                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))
3745                                 dam = dam * 2 / 3;
3746
3747                         /* Attempt a saving throw */
3748                         if ((r_ptr->flags1 & RF1_QUESTOR) ||
3749                             (r_ptr->flags3 & RF3_NO_CONF) ||
3750                             (m_ptr->mflag2 & MFLAG2_NOPET) ||
3751                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 5))
3752                         {
3753                                 /* Memorize a flag */
3754                                 if (r_ptr->flags3 & RF3_NO_CONF)
3755                                 {
3756                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3757                                 }
3758
3759                                 /* Resist */
3760                                 /* No obvious effect */
3761 #ifdef JP
3762 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3763 #else
3764                                 note = " is unaffected!";
3765 #endif
3766
3767                                 obvious = FALSE;
3768
3769                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3770                         }
3771                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3772                         {
3773 #ifdef JP
3774 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
3775 #else
3776                                 note = " hates you too much!";
3777 #endif
3778
3779                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3780                         }
3781                         else
3782                         {
3783 #ifdef JP
3784 note = "¤ÏÆÍÁ³Í§¹¥Åª¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡ª";
3785 #else
3786                                 note = " suddenly seems friendly!";
3787 #endif
3788
3789                                 set_pet(m_ptr);
3790
3791                                 chg_virtue(V_INDIVIDUALISM, -1);
3792                                 if (r_ptr->flags3 & RF3_ANIMAL)
3793                                         chg_virtue(V_NATURE, 1);
3794                         }
3795
3796                         /* No "real" damage */
3797                         dam = 0;
3798                         break;
3799                 }
3800
3801                 /* Control undead */
3802                 case GF_CONTROL_UNDEAD:
3803                 {
3804                         int vir;
3805                         if (seen) obvious = TRUE;
3806
3807                         vir = virtue_number(V_UNLIFE);
3808                         if (vir)
3809                         {
3810                                 dam += p_ptr->virtues[vir-1]/10;
3811                         }
3812
3813                         vir = virtue_number(V_INDIVIDUALISM);
3814                         if (vir)
3815                         {
3816                                 dam -= p_ptr->virtues[vir-1]/20;
3817                         }
3818
3819                         if ((r_ptr->flagsr & RFR_RES_ALL) || p_ptr->inside_arena)
3820                         {
3821 #ifdef JP
3822                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3823 #else
3824                                 note = " is immune.";
3825 #endif
3826                                 dam = 0;
3827                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3828                                 break;
3829                         }
3830
3831                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))
3832                                 dam = dam * 2 / 3;
3833
3834                         /* Attempt a saving throw */
3835                         if ((r_ptr->flags1 & RF1_QUESTOR) ||
3836                           (!(r_ptr->flags3 & RF3_UNDEAD)) ||
3837                             (m_ptr->mflag2 & MFLAG2_NOPET) ||
3838                                  (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3839                         {
3840                                 /* No obvious effect */
3841 #ifdef JP
3842 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3843 #else
3844                                 note = " is unaffected!";
3845 #endif
3846
3847                                 obvious = FALSE;
3848                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3849                         }
3850                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3851                         {
3852 #ifdef JP
3853 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
3854 #else
3855                                 note = " hates you too much!";
3856 #endif
3857
3858                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3859                         }
3860                         else
3861                         {
3862 #ifdef JP
3863 note = "¤Ï´û¤Ë¤¢¤Ê¤¿¤ÎÅÛÎì¤À¡ª";
3864 #else
3865                                 note = " is in your thrall!";
3866 #endif
3867
3868                                 set_pet(m_ptr);
3869                         }
3870
3871                         /* No "real" damage */
3872                         dam = 0;
3873                         break;
3874                 }
3875
3876                 /* Control demon */
3877                 case GF_CONTROL_DEMON:
3878                 {
3879                         int vir;
3880                         if (seen) obvious = TRUE;
3881
3882                         vir = virtue_number(V_UNLIFE);
3883                         if (vir)
3884                         {
3885                                 dam += p_ptr->virtues[vir-1]/10;
3886                         }
3887
3888                         vir = virtue_number(V_INDIVIDUALISM);
3889                         if (vir)
3890                         {
3891                                 dam -= p_ptr->virtues[vir-1]/20;
3892                         }
3893
3894                         if ((r_ptr->flagsr & RFR_RES_ALL) || p_ptr->inside_arena)
3895                         {
3896 #ifdef JP
3897                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3898 #else
3899                                 note = " is immune.";
3900 #endif
3901                                 dam = 0;
3902                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3903                                 break;
3904                         }
3905
3906                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))
3907                                 dam = dam * 2 / 3;
3908
3909                         /* Attempt a saving throw */
3910                         if ((r_ptr->flags1 & RF1_QUESTOR) ||
3911                           (!(r_ptr->flags3 & RF3_DEMON)) ||
3912                             (m_ptr->mflag2 & MFLAG2_NOPET) ||
3913                                  (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3914                         {
3915                                 /* No obvious effect */
3916 #ifdef JP
3917 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3918 #else
3919                                 note = " is unaffected!";
3920 #endif
3921
3922                                 obvious = FALSE;
3923                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3924                         }
3925                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3926                         {
3927 #ifdef JP
3928 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
3929 #else
3930                                 note = " hates you too much!";
3931 #endif
3932
3933                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
3934                         }
3935                         else
3936                         {
3937 #ifdef JP
3938 note = "¤Ï´û¤Ë¤¢¤Ê¤¿¤ÎÅÛÎì¤À¡ª";
3939 #else
3940                                 note = " is in your thrall!";
3941 #endif
3942
3943                                 set_pet(m_ptr);
3944                         }
3945
3946                         /* No "real" damage */
3947                         dam = 0;
3948                         break;
3949                 }
3950
3951                 /* Tame animal */
3952                 case GF_CONTROL_ANIMAL:
3953                 {
3954                         int vir;
3955
3956                         if (seen) obvious = TRUE;
3957
3958                         vir = virtue_number(V_NATURE);
3959                         if (vir)
3960                         {
3961                                 dam += p_ptr->virtues[vir-1]/10;
3962                         }
3963
3964                         vir = virtue_number(V_INDIVIDUALISM);
3965                         if (vir)
3966                         {
3967                                 dam -= p_ptr->virtues[vir-1]/20;
3968                         }
3969
3970                         if ((r_ptr->flagsr & RFR_RES_ALL) || p_ptr->inside_arena)
3971                         {
3972 #ifdef JP
3973                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3974 #else
3975                                 note = " is immune.";
3976 #endif
3977                                 dam = 0;
3978                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
3979                                 break;
3980                         }
3981
3982                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))
3983                                 dam = dam * 2 / 3;
3984
3985                         /* Attempt a saving throw */
3986                         if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
3987                           (!(r_ptr->flags3 & (RF3_ANIMAL))) ||
3988                             (m_ptr->mflag2 & MFLAG2_NOPET) ||
3989                                  (r_ptr->flags3 & (RF3_NO_CONF)) ||
3990                                  (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3991                         {
3992                                 /* Memorize a flag */
3993                                 if (r_ptr->flags3 & (RF3_NO_CONF))
3994                                 {
3995                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
3996                                 }
3997
3998                                 /* Resist */
3999                                 /* No obvious effect */
4000 #ifdef JP
4001 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4002 #else
4003                                 note = " is unaffected!";
4004 #endif
4005
4006                                 obvious = FALSE;
4007                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4008                         }
4009                         else if (p_ptr->cursed & TRC_AGGRAVATE)
4010                         {
4011 #ifdef JP
4012 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
4013 #else
4014                                 note = " hates you too much!";
4015 #endif
4016
4017                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4018                         }
4019                         else
4020                         {
4021 #ifdef JP
4022 note = "¤Ï¤Ê¤Ä¤¤¤¿¡£";
4023 #else
4024                                 note = " is tamed!";
4025 #endif
4026
4027                                 set_pet(m_ptr);
4028
4029                                 if (r_ptr->flags3 & RF3_ANIMAL)
4030                                         chg_virtue(V_NATURE, 1);
4031                         }
4032
4033                         /* No "real" damage */
4034                         dam = 0;
4035                         break;
4036                 }
4037
4038                 /* Tame animal */
4039                 case GF_CONTROL_LIVING:
4040                 {
4041                         int vir;
4042
4043                         vir = virtue_number(V_UNLIFE);
4044                         if (seen) obvious = TRUE;
4045
4046                         dam += (adj_chr_chm[p_ptr->stat_ind[A_CHR]]);
4047                         vir = virtue_number(V_UNLIFE);
4048                         if (vir)
4049                         {
4050                                 dam -= p_ptr->virtues[vir-1]/10;
4051                         }
4052
4053                         vir = virtue_number(V_INDIVIDUALISM);
4054                         if (vir)
4055                         {
4056                                 dam -= p_ptr->virtues[vir-1]/20;
4057                         }
4058
4059                         if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 30;
4060                         if (dam < 1) dam = 1;
4061 #ifdef JP
4062 msg_format("%s¤ò¸«¤Ä¤á¤¿¡£",m_name);
4063 #else
4064                         msg_format("You stare into %s.", m_name);
4065 #endif
4066                         if ((r_ptr->flagsr & RFR_RES_ALL) || p_ptr->inside_arena)
4067                         {
4068 #ifdef JP
4069                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4070 #else
4071                                 note = " is immune.";
4072 #endif
4073                                 dam = 0;
4074                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4075                                 break;
4076                         }
4077
4078                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))
4079                                 dam = dam * 2 / 3;
4080
4081                         /* Attempt a saving throw */
4082                         if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
4083                             (m_ptr->mflag2 & MFLAG2_NOPET) ||
4084                                  !monster_living(r_ptr) ||
4085                                  ((r_ptr->level+10) > randint1(dam)))
4086                         {
4087                                 /* Resist */
4088                                 /* No obvious effect */
4089 #ifdef JP
4090 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4091 #else
4092                                 note = " is unaffected!";
4093 #endif
4094
4095                                 obvious = FALSE;
4096                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4097                         }
4098                         else if (p_ptr->cursed & TRC_AGGRAVATE)
4099                         {
4100 #ifdef JP
4101 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
4102 #else
4103                                 note = " hates you too much!";
4104 #endif
4105
4106                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
4107                         }
4108                         else
4109                         {
4110 #ifdef JP
4111 note = "¤ò»ÙÇÛ¤·¤¿¡£";
4112 #else
4113                                 note = " is tamed!";
4114 #endif
4115
4116                                 set_pet(m_ptr);
4117
4118                                 if (r_ptr->flags3 & RF3_ANIMAL)
4119                                         chg_virtue(V_NATURE, 1);
4120                         }
4121
4122                         /* No "real" damage */
4123                         dam = 0;
4124                         break;
4125                 }
4126
4127                 /* Confusion (Use "dam" as "power") */
4128                 case GF_OLD_CONF:
4129                 {
4130                         if (seen) obvious = TRUE;
4131
4132                         if (r_ptr->flagsr & RFR_RES_ALL)
4133                         {
4134 #ifdef JP
4135                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4136 #else
4137                                 note = " is immune.";
4138 #endif
4139                                 dam = 0;
4140                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4141                                 break;
4142                         }
4143                         /* Get confused later */
4144                         do_conf = damroll(3, (dam / 2)) + 1;
4145
4146                         /* Attempt a saving throw */
4147                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4148                             (r_ptr->flags3 & (RF3_NO_CONF)) ||
4149                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4150                         {
4151                                 /* Memorize a flag */
4152                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4153                                 {
4154                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
4155                                 }
4156
4157                                 /* Resist */
4158                                 do_conf = 0;
4159
4160                                 /* No obvious effect */
4161 #ifdef JP
4162 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4163 #else
4164                                 note = " is unaffected!";
4165 #endif
4166
4167                                 obvious = FALSE;
4168                         }
4169
4170                         /* No "real" damage */
4171                         dam = 0;
4172                         break;
4173                 }
4174
4175                 case GF_STUN:
4176                 {
4177                         if (seen) obvious = TRUE;
4178
4179                         if (r_ptr->flagsr & RFR_RES_ALL)
4180                         {
4181 #ifdef JP
4182                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4183 #else
4184                                 note = " is immune.";
4185 #endif
4186                                 dam = 0;
4187                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4188                                 break;
4189                         }
4190                         do_stun = damroll((caster_lev / 20) + 3 , (dam)) + 1;
4191
4192                         /* Attempt a saving throw */
4193                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4194                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4195                         {
4196                                 /* Resist */
4197                                 do_stun = 0;
4198
4199                                 /* No obvious effect */
4200 #ifdef JP
4201 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4202 #else
4203                                 note = " is unaffected!";
4204 #endif
4205
4206                                 obvious = FALSE;
4207                         }
4208
4209                         /* No "real" damage */
4210                         dam = 0;
4211                         break;
4212                 }
4213
4214
4215
4216
4217                 /* Lite, but only hurts susceptible creatures */
4218                 case GF_LITE_WEAK:
4219                 {
4220                         if (!dam)
4221                         {
4222                                 skipped = TRUE;
4223                                 break;
4224                         }
4225                         if (r_ptr->flagsr & RFR_RES_ALL)
4226                         {
4227                                 dam = 0;
4228                                 break;
4229                         }
4230                         /* Hurt by light */
4231                         if (r_ptr->flags3 & (RF3_HURT_LITE))
4232                         {
4233                                 /* Obvious effect */
4234                                 if (seen) obvious = TRUE;
4235
4236                                 /* Memorize the effects */
4237                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4238
4239                                 /* Special effect */
4240 #ifdef JP
4241 note = "¤Ï¸÷¤Ë¿È¤ò¤¹¤¯¤á¤¿¡ª";
4242 note_dies = "¤Ï¸÷¤ò¼õ¤±¤Æ¤·¤Ü¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
4243 #else
4244                                 note = " cringes from the light!";
4245                                 note_dies = " shrivels away in the light!";
4246 #endif
4247
4248                         }
4249
4250                         /* Normally no damage */
4251                         else
4252                         {
4253                                 /* No damage */
4254                                 dam = 0;
4255                         }
4256
4257                         break;
4258                 }
4259
4260
4261
4262                 /* Lite -- opposite of Dark */
4263                 case GF_LITE:
4264                 {
4265                         if (seen) obvious = TRUE;
4266
4267                         if (r_ptr->flagsr & RFR_RES_ALL)
4268                         {
4269 #ifdef JP
4270                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4271 #else
4272                                 note = " is immune.";
4273 #endif
4274                                 dam = 0;
4275                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4276                                 break;
4277                         }
4278                         if (r_ptr->flagsr & RFR_RES_LITE)
4279                         {
4280 #ifdef JP
4281                                 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4282 #else
4283                                 note = " resists.";
4284 #endif
4285
4286                                 dam *= 2; dam /= (randint1(6)+6);
4287                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_LITE);
4288                         }
4289                         else if (r_ptr->flags3 & (RF3_HURT_LITE))
4290                         {
4291                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4292 #ifdef JP
4293                                 note = "¤Ï¸÷¤Ë¿È¤ò¤¹¤¯¤á¤¿¡ª";
4294                                 note_dies = "¤Ï¸÷¤ò¼õ¤±¤Æ¤·¤Ü¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
4295 #else
4296                                 note = " cringes from the light!";
4297                                 note_dies = " shrivels away in the light!";
4298 #endif
4299
4300                                 dam *= 2;
4301                         }
4302                         break;
4303                 }
4304
4305
4306                 /* Dark -- opposite of Lite */
4307                 case GF_DARK:
4308                 {
4309                         if (seen) obvious = TRUE;
4310
4311                         if (r_ptr->flagsr & RFR_RES_ALL)
4312                         {
4313 #ifdef JP
4314                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4315 #else
4316                                 note = " is immune.";
4317 #endif
4318                                 dam = 0;
4319                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4320                                 break;
4321                         }
4322                         if (r_ptr->flagsr & RFR_RES_DARK)
4323                         {
4324 #ifdef JP
4325                                 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4326 #else
4327                                 note = " resists.";
4328 #endif
4329
4330                                 dam *= 2; dam /= (randint1(6)+6);
4331                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_DARK);
4332                         }
4333                         break;
4334                 }
4335
4336
4337                 /* Stone to Mud */
4338                 case GF_KILL_WALL:
4339                 {
4340                         if (r_ptr->flagsr & RFR_RES_ALL)
4341                         {
4342                                 dam = 0;
4343                                 break;
4344                         }
4345                         /* Hurt by rock remover */
4346                         if (r_ptr->flags3 & (RF3_HURT_ROCK))
4347                         {
4348                                 /* Notice effect */
4349                                 if (seen) obvious = TRUE;
4350
4351                                 /* Memorize the effects */
4352                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
4353
4354                                 /* Cute little message */
4355 #ifdef JP
4356 note = "¤ÎÈéÉ椬¤¿¤À¤ì¤¿¡ª";
4357 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4358 #else
4359                                 note = " loses some skin!";
4360                                 note_dies = " dissolves!";
4361 #endif
4362
4363                         }
4364
4365                         /* Usually, ignore the effects */
4366                         else
4367                         {
4368                                 /* No damage */
4369                                 dam = 0;
4370                         }
4371
4372                         break;
4373                 }
4374
4375
4376                 /* Teleport undead (Use "dam" as "power") */
4377                 case GF_AWAY_UNDEAD:
4378                 {
4379                         /* Only affect undead */
4380                         if (r_ptr->flags3 & (RF3_UNDEAD))
4381                         {
4382                                 bool resists_tele = FALSE;
4383
4384                                 if (r_ptr->flagsr & RFR_RES_TELE)
4385                                 {
4386                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
4387                                         {
4388                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
4389 #ifdef JP
4390 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4391 #else
4392                                                 note = " is unaffected!";
4393 #endif
4394
4395                                                 resists_tele = TRUE;
4396                                         }
4397                                         else if (r_ptr->level > randint1(100))
4398                                         {
4399                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
4400 #ifdef JP
4401 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4402 #else
4403                                                 note = " resists!";
4404 #endif
4405
4406                                                 resists_tele = TRUE;
4407                                         }
4408                                 }
4409
4410                                 if (!resists_tele)
4411                                 {
4412                                         if (seen) obvious = TRUE;
4413                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
4414                                         do_dist = dam;
4415                                 }
4416                         }
4417
4418                         /* Others ignore */
4419                         else
4420                         {
4421                                 /* Irrelevant */
4422                                 skipped = TRUE;
4423                         }
4424
4425                         /* No "real" damage */
4426                         dam = 0;
4427                         break;
4428                 }
4429
4430
4431                 /* Teleport evil (Use "dam" as "power") */
4432                 case GF_AWAY_EVIL:
4433                 {
4434                         /* Only affect evil */
4435                         if (r_ptr->flags3 & (RF3_EVIL))
4436                         {
4437                                 bool resists_tele = FALSE;
4438
4439                                 if (r_ptr->flagsr & RFR_RES_TELE)
4440                                 {
4441                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
4442                                         {
4443                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
4444 #ifdef JP
4445 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4446 #else
4447                                                 note = " is unaffected!";
4448 #endif
4449
4450                                                 resists_tele = TRUE;
4451                                         }
4452                                         else if (r_ptr->level > randint1(100))
4453                                         {
4454                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
4455 #ifdef JP
4456 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4457 #else
4458                                                 note = " resists!";
4459 #endif
4460
4461                                                 resists_tele = TRUE;
4462                                         }
4463                                 }
4464
4465                                 if (!resists_tele)
4466                                 {
4467                                         if (seen) obvious = TRUE;
4468                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
4469                                         do_dist = dam;
4470                                 }
4471                         }
4472
4473                         /* Others ignore */
4474                         else
4475                         {
4476                                 /* Irrelevant */
4477                                 skipped = TRUE;
4478                         }
4479
4480                         /* No "real" damage */
4481                         dam = 0;
4482                         break;
4483                 }
4484
4485
4486                 /* Teleport monster (Use "dam" as "power") */
4487                 case GF_AWAY_ALL:
4488                 {
4489                         bool resists_tele = FALSE;
4490                         if (r_ptr->flagsr & RFR_RES_TELE)
4491                         {
4492                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flagsr & RFR_RES_ALL))
4493                                 {
4494                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
4495 #ifdef JP
4496                                         note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4497 #else
4498                                         note = " is unaffected!";
4499 #endif
4500
4501                                         resists_tele = TRUE;
4502                                 }
4503                                 else if (r_ptr->level > randint1(100))
4504                                 {
4505                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
4506 #ifdef JP
4507                                         note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4508 #else
4509                                         note = " resists!";
4510 #endif
4511
4512                                         resists_tele = TRUE;
4513                                 }
4514                         }
4515
4516                         if (!resists_tele)
4517                         {
4518                                 /* Obvious */
4519                                 if (seen) obvious = TRUE;
4520
4521                                 /* Prepare to teleport */
4522                                 do_dist = dam;
4523                         }
4524
4525                         /* No "real" damage */
4526                         dam = 0;
4527                         break;
4528                 }
4529
4530
4531                 /* Turn undead (Use "dam" as "power") */
4532                 case GF_TURN_UNDEAD:
4533                 {
4534                         if (r_ptr->flagsr & RFR_RES_ALL)
4535                         {
4536                                 skipped = TRUE;
4537                                 break;
4538                         }
4539                         /* Only affect undead */
4540                         if (r_ptr->flags3 & (RF3_UNDEAD))
4541                         {
4542                                 /* Obvious */
4543                                 if (seen) obvious = TRUE;
4544
4545                                 /* Learn about type */
4546                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
4547
4548                                 /* Apply some fear */
4549                                 do_fear = damroll(3, (dam / 2)) + 1;
4550
4551                                 /* Attempt a saving throw */
4552                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
4553                                 {
4554                                         /* No obvious effect */
4555 #ifdef JP
4556                                         note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4557 #else
4558                                         note = " is unaffected!";
4559 #endif
4560
4561                                         obvious = FALSE;
4562                                         do_fear = 0;
4563                                 }
4564                         }
4565
4566                         /* Others ignore */
4567                         else
4568                         {
4569                                 /* Irrelevant */
4570                                 skipped = TRUE;
4571                         }
4572
4573                         /* No "real" damage */
4574                         dam = 0;
4575                         break;
4576                 }
4577
4578
4579                 /* Turn evil (Use "dam" as "power") */
4580                 case GF_TURN_EVIL:
4581                 {
4582                         if (r_ptr->flagsr & RFR_RES_ALL)
4583                         {
4584                                 skipped = TRUE;
4585                                 break;
4586                         }
4587                         /* Only affect evil */
4588                         if (r_ptr->flags3 & (RF3_EVIL))
4589                         {
4590                                 /* Obvious */
4591                                 if (seen) obvious = TRUE;
4592
4593                                 /* Learn about type */
4594                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
4595
4596                                 /* Apply some fear */
4597                                 do_fear = damroll(3, (dam / 2)) + 1;
4598
4599                                 /* Attempt a saving throw */
4600                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
4601                                 {
4602                                         /* No obvious effect */
4603 #ifdef JP
4604                                         note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4605 #else
4606                                         note = " is unaffected!";
4607 #endif
4608
4609                                         obvious = FALSE;
4610                                         do_fear = 0;
4611                                 }
4612                         }
4613
4614                         /* Others ignore */
4615                         else
4616                         {
4617                                 /* Irrelevant */
4618                                 skipped = TRUE;
4619                         }
4620
4621                         /* No "real" damage */
4622                         dam = 0;
4623                         break;
4624                 }
4625
4626
4627                 /* Turn monster (Use "dam" as "power") */
4628                 case GF_TURN_ALL:
4629                 {
4630                         if (r_ptr->flagsr & RFR_RES_ALL)
4631                         {
4632                                 skipped = TRUE;
4633                                 break;
4634                         }
4635                         /* Obvious */
4636                         if (seen) obvious = TRUE;
4637
4638                         /* Apply some fear */
4639                         do_fear = damroll(3, (dam / 2)) + 1;
4640
4641                         /* Attempt a saving throw */
4642                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4643                             (r_ptr->flags3 & (RF3_NO_FEAR)) ||
4644                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4645                         {
4646                                 /* No obvious effect */
4647 #ifdef JP
4648 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4649 #else
4650                                 note = " is unaffected!";
4651 #endif
4652
4653                                 obvious = FALSE;
4654                                 do_fear = 0;
4655                         }
4656
4657                         /* No "real" damage */
4658                         dam = 0;
4659                         break;
4660                 }
4661
4662
4663                 /* Dispel undead */
4664                 case GF_DISP_UNDEAD:
4665                 {
4666                         if (r_ptr->flagsr & RFR_RES_ALL)
4667                         {
4668                                 skipped = TRUE;
4669                                 dam = 0;
4670                                 break;
4671                         }
4672                         /* Only affect undead */
4673                         if (r_ptr->flags3 & (RF3_UNDEAD))
4674                         {
4675                                 /* Obvious */
4676                                 if (seen) obvious = TRUE;
4677
4678                                 /* Learn about type */
4679                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
4680
4681                                 /* Message */
4682 #ifdef JP
4683                                 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4684                                 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4685 #else
4686                                 note = " shudders.";
4687                                 note_dies = " dissolves!";
4688 #endif
4689                         }
4690
4691                         /* Others ignore */
4692                         else
4693                         {
4694                                 /* Irrelevant */
4695                                 skipped = TRUE;
4696
4697                                 /* No damage */
4698                                 dam = 0;
4699                         }
4700
4701                         break;
4702                 }
4703
4704
4705                 /* Dispel evil */
4706                 case GF_DISP_EVIL:
4707                 {
4708                         if (r_ptr->flagsr & RFR_RES_ALL)
4709                         {
4710                                 skipped = TRUE;
4711                                 dam = 0;
4712                                 break;
4713                         }
4714                         /* Only affect evil */
4715                         if (r_ptr->flags3 & (RF3_EVIL))
4716                         {
4717                                 /* Obvious */
4718                                 if (seen) obvious = TRUE;
4719
4720                                 /* Learn about type */
4721                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
4722
4723                                 /* Message */
4724 #ifdef JP
4725                                 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4726                                 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4727 #else
4728                                 note = " shudders.";
4729                                 note_dies = " dissolves!";
4730 #endif
4731                         }
4732
4733                         /* Others ignore */
4734                         else
4735                         {
4736                                 /* Irrelevant */
4737                                 skipped = TRUE;
4738
4739                                 /* No damage */
4740                                 dam = 0;
4741                         }
4742
4743                         break;
4744                 }
4745
4746                 /* Dispel good */
4747                 case GF_DISP_GOOD:
4748                 {
4749                         if (r_ptr->flagsr & RFR_RES_ALL)
4750                         {
4751                                 skipped = TRUE;
4752                                 dam = 0;
4753                                 break;
4754                         }
4755                         /* Only affect good */
4756                         if (r_ptr->flags3 & (RF3_GOOD))
4757                         {
4758                                 /* Obvious */
4759                                 if (seen) obvious = TRUE;
4760
4761                                 /* Learn about type */
4762                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
4763
4764                                 /* Message */
4765 #ifdef JP
4766                                 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4767                                 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4768 #else
4769                                 note = " shudders.";
4770                                 note_dies = " dissolves!";
4771 #endif
4772                         }
4773
4774                         /* Others ignore */
4775                         else
4776                         {
4777                                 /* Irrelevant */
4778                                 skipped = TRUE;
4779
4780                                 /* No damage */
4781                                 dam = 0;
4782                         }
4783
4784                         break;
4785                 }
4786
4787                 /* Dispel living */
4788                 case GF_DISP_LIVING:
4789                 {
4790                         if (r_ptr->flagsr & RFR_RES_ALL)
4791                         {
4792                                 skipped = TRUE;
4793                                 dam = 0;
4794                                 break;
4795                         }
4796                         /* Only affect non-undead */
4797                         if (monster_living(r_ptr))
4798                         {
4799                                 /* Obvious */
4800                                 if (seen) obvious = TRUE;
4801
4802                                 /* Message */
4803 #ifdef JP
4804 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4805 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4806 #else
4807                                 note = " shudders.";
4808                                 note_dies = " dissolves!";
4809 #endif
4810
4811                         }
4812
4813                         /* Others ignore */
4814                         else
4815                         {
4816                                 /* Irrelevant */
4817                                 skipped = TRUE;
4818
4819                                 /* No damage */
4820                                 dam = 0;
4821                         }
4822
4823                         break;
4824                 }
4825
4826                 /* Dispel demons */
4827                 case GF_DISP_DEMON:
4828                 {
4829                         if (r_ptr->flagsr & RFR_RES_ALL)
4830                         {
4831                                 skipped = TRUE;
4832                                 dam = 0;
4833                                 break;
4834                         }
4835                         /* Only affect demons */
4836                         if (r_ptr->flags3 & (RF3_DEMON))
4837                         {
4838                                 /* Obvious */
4839                                 if (seen) obvious = TRUE;
4840
4841                                 /* Learn about type */
4842                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
4843
4844                                 /* Message */
4845 #ifdef JP
4846                                 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4847                                 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4848 #else
4849                                 note = " shudders.";
4850                                 note_dies = " dissolves!";
4851 #endif
4852                         }
4853
4854                         /* Others ignore */
4855                         else
4856                         {
4857                                 /* Irrelevant */
4858                                 skipped = TRUE;
4859
4860                                 /* No damage */
4861                                 dam = 0;
4862                         }
4863
4864                         break;
4865                 }
4866
4867                 /* Dispel monster */
4868                 case GF_DISP_ALL:
4869                 {
4870                         if (r_ptr->flagsr & RFR_RES_ALL)
4871                         {
4872                                 skipped = TRUE;
4873                                 dam = 0;
4874                                 break;
4875                         }
4876                         /* Obvious */
4877                         if (seen) obvious = TRUE;
4878
4879                         /* Message */
4880 #ifdef JP
4881 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4882 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4883 #else
4884                         note = " shudders.";
4885                         note_dies = " dissolves!";
4886 #endif
4887
4888
4889                         break;
4890                 }
4891
4892                 /* Drain mana */
4893                 case GF_DRAIN_MANA:
4894                 {
4895                         if (seen) obvious = TRUE;
4896
4897                         if (r_ptr->flagsr & RFR_RES_ALL)
4898                         {
4899 #ifdef JP
4900                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4901 #else
4902                                 note = " is immune.";
4903 #endif
4904                                 skipped = TRUE;
4905                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4906                                 break;
4907                         }
4908
4909                         if ((r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) || (r_ptr->flags5 & ~(RF5_NOMAGIC_MASK)) || (r_ptr->flags6 & ~(RF6_NOMAGIC_MASK)))
4910                         {
4911                                 if (who > 0)
4912                                 {
4913                                         /* Heal the monster */
4914                                         if (caster_ptr->hp < caster_ptr->maxhp)
4915                                         {
4916                                                 /* Heal */
4917                                                 caster_ptr->hp += 6 * dam;
4918                                                 if (caster_ptr->hp > caster_ptr->maxhp) caster_ptr->hp = caster_ptr->maxhp;
4919
4920                                                 /* Redraw (later) if needed */
4921                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
4922                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
4923
4924                                                 /* Special message */
4925                                                 if (see_s_msg)
4926                                                 {
4927                                                         /* Get the monster name */
4928                                                         monster_desc(killer, caster_ptr, 0);
4929 #ifdef JP
4930                                                         msg_format("%^s¤Ïµ¤Ê¬¤¬Îɤµ¤½¤¦¤À¡£", killer);
4931 #else
4932                                                         msg_format("%^s appears healthier.", killer);
4933 #endif
4934                                                 }
4935                                         }
4936                                 }
4937                                 else
4938                                 {
4939                                         /* Message */
4940 #ifdef JP
4941                                         msg_format("%s¤«¤éÀº¿À¥¨¥Í¥ë¥®¡¼¤òµÛ¤¤¤È¤Ã¤¿¡£", m_name);
4942 #else
4943                                         msg_format("You draw psychic energy from %s.", m_name);
4944 #endif
4945
4946                                         (void)hp_player(dam);
4947                                 }
4948                         }
4949                         else
4950                         {
4951 #ifdef JP
4952                                 if (see_s_msg) msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
4953 #else
4954                                 if (see_s_msg) msg_format("%s is unaffected.", m_name);
4955 #endif
4956                         }
4957                         dam = 0;
4958                         break;
4959                 }
4960
4961                 /* Mind blast */
4962                 case GF_MIND_BLAST:
4963                 {
4964                         if (seen) obvious = TRUE;
4965                         /* Message */
4966 #ifdef JP
4967                         if (!who) msg_format("%s¤ò¤¸¤Ã¤Èâˤó¤À¡£", m_name);
4968 #else
4969                         if (!who) msg_format("You gaze intently at %s.", m_name);
4970 #endif
4971
4972                         if (r_ptr->flagsr & RFR_RES_ALL)
4973                         {
4974 #ifdef JP
4975                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4976 #else
4977                                 note = " is immune.";
4978 #endif
4979                                 skipped = TRUE;
4980                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
4981                                 break;
4982                         }
4983
4984                         /* Attempt a saving throw */
4985                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
4986                                  (r_ptr->flags3 & RF3_NO_CONF) ||
4987                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
4988                         {
4989                                 /* Memorize a flag */
4990                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4991                                 {
4992                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
4993                                 }
4994 #ifdef JP
4995                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
4996 #else
4997                                 note = "is unaffected!";
4998 #endif
4999                                 dam = 0;
5000                         }
5001                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
5002                         {
5003                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
5004 #ifdef JP
5005                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5006 #else
5007                                 note = " is immune!";
5008 #endif
5009                                 dam = 0;
5010                         }
5011                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
5012                         {
5013                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
5014 #ifdef JP
5015                                 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡£";
5016 #else
5017                                 note = " resists.";
5018 #endif
5019                                 dam /= 3;
5020                         }
5021                         else
5022                         {
5023 #ifdef JP
5024                                 note = "¤ÏÀº¿À¹¶·â¤ò¿©¤é¤Ã¤¿¡£";
5025                                 note_dies = "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±³Ì¤È¤Ê¤Ã¤¿¡£";
5026 #else
5027                                 note = " is blasted by psionic energy.";
5028                                 note_dies = " collapses, a mindless husk.";
5029 #endif
5030
5031                                 if (who > 0) do_conf = randint0(4) + 4;
5032                                 else do_conf = randint0(8) + 8;
5033                         }
5034                         break;
5035                 }
5036
5037                 /* Brain smash */
5038                 case GF_BRAIN_SMASH:
5039                 {
5040                         if (seen) obvious = TRUE;
5041                         /* Message */
5042 #ifdef JP
5043                         if (!who) msg_format("%s¤ò¤¸¤Ã¤Èâˤó¤À¡£", m_name);
5044 #else
5045                         if (!who) msg_format("You gaze intently at %s.", m_name);
5046 #endif
5047
5048                         if (r_ptr->flagsr & RFR_RES_ALL)
5049                         {
5050 #ifdef JP
5051                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5052 #else
5053                                 note = " is immune.";
5054 #endif
5055                                 skipped = TRUE;
5056                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5057                                 break;
5058                         }
5059
5060                         /* Attempt a saving throw */
5061                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
5062                                  (r_ptr->flags3 & RF3_NO_CONF) ||
5063                                  (r_ptr->level > randint1((caster_lev - 10) < 1 ? 1 : (caster_lev - 10)) + 10))
5064                         {
5065                                 /* Memorize a flag */
5066                                 if (r_ptr->flags3 & (RF3_NO_CONF))
5067                                 {
5068                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_CONF);
5069                                 }
5070 #ifdef JP
5071                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5072 #else
5073                                 note = "is unaffected!";
5074 #endif
5075                                 dam = 0;
5076                         }
5077                         else if (r_ptr->flags2 & RF2_EMPTY_MIND)
5078                         {
5079                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
5080 #ifdef JP
5081                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5082 #else
5083                                 note = " is immune!";
5084 #endif
5085                                 dam = 0;
5086                         }
5087                         else if (r_ptr->flags2 & RF2_WEIRD_MIND)
5088                         {
5089                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
5090 #ifdef JP
5091                                 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡£";
5092 #else
5093                                 note = " resists.";
5094 #endif
5095                                 dam /= 3;
5096                         }
5097                         else
5098                         {
5099 #ifdef JP
5100                                 note = "¤ÏÀº¿À¹¶·â¤ò¿©¤é¤Ã¤¿¡£";
5101                                 note_dies = "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±³Ì¤È¤Ê¤Ã¤¿¡£";
5102 #else
5103                                 note = " is blasted by psionic energy.";
5104                                 note_dies = " collapses, a mindless husk.";
5105 #endif
5106
5107                                 if (who > 0)
5108                                 {
5109                                         do_conf = randint0(4) + 4;
5110                                         do_stun = randint0(4) + 4;
5111                                 }
5112                                 else
5113                                 {
5114                                         do_conf = randint0(8) + 8;
5115                                         do_stun = randint0(8) + 8;
5116                                 }
5117                                 m_ptr->slow = MIN(200, m_ptr->slow + 10);
5118                                 if (c_ptr->m_idx == p_ptr->riding)
5119                                         p_ptr->update |= (PU_BONUS);
5120                         }
5121                         break;
5122                 }
5123
5124                 /* CAUSE_1 */
5125                 case GF_CAUSE_1:
5126                 {
5127                         if (seen) obvious = TRUE;
5128                         /* Message */
5129 #ifdef JP
5130                         if (!who) msg_format("%s¤ò»Øº¹¤·¤Æ¼ö¤¤¤ò¤«¤±¤¿¡£", m_name);
5131 #else
5132                         if (!who) msg_format("You point at %s and curses.", m_name);
5133 #endif
5134
5135                         if (r_ptr->flagsr & RFR_RES_ALL)
5136                         {
5137 #ifdef JP
5138                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5139 #else
5140                                 note = " is immune.";
5141 #endif
5142                                 skipped = TRUE;
5143                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5144                                 break;
5145                         }
5146
5147                         /* Attempt a saving throw */
5148                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
5149                         {
5150 #ifdef JP
5151                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5152 #else
5153                                 note = "is unaffected!";
5154 #endif
5155                                 dam = 0;
5156                         }
5157                         break;
5158                 }
5159
5160                 /* CAUSE_2 */
5161                 case GF_CAUSE_2:
5162                 {
5163                         if (seen) obvious = TRUE;
5164                         /* Message */
5165 #ifdef JP
5166                         if (!who) msg_format("%s¤ò»Øº¹¤·¤Æ¶²¤í¤·¤²¤Ë¼ö¤¤¤ò¤«¤±¤¿¡£", m_name);
5167 #else
5168                         if (!who) msg_format("You point at %s and curses horribly.", m_name);
5169 #endif
5170
5171                         if (r_ptr->flagsr & RFR_RES_ALL)
5172                         {
5173 #ifdef JP
5174                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5175 #else
5176                                 note = " is immune.";
5177 #endif
5178                                 skipped = TRUE;
5179                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5180                                 break;
5181                         }
5182
5183                         /* Attempt a saving throw */
5184                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
5185                         {
5186 #ifdef JP
5187                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5188 #else
5189                                 note = "is unaffected!";
5190 #endif
5191                                 dam = 0;
5192                         }
5193                         break;
5194                 }
5195
5196                 /* CAUSE_3 */
5197                 case GF_CAUSE_3:
5198                 {
5199                         if (seen) obvious = TRUE;
5200                         /* Message */
5201 #ifdef JP
5202                         if (!who) msg_format("%s¤ò»Øº¹¤·¡¢¶²¤í¤·¤²¤Ë¼öʸ¤ò¾§¤¨¤¿¡ª", m_name);
5203 #else
5204                         if (!who) msg_format("You point at %s, incanting terribly!", m_name);
5205 #endif
5206
5207                         if (r_ptr->flagsr & RFR_RES_ALL)
5208                         {
5209 #ifdef JP
5210                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5211 #else
5212                                 note = " is immune.";
5213 #endif
5214                                 skipped = TRUE;
5215                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5216                                 break;
5217                         }
5218
5219                         /* Attempt a saving throw */
5220                         if (randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35))
5221                         {
5222 #ifdef JP
5223                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5224 #else
5225                                 note = "is unaffected!";
5226 #endif
5227                                 dam = 0;
5228                         }
5229                         break;
5230                 }
5231
5232                 /* CAUSE_4 */
5233                 case GF_CAUSE_4:
5234                 {
5235                         if (seen) obvious = TRUE;
5236                         /* Message */
5237 #ifdef JP
5238                         if (!who) msg_format("%s¤ÎÈ빦¤òÆͤ¤¤Æ¡¢¡Ö¤ªÁ°¤Ï´û¤Ë»à¤ó¤Ç¤¤¤ë¡×¤È¶«¤ó¤À¡£", m_name);
5239 #else
5240                         if (!who) msg_format("You point at %s, screaming the word, 'DIE!'.", m_name);
5241 #endif
5242
5243                         if (r_ptr->flagsr & RFR_RES_ALL)
5244                         {
5245 #ifdef JP
5246                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5247 #else
5248                                 note = " is immune.";
5249 #endif
5250                                 skipped = TRUE;
5251                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5252                                 break;
5253                         }
5254
5255                         /* Attempt a saving throw */
5256                         if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (caster_ptr->r_idx != MON_KENSHIROU)))
5257                         {
5258 #ifdef JP
5259                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5260 #else
5261                                 note = "is unaffected!";
5262 #endif
5263                                 dam = 0;
5264                         }
5265                         break;
5266                 }
5267
5268                 /* HAND_DOOM */
5269                 case GF_HAND_DOOM:
5270                 {
5271                         if (seen) obvious = TRUE;
5272
5273                         if (r_ptr->flagsr & RFR_RES_ALL)
5274                         {
5275 #ifdef JP
5276                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5277 #else
5278                                 note = " is immune.";
5279 #endif
5280                                 skipped = TRUE;
5281                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5282                                 break;
5283                         }
5284
5285                         if (r_ptr->flags1 & RF1_UNIQUE)
5286                         {
5287 #ifdef JP
5288                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5289 #else
5290                                 note = "is unaffected!";
5291 #endif
5292                                 dam = 0;
5293                         }
5294                         else
5295                         {
5296                                 if ((who > 0) ? ((caster_lev + randint1(dam)) > (r_ptr->level + 10 + randint1(20))) :
5297                                    (((caster_lev / 2) + randint1(dam)) > (r_ptr->level + randint1(200))))
5298                                 {
5299                                         dam = ((40 + randint1(20)) * m_ptr->hp) / 100;
5300
5301                                         if (m_ptr->hp < dam) dam = m_ptr->hp - 1;
5302                                 }
5303                                 else
5304                                 {
5305 #ifdef JP
5306                                         note = "¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª";
5307 #else
5308                                         note = "resists!";
5309 #endif
5310                                         dam = 0;
5311                                 }
5312                         }
5313                         break;
5314                 }
5315
5316                 /* Capture monster */
5317                 case GF_CAPTURE:
5318                 {
5319                         int nokori_hp;
5320                         if ((p_ptr->inside_quest && (quest[p_ptr->inside_quest].type == QUEST_TYPE_KILL_ALL) && !is_pet(m_ptr)) ||
5321                             (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)
5322                         {
5323 #ifdef JP
5324 msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",m_name);
5325 #else
5326                                 msg_format("%^s is unaffected.", m_name);
5327 #endif
5328                                 skipped = TRUE;
5329                                 break;
5330                         }
5331
5332                         if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp*4L;
5333                         else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(r_ptr))
5334                                 nokori_hp = m_ptr->maxhp * 3 / 10;
5335                         else
5336                                 nokori_hp = m_ptr->maxhp * 3 / 20;
5337
5338                         if (m_ptr->hp >= nokori_hp)
5339                         {
5340 #ifdef JP
5341 msg_format("¤â¤Ã¤È¼å¤é¤»¤Ê¤¤¤È¡£");
5342 #else
5343                                 msg_format("You need to weaken %s more.", m_name);
5344 #endif
5345                                 skipped = TRUE;
5346                         }
5347                         else if (m_ptr->hp < randint0(nokori_hp))
5348                         {
5349                                 if (m_ptr->mflag2 & MFLAG2_CHAMELEON) choose_new_monster(c_ptr->m_idx, FALSE, MON_CHAMELEON);
5350 #ifdef JP
5351 msg_format("%s¤òÊᤨ¤¿¡ª",m_name);
5352 #else
5353                                 msg_format("You capture %^s!", m_name);
5354 #endif
5355                                 cap_mon = m_list[c_ptr->m_idx].r_idx;
5356                                 cap_mspeed = m_list[c_ptr->m_idx].mspeed;
5357                                 cap_hp = m_list[c_ptr->m_idx].hp;
5358                                 cap_maxhp = m_list[c_ptr->m_idx].max_maxhp;
5359                                 if (m_list[c_ptr->m_idx].nickname)
5360                                         cap_nickname = quark_add(quark_str(m_list[c_ptr->m_idx].nickname));
5361                                 else
5362                                         cap_nickname = 0;
5363                                 if (c_ptr->m_idx == p_ptr->riding)
5364                                 {
5365                                         if (rakuba(-1, FALSE))
5366                                         {
5367 #ifdef JP
5368 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
5369 #else
5370                                                 msg_format("You have fallen from %s.", m_name);
5371 #endif
5372                                         }
5373                                 }
5374
5375                                 delete_monster_idx(c_ptr->m_idx);
5376
5377                                 return (TRUE);
5378                         }
5379                         else
5380                         {
5381 #ifdef JP
5382 msg_format("¤¦¤Þ¤¯Êá¤Þ¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡£");
5383 #else
5384                                 msg_format("You failed to capture %s.", m_name);
5385 #endif
5386                                 skipped = TRUE;
5387                         }
5388                         break;
5389                 }
5390
5391                 /* Attack (Use "dam" as attack type) */
5392                 case GF_ATTACK:
5393                 {
5394                         /* Return this monster's death */
5395                         return py_attack(y, x, dam);
5396                 }
5397
5398                 /* Sleep (Use "dam" as "power") */
5399                 case GF_ENGETSU:
5400                 {
5401                         int effect = 0;
5402                         bool done = TRUE;
5403
5404                         if (seen) obvious = TRUE;
5405
5406                         if (r_ptr->flagsr & RFR_RES_ALL)
5407                         {
5408 #ifdef JP
5409                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5410 #else
5411                                 note = " is immune.";
5412 #endif
5413                                 dam = 0;
5414                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5415                                 break;
5416                         }
5417                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
5418                         {
5419 #ifdef JP
5420 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5421 #else
5422                                 note = " is immune!";
5423 #endif
5424                                 dam = 0;
5425                                 skipped = TRUE;
5426                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
5427                                 break;
5428                         }
5429                         if (m_ptr->csleep)
5430                         {
5431 #ifdef JP
5432 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5433 #else
5434                                 note = " is immune!";
5435 #endif
5436                                 dam = 0;
5437                                 skipped = TRUE;
5438                                 break;
5439                         }
5440
5441                         if (one_in_(5)) effect = 1;
5442                         else if (one_in_(4)) effect = 2;
5443                         else if (one_in_(3)) effect = 3;
5444                         else done = FALSE;
5445
5446                         if (effect == 1)
5447                         {
5448                                 /* Powerful monsters can resist */
5449                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5450                                     (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
5451                                 {
5452 #ifdef JP
5453 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5454 #else
5455                                         note = " is unaffected!";
5456 #endif
5457
5458                                         obvious = FALSE;
5459                                 }
5460
5461                                 /* Normal monsters slow down */
5462                                 else
5463                                 {
5464                                         if (!m_ptr->slow)
5465                                         {
5466 #ifdef JP
5467 note = "¤ÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤¿¡£";
5468 #else
5469                                                 note = " starts moving slower.";
5470 #endif
5471                                         }
5472                                         m_ptr->slow = MIN(200, m_ptr->slow + 50);
5473
5474                                         if (c_ptr->m_idx == p_ptr->riding)
5475                                                 p_ptr->update |= (PU_BONUS);
5476                                 }
5477                         }
5478
5479                         else if (effect == 2)
5480                         {
5481                                 do_stun = damroll((p_ptr->lev / 10) + 3 , (dam)) + 1;
5482
5483                                 /* Attempt a saving throw */
5484                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
5485                                     (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
5486                                 {
5487                                         /* Resist */
5488                                         do_stun = 0;
5489
5490                                         /* No obvious effect */
5491 #ifdef JP
5492 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5493 #else
5494                                         note = " is unaffected!";
5495 #endif
5496
5497                                         obvious = FALSE;
5498                                 }
5499                         }
5500
5501                         else if (effect == 3)
5502                         {
5503                                 /* Attempt a saving throw */
5504                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5505                                     (r_ptr->flags3 & RF3_NO_SLEEP) ||
5506                                     (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
5507                                 {
5508                                         /* Memorize a flag */
5509                                         if (r_ptr->flags3 & RF3_NO_SLEEP)
5510                                         {
5511                                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
5512                                         }
5513
5514                                         /* No obvious effect */
5515 #ifdef JP
5516 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5517 #else
5518                                         note = " is unaffected!";
5519 #endif
5520
5521                                         obvious = FALSE;
5522                                 }
5523                                 else
5524                                 {
5525                                         /* Go to sleep (much) later */
5526 #ifdef JP
5527 note = "¤Ï̲¤ê¹þ¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
5528 #else
5529                                         note = " falls asleep!";
5530 #endif
5531
5532                                         do_sleep = 500;
5533                                 }
5534                         }
5535
5536                         if (!done)
5537                         {
5538 #ifdef JP
5539 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5540 #else
5541                                 note = " is immune!";
5542 #endif
5543                         }
5544
5545                         /* No "real" damage */
5546                         dam = 0;
5547                         break;
5548                 }
5549
5550                 /* GENOCIDE */
5551                 case GF_GENOCIDE:
5552                 {
5553                         bool angry = FALSE;
5554                         if (seen) obvious = TRUE;
5555
5556                         if (r_ptr->flagsr & RFR_RES_ALL)
5557                         {
5558 #ifdef JP
5559                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5560 #else
5561                                 note = " is immune.";
5562 #endif
5563                                 skipped = TRUE;
5564                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5565                                 break;
5566                         }
5567
5568                         if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (c_ptr->m_idx == p_ptr->riding)) || p_ptr->inside_arena || p_ptr->inside_quest)
5569                         {
5570                                 dam = 0;
5571                                 angry = TRUE;
5572                         }
5573                         else
5574                         {
5575                                 if ((r_ptr->level > randint0(dam)) || (m_ptr->mflag2 & MFLAG2_NOGENO))
5576                                 {
5577                                         dam = 0;
5578                                         angry = TRUE;
5579                                 }
5580                                 else
5581                                 {
5582                                         delete_monster_idx(c_ptr->m_idx);
5583 #ifdef JP
5584                                         msg_format("%s¤Ï¾ÃÌǤ·¤¿¡ª",m_name);
5585 #else
5586                                         msg_format("%^s disappered!",m_name);
5587 #endif
5588
5589 #ifdef JP
5590                                         take_hit(DAMAGE_GENO, randint1((r_ptr->level+1)/2), "¥â¥ó¥¹¥¿¡¼¾ÃÌǤμöʸ¤ò¾§¤¨¤¿ÈèÏ«", -1);
5591 #else
5592                                         take_hit(DAMAGE_GENO, randint1((r_ptr->level+1)/2), "the strain of casting Genocide One", -1);
5593 #endif
5594                                         dam = 0;
5595
5596                                         chg_virtue(V_VITALITY, -1);
5597
5598                                         skipped = TRUE;
5599
5600                                         /* Redraw */
5601                                         p_ptr->redraw |= (PR_HP);
5602
5603                                         /* Window stuff */
5604                                         p_ptr->window |= (PW_PLAYER);
5605                                         return TRUE;
5606                                 }
5607                         }
5608                         if (angry)
5609                         {
5610 #ifdef JP
5611 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5612 #else
5613                                 note = "is unaffected!";
5614 #endif
5615                                 get_angry = TRUE;
5616                                 if (one_in_(13)) m_ptr->mflag2 |= MFLAG2_NOGENO;
5617                         }
5618                         break;
5619                 }
5620
5621                 case GF_PHOTO:
5622                 {
5623 #ifdef JP
5624                         if (!who) msg_format("%s¤ò¼Ì¿¿¤Ë»£¤Ã¤¿¡£", m_name);
5625 #else
5626                         if (!who) msg_format("You take a photograph of %s.", m_name);
5627 #endif
5628                         /* Hurt by light */
5629                         if (r_ptr->flags3 & (RF3_HURT_LITE))
5630                         {
5631                                 /* Obvious effect */
5632                                 if (seen) obvious = TRUE;
5633
5634                                 /* Memorize the effects */
5635                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_HURT_LITE);
5636
5637                                 /* Special effect */
5638 #ifdef JP
5639                                 note = "¤Ï¸÷¤Ë¿È¤ò¤¹¤¯¤á¤¿¡ª";
5640                                 note_dies = "¤Ï¸÷¤ò¼õ¤±¤Æ¤·¤Ü¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
5641 #else
5642                                 note = " cringes from the light!";
5643                                 note_dies = " shrivels away in the light!";
5644 #endif
5645                         }
5646
5647                         /* Normally no damage */
5648                         else
5649                         {
5650                                 /* No damage */
5651                                 dam = 0;
5652                         }
5653
5654                         photo = m_ptr->r_idx;
5655
5656                         break;
5657                 }
5658
5659
5660                 /* blood curse */
5661                 case GF_BLOOD_CURSE:
5662                 {
5663                         if (seen) obvious = TRUE;
5664
5665                         if (r_ptr->flagsr & RFR_RES_ALL)
5666                         {
5667 #ifdef JP
5668                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5669 #else
5670                                 note = " is immune.";
5671 #endif
5672                                 dam = 0;
5673                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5674                                 break;
5675                         }
5676                         break;
5677                 }
5678
5679                 case GF_CRUSADE:
5680                 {
5681                         bool success = FALSE;
5682                         if (seen) obvious = TRUE;
5683
5684                         if ((r_ptr->flags3 & (RF3_GOOD)) && !p_ptr->inside_arena)
5685                         {
5686                                 if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 50;
5687                                 if (dam < 1) dam = 1;
5688
5689                                 /* No need to tame your pet */
5690                                 if (is_pet(m_ptr))
5691                                 {
5692 #ifdef JP
5693                                         note = "¤ÎÆ°¤­¤¬Â®¤¯¤Ê¤Ã¤¿¡£";
5694 #else
5695                                         note = " starts moving faster.";
5696 #endif
5697
5698                                         m_ptr->fast = MIN(200, m_ptr->fast + 100);
5699                                         success = TRUE;
5700                                 }
5701
5702                                 /* Attempt a saving throw */
5703                                 else if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
5704                                     (r_ptr->flags1 & (RF1_UNIQUE)) ||
5705                                     (m_ptr->mflag2 & MFLAG2_NOPET) ||
5706                                     (p_ptr->cursed & TRC_AGGRAVATE) ||
5707                                          ((r_ptr->level+10) > randint1(dam)))
5708                                 {
5709                                         /* Resist */
5710                                         if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
5711                                 }
5712                                 else
5713                                 {
5714 #ifdef JP
5715 note = "¤ò»ÙÇÛ¤·¤¿¡£";
5716 #else
5717                                         note = " is tamed!";
5718 #endif
5719
5720                                         set_pet(m_ptr);
5721                                         m_ptr->fast = MIN(200, m_ptr->fast + 100);
5722
5723                                         /* Learn about type */
5724                                         if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
5725                                         success = TRUE;
5726                                 }
5727                         }
5728
5729                         if (!success)
5730                         {
5731                                 if (!(r_ptr->flags3 & RF3_NO_FEAR))
5732                                 {
5733                                         do_fear = randint1(90)+10;
5734                                 }
5735                                 else if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_NO_FEAR);
5736                         }
5737
5738                         /* No "real" damage */
5739                         dam = 0;
5740                         break;
5741                 }
5742
5743                 case GF_WOUNDS:
5744                 {
5745                         if (seen) obvious = TRUE;
5746
5747                         if (r_ptr->flagsr & RFR_RES_ALL)
5748                         {
5749 #ifdef JP
5750                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5751 #else
5752                                 note = " is immune.";
5753 #endif
5754                                 skipped = TRUE;
5755                                 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= (RFR_RES_ALL);
5756                                 break;
5757                         }
5758
5759                         /* Attempt a saving throw */
5760                         if (randint0(100 + dam) < (r_ptr->level + 50))
5761                         {
5762
5763 #ifdef JP
5764 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5765 #else
5766                                 note = "is unaffected!";
5767 #endif
5768                                 dam = 0;
5769                         }
5770                         break;
5771                 }
5772
5773                 /* Default */
5774                 default:
5775                 {
5776                         /* Irrelevant */
5777                         skipped = TRUE;
5778
5779                         /* No damage */
5780                         dam = 0;
5781
5782                         break;
5783                 }
5784         }
5785
5786
5787         /* Absolutely no effect */
5788         if (skipped) return (FALSE);
5789
5790         /* "Unique" monsters cannot be polymorphed */
5791         if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
5792
5793         /* Quest monsters cannot be polymorphed */
5794         if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
5795
5796         if (p_ptr->riding && (c_ptr->m_idx == p_ptr->riding)) do_poly = FALSE;
5797
5798         /* "Unique" and "quest" monsters can only be "killed" by the player. */
5799         if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle)
5800         {
5801                 if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
5802         }
5803
5804         if (!who && slept)
5805         {
5806                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
5807                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
5808         }
5809
5810         /* Modify the damage */
5811         tmp = dam;
5812         dam = mon_damage_mod(m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
5813 #ifdef JP
5814         if ((tmp > 0) && (dam == 0)) note = "¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£";
5815 #else
5816         if ((tmp > 0) && (dam == 0)) note = " is unharmed.";
5817 #endif
5818
5819         /* Check for death */
5820         if (dam > m_ptr->hp)
5821         {
5822                 /* Extract method of death */
5823                 note = note_dies;
5824         }
5825         else
5826         {
5827                 /* Sound and Impact resisters never stun */
5828                 if (do_stun &&
5829                     !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
5830                     !(r_ptr->flags3 & RF3_NO_STUN))
5831                 {
5832                         /* Obvious */
5833                         if (seen) obvious = TRUE;
5834
5835                         /* Get stunned */
5836                         if (m_ptr->stunned)
5837                         {
5838 #ifdef JP
5839                                 note = "¤Ï¤Ò¤É¤¯¤â¤¦¤í¤¦¤È¤·¤¿¡£";
5840 #else
5841                                 note = " is more dazed.";
5842 #endif
5843
5844                                 tmp = m_ptr->stunned + (do_stun / 2);
5845                         }
5846                         else
5847                         {
5848 #ifdef JP
5849                                 note = "¤Ï¤â¤¦¤í¤¦¤È¤·¤¿¡£";
5850 #else
5851                                 note = " is dazed.";
5852 #endif
5853
5854                                 tmp = do_stun;
5855                         }
5856
5857                         /* Apply stun */
5858                         m_ptr->stunned = (tmp < 200) ? tmp : 200;
5859
5860                         /* Get angry */
5861                         get_angry = TRUE;
5862                 }
5863
5864                 /* Confusion and Chaos resisters (and sleepers) never confuse */
5865                 if (do_conf &&
5866                          !(r_ptr->flags3 & RF3_NO_CONF) &&
5867                          !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
5868                 {
5869                         /* Obvious */
5870                         if (seen) obvious = TRUE;
5871
5872                         /* Already partially confused */
5873                         if (m_ptr->confused)
5874                         {
5875 #ifdef JP
5876                                 note = "¤Ï¤µ¤é¤Ëº®Í𤷤¿¤è¤¦¤À¡£";
5877 #else
5878                                 note = " looks more confused.";
5879 #endif
5880
5881                                 tmp = m_ptr->confused + (do_conf / 2);
5882                         }
5883
5884                         /* Was not confused */
5885                         else
5886                         {
5887 #ifdef JP
5888                                 note = "¤Ïº®Í𤷤¿¤è¤¦¤À¡£";
5889 #else
5890                                 note = " looks confused.";
5891 #endif
5892
5893                                 tmp = do_conf;
5894                         }
5895
5896                         /* Apply confusion */
5897                         m_ptr->confused = (tmp < 200) ? tmp : 200;
5898
5899                         /* Get angry */
5900                         get_angry = TRUE;
5901                 }
5902
5903                 if (do_time)
5904                 {
5905                         /* Obvious */
5906                         if (seen) obvious = TRUE;
5907
5908                         if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp - 1;
5909
5910                         if (do_time)
5911                         {
5912 #ifdef JP
5913                                 note = "¤Ï¼å¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£";
5914 #else
5915                                 note = " seems weakened.";
5916 #endif
5917                                 m_ptr->maxhp -= do_time;
5918                                 if ((m_ptr->hp - dam) > m_ptr->maxhp) dam = m_ptr->hp - m_ptr->maxhp;
5919                         }
5920                         get_angry = TRUE;
5921                 }
5922
5923                 /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
5924                 if (do_poly && (randint1(90) > r_ptr->level))
5925                 {
5926                         if (polymorph_monster(y, x))
5927                         {
5928                                 /* Obvious */
5929                                 if (seen) obvious = TRUE;
5930
5931                                 /* Monster polymorphs */
5932 #ifdef JP
5933                                 note = "¤¬ÊѿȤ·¤¿¡ª";
5934 #else
5935                                 note = " changes!";
5936 #endif
5937
5938                                 /* Turn off the damage */
5939                                 dam = 0;
5940
5941                                 /* Hack -- Get new monster */
5942                                 m_ptr = &m_list[c_ptr->m_idx];
5943
5944                                 /* Hack -- Get new race */
5945                                 r_ptr = &r_info[m_ptr->r_idx];
5946                         }
5947                         else
5948                         {
5949                                 /* No polymorph */
5950 #ifdef JP
5951                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5952 #else
5953                                 note = " is unaffected!";
5954 #endif
5955                         }
5956                 }
5957
5958                 /* Handle "teleport" */
5959                 if (do_dist)
5960                 {
5961                         /* Obvious */
5962                         if (seen) obvious = TRUE;
5963
5964                         /* Message */
5965 #ifdef JP
5966                         note = "¤¬¾Ã¤¨µî¤Ã¤¿¡ª";
5967 #else
5968                         note = " disappears!";
5969 #endif
5970
5971                         if (!who) chg_virtue(V_VALOUR, -1);
5972
5973                         /* Teleport */
5974                         teleport_away(c_ptr->m_idx, do_dist, (bool)(!who), TRUE);
5975
5976                         /* Hack -- get new location */
5977                         y = m_ptr->fy;
5978                         x = m_ptr->fx;
5979
5980                         /* Hack -- get new grid */
5981                         c_ptr = &cave[y][x];
5982                 }
5983
5984                 /* Fear */
5985                 if (do_fear)
5986                 {
5987                         /* Increase fear */
5988                         tmp = m_ptr->monfear + do_fear;
5989
5990                         /* Set fear */
5991                         m_ptr->monfear = (tmp < 200) ? tmp : 200;
5992
5993                         /* Get angry */
5994                         get_angry = TRUE;
5995                 }
5996         }
5997
5998         if (typ == GF_DRAIN_MANA)
5999         {
6000                 /* Drain mana does nothing */
6001         }
6002
6003         /* If another monster did the damage, hurt the monster by hand */
6004         else if (who)
6005         {
6006                 /* Redraw (later) if needed */
6007                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
6008                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
6009
6010                 /* Wake the monster up */
6011                 m_ptr->csleep = 0;
6012
6013                 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
6014
6015                 /* Hurt the monster */
6016                 m_ptr->hp -= dam;
6017
6018                 /* Dead monster */
6019                 if (m_ptr->hp < 0)
6020                 {
6021                         bool sad = FALSE;
6022
6023                         if (is_pet(m_ptr) && !(m_ptr->ml))
6024                                 sad = TRUE;
6025
6026                         /* Give detailed messages if destroyed */
6027                         if (known && note)
6028                         {
6029                                 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
6030                                 if (see_s_msg)
6031                                 {
6032                                         msg_format("%^s%s", m_name, note);
6033                                 }
6034                                 else
6035                                 {
6036                                         mon_fight = TRUE;
6037                                 }
6038                         }
6039
6040                         monster_gain_exp(who, m_ptr->r_idx);
6041
6042                         /* Generate treasure, etc */
6043                         monster_death(c_ptr->m_idx, FALSE);
6044
6045                         /* Delete the monster */
6046                         delete_monster_idx(c_ptr->m_idx);
6047
6048                         if (sad)
6049                         {
6050 #ifdef JP
6051 msg_print("¾¯¤·Èᤷ¤¤µ¤Ê¬¤¬¤·¤¿¡£");
6052 #else
6053                                 msg_print("You feel sad for a moment.");
6054 #endif
6055
6056                         }
6057                 }
6058
6059                 /* Damaged monster */
6060                 else
6061                 {
6062                         /* Give detailed messages if visible or destroyed */
6063                         if (note && seen_msg) msg_format("%^s%s", m_name, note);
6064
6065                         /* Hack -- Pain message */
6066                         else if (see_s_msg)
6067                         {
6068                                 message_pain(c_ptr->m_idx, dam);
6069                         }
6070                         else
6071                         {
6072                                 mon_fight = TRUE;
6073                         }
6074
6075                         /* Hack -- handle sleep */
6076                         if (do_sleep) m_ptr->csleep = do_sleep;
6077                 }
6078         }
6079
6080         else if (heal_leper)
6081         {
6082 #ifdef JP
6083                 if (seen_msg) msg_print("ÉÔ·é¤ÊÉ¿ͤÏɵ¤¤¬¼£¤Ã¤¿¡ª");
6084 #else
6085                 if (seen_msg) msg_print("The Mangy looking leper is healed!");
6086 #endif
6087
6088                 delete_monster_idx(c_ptr->m_idx);
6089         }
6090
6091         /* If the player did it, give him experience, check fear */
6092         else
6093         {
6094                 bool fear = FALSE;
6095
6096                 /* Hurt the monster, check for fear and death */
6097                 if (mon_take_hit(c_ptr->m_idx, dam, &fear, note_dies))
6098                 {
6099                         /* Dead monster */
6100                 }
6101
6102                 /* Damaged monster */
6103                 else
6104                 {
6105                         /* HACK - anger the monster before showing the sleep message */
6106                         if (do_sleep) anger_monster(m_ptr);
6107
6108                         /* Give detailed messages if visible or destroyed */
6109                         if (note && seen_msg)
6110 #ifdef JP
6111                                 msg_format("%s%s", m_name, note);
6112 #else
6113                                 msg_format("%^s%s", m_name, note);
6114 #endif
6115
6116
6117                         /* Hack -- Pain message */
6118                         else if (known && (dam || !do_fear))
6119                         {
6120                                 message_pain(c_ptr->m_idx, dam);
6121                         }
6122
6123                         /* Anger monsters */
6124                         if (((dam > 0) || get_angry) && !do_sleep)
6125                                 anger_monster(m_ptr);
6126
6127                         /* Take note */
6128                         if ((fear || do_fear) && seen)
6129                         {
6130                                 /* Sound */
6131                                 sound(SOUND_FLEE);
6132
6133                                 /* Message */
6134 #ifdef JP
6135                                 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
6136 #else
6137                                 msg_format("%^s flees in terror!", m_name);
6138 #endif
6139                         }
6140
6141                         /* Hack -- handle sleep */
6142                         if (do_sleep) m_ptr->csleep = do_sleep;
6143                 }
6144         }
6145
6146         if ((typ == GF_BLOOD_CURSE) && one_in_(4))
6147         {
6148                 int curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
6149                 int count = 0;
6150                 do
6151                 {
6152                         switch (randint1(28))
6153                         {
6154                         case 1: case 2:
6155                                 if (!count)
6156                                 {
6157 #ifdef JP
6158 msg_print("ÃÏÌ̤¬Íɤ줿...");
6159 #else
6160                                         msg_print("The ground trembles...");
6161 #endif
6162
6163                                         earthquake(ty, tx, 4 + randint0(4));
6164                                         if (!one_in_(6)) break;
6165                                 }
6166                         case 3: case 4: case 5: case 6:
6167                                 if (!count)
6168                                 {
6169                                         int dam = damroll(10, 10);
6170 #ifdef JP
6171 msg_print("½ã¿è¤ÊËâÎϤμ¡¸µ¤Ø¤ÎÈ⤬³«¤¤¤¿¡ª");
6172 #else
6173                                         msg_print("A portal opens to a plane of raw mana!");
6174 #endif
6175
6176                                         project(0, 8, ty,tx, dam, GF_MANA, curse_flg, -1);
6177                                         if (!one_in_(6)) break;
6178                                 }
6179                         case 7: case 8:
6180                                 if (!count)
6181                                 {
6182 #ifdef JP
6183 msg_print("¶õ´Ö¤¬ÏĤó¤À¡ª");
6184 #else
6185                                         msg_print("Space warps about you!");
6186 #endif
6187
6188                                         if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), FALSE, TRUE);
6189                                         if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
6190                                         if (!one_in_(6)) break;
6191                                 }
6192                         case 9: case 10: case 11:
6193 #ifdef JP
6194 msg_print("¥¨¥Í¥ë¥®¡¼¤Î¤¦¤Í¤ê¤ò´¶¤¸¤¿¡ª");
6195 #else
6196                                 msg_print("You feel a surge of energy!");
6197 #endif
6198
6199                                 project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
6200                                 if (!one_in_(6)) break;
6201                         case 12: case 13: case 14: case 15: case 16:
6202                                 aggravate_monsters(0);
6203                                 if (!one_in_(6)) break;
6204                         case 17: case 18:
6205                                 count += activate_hi_summon(ty, tx, TRUE);
6206                                 if (!one_in_(6)) break;
6207                         case 19: case 20: case 21: case 22:
6208                         {
6209                                 bool pet = !one_in_(3);
6210                                 u32b mode = PM_ALLOW_GROUP;
6211
6212                                 if (pet) mode |= PM_FORCE_PET;
6213                                 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
6214
6215                                 count += summon_specific((pet ? -1 : 0), py, px, (pet ? p_ptr->lev*2/3+randint1(p_ptr->lev/2) : dun_level), 0, mode);
6216                                 if (!one_in_(6)) break;
6217                         }
6218                         case 23: case 24: case 25:
6219                                 if (p_ptr->hold_life && (randint0(100) < 75)) break;
6220 #ifdef JP
6221 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
6222 #else
6223                                 msg_print("You feel your life draining away...");
6224 #endif
6225
6226                                 if (p_ptr->hold_life) lose_exp(p_ptr->exp / 160);
6227                                 else lose_exp(p_ptr->exp / 16);
6228                                 if (!one_in_(6)) break;
6229                         case 26: case 27: case 28:
6230                         {
6231                                 int i = 0;
6232                                 if (one_in_(13))
6233                                 {
6234                                         while (i < 6)
6235                                         {
6236                                                 do
6237                                                 {
6238                                                         (void)do_dec_stat(i);
6239                                                 }
6240                                                 while (one_in_(2));
6241
6242                                                 i++;
6243                                         }
6244                                 }
6245                                 else
6246                                 {
6247                                         (void)do_dec_stat(randint0(6));
6248                                 }
6249                                 break;
6250                         }
6251                         }
6252                 }
6253                 while (one_in_(5));
6254         }
6255
6256         if (p_ptr->inside_battle)
6257         {
6258                 p_ptr->health_who = c_ptr->m_idx;
6259                 p_ptr->redraw |= (PR_HEALTH);
6260                 redraw_stuff();
6261         }
6262
6263         /* XXX XXX XXX Verify this code */
6264
6265         /* Update the monster */
6266         update_mon(c_ptr->m_idx, FALSE);
6267
6268         /* Redraw the monster grid */
6269         lite_spot(y, x);
6270
6271
6272         /* Update monster recall window */
6273         if (p_ptr->monster_race_idx == m_ptr->r_idx)
6274         {
6275                 /* Window stuff */
6276                 p_ptr->window |= (PW_MONSTER);
6277         }
6278
6279         if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
6280         {
6281                 if (!who)
6282                 {
6283                         if (!projectable(m_ptr->fy, m_ptr->fx, py, px) && !(flg & PROJECT_NO_HANGEKI))
6284                         {
6285                                 set_target(m_ptr, monster_target_y, monster_target_x);
6286                         }
6287                 }
6288                 else if ((who > 0) && is_pet(caster_ptr) && !player_bold(m_ptr->target_y, m_ptr->target_x))
6289                 {
6290                         set_target(m_ptr, caster_ptr->fy, caster_ptr->fx);
6291                 }
6292         }
6293
6294         if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx) && (dam > 0))
6295         {
6296                 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
6297                 rakubadam_m = (dam > 200) ? 200 : dam;
6298         }
6299
6300
6301         if (photo)
6302         {
6303                 object_type *q_ptr;
6304                 object_type forge;
6305
6306                 /* Get local object */
6307                 q_ptr = &forge;
6308
6309                 /* Prepare to make a Blade of Chaos */
6310                 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
6311
6312                 q_ptr->pval = photo;
6313
6314                 /* Mark the item as fully known */
6315                 q_ptr->ident |= (IDENT_MENTAL);
6316
6317                 /* Drop it in the dungeon */
6318                 (void)drop_near(q_ptr, -1, py, px);
6319         }
6320
6321         /* Track it */
6322         project_m_n++;
6323         project_m_x = x;
6324         project_m_y = y;
6325
6326         /* Return "Anything seen?" */
6327         return (obvious);
6328 }
6329
6330
6331 /*
6332  * Helper function for "project()" below.
6333  *
6334  * Handle a beam/bolt/ball causing damage to the player.
6335  *
6336  * This routine takes a "source monster" (by index), a "distance", a default
6337  * "damage", and a "damage type".  See "project_m()" above.
6338  *
6339  * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
6340  * is reduced (see "project_m()" above).  This can happen if a monster breathes
6341  * at the player and hits a wall instead.
6342  *
6343  * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
6344  * to know if this is actually a ball or a bolt spell
6345  *
6346  *
6347  * We return "TRUE" if any "obvious" effects were observed.  XXX XXX Actually,
6348  * we just assume that the effects were obvious, for historical reasons.
6349  */
6350 static bool project_p(int who, cptr who_name, int r, int y, int x, int dam, int typ, int flg, int monspell)
6351 {
6352         int k = 0;
6353         int rlev = 0;
6354
6355         /* Hack -- assume obvious */
6356         bool obvious = TRUE;
6357
6358         /* Player blind-ness */
6359         bool blind = (p_ptr->blind ? TRUE : FALSE);
6360
6361         /* Player needs a "description" (he is blind) */
6362         bool fuzzy = FALSE;
6363
6364         /* Source monster */
6365         monster_type *m_ptr = NULL;
6366
6367         /* Monster name (for attacks) */
6368         char m_name[80];
6369
6370         /* Monster name (for damage) */
6371         char killer[80];
6372
6373         /* Hack -- messages */
6374         cptr act = NULL;
6375
6376         int get_damage = 0;
6377
6378
6379         /* Player is not here */
6380         if (!player_bold(y, x)) return (FALSE);
6381
6382         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (p_ptr->lev*3/5+20)) && who && (who != p_ptr->riding))
6383         {
6384                 kawarimi(TRUE);
6385                 return FALSE;
6386         }
6387
6388         /* Player cannot hurt himself */
6389         if (!who) return (FALSE);
6390         if (who == p_ptr->riding) return (FALSE);
6391
6392         if ((p_ptr->reflect || ((p_ptr->special_defense & KATA_FUUJIN) && !p_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
6393         {
6394                 byte t_y, t_x;
6395                 int max_attempts = 10;
6396
6397 #ifdef JP
6398                 if (blind) msg_print("²¿¤«¤¬Ä·¤ÍÊ֤ä¿¡ª");
6399                 else if (p_ptr->special_defense & KATA_FUUJIN) msg_print("É÷¤ÎÇ¡¤¯Éð´ï¤ò¿¶¤ë¤Ã¤ÆÃƤ­ÊÖ¤·¤¿¡ª");
6400                 else msg_print("¹¶·â¤¬Ä·¤ÍÊ֤ä¿¡ª");
6401 #else
6402                 if (blind) msg_print("Something bounces!");
6403                 else msg_print("The attack bounces!");
6404 #endif
6405
6406
6407                 /* Choose 'new' target */
6408                 do
6409                 {
6410                         t_y = m_list[who].fy - 1 + randint1(3);
6411                         t_x = m_list[who].fx - 1 + randint1(3);
6412                         max_attempts--;
6413                 }
6414                 while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(py, px, t_y, t_x));
6415
6416                 if (max_attempts < 1)
6417                 {
6418                         t_y = m_list[who].fy;
6419                         t_x = m_list[who].fx;
6420                 }
6421
6422                 project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL|PROJECT_REFLECTABLE), monspell);
6423
6424                 disturb(1, 0);
6425                 return TRUE;
6426         }
6427
6428         /* XXX XXX XXX */
6429         /* Limit maximum damage */
6430         if (dam > 1600) dam = 1600;
6431
6432         /* Reduce damage by distance */
6433         dam = (dam + r) / (r + 1);
6434
6435
6436         /* If the player is blind, be more descriptive */
6437         if (blind) fuzzy = TRUE;
6438
6439
6440         if (who > 0)
6441         {
6442                 /* Get the source monster */
6443                 m_ptr = &m_list[who];
6444                 /* Extract the monster level */
6445                 rlev = (((&r_info[m_ptr->r_idx])->level >= 1) ? (&r_info[m_ptr->r_idx])->level : 1);
6446
6447                 /* Get the monster name */
6448                 monster_desc(m_name, m_ptr, 0);
6449
6450                 /* Get the monster's real name (gotten before polymorph!) */
6451                 strcpy(killer, who_name);
6452         }
6453         else if (who < 0)
6454         {
6455 #ifdef JP
6456                 strcpy(killer, "æ«");
6457 #else
6458                 strcpy(killer, "a trap");
6459 #endif
6460         }
6461
6462         /* Analyze the damage */
6463         switch (typ)
6464         {
6465                 /* Standard damage -- hurts inventory too */
6466                 case GF_ACID:
6467                 {
6468 #ifdef JP
6469 if (fuzzy) msg_print("»À¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6470 #else
6471                         if (fuzzy) msg_print("You are hit by acid!");
6472 #endif
6473                         
6474                         get_damage = acid_dam(dam, killer, monspell);
6475                         break;
6476                 }
6477
6478                 /* Standard damage -- hurts inventory too */
6479                 case GF_FIRE:
6480                 {
6481 #ifdef JP
6482 if (fuzzy) msg_print("²Ð±ê¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6483 #else
6484                         if (fuzzy) msg_print("You are hit by fire!");
6485 #endif
6486
6487                         get_damage = fire_dam(dam, killer, monspell);
6488                         break;
6489                 }
6490
6491                 /* Standard damage -- hurts inventory too */
6492                 case GF_COLD:
6493                 {
6494 #ifdef JP
6495 if (fuzzy) msg_print("Î䵤¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6496 #else
6497                         if (fuzzy) msg_print("You are hit by cold!");
6498 #endif
6499
6500                         get_damage = cold_dam(dam, killer, monspell);
6501                         break;
6502                 }
6503
6504                 /* Standard damage -- hurts inventory too */
6505                 case GF_ELEC:
6506                 {
6507 #ifdef JP
6508 if (fuzzy) msg_print("ÅÅ·â¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6509 #else
6510                         if (fuzzy) msg_print("You are hit by lightning!");
6511 #endif
6512
6513                         get_damage = elec_dam(dam, killer, monspell);
6514                         break;
6515                 }
6516
6517                 /* Standard damage -- also poisons player */
6518                 case GF_POIS:
6519                 {
6520                         bool double_resist = IS_OPPOSE_POIS();
6521 #ifdef JP
6522 if (fuzzy) msg_print("ÆǤǹ¶·â¤µ¤ì¤¿¡ª");
6523 #else
6524                         if (fuzzy) msg_print("You are hit by poison!");
6525 #endif
6526
6527                         if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6528                         if (double_resist) dam = (dam + 2) / 3;
6529
6530                         if ((!(double_resist || p_ptr->resist_pois)) &&
6531                              one_in_(HURT_CHANCE))
6532                         {
6533                                 do_dec_stat(A_CON);
6534                         }
6535
6536                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6537
6538                         if (!(double_resist || p_ptr->resist_pois))
6539                         {
6540                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
6541                         }
6542                         break;
6543                 }
6544
6545                 /* Standard damage -- also poisons / mutates player */
6546                 case GF_NUKE:
6547                 {
6548                         bool double_resist = IS_OPPOSE_POIS();
6549 #ifdef JP
6550 if (fuzzy) msg_print("Êü¼Íǽ¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6551 #else
6552                         if (fuzzy) msg_print("You are hit by radiation!");
6553 #endif
6554
6555                         if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6556                         if (double_resist) dam = (2 * dam + 2) / 5;
6557                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6558                         if (!(double_resist || p_ptr->resist_pois))
6559                         {
6560                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
6561
6562                                 if (one_in_(5)) /* 6 */
6563                                 {
6564 #ifdef JP
6565 msg_print("´ñ·ÁŪ¤ÊÊѿȤò¿ë¤²¤¿¡ª");
6566 #else
6567                                         msg_print("You undergo a freakish metamorphosis!");
6568 #endif
6569
6570                                         if (one_in_(4)) /* 4 */
6571                                                 do_poly_self();
6572                                         else
6573                                                 mutate_player();
6574                                 }
6575
6576                                 if (one_in_(6))
6577                                 {
6578                                         inven_damage(set_acid_destroy, 2);
6579                                 }
6580                         }
6581                         break;
6582                 }
6583
6584                 /* Standard damage */
6585                 case GF_MISSILE:
6586                 {
6587 #ifdef JP
6588 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6589 #else
6590                         if (fuzzy) msg_print("You are hit by something!");
6591 #endif
6592
6593                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6594                         break;
6595                 }
6596
6597                 /* Holy Orb -- Player only takes partial damage */
6598                 case GF_HOLY_FIRE:
6599                 {
6600 #ifdef JP
6601 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6602 #else
6603                         if (fuzzy) msg_print("You are hit by something!");
6604 #endif
6605
6606                         if (p_ptr->align > 10)
6607                                 dam /= 2;
6608                         else if (p_ptr->align < -10)
6609                                 dam *= 2;
6610                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6611                         break;
6612                 }
6613
6614                 case GF_HELL_FIRE:
6615                 {
6616 #ifdef JP
6617 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6618 #else
6619                         if (fuzzy) msg_print("You are hit by something!");
6620 #endif
6621
6622                         if (p_ptr->align > 10)
6623                                 dam *= 2;
6624                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6625                         break;
6626                 }
6627
6628                 /* Arrow -- XXX no dodging */
6629                 case GF_ARROW:
6630                 {
6631 #ifdef JP
6632 if (fuzzy) msg_print("²¿¤«±Ô¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6633 #else
6634                         if (fuzzy) msg_print("You are hit by something sharp!");
6635 #endif
6636
6637                         else if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
6638                         {
6639 #ifdef JP
6640                                 msg_print("Ìð¤ò»Â¤ê¼Î¤Æ¤¿¡ª");
6641 #else
6642                                 msg_print("You cut down the arrow!");
6643 #endif
6644                                 break;
6645                         }
6646                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6647                         break;
6648                 }
6649
6650                 /* Plasma -- XXX No resist */
6651                 case GF_PLASMA:
6652                 {
6653 #ifdef JP
6654                         if (fuzzy) msg_print("²¿¤«¤È¤Æ¤âÇ®¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6655 #else
6656                         if (fuzzy) msg_print("You are hit by something *HOT*!");
6657 #endif
6658
6659                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6660
6661                         if (!p_ptr->resist_sound)
6662                         {
6663                                 int k = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
6664                                 (void)set_stun(p_ptr->stun + k);
6665                         }
6666
6667                         if (!(p_ptr->resist_fire ||
6668                               IS_OPPOSE_FIRE() ||
6669                               p_ptr->immune_fire))
6670                         {
6671                                 inven_damage(set_acid_destroy, 3);
6672                         }
6673
6674                         break;
6675                 }
6676
6677                 /* Nether -- drain experience */
6678                 case GF_NETHER:
6679                 {
6680 #ifdef JP
6681 if (fuzzy) msg_print("ÃϹö¤ÎÎϤǹ¶·â¤µ¤ì¤¿¡ª");
6682 #else
6683                         if (fuzzy) msg_print("You are hit by nether forces!");
6684 #endif
6685
6686
6687                         if (p_ptr->resist_neth)
6688                         {
6689                                 if (!prace_is_(RACE_SPECTRE))
6690                                         dam *= 6; dam /= (randint1(4) + 7);
6691                         }
6692                         else drain_exp(200 + (p_ptr->exp / 100), 200 + (p_ptr->exp / 1000), 75);
6693
6694                         if (prace_is_(RACE_SPECTRE))
6695                         {
6696 #ifdef JP
6697 msg_print("µ¤Ê¬¤¬¤è¤¯¤Ê¤Ã¤¿¡£");
6698 #else
6699                                 msg_print("You feel invigorated!");
6700 #endif
6701
6702                                 hp_player(dam / 4);
6703                                 learn_spell(monspell);
6704                         }
6705                         else
6706                         {
6707                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6708                         }
6709
6710                         break;
6711                 }
6712
6713                 /* Water -- stun/confuse */
6714                 case GF_WATER:
6715                 {
6716 #ifdef JP
6717 if (fuzzy) msg_print("²¿¤«¼¾¤Ã¤¿¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6718 #else
6719                         if (fuzzy) msg_print("You are hit by something wet!");
6720 #endif
6721
6722                         if (!p_ptr->resist_sound)
6723                         {
6724                                 set_stun(p_ptr->stun + randint1(40));
6725                         }
6726                         if (!p_ptr->resist_conf)
6727                         {
6728                                 set_confused(p_ptr->confused + randint1(5) + 5);
6729                         }
6730
6731                         if (one_in_(5))
6732                         {
6733                                 inven_damage(set_cold_destroy, 3);
6734                         }
6735
6736                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6737                         break;
6738                 }
6739
6740                 /* Chaos -- many effects */
6741                 case GF_CHAOS:
6742                 {
6743 #ifdef JP
6744 if (fuzzy) msg_print("̵Ãá½ø¤ÎÇÈÆ°¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6745 #else
6746                         if (fuzzy) msg_print("You are hit by a wave of anarchy!");
6747 #endif
6748
6749                         if (p_ptr->resist_chaos)
6750                         {
6751                                 dam *= 6; dam /= (randint1(4) + 7);
6752                         }
6753                         if (!p_ptr->resist_conf)
6754                         {
6755                                 (void)set_confused(p_ptr->confused + randint0(20) + 10);
6756                         }
6757                         if (!p_ptr->resist_chaos)
6758                         {
6759                                 (void)set_image(p_ptr->image + randint1(10));
6760                                 if (one_in_(3))
6761                                 {
6762 #ifdef JP
6763 msg_print("¤¢¤Ê¤¿¤Î¿ÈÂΤϥ«¥ª¥¹¤ÎÎϤÇDZ¤¸¶Ê¤²¤é¤ì¤¿¡ª");
6764 #else
6765                                         msg_print("Your body is twisted by chaos!");
6766 #endif
6767
6768                                         (void)gain_random_mutation(0);
6769                                 }
6770                         }
6771                         if (!p_ptr->resist_neth && !p_ptr->resist_chaos)
6772                         {
6773                                 drain_exp(5000 + (p_ptr->exp / 100), 500 + (p_ptr->exp / 1000), 75);
6774                         }
6775                         if (!p_ptr->resist_chaos || one_in_(9))
6776                         {
6777                                 inven_damage(set_elec_destroy, 2);
6778                                 inven_damage(set_fire_destroy, 2);
6779                         }
6780                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6781                         break;
6782                 }
6783
6784                 /* Shards -- mostly cutting */
6785                 case GF_SHARDS:
6786                 {
6787 #ifdef JP
6788 if (fuzzy) msg_print("²¿¤«±Ô¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6789 #else
6790                         if (fuzzy) msg_print("You are hit by something sharp!");
6791 #endif
6792
6793                         if (p_ptr->resist_shard)
6794                         {
6795                                 dam *= 6; dam /= (randint1(4) + 7);
6796                         }
6797                         else
6798                         {
6799                                 (void)set_cut(p_ptr->cut + dam);
6800                         }
6801
6802                         if (!p_ptr->resist_shard || one_in_(13))
6803                         {
6804                                 inven_damage(set_cold_destroy, 2);
6805                         }
6806
6807                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6808                         break;
6809                 }
6810
6811                 /* Sound -- mostly stunning */
6812                 case GF_SOUND:
6813                 {
6814 #ifdef JP
6815 if (fuzzy) msg_print("¹ì²»¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6816 #else
6817                         if (fuzzy) msg_print("You are hit by a loud noise!");
6818 #endif
6819
6820                         if (p_ptr->resist_sound)
6821                         {
6822                                 dam *= 5; dam /= (randint1(4) + 7);
6823                         }
6824                         else
6825                         {
6826                                 int k = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
6827                                 (void)set_stun(p_ptr->stun + k);
6828                         }
6829
6830                         if (!p_ptr->resist_sound || one_in_(13))
6831                         {
6832                                 inven_damage(set_cold_destroy, 2);
6833                         }
6834
6835                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6836                         break;
6837                 }
6838
6839                 /* Pure confusion */
6840                 case GF_CONFUSION:
6841                 {
6842 #ifdef JP
6843 if (fuzzy) msg_print("²¿¤«º®Í𤹤ë¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6844 #else
6845                         if (fuzzy) msg_print("You are hit by something puzzling!");
6846 #endif
6847
6848                         if (p_ptr->resist_conf)
6849                         {
6850                                 dam *= 5; dam /= (randint1(4) + 7);
6851                         }
6852                         if (!p_ptr->resist_conf)
6853                         {
6854                                 (void)set_confused(p_ptr->confused + randint1(20) + 10);
6855                         }
6856                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6857                         break;
6858                 }
6859
6860                 /* Disenchantment -- see above */
6861                 case GF_DISENCHANT:
6862                 {
6863 #ifdef JP
6864                         if (fuzzy) msg_print("²¿¤«¤µ¤¨¤Ê¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6865 #else
6866                         if (fuzzy) msg_print("You are hit by something static!");
6867 #endif
6868
6869                         if (p_ptr->resist_disen)
6870                         {
6871                                 dam *= 6; dam /= (randint1(4) + 7);
6872                         }
6873                         else
6874                         {
6875                                 (void)apply_disenchant(0);
6876                         }
6877                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6878                         break;
6879                 }
6880
6881                 /* Nexus -- see above */
6882                 case GF_NEXUS:
6883                 {
6884 #ifdef JP
6885 if (fuzzy) msg_print("²¿¤«´ñ̯¤Ê¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6886 #else
6887                         if (fuzzy) msg_print("You are hit by something strange!");
6888 #endif
6889
6890                         if (p_ptr->resist_nexus)
6891                         {
6892                                 dam *= 6; dam /= (randint1(4) + 7);
6893                         }
6894                         else
6895                         {
6896                                 apply_nexus(m_ptr);
6897                         }
6898                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6899                         break;
6900                 }
6901
6902                 /* Force -- mostly stun */
6903                 case GF_FORCE:
6904                 {
6905 #ifdef JP
6906 if (fuzzy) msg_print("±¿Æ°¥¨¥Í¥ë¥®¡¼¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6907 #else
6908                         if (fuzzy) msg_print("You are hit by kinetic force!");
6909 #endif
6910
6911                         if (!p_ptr->resist_sound)
6912                         {
6913                                 (void)set_stun(p_ptr->stun + randint1(20));
6914                         }
6915                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6916                         break;
6917                 }
6918
6919
6920                 /* Rocket -- stun, cut */
6921                 case GF_ROCKET:
6922                 {
6923 #ifdef JP
6924 if (fuzzy) msg_print("Çúȯ¤¬¤¢¤Ã¤¿¡ª");
6925 #else
6926                         if (fuzzy) msg_print("There is an explosion!");
6927 #endif
6928
6929                         if (!p_ptr->resist_sound)
6930                         {
6931                                 (void)set_stun(p_ptr->stun + randint1(20));
6932                         }
6933                         if (p_ptr->resist_shard)
6934                         {
6935                                 dam /= 2;
6936                         }
6937                         else
6938                         {
6939                                 (void)set_cut(p_ptr->  cut + ( dam / 2));
6940                         }
6941
6942                         if ((!p_ptr->resist_shard) || one_in_(12))
6943                         {
6944                                 inven_damage(set_cold_destroy, 3);
6945                         }
6946
6947                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6948                         break;
6949                 }
6950
6951                 /* Inertia -- slowness */
6952                 case GF_INERTIA:
6953                 {
6954 #ifdef JP
6955 if (fuzzy) msg_print("²¿¤«ÃÙ¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6956 #else
6957                         if (fuzzy) msg_print("You are hit by something slow!");
6958 #endif
6959
6960                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
6961                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6962                         break;
6963                 }
6964
6965                 /* Lite -- blinding */
6966                 case GF_LITE:
6967                 {
6968 #ifdef JP
6969 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6970 #else
6971                         if (fuzzy) msg_print("You are hit by something!");
6972 #endif
6973
6974                         if (p_ptr->resist_lite)
6975                         {
6976                                 dam *= 4; dam /= (randint1(4) + 7);
6977                         }
6978                         else if (!blind && !p_ptr->resist_blind)
6979                         {
6980                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
6981                         }
6982                         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
6983                         {
6984 #ifdef JP
6985 msg_print("¸÷¤ÇÆùÂΤ¬¾Ç¤¬¤µ¤ì¤¿¡ª");
6986 #else
6987                                 msg_print("The light scorches your flesh!");
6988 #endif
6989
6990                                 dam *= 2;
6991                         }
6992                         else if (prace_is_(RACE_S_FAIRY))
6993                         {
6994                                 dam = dam * 4 / 3;
6995                         }
6996                         if (p_ptr->wraith_form) dam *= 2;
6997                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6998
6999                         if (p_ptr->wraith_form)
7000                         {
7001                                 p_ptr->wraith_form = 0;
7002 #ifdef JP
7003 msg_print("Á®¸÷¤Î¤¿¤áÈóʪ¼ÁŪ¤Ê±Æ¤Î¸ºß¤Ç¤¤¤é¤ì¤Ê¤¯¤Ê¤Ã¤¿¡£");
7004 #else
7005                                 msg_print("The light forces you out of your incorporeal shadow form.");
7006 #endif
7007
7008                                 p_ptr->redraw |= PR_MAP;
7009                                 /* Update monsters */
7010                                 p_ptr->update |= (PU_MONSTERS);
7011                                 /* Window stuff */
7012                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
7013
7014                                 /* Redraw status bar */
7015                                 p_ptr->redraw |= (PR_STATUS);
7016
7017                         }
7018
7019                         break;
7020                 }
7021
7022                 /* Dark -- blinding */
7023                 case GF_DARK:
7024                 {
7025 #ifdef JP
7026 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7027 #else
7028                         if (fuzzy) msg_print("You are hit by something!");
7029 #endif
7030
7031                         if (p_ptr->resist_dark)
7032                         {
7033                                 dam *= 4; dam /= (randint1(4) + 7);
7034
7035                                 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
7036                         }
7037                         else if (!blind && !p_ptr->resist_blind)
7038                         {
7039                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
7040                         }
7041                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7042                         break;
7043                 }
7044
7045                 /* Time -- bolt fewer effects XXX */
7046                 case GF_TIME:
7047                 {
7048 #ifdef JP
7049 if (fuzzy) msg_print("²áµî¤«¤é¤Î¾×·â¤Ë¹¶·â¤µ¤ì¤¿¡ª");
7050 #else
7051                         if (fuzzy) msg_print("You are hit by a blast from the past!");
7052 #endif
7053
7054                         if (p_ptr->resist_time)
7055                         {
7056                                 dam *= 4;
7057                                 dam /= (randint1(4) + 7);
7058 #ifdef JP
7059 msg_print("»þ´Ö¤¬Ä̤ê²á¤®¤Æ¤¤¤¯µ¤¤¬¤¹¤ë¡£");
7060 #else
7061                                 msg_print("You feel as if time is passing you by.");
7062 #endif
7063
7064                         }
7065                         else
7066                         {
7067                                 switch (randint1(10))
7068                                 {
7069                                         case 1: case 2: case 3: case 4: case 5:
7070                                         {
7071                                                 if (p_ptr->prace == RACE_ANDROID) break;
7072 #ifdef JP
7073 msg_print("¿ÍÀ¸¤¬µÕÌá¤ê¤·¤¿µ¤¤¬¤¹¤ë¡£");
7074 #else
7075                                                 msg_print("You feel life has clocked back.");
7076 #endif
7077
7078                                                 lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
7079                                                 break;
7080                                         }
7081
7082                                         case 6: case 7: case 8: case 9:
7083                                         {
7084                                                 switch (randint1(6))
7085                                                 {
7086 #ifdef JP
7087 case 1: k = A_STR; act = "¶¯¤¯"; break;
7088 case 2: k = A_INT; act = "ÁïÌÀ¤Ç"; break;
7089 case 3: k = A_WIS; act = "¸­ÌÀ¤Ç"; break;
7090 case 4: k = A_DEX; act = "´ïÍѤÇ"; break;
7091 case 5: k = A_CON; act = "·ò¹¯¤Ç"; break;
7092 case 6: k = A_CHR; act = "Èþ¤·¤¯"; break;
7093 #else
7094                                                         case 1: k = A_STR; act = "strong"; break;
7095                                                         case 2: k = A_INT; act = "bright"; break;
7096                                                         case 3: k = A_WIS; act = "wise"; break;
7097                                                         case 4: k = A_DEX; act = "agile"; break;
7098                                                         case 5: k = A_CON; act = "hale"; break;
7099                                                         case 6: k = A_CHR; act = "beautiful"; break;
7100 #endif
7101
7102                                                 }
7103
7104 #ifdef JP
7105 msg_format("¤¢¤Ê¤¿¤Ï°ÊÁ°¤Û¤É%s¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿...¡£", act);
7106 #else
7107                                                 msg_format("You're not as %s as you used to be...", act);
7108 #endif
7109
7110
7111                                                 p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
7112                                                 if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
7113                                                 p_ptr->update |= (PU_BONUS);
7114                                                 break;
7115                                         }
7116
7117                                         case 10:
7118                                         {
7119 #ifdef JP
7120 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤Û¤ÉÎ϶¯¤¯¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿...¡£");
7121 #else
7122                                                 msg_print("You're not as powerful as you used to be...");
7123 #endif
7124
7125
7126                                                 for (k = 0; k < 6; k++)
7127                                                 {
7128                                                         p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
7129                                                         if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
7130                                                 }
7131                                                 p_ptr->update |= (PU_BONUS);
7132                                                 break;
7133                                         }
7134                                 }
7135                         }
7136
7137                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7138                         break;
7139                 }
7140
7141                 /* Gravity -- stun plus slowness plus teleport */
7142                 case GF_GRAVITY:
7143                 {
7144 #ifdef JP
7145                         if (fuzzy) msg_print("²¿¤«½Å¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7146                         msg_print("¼þÊդνÅÎϤ¬¤æ¤¬¤ó¤À¡£");
7147 #else
7148                         if (fuzzy) msg_print("You are hit by something heavy!");
7149                         msg_print("Gravity warps around you.");
7150 #endif
7151
7152                         teleport_player(5, TRUE);
7153                         if (!p_ptr->levitation)
7154                                 (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
7155                         if (!(p_ptr->resist_sound || p_ptr->levitation))
7156                         {
7157                                 int k = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
7158                                 (void)set_stun(p_ptr->stun + k);
7159                         }
7160                         if (p_ptr->levitation)
7161                         {
7162                                 dam = (dam * 2) / 3;
7163                         }
7164
7165                         if (!p_ptr->levitation || one_in_(13))
7166                         {
7167                                 inven_damage(set_cold_destroy, 2);
7168                         }
7169
7170                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7171                         break;
7172                 }
7173
7174                 /* Standard damage */
7175                 case GF_DISINTEGRATE:
7176                 {
7177 #ifdef JP
7178 if (fuzzy) msg_print("½ã¿è¤Ê¥¨¥Í¥ë¥®¡¼¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7179 #else
7180                         if (fuzzy) msg_print("You are hit by pure energy!");
7181 #endif
7182
7183                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7184                         break;
7185                 }
7186
7187                 case GF_OLD_HEAL:
7188                 {
7189 #ifdef JP
7190 if (fuzzy) msg_print("²¿¤é¤«¤Î¹¶·â¤Ë¤è¤Ã¤Æµ¤Ê¬¤¬¤è¤¯¤Ê¤Ã¤¿¡£");
7191 #else
7192                         if (fuzzy) msg_print("You are hit by something invigorating!");
7193 #endif
7194
7195                         (void)hp_player(dam);
7196                         dam = 0;
7197                         break;
7198                 }
7199
7200                 case GF_OLD_SPEED:
7201                 {
7202 #ifdef JP
7203 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7204 #else
7205                         if (fuzzy) msg_print("You are hit by something!");
7206 #endif
7207
7208                         (void)set_fast(p_ptr->fast + randint1(5), FALSE);
7209                         dam = 0;
7210                         break;
7211                 }
7212
7213                 case GF_OLD_SLOW:
7214                 {
7215 #ifdef JP
7216 if (fuzzy) msg_print("²¿¤«ÃÙ¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7217 #else
7218                         if (fuzzy) msg_print("You are hit by something slow!");
7219 #endif
7220
7221                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
7222                         break;
7223                 }
7224
7225                 case GF_OLD_SLEEP:
7226                 {
7227                         if (p_ptr->free_act)  break;
7228 #ifdef JP
7229 if (fuzzy) msg_print("̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
7230 #else
7231                         if (fuzzy) msg_print("You fall asleep!");
7232 #endif
7233
7234
7235                         if (ironman_nightmare)
7236                         {
7237 #ifdef JP
7238 msg_print("¶²¤í¤·¤¤¸÷·Ê¤¬Æ¬¤ËÉ⤫¤ó¤Ç¤­¤¿¡£");
7239 #else
7240                                 msg_print("A horrible vision enters your mind.");
7241 #endif
7242
7243
7244                                 /* Pick a nightmare */
7245                                 get_mon_num_prep(get_nightmare, NULL);
7246
7247                                 /* Have some nightmares */
7248                                 have_nightmare(get_mon_num(MAX_DEPTH));
7249
7250                                 /* Remove the monster restriction */
7251                                 get_mon_num_prep(NULL, NULL);
7252                         }
7253
7254                         set_paralyzed(p_ptr->paralyzed + dam);
7255                         dam = 0;
7256                         break;
7257                 }
7258
7259                 /* Pure damage */
7260                 case GF_MANA:
7261                 case GF_SEEKER:
7262                 case GF_SUPER_RAY:
7263                 {
7264 #ifdef JP
7265 if (fuzzy) msg_print("ËâË¡¤Î¥ª¡¼¥é¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7266 #else
7267                         if (fuzzy) msg_print("You are hit by an aura of magic!");
7268 #endif
7269
7270                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7271                         break;
7272                 }
7273
7274                 /* Pure damage */
7275                 case GF_PSY_SPEAR:
7276                 {
7277 #ifdef JP
7278 if (fuzzy) msg_print("¥¨¥Í¥ë¥®¡¼¤Î²ô¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7279 #else
7280                         if (fuzzy) msg_print("You are hit by an energy!");
7281 #endif
7282
7283                         get_damage = take_hit(DAMAGE_FORCE, dam, killer, monspell);
7284                         break;
7285                 }
7286
7287                 /* Pure damage */
7288                 case GF_METEOR:
7289                 {
7290 #ifdef JP
7291 if (fuzzy) msg_print("²¿¤«¤¬¶õ¤«¤é¤¢¤Ê¤¿¤ÎƬ¾å¤ËÍî¤Á¤Æ¤­¤¿¡ª");
7292 #else
7293                         if (fuzzy) msg_print("Something falls from the sky on you!");
7294 #endif
7295
7296                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7297                         if (!p_ptr->resist_shard || one_in_(13))
7298                         {
7299                                 if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
7300                                 inven_damage(set_cold_destroy, 2);
7301                         }
7302
7303                         break;
7304                 }
7305
7306                 /* Ice -- cold plus stun plus cuts */
7307                 case GF_ICE:
7308                 {
7309 #ifdef JP
7310 if (fuzzy) msg_print("²¿¤«±Ô¤¯Î䤿¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7311 #else
7312                         if (fuzzy) msg_print("You are hit by something sharp and cold!");
7313 #endif
7314
7315                         cold_dam(dam, killer, monspell);
7316                         if (!p_ptr->resist_shard)
7317                         {
7318                                 (void)set_cut(p_ptr->cut + damroll(5, 8));
7319                         }
7320                         if (!p_ptr->resist_sound)
7321                         {
7322                                 (void)set_stun(p_ptr->stun + randint1(15));
7323                         }
7324
7325                         if ((!(p_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
7326                         {
7327                                 if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
7328                         }
7329
7330                         break;
7331                 }
7332
7333                 /* Death Ray */
7334                 case GF_DEATH_RAY:
7335                 {
7336 #ifdef JP
7337 if (fuzzy) msg_print("²¿¤«Èó¾ï¤ËÎ䤿¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7338 #else
7339                         if (fuzzy) msg_print("You are hit by something extremely cold!");
7340 #endif
7341
7342
7343                         if (p_ptr->mimic_form)
7344                         {
7345                                 if (!(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
7346                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7347                         }
7348                         else
7349                         {
7350
7351                         switch (p_ptr->prace)
7352                         {
7353                                 /* Some races are immune */
7354                                 case RACE_GOLEM:
7355                                 case RACE_SKELETON:
7356                                 case RACE_ZOMBIE:
7357                                 case RACE_VAMPIRE:
7358                                 case RACE_DEMON:
7359                                 case RACE_SPECTRE:
7360                                 {
7361                                         dam = 0;
7362                                         break;
7363                                 }
7364                                 /* Hurt a lot */
7365                                 default:
7366                                 {
7367                                         get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7368                                         break;
7369                                 }
7370                         }
7371                         }
7372
7373                         break;
7374                 }
7375
7376                 /* Drain mana */
7377                 case GF_DRAIN_MANA:
7378                 {
7379                         if (p_ptr->csp)
7380                         {
7381                                 /* Basic message */
7382 #ifdef JP
7383                                 if (who > 0) msg_format("%^s¤ËÀº¿À¥¨¥Í¥ë¥®¡¼¤òµÛ¤¤¼è¤é¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª", m_name);
7384                                 else msg_print("Àº¿À¥¨¥Í¥ë¥®¡¼¤òµÛ¤¤¼è¤é¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
7385 #else
7386                                 if (who > 0) msg_format("%^s draws psychic energy from you!", m_name);
7387                                 else msg_print("Your psychic energy is drawn!");
7388 #endif
7389
7390                                 /* Full drain */
7391                                 if (dam >= p_ptr->csp)
7392                                 {
7393                                         dam = p_ptr->csp;
7394                                         p_ptr->csp = 0;
7395                                         p_ptr->csp_frac = 0;
7396                                 }
7397
7398                                 /* Partial drain */
7399                                 else
7400                                 {
7401                                         p_ptr->csp -= dam;
7402                                 }
7403
7404                                 learn_spell(monspell);
7405
7406                                 /* Redraw mana */
7407                                 p_ptr->redraw |= (PR_MANA);
7408
7409                                 /* Window stuff */
7410                                 p_ptr->window |= (PW_PLAYER);
7411                                 p_ptr->window |= (PW_SPELL);
7412
7413                                 if (who > 0)
7414                                 {
7415                                         /* Heal the monster */
7416                                         if (m_ptr->hp < m_ptr->maxhp)
7417                                         {
7418                                                 /* Heal */
7419                                                 m_ptr->hp += (6 * dam);
7420                                                 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
7421
7422                                                 /* Redraw (later) if needed */
7423                                                 if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
7424                                                 if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
7425
7426                                                 /* Special message */
7427                                                 if (m_ptr->ml)
7428                                                 {
7429 #ifdef JP
7430                                                         msg_format("%^s¤Ïµ¤Ê¬¤¬Îɤµ¤½¤¦¤À¡£", m_name);
7431 #else
7432                                                         msg_format("%^s appears healthier.", m_name);
7433 #endif
7434                                                 }
7435                                         }
7436                                 }
7437                         }
7438
7439                         dam = 0;
7440                         break;
7441                 }
7442
7443                 /* Mind blast */
7444                 case GF_MIND_BLAST:
7445                 {
7446                         if (randint0(100 + rlev/2) < (MAX(5, p_ptr->skill_sav)))
7447                         {
7448 #ifdef JP
7449                                 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
7450 #else
7451                                 msg_print("You resist the effects!");
7452 #endif
7453                                 learn_spell(monspell);
7454                         }
7455                         else
7456                         {
7457 #ifdef JP
7458                                 msg_print("ÎîŪ¥¨¥Í¥ë¥®¡¼¤ÇÀº¿À¤¬¹¶·â¤µ¤ì¤¿¡£");
7459 #else
7460                                 msg_print("Your mind is blasted by psyonic energy.");
7461 #endif
7462
7463                                 if (!p_ptr->resist_conf)
7464                                 {
7465                                         (void)set_confused(p_ptr->confused + randint0(4) + 4);
7466                                 }
7467
7468                                 if (!p_ptr->resist_chaos && one_in_(3))
7469                                 {
7470                                         (void)set_image(p_ptr->image + randint0(250) + 150);
7471                                 }
7472
7473                                 p_ptr->csp -= 50;
7474                                 if (p_ptr->csp < 0)
7475                                 {
7476                                         p_ptr->csp = 0;
7477                                         p_ptr->csp_frac = 0;
7478                                 }
7479                                 p_ptr->redraw |= PR_MANA;
7480
7481                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7482                         }
7483                         break;
7484                 }
7485
7486                 /* Brain smash */
7487                 case GF_BRAIN_SMASH:
7488                 {
7489                         if (randint0(100 + rlev/2) < (MAX(5, p_ptr->skill_sav)))
7490                         {
7491 #ifdef JP
7492                                 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
7493 #else
7494                                 msg_print("You resist the effects!");
7495 #endif
7496                                 learn_spell(monspell);
7497                         }
7498                         else
7499                         {
7500 #ifdef JP
7501                                 msg_print("ÎîŪ¥¨¥Í¥ë¥®¡¼¤ÇÀº¿À¤¬¹¶·â¤µ¤ì¤¿¡£");
7502 #else
7503                                 msg_print("Your mind is blasted by psionic energy.");
7504 #endif
7505
7506                                 p_ptr->csp -= 100;
7507                                 if (p_ptr->csp < 0)
7508                                 {
7509                                         p_ptr->csp = 0;
7510                                         p_ptr->csp_frac = 0;
7511                                 }
7512                                 p_ptr->redraw |= PR_MANA;
7513
7514                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7515                                 if (!p_ptr->resist_blind)
7516                                 {
7517                                         (void)set_blind(p_ptr->blind + 8 + randint0(8));
7518                                 }
7519                                 if (!p_ptr->resist_conf)
7520                                 {
7521                                         (void)set_confused(p_ptr->confused + randint0(4) + 4);
7522                                 }
7523                                 if (!p_ptr->free_act)
7524                                 {
7525                                         (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
7526                                 }
7527                                 (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
7528
7529                                 while (randint0(100 + rlev/2) > (MAX(5, p_ptr->skill_sav)))
7530                                         (void)do_dec_stat(A_INT);
7531                                 while (randint0(100 + rlev/2) > (MAX(5, p_ptr->skill_sav)))
7532                                         (void)do_dec_stat(A_WIS);
7533
7534                                 if (!p_ptr->resist_chaos)
7535                                 {
7536                                         (void)set_image(p_ptr->image + randint0(250) + 150);
7537                                 }
7538                         }
7539                         break;
7540                 }
7541
7542                 /* cause 1 */
7543                 case GF_CAUSE_1:
7544                 {
7545                         if (randint0(100 + rlev/2) < p_ptr->skill_sav)
7546                         {
7547 #ifdef JP
7548                                 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
7549 #else
7550                                 msg_print("You resist the effects!");
7551 #endif
7552                                 learn_spell(monspell);
7553                         }
7554                         else
7555                         {
7556                                 curse_equipment(15, 0);
7557                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7558                         }
7559                         break;
7560                 }
7561
7562                 /* cause 2 */
7563                 case GF_CAUSE_2:
7564                 {
7565                         if (randint0(100 + rlev/2) < p_ptr->skill_sav)
7566                         {
7567 #ifdef JP
7568                                 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
7569 #else
7570                                 msg_print("You resist the effects!");
7571 #endif
7572                                 learn_spell(monspell);
7573                         }
7574                         else
7575                         {
7576                                 curse_equipment(25, MIN(rlev/2-15, 5));
7577                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7578                         }
7579                         break;
7580                 }
7581
7582                 /* cause 3 */
7583                 case GF_CAUSE_3:
7584                 {
7585                         if (randint0(100 + rlev/2) < p_ptr->skill_sav)
7586                         {
7587 #ifdef JP
7588                                 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
7589 #else
7590                                 msg_print("You resist the effects!");
7591 #endif
7592                                 learn_spell(monspell);
7593                         }
7594                         else
7595                         {
7596                                 curse_equipment(33, MIN(rlev/2-15, 15));
7597                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7598                         }
7599                         break;
7600                 }
7601
7602                 /* cause 4 */
7603                 case GF_CAUSE_4:
7604                 {
7605                         if ((randint0(100 + rlev/2) < p_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU))
7606                         {
7607 #ifdef JP
7608                                 msg_print("¤·¤«¤·È빦¤òÄ·¤ÍÊÖ¤·¤¿¡ª");
7609 #else
7610                                 msg_print("You resist the effects!");
7611 #endif
7612                                 learn_spell(monspell);
7613                         }
7614                         else
7615                         {
7616                                 get_damage = take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7617                                 (void)set_cut(p_ptr->cut + damroll(10, 10));
7618                         }
7619                         break;
7620                 }
7621
7622                 /* Hand of Doom */
7623                 case GF_HAND_DOOM:
7624                 {
7625                         if (randint0(100 + rlev/2) < p_ptr->skill_sav)
7626                         {
7627 #ifdef JP
7628                                 msg_format("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
7629 #else
7630                                 msg_format("You resist the effects!");
7631 #endif
7632                                 learn_spell(monspell);
7633                         }
7634                         else
7635                         {
7636 #ifdef JP
7637                                 msg_print("¤¢¤Ê¤¿¤ÏÌ¿¤¬Çö¤Þ¤Ã¤Æ¤¤¤¯¤è¤¦¤Ë´¶¤¸¤¿¡ª");
7638 #else
7639                                 msg_print("You feel your life fade away!");
7640 #endif
7641
7642                                 get_damage = take_hit(DAMAGE_ATTACK, dam, m_name, monspell);
7643                                 curse_equipment(40, 20);
7644
7645                                 if (p_ptr->chp < 1) p_ptr->chp = 1;
7646                         }
7647                         break;
7648                 }
7649
7650                 /* Default */
7651                 default:
7652                 {
7653                         /* No damage */
7654                         dam = 0;
7655
7656                         break;
7657                 }
7658         }
7659
7660         if (p_ptr->tim_eyeeye && get_damage > 0 && !p_ptr->is_dead)
7661         {
7662 #ifdef JP
7663                 msg_format("¹¶·â¤¬%s¼«¿È¤ò½ý¤Ä¤±¤¿¡ª", m_name);
7664 #else
7665                 char m_name_self[80];
7666
7667                 /* hisself */
7668                 monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
7669
7670                 msg_format("The attack of %s has wounded %s!", m_name, m_name_self);
7671 #endif
7672                 project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
7673                 set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
7674         }
7675
7676         if (p_ptr->riding && dam > 0)
7677         {
7678                 rakubadam_p = (dam > 200) ? 200 : dam;
7679         }
7680
7681
7682         /* Disturb */
7683         disturb(1, 0);
7684
7685
7686         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
7687         {
7688                 kawarimi(FALSE);
7689                 return obvious;
7690         }
7691
7692         /* Return "Anything seen?" */
7693         return (obvious);
7694 }
7695
7696
7697 /*
7698  * Find the distance from (x, y) to a line.
7699  */
7700 int dist_to_line(int y, int x, int y1, int x1, int y2, int x2)
7701 {
7702         /* Vector from (x, y) to (x1, y1) */
7703         int py = y1 - y;
7704         int px = x1 - x;
7705
7706         /* Normal vector */
7707         int ny = x2 - x1;
7708         int nx = y1 - y2;
7709
7710    /* Length of N */
7711         int pd = distance(y1, x1, y, x);
7712         int nd = distance(y1, x1, y2, x2);
7713
7714         if (pd > nd) return distance(y, x, y2, x2);
7715
7716         /* Component of P on N */
7717         nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
7718
7719    /* Absolute value */
7720    return((nd >= 0) ? nd : 0 - nd);
7721 }
7722
7723
7724
7725 /*
7726  * XXX XXX XXX
7727  * Modified version of los() for calculation of disintegration balls.
7728  * Disintegration effects are stopped by permanent walls.
7729  */
7730 bool in_disintegration_range(int y1, int x1, int y2, int x2)
7731 {
7732         /* Delta */
7733         int dx, dy;
7734
7735         /* Absolute */
7736         int ax, ay;
7737
7738         /* Signs */
7739         int sx, sy;
7740
7741         /* Fractions */
7742         int qx, qy;
7743
7744         /* Scanners */
7745         int tx, ty;
7746
7747         /* Scale factors */
7748         int f1, f2;
7749
7750         /* Slope, or 1/Slope, of LOS */
7751         int m;
7752
7753
7754         /* Extract the offset */
7755         dy = y2 - y1;
7756         dx = x2 - x1;
7757
7758         /* Extract the absolute offset */
7759         ay = ABS(dy);
7760         ax = ABS(dx);
7761
7762
7763         /* Handle adjacent (or identical) grids */
7764         if ((ax < 2) && (ay < 2)) return (TRUE);
7765
7766
7767         /* Paranoia -- require "safe" origin */
7768         /* if (!in_bounds(y1, x1)) return (FALSE); */
7769
7770
7771         /* Directly South/North */
7772         if (!dx)
7773         {
7774                 /* South -- check for walls */
7775                 if (dy > 0)
7776                 {
7777                         for (ty = y1 + 1; ty < y2; ty++)
7778                         {
7779                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
7780                         }
7781                 }
7782
7783                 /* North -- check for walls */
7784                 else
7785                 {
7786                         for (ty = y1 - 1; ty > y2; ty--)
7787                         {
7788                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
7789                         }
7790                 }
7791
7792                 /* Assume los */
7793                 return (TRUE);
7794         }
7795
7796         /* Directly East/West */
7797         if (!dy)
7798         {
7799                 /* East -- check for walls */
7800                 if (dx > 0)
7801                 {
7802                         for (tx = x1 + 1; tx < x2; tx++)
7803                         {
7804                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
7805                         }
7806                 }
7807
7808                 /* West -- check for walls */
7809                 else
7810                 {
7811                         for (tx = x1 - 1; tx > x2; tx--)
7812                         {
7813                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
7814                         }
7815                 }
7816
7817                 /* Assume los */
7818                 return (TRUE);
7819         }
7820
7821
7822         /* Extract some signs */
7823         sx = (dx < 0) ? -1 : 1;
7824         sy = (dy < 0) ? -1 : 1;
7825
7826
7827         /* Vertical "knights" */
7828         if (ax == 1)
7829         {
7830                 if (ay == 2)
7831                 {
7832                         if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
7833                 }
7834         }
7835
7836         /* Horizontal "knights" */
7837         else if (ay == 1)
7838         {
7839                 if (ax == 2)
7840                 {
7841                         if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
7842                 }
7843         }
7844
7845
7846         /* Calculate scale factor div 2 */
7847         f2 = (ax * ay);
7848
7849         /* Calculate scale factor */
7850         f1 = f2 << 1;
7851
7852
7853         /* Travel horizontally */
7854         if (ax >= ay)
7855         {
7856                 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
7857                 qy = ay * ay;
7858                 m = qy << 1;
7859
7860                 tx = x1 + sx;
7861
7862                 /* Consider the special case where slope == 1. */
7863                 if (qy == f2)
7864                 {
7865                         ty = y1 + sy;
7866                         qy -= f1;
7867                 }
7868                 else
7869                 {
7870                         ty = y1;
7871                 }
7872
7873                 /* Note (below) the case (qy == f2), where */
7874                 /* the LOS exactly meets the corner of a tile. */
7875                 while (x2 - tx)
7876                 {
7877                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
7878
7879                         qy += m;
7880
7881                         if (qy < f2)
7882                         {
7883                                 tx += sx;
7884                         }
7885                         else if (qy > f2)
7886                         {
7887                                 ty += sy;
7888                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
7889                                 qy -= f1;
7890                                 tx += sx;
7891                         }
7892                         else
7893                         {
7894                                 ty += sy;
7895                                 qy -= f1;
7896                                 tx += sx;
7897                         }
7898                 }
7899         }
7900
7901         /* Travel vertically */
7902         else
7903         {
7904                 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
7905                 qx = ax * ax;
7906                 m = qx << 1;
7907
7908                 ty = y1 + sy;
7909
7910                 if (qx == f2)
7911                 {
7912                         tx = x1 + sx;
7913                         qx -= f1;
7914                 }
7915                 else
7916                 {
7917                         tx = x1;
7918                 }
7919
7920                 /* Note (below) the case (qx == f2), where */
7921                 /* the LOS exactly meets the corner of a tile. */
7922                 while (y2 - ty)
7923                 {
7924                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
7925
7926                         qx += m;
7927
7928                         if (qx < f2)
7929                         {
7930                                 ty += sy;
7931                         }
7932                         else if (qx > f2)
7933                         {
7934                                 tx += sx;
7935                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
7936                                 qx -= f1;
7937                                 ty += sy;
7938                         }
7939                         else
7940                         {
7941                                 tx += sx;
7942                                 qx -= f1;
7943                                 ty += sy;
7944                         }
7945                 }
7946         }
7947
7948         /* Assume los */
7949         return (TRUE);
7950 }
7951
7952
7953 /*
7954  * breath shape
7955  */
7956 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)
7957 {
7958         int by = y1;
7959         int bx = x1;
7960         int brad = 0;
7961         int brev = rad * rad / dist;
7962         int bdis = 0;
7963         int cdis;
7964         int path_n = 0;
7965         int mdis = distance(y1, x1, y2, x2) + rad;
7966
7967         while (bdis <= mdis)
7968         {
7969                 int x, y;
7970
7971                 if ((0 < dist) && (path_n < dist))
7972                 {
7973                         int ny = GRID_Y(path_g[path_n]);
7974                         int nx = GRID_X(path_g[path_n]);
7975                         int nd = distance(ny, nx, y1, x1);
7976
7977                         /* Get next base point */
7978                         if (bdis >= nd)
7979                         {
7980                                 by = ny;
7981                                 bx = nx;
7982                                 path_n++;
7983                         }
7984                 }
7985
7986                 /* Travel from center outward */
7987                 for (cdis = 0; cdis <= brad; cdis++)
7988                 {
7989                         /* Scan the maximal blast area of radius "cdis" */
7990                         for (y = by - cdis; y <= by + cdis; y++)
7991                         {
7992                                 for (x = bx - cdis; x <= bx + cdis; x++)
7993                                 {
7994                                         /* Ignore "illegal" locations */
7995                                         if (!in_bounds(y, x)) continue;
7996
7997                                         /* Enforce a circular "ripple" */
7998                                         if (distance(y1, x1, y, x) != bdis) continue;
7999
8000                                         /* Enforce an arc */
8001                                         if (distance(by, bx, y, x) != cdis) continue;
8002
8003                                         switch (typ)
8004                                         {
8005                                         case GF_LITE:
8006                                         case GF_LITE_WEAK:
8007                                                 /* Lights are stopped by opaque terrains */
8008                                                 if (!los(by, bx, y, x)) continue;
8009                                                 break;
8010                                         case GF_DISINTEGRATE:
8011                                                 /* Disintegration are stopped only by perma-walls */
8012                                                 if (!in_disintegration_range(by, bx, y, x)) continue;
8013                                                 break;
8014                                         default:
8015                                                 /* Ball explosions are stopped by walls */
8016                                                 if (!projectable(by, bx, y, x)) continue;
8017                                                 break;
8018                                         }
8019
8020                                         /* Save this grid */
8021                                         gy[*pgrids] = y;
8022                                         gx[*pgrids] = x;
8023                                         (*pgrids)++;
8024                                 }
8025                         }
8026                 }
8027
8028                 /* Encode some more "radius" info */
8029                 gm[bdis + 1] = *pgrids;
8030
8031                 /* Increase the size */
8032                 brad = rad * (path_n + brev) / (dist + brev);
8033
8034                 /* Find the next ripple */
8035                 bdis++;
8036         }
8037
8038         /* Store the effect size */
8039         *pgm_rad = bdis;
8040 }
8041
8042
8043 /*
8044  * Generic "beam"/"bolt"/"ball" projection routine.
8045  *
8046  * Input:
8047  *   who: Index of "source" monster (zero for "player")
8048  *   rad: Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
8049  *   y,x: Target location (or location to travel "towards")
8050  *   dam: Base damage roll to apply to affected monsters (or player)
8051  *   typ: Type of damage to apply to monsters (and objects)
8052  *   flg: Extra bit flags (see PROJECT_xxxx in "defines.h")
8053  *
8054  * Return:
8055  *   TRUE if any "effects" of the projection were observed, else FALSE
8056  *
8057  * Allows a monster (or player) to project a beam/bolt/ball of a given kind
8058  * towards a given location (optionally passing over the heads of interposing
8059  * monsters), and have it do a given amount of damage to the monsters (and
8060  * optionally objects) within the given radius of the final location.
8061  *
8062  * A "bolt" travels from source to target and affects only the target grid.
8063  * A "beam" travels from source to target, affecting all grids passed through.
8064  * A "ball" travels from source to the target, exploding at the target, and
8065  *   affecting everything within the given radius of the target location.
8066  *
8067  * Traditionally, a "bolt" does not affect anything on the ground, and does
8068  * not pass over the heads of interposing monsters, much like a traditional
8069  * missile, and will "stop" abruptly at the "target" even if no monster is
8070  * positioned there, while a "ball", on the other hand, passes over the heads
8071  * of monsters between the source and target, and affects everything except
8072  * the source monster which lies within the final radius, while a "beam"
8073  * affects every monster between the source and target, except for the casting
8074  * monster (or player), and rarely affects things on the ground.
8075  *
8076  * Two special flags allow us to use this function in special ways, the
8077  * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
8078  * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
8079  * actually projecting from the source monster (or player).
8080  *
8081  * The player will only get "experience" for monsters killed by himself
8082  * Unique monsters can only be destroyed by attacks from the player
8083  *
8084  * Only 256 grids can be affected per projection, limiting the effective
8085  * "radius" of standard ball attacks to nine units (diameter nineteen).
8086  *
8087  * One can project in a given "direction" by combining PROJECT_THRU with small
8088  * offsets to the initial location (see "line_spell()"), or by calculating
8089  * "virtual targets" far away from the player.
8090  *
8091  * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
8092  * continuing until it actually hits somethings (useful for "stone to mud").
8093  *
8094  * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
8095  *
8096  * Balls must explode BEFORE hitting walls, or they would affect monsters
8097  * on both sides of a wall.  Some bug reports indicate that this is still
8098  * happening in 2.7.8 for Windows, though it appears to be impossible.
8099  *
8100  * We "pre-calculate" the blast area only in part for efficiency.
8101  * More importantly, this lets us do "explosions" from the "inside" out.
8102  * This results in a more logical distribution of "blast" treasure.
8103  * It also produces a better (in my opinion) animation of the explosion.
8104  * It could be (but is not) used to have the treasure dropped by monsters
8105  * in the middle of the explosion fall "outwards", and then be damaged by
8106  * the blast as it spreads outwards towards the treasure drop location.
8107  *
8108  * Walls and doors are included in the blast area, so that they can be
8109  * "burned" or "melted" in later versions.
8110  *
8111  * This algorithm is intended to maximize simplicity, not necessarily
8112  * efficiency, since this function is not a bottleneck in the code.
8113  *
8114  * We apply the blast effect from ground zero outwards, in several passes,
8115  * first affecting features, then objects, then monsters, then the player.
8116  * This allows walls to be removed before checking the object or monster
8117  * in the wall, and protects objects which are dropped by monsters killed
8118  * in the blast, and allows the player to see all affects before he is
8119  * killed or teleported away.  The semantics of this method are open to
8120  * various interpretations, but they seem to work well in practice.
8121  *
8122  * We process the blast area from ground-zero outwards to allow for better
8123  * distribution of treasure dropped by monsters, and because it provides a
8124  * pleasing visual effect at low cost.
8125  *
8126  * Note that the damage done by "ball" explosions decreases with distance.
8127  * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
8128  *
8129  * Notice the "napalm" effect of "beam" weapons.  First they "project" to
8130  * the target, and then the damage "flows" along this beam of destruction.
8131  * The damage at every grid is the same as at the "center" of a "ball"
8132  * explosion, since the "beam" grids are treated as if they ARE at the
8133  * center of a "ball" explosion.
8134  *
8135  * Currently, specifying "beam" plus "ball" means that locations which are
8136  * covered by the initial "beam", and also covered by the final "ball", except
8137  * for the final grid (the epicenter of the ball), will be "hit twice", once
8138  * by the initial beam, and once by the exploding ball.  For the grid right
8139  * next to the epicenter, this results in 150% damage being done.  The center
8140  * does not have this problem, for the same reason the final grid in a "beam"
8141  * plus "bolt" does not -- it is explicitly removed.  Simply removing "beam"
8142  * grids which are covered by the "ball" will NOT work, as then they will
8143  * receive LESS damage than they should.  Do not combine "beam" with "ball".
8144  *
8145  * The array "gy[],gx[]" with current size "grids" is used to hold the
8146  * collected locations of all grids in the "blast area" plus "beam path".
8147  *
8148  * Note the rather complex usage of the "gm[]" array.  First, gm[0] is always
8149  * zero.  Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
8150  * first blast grid (see above) with radius "N" from the blast center.  Note
8151  * that only the first gm[1] grids in the blast area thus take full damage.
8152  * Also, note that gm[rad+1] is always equal to "grids", which is the total
8153  * number of blast grids.
8154  *
8155  * Note that once the projection is complete, (y2,x2) holds the final location
8156  * of bolts/beams, and the "epicenter" of balls.
8157  *
8158  * Note also that "rad" specifies the "inclusive" radius of projection blast,
8159  * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
8160  * implementation of the "distance" function.  Also, a bolt can be properly
8161  * viewed as a "ball" with a "rad" of "zero".
8162  *
8163  * Note that if no "target" is reached before the beam/bolt/ball travels the
8164  * maximum distance allowed (MAX_RANGE), no "blast" will be induced.  This
8165  * may be relevant even for bolts, since they have a "1x1" mini-blast.
8166  *
8167  * Note that for consistency, we "pretend" that the bolt actually takes "time"
8168  * to move from point A to point B, even if the player cannot see part of the
8169  * projection path.  Note that in general, the player will *always* see part
8170  * of the path, since it either starts at the player or ends on the player.
8171  *
8172  * Hack -- we assume that every "projection" is "self-illuminating".
8173  *
8174  * Hack -- when only a single monster is affected, we automatically track
8175  * (and recall) that monster, unless "PROJECT_JUMP" is used.
8176  *
8177  * Note that all projections now "explode" at their final destination, even
8178  * if they were being projected at a more distant destination.  This means
8179  * that "ball" spells will *always* explode.
8180  *
8181  * Note that we must call "handle_stuff()" after affecting terrain features
8182  * in the blast radius, in case the "illumination" of the grid was changed,
8183  * and "update_view()" and "update_monsters()" need to be called.
8184  */
8185 bool project(int who, int rad, int y, int x, int dam, int typ, int flg, int monspell)
8186 {
8187         int i, t, dist;
8188
8189         int y1, x1;
8190         int y2, x2;
8191         int by, bx;
8192
8193         int dist_hack = 0;
8194
8195         int y_saver, x_saver; /* For reflecting monsters */
8196
8197         int msec = delay_factor * delay_factor * delay_factor;
8198
8199         /* Assume the player sees nothing */
8200         bool notice = FALSE;
8201
8202         /* Assume the player has seen nothing */
8203         bool visual = FALSE;
8204
8205         /* Assume the player has seen no blast grids */
8206         bool drawn = FALSE;
8207
8208         /* Assume to be a normal ball spell */
8209         bool breath = FALSE;
8210
8211         /* Is the player blind? */
8212         bool blind = (p_ptr->blind ? TRUE : FALSE);
8213
8214         bool old_hide = FALSE;
8215
8216         /* Number of grids in the "path" */
8217         int path_n = 0;
8218
8219         /* Actual grids in the "path" */
8220         u16b path_g[512];
8221
8222         /* Number of grids in the "blast area" (including the "beam" path) */
8223         int grids = 0;
8224
8225         /* Coordinates of the affected grids */
8226         byte gx[1024], gy[1024];
8227
8228         /* Encoded "radius" info (see above) */
8229         byte gm[32];
8230
8231         /* Actual radius encoded in gm[] */
8232         int gm_rad = rad;
8233
8234         bool jump = FALSE;
8235
8236         /* Attacker's name (prepared before polymorph)*/
8237         char who_name[80];
8238
8239         /* Initialize by null string */
8240         who_name[0] = '\0';
8241
8242         rakubadam_p = 0;
8243         rakubadam_m = 0;
8244
8245         /* Default target of monsterspell is player */
8246         monster_target_y=py;
8247         monster_target_x=px;
8248
8249         /* Hack -- Jump to target */
8250         if (flg & (PROJECT_JUMP))
8251         {
8252                 x1 = x;
8253                 y1 = y;
8254
8255                 /* Clear the flag */
8256                 flg &= ~(PROJECT_JUMP);
8257
8258                 jump = TRUE;
8259         }
8260
8261         /* Start at player */
8262         else if (who <= 0)
8263         {
8264                 x1 = px;
8265                 y1 = py;
8266         }
8267
8268         /* Start at monster */
8269         else if (who > 0)
8270         {
8271                 x1 = m_list[who].fx;
8272                 y1 = m_list[who].fy;
8273                 monster_desc(who_name, &m_list[who], MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
8274         }
8275
8276         /* Oops */
8277         else
8278         {
8279                 x1 = x;
8280                 y1 = y;
8281         }
8282
8283         y_saver = y1;
8284         x_saver = x1;
8285
8286         /* Default "destination" */
8287         y2 = y;
8288         x2 = x;
8289
8290
8291         /* Hack -- verify stuff */
8292         if (flg & (PROJECT_THRU))
8293         {
8294                 if ((x1 == x2) && (y1 == y2))
8295                 {
8296                         flg &= ~(PROJECT_THRU);
8297                 }
8298         }
8299
8300         /* Handle a breath attack */
8301         if (rad < 0)
8302         {
8303                 rad = 0 - rad;
8304                 breath = TRUE;
8305                 if (flg & PROJECT_HIDE) old_hide = TRUE;
8306                 flg |= PROJECT_HIDE;
8307         }
8308
8309
8310         /* Hack -- Assume there will be no blast (max radius 32) */
8311         for (dist = 0; dist < 32; dist++) gm[dist] = 0;
8312
8313
8314         /* Initial grid */
8315         y = y1;
8316         x = x1;
8317         dist = 0;
8318
8319         /* Collect beam grids */
8320         if (flg & (PROJECT_BEAM))
8321         {
8322                 gy[grids] = y;
8323                 gx[grids] = x;
8324                 grids++;
8325         }
8326
8327         switch (typ)
8328         {
8329         case GF_LITE:
8330         case GF_LITE_WEAK:
8331                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_LOS);
8332                 break;
8333         case GF_DISINTEGRATE:
8334                 flg |= (PROJECT_GRID);
8335                 if (breath || (flg & PROJECT_BEAM)) flg |= (PROJECT_DISI);
8336                 break;
8337         }
8338
8339         /* Calculate the projection path */
8340
8341         path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
8342
8343         /* Hack -- Handle stuff */
8344         handle_stuff();
8345
8346         /* Giga-Hack SEEKER & SUPER_RAY */
8347
8348         if( typ == GF_SEEKER )
8349         {
8350                 int j;
8351                 int last_i=0;
8352
8353                 /* Mega-Hack */
8354                 project_m_n = 0;
8355                 project_m_x = 0;
8356                 project_m_y = 0;
8357
8358                 for (i = 0; i < path_n; ++i)
8359                 {
8360                         int oy = y;
8361                         int ox = x;
8362
8363                         int ny = GRID_Y(path_g[i]);
8364                         int nx = GRID_X(path_g[i]);
8365
8366                         /* Advance */
8367                         y = ny;
8368                         x = nx;
8369
8370                         gy[grids] = y;
8371                         gx[grids] = x;
8372                         grids++;
8373
8374
8375                         /* Only do visuals if requested */
8376                         if (!blind && !(flg & (PROJECT_HIDE)))
8377                         {
8378                                 /* Only do visuals if the player can "see" the bolt */
8379                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8380                                 {
8381                                         u16b p;
8382
8383                                         byte a;
8384                                         char c;
8385
8386                                         /* Obtain the bolt pict */
8387                                         p = bolt_pict(oy, ox, y, x, typ);
8388
8389                                         /* Extract attr/char */
8390                                         a = PICT_A(p);
8391                                         c = PICT_C(p);
8392
8393                                         /* Visual effects */
8394                                         print_rel(c, a, y, x);
8395                                         move_cursor_relative(y, x);
8396                                         /*if (fresh_before)*/ Term_fresh();
8397                                         Term_xtra(TERM_XTRA_DELAY, msec);
8398                                         lite_spot(y, x);
8399                                         /*if (fresh_before)*/ Term_fresh();
8400
8401                                         /* Display "beam" grids */
8402                                         if (flg & (PROJECT_BEAM))
8403                                         {
8404                                                 /* Obtain the explosion pict */
8405                                                 p = bolt_pict(y, x, y, x, typ);
8406
8407                                                 /* Extract attr/char */
8408                                                 a = PICT_A(p);
8409                                                 c = PICT_C(p);
8410
8411                                                 /* Visual effects */
8412                                                 print_rel(c, a, y, x);
8413                                         }
8414
8415                                         /* Hack -- Activate delay */
8416                                         visual = TRUE;
8417                                 }
8418
8419                                 /* Hack -- delay anyway for consistency */
8420                                 else if (visual)
8421                                 {
8422                                         /* Delay for consistency */
8423                                         Term_xtra(TERM_XTRA_DELAY, msec);
8424                                 }
8425                         }
8426                         if(project_o(0,0,y,x,dam,GF_SEEKER))notice=TRUE;
8427                         if( is_mirror_grid(&cave[y][x]))
8428                         {
8429                           /* The target of monsterspell becomes tha mirror(broken) */
8430                                 monster_target_y=(s16b)y;
8431                                 monster_target_x=(s16b)x;
8432
8433                                 remove_mirror(y,x);
8434                                 next_mirror( &oy,&ox,y,x );
8435
8436                                 path_n = i+project_path(&(path_g[i+1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
8437                                 for( j = last_i; j <=i ; j++ )
8438                                 {
8439                                         y = GRID_Y(path_g[j]);
8440                                         x = GRID_X(path_g[j]);
8441                                         if(project_m(0,0,y,x,dam,GF_SEEKER,flg))notice=TRUE;
8442                                         if(!who && (project_m_n==1) && !jump ){
8443                                           if(cave[project_m_y][project_m_x].m_idx >0 ){
8444                                             monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
8445
8446                                             /* Hack -- auto-recall */
8447                                             if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8448
8449                                             /* Hack - auto-track */
8450                                             if (m_ptr->ml) health_track(cave[project_m_y][project_m_x].m_idx);
8451                                           }
8452                                         }
8453                                         (void)project_f(0,0,y,x,dam,GF_SEEKER);
8454                                 }
8455                                 last_i = i;
8456                         }
8457                 }
8458                 for( i = last_i ; i < path_n ; i++ )
8459                 {
8460                         int x,y;
8461                         y = GRID_Y(path_g[i]);
8462                         x = GRID_X(path_g[i]);
8463                         if(project_m(0,0,y,x,dam,GF_SEEKER,flg))
8464                           notice=TRUE;
8465                         if(!who && (project_m_n==1) && !jump ){
8466                           if(cave[project_m_y][project_m_x].m_idx >0 ){
8467                             monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
8468                             
8469                             /* Hack -- auto-recall */
8470                             if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8471                             
8472                             /* Hack - auto-track */
8473                             if (m_ptr->ml) health_track(cave[project_m_y][project_m_x].m_idx);
8474                           }
8475                         }
8476                         (void)project_f(0,0,y,x,dam,GF_SEEKER);
8477                 }
8478                 return notice;
8479         }
8480         else if(typ == GF_SUPER_RAY){
8481                 int j;
8482                 int second_step = 0;
8483
8484                 /* Mega-Hack */
8485                 project_m_n = 0;
8486                 project_m_x = 0;
8487                 project_m_y = 0;
8488
8489                 for (i = 0; i < path_n; ++i)
8490                 {
8491                         int oy = y;
8492                         int ox = x;
8493
8494                         int ny = GRID_Y(path_g[i]);
8495                         int nx = GRID_X(path_g[i]);
8496
8497                         /* Advance */
8498                         y = ny;
8499                         x = nx;
8500
8501                         gy[grids] = y;
8502                         gx[grids] = x;
8503                         grids++;
8504
8505
8506                         /* Only do visuals if requested */
8507                         if (!blind && !(flg & (PROJECT_HIDE)))
8508                         {
8509                                 /* Only do visuals if the player can "see" the bolt */
8510                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8511                                 {
8512                                         u16b p;
8513
8514                                         byte a;
8515                                         char c;
8516
8517                                         /* Obtain the bolt pict */
8518                                         p = bolt_pict(oy, ox, y, x, typ);
8519
8520                                         /* Extract attr/char */
8521                                         a = PICT_A(p);
8522                                         c = PICT_C(p);
8523
8524                                         /* Visual effects */
8525                                         print_rel(c, a, y, x);
8526                                         move_cursor_relative(y, x);
8527                                         /*if (fresh_before)*/ Term_fresh();
8528                                         Term_xtra(TERM_XTRA_DELAY, msec);
8529                                         lite_spot(y, x);
8530                                         /*if (fresh_before)*/ Term_fresh();
8531
8532                                         /* Display "beam" grids */
8533                                         if (flg & (PROJECT_BEAM))
8534                                         {
8535                                                 /* Obtain the explosion pict */
8536                                                 p = bolt_pict(y, x, y, x, typ);
8537
8538                                                 /* Extract attr/char */
8539                                                 a = PICT_A(p);
8540                                                 c = PICT_C(p);
8541
8542                                                 /* Visual effects */
8543                                                 print_rel(c, a, y, x);
8544                                         }
8545
8546                                         /* Hack -- Activate delay */
8547                                         visual = TRUE;
8548                                 }
8549
8550                                 /* Hack -- delay anyway for consistency */
8551                                 else if (visual)
8552                                 {
8553                                         /* Delay for consistency */
8554                                         Term_xtra(TERM_XTRA_DELAY, msec);
8555                                 }
8556                         }
8557                         if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
8558                         if (!cave_have_flag_bold(y, x, FF_PROJECT))
8559                         {
8560                                 if( second_step )continue;
8561                                 break;
8562                         }
8563                         if( is_mirror_grid(&cave[y][x]) && !second_step )
8564                         {
8565                           /* The target of monsterspell becomes tha mirror(broken) */
8566                                 monster_target_y=(s16b)y;
8567                                 monster_target_x=(s16b)x;
8568
8569                                 remove_mirror(y,x);
8570                                 for( j = 0; j <=i ; j++ )
8571                                 {
8572                                         y = GRID_Y(path_g[j]);
8573                                         x = GRID_X(path_g[j]);
8574                                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
8575                                 }
8576                                 path_n = i;
8577                                 second_step =i+1;
8578                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
8579                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
8580                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
8581                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x-1, flg);
8582                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x+1, flg);
8583                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x-1, flg);
8584                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
8585                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
8586                         }
8587                 }
8588                 for( i = 0; i < path_n ; i++ )
8589                 {
8590                         int x,y;
8591                         y = GRID_Y(path_g[i]);
8592                         x = GRID_X(path_g[i]);
8593                         (void)project_m(0,0,y,x,dam,GF_SUPER_RAY,flg);
8594                         if(!who && (project_m_n==1) && !jump ){
8595                           if(cave[project_m_y][project_m_x].m_idx >0 ){
8596                             monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
8597                             
8598                             /* Hack -- auto-recall */
8599                             if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8600                             
8601                             /* Hack - auto-track */
8602                             if (m_ptr->ml) health_track(cave[project_m_y][project_m_x].m_idx);
8603                           }
8604                         }
8605                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
8606                 }
8607                 return notice;
8608         }
8609
8610         /* Project along the path */
8611         for (i = 0; i < path_n; ++i)
8612         {
8613                 int oy = y;
8614                 int ox = x;
8615
8616                 int ny = GRID_Y(path_g[i]);
8617                 int nx = GRID_X(path_g[i]);
8618
8619                 if (flg & PROJECT_DISI)
8620                 {
8621                         /* Hack -- Balls explode before reaching walls */
8622                         if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
8623                 }
8624                 else if (flg & PROJECT_LOS)
8625                 {
8626                         /* Hack -- Balls explode before reaching walls */
8627                         if (!cave_los_bold(ny, nx) && (rad > 0)) break;
8628                 }
8629                 else
8630                 {
8631                         /* Hack -- Balls explode before reaching walls */
8632                         if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && (rad > 0)) break;
8633                 }
8634
8635                 /* Advance */
8636                 y = ny;
8637                 x = nx;
8638
8639                 /* Collect beam grids */
8640                 if (flg & (PROJECT_BEAM))
8641                 {
8642                         gy[grids] = y;
8643                         gx[grids] = x;
8644                         grids++;
8645                 }
8646
8647                 /* Only do visuals if requested */
8648                 if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
8649                 {
8650                         /* Only do visuals if the player can "see" the bolt */
8651                         if (panel_contains(y, x) && player_has_los_bold(y, x))
8652                         {
8653                                 u16b p;
8654
8655                                 byte a;
8656                                 char c;
8657
8658                                 /* Obtain the bolt pict */
8659                                 p = bolt_pict(oy, ox, y, x, typ);
8660
8661                                 /* Extract attr/char */
8662                                 a = PICT_A(p);
8663                                 c = PICT_C(p);
8664
8665                                 /* Visual effects */
8666                                 print_rel(c, a, y, x);
8667                                 move_cursor_relative(y, x);
8668                                 /*if (fresh_before)*/ Term_fresh();
8669                                 Term_xtra(TERM_XTRA_DELAY, msec);
8670                                 lite_spot(y, x);
8671                                 /*if (fresh_before)*/ Term_fresh();
8672
8673                                 /* Display "beam" grids */
8674                                 if (flg & (PROJECT_BEAM))
8675                                 {
8676                                         /* Obtain the explosion pict */
8677                                         p = bolt_pict(y, x, y, x, typ);
8678
8679                                         /* Extract attr/char */
8680                                         a = PICT_A(p);
8681                                         c = PICT_C(p);
8682
8683                                         /* Visual effects */
8684                                         print_rel(c, a, y, x);
8685                                 }
8686
8687                                 /* Hack -- Activate delay */
8688                                 visual = TRUE;
8689                         }
8690
8691                         /* Hack -- delay anyway for consistency */
8692                         else if (visual)
8693                         {
8694                                 /* Delay for consistency */
8695                                 Term_xtra(TERM_XTRA_DELAY, msec);
8696                         }
8697                 }
8698         }
8699
8700         path_n = i;
8701
8702         /* Save the "blast epicenter" */
8703         by = y;
8704         bx = x;
8705
8706         if (breath && !path_n)
8707         {
8708                 breath = FALSE;
8709                 gm_rad = rad;
8710                 if (!old_hide)
8711                 {
8712                         flg &= ~(PROJECT_HIDE);
8713                 }
8714         }
8715
8716         /* Start the "explosion" */
8717         gm[0] = 0;
8718
8719         /* Hack -- make sure beams get to "explode" */
8720         gm[1] = grids;
8721
8722         dist = path_n;
8723         dist_hack = dist;
8724
8725         project_length = 0;
8726
8727         /* If we found a "target", explode there */
8728         if (dist <= MAX_RANGE)
8729         {
8730                 /* Mega-Hack -- remove the final "beam" grid */
8731                 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
8732
8733                 /*
8734                  * Create a conical breath attack
8735                  *
8736                  *         ***
8737                  *     ********
8738                  * D********@**
8739                  *     ********
8740                  *         ***
8741                  */
8742
8743                 if (breath)
8744                 {
8745                         flg &= ~(PROJECT_HIDE);
8746
8747                         breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
8748                 }
8749                 else
8750                 {
8751                         /* Determine the blast area, work from the inside out */
8752                         for (dist = 0; dist <= rad; dist++)
8753                         {
8754                                 /* Scan the maximal blast area of radius "dist" */
8755                                 for (y = by - dist; y <= by + dist; y++)
8756                                 {
8757                                         for (x = bx - dist; x <= bx + dist; x++)
8758                                         {
8759                                                 /* Ignore "illegal" locations */
8760                                                 if (!in_bounds2(y, x)) continue;
8761
8762                                                 /* Enforce a "circular" explosion */
8763                                                 if (distance(by, bx, y, x) != dist) continue;
8764
8765                                                 switch (typ)
8766                                                 {
8767                                                 case GF_LITE:
8768                                                 case GF_LITE_WEAK:
8769                                                         /* Lights are stopped by opaque terrains */
8770                                                         if (!los(by, bx, y, x)) continue;
8771                                                         break;
8772                                                 case GF_DISINTEGRATE:
8773                                                         /* Disintegration are stopped only by perma-walls */
8774                                                         if (!in_disintegration_range(by, bx, y, x)) continue;
8775                                                         break;
8776                                                 default:
8777                                                         /* Ball explosions are stopped by walls */
8778                                                         if (!projectable(by, bx, y, x)) continue;
8779                                                         break;
8780                                                 }
8781
8782                                                 /* Save this grid */
8783                                                 gy[grids] = y;
8784                                                 gx[grids] = x;
8785                                                 grids++;
8786                                         }
8787                                 }
8788
8789                                 /* Encode some more "radius" info */
8790                                 gm[dist+1] = grids;
8791                         }
8792                 }
8793         }
8794
8795         /* Speed -- ignore "non-explosions" */
8796         if (!grids) return (FALSE);
8797
8798
8799         /* Display the "blast area" if requested */
8800         if (!blind && !(flg & (PROJECT_HIDE)))
8801         {
8802                 /* Then do the "blast", from inside out */
8803                 for (t = 0; t <= gm_rad; t++)
8804                 {
8805                         /* Dump everything with this radius */
8806                         for (i = gm[t]; i < gm[t+1]; i++)
8807                         {
8808                                 /* Extract the location */
8809                                 y = gy[i];
8810                                 x = gx[i];
8811
8812                                 /* Only do visuals if the player can "see" the blast */
8813                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8814                                 {
8815                                         u16b p;
8816
8817                                         byte a;
8818                                         char c;
8819
8820                                         drawn = TRUE;
8821
8822                                         /* Obtain the explosion pict */
8823                                         p = bolt_pict(y, x, y, x, typ);
8824
8825                                         /* Extract attr/char */
8826                                         a = PICT_A(p);
8827                                         c = PICT_C(p);
8828
8829                                         /* Visual effects -- Display */
8830                                         print_rel(c, a, y, x);
8831                                 }
8832                         }
8833
8834                         /* Hack -- center the cursor */
8835                         move_cursor_relative(by, bx);
8836
8837                         /* Flush each "radius" seperately */
8838                         /*if (fresh_before)*/ Term_fresh();
8839
8840                         /* Delay (efficiently) */
8841                         if (visual || drawn)
8842                         {
8843                                 Term_xtra(TERM_XTRA_DELAY, msec);
8844                         }
8845                 }
8846
8847                 /* Flush the erasing */
8848                 if (drawn)
8849                 {
8850                         /* Erase the explosion drawn above */
8851                         for (i = 0; i < grids; i++)
8852                         {
8853                                 /* Extract the location */
8854                                 y = gy[i];
8855                                 x = gx[i];
8856
8857                                 /* Hack -- Erase if needed */
8858                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8859                                 {
8860                                         lite_spot(y, x);
8861                                 }
8862                         }
8863
8864                         /* Hack -- center the cursor */
8865                         move_cursor_relative(by, bx);
8866
8867                         /* Flush the explosion */
8868                         /*if (fresh_before)*/ Term_fresh();
8869                 }
8870         }
8871
8872
8873         /* Update stuff if needed */
8874         if (p_ptr->update) update_stuff();
8875
8876
8877         /* Check features */
8878         if (flg & (PROJECT_GRID))
8879         {
8880                 /* Start with "dist" of zero */
8881                 dist = 0;
8882
8883                 /* Scan for features */
8884                 for (i = 0; i < grids; i++)
8885                 {
8886                         /* Hack -- Notice new "dist" values */
8887                         if (gm[dist+1] == i) dist++;
8888
8889                         /* Get the grid location */
8890                         y = gy[i];
8891                         x = gx[i];
8892
8893                         /* Find the closest point in the blast */
8894                         if (breath)
8895                         {
8896                                 int d = dist_to_line(y, x, y1, x1, by, bx);
8897
8898                                 /* Affect the grid */
8899                                 if (project_f(who, d, y, x, dam, typ)) notice = TRUE;
8900                         }
8901                         else
8902                         {
8903                                 /* Affect the grid */
8904                                 if (project_f(who, dist, y, x, dam, typ)) notice = TRUE;
8905                         }
8906                 }
8907         }
8908
8909         /* Update stuff if needed */
8910         if (p_ptr->update) update_stuff();
8911
8912         /* Check objects */
8913         if (flg & (PROJECT_ITEM))
8914         {
8915                 /* Start with "dist" of zero */
8916                 dist = 0;
8917
8918                 /* Scan for objects */
8919                 for (i = 0; i < grids; i++)
8920                 {
8921                         /* Hack -- Notice new "dist" values */
8922                         if (gm[dist+1] == i) dist++;
8923
8924                         /* Get the grid location */
8925                         y = gy[i];
8926                         x = gx[i];
8927
8928                         /* Find the closest point in the blast */
8929                         if (breath)
8930                         {
8931                                 int d = dist_to_line(y, x, y1, x1, by, bx);
8932
8933                                 /* Affect the object in the grid */
8934                                 if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
8935                         }
8936                         else
8937                         {
8938                                 /* Affect the object in the grid */
8939                                 if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
8940                         }
8941                 }
8942         }
8943
8944
8945         /* Check monsters */
8946         if (flg & (PROJECT_KILL))
8947         {
8948                 /* Mega-Hack */
8949                 project_m_n = 0;
8950                 project_m_x = 0;
8951                 project_m_y = 0;
8952
8953                 /* Start with "dist" of zero */
8954                 dist = 0;
8955
8956                 /* Scan for monsters */
8957                 for (i = 0; i < grids; i++)
8958                 {
8959                         int effective_dist;
8960
8961                         /* Hack -- Notice new "dist" values */
8962                         if (gm[dist + 1] == i) dist++;
8963
8964                         /* Get the grid location */
8965                         y = gy[i];
8966                         x = gx[i];
8967
8968                         /* A single bolt may be reflected */
8969                         if (grids <= 1)
8970                         {
8971                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
8972                                 monster_race *ref_ptr = &r_info[m_ptr->r_idx];
8973
8974                                 if ((ref_ptr->flags2 & RF2_REFLECTING) && (flg & PROJECT_REFLECTABLE) && (!who || dist_hack > 1) && !one_in_(10))
8975                                 {
8976                                         byte t_y, t_x;
8977                                         int max_attempts = 10;
8978
8979                                         /* Choose 'new' target */
8980                                         do
8981                                         {
8982                                                 t_y = y_saver - 1 + randint1(3);
8983                                                 t_x = x_saver - 1 + randint1(3);
8984                                                 max_attempts--;
8985                                         }
8986                                         while (max_attempts && in_bounds2u(t_y, t_x) && !projectable(y, x, t_y, t_x));
8987
8988                                         if (max_attempts < 1)
8989                                         {
8990                                                 t_y = y_saver;
8991                                                 t_x = x_saver;
8992                                         }
8993
8994                                         if (is_seen(m_ptr))
8995                                         {
8996 #ifdef JP
8997                                                 if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
8998                                                         msg_print("¡ÖËÌÅÍ¿À·ý±üµÁ¡¦Æó»Ø¿¿¶õÇÄ¡ª¡×");
8999                                                 else if (m_ptr->r_idx == MON_DIO) msg_print("¥Ç¥£¥ª¡¦¥Ö¥é¥ó¥É¡¼¤Ï»Ø°ìËܤǹ¶·â¤òÃƤ­ÊÖ¤·¤¿¡ª");
9000                                                 else msg_print("¹¶·â¤ÏÄ·¤ÍÊ֤ä¿¡ª");
9001 #else
9002                                                 msg_print("The attack bounces!");
9003 #endif
9004                                         }
9005                                         if (is_original_ap_and_seen(m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
9006
9007                                         /* Reflected bolts randomly target either one */
9008                                         if (one_in_(2)) flg |= PROJECT_PLAYER;
9009                                         else flg &= ~(PROJECT_PLAYER);
9010
9011                                         /* The bolt is reflected */
9012                                         project(cave[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
9013
9014                                         /* Don't affect the monster any longer */
9015                                         continue;
9016                                 }
9017                         }
9018
9019
9020                         /* Find the closest point in the blast */
9021                         if (breath)
9022                         {
9023                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
9024                         }
9025                         else
9026                         {
9027                                 effective_dist = dist;
9028                         }
9029
9030
9031                         /* There is the riding player on this monster */
9032                         if (p_ptr->riding && player_bold(y, x))
9033                         {
9034                                 /* Aimed on the player */
9035                                 if (flg & PROJECT_PLAYER)
9036                                 {
9037                                         if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
9038                                         {
9039                                                 /*
9040                                                  * A beam or bolt is well aimed
9041                                                  * at the PLAYER!
9042                                                  * So don't affects the mount.
9043                                                  */
9044                                                 continue;
9045                                         }
9046                                         else
9047                                         {
9048                                                 /*
9049                                                  * The spell is not well aimed, 
9050                                                  * So partly affect the mount too.
9051                                                  */
9052                                                 effective_dist++;
9053                                         }
9054                                 }
9055
9056                                 /*
9057                                  * This grid is the original target.
9058                                  * Or aimed on your horse.
9059                                  */
9060                                 else if (((y == y2) && (x == x2)) || (flg & PROJECT_AIMED))
9061                                 {
9062                                         /* Hit the mount with full damage */
9063                                 }
9064
9065                                 /*
9066                                  * Otherwise this grid is not the
9067                                  * original target, it means that line
9068                                  * of fire is obstructed by this
9069                                  * monster.
9070                                  */
9071                                 /*
9072                                  * A beam or bolt will hit either
9073                                  * player or mount.  Choose randomly.
9074                                  */
9075                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
9076                                 {
9077                                         if (one_in_(2))
9078                                         {
9079                                                 /* Hit the mount with full damage */
9080                                         }
9081                                         else
9082                                         {
9083                                                 /* Hit the player later */
9084                                                 flg |= PROJECT_PLAYER;
9085
9086                                                 /* Don't affect the mount */
9087                                                 continue;
9088                                         }
9089                                 }
9090
9091                                 /*
9092                                  * The spell is not well aimed, so
9093                                  * partly affect both player and
9094                                  * mount.
9095                                  */
9096                                 else
9097                                 {
9098                                         effective_dist++;
9099                                 }
9100                         }
9101
9102                         /* Affect the monster in the grid */
9103                         if (project_m(who, effective_dist, y, x, dam, typ,flg)) notice = TRUE;
9104                 }
9105
9106
9107                 /* Player affected one monster (without "jumping") */
9108                 if (!who && (project_m_n == 1) && !jump)
9109                 {
9110                         /* Location */
9111                         x = project_m_x;
9112                         y = project_m_y;
9113
9114                         /* Track if possible */
9115                         if (cave[y][x].m_idx > 0)
9116                         {
9117                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
9118
9119                                 /* Hack -- auto-recall */
9120                                 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
9121
9122                                 /* Hack - auto-track */
9123                                 if (m_ptr->ml) health_track(cave[y][x].m_idx);
9124                         }
9125                 }
9126         }
9127
9128
9129         /* Check player */
9130         if (flg & (PROJECT_KILL))
9131         {
9132                 /* Start with "dist" of zero */
9133                 dist = 0;
9134
9135                 /* Scan for player */
9136                 for (i = 0; i < grids; i++)
9137                 {
9138                         int effective_dist;
9139
9140                         /* Hack -- Notice new "dist" values */
9141                         if (gm[dist+1] == i) dist++;
9142
9143                         /* Get the grid location */
9144                         y = gy[i];
9145                         x = gx[i];
9146
9147                         /* Affect the player? */
9148                         if (!player_bold(y, x)) continue;
9149
9150                         /* Find the closest point in the blast */
9151                         if (breath)
9152                         {
9153                                 effective_dist = dist_to_line(y, x, y1, x1, by, bx);
9154                         }
9155                         else
9156                         {
9157                                 effective_dist = dist;
9158                         }
9159
9160                         /* Target may be your horse */
9161                         if (p_ptr->riding)
9162                         {
9163                                 /* Aimed on the player */
9164                                 if (flg & PROJECT_PLAYER)
9165                                 {
9166                                         /* Hit the player with full damage */
9167                                 }
9168
9169                                 /*
9170                                  * Hack -- When this grid was not the
9171                                  * original target, a beam or bolt
9172                                  * would hit either player or mount,
9173                                  * and should be choosen randomly.
9174                                  *
9175                                  * But already choosen to hit the
9176                                  * mount at this point.
9177                                  *
9178                                  * Or aimed on your horse.
9179                                  */
9180                                 else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE | PROJECT_AIMED))
9181                                 {
9182                                         /*
9183                                          * A beam or bolt is well aimed
9184                                          * at the mount!
9185                                          * So don't affects the player.
9186                                          */
9187                                         continue;
9188                                 }
9189                                 else
9190                                 {
9191                                         /*
9192                                          * The spell is not well aimed, 
9193                                          * So partly affect the player too.
9194                                          */
9195                                         effective_dist++;
9196                                 }
9197                         }
9198
9199                         /* Affect the player */
9200                         if (project_p(who, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
9201                 }
9202         }
9203
9204         if (p_ptr->riding)
9205         {
9206                 char m_name[80];
9207
9208                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
9209
9210                 if (rakubadam_m > 0)
9211                 {
9212                         if (rakuba(rakubadam_m, FALSE))
9213                         {
9214 #ifdef JP
9215 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
9216 #else
9217                                 msg_format("%^s has thrown you off!", m_name);
9218 #endif
9219                         }
9220                 }
9221                 if (p_ptr->riding && rakubadam_p > 0)
9222                 {
9223                         if(rakuba(rakubadam_p, FALSE))
9224                         {
9225 #ifdef JP
9226 msg_format("%^s¤«¤éÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª", m_name);
9227 #else
9228                                 msg_format("You have fallen from %s.", m_name);
9229 #endif
9230                         }
9231                 }
9232         }
9233
9234         /* Return "something was noticed" */
9235         return (notice);
9236 }
9237
9238 bool binding_field( int dam )
9239 {
9240         int mirror_x[10],mirror_y[10]; /* ¶À¤Ï¤â¤Ã¤È¾¯¤Ê¤¤ */
9241         int mirror_num=0;              /* ¶À¤Î¿ô */
9242         int x,y;
9243         int centersign;
9244         int x1,x2,y1,y2;
9245         u16b p;
9246         int msec= delay_factor*delay_factor*delay_factor;
9247
9248         /* »°³Ñ·Á¤ÎĺÅÀ */
9249         int point_x[3];
9250         int point_y[3];
9251
9252         /* Default target of monsterspell is player */
9253         monster_target_y=py;
9254         monster_target_x=px;
9255
9256         for( x=0 ; x < cur_wid ; x++ )
9257         {
9258                 for( y=0 ; y < cur_hgt ; y++ )
9259                 {
9260                         if( is_mirror_grid(&cave[y][x]) &&
9261                             distance(py,px,y,x) <= MAX_RANGE &&
9262                             distance(py,px,y,x) != 0 &&
9263                             player_has_los_bold(y,x) &&
9264                             projectable(py, px, y, x)
9265                             ){
9266                                 mirror_y[mirror_num]=y;
9267                                 mirror_x[mirror_num]=x;
9268                                 mirror_num++;
9269                         }
9270                 }
9271         }
9272
9273         if( mirror_num < 2 )return FALSE;
9274
9275         point_x[0] = randint0( mirror_num );
9276         do {
9277           point_x[1] = randint0( mirror_num );
9278         }
9279         while( point_x[0] == point_x[1] );
9280
9281         point_y[0]=mirror_y[point_x[0]];
9282         point_x[0]=mirror_x[point_x[0]];
9283         point_y[1]=mirror_y[point_x[1]];
9284         point_x[1]=mirror_x[point_x[1]];
9285         point_y[2]=py;
9286         point_x[2]=px;
9287
9288         x=point_x[0]+point_x[1]+point_x[2];
9289         y=point_y[0]+point_y[1]+point_y[2];
9290
9291         centersign = (point_x[0]*3-x)*(point_y[1]*3-y)
9292                 - (point_y[0]*3-y)*(point_x[1]*3-x);
9293         if( centersign == 0 )return FALSE;
9294                             
9295         x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
9296         x1 = x1 < point_x[2] ? x1 : point_x[2];
9297         y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
9298         y1 = y1 < point_y[2] ? y1 : point_y[2];
9299
9300         x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
9301         x2 = x2 > point_x[2] ? x2 : point_x[2];
9302         y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
9303         y2 = y2 > point_y[2] ? y2 : point_y[2];
9304
9305         for( y=y1 ; y <=y2 ; y++ ){
9306                 for( x=x1 ; x <=x2 ; x++ ){
9307                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
9308                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
9309                             centersign*( (point_x[1]-x)*(point_y[2]-y)
9310                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
9311                             centersign*( (point_x[2]-x)*(point_y[0]-y)
9312                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
9313                         {
9314                                 if (player_has_los_bold(y, x) && projectable(py, px, y, x)) {
9315                                         /* Visual effects */
9316                                         if(!(p_ptr->blind)
9317                                            && panel_contains(y,x)){
9318                                           p = bolt_pict(y,x,y,x, GF_MANA );
9319                                           print_rel(PICT_C(p), PICT_A(p),y,x);
9320                                           move_cursor_relative(y, x);
9321                                           /*if (fresh_before)*/ Term_fresh();
9322                                           Term_xtra(TERM_XTRA_DELAY, msec);
9323                                         }
9324                                 }
9325                         }
9326                 }
9327         }
9328         for( y=y1 ; y <=y2 ; y++ ){
9329                 for( x=x1 ; x <=x2 ; x++ ){
9330                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
9331                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
9332                             centersign*( (point_x[1]-x)*(point_y[2]-y)
9333                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
9334                             centersign*( (point_x[2]-x)*(point_y[0]-y)
9335                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
9336                         {
9337                                 if (player_has_los_bold(y, x) && projectable(py, px, y, x)) {
9338                                         (void)project_f(0,0,y,x,dam,GF_MANA); 
9339                                 }
9340                         }
9341                 }
9342         }
9343         for( y=y1 ; y <=y2 ; y++ ){
9344                 for( x=x1 ; x <=x2 ; x++ ){
9345                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
9346                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
9347                             centersign*( (point_x[1]-x)*(point_y[2]-y)
9348                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
9349                             centersign*( (point_x[2]-x)*(point_y[0]-y)
9350                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
9351                         {
9352                                 if (player_has_los_bold(y, x) && projectable(py, px, y, x)) {
9353                                         (void)project_o(0,0,y,x,dam,GF_MANA); 
9354                                 }
9355                         }
9356                 }
9357         }
9358         for( y=y1 ; y <=y2 ; y++ ){
9359                 for( x=x1 ; x <=x2 ; x++ ){
9360                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
9361                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
9362                             centersign*( (point_x[1]-x)*(point_y[2]-y)
9363                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
9364                             centersign*( (point_x[2]-x)*(point_y[0]-y)
9365                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
9366                         {
9367                                 if (player_has_los_bold(y, x) && projectable(py, px, y, x)) {
9368                                         (void)project_m(0,0,y,x,dam,GF_MANA,
9369                                           (PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP));
9370                                 }
9371                         }
9372                 }
9373         }
9374         if( one_in_(7) ){
9375 #ifdef JP
9376                 msg_print("¶À¤¬·ë³¦¤ËÂѤ¨¤­¤ì¤º¡¢²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡£");
9377 #else
9378                 msg_print("The field broke a mirror");
9379 #endif  
9380                 remove_mirror(point_y[0],point_x[0]);
9381         }
9382
9383         return TRUE;
9384 }
9385
9386 void seal_of_mirror( int dam )
9387 {
9388         int x,y;
9389
9390         for( x = 0 ; x < cur_wid ; x++ )
9391         {
9392                 for( y = 0 ; y < cur_hgt ; y++ )
9393                 {
9394                         if( is_mirror_grid(&cave[y][x]))
9395                         {
9396                                 if(project_m(0,0,y,x,dam,GF_GENOCIDE,
9397                                                          (PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP)))
9398                                 {
9399                                         if( !cave[y][x].m_idx )
9400                                         {
9401                                                 remove_mirror(y,x);
9402                                         }
9403                                 }
9404                         }
9405                 }
9406         }
9407         return;
9408 }
9409