OSDN Git Service

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