OSDN Git Service

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