OSDN Git Service

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