OSDN Git Service

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