OSDN Git Service

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