OSDN Git Service

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