OSDN Git Service

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