OSDN Git Service

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