OSDN Git Service

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