OSDN Git Service

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