OSDN Git Service

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