OSDN Git Service

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