OSDN Git Service

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