OSDN Git Service

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