OSDN Git Service

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