OSDN Git Service

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