OSDN Git Service

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