OSDN Git Service

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