OSDN Git Service

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