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                         else 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                         else 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                         else if (r_ptr->flags3 & (RF3_HURT_COLD))
3279                         {
3280 #ifdef JP
3281 note = "¤Ï¤Ò¤É¤¤Ä˼ê¤ò¤¦¤±¤¿¡£";
3282 #else
3283                                 note = " is hit hard.";
3284 #endif
3285
3286                                 dam *= 2;
3287                                 if (seen) r_ptr->r_flags3 |= (RF3_HURT_COLD);
3288                         }
3289                         break;
3290                 }
3291
3292
3293                 /* Drain Life */
3294                 case GF_OLD_DRAIN:
3295                 {
3296                         if (seen) obvious = TRUE;
3297
3298                         if (r_ptr->flags3 & (RF3_RES_ALL))
3299                         {
3300 #ifdef JP
3301                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
3302 #else
3303                                 note = " is immune.";
3304 #endif
3305                                 dam = 0;
3306                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3307                                 break;
3308                         }
3309                         if (!monster_living(r_ptr))
3310                         {
3311                                 if (r_ptr->flags3 & RF3_UNDEAD)
3312                                 {
3313                                         if (seen) r_ptr->r_flags3 |= (RF3_UNDEAD);
3314                                 }
3315
3316                                 if (r_ptr->flags3 & (RF3_DEMON))
3317                                 {
3318                                         if (seen) r_ptr->r_flags3 |= (RF3_DEMON);
3319                                 }
3320
3321 #ifdef JP
3322 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3323 #else
3324                                 note = " is unaffected!";
3325 #endif
3326
3327                                 obvious = FALSE;
3328                                 dam = 0;
3329                         }
3330                         else do_time = (dam+7)/8;
3331
3332                         break;
3333                 }
3334
3335                 /* Death Ray */
3336                 case GF_DEATH_RAY:
3337                 {
3338                         if (seen) obvious = TRUE;
3339
3340                         if (r_ptr->flags3 & (RF3_RES_ALL))
3341                         {
3342 #ifdef JP
3343                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
3344 #else
3345                                 note = " is immune.";
3346 #endif
3347                                 dam = 0;
3348                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3349                                 break;
3350                         }
3351                         if ((r_ptr->flags3 & RF3_UNDEAD) ||
3352                             (r_ptr->flags3 & RF3_NONLIVING))
3353                         {
3354                                 if (r_ptr->flags3 & RF3_UNDEAD)
3355                                 {
3356                                         if (seen) r_ptr->r_flags3 |= (RF3_UNDEAD);
3357                                 }
3358
3359 #ifdef JP
3360 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡£";
3361 #else
3362                                 note = " is immune.";
3363 #endif
3364
3365                                 obvious = FALSE;
3366                                 dam = 0;
3367                         }
3368                         else if (((r_ptr->flags1 & RF1_UNIQUE) &&
3369                                  (randint1(888) != 666)) ||
3370                                  (((r_ptr->level + randint1(20)) > randint1(p_ptr->lev + randint1(10))) &&
3371                                  randint1(100) != 66))
3372                         {
3373 #ifdef JP
3374 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
3375 #else
3376                                 note = " resists!";
3377 #endif
3378
3379                                 obvious = FALSE;
3380                                 dam = 0;
3381                         }
3382
3383                         break;
3384                 }
3385
3386                 /* Polymorph monster (Use "dam" as "power") */
3387                 case GF_OLD_POLY:
3388                 {
3389                         if (seen) obvious = TRUE;
3390
3391                         if (r_ptr->flags3 & (RF3_RES_ALL))
3392                         {
3393 #ifdef JP
3394                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3395 #else
3396                                 note = " is immune.";
3397 #endif
3398                                 dam = 0;
3399                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3400                                 break;
3401                         }
3402                         /* Attempt to polymorph (see below) */
3403                         do_poly = TRUE;
3404
3405                         /* Powerful monsters can resist */
3406                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3407                             (r_ptr->flags1 & RF1_QUESTOR) ||
3408                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3409                         {
3410 #ifdef JP
3411 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
3412 #else
3413                                 note = " is unaffected!";
3414 #endif
3415
3416                                 do_poly = FALSE;
3417                                 obvious = FALSE;
3418                         }
3419
3420                         /* No "real" damage */
3421                         dam = 0;
3422
3423                         break;
3424                 }
3425
3426
3427                 /* Clone monsters (Ignore "dam") */
3428                 case GF_OLD_CLONE:
3429                 {
3430                         bool friendly = FALSE;
3431                         bool pet = FALSE;
3432
3433                         if (seen) obvious = TRUE;
3434
3435                         if (is_pet(m_ptr) || (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & (RF7_UNIQUE_7 | RF7_UNIQUE2)))
3436                         {
3437 #ifdef JP
3438 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
3439 #else
3440  note = " is unaffected!";
3441 #endif
3442                         }
3443                         else
3444                         {
3445                                 /* Heal fully */
3446                                 m_ptr->hp = m_ptr->maxhp;
3447
3448                                 /* Attempt to clone. */
3449                                 if (multiply_monster(c_ptr->m_idx, TRUE, friendly, pet))
3450                                 {
3451 #ifdef JP
3452 note = "¤¬Ê¬Îö¤·¤¿¡ª";
3453 #else
3454                                         note = " spawns!";
3455 #endif
3456
3457                                 }
3458                         }
3459
3460                         /* No "real" damage */
3461                         dam = 0;
3462
3463                         break;
3464                 }
3465
3466
3467                 /* Heal Monster (use "dam" as amount of healing) */
3468                 case GF_STAR_HEAL:
3469                 {
3470                         if (seen) obvious = TRUE;
3471
3472                         /* Wake up */
3473                         m_ptr->csleep = 0;
3474
3475                         if (m_ptr->maxhp < m_ptr->max_maxhp)
3476                         {
3477 #ifdef JP
3478 msg_format("%^s¤Î¶¯¤µ¤¬Ìá¤Ã¤¿¡£", m_name);
3479 #else
3480                                 msg_format("%^s recovers %s vitality.", m_name, m_poss);
3481 #endif
3482                                 m_ptr->maxhp = m_ptr->max_maxhp;
3483                         }
3484                         if (!dam) break;
3485                 }
3486                 case GF_OLD_HEAL:
3487                 {
3488                         if (seen) obvious = TRUE;
3489
3490                         /* Wake up */
3491                         m_ptr->csleep = 0;
3492
3493                         if (m_ptr->stunned)
3494                         {
3495 #ifdef JP
3496 msg_format("%^s¤ÏÛ¯Û°¾õÂÖ¤«¤éΩ¤Áľ¤Ã¤¿¡£", m_name);
3497 #else
3498                                 msg_format("%^s is no longer stunned.", m_name);
3499 #endif
3500                                 m_ptr->stunned = 0;
3501                         }
3502                         if (m_ptr->confused)
3503                         {
3504 #ifdef JP
3505 msg_format("%^s¤Ïº®Í𤫤éΩ¤Áľ¤Ã¤¿¡£", m_name);
3506 #else
3507                                 msg_format("%^s is no longer confused.", m_name);
3508 #endif
3509                                 m_ptr->confused = 0;
3510                         }
3511                         if (m_ptr->monfear)
3512                         {
3513 #ifdef JP
3514 msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
3515 #else
3516                                 msg_format("%^s recovers %s courage.", m_name, m_poss);
3517 #endif
3518                                 m_ptr->monfear = 0;
3519                         }
3520
3521                         /* Heal */
3522                         if (m_ptr->hp < 30000) m_ptr->hp += dam;
3523
3524                         /* No overflow */
3525                         if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
3526
3527                         chg_virtue(V_VITALITY, 1);
3528                         
3529                         if (r_ptr->flags1 & RF1_UNIQUE)
3530                                 chg_virtue(V_INDIVIDUALISM, 1);
3531         
3532                         if (is_friendly(m_ptr))
3533                                 chg_virtue(V_HONOUR, 1);
3534                         else if (!(r_ptr->flags3 & RF3_EVIL))
3535                         {
3536                                 if (r_ptr->flags3 & RF3_GOOD)
3537                                         chg_virtue(V_COMPASSION, 2);
3538                                 else
3539                                         chg_virtue(V_COMPASSION, 1);
3540                         }
3541
3542                         if (m_ptr->r_idx == MON_LEPER)
3543                         {
3544                                 heal_leper = TRUE;
3545                                 chg_virtue(V_COMPASSION, 5);
3546                         }
3547         
3548                         if (r_ptr->flags3 & RF3_ANIMAL)
3549                                 chg_virtue(V_NATURE, 1);
3550
3551                         /* Redraw (later) if needed */
3552                         if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
3553                         if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
3554
3555                         /* Message */
3556 #ifdef JP
3557 note = "¤ÏÂÎÎϤò²óÉü¤·¤¿¤è¤¦¤À¡£";
3558 #else
3559                         note = " looks healthier.";
3560 #endif
3561
3562
3563                         /* No "real" damage */
3564                         dam = 0;
3565                         break;
3566                 }
3567
3568
3569                 /* Speed Monster (Ignore "dam") */
3570                 case GF_OLD_SPEED:
3571                 {
3572                         if (seen) obvious = TRUE;
3573
3574                         /* Speed up */
3575                         if (!m_ptr->fast)
3576                         {
3577 #ifdef JP
3578 note = "¤ÎÆ°¤­¤¬Â®¤¯¤Ê¤Ã¤¿¡£";
3579 #else
3580                                 note = " starts moving faster.";
3581 #endif
3582                         }
3583                         m_ptr->fast = MIN(200, m_ptr->fast + 100);
3584
3585                         if (c_ptr->m_idx == p_ptr->riding)
3586                                 p_ptr->update |= (PU_BONUS);
3587
3588                         if (r_ptr->flags1 & RF1_UNIQUE)
3589                                 chg_virtue(V_INDIVIDUALISM, 1);
3590                         if (is_friendly(m_ptr))
3591                                 chg_virtue(V_HONOUR, 1);
3592
3593                         /* No "real" damage */
3594                         dam = 0;
3595                         break;
3596                 }
3597
3598
3599                 /* Slow Monster (Use "dam" as "power") */
3600                 case GF_OLD_SLOW:
3601                 {
3602                         if (seen) obvious = TRUE;
3603
3604                         if (r_ptr->flags3 & (RF3_RES_ALL))
3605                         {
3606 #ifdef JP
3607                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3608 #else
3609                                 note = " is immune.";
3610 #endif
3611                                 dam = 0;
3612                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3613                                 break;
3614                         }
3615                         /* Powerful monsters can resist */
3616                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3617                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3618                         {
3619 #ifdef JP
3620 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3621 #else
3622                                 note = " is unaffected!";
3623 #endif
3624
3625                                 obvious = FALSE;
3626                         }
3627
3628                         /* Normal monsters slow down */
3629                         else
3630                         {
3631                                 if (!m_ptr->slow)
3632                                 {
3633 #ifdef JP
3634 note = "¤ÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤¿¡£";
3635 #else
3636                                         note = " starts moving slower.";
3637 #endif
3638                                 }
3639                                 m_ptr->slow = MIN(200, m_ptr->slow + 50);
3640
3641                                 if (c_ptr->m_idx == p_ptr->riding)
3642                                         p_ptr->update |= (PU_BONUS);
3643                         }
3644
3645                         /* No "real" damage */
3646                         dam = 0;
3647                         break;
3648                 }
3649
3650
3651                 /* Sleep (Use "dam" as "power") */
3652                 case GF_OLD_SLEEP:
3653                 {
3654                         if (seen) obvious = TRUE;
3655
3656                         if (r_ptr->flags3 & (RF3_RES_ALL))
3657                         {
3658 #ifdef JP
3659                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3660 #else
3661                                 note = " is immune.";
3662 #endif
3663                                 dam = 0;
3664                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3665                                 break;
3666                         }
3667                         /* Attempt a saving throw */
3668                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3669                             (r_ptr->flags3 & RF3_NO_SLEEP) ||
3670                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3671                         {
3672                                 /* Memorize a flag */
3673                                 if (r_ptr->flags3 & RF3_NO_SLEEP)
3674                                 {
3675                                         if (seen) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
3676                                 }
3677
3678                                 /* No obvious effect */
3679 #ifdef JP
3680 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3681 #else
3682                                 note = " is unaffected!";
3683 #endif
3684
3685                                 obvious = FALSE;
3686                         }
3687                         else
3688                         {
3689                                 /* Go to sleep (much) later */
3690 #ifdef JP
3691 note = "¤Ï̲¤ê¹þ¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
3692 #else
3693                                 note = " falls asleep!";
3694 #endif
3695
3696                                 do_sleep = 500;
3697                         }
3698
3699                         /* No "real" damage */
3700                         dam = 0;
3701                         break;
3702                 }
3703
3704
3705                 /* Sleep (Use "dam" as "power") */
3706                 case GF_STASIS:
3707                 {
3708                         if (seen) obvious = TRUE;
3709
3710                         if (r_ptr->flags3 & (RF3_RES_ALL))
3711                         {
3712 #ifdef JP
3713                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3714 #else
3715                                 note = " is immune.";
3716 #endif
3717                                 dam = 0;
3718                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3719                                 break;
3720                         }
3721                         /* Attempt a saving throw */
3722                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
3723                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3724                         {
3725 #ifdef JP
3726 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3727 #else
3728                                 note = " is unaffected!";
3729 #endif
3730
3731                                 obvious = FALSE;
3732                         }
3733                         else
3734                         {
3735                                 /* Go to sleep (much) later */
3736 #ifdef JP
3737 note = "¤ÏÆ°¤±¤Ê¤¯¤Ê¤Ã¤¿¡ª";
3738 #else
3739                                 note = " is suspended!";
3740 #endif
3741
3742                                 do_sleep = 500;
3743                         }
3744
3745                         /* No "real" damage */
3746                         dam = 0;
3747                         break;
3748                 }
3749
3750                 /* Charm monster */
3751                 case GF_CHARM:
3752                 {
3753                         int vir;
3754                         dam += (adj_con_fix[p_ptr->stat_ind[A_CHR]] - 1);
3755                         vir = virtue_number(V_HARMONY);
3756                         if (vir)
3757                         {
3758                                 dam += p_ptr->virtues[vir-1]/10;
3759                         }
3760
3761                         vir = virtue_number(V_INDIVIDUALISM);
3762                         if (vir)
3763                         {
3764                                 dam -= p_ptr->virtues[vir-1]/20;
3765                         }
3766
3767                         if (seen) obvious = TRUE;
3768
3769                         if ((r_ptr->flags3 & (RF3_RES_ALL)) || p_ptr->inside_arena)
3770                         {
3771 #ifdef JP
3772                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3773 #else
3774                                 note = " is immune.";
3775 #endif
3776                                 dam = 0;
3777                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3778                                 break;
3779                         }
3780
3781                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))
3782                                 dam = dam * 2 / 3;
3783
3784                         /* Attempt a saving throw */
3785                         if ((r_ptr->flags1 & RF1_QUESTOR) ||
3786                             (r_ptr->flags3 & RF3_NO_CONF) ||
3787                             (m_ptr->mflag2 & MFLAG_NOPET) ||
3788                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 5))
3789                         {
3790                                 /* Memorize a flag */
3791                                 if (r_ptr->flags3 & RF3_NO_CONF)
3792                                 {
3793                                         if (seen) r_ptr->r_flags3 |= (RF3_NO_CONF);
3794                                 }
3795
3796                                 /* Resist */
3797                                 /* No obvious effect */
3798 #ifdef JP
3799 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3800 #else
3801                                 note = " is unaffected!";
3802 #endif
3803
3804                                 obvious = FALSE;
3805
3806                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
3807                         }
3808                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3809                         {
3810 #ifdef JP
3811 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
3812 #else
3813                                 note = " hates you too much!";
3814 #endif
3815
3816                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
3817                         }
3818                         else
3819                         {
3820 #ifdef JP
3821 note = "¤ÏÆÍÁ³Í§¹¥Åª¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡ª";
3822 #else
3823                                 note = " suddenly seems friendly!";
3824 #endif
3825
3826                                 set_pet(m_ptr);
3827
3828                                 chg_virtue(V_INDIVIDUALISM, -1);
3829                                 if (r_ptr->flags3 & RF3_ANIMAL)
3830                                         chg_virtue(V_NATURE, 1);
3831                         }
3832
3833                         /* No "real" damage */
3834                         dam = 0;
3835                         break;
3836                 }
3837
3838                 /* Control undead */
3839                 case GF_CONTROL_UNDEAD:
3840                 {
3841                         int vir;
3842                         if (seen) obvious = TRUE;
3843
3844                         vir = virtue_number(V_UNLIFE);
3845                         if (vir)
3846                         {
3847                                 dam += p_ptr->virtues[vir-1]/10;
3848                         }
3849
3850                         vir = virtue_number(V_INDIVIDUALISM);
3851                         if (vir)
3852                         {
3853                                 dam -= p_ptr->virtues[vir-1]/20;
3854                         }
3855
3856                         if ((r_ptr->flags3 & (RF3_RES_ALL)) || p_ptr->inside_arena)
3857                         {
3858 #ifdef JP
3859                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3860 #else
3861                                 note = " is immune.";
3862 #endif
3863                                 dam = 0;
3864                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3865                                 break;
3866                         }
3867
3868                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))
3869                                 dam = dam * 2 / 3;
3870
3871                         /* Attempt a saving throw */
3872                         if ((r_ptr->flags1 & RF1_QUESTOR) ||
3873                           (!(r_ptr->flags3 & RF3_UNDEAD)) ||
3874                             (m_ptr->mflag2 & MFLAG_NOPET) ||
3875                                  (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3876                         {
3877                                 /* No obvious effect */
3878 #ifdef JP
3879 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3880 #else
3881                                 note = " is unaffected!";
3882 #endif
3883
3884                                 obvious = FALSE;
3885                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
3886                         }
3887                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3888                         {
3889 #ifdef JP
3890 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
3891 #else
3892                                 note = " hates you too much!";
3893 #endif
3894
3895                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
3896                         }
3897                         else
3898                         {
3899 #ifdef JP
3900 note = "¤Ï´û¤Ë¤¢¤Ê¤¿¤ÎÅÛÎì¤À¡ª";
3901 #else
3902                                 note = " is in your thrall!";
3903 #endif
3904
3905                                 set_pet(m_ptr);
3906                         }
3907
3908                         /* No "real" damage */
3909                         dam = 0;
3910                         break;
3911                 }
3912
3913                 /* Control demon */
3914                 case GF_CONTROL_DEMON:
3915                 {
3916                         int vir;
3917                         if (seen) obvious = TRUE;
3918
3919                         vir = virtue_number(V_UNLIFE);
3920                         if (vir)
3921                         {
3922                                 dam += p_ptr->virtues[vir-1]/10;
3923                         }
3924
3925                         vir = virtue_number(V_INDIVIDUALISM);
3926                         if (vir)
3927                         {
3928                                 dam -= p_ptr->virtues[vir-1]/20;
3929                         }
3930
3931                         if ((r_ptr->flags3 & (RF3_RES_ALL)) || p_ptr->inside_arena)
3932                         {
3933 #ifdef JP
3934                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3935 #else
3936                                 note = " is immune.";
3937 #endif
3938                                 dam = 0;
3939                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
3940                                 break;
3941                         }
3942
3943                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))
3944                                 dam = dam * 2 / 3;
3945
3946                         /* Attempt a saving throw */
3947                         if ((r_ptr->flags1 & RF1_QUESTOR) ||
3948                           (!(r_ptr->flags3 & RF3_DEMON)) ||
3949                             (m_ptr->mflag2 & MFLAG_NOPET) ||
3950                                  (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
3951                         {
3952                                 /* No obvious effect */
3953 #ifdef JP
3954 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
3955 #else
3956                                 note = " is unaffected!";
3957 #endif
3958
3959                                 obvious = FALSE;
3960                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
3961                         }
3962                         else if (p_ptr->cursed & TRC_AGGRAVATE)
3963                         {
3964 #ifdef JP
3965 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
3966 #else
3967                                 note = " hates you too much!";
3968 #endif
3969
3970                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
3971                         }
3972                         else
3973                         {
3974 #ifdef JP
3975 note = "¤Ï´û¤Ë¤¢¤Ê¤¿¤ÎÅÛÎì¤À¡ª";
3976 #else
3977                                 note = " is in your thrall!";
3978 #endif
3979
3980                                 set_pet(m_ptr);
3981                         }
3982
3983                         /* No "real" damage */
3984                         dam = 0;
3985                         break;
3986                 }
3987
3988                 /* Tame animal */
3989                 case GF_CONTROL_ANIMAL:
3990                 {
3991                         int vir;
3992
3993                         if (seen) obvious = TRUE;
3994
3995                         vir = virtue_number(V_NATURE);
3996                         if (vir)
3997                         {
3998                                 dam += p_ptr->virtues[vir-1]/10;
3999                         }
4000
4001                         vir = virtue_number(V_INDIVIDUALISM);
4002                         if (vir)
4003                         {
4004                                 dam -= p_ptr->virtues[vir-1]/20;
4005                         }
4006
4007                         if ((r_ptr->flags3 & (RF3_RES_ALL)) || p_ptr->inside_arena)
4008                         {
4009 #ifdef JP
4010                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4011 #else
4012                                 note = " is immune.";
4013 #endif
4014                                 dam = 0;
4015                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4016                                 break;
4017                         }
4018
4019                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))
4020                                 dam = dam * 2 / 3;
4021
4022                         /* Attempt a saving throw */
4023                         if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
4024                           (!(r_ptr->flags3 & (RF3_ANIMAL))) ||
4025                             (m_ptr->mflag2 & MFLAG_NOPET) ||
4026                                  (r_ptr->flags3 & (RF3_NO_CONF)) ||
4027                                  (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4028                         {
4029                                 /* Memorize a flag */
4030                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4031                                 {
4032                                         if (seen) r_ptr->r_flags3 |= (RF3_NO_CONF);
4033                                 }
4034
4035                                 /* Resist */
4036                                 /* No obvious effect */
4037 #ifdef JP
4038 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4039 #else
4040                                 note = " is unaffected!";
4041 #endif
4042
4043                                 obvious = FALSE;
4044                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
4045                         }
4046                         else if (p_ptr->cursed & TRC_AGGRAVATE)
4047                         {
4048 #ifdef JP
4049 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
4050 #else
4051                                 note = " hates you too much!";
4052 #endif
4053
4054                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
4055                         }
4056                         else
4057                         {
4058 #ifdef JP
4059 note = "¤Ï¤Ê¤Ä¤¤¤¿¡£";
4060 #else
4061                                 note = " is tamed!";
4062 #endif
4063
4064                                 set_pet(m_ptr);
4065
4066                                 if (r_ptr->flags3 & RF3_ANIMAL)
4067                                         chg_virtue(V_NATURE, 1);
4068                         }
4069
4070                         /* No "real" damage */
4071                         dam = 0;
4072                         break;
4073                 }
4074
4075                 /* Tame animal */
4076                 case GF_CONTROL_LIVING:
4077                 {
4078                         int vir;
4079
4080                         vir = virtue_number(V_UNLIFE);
4081                         if (seen) obvious = TRUE;
4082
4083                         dam += (adj_chr_chm[p_ptr->stat_ind[A_CHR]]);
4084                         vir = virtue_number(V_UNLIFE);
4085                         if (vir)
4086                         {
4087                                 dam -= p_ptr->virtues[vir-1]/10;
4088                         }
4089
4090                         vir = virtue_number(V_INDIVIDUALISM);
4091                         if (vir)
4092                         {
4093                                 dam -= p_ptr->virtues[vir-1]/20;
4094                         }
4095
4096                         if (r_ptr->flags3 & (RF3_NO_CONF)) dam -= 30;
4097                         if (dam < 1) dam = 1;
4098 #ifdef JP
4099 msg_format("%s¤ò¸«¤Ä¤á¤¿¡£",m_name);
4100 #else
4101                         msg_format("You stare into %s.", m_name);
4102 #endif
4103                         if ((r_ptr->flags3 & (RF3_RES_ALL)) || p_ptr->inside_arena)
4104                         {
4105 #ifdef JP
4106                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4107 #else
4108                                 note = " is immune.";
4109 #endif
4110                                 dam = 0;
4111                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4112                                 break;
4113                         }
4114
4115                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))
4116                                 dam = dam * 2 / 3;
4117
4118                         /* Attempt a saving throw */
4119                         if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
4120                             (m_ptr->mflag2 & MFLAG_NOPET) ||
4121                                  (r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) ||
4122                                  ((r_ptr->level+10) > randint1(dam)))
4123                         {
4124                                 /* Resist */
4125                                 /* No obvious effect */
4126 #ifdef JP
4127 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4128 #else
4129                                 note = " is unaffected!";
4130 #endif
4131
4132                                 obvious = FALSE;
4133                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
4134                         }
4135                         else if (p_ptr->cursed & TRC_AGGRAVATE)
4136                         {
4137 #ifdef JP
4138 note = "¤Ï¤¢¤Ê¤¿¤ËŨ°Õ¤òÊú¤¤¤Æ¤¤¤ë¡ª";
4139 #else
4140                                 note = " hates you too much!";
4141 #endif
4142
4143                                 if (one_in_(4)) m_ptr->mflag2 |= MFLAG_NOPET;
4144                         }
4145                         else
4146                         {
4147 #ifdef JP
4148 note = "¤ò»ÙÇÛ¤·¤¿¡£";
4149 #else
4150                                 note = " is tamed!";
4151 #endif
4152
4153                                 set_pet(m_ptr);
4154
4155                                 if (r_ptr->flags3 & RF3_ANIMAL)
4156                                         chg_virtue(V_NATURE, 1);
4157                         }
4158
4159                         /* No "real" damage */
4160                         dam = 0;
4161                         break;
4162                 }
4163
4164                 /* Confusion (Use "dam" as "power") */
4165                 case GF_OLD_CONF:
4166                 {
4167                         if (seen) obvious = TRUE;
4168
4169                         if (r_ptr->flags3 & (RF3_RES_ALL))
4170                         {
4171 #ifdef JP
4172                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4173 #else
4174                                 note = " is immune.";
4175 #endif
4176                                 dam = 0;
4177                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4178                                 break;
4179                         }
4180                         /* Get confused later */
4181                         do_conf = damroll(3, (dam / 2)) + 1;
4182
4183                         /* Attempt a saving throw */
4184                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4185                             (r_ptr->flags3 & (RF3_NO_CONF)) ||
4186                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4187                         {
4188                                 /* Memorize a flag */
4189                                 if (r_ptr->flags3 & (RF3_NO_CONF))
4190                                 {
4191                                         if (seen) r_ptr->r_flags3 |= (RF3_NO_CONF);
4192                                 }
4193
4194                                 /* Resist */
4195                                 do_conf = 0;
4196
4197                                 /* No obvious effect */
4198 #ifdef JP
4199 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4200 #else
4201                                 note = " is unaffected!";
4202 #endif
4203
4204                                 obvious = FALSE;
4205                         }
4206
4207                         /* No "real" damage */
4208                         dam = 0;
4209                         break;
4210                 }
4211
4212                 case GF_STUN:
4213                 {
4214                         if (seen) obvious = TRUE;
4215
4216                         if (r_ptr->flags3 & (RF3_RES_ALL))
4217                         {
4218 #ifdef JP
4219                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4220 #else
4221                                 note = " is immune.";
4222 #endif
4223                                 dam = 0;
4224                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4225                                 break;
4226                         }
4227                         do_stun = damroll((p_ptr->lev / 10) + 3 , (dam)) + 1;
4228
4229                         /* Attempt a saving throw */
4230                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4231                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4232                         {
4233                                 /* Resist */
4234                                 do_stun = 0;
4235
4236                                 /* No obvious effect */
4237 #ifdef JP
4238 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4239 #else
4240                                 note = " is unaffected!";
4241 #endif
4242
4243                                 obvious = FALSE;
4244                         }
4245
4246                         /* No "real" damage */
4247                         dam = 0;
4248                         break;
4249                 }
4250
4251
4252
4253
4254                 /* Lite, but only hurts susceptible creatures */
4255                 case GF_LITE_WEAK:
4256                 {
4257                         if (!dam)
4258                         {
4259                                 skipped = TRUE;
4260                                 break;
4261                         }
4262                         if (r_ptr->flags3 & (RF3_RES_ALL))
4263                         {
4264                                 dam = 0;
4265                                 break;
4266                         }
4267                         /* Hurt by light */
4268                         if (r_ptr->flags3 & (RF3_HURT_LITE))
4269                         {
4270                                 /* Obvious effect */
4271                                 if (seen) obvious = TRUE;
4272
4273                                 /* Memorize the effects */
4274                                 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4275
4276                                 /* Special effect */
4277 #ifdef JP
4278 note = "¤Ï¸÷¤Ë¿È¤ò¤¹¤¯¤á¤¿¡ª";
4279 note_dies = "¤Ï¸÷¤ò¼õ¤±¤Æ¤·¤Ü¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
4280 #else
4281                                 note = " cringes from the light!";
4282                                 note_dies = " shrivels away in the light!";
4283 #endif
4284
4285                         }
4286
4287                         /* Normally no damage */
4288                         else
4289                         {
4290                                 /* No damage */
4291                                 dam = 0;
4292                         }
4293
4294                         break;
4295                 }
4296
4297
4298
4299                 /* Lite -- opposite of Dark */
4300                 case GF_LITE:
4301                 {
4302                         if (seen) obvious = TRUE;
4303                         if (r_ptr->flags3 & (RF3_RES_ALL))
4304                         {
4305 #ifdef JP
4306                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4307 #else
4308                                 note = " is immune.";
4309 #endif
4310                                 dam = 0;
4311                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4312                                 break;
4313                         }
4314                         if (r_ptr->flags4 & (RF4_BR_LITE))
4315                         {
4316 #ifdef JP
4317 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4318 #else
4319                                 note = " resists.";
4320 #endif
4321
4322                                 dam *= 2; dam /= (randint1(6)+6);
4323                         }
4324                         else if (r_ptr->flags3 & (RF3_HURT_LITE))
4325                         {
4326                                 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
4327 #ifdef JP
4328 note = "¤Ï¸÷¤Ë¿È¤ò¤¹¤¯¤á¤¿¡ª";
4329 note_dies = "¤Ï¸÷¤ò¼õ¤±¤Æ¤·¤Ü¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
4330 #else
4331                                 note = " cringes from the light!";
4332                                 note_dies = " shrivels away in the light!";
4333 #endif
4334
4335                                 dam *= 2;
4336                         }
4337                         break;
4338                 }
4339
4340
4341                 /* Dark -- opposite of Lite */
4342                 case GF_DARK:
4343                 {
4344                         if (seen) obvious = TRUE;
4345
4346                         if (r_ptr->flags3 & (RF3_RES_ALL))
4347                         {
4348 #ifdef JP
4349                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4350 #else
4351                                 note = " is immune.";
4352 #endif
4353                                 dam = 0;
4354                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4355                                 break;
4356                         }
4357                         /* Likes darkness... */
4358                         if ((r_ptr->flags4 & (RF4_BR_DARK)) ||
4359                             (r_ptr->flags3 & RF3_ORC) ||
4360                             (r_ptr->flags3 & RF3_HURT_LITE))
4361                         {
4362 #ifdef JP
4363 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4364 #else
4365                                 note = " resists.";
4366 #endif
4367
4368                                 dam *= 2; dam /= (randint1(6)+6);
4369                         }
4370                         break;
4371                 }
4372
4373
4374                 /* Stone to Mud */
4375                 case GF_KILL_WALL:
4376                 {
4377                         if (r_ptr->flags3 & (RF3_RES_ALL))
4378                         {
4379                                 dam = 0;
4380                                 break;
4381                         }
4382                         /* Hurt by rock remover */
4383                         if (r_ptr->flags3 & (RF3_HURT_ROCK))
4384                         {
4385                                 /* Notice effect */
4386                                 if (seen) obvious = TRUE;
4387
4388                                 /* Memorize the effects */
4389                                 if (seen) r_ptr->r_flags3 |= (RF3_HURT_ROCK);
4390
4391                                 /* Cute little message */
4392 #ifdef JP
4393 note = "¤ÎÈéÉ椬¤¿¤À¤ì¤¿¡ª";
4394 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4395 #else
4396                                 note = " loses some skin!";
4397                                 note_dies = " dissolves!";
4398 #endif
4399
4400                         }
4401
4402                         /* Usually, ignore the effects */
4403                         else
4404                         {
4405                                 /* No damage */
4406                                 dam = 0;
4407                         }
4408
4409                         break;
4410                 }
4411
4412
4413                 /* Teleport undead (Use "dam" as "power") */
4414                 case GF_AWAY_UNDEAD:
4415                 {
4416                         /* Only affect undead */
4417                         if (r_ptr->flags3 & (RF3_UNDEAD))
4418                         {
4419                                 bool resists_tele = FALSE;
4420
4421                                 if (r_ptr->flags3 & (RF3_RES_TELE))
4422                                 {
4423                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags3 & (RF3_RES_ALL)))
4424                                         {
4425                                                 if (seen) r_ptr->r_flags3 |= RF3_RES_TELE;
4426 #ifdef JP
4427 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4428 #else
4429                                                 note = " is unaffected!";
4430 #endif
4431
4432                                                 resists_tele = TRUE;
4433                                         }
4434                                         else if (r_ptr->level > randint1(100))
4435                                         {
4436                                                 if (seen) r_ptr->r_flags3 |= RF3_RES_TELE;
4437 #ifdef JP
4438 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4439 #else
4440                                                 note = " resists!";
4441 #endif
4442
4443                                                 resists_tele = TRUE;
4444                                         }
4445                                 }
4446
4447                                 if (!resists_tele)
4448                                 {
4449                                         if (seen) obvious = TRUE;
4450                                         if (seen) r_ptr->r_flags3 |= (RF3_UNDEAD);
4451                                         do_dist = dam;
4452                                 }
4453                         }
4454
4455                         /* Others ignore */
4456                         else
4457                         {
4458                                 /* Irrelevant */
4459                                 skipped = TRUE;
4460                         }
4461
4462                         /* No "real" damage */
4463                         dam = 0;
4464                         break;
4465                 }
4466
4467
4468                 /* Teleport evil (Use "dam" as "power") */
4469                 case GF_AWAY_EVIL:
4470                 {
4471                         /* Only affect evil */
4472                         if (r_ptr->flags3 & (RF3_EVIL))
4473                         {
4474                                 bool resists_tele = FALSE;
4475
4476                                 if (r_ptr->flags3 & (RF3_RES_TELE))
4477                                 {
4478                                         if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags3 & (RF3_RES_ALL)))
4479                                         {
4480                                                 if (seen) r_ptr->r_flags3 |= RF3_RES_TELE;
4481 #ifdef JP
4482 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4483 #else
4484                                                 note = " is unaffected!";
4485 #endif
4486
4487                                                 resists_tele = TRUE;
4488                                         }
4489                                         else if (r_ptr->level > randint1(100))
4490                                         {
4491                                                 if (seen) r_ptr->r_flags3 |= RF3_RES_TELE;
4492 #ifdef JP
4493 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4494 #else
4495                                                 note = " resists!";
4496 #endif
4497
4498                                                 resists_tele = TRUE;
4499                                         }
4500                                 }
4501
4502                                 if (!resists_tele)
4503                                 {
4504                                         if (seen) obvious = TRUE;
4505                                         if (seen) r_ptr->r_flags3 |= (RF3_EVIL);
4506                                         do_dist = dam;
4507                                 }
4508                         }
4509
4510                         /* Others ignore */
4511                         else
4512                         {
4513                                 /* Irrelevant */
4514                                 skipped = TRUE;
4515                         }
4516
4517                         /* No "real" damage */
4518                         dam = 0;
4519                         break;
4520                 }
4521
4522
4523                 /* Teleport monster (Use "dam" as "power") */
4524                 case GF_AWAY_ALL:
4525                 {
4526                         bool resists_tele = FALSE;
4527                         if (r_ptr->flags3 & (RF3_RES_TELE))
4528                         {
4529                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags3 & (RF3_RES_ALL)))
4530                                 {
4531                                         if (seen) r_ptr->r_flags3 |= RF3_RES_TELE;
4532 #ifdef JP
4533 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4534 #else
4535                                         note = " is unaffected!";
4536 #endif
4537
4538                                         resists_tele = TRUE;
4539                                 }
4540                                 else if (r_ptr->level > randint1(100))
4541                                 {
4542                                         if (seen) r_ptr->r_flags3 |= RF3_RES_TELE;
4543 #ifdef JP
4544 note = "¤Ë¤ÏÂÑÀ­¤¬¤¢¤ë¡ª";
4545 #else
4546                                         note = " resists!";
4547 #endif
4548
4549                                         resists_tele = TRUE;
4550                                 }
4551                         }
4552
4553                         if (!resists_tele)
4554                         {
4555                                 /* Obvious */
4556                                 if (seen) obvious = TRUE;
4557
4558                                 /* Prepare to teleport */
4559                                 do_dist = dam;
4560                         }
4561
4562                         /* No "real" damage */
4563                         dam = 0;
4564                         break;
4565                 }
4566
4567
4568                 /* Turn undead (Use "dam" as "power") */
4569                 case GF_TURN_UNDEAD:
4570                 {
4571                         if (r_ptr->flags3 & (RF3_RES_ALL))
4572                         {
4573                                 skipped = TRUE;
4574                                 break;
4575                         }
4576                         /* Only affect undead */
4577                         if (r_ptr->flags3 & (RF3_UNDEAD))
4578                         {
4579                                 /* Learn about type */
4580                                 if (seen) r_ptr->r_flags3 |= (RF3_UNDEAD);
4581
4582                                 /* Obvious */
4583                                 if (seen) obvious = TRUE;
4584
4585                                 /* Apply some fear */
4586                                 do_fear = damroll(3, (dam / 2)) + 1;
4587
4588                                 /* Attempt a saving throw */
4589                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
4590                                 {
4591                                         /* No obvious effect */
4592 #ifdef JP
4593 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4594 #else
4595                                         note = " is unaffected!";
4596 #endif
4597
4598                                         obvious = FALSE;
4599                                         do_fear = 0;
4600                                 }
4601                         }
4602
4603                         /* Others ignore */
4604                         else
4605                         {
4606                                 /* Irrelevant */
4607                                 skipped = TRUE;
4608                         }
4609
4610                         /* No "real" damage */
4611                         dam = 0;
4612                         break;
4613                 }
4614
4615
4616                 /* Turn evil (Use "dam" as "power") */
4617                 case GF_TURN_EVIL:
4618                 {
4619                         if (r_ptr->flags3 & (RF3_RES_ALL))
4620                         {
4621                                 skipped = TRUE;
4622                                 break;
4623                         }
4624                         /* Only affect evil */
4625                         if (r_ptr->flags3 & (RF3_EVIL))
4626                         {
4627                                 /* Learn about type */
4628                                 if (seen) r_ptr->r_flags3 |= (RF3_EVIL);
4629
4630                                 /* Obvious */
4631                                 if (seen) obvious = TRUE;
4632
4633                                 /* Apply some fear */
4634                                 do_fear = damroll(3, (dam / 2)) + 1;
4635
4636                                 /* Attempt a saving throw */
4637                                 if (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10)
4638                                 {
4639                                         /* No obvious effect */
4640 #ifdef JP
4641 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4642 #else
4643                                         note = " is unaffected!";
4644 #endif
4645
4646                                         obvious = FALSE;
4647                                         do_fear = 0;
4648                                 }
4649                         }
4650
4651                         /* Others ignore */
4652                         else
4653                         {
4654                                 /* Irrelevant */
4655                                 skipped = TRUE;
4656                         }
4657
4658                         /* No "real" damage */
4659                         dam = 0;
4660                         break;
4661                 }
4662
4663
4664                 /* Turn monster (Use "dam" as "power") */
4665                 case GF_TURN_ALL:
4666                 {
4667                         if (r_ptr->flags3 & (RF3_RES_ALL))
4668                         {
4669                                 skipped = TRUE;
4670                                 break;
4671                         }
4672                         /* Obvious */
4673                         if (seen) obvious = TRUE;
4674
4675                         /* Apply some fear */
4676                         do_fear = damroll(3, (dam / 2)) + 1;
4677
4678                         /* Attempt a saving throw */
4679                         if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
4680                             (r_ptr->flags3 & (RF3_NO_FEAR)) ||
4681                             (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
4682                         {
4683                                 /* No obvious effect */
4684 #ifdef JP
4685 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
4686 #else
4687                                 note = " is unaffected!";
4688 #endif
4689
4690                                 obvious = FALSE;
4691                                 do_fear = 0;
4692                         }
4693
4694                         /* No "real" damage */
4695                         dam = 0;
4696                         break;
4697                 }
4698
4699
4700                 /* Dispel undead */
4701                 case GF_DISP_UNDEAD:
4702                 {
4703                         if (r_ptr->flags3 & (RF3_RES_ALL))
4704                         {
4705                                 skipped = TRUE;
4706                                 dam = 0;
4707                                 break;
4708                         }
4709                         /* Only affect undead */
4710                         if (r_ptr->flags3 & (RF3_UNDEAD))
4711                         {
4712                                 /* Learn about type */
4713                                 if (seen) r_ptr->r_flags3 |= (RF3_UNDEAD);
4714
4715                                 /* Obvious */
4716                                 if (seen) obvious = TRUE;
4717
4718                                 /* Message */
4719 #ifdef JP
4720 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4721 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4722 #else
4723                                 note = " shudders.";
4724                                 note_dies = " dissolves!";
4725 #endif
4726
4727                         }
4728
4729                         /* Others ignore */
4730                         else
4731                         {
4732                                 /* Irrelevant */
4733                                 skipped = TRUE;
4734
4735                                 /* No damage */
4736                                 dam = 0;
4737                         }
4738
4739                         break;
4740                 }
4741
4742
4743                 /* Dispel evil */
4744                 case GF_DISP_EVIL:
4745                 {
4746                         if (r_ptr->flags3 & (RF3_RES_ALL))
4747                         {
4748                                 skipped = TRUE;
4749                                 dam = 0;
4750                                 break;
4751                         }
4752                         /* Only affect evil */
4753                         if (r_ptr->flags3 & (RF3_EVIL))
4754                         {
4755                                 /* Learn about type */
4756                                 if (seen) r_ptr->r_flags3 |= (RF3_EVIL);
4757
4758                                 /* Obvious */
4759                                 if (seen) obvious = TRUE;
4760
4761                                 /* Message */
4762 #ifdef JP
4763 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4764 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4765 #else
4766                                 note = " shudders.";
4767                                 note_dies = " dissolves!";
4768 #endif
4769
4770                         }
4771
4772                         /* Others ignore */
4773                         else
4774                         {
4775                                 /* Irrelevant */
4776                                 skipped = TRUE;
4777
4778                                 /* No damage */
4779                                 dam = 0;
4780                         }
4781
4782                         break;
4783                 }
4784
4785                 /* Dispel good */
4786                 case GF_DISP_GOOD:
4787                 {
4788                         if (r_ptr->flags3 & (RF3_RES_ALL))
4789                         {
4790                                 skipped = TRUE;
4791                                 dam = 0;
4792                                 break;
4793                         }
4794                         /* Only affect good */
4795                         if (r_ptr->flags3 & (RF3_GOOD))
4796                         {
4797                                 /* Learn about type */
4798                                 if (seen) r_ptr->r_flags3 |= (RF3_GOOD);
4799
4800                                 /* Obvious */
4801                                 if (seen) obvious = TRUE;
4802
4803                                 /* Message */
4804 #ifdef JP
4805 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4806 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4807 #else
4808                                 note = " shudders.";
4809                                 note_dies = " dissolves!";
4810 #endif
4811
4812                         }
4813
4814                         /* Others ignore */
4815                         else
4816                         {
4817                                 /* Irrelevant */
4818                                 skipped = TRUE;
4819
4820                                 /* No damage */
4821                                 dam = 0;
4822                         }
4823
4824                         break;
4825                 }
4826
4827                 /* Dispel living */
4828                 case GF_DISP_LIVING:
4829                 {
4830                         if (r_ptr->flags3 & (RF3_RES_ALL))
4831                         {
4832                                 skipped = TRUE;
4833                                 dam = 0;
4834                                 break;
4835                         }
4836                         /* Only affect non-undead */
4837                         if (monster_living(r_ptr))
4838                         {
4839                                 /* Obvious */
4840                                 if (seen) obvious = TRUE;
4841
4842                                 /* Message */
4843 #ifdef JP
4844 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4845 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4846 #else
4847                                 note = " shudders.";
4848                                 note_dies = " dissolves!";
4849 #endif
4850
4851                         }
4852
4853                         /* Others ignore */
4854                         else
4855                         {
4856                                 /* Irrelevant */
4857                                 skipped = TRUE;
4858
4859                                 /* No damage */
4860                                 dam = 0;
4861                         }
4862
4863                         break;
4864                 }
4865
4866                 /* Dispel demons */
4867                 case GF_DISP_DEMON:
4868                 {
4869                         if (r_ptr->flags3 & (RF3_RES_ALL))
4870                         {
4871                                 skipped = TRUE;
4872                                 dam = 0;
4873                                 break;
4874                         }
4875                         /* Only affect demons */
4876                         if (r_ptr->flags3 & (RF3_DEMON))
4877                         {
4878                                 /* Learn about type */
4879                                 if (seen) r_ptr->r_flags3 |= (RF3_DEMON);
4880
4881                                 /* Obvious */
4882                                 if (seen) obvious = TRUE;
4883
4884                                 /* Message */
4885 #ifdef JP
4886 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4887 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4888 #else
4889                                 note = " shudders.";
4890                                 note_dies = " dissolves!";
4891 #endif
4892
4893                         }
4894
4895                         /* Others ignore */
4896                         else
4897                         {
4898                                 /* Irrelevant */
4899                                 skipped = TRUE;
4900
4901                                 /* No damage */
4902                                 dam = 0;
4903                         }
4904
4905                         break;
4906                 }
4907
4908                 /* Dispel monster */
4909                 case GF_DISP_ALL:
4910                 {
4911                         if (r_ptr->flags3 & (RF3_RES_ALL))
4912                         {
4913                                 skipped = TRUE;
4914                                 dam = 0;
4915                                 break;
4916                         }
4917                         /* Obvious */
4918                         if (seen) obvious = TRUE;
4919
4920                         /* Message */
4921 #ifdef JP
4922 note = "¤Ï¿È¿Ì¤¤¤·¤¿¡£";
4923 note_dies = "¤Ï¥É¥í¥É¥í¤ËÍϤ±¤¿¡ª";
4924 #else
4925                         note = " shudders.";
4926                         note_dies = " dissolves!";
4927 #endif
4928
4929
4930                         break;
4931                 }
4932
4933                 /* Drain mana */
4934                 case GF_DRAIN_MANA:
4935                 {
4936                         if (seen) obvious = TRUE;
4937                         if (r_ptr->flags3 & (RF3_RES_ALL))
4938                         {
4939 #ifdef JP
4940                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4941 #else
4942                                 note = " is immune.";
4943 #endif
4944                                 skipped = TRUE;
4945                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4946                                 break;
4947                         }
4948
4949                         if ((r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) || (r_ptr->flags5 & ~(RF5_NOMAGIC_MASK)) || (r_ptr->flags6 & ~(RF6_NOMAGIC_MASK)))
4950                         {
4951                                 /* Message */
4952 #ifdef JP
4953 msg_format("%s¤«¤éÀº¿À¥¨¥Í¥ë¥®¡¼¤òµÛ¤¤¤È¤Ã¤¿¡£",m_name);
4954 #else
4955                                 msg_format("You draws psychic energy from %s.", m_name);
4956 #endif
4957
4958                                 (void)hp_player(dam);
4959                         }
4960                         else
4961                         {
4962 #ifdef JP
4963 msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",m_name);
4964 #else
4965                                 msg_format("%s is unaffected.", m_name);
4966 #endif
4967                         }
4968                         dam = 0;
4969                         break;
4970                 }
4971
4972                 /* Mind blast */
4973                 case GF_MIND_BLAST:
4974                 {
4975                         if (seen) obvious = TRUE;
4976                         /* Message */
4977 #ifdef JP
4978 msg_format("%s¤ò¤¸¤Ã¤Èâˤó¤À¡£",m_name);
4979 #else
4980                         msg_format("You gazes intently at %s.", m_name);
4981 #endif
4982
4983                         if (r_ptr->flags3 & (RF3_RES_ALL))
4984                         {
4985 #ifdef JP
4986                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
4987 #else
4988                                 note = " is immune.";
4989 #endif
4990                                 skipped = TRUE;
4991                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
4992                                 break;
4993                         }
4994
4995                         /* Attempt a saving throw */
4996                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
4997                                  (r_ptr->flags3 & RF3_NO_CONF) ||
4998                                  (r_ptr->level > randint1((p_ptr->lev*2 - 10) < 1 ? 1 : (p_ptr->lev*2 - 10)) + 10))
4999                         {
5000                                 /* Memorize a flag */
5001                                 if (r_ptr->flags3 & (RF3_NO_CONF))
5002                                 {
5003                                         r_ptr->r_flags3 |= (RF3_NO_CONF);
5004                                 }
5005 #ifdef JP
5006 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5007 #else
5008                                 note = "is unaffected!";
5009 #endif
5010                                 dam = 0;
5011                         }
5012                         else
5013                         {
5014 #ifdef JP
5015 msg_format("%s¤ÏÀº¿À¹¶·â¤ò¿©¤é¤Ã¤¿¡£",m_name);
5016 note_dies = "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±¶õ¤È¤Ê¤Ã¤¿¡£";
5017 #else
5018                                 msg_format("%^s is blasted by psionic energy.", m_name);
5019                                 note_dies = " collapses, a mindless husk.";
5020 #endif
5021
5022                                 do_conf = randint0(8) + 8;
5023                         }
5024                         break;
5025                 }
5026
5027                 /* Brain smash */
5028                 case GF_BRAIN_SMASH:
5029                 {
5030                         if (seen) obvious = TRUE;
5031                         /* Message */
5032 #ifdef JP
5033 msg_format("%s¤ò¤¸¤Ã¤Èâˤó¤À¡£",m_name);
5034 #else
5035                         msg_format("You gazes intently at %s.", m_name);
5036 #endif
5037
5038                         if (r_ptr->flags3 & (RF3_RES_ALL))
5039                         {
5040 #ifdef JP
5041                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5042 #else
5043                                 note = " is immune.";
5044 #endif
5045                                 skipped = TRUE;
5046                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5047                                 break;
5048                         }
5049
5050                         /* Attempt a saving throw */
5051                         if ((r_ptr->flags1 & RF1_UNIQUE) ||
5052                                  (r_ptr->flags3 & RF3_NO_CONF) ||
5053                                  (r_ptr->level > randint1((p_ptr->lev*2 - 10) < 1 ? 1 : (p_ptr->lev*2 - 10)) + 10))
5054                         {
5055                                 /* Memorize a flag */
5056                                 if (r_ptr->flags3 & (RF3_NO_CONF))
5057                                 {
5058                                         r_ptr->r_flags3 |= (RF3_NO_CONF);
5059                                 }
5060 #ifdef JP
5061 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5062 #else
5063                                 note = "is unaffected!";
5064 #endif
5065                                 dam = 0;
5066                         }
5067                         else
5068                         {
5069 #ifdef JP
5070 msg_format("%s¤ÏÀº¿À¹¶·â¤ò¿©¤é¤Ã¤¿¡£",m_name);
5071 note_dies = "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±¶õ¤È¤Ê¤Ã¤¿¡£";
5072 #else
5073                                 msg_format("%^s is blasted by psionic energy.", m_name);
5074                                 note_dies = " collapses, a mindless husk.";
5075 #endif
5076
5077                                 do_conf = randint0(8) + 8;
5078                                 do_stun = randint0(8) + 8;
5079                                 m_ptr->slow = MIN(200, m_ptr->slow + 10);
5080                                 if (c_ptr->m_idx == p_ptr->riding)
5081                                         p_ptr->update |= (PU_BONUS);
5082                         }
5083                         break;
5084                 }
5085
5086                 /* CAUSE_1 */
5087                 case GF_CAUSE_1:
5088                 {
5089                         if (seen) obvious = TRUE;
5090                         /* Message */
5091 #ifdef JP
5092 msg_format("%s¤ò»Øº¹¤·¤Æ¼ö¤¤¤ò¤«¤±¤¿¡£",m_name);
5093 #else
5094                         msg_format("You points at %s and curses.", m_name);
5095 #endif
5096
5097                         if (r_ptr->flags3 & (RF3_RES_ALL))
5098                         {
5099 #ifdef JP
5100                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5101 #else
5102                                 note = " is immune.";
5103 #endif
5104                                 skipped = TRUE;
5105                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5106                                 break;
5107                         }
5108
5109                         /* Attempt a saving throw */
5110                         if (randint0(100 + p_ptr->lev) < (r_ptr->level + 35))
5111                         {
5112
5113 #ifdef JP
5114 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5115 #else
5116                                 note = "is unaffected!";
5117 #endif
5118                                 dam = 0;
5119                         }
5120                         break;
5121                 }
5122
5123                 /* CAUSE_2 */
5124                 case GF_CAUSE_2:
5125                 {
5126                         if (seen) obvious = TRUE;
5127                         /* Message */
5128 #ifdef JP
5129 msg_format("%s¤ò»Øº¹¤·¤Æ¶²¤í¤·¤²¤Ë¼ö¤¤¤ò¤«¤±¤¿¡£",m_name);
5130 #else
5131                         msg_format("You points at %s and curses horribly.", m_name);
5132 #endif
5133
5134                         if (r_ptr->flags3 & (RF3_RES_ALL))
5135                         {
5136 #ifdef JP
5137                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5138 #else
5139                                 note = " is immune.";
5140 #endif
5141                                 skipped = TRUE;
5142                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5143                                 break;
5144                         }
5145
5146                         /* Attempt a saving throw */
5147                         if (randint0(100 + p_ptr->lev) < (r_ptr->level + 35))
5148                         {
5149
5150 #ifdef JP
5151 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5152 #else
5153                                 note = "is unaffected!";
5154 #endif
5155                                 dam = 0;
5156                         }
5157                         break;
5158                 }
5159
5160                 /* CAUSE_3 */
5161                 case GF_CAUSE_3:
5162                 {
5163                         if (seen) obvious = TRUE;
5164                         /* Message */
5165 #ifdef JP
5166 msg_format("%s¤ò»Øº¹¤·¡¢¶²¤·¤²¤Ë¼öʸ¤ò¾§¤¨¤¿¡ª",m_name);
5167 #else
5168                         msg_format("You points at %s, incanting terribly!", m_name);
5169 #endif
5170
5171                         if (r_ptr->flags3 & (RF3_RES_ALL))
5172                         {
5173 #ifdef JP
5174                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5175 #else
5176                                 note = " is immune.";
5177 #endif
5178                                 skipped = TRUE;
5179                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5180                                 break;
5181                         }
5182
5183                         /* Attempt a saving throw */
5184                         if (randint0(100 + p_ptr->lev) < (r_ptr->level + 35))
5185                         {
5186
5187 #ifdef JP
5188 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5189 #else
5190                                 note = "is unaffected!";
5191 #endif
5192                                 dam = 0;
5193                         }
5194                         break;
5195                 }
5196
5197                 /* CAUSE_4 */
5198                 case GF_CAUSE_4:
5199                 {
5200                         if (seen) obvious = TRUE;
5201                         /* Message */
5202 #ifdef JP
5203 msg_format("%s¤ÎÈ빦¤òÆͤ¤¤Æ¡¢¡Ö¤ªÁ°¤Ï´û¤Ë»à¤ó¤Ç¤¤¤ë¡×¤È¶«¤ó¤À¡£",m_name);
5204 #else
5205                         msg_format("You points at %s, screaming th word, 'DIE!'.", m_name);
5206 #endif
5207
5208                         if (r_ptr->flags3 & (RF3_RES_ALL))
5209                         {
5210 #ifdef JP
5211                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5212 #else
5213                                 note = " is immune.";
5214 #endif
5215                                 skipped = TRUE;
5216                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5217                                 break;
5218                         }
5219
5220                         /* Attempt a saving throw */
5221                         if (randint0(100 + p_ptr->lev) < (r_ptr->level + 35))
5222                         {
5223
5224 #ifdef JP
5225 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£";
5226 #else
5227                                 note = "is unaffected!";
5228 #endif
5229                                 dam = 0;
5230                         }
5231                         break;
5232                 }
5233
5234                 /* HAND_DOOM */
5235                 case GF_HAND_DOOM:
5236                 {
5237                         if (seen) obvious = TRUE;
5238
5239                         if (r_ptr->flags3 & (RF3_RES_ALL))
5240                         {
5241 #ifdef JP
5242                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5243 #else
5244                                 note = " is immune.";
5245 #endif
5246                                 skipped = TRUE;
5247                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5248                                 break;
5249                         }
5250
5251                         if (r_ptr->flags1 & RF1_UNIQUE)
5252                         {
5253 #ifdef JP
5254 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5255 #else
5256                                 note = "is unaffected!";
5257 #endif
5258                                 dam = 0;
5259                         }
5260                         else
5261                         {
5262                                 if ((p_ptr->lev + randint1(dam)) >
5263                                         (r_ptr->level + randint1(200)))
5264                                         {
5265                                                 dam = ((40 + randint1(20)) * m_ptr->hp) / 100;
5266
5267                                                 if (m_ptr->hp < dam) dam = m_ptr->hp - 1;
5268                                         }
5269                                         else
5270                                         {
5271 #ifdef JP
5272 note = "¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª";
5273 #else
5274                                                 note = "resists!";
5275 #endif
5276                                                 dam = 0;
5277                                         }
5278                                 }
5279                         break;
5280                 }
5281
5282                 /* Capture monster */
5283                 case GF_CAPTURE:
5284                 {
5285                         int nokori_hp;
5286                         if ((p_ptr->inside_quest && (quest[p_ptr->inside_quest].type == QUEST_TYPE_KILL_ALL) && !is_pet(m_ptr)) ||
5287                             (r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_UNIQUE_7)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (r_ptr->flags1 & RF1_QUESTOR))
5288                         {
5289 #ifdef JP
5290 msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",m_name);
5291 #else
5292                                 msg_format("%^s is unaffected.", m_name);
5293 #endif
5294                                 skipped = TRUE;
5295                                 break;
5296                         }
5297
5298                         if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp*4L;
5299                         else if ((p_ptr->pclass == CLASS_BEASTMASTER) && (r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)))
5300                                 nokori_hp = m_ptr->maxhp * 3 / 10;
5301                         else
5302                                 nokori_hp = m_ptr->maxhp * 3 / 20;
5303                         
5304                         if (m_ptr->hp >= nokori_hp)
5305                         {
5306 #ifdef JP
5307 msg_format("¤â¤Ã¤È¼å¤é¤»¤Ê¤¤¤È¡£");
5308 #else
5309                                 msg_format("You need to weaken %s more.", m_name);
5310 #endif
5311                                 skipped = TRUE;
5312                         }
5313                         else if (m_ptr->hp < randint0(nokori_hp))
5314                         {
5315                                 if (m_ptr->mflag2 & MFLAG_CHAMELEON) choose_new_monster(c_ptr->m_idx, FALSE, MON_CHAMELEON);
5316 #ifdef JP
5317 msg_format("%s¤òÊᤨ¤¿¡ª",m_name);
5318 #else
5319                                 msg_format("You captures %^s!", m_name);
5320 #endif
5321                                 cap_mon = m_list[c_ptr->m_idx].r_idx;
5322                                 cap_mspeed = m_list[c_ptr->m_idx].mspeed;
5323                                 cap_hp = m_list[c_ptr->m_idx].hp;
5324                                 cap_maxhp = m_list[c_ptr->m_idx].max_maxhp;
5325                                 if (m_list[c_ptr->m_idx].nickname)
5326                                         cap_nickname = quark_add(quark_str(m_list[c_ptr->m_idx].nickname));
5327                                 else
5328                                         cap_nickname = 0;
5329                                 if (c_ptr->m_idx == p_ptr->riding)
5330                                 {
5331                                         if (rakuba(-1, FALSE))
5332                                         {
5333 #ifdef JP
5334 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
5335 #else
5336                                                 msg_format("You have fallen from %s.", m_name);
5337 #endif
5338                                         }
5339                                 }
5340
5341                                 delete_monster_idx(c_ptr->m_idx);
5342
5343                                 return (TRUE);
5344                         }
5345                         else
5346                         {
5347 #ifdef JP
5348 msg_format("¤¦¤Þ¤¯Êá¤Þ¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡£");
5349 #else
5350                                 msg_format("You failed to capture %s.", m_name);
5351 #endif
5352                                 skipped = TRUE;
5353                         }
5354                         break;
5355                 }
5356
5357                 case GF_ATTACK:
5358                 {
5359                         if (seen) obvious = TRUE;
5360                         skipped = TRUE;
5361                         if (dam == HISSATSU_NYUSIN)
5362                         {
5363                                 int i;
5364                                 int ny = y, nx = x;
5365                                 bool success = FALSE;
5366                                 for (i = 0; i < 8; i++)
5367                                 {
5368                                         if (cave_empty_bold(y+ddy[i], x+ddx[i]) || ((y+ddy[i] == py) && (x+ddx[i] == px)))
5369                                         {
5370                                                 success = TRUE;
5371                                                 if (distance(py, px, ny, nx) > distance(py, px, y+ddy[i], x+ddx[i]))
5372                                                 {
5373                                                         ny = y+ddy[i];
5374                                                         nx = x+ddx[i];
5375                                                 }
5376                                         }
5377                                 }
5378                                 if (success)
5379                                 {
5380                                         if ((ny != py) || (nx != px))
5381                                         {
5382                                                 teleport_player_to(ny, nx, FALSE);
5383 #ifdef JP
5384                                                 msg_print("ÁÇÁ᤯Áê¼ê¤Î²û¤ËÆþ¤ê¹þ¤ó¤À¡ª");
5385 #else
5386                                                 msg_format("You quickly jump in and attack %s!", m_name);
5387 #endif
5388                                         }
5389                                 }
5390                                 else
5391                                 {
5392 #ifdef JP
5393                                         msg_print("¼ºÇÔ¡ª");
5394 #else
5395                                         msg_print("Failed!");
5396 #endif
5397                                         dam = 0;
5398                                         break;
5399                                 }
5400                         }
5401                         if (c_ptr->m_idx)
5402                                 return (py_attack(y, x, dam));
5403                         else
5404 #ifdef JP
5405                                 msg_print("¹¶·â¤Ï¶õ¤òÀڤä¿¡£");
5406 #else
5407                                 msg_print("You attack the empty air.");
5408 #endif
5409                         dam = 0;
5410                         break;
5411                 }
5412
5413                 /* Sleep (Use "dam" as "power") */
5414                 case GF_ENGETSU:
5415                 {
5416                         int effect = 0;
5417                         bool done = TRUE;
5418
5419                         if (seen) obvious = TRUE;
5420
5421                         if (r_ptr->flags3 & (RF3_RES_ALL))
5422                         {
5423 #ifdef JP
5424                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5425 #else
5426                                 note = " is immune.";
5427 #endif
5428                                 dam = 0;
5429                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5430                                 break;
5431                         }
5432                         if (r_ptr->flags2 & RF2_EMPTY_MIND)
5433                         {
5434 #ifdef JP
5435 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5436 #else
5437                                 note = " is immune!";
5438 #endif
5439                                 dam = 0;
5440                                 skipped = TRUE;
5441                                 if (seen) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
5442                                 break;
5443                         }
5444                         if (m_ptr->csleep)
5445                         {
5446 #ifdef JP
5447 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5448 #else
5449                                 note = " is immune!";
5450 #endif
5451                                 dam = 0;
5452                                 skipped = TRUE;
5453                                 break;
5454                         }
5455
5456                         if (one_in_(5)) effect = 1;
5457                         else if (one_in_(4)) effect = 2;
5458                         else if (one_in_(3)) effect = 3;
5459                         else done = FALSE;
5460
5461                         if (effect == 1)
5462                         {
5463                                 /* Powerful monsters can resist */
5464                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5465                                     (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
5466                                 {
5467 #ifdef JP
5468 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5469 #else
5470                                         note = " is unaffected!";
5471 #endif
5472
5473                                         obvious = FALSE;
5474                                 }
5475
5476                                 /* Normal monsters slow down */
5477                                 else
5478                                 {
5479                                         if (!m_ptr->slow)
5480                                         {
5481 #ifdef JP
5482 note = "¤ÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤¿¡£";
5483 #else
5484                                                 note = " starts moving slower.";
5485 #endif
5486                                         }
5487                                         m_ptr->slow = MIN(200, m_ptr->slow + 50);
5488
5489                                         if (c_ptr->m_idx == p_ptr->riding)
5490                                                 p_ptr->update |= (PU_BONUS);
5491                                 }
5492                         }
5493
5494                         else if (effect == 2)
5495                         {
5496                                 do_stun = damroll((p_ptr->lev / 10) + 3 , (dam)) + 1;
5497
5498                                 /* Attempt a saving throw */
5499                                 if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
5500                                     (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
5501                                 {
5502                                         /* Resist */
5503                                         do_stun = 0;
5504
5505                                         /* No obvious effect */
5506 #ifdef JP
5507 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5508 #else
5509                                         note = " is unaffected!";
5510 #endif
5511
5512                                         obvious = FALSE;
5513                                 }
5514                         }
5515
5516                         else if (effect == 3)
5517                         {
5518                                 /* Attempt a saving throw */
5519                                 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5520                                     (r_ptr->flags3 & RF3_NO_SLEEP) ||
5521                                     (r_ptr->level > randint1((dam - 10) < 1 ? 1 : (dam - 10)) + 10))
5522                                 {
5523                                         /* Memorize a flag */
5524                                         if (r_ptr->flags3 & RF3_NO_SLEEP)
5525                                         {
5526                                                 if (seen) r_ptr->r_flags3 |= (RF3_NO_SLEEP);
5527                                         }
5528
5529                                         /* No obvious effect */
5530 #ifdef JP
5531 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5532 #else
5533                                         note = " is unaffected!";
5534 #endif
5535
5536                                         obvious = FALSE;
5537                                 }
5538                                 else
5539                                 {
5540                                         /* Go to sleep (much) later */
5541 #ifdef JP
5542 note = "¤Ï̲¤ê¹þ¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
5543 #else
5544                                         note = " falls asleep!";
5545 #endif
5546
5547                                         do_sleep = 500;
5548                                 }
5549                         }
5550
5551                         if (!done)
5552                         {
5553 #ifdef JP
5554 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5555 #else
5556                                 note = " is immune!";
5557 #endif
5558                         }
5559
5560                         /* No "real" damage */
5561                         dam = 0;
5562                         break;
5563                 }
5564
5565                 /* GENOCIDE */
5566                 case GF_GENOCIDE:
5567                 {
5568                         bool angry = FALSE;
5569                         if (seen) obvious = TRUE;
5570
5571                         if (r_ptr->flags3 & (RF3_RES_ALL))
5572                         {
5573 #ifdef JP
5574                                 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5575 #else
5576                                 note = " is immune.";
5577 #endif
5578                                 skipped = TRUE;
5579                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5580                                 break;
5581                         }
5582
5583                         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)
5584                         {
5585                                 dam = 0;
5586                                 angry = TRUE;
5587                         }
5588                         else
5589                         {
5590                                 if ((r_ptr->level > randint0(dam)) || (m_ptr->mflag2 & MFLAG_NOGENO))
5591                                 {
5592                                         dam = 0;
5593                                         angry = TRUE;
5594                                 }
5595                                 else
5596                                 {
5597                                         delete_monster_idx(c_ptr->m_idx);
5598 #ifdef JP
5599                                         msg_format("%s¤Ï¾ÃÌǤ·¤¿¡ª",m_name);
5600 #else
5601                                         msg_format("%^s disappered!",m_name);
5602 #endif
5603
5604 #ifdef JP
5605                                         take_hit(DAMAGE_GENO, randint1((r_ptr->level+1)/2), "¥â¥ó¥¹¥¿¡¼¾ÃÌǤμöʸ¤ò¾§¤¨¤¿ÈèÏ«", -1);
5606 #else
5607                                         take_hit(DAMAGE_GENO, randint1((r_ptr->level+1)/2), "the strain of casting Genocide One", -1);
5608 #endif
5609                                         dam = 0;
5610
5611                                         chg_virtue(V_VITALITY, -1);
5612
5613                                         skipped = TRUE;
5614
5615                                         /* Redraw */
5616                                         p_ptr->redraw |= (PR_HP);
5617
5618                                         /* Window stuff */
5619                                         p_ptr->window |= (PW_PLAYER);
5620                                         return TRUE;
5621                                 }
5622                         }
5623                         if (angry)
5624                         {
5625 #ifdef JP
5626 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5627 #else
5628                                 note = "is unaffected!";
5629 #endif
5630                                 get_angry = TRUE;
5631                                 if (one_in_(13)) m_ptr->mflag2 |= MFLAG_NOGENO;
5632                         }
5633                         break;
5634                 }
5635
5636                 case GF_PHOTO:
5637                 {
5638 #ifdef JP
5639                         msg_format("%s¤ò¼Ì¿¿¤Ë»£¤Ã¤¿¡£",m_name);
5640 #else
5641                         msg_format("You take a photograph of %s.",m_name);
5642 #endif
5643                         /* Hurt by light */
5644                         if (r_ptr->flags3 & (RF3_HURT_LITE))
5645                         {
5646                                 /* Obvious effect */
5647                                 if (seen) obvious = TRUE;
5648
5649                                 /* Memorize the effects */
5650                                 if (seen) r_ptr->r_flags3 |= (RF3_HURT_LITE);
5651
5652                                 /* Special effect */
5653 #ifdef JP
5654 note = "¤Ï¸÷¤Ë¿È¤ò¤¹¤¯¤á¤¿¡ª";
5655 note_dies = "¤Ï¸÷¤ò¼õ¤±¤Æ¤·¤Ü¤ó¤Ç¤·¤Þ¤Ã¤¿¡ª";
5656 #else
5657                                 note = " cringes from the light!";
5658                                 note_dies = " shrivels away in the light!";
5659 #endif
5660
5661                         }
5662
5663                         /* Normally no damage */
5664                         else
5665                         {
5666                                 /* No damage */
5667                                 dam = 0;
5668                         }
5669
5670                         photo = m_ptr->r_idx;
5671
5672                         break;
5673                 }
5674
5675
5676                 /* blood curse */
5677                 case GF_BLOOD_CURSE:
5678                 {
5679                         if (seen) obvious = TRUE;
5680                         if (r_ptr->flags3 & (RF3_RES_ALL))
5681                         {
5682 #ifdef JP
5683                                 note = "¤Ë¤Ï´°Á´¤ÊÂÑÀ­¤¬¤¢¤ë¡ª";
5684 #else
5685                                 note = " is immune.";
5686 #endif
5687                                 dam = 0;
5688                                 if (seen) r_ptr->r_flags3 |= (RF3_RES_ALL);
5689                                 break;
5690                         }
5691                         break;
5692                 }
5693
5694                 /* Default */
5695                 default:
5696                 {
5697                         /* Irrelevant */
5698                         skipped = TRUE;
5699
5700                         /* No damage */
5701                         dam = 0;
5702
5703                         break;
5704                 }
5705         }
5706
5707
5708         /* Absolutely no effect */
5709         if (skipped) return (FALSE);
5710
5711         /* "Unique" monsters cannot be polymorphed */
5712         if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
5713
5714         /* Quest monsters cannot be polymorphed */
5715         if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
5716
5717         if (p_ptr->riding & (c_ptr->m_idx == p_ptr->riding)) do_poly = FALSE;
5718
5719         /* "Unique" and "quest" monsters can only be "killed" by the player. */
5720         if (((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->flags1 & RF1_QUESTOR)) && !p_ptr->inside_battle)
5721         {
5722                 if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
5723         }
5724
5725         if (!who && slept)
5726         {
5727                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
5728                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
5729         }
5730
5731         /* Modify the damage */
5732         tmp = dam;
5733         dam = mon_damage_mod(m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
5734 #ifdef JP
5735         if ((tmp > 0) && (dam == 0)) note = "¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤";
5736 #else
5737         if ((tmp > 0) && (dam == 0)) note = " is unharmed.";
5738 #endif
5739
5740         /* Check for death */
5741         if (dam > m_ptr->hp)
5742         {
5743                 /* Extract method of death */
5744                 note = note_dies;
5745         }
5746
5747         /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
5748         else if (do_poly && (randint1(90) > r_ptr->level))
5749         {
5750                 if (polymorph_monster(y, x))
5751                 {
5752                         /* Obvious */
5753                         if (seen) obvious = TRUE;
5754
5755                         /* Monster polymorphs */
5756 #ifdef JP
5757 note = "¤¬ÊѿȤ·¤¿¡ª";
5758 #else
5759                         note = " changes!";
5760 #endif
5761
5762
5763                         /* Turn off the damage */
5764                         dam = 0;
5765
5766                         /* Hack -- Get new monster */
5767                         m_ptr = &m_list[c_ptr->m_idx];
5768
5769                         /* Hack -- Get new race */
5770                         r_ptr = &r_info[m_ptr->r_idx];
5771                 }
5772                 else
5773                 {
5774                         /* No polymorph */
5775 #ifdef JP
5776 note = "¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª";
5777 #else
5778                         note = " is unaffected!";
5779 #endif
5780
5781                 }
5782         }
5783
5784         /* Handle "teleport" */
5785         else if (do_dist)
5786         {
5787                 /* Obvious */
5788                 if (seen) obvious = TRUE;
5789
5790                 /* Message */
5791 #ifdef JP
5792 note = "¤¬¾Ã¤¨µî¤Ã¤¿¡ª";
5793 #else
5794                 note = " disappears!";
5795 #endif
5796
5797                 chg_virtue(V_VALOUR, -1);
5798
5799                 /* Teleport */
5800                 teleport_away(c_ptr->m_idx, do_dist, (bool)(!who));
5801
5802                 /* Hack -- get new location */
5803                 y = m_ptr->fy;
5804                 x = m_ptr->fx;
5805
5806                 /* Hack -- get new grid */
5807                 c_ptr = &cave[y][x];
5808         }
5809
5810         /* Sound and Impact breathers never stun */
5811         else if (do_stun &&
5812             !(r_ptr->flags4 & (RF4_BR_SOUN)) &&
5813             !(r_ptr->flags4 & (RF4_BR_WALL)) &&
5814             !(r_ptr->flags3 & (RF3_NO_STUN)))
5815         {
5816                 /* Obvious */
5817                 if (seen) obvious = TRUE;
5818
5819                 /* Get confused */
5820                 if (m_ptr->stunned)
5821                 {
5822 #ifdef JP
5823 note = "¤Ï¤Ò¤É¤¯¤â¤¦¤í¤¦¤È¤·¤¿¡£";
5824 #else
5825                         note = " is more dazed.";
5826 #endif
5827
5828                         tmp = m_ptr->stunned + (do_stun / 2);
5829                 }
5830                 else
5831                 {
5832 #ifdef JP
5833 note = "¤Ï¤â¤¦¤í¤¦¤È¤·¤¿¡£";
5834 #else
5835                         note = " is dazed.";
5836 #endif
5837
5838                         tmp = do_stun;
5839                 }
5840
5841                 /* Apply stun */
5842                 m_ptr->stunned = (tmp < 200) ? tmp : 200;
5843
5844                 /* Get angry */
5845                 get_angry = TRUE;
5846         }
5847
5848         /* Confusion and Chaos breathers (and sleepers) never confuse */
5849         else if (do_conf &&
5850                  !(r_ptr->flags3 & (RF3_NO_CONF)) &&
5851                  !(r_ptr->flags4 & (RF4_BR_CONF)) &&
5852                  !(r_ptr->flags4 & (RF4_BR_CHAO)))
5853         {
5854                 /* Obvious */
5855                 if (seen) obvious = TRUE;
5856
5857                 /* Already partially confused */
5858                 if (m_ptr->confused)
5859                 {
5860 #ifdef JP
5861 note = "¤Ï¤µ¤é¤Ëº®Í𤷤¿¤è¤¦¤À¡£";
5862 #else
5863                         note = " looks more confused.";
5864 #endif
5865
5866                         tmp = m_ptr->confused + (do_conf / 2);
5867                 }
5868
5869                 /* Was not confused */
5870                 else
5871                 {
5872 #ifdef JP
5873 note = "¤Ïº®Í𤷤¿¤è¤¦¤À¡£";
5874 #else
5875                         note = " looks confused.";
5876 #endif
5877
5878                         tmp = do_conf;
5879                 }
5880
5881                 /* Apply confusion */
5882                 m_ptr->confused = (tmp < 200) ? tmp : 200;
5883
5884                 /* Get angry */
5885                 get_angry = TRUE;
5886         }
5887         else if (do_time)
5888         {
5889                 /* Obvious */
5890                 if (seen) obvious = TRUE;
5891
5892                 if (do_time >= m_ptr->maxhp) do_time = m_ptr->maxhp-1;
5893
5894                 if (do_time)
5895                 {
5896 #ifdef JP
5897 note = "¤Ï¼å¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£";
5898 #else
5899                         note = " seems weakened.";
5900 #endif
5901                         m_ptr->maxhp -= do_time;
5902                         if ((m_ptr->hp - dam) > m_ptr->maxhp) dam = m_ptr->hp-m_ptr->maxhp;
5903                 }
5904                 get_angry = TRUE;
5905         }
5906
5907
5908         /* Fear */
5909         if (do_fear)
5910         {
5911                 /* Increase fear */
5912                 tmp = m_ptr->monfear + do_fear;
5913
5914                 /* Set fear */
5915                 m_ptr->monfear = (tmp < 200) ? tmp : 200;
5916
5917                 /* Get angry */
5918                 get_angry = TRUE;
5919         }
5920
5921
5922         /* If another monster did the damage, hurt the monster by hand */
5923         if (who)
5924         {
5925                 /* Redraw (later) if needed */
5926                 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
5927                 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
5928
5929                 /* Wake the monster up */
5930                 m_ptr->csleep = 0;
5931
5932                 /* Hurt the monster */
5933                 m_ptr->hp -= dam;
5934
5935                 /* Dead monster */
5936                 if (m_ptr->hp < 0)
5937                 {
5938                         bool sad = FALSE;
5939
5940                         if (is_pet(m_ptr) && !(m_ptr->ml))
5941                                 sad = TRUE;
5942
5943                         /* Give detailed messages if destroyed */
5944                         if (known && note)
5945                         {
5946                                 monster_desc(m_name, m_ptr, 0x100);
5947                                 if (see_s)
5948                                 {
5949                                         msg_format("%^s%s", m_name, note);
5950                                 }
5951                                 else
5952                                 {
5953                                         mon_fight = TRUE;
5954                                 }
5955                         }
5956
5957                         monster_gain_exp(who, m_ptr->r_idx);
5958
5959                         /* Generate treasure, etc */
5960                         monster_death(c_ptr->m_idx, FALSE);
5961
5962                         /* Delete the monster */
5963                         delete_monster_idx(c_ptr->m_idx);
5964
5965                         if (sad)
5966                         {
5967 #ifdef JP
5968 msg_print("¾¯¤·Èᤷ¤¤µ¤Ê¬¤¬¤·¤¿¡£");
5969 #else
5970                                 msg_print("You feel sad for a moment.");
5971 #endif
5972
5973                         }
5974                 }
5975
5976                 /* Damaged monster */
5977                 else
5978                 {
5979                         /* Give detailed messages if visible or destroyed */
5980                         if (note && seen) msg_format("%^s%s", m_name, note);
5981
5982                         /* Hack -- Pain message */
5983                         else if (see_s)
5984                         {
5985                                 message_pain(c_ptr->m_idx, dam);
5986                         }
5987                         else
5988                         {
5989                                 mon_fight = TRUE;
5990                         }
5991
5992                         /* Hack -- handle sleep */
5993                         if (do_sleep) m_ptr->csleep = do_sleep;
5994                 }
5995         }
5996
5997         else if (heal_leper)
5998         {
5999 #ifdef JP
6000 msg_print("ÉÔ·é¤ÊÉ¿ͤÏɵ¤¤¬¼£¤Ã¤¿¡ª");
6001 #else
6002                 msg_print("The Mangy looking leper is healed!");
6003 #endif
6004
6005                 delete_monster_idx(c_ptr->m_idx);
6006         }
6007         /* If the player did it, give him experience, check fear */
6008         else if (typ != GF_DRAIN_MANA)
6009         {
6010                 bool fear = FALSE;
6011
6012                 /* Hurt the monster, check for fear and death */
6013                 if (mon_take_hit(c_ptr->m_idx, dam, &fear, note_dies))
6014                 {
6015                         /* Dead monster */
6016                 }
6017
6018                 /* Damaged monster */
6019                 else
6020                 {
6021                         /* HACK - anger the monster before showing the sleep message */
6022                         if (do_sleep) anger_monster(m_ptr);
6023
6024                         /* Give detailed messages if visible or destroyed */
6025                         if (note && seen)
6026 #ifdef JP
6027 msg_format("%s%s", m_name, note);
6028 #else
6029                                 msg_format("%^s%s", m_name, note);
6030 #endif
6031
6032
6033                         /* Hack -- Pain message */
6034                         else if (known)
6035                         {
6036                                 message_pain(c_ptr->m_idx, dam);
6037                         }
6038
6039                         /* Anger monsters */
6040                         if (((dam > 0) || get_angry) && !do_sleep)
6041                                 anger_monster(m_ptr);
6042
6043                         /* Take note */
6044                         if ((fear || do_fear) && (m_ptr->ml))
6045                         {
6046                                 /* Sound */
6047                                 sound(SOUND_FLEE);
6048
6049                                 /* Message */
6050 #ifdef JP
6051 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
6052 #else
6053                                 msg_format("%^s flees in terror!", m_name);
6054 #endif
6055
6056                         }
6057
6058                         /* Hack -- handle sleep */
6059                         if (do_sleep) m_ptr->csleep = do_sleep;
6060                 }
6061         }
6062
6063         if ((typ == GF_BLOOD_CURSE) && one_in_(4))
6064         {
6065                 int curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
6066                 int count = 0;
6067                 do
6068                 {
6069                         switch (randint1(28))
6070                         {
6071                         case 1: case 2:
6072                                 if (!count)
6073                                 {
6074 #ifdef JP
6075 msg_print("ÃÏÌ̤¬Íɤ줿...");
6076 #else
6077                                         msg_print("The ground trembles...");
6078 #endif
6079
6080                                         earthquake(ty, tx, 4 + randint0(4));
6081                                         if (!one_in_(6)) break;
6082                                 }
6083                         case 3: case 4: case 5: case 6:
6084                                 if (!count)
6085                                 {
6086                                         int dam = damroll(10, 10);
6087 #ifdef JP
6088 msg_print("½ã¿è¤ÊËâÎϤμ¡¸µ¤Ø¤ÎÈ⤬³«¤¤¤¿¡ª");
6089 #else
6090                                         msg_print("A portal opens to a plane of raw mana!");
6091 #endif
6092
6093                                         project(0, 8, ty,tx, dam, GF_MANA, curse_flg, -1);
6094                                         if (!one_in_(6)) break;
6095                                 }
6096                         case 7: case 8:
6097                                 if (!count)
6098                                 {
6099 #ifdef JP
6100 msg_print("¶õ´Ö¤¬ÏĤó¤À¡ª");
6101 #else
6102                                         msg_print("Space warps about you!");
6103 #endif
6104
6105                                         if (m_ptr->r_idx) teleport_away(c_ptr->m_idx, damroll(10, 10), FALSE);
6106                                         if (one_in_(13)) count += activate_hi_summon(ty, tx, TRUE);
6107                                         if (!one_in_(6)) break;
6108                                 }
6109                         case 9: case 10: case 11:
6110 #ifdef JP
6111 msg_print("¥¨¥Í¥ë¥®¡¼¤Î¤¦¤Í¤ê¤ò´¶¤¸¤¿¡ª");
6112 #else
6113                                 msg_print("You feel a surge of energy!");
6114 #endif
6115
6116                                 project(0, 7, ty, tx, 50, GF_DISINTEGRATE, curse_flg, -1);
6117                                 if (!one_in_(6)) break;
6118                         case 12: case 13: case 14: case 15: case 16:
6119                                 aggravate_monsters(0);
6120                                 if (!one_in_(6)) break;
6121                         case 17: case 18:
6122                                 count += activate_hi_summon(ty, tx, TRUE);
6123                                 if (!one_in_(6)) break;
6124                         case 19: case 20: case 21: case 22:
6125                         {
6126                                 bool pet = FALSE, friendly = FALSE;
6127
6128                                 if (one_in_(3))
6129                                 {
6130                                         friendly = TRUE;
6131                                 }
6132                                 else
6133                                 {
6134                                         pet = TRUE;
6135                                 }
6136                                 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));
6137                                 if (!one_in_(6)) break;
6138                         }
6139                         case 23: case 24: case 25:
6140                                 if (p_ptr->hold_life && (randint0(100) < 75)) break;
6141 #ifdef JP
6142 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
6143 #else
6144                                 msg_print("You feel your life draining away...");
6145 #endif
6146
6147                                 if (p_ptr->hold_life) lose_exp(p_ptr->exp / 160);
6148                                 else lose_exp(p_ptr->exp / 16);
6149                                 if (!one_in_(6)) break;
6150                         case 26: case 27: case 28:
6151                         {
6152                                 int i = 0;
6153                                 if (one_in_(13))
6154                                 {
6155                                         while (i < 6)
6156                                         {
6157                                                 do
6158                                                 {
6159                                                         (void)do_dec_stat(i);
6160                                                 }
6161                                                 while (one_in_(2));
6162
6163                                                 i++;
6164                                         }
6165                                 }
6166                                 else
6167                                 {
6168                                         (void)do_dec_stat(randint0(6));
6169                                 }
6170                                 break;
6171                         }
6172                         }
6173                 }
6174                 while (one_in_(5));
6175         }
6176
6177         if (p_ptr->inside_battle)
6178         {
6179                 p_ptr->health_who = c_ptr->m_idx;
6180                 p_ptr->redraw |= (PR_HEALTH);
6181                 redraw_stuff();
6182         }
6183
6184         /* XXX XXX XXX Verify this code */
6185
6186         /* Update the monster */
6187         update_mon(c_ptr->m_idx, FALSE);
6188
6189         /* Redraw the monster grid */
6190         lite_spot(y, x);
6191
6192
6193         /* Update monster recall window */
6194         if (p_ptr->monster_race_idx == m_ptr->r_idx)
6195         {
6196                 /* Window stuff */
6197                 p_ptr->window |= (PW_MONSTER);
6198         }
6199
6200         if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
6201         {
6202                 if (!who)
6203                 {
6204                         if (!projectable(m_ptr->fy, m_ptr->fx, py, px) && !(flg & PROJECT_NO_HANGEKI))
6205                         {
6206                                 set_target(m_ptr, monster_target_y, monster_target_x);
6207                         }
6208                 }
6209                 else if (is_pet(&m_list[who]) && (m_ptr->target_y != py) && (m_ptr->target_x != px))
6210                 {
6211                         set_target(m_ptr, m_list[who].fy, m_list[who].fx);
6212                 }
6213         }
6214
6215         if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx) && (dam > 0))
6216         {
6217                 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
6218                 rakubadam_m = (dam > 200) ? 200 : dam;
6219         }
6220
6221
6222         if (photo)
6223         {
6224                 object_type *q_ptr;
6225                 object_type forge;
6226
6227                 /* Get local object */
6228                 q_ptr = &forge;
6229
6230                 /* Prepare to make a Blade of Chaos */
6231                 object_prep(q_ptr, lookup_kind(TV_STATUE, SV_PHOTO));
6232
6233                 q_ptr->pval = photo;
6234
6235                 /* Mark the item as fully known */
6236                 q_ptr->ident |= (IDENT_MENTAL);
6237
6238                 /* Drop it in the dungeon */
6239                 (void)drop_near(q_ptr, -1, py, px);
6240         }
6241
6242         /* Track it */
6243         project_m_n++;
6244         project_m_x = x;
6245         project_m_y = y;
6246
6247         /* Return "Anything seen?" */
6248         return (obvious);
6249 }
6250
6251
6252 /*
6253  * Helper function for "project()" below.
6254  *
6255  * Handle a beam/bolt/ball causing damage to the player.
6256  *
6257  * This routine takes a "source monster" (by index), a "distance", a default
6258  * "damage", and a "damage type".  See "project_m()" above.
6259  *
6260  * If "rad" is non-zero, then the blast was centered elsewhere, and the damage
6261  * is reduced (see "project_m()" above).  This can happen if a monster breathes
6262  * at the player and hits a wall instead.
6263  *
6264  * NOTE (Zangband): 'Bolt' attacks can be reflected back, so we need
6265  * to know if this is actually a ball or a bolt spell
6266  *
6267  *
6268  * We return "TRUE" if any "obvious" effects were observed.  XXX XXX Actually,
6269  * we just assume that the effects were obvious, for historical reasons.
6270  */
6271 static bool project_p(int who, cptr who_name, int r, int y, int x, int dam, int typ, int a_rad, int monspell)
6272 {
6273         int k = 0;
6274
6275         /* Hack -- assume obvious */
6276         bool obvious = TRUE;
6277
6278         /* Player blind-ness */
6279         bool blind = (p_ptr->blind ? TRUE : FALSE);
6280
6281         /* Player needs a "description" (he is blind) */
6282         bool fuzzy = FALSE;
6283
6284         /* Source monster */
6285         monster_type *m_ptr;
6286
6287         /* Monster name (for attacks) */
6288         char m_name[80];
6289
6290         /* Monster name (for damage) */
6291         char killer[80];
6292
6293         /* Hack -- messages */
6294         cptr act = NULL;
6295
6296
6297         /* Player is not here */
6298         if ((x != px) || (y != py)) return (FALSE);
6299
6300         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (p_ptr->lev*3/5+20)) && who && (who != p_ptr->riding))
6301         {
6302                 kawarimi(TRUE);
6303                 return FALSE;
6304         }
6305
6306         /* Player cannot hurt himself */
6307         if (!who) return (FALSE);
6308         if (who == p_ptr->riding) return (FALSE);
6309
6310         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))
6311         {
6312                 byte t_y, t_x;
6313                 int max_attempts = 10;
6314
6315 #ifdef JP
6316 if (blind) msg_print("²¿¤«¤¬Ä·¤ÍÊ֤ä¿¡ª");
6317 else if (p_ptr->special_defense & KATA_FUUJIN) msg_print("É÷¤ÎÇ¡¤¯Éð´ï¤ò¿¶¤ë¤Ã¤ÆÃƤ­ÊÖ¤·¤¿¡ª");
6318 else msg_print("¹¶·â¤¬Ä·¤ÍÊ֤ä¿¡ª");
6319 #else
6320                 if (blind) msg_print("Something bounces!");
6321                 else msg_print("The attack bounces!");
6322 #endif
6323
6324
6325                 /* Choose 'new' target */
6326                 do
6327                 {
6328                         t_y = m_list[who].fy - 1 + randint1(3);
6329                         t_x = m_list[who].fx - 1 + randint1(3);
6330                         max_attempts--;
6331                 }
6332                 while (max_attempts && in_bounds2u(t_y, t_x) &&
6333                      !(player_has_los_bold(t_y, t_x)));
6334
6335                 if (max_attempts < 1)
6336                 {
6337                         t_y = m_list[who].fy;
6338                         t_x = m_list[who].fx;
6339                 }
6340
6341                 project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP|PROJECT_KILL), monspell);
6342
6343                 disturb(1, 0);
6344                 return TRUE;
6345         }
6346
6347         /* XXX XXX XXX */
6348         /* Limit maximum damage */
6349         if (dam > 1600) dam = 1600;
6350
6351         /* Reduce damage by distance */
6352         dam = (dam + r) / (r + 1);
6353
6354
6355         /* If the player is blind, be more descriptive */
6356         if (blind) fuzzy = TRUE;
6357
6358
6359         /* Get the source monster */
6360         m_ptr = &m_list[who];
6361
6362         /* Get the monster name */
6363         monster_desc(m_name, m_ptr, 0);
6364
6365         /* Get the monster's real name (gotten before polymorph!) */
6366         strcpy(killer, who_name);
6367
6368         /* Analyze the damage */
6369         switch (typ)
6370         {
6371                 /* Standard damage -- hurts inventory too */
6372                 case GF_ACID:
6373                 {
6374 #ifdef JP
6375 if (fuzzy) msg_print("»À¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6376 #else
6377                         if (fuzzy) msg_print("You are hit by acid!");
6378 #endif
6379
6380                         acid_dam(dam, killer, monspell);
6381                         break;
6382                 }
6383
6384                 /* Standard damage -- hurts inventory too */
6385                 case GF_FIRE:
6386                 {
6387 #ifdef JP
6388 if (fuzzy) msg_print("²Ð±ê¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6389 #else
6390                         if (fuzzy) msg_print("You are hit by fire!");
6391 #endif
6392
6393                         fire_dam(dam, killer, monspell);
6394                         break;
6395                 }
6396
6397                 /* Standard damage -- hurts inventory too */
6398                 case GF_COLD:
6399                 {
6400 #ifdef JP
6401 if (fuzzy) msg_print("Î䵤¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6402 #else
6403                         if (fuzzy) msg_print("You are hit by cold!");
6404 #endif
6405
6406                         cold_dam(dam, killer, monspell);
6407                         break;
6408                 }
6409
6410                 /* Standard damage -- hurts inventory too */
6411                 case GF_ELEC:
6412                 {
6413 #ifdef JP
6414 if (fuzzy) msg_print("ÅÅ·â¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6415 #else
6416                         if (fuzzy) msg_print("You are hit by lightning!");
6417 #endif
6418
6419                         elec_dam(dam, killer, monspell);
6420                         break;
6421                 }
6422
6423                 /* Standard damage -- also poisons player */
6424                 case GF_POIS:
6425                 {
6426                         bool double_resist = (p_ptr->oppose_pois  || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
6427 #ifdef JP
6428 if (fuzzy) msg_print("ÆǤǹ¶·â¤µ¤ì¤¿¡ª");
6429 #else
6430                         if (fuzzy) msg_print("You are hit by poison!");
6431 #endif
6432
6433                         if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6434                         if (double_resist) dam = (dam + 2) / 3;
6435
6436                         if ((!(double_resist || p_ptr->resist_pois)) &&
6437                              one_in_(HURT_CHANCE))
6438                         {
6439                                 do_dec_stat(A_CON);
6440                         }
6441
6442                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6443
6444                         if (!(double_resist || p_ptr->resist_pois))
6445                         {
6446                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
6447                         }
6448                         break;
6449                 }
6450
6451                 /* Standard damage -- also poisons / mutates player */
6452                 case GF_NUKE:
6453                 {
6454                         bool double_resist = (p_ptr->oppose_pois  || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
6455 #ifdef JP
6456 if (fuzzy) msg_print("Êü¼Íǽ¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6457 #else
6458                         if (fuzzy) msg_print("You are hit by radiation!");
6459 #endif
6460
6461                         if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6462                         if (double_resist) dam = (2 * dam + 2) / 5;
6463                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6464                         if (!(double_resist || p_ptr->resist_pois))
6465                         {
6466                                 set_poisoned(p_ptr->poisoned + randint0(dam) + 10);
6467
6468                                 if (one_in_(5)) /* 6 */
6469                                 {
6470 #ifdef JP
6471 msg_print("´ñ·ÁŪ¤ÊÊѿȤò¿ë¤²¤¿¡ª");
6472 #else
6473                                         msg_print("You undergo a freakish metamorphosis!");
6474 #endif
6475
6476                                         if (one_in_(4)) /* 4 */
6477                                                 do_poly_self();
6478                                         else
6479                                                 mutate_player();
6480                                 }
6481
6482                                 if (one_in_(6))
6483                                 {
6484                                         inven_damage(set_acid_destroy, 2);
6485                                 }
6486                         }
6487                         break;
6488                 }
6489
6490                 /* Standard damage */
6491                 case GF_MISSILE:
6492                 {
6493 #ifdef JP
6494 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6495 #else
6496                         if (fuzzy) msg_print("You are hit by something!");
6497 #endif
6498
6499                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6500                         break;
6501                 }
6502
6503                 /* Holy Orb -- Player only takes partial damage */
6504                 case GF_HOLY_FIRE:
6505                 {
6506 #ifdef JP
6507 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6508 #else
6509                         if (fuzzy) msg_print("You are hit by something!");
6510 #endif
6511
6512                         if (p_ptr->align > 10)
6513                                 dam /= 2;
6514                         else if (p_ptr->align < -10)
6515                                 dam *= 2;
6516                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6517                         break;
6518                 }
6519
6520                 case GF_HELL_FIRE:
6521                 {
6522 #ifdef JP
6523 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6524 #else
6525                         if (fuzzy) msg_print("You are hit by something!");
6526 #endif
6527
6528                         if (p_ptr->align > 10)
6529                                 dam *= 2;
6530                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6531                         break;
6532                 }
6533
6534                 /* Arrow -- XXX no dodging */
6535                 case GF_ARROW:
6536                 {
6537 #ifdef JP
6538 if (fuzzy) msg_print("²¿¤«±Ô¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6539 #else
6540                         if (fuzzy) msg_print("You are hit by something sharp!");
6541 #endif
6542
6543                         else if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
6544                         {
6545 #ifdef JP
6546                                 msg_print("Ìð¤ò»Â¤ê¼Î¤Æ¤¿¡ª");
6547 #else
6548                                 msg_print("You cut down the arrow!");
6549 #endif
6550                                 break;
6551                         }
6552                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6553                         break;
6554                 }
6555
6556                 /* Plasma -- XXX No resist */
6557                 case GF_PLASMA:
6558                 {
6559 #ifdef JP
6560 if (fuzzy) msg_print("²¿¤«¤È¤Æ¤âÇ®¤¤¤â¤Î¤Ç¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6561 #else
6562                         if (fuzzy) msg_print("You are hit by something *HOT*!");
6563 #endif
6564
6565                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6566
6567                         if (!p_ptr->resist_sound)
6568                         {
6569                                 int k = (randint1((dam > 40) ? 35 : (dam * 3 / 4 + 5)));
6570                                 (void)set_stun(p_ptr->stun + k);
6571                         }
6572
6573                         if (!(p_ptr->resist_fire ||
6574                               p_ptr->oppose_fire ||
6575                               music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU) ||
6576                               p_ptr->immune_fire))
6577                         {
6578                                 inven_damage(set_acid_destroy, 3);
6579                         }
6580
6581                         break;
6582                 }
6583
6584                 /* Nether -- drain experience */
6585                 case GF_NETHER:
6586                 {
6587 #ifdef JP
6588 if (fuzzy) msg_print("ÃϹö¤ÎÎϤǹ¶·â¤µ¤ì¤¿¡ª");
6589 #else
6590                         if (fuzzy) msg_print("You are hit by nether forces!");
6591 #endif
6592
6593
6594                         if (p_ptr->resist_neth)
6595                         {
6596                                 if (!prace_is_(RACE_SPECTRE))
6597                                         dam *= 6; dam /= (randint1(4) + 7);
6598                         }
6599                         else if (p_ptr->prace != RACE_ANDROID)
6600                         {
6601                                 if (p_ptr->hold_life && (randint0(100) < 75))
6602                                 {
6603 #ifdef JP
6604 msg_print("¤·¤«¤·¼«¸Ê¤ÎÀ¸Ì¿ÎϤò¼é¤ê¤­¤Ã¤¿¡ª");
6605 #else
6606                                         msg_print("You keep hold of your life force!");
6607 #endif
6608
6609                                 }
6610                                 else if (p_ptr->hold_life)
6611                                 {
6612 #ifdef JP
6613 msg_print("À¸Ì¿ÎϤ¬¾¯¤·ÂΤ«¤éÈ´¤±Íî¤Á¤¿µ¤¤¬¤¹¤ë¡ª");
6614 #else
6615                                         msg_print("You feel your life slipping away!");
6616 #endif
6617
6618                                         lose_exp(200 + (p_ptr->exp / 1000) * MON_DRAIN_LIFE);
6619                                 }
6620                                 else
6621                                 {
6622 #ifdef JP
6623 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
6624 #else
6625                                         msg_print("You feel your life draining away!");
6626 #endif
6627
6628                                         lose_exp(200 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
6629                                 }
6630                         }
6631
6632                         if (prace_is_(RACE_SPECTRE))
6633                         {
6634 #ifdef JP
6635 msg_print("µ¤Ê¬¤¬¤è¤¯¤Ê¤Ã¤¿¡£");
6636 #else
6637                                 msg_print("You feel invigorated!");
6638 #endif
6639
6640                                 hp_player(dam / 4);
6641                                 learn_spell(monspell);
6642                         }
6643                         else
6644                         {
6645                                 take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6646                         }
6647
6648                         break;
6649                 }
6650
6651                 /* Water -- stun/confuse */
6652                 case GF_WATER:
6653                 {
6654 #ifdef JP
6655 if (fuzzy) msg_print("²¿¤«¼¾¤Ã¤¿¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6656 #else
6657                         if (fuzzy) msg_print("You are hit by something wet!");
6658 #endif
6659
6660                         if (!p_ptr->resist_sound)
6661                         {
6662                                 set_stun(p_ptr->stun + randint1(40));
6663                         }
6664                         if (!p_ptr->resist_conf)
6665                         {
6666                                 set_confused(p_ptr->confused + randint1(5) + 5);
6667                         }
6668
6669                         if (one_in_(5))
6670                         {
6671                                 inven_damage(set_cold_destroy, 3);
6672                         }
6673
6674                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6675                         break;
6676                 }
6677
6678                 /* Chaos -- many effects */
6679                 case GF_CHAOS:
6680                 {
6681 #ifdef JP
6682 if (fuzzy) msg_print("̵Ãá½ø¤ÎÇÈÆ°¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6683 #else
6684                         if (fuzzy) msg_print("You are hit by a wave of anarchy!");
6685 #endif
6686
6687                         if (p_ptr->resist_chaos)
6688                         {
6689                                 dam *= 6; dam /= (randint1(4) + 7);
6690                         }
6691                         if (!p_ptr->resist_conf)
6692                         {
6693                                 (void)set_confused(p_ptr->confused + randint0(20) + 10);
6694                         }
6695                         if (!p_ptr->resist_chaos)
6696                         {
6697                                 (void)set_image(p_ptr->image + randint1(10));
6698                                 if (one_in_(3))
6699                                 {
6700 #ifdef JP
6701 msg_print("¤¢¤Ê¤¿¤Î¿ÈÂΤϥ«¥ª¥¹¤ÎÎϤÇDZ¤¸¶Ê¤²¤é¤ì¤¿¡ª");
6702 #else
6703                                         msg_print("Your body is twisted by chaos!");
6704 #endif
6705
6706                                         (void)gain_random_mutation(0);
6707                                 }
6708                         }
6709                         if (!p_ptr->resist_neth && !p_ptr->resist_chaos)
6710                         {
6711                                 if (p_ptr->prace == RACE_ANDROID)
6712                                 {
6713                                 }
6714                                 else if (p_ptr->hold_life && (randint0(100) < 75))
6715                                 {
6716 #ifdef JP
6717 msg_print("¤·¤«¤·¼«¸Ê¤ÎÀ¸Ì¿ÎϤò¼é¤ê¤­¤Ã¤¿¡ª");
6718 #else
6719                                         msg_print("You keep hold of your life force!");
6720 #endif
6721
6722                                 }
6723                                 else if (p_ptr->hold_life)
6724                                 {
6725 #ifdef JP
6726 msg_print("À¸Ì¿ÎϤ¬¾¯¤·ÂΤ«¤éÈ´¤±Íî¤Á¤¿µ¤¤¬¤¹¤ë¡ª");
6727 #else
6728                                         msg_print("You feel your life slipping away!");
6729 #endif
6730
6731                                         lose_exp(500 + (p_ptr->exp / 1000) * MON_DRAIN_LIFE);
6732                                 }
6733                                 else
6734                                 {
6735 #ifdef JP
6736 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
6737 #else
6738                                         msg_print("You feel your life draining away!");
6739 #endif
6740
6741                                         lose_exp(5000 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
6742                                 }
6743                         }
6744                         if (!p_ptr->resist_chaos || one_in_(9))
6745                         {
6746                                 inven_damage(set_elec_destroy, 2);
6747                                 inven_damage(set_fire_destroy, 2);
6748                         }
6749                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6750                         break;
6751                 }
6752
6753                 /* Shards -- mostly cutting */
6754                 case GF_SHARDS:
6755                 {
6756 #ifdef JP
6757 if (fuzzy) msg_print("²¿¤«±Ô¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6758 #else
6759                         if (fuzzy) msg_print("You are hit by something sharp!");
6760 #endif
6761
6762                         if (p_ptr->resist_shard)
6763                         {
6764                                 dam *= 6; dam /= (randint1(4) + 7);
6765                         }
6766                         else
6767                         {
6768                                 (void)set_cut(p_ptr->cut + dam);
6769                         }
6770
6771                         if (!p_ptr->resist_shard || one_in_(13))
6772                         {
6773                                 inven_damage(set_cold_destroy, 2);
6774                         }
6775
6776                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6777                         break;
6778                 }
6779
6780                 /* Sound -- mostly stunning */
6781                 case GF_SOUND:
6782                 {
6783 #ifdef JP
6784 if (fuzzy) msg_print("¹ì²»¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6785 #else
6786                         if (fuzzy) msg_print("You are hit by a loud noise!");
6787 #endif
6788
6789                         if (p_ptr->resist_sound)
6790                         {
6791                                 dam *= 5; dam /= (randint1(4) + 7);
6792                         }
6793                         else
6794                         {
6795                                 int k = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
6796                                 (void)set_stun(p_ptr->stun + k);
6797                         }
6798
6799                         if (!p_ptr->resist_sound || one_in_(13))
6800                         {
6801                                 inven_damage(set_cold_destroy, 2);
6802                         }
6803
6804                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6805                         break;
6806                 }
6807
6808                 /* Pure confusion */
6809                 case GF_CONFUSION:
6810                 {
6811 #ifdef JP
6812 if (fuzzy) msg_print("²¿¤«º®Í𤹤ë¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6813 #else
6814                         if (fuzzy) msg_print("You are hit by something puzzling!");
6815 #endif
6816
6817                         if (p_ptr->resist_conf)
6818                         {
6819                                 dam *= 5; dam /= (randint1(4) + 7);
6820                         }
6821                         if (!p_ptr->resist_conf)
6822                         {
6823                                 (void)set_confused(p_ptr->confused + randint1(20) + 10);
6824                         }
6825                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6826                         break;
6827                 }
6828
6829                 /* Disenchantment -- see above */
6830                 case GF_DISENCHANT:
6831                 {
6832 #ifdef JP
6833 if (fuzzy) msg_print("²¿¤«¤µ¤¨¤Ê¤¤¤â¤Î¤Ç¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6834 #else
6835                         if (fuzzy) msg_print("You are hit by something static!");
6836 #endif
6837
6838                         if (p_ptr->resist_disen)
6839                         {
6840                                 dam *= 6; dam /= (randint1(4) + 7);
6841                         }
6842                         else
6843                         {
6844                                 (void)apply_disenchant(0);
6845                         }
6846                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6847                         break;
6848                 }
6849
6850                 /* Nexus -- see above */
6851                 case GF_NEXUS:
6852                 {
6853 #ifdef JP
6854 if (fuzzy) msg_print("²¿¤«´ñ̯¤Ê¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6855 #else
6856                         if (fuzzy) msg_print("You are hit by something strange!");
6857 #endif
6858
6859                         if (p_ptr->resist_nexus)
6860                         {
6861                                 dam *= 6; dam /= (randint1(4) + 7);
6862                         }
6863                         else
6864                         {
6865                                 apply_nexus(m_ptr);
6866                         }
6867                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6868                         break;
6869                 }
6870
6871                 /* Force -- mostly stun */
6872                 case GF_FORCE:
6873                 {
6874 #ifdef JP
6875 if (fuzzy) msg_print("±¿Æ°¥¨¥Í¥ë¥®¡¼¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6876 #else
6877                         if (fuzzy) msg_print("You are hit by kinetic force!");
6878 #endif
6879
6880                         if (!p_ptr->resist_sound)
6881                         {
6882                                 (void)set_stun(p_ptr->stun + randint1(20));
6883                         }
6884                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6885                         break;
6886                 }
6887
6888
6889                 /* Rocket -- stun, cut */
6890                 case GF_ROCKET:
6891                 {
6892 #ifdef JP
6893 if (fuzzy) msg_print("Çúȯ¤¬¤¢¤Ã¤¿¡ª");
6894 #else
6895                         if (fuzzy) msg_print("There is an explosion!");
6896 #endif
6897
6898                         if (!p_ptr->resist_sound)
6899                         {
6900                                 (void)set_stun(p_ptr->stun + randint1(20));
6901                         }
6902                         if (p_ptr->resist_shard)
6903                         {
6904                                 dam /= 2;
6905                         }
6906                         else
6907                         {
6908                                 (void)set_cut(p_ptr->  cut + ( dam / 2));
6909                         }
6910
6911                         if ((!p_ptr->resist_shard) || one_in_(12))
6912                         {
6913                                 inven_damage(set_cold_destroy, 3);
6914                         }
6915
6916                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6917                         break;
6918                 }
6919
6920                 /* Inertia -- slowness */
6921                 case GF_INERTIA:
6922                 {
6923 #ifdef JP
6924 if (fuzzy) msg_print("²¿¤«ÃÙ¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6925 #else
6926                         if (fuzzy) msg_print("You are hit by something slow!");
6927 #endif
6928
6929                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
6930                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6931                         break;
6932                 }
6933
6934                 /* Lite -- blinding */
6935                 case GF_LITE:
6936                 {
6937 #ifdef JP
6938 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6939 #else
6940                         if (fuzzy) msg_print("You are hit by something!");
6941 #endif
6942
6943                         if (p_ptr->resist_lite)
6944                         {
6945                                 dam *= 4; dam /= (randint1(4) + 7);
6946                         }
6947                         else if (!blind && !p_ptr->resist_blind)
6948                         {
6949                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
6950                         }
6951                         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
6952                         {
6953 #ifdef JP
6954 msg_print("¸÷¤ÇÆùÂΤ¬¾Ç¤¬¤µ¤ì¤¿¡ª");
6955 #else
6956                                 msg_print("The light scorches your flesh!");
6957 #endif
6958
6959                                 dam *= 2;
6960                         }
6961                         else if (prace_is_(RACE_S_FAIRY))
6962                         {
6963                                 dam = dam * 4 / 3;
6964                         }
6965                         if (p_ptr->wraith_form) dam *= 2;
6966                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
6967
6968                         if (p_ptr->wraith_form)
6969                         {
6970                                 p_ptr->wraith_form = 0;
6971 #ifdef JP
6972 msg_print("Á®¸÷¤Î¤¿¤áÈóʪ¼ÁŪ¤Ê±Æ¤Î¸ºß¤Ç¤¤¤é¤ì¤Ê¤¯¤Ê¤Ã¤¿¡£");
6973 #else
6974                                 msg_print("The light forces you out of your incorporeal shadow form.");
6975 #endif
6976
6977                                 p_ptr->redraw |= PR_MAP;
6978                                 /* Update monsters */
6979                                 p_ptr->update |= (PU_MONSTERS);
6980                                 /* Window stuff */
6981                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
6982
6983                                 /* Redraw status bar */
6984                                 p_ptr->redraw |= (PR_STATUS);
6985
6986                         }
6987
6988                         break;
6989                 }
6990
6991                 /* Dark -- blinding */
6992                 case GF_DARK:
6993                 {
6994 #ifdef JP
6995 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
6996 #else
6997                         if (fuzzy) msg_print("You are hit by something!");
6998 #endif
6999
7000                         if (p_ptr->resist_dark)
7001                         {
7002                                 dam *= 4; dam /= (randint1(4) + 7);
7003
7004                                 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
7005                         }
7006                         else if (!blind && !p_ptr->resist_blind)
7007                         {
7008                                 (void)set_blind(p_ptr->blind + randint1(5) + 2);
7009                         }
7010                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7011                         break;
7012                 }
7013
7014                 /* Time -- bolt fewer effects XXX */
7015                 case GF_TIME:
7016                 {
7017 #ifdef JP
7018 if (fuzzy) msg_print("²áµî¤«¤é¤Î¾×·â¤Ë¹¶·â¤µ¤ì¤¿¡ª");
7019 #else
7020                         if (fuzzy) msg_print("You are hit by a blast from the past!");
7021 #endif
7022
7023                         if (p_ptr->resist_time)
7024                         {
7025                                 dam *= 4;
7026                                 dam /= (randint1(4) + 7);
7027 #ifdef JP
7028 msg_print("»þ´Ö¤¬Ä̤ê²á¤®¤Æ¤¤¤¯µ¤¤¬¤¹¤ë¡£");
7029 #else
7030                                 msg_print("You feel as if time is passing you by.");
7031 #endif
7032
7033                         }
7034                         else
7035                         {
7036                                 switch (randint1(10))
7037                                 {
7038                                         case 1: case 2: case 3: case 4: case 5:
7039                                         {
7040                                                 if (p_ptr->prace == RACE_ANDROID) break;
7041 #ifdef JP
7042 msg_print("¿ÍÀ¸¤¬µÕÌá¤ê¤·¤¿µ¤¤¬¤¹¤ë¡£");
7043 #else
7044                                                 msg_print("You feel life has clocked back.");
7045 #endif
7046
7047                                                 lose_exp(100 + (p_ptr->exp / 100) * MON_DRAIN_LIFE);
7048                                                 break;
7049                                         }
7050
7051                                         case 6: case 7: case 8: case 9:
7052                                         {
7053                                                 switch (randint1(6))
7054                                                 {
7055 #ifdef JP
7056 case 1: k = A_STR; act = "¶¯¤¯"; break;
7057 case 2: k = A_INT; act = "ÁïÌÀ¤Ç"; break;
7058 case 3: k = A_WIS; act = "¸­ÌÀ¤Ç"; break;
7059 case 4: k = A_DEX; act = "´ïÍѤÇ"; break;
7060 case 5: k = A_CON; act = "·ò¹¯¤Ç"; break;
7061 case 6: k = A_CHR; act = "Èþ¤·¤¯"; break;
7062 #else
7063                                                         case 1: k = A_STR; act = "strong"; break;
7064                                                         case 2: k = A_INT; act = "bright"; break;
7065                                                         case 3: k = A_WIS; act = "wise"; break;
7066                                                         case 4: k = A_DEX; act = "agile"; break;
7067                                                         case 5: k = A_CON; act = "hale"; break;
7068                                                         case 6: k = A_CHR; act = "beautiful"; break;
7069 #endif
7070
7071                                                 }
7072
7073 #ifdef JP
7074 msg_format("¤¢¤Ê¤¿¤Ï°ÊÁ°¤Û¤É%s¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿...¡£", act);
7075 #else
7076                                                 msg_format("You're not as %s as you used to be...", act);
7077 #endif
7078
7079
7080                                                 p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 3) / 4;
7081                                                 if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
7082                                                 p_ptr->update |= (PU_BONUS);
7083                                                 break;
7084                                         }
7085
7086                                         case 10:
7087                                         {
7088 #ifdef JP
7089 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤Û¤ÉÎ϶¯¤¯¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿...¡£");
7090 #else
7091                                                 msg_print("You're not as powerful as you used to be...");
7092 #endif
7093
7094
7095                                                 for (k = 0; k < 6; k++)
7096                                                 {
7097                                                         p_ptr->stat_cur[k] = (p_ptr->stat_cur[k] * 7) / 8;
7098                                                         if (p_ptr->stat_cur[k] < 3) p_ptr->stat_cur[k] = 3;
7099                                                 }
7100                                                 p_ptr->update |= (PU_BONUS);
7101                                                 break;
7102                                         }
7103                                 }
7104                         }
7105
7106                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7107                         break;
7108                 }
7109
7110                 /* Gravity -- stun plus slowness plus teleport */
7111                 case GF_GRAVITY:
7112                 {
7113 #ifdef JP
7114 if (fuzzy) msg_print("²¿¤«½Å¤¤¤â¤Î¤Ç¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7115 msg_print("¼þÊդνÅÎϤ¬¤æ¤¬¤ó¤À¡£");
7116 #else
7117                         if (fuzzy) msg_print("You are hit by something heavy!");
7118                         msg_print("Gravity warps around you.");
7119 #endif
7120
7121                         teleport_player(5);
7122                         if (!p_ptr->ffall)
7123                                 (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
7124                         if (!(p_ptr->resist_sound || p_ptr->ffall))
7125                         {
7126                                 int k = (randint1((dam > 90) ? 35 : (dam / 3 + 5)));
7127                                 (void)set_stun(p_ptr->stun + k);
7128                         }
7129                         if (p_ptr->ffall)
7130                         {
7131                                 dam = (dam * 2) / 3;
7132                         }
7133
7134                         if (!p_ptr->ffall || one_in_(13))
7135                         {
7136                                 inven_damage(set_cold_destroy, 2);
7137                         }
7138
7139                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7140                         break;
7141                 }
7142
7143                 /* Standard damage */
7144                 case GF_DISINTEGRATE:
7145                 {
7146 #ifdef JP
7147 if (fuzzy) msg_print("½ã¿è¤Ê¥¨¥Í¥ë¥®¡¼¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7148 #else
7149                         if (fuzzy) msg_print("You are hit by pure energy!");
7150 #endif
7151
7152                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7153                         break;
7154                 }
7155
7156                 case GF_OLD_HEAL:
7157                 {
7158 #ifdef JP
7159 if (fuzzy) msg_print("²¿¤é¤«¤Î¹¶·â¤Ë¤è¤Ã¤Æµ¤Ê¬¤¬¤è¤¯¤Ê¤Ã¤¿¡£");
7160 #else
7161                         if (fuzzy) msg_print("You are hit by something invigorating!");
7162 #endif
7163
7164                         (void)hp_player(dam);
7165                         dam = 0;
7166                         break;
7167                 }
7168
7169                 case GF_OLD_SPEED:
7170                 {
7171 #ifdef JP
7172 if (fuzzy) msg_print("²¿¤«¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7173 #else
7174                         if (fuzzy) msg_print("You are hit by something!");
7175 #endif
7176
7177                         (void)set_fast(p_ptr->fast + randint1(5), FALSE);
7178                         dam = 0;
7179                         break;
7180                 }
7181
7182                 case GF_OLD_SLOW:
7183                 {
7184 #ifdef JP
7185 if (fuzzy) msg_print("²¿¤«ÃÙ¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7186 #else
7187                         if (fuzzy) msg_print("You are hit by something slow!");
7188 #endif
7189
7190                         (void)set_slow(p_ptr->slow + randint0(4) + 4, FALSE);
7191                         break;
7192                 }
7193
7194                 case GF_OLD_SLEEP:
7195                 {
7196                         if (p_ptr->free_act)  break;
7197 #ifdef JP
7198 if (fuzzy) msg_print("̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
7199 #else
7200                         if (fuzzy) msg_print("You fall asleep!");
7201 #endif
7202
7203
7204                         if (ironman_nightmare)
7205                         {
7206 #ifdef JP
7207 msg_print("¶²¤í¤·¤¤¸÷·Ê¤¬Æ¬¤ËÉ⤫¤ó¤Ç¤­¤¿¡£");
7208 #else
7209                                 msg_print("A horrible vision enters your mind.");
7210 #endif
7211
7212
7213                                 /* Pick a nightmare */
7214                                 get_mon_num_prep(get_nightmare, NULL);
7215
7216                                 /* Have some nightmares */
7217                                 have_nightmare(get_mon_num(MAX_DEPTH));
7218
7219                                 /* Remove the monster restriction */
7220                                 get_mon_num_prep(NULL, NULL);
7221                         }
7222
7223                         set_paralyzed(p_ptr->paralyzed + dam);
7224                         dam = 0;
7225                         break;
7226                 }
7227
7228                 /* Pure damage */
7229                 case GF_MANA:
7230                 case GF_SEEKER:
7231                 case GF_SUPER_RAY:
7232                 {
7233 #ifdef JP
7234 if (fuzzy) msg_print("ËâË¡¤Î¥ª¡¼¥é¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7235 #else
7236                         if (fuzzy) msg_print("You are hit by an aura of magic!");
7237 #endif
7238
7239                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7240                         break;
7241                 }
7242
7243                 /* Pure damage */
7244                 case GF_PSY_SPEAR:
7245                 {
7246 #ifdef JP
7247 if (fuzzy) msg_print("¥¨¥Í¥ë¥®¡¼¤Î²ô¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7248 #else
7249                         if (fuzzy) msg_print("You are hit by an energy!");
7250 #endif
7251
7252                         take_hit(DAMAGE_FORCE, dam, killer, monspell);
7253                         break;
7254                 }
7255
7256                 /* Pure damage */
7257                 case GF_METEOR:
7258                 {
7259 #ifdef JP
7260 if (fuzzy) msg_print("²¿¤«¤¬¶õ¤«¤é¤¢¤Ê¤¿¤ÎƬ¾å¤ËÍî¤Á¤Æ¤­¤¿¡ª");
7261 #else
7262                         if (fuzzy) msg_print("Something falls from the sky on you!");
7263 #endif
7264
7265                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7266                         if (!p_ptr->resist_shard || one_in_(13))
7267                         {
7268                                 if (!p_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
7269                                 inven_damage(set_cold_destroy, 2);
7270                         }
7271
7272                         break;
7273                 }
7274
7275                 /* Ice -- cold plus stun plus cuts */
7276                 case GF_ICE:
7277                 {
7278 #ifdef JP
7279 if (fuzzy) msg_print("²¿¤«±Ô¤¯Î䤿¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7280 #else
7281                         if (fuzzy) msg_print("You are hit by something sharp and cold!");
7282 #endif
7283
7284                         cold_dam(dam, killer, monspell);
7285                         if (!p_ptr->resist_shard)
7286                         {
7287                                 (void)set_cut(p_ptr->cut + damroll(5, 8));
7288                         }
7289                         if (!p_ptr->resist_sound)
7290                         {
7291                                 (void)set_stun(p_ptr->stun + randint1(15));
7292                         }
7293
7294                         if ((!(p_ptr->resist_cold || p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))) || one_in_(12))
7295                         {
7296                                 if (!p_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
7297                         }
7298
7299                         break;
7300                 }
7301
7302                 /* Death Ray */
7303                 case GF_DEATH_RAY:
7304                 {
7305 #ifdef JP
7306 if (fuzzy) msg_print("²¿¤«Èó¾ï¤ËÎ䤿¤¤¤â¤Î¤Ç¹¶·â¤µ¤ì¤¿¡ª");
7307 #else
7308                         if (fuzzy) msg_print("You are hit by something extremely cold!");
7309 #endif
7310
7311
7312                         if (p_ptr->mimic_form)
7313                         {
7314                                 if (!(mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
7315                                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7316                         }
7317                         else
7318                         {
7319
7320                         switch (p_ptr->prace)
7321                         {
7322                                 /* Some races are immune */
7323                                 case RACE_GOLEM:
7324                                 case RACE_SKELETON:
7325                                 case RACE_ZOMBIE:
7326                                 case RACE_VAMPIRE:
7327                                 case RACE_DEMON:
7328                                 case RACE_SPECTRE:
7329                                 {
7330                                         dam = 0;
7331                                         break;
7332                                 }
7333                                 /* Hurt a lot */
7334                                 default:
7335                                 {
7336                                         take_hit(DAMAGE_ATTACK, dam, killer, monspell);
7337                                         break;
7338                                 }
7339                         }
7340                         }
7341
7342                         break;
7343                 }
7344
7345
7346                 /* Default */
7347                 default:
7348                 {
7349                         /* No damage */
7350                         dam = 0;
7351
7352                         break;
7353                 }
7354         }
7355
7356         if (p_ptr->riding && dam > 0)
7357         {
7358                 rakubadam_p = (dam > 200) ? 200 : dam;
7359         }
7360
7361
7362         /* Disturb */
7363         disturb(1, 0);
7364
7365
7366         if ((p_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != p_ptr->riding))
7367         {
7368                 kawarimi(FALSE);
7369                 return obvious;
7370         }
7371
7372         /* Return "Anything seen?" */
7373         return (obvious);
7374 }
7375
7376
7377 /*
7378  * Find the distance from (x, y) to a line.
7379  */
7380 int dist_to_line(int y, int x, int y1, int x1, int y2, int x2)
7381 {
7382         /* Vector from (x, y) to (x1, y1) */
7383         int py = y1 - y;
7384         int px = x1 - x;
7385
7386         /* Normal vector */
7387         int ny = x2 - x1;
7388         int nx = y1 - y2;
7389
7390    /* Length of N */
7391         int pd = distance(y1, x1, y, x);
7392         int nd = distance(y1, x1, y2, x2);
7393
7394         if (pd > nd) return distance(y, x, y2, x2);
7395
7396         /* Component of P on N */
7397         nd = ((nd) ? ((py * ny + px * nx) / nd) : 0);
7398
7399    /* Absolute value */
7400    return((nd >= 0) ? nd : 0 - nd);
7401 }
7402
7403
7404
7405 /*
7406  * XXX XXX XXX
7407  * Modified version of los() for calculation of disintegration balls.
7408  * Disintegration effects are stopped by permanent walls.
7409  */
7410 bool in_disintegration_range(int y1, int x1, int y2, int x2)
7411 {
7412         /* Delta */
7413         int dx, dy;
7414
7415         /* Absolute */
7416         int ax, ay;
7417
7418         /* Signs */
7419         int sx, sy;
7420
7421         /* Fractions */
7422         int qx, qy;
7423
7424         /* Scanners */
7425         int tx, ty;
7426
7427         /* Scale factors */
7428         int f1, f2;
7429
7430         /* Slope, or 1/Slope, of LOS */
7431         int m;
7432
7433
7434         /* Extract the offset */
7435         dy = y2 - y1;
7436         dx = x2 - x1;
7437
7438         /* Extract the absolute offset */
7439         ay = ABS(dy);
7440         ax = ABS(dx);
7441
7442
7443         /* Handle adjacent (or identical) grids */
7444         if ((ax < 2) && (ay < 2)) return (TRUE);
7445
7446
7447         /* Paranoia -- require "safe" origin */
7448         /* if (!in_bounds(y1, x1)) return (FALSE); */
7449
7450
7451         /* Directly South/North */
7452         if (!dx)
7453         {
7454                 /* South -- check for walls */
7455                 if (dy > 0)
7456                 {
7457                         for (ty = y1 + 1; ty < y2; ty++)
7458                         {
7459                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
7460                         }
7461                 }
7462
7463                 /* North -- check for walls */
7464                 else
7465                 {
7466                         for (ty = y1 - 1; ty > y2; ty--)
7467                         {
7468                                 if (cave_stop_disintegration(ty, x1)) return (FALSE);
7469                         }
7470                 }
7471
7472                 /* Assume los */
7473                 return (TRUE);
7474         }
7475
7476         /* Directly East/West */
7477         if (!dy)
7478         {
7479                 /* East -- check for walls */
7480                 if (dx > 0)
7481                 {
7482                         for (tx = x1 + 1; tx < x2; tx++)
7483                         {
7484                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
7485                         }
7486                 }
7487
7488                 /* West -- check for walls */
7489                 else
7490                 {
7491                         for (tx = x1 - 1; tx > x2; tx--)
7492                         {
7493                                 if (cave_stop_disintegration(y1, tx)) return (FALSE);
7494                         }
7495                 }
7496
7497                 /* Assume los */
7498                 return (TRUE);
7499         }
7500
7501
7502         /* Extract some signs */
7503         sx = (dx < 0) ? -1 : 1;
7504         sy = (dy < 0) ? -1 : 1;
7505
7506
7507         /* Vertical "knights" */
7508         if (ax == 1)
7509         {
7510                 if (ay == 2)
7511                 {
7512                         if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
7513                 }
7514         }
7515
7516         /* Horizontal "knights" */
7517         else if (ay == 1)
7518         {
7519                 if (ax == 2)
7520                 {
7521                         if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
7522                 }
7523         }
7524
7525
7526         /* Calculate scale factor div 2 */
7527         f2 = (ax * ay);
7528
7529         /* Calculate scale factor */
7530         f1 = f2 << 1;
7531
7532
7533         /* Travel horizontally */
7534         if (ax >= ay)
7535         {
7536                 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
7537                 qy = ay * ay;
7538                 m = qy << 1;
7539
7540                 tx = x1 + sx;
7541
7542                 /* Consider the special case where slope == 1. */
7543                 if (qy == f2)
7544                 {
7545                         ty = y1 + sy;
7546                         qy -= f1;
7547                 }
7548                 else
7549                 {
7550                         ty = y1;
7551                 }
7552
7553                 /* Note (below) the case (qy == f2), where */
7554                 /* the LOS exactly meets the corner of a tile. */
7555                 while (x2 - tx)
7556                 {
7557                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
7558
7559                         qy += m;
7560
7561                         if (qy < f2)
7562                         {
7563                                 tx += sx;
7564                         }
7565                         else if (qy > f2)
7566                         {
7567                                 ty += sy;
7568                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
7569                                 qy -= f1;
7570                                 tx += sx;
7571                         }
7572                         else
7573                         {
7574                                 ty += sy;
7575                                 qy -= f1;
7576                                 tx += sx;
7577                         }
7578                 }
7579         }
7580
7581         /* Travel vertically */
7582         else
7583         {
7584                 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
7585                 qx = ax * ax;
7586                 m = qx << 1;
7587
7588                 ty = y1 + sy;
7589
7590                 if (qx == f2)
7591                 {
7592                         tx = x1 + sx;
7593                         qx -= f1;
7594                 }
7595                 else
7596                 {
7597                         tx = x1;
7598                 }
7599
7600                 /* Note (below) the case (qx == f2), where */
7601                 /* the LOS exactly meets the corner of a tile. */
7602                 while (y2 - ty)
7603                 {
7604                         if (cave_stop_disintegration(ty, tx)) return (FALSE);
7605
7606                         qx += m;
7607
7608                         if (qx < f2)
7609                         {
7610                                 ty += sy;
7611                         }
7612                         else if (qx > f2)
7613                         {
7614                                 tx += sx;
7615                                 if (cave_stop_disintegration(ty, tx)) return (FALSE);
7616                                 qx -= f1;
7617                                 ty += sy;
7618                         }
7619                         else
7620                         {
7621                                 tx += sx;
7622                                 qx -= f1;
7623                                 ty += sy;
7624                         }
7625                 }
7626         }
7627
7628         /* Assume los */
7629         return (TRUE);
7630 }
7631
7632 /*
7633  * breath shape
7634  */ 
7635 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)
7636 {
7637         int by, bx;
7638         int brad = 0;
7639         int bdis = 0;
7640         int cdis;
7641         
7642         /* Not done yet */
7643         bool done = FALSE;
7644         
7645         by = y1;
7646         bx = x1;
7647         
7648         while (bdis <= distance(y1, x1, y2, x2) + rad)
7649         {
7650                 /* Travel from center outward */
7651                 for (cdis = 0; cdis <= brad; cdis++)
7652                 {
7653                         int y,x;
7654                         /* Scan the maximal blast area of radius "cdis" */
7655                         for (y = by - cdis; y <= by + cdis; y++)
7656                         {
7657                                 for (x = bx - cdis; x <= bx + cdis; x++)
7658                                 {
7659                                         /* Ignore "illegal" locations */
7660                                         if (!in_bounds(y, x)) continue;
7661                                         
7662                                         /* Enforce a circular "ripple" */
7663                                         if (distance(y1, x1, y, x) != bdis) continue;
7664                                         
7665                                         /* Enforce an arc */
7666                                         if (distance(by, bx, y, x) != cdis) continue;
7667                                         
7668                                         if (disint_ball)
7669                                         {
7670                                                 /* Disintegration balls explosions are stopped by perma-walls */
7671                                                 if (!in_disintegration_range(by, bx, y, x)) continue;
7672                                                 
7673                                                 if (real_breath && cave_valid_bold(y, x) &&
7674                                                     (cave[y][x].feat < FEAT_PATTERN_START ||
7675                                                      cave[y][x].feat > FEAT_PATTERN_XTRA2) &&
7676                                                     (cave[y][x].feat < FEAT_DEEP_WATER ||
7677                                                      cave[y][x].feat > FEAT_GRASS))
7678                                                 {
7679                                                         if (cave[y][x].feat == FEAT_TREES)
7680                                                                 cave_set_feat(y, x, FEAT_GRASS);
7681                                                         else
7682                                                         {
7683                                                                 cave[y][x].feat = floor_type[randint0(100)];
7684                                                                 cave[y][x].info &= ~(CAVE_MASK);
7685                                                                 cave[y][x].info |= CAVE_FLOOR;
7686                                                         }
7687                                                 }
7688                                                 /* Update some things -- similar to GF_KILL_WALL */
7689                                                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
7690                                         }
7691                                         else
7692                                         {
7693                                                 /* The blast is stopped by walls */
7694                                                 if (!los(by, bx, y, x)) continue;
7695                                         }
7696                                         
7697                                         /* Save this grid */
7698                                         gy[*pgrids] = y;
7699                                         gx[*pgrids] = x;
7700                                         (*pgrids)++;
7701                                 }
7702                         }
7703                 }
7704                 
7705                 /* Encode some more "radius" info */
7706                 gm[bdis + 1] = *pgrids;
7707                 
7708                 /* Stop moving */
7709                 if ((by == y2) && (bx == x2)) done = TRUE;
7710                 
7711                 /* Finish */
7712                 if (done)
7713                 {
7714                         bdis++;
7715                         continue;
7716                 }
7717                 
7718                 /* Ripple outwards */
7719 /*              mmove2(&by, &bx, y1, x1, y2, x2); */
7720                 
7721                 by = GRID_Y(path_g[bdis]);
7722                 bx = GRID_X(path_g[bdis]);
7723         
7724                 /* Find the next ripple */
7725                 bdis++;
7726                 
7727                 /* Increase the size */
7728                 brad = (rad * bdis) / dist;
7729         }
7730         
7731         /* Store the effect size */
7732         *pgm_rad = bdis;
7733 }
7734
7735
7736 /*
7737  * Generic "beam"/"bolt"/"ball" projection routine.
7738  *
7739  * Input:
7740  *   who: Index of "source" monster (zero for "player")
7741  *   rad: Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
7742  *   y,x: Target location (or location to travel "towards")
7743  *   dam: Base damage roll to apply to affected monsters (or player)
7744  *   typ: Type of damage to apply to monsters (and objects)
7745  *   flg: Extra bit flags (see PROJECT_xxxx in "defines.h")
7746  *
7747  * Return:
7748  *   TRUE if any "effects" of the projection were observed, else FALSE
7749  *
7750  * Allows a monster (or player) to project a beam/bolt/ball of a given kind
7751  * towards a given location (optionally passing over the heads of interposing
7752  * monsters), and have it do a given amount of damage to the monsters (and
7753  * optionally objects) within the given radius of the final location.
7754  *
7755  * A "bolt" travels from source to target and affects only the target grid.
7756  * A "beam" travels from source to target, affecting all grids passed through.
7757  * A "ball" travels from source to the target, exploding at the target, and
7758  *   affecting everything within the given radius of the target location.
7759  *
7760  * Traditionally, a "bolt" does not affect anything on the ground, and does
7761  * not pass over the heads of interposing monsters, much like a traditional
7762  * missile, and will "stop" abruptly at the "target" even if no monster is
7763  * positioned there, while a "ball", on the other hand, passes over the heads
7764  * of monsters between the source and target, and affects everything except
7765  * the source monster which lies within the final radius, while a "beam"
7766  * affects every monster between the source and target, except for the casting
7767  * monster (or player), and rarely affects things on the ground.
7768  *
7769  * Two special flags allow us to use this function in special ways, the
7770  * "PROJECT_HIDE" flag allows us to perform "invisible" projections, while
7771  * the "PROJECT_JUMP" flag allows us to affect a specific grid, without
7772  * actually projecting from the source monster (or player).
7773  *
7774  * The player will only get "experience" for monsters killed by himself
7775  * Unique monsters can only be destroyed by attacks from the player
7776  *
7777  * Only 256 grids can be affected per projection, limiting the effective
7778  * "radius" of standard ball attacks to nine units (diameter nineteen).
7779  *
7780  * One can project in a given "direction" by combining PROJECT_THRU with small
7781  * offsets to the initial location (see "line_spell()"), or by calculating
7782  * "virtual targets" far away from the player.
7783  *
7784  * One can also use PROJECT_THRU to send a beam/bolt along an angled path,
7785  * continuing until it actually hits somethings (useful for "stone to mud").
7786  *
7787  * Bolts and Beams explode INSIDE walls, so that they can destroy doors.
7788  *
7789  * Balls must explode BEFORE hitting walls, or they would affect monsters
7790  * on both sides of a wall.  Some bug reports indicate that this is still
7791  * happening in 2.7.8 for Windows, though it appears to be impossible.
7792  *
7793  * We "pre-calculate" the blast area only in part for efficiency.
7794  * More importantly, this lets us do "explosions" from the "inside" out.
7795  * This results in a more logical distribution of "blast" treasure.
7796  * It also produces a better (in my opinion) animation of the explosion.
7797  * It could be (but is not) used to have the treasure dropped by monsters
7798  * in the middle of the explosion fall "outwards", and then be damaged by
7799  * the blast as it spreads outwards towards the treasure drop location.
7800  *
7801  * Walls and doors are included in the blast area, so that they can be
7802  * "burned" or "melted" in later versions.
7803  *
7804  * This algorithm is intended to maximize simplicity, not necessarily
7805  * efficiency, since this function is not a bottleneck in the code.
7806  *
7807  * We apply the blast effect from ground zero outwards, in several passes,
7808  * first affecting features, then objects, then monsters, then the player.
7809  * This allows walls to be removed before checking the object or monster
7810  * in the wall, and protects objects which are dropped by monsters killed
7811  * in the blast, and allows the player to see all affects before he is
7812  * killed or teleported away.  The semantics of this method are open to
7813  * various interpretations, but they seem to work well in practice.
7814  *
7815  * We process the blast area from ground-zero outwards to allow for better
7816  * distribution of treasure dropped by monsters, and because it provides a
7817  * pleasing visual effect at low cost.
7818  *
7819  * Note that the damage done by "ball" explosions decreases with distance.
7820  * This decrease is rapid, grids at radius "dist" take "1/dist" damage.
7821  *
7822  * Notice the "napalm" effect of "beam" weapons.  First they "project" to
7823  * the target, and then the damage "flows" along this beam of destruction.
7824  * The damage at every grid is the same as at the "center" of a "ball"
7825  * explosion, since the "beam" grids are treated as if they ARE at the
7826  * center of a "ball" explosion.
7827  *
7828  * Currently, specifying "beam" plus "ball" means that locations which are
7829  * covered by the initial "beam", and also covered by the final "ball", except
7830  * for the final grid (the epicenter of the ball), will be "hit twice", once
7831  * by the initial beam, and once by the exploding ball.  For the grid right
7832  * next to the epicenter, this results in 150% damage being done.  The center
7833  * does not have this problem, for the same reason the final grid in a "beam"
7834  * plus "bolt" does not -- it is explicitly removed.  Simply removing "beam"
7835  * grids which are covered by the "ball" will NOT work, as then they will
7836  * receive LESS damage than they should.  Do not combine "beam" with "ball".
7837  *
7838  * The array "gy[],gx[]" with current size "grids" is used to hold the
7839  * collected locations of all grids in the "blast area" plus "beam path".
7840  *
7841  * Note the rather complex usage of the "gm[]" array.  First, gm[0] is always
7842  * zero.  Second, for N>1, gm[N] is always the index (in gy[],gx[]) of the
7843  * first blast grid (see above) with radius "N" from the blast center.  Note
7844  * that only the first gm[1] grids in the blast area thus take full damage.
7845  * Also, note that gm[rad+1] is always equal to "grids", which is the total
7846  * number of blast grids.
7847  *
7848  * Note that once the projection is complete, (y2,x2) holds the final location
7849  * of bolts/beams, and the "epicenter" of balls.
7850  *
7851  * Note also that "rad" specifies the "inclusive" radius of projection blast,
7852  * so that a "rad" of "one" actually covers 5 or 9 grids, depending on the
7853  * implementation of the "distance" function.  Also, a bolt can be properly
7854  * viewed as a "ball" with a "rad" of "zero".
7855  *
7856  * Note that if no "target" is reached before the beam/bolt/ball travels the
7857  * maximum distance allowed (MAX_RANGE), no "blast" will be induced.  This
7858  * may be relevant even for bolts, since they have a "1x1" mini-blast.
7859  *
7860  * Note that for consistency, we "pretend" that the bolt actually takes "time"
7861  * to move from point A to point B, even if the player cannot see part of the
7862  * projection path.  Note that in general, the player will *always* see part
7863  * of the path, since it either starts at the player or ends on the player.
7864  *
7865  * Hack -- we assume that every "projection" is "self-illuminating".
7866  *
7867  * Hack -- when only a single monster is affected, we automatically track
7868  * (and recall) that monster, unless "PROJECT_JUMP" is used.
7869  *
7870  * Note that all projections now "explode" at their final destination, even
7871  * if they were being projected at a more distant destination.  This means
7872  * that "ball" spells will *always* explode.
7873  *
7874  * Note that we must call "handle_stuff()" after affecting terrain features
7875  * in the blast radius, in case the "illumination" of the grid was changed,
7876  * and "update_view()" and "update_monsters()" need to be called.
7877  */
7878 bool project(int who, int rad, int y, int x, int dam, int typ, int flg, int monspell)
7879 {
7880         int i, t, dist;
7881
7882         int y1, x1;
7883         int y2, x2;
7884
7885         int dist_hack = 0;
7886
7887         int y_saver, x_saver; /* For reflecting monsters */
7888
7889         int msec = delay_factor * delay_factor * delay_factor;
7890
7891         /* Assume the player sees nothing */
7892         bool notice = FALSE;
7893
7894         /* Assume the player has seen nothing */
7895         bool visual = FALSE;
7896
7897         /* Assume the player has seen no blast grids */
7898         bool drawn = FALSE;
7899
7900         /* Assume to be a normal ball spell */
7901         bool breath = FALSE;
7902
7903         /* Is the player blind? */
7904         bool blind = (p_ptr->blind ? TRUE : FALSE);
7905
7906         bool old_hide = FALSE;
7907
7908         /* Number of grids in the "path" */
7909         int path_n = 0;
7910
7911         /* Actual grids in the "path" */
7912         u16b path_g[512];
7913
7914         /* Number of grids in the "blast area" (including the "beam" path) */
7915         int grids = 0;
7916
7917         /* Coordinates of the affected grids */
7918         byte gx[1024], gy[1024];
7919
7920         /* Encoded "radius" info (see above) */
7921         byte gm[32];
7922
7923         /* Actual radius encoded in gm[] */
7924         int gm_rad = rad;
7925
7926         bool jump = FALSE;
7927
7928         /* Attacker's name (prepared before polymorph)*/
7929         char who_name[80];
7930
7931         rakubadam_p = 0;
7932         rakubadam_m = 0;
7933
7934         /* Default target of monsterspell is player */
7935         monster_target_y=py;
7936         monster_target_x=px;
7937
7938         /* Hack -- Jump to target */
7939         if (flg & (PROJECT_JUMP))
7940         {
7941                 x1 = x;
7942                 y1 = y;
7943
7944                 /* Clear the flag */
7945                 flg &= ~(PROJECT_JUMP);
7946
7947                 jump = TRUE;
7948         }
7949
7950         /* Start at player */
7951         else if (who <= 0)
7952         {
7953                 x1 = px;
7954                 y1 = py;
7955         }
7956
7957         /* Start at monster */
7958         else if (who > 0)
7959         {
7960                 x1 = m_list[who].fx;
7961                 y1 = m_list[who].fy;
7962                 monster_desc(who_name, &m_list[who], 0x288);
7963         }
7964
7965         /* Oops */
7966         else
7967         {
7968                 x1 = x;
7969                 y1 = y;
7970         }
7971
7972         y_saver = y1;
7973         x_saver = x1;
7974
7975         /* Default "destination" */
7976         y2 = y;
7977         x2 = x;
7978
7979
7980         /* Hack -- verify stuff */
7981         if (flg & (PROJECT_THRU))
7982         {
7983                 if ((x1 == x2) && (y1 == y2))
7984                 {
7985                         flg &= ~(PROJECT_THRU);
7986                 }
7987         }
7988
7989         /* Handle a breath attack */
7990         if (rad < 0)
7991         {
7992                 rad = 0 - rad;
7993                 breath = TRUE;
7994                 if (flg & PROJECT_HIDE) old_hide = TRUE;
7995                 flg |= PROJECT_HIDE;
7996         }
7997
7998
7999         /* Hack -- Assume there will be no blast (max radius 32) */
8000         for (dist = 0; dist < 32; dist++) gm[dist] = 0;
8001
8002
8003         /* Initial grid */
8004         y = y1;
8005         x = x1;
8006         dist = 0;
8007
8008         /* Collect beam grids */
8009         if (flg & (PROJECT_BEAM))
8010         {
8011                 gy[grids] = y;
8012                 gx[grids] = x;
8013                 grids++;
8014         }
8015
8016         if (breath && typ == GF_DISINTEGRATE)
8017         {
8018                 flg |= (PROJECT_DISI);
8019         }
8020
8021         /* Calculate the projection path */
8022
8023         path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
8024
8025         /* Hack -- Handle stuff */
8026         handle_stuff();
8027
8028         /* Giga-Hack SEEKER & SUPER_RAY */
8029
8030         if( typ == GF_SEEKER )
8031         {
8032                 int j;
8033                 int last_i=0;
8034
8035                 /* Mega-Hack */
8036                 project_m_n = 0;
8037                 project_m_x = 0;
8038                 project_m_y = 0;
8039
8040                 for (i = 0; i < path_n; ++i)
8041                 {
8042                         int oy = y;
8043                         int ox = x;
8044
8045                         int ny = GRID_Y(path_g[i]);
8046                         int nx = GRID_X(path_g[i]);
8047
8048                         /* Advance */
8049                         y = ny;
8050                         x = nx;
8051
8052                         gy[grids] = y;
8053                         gx[grids] = x;
8054                         grids++;
8055
8056
8057                         /* Only do visuals if requested */
8058                         if (!blind && !(flg & (PROJECT_HIDE)))
8059                         {
8060                                 /* Only do visuals if the player can "see" the bolt */
8061                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8062                                 {
8063                                         u16b p;
8064
8065                                         byte a;
8066                                         char c;
8067
8068                                         /* Obtain the bolt pict */
8069                                         p = bolt_pict(oy, ox, y, x, typ);
8070
8071                                         /* Extract attr/char */
8072                                         a = PICT_A(p);
8073                                         c = PICT_C(p);
8074
8075                                         /* Visual effects */
8076                                         print_rel(c, a, y, x);
8077                                         move_cursor_relative(y, x);
8078                                         /*if (fresh_before)*/ Term_fresh();
8079                                         Term_xtra(TERM_XTRA_DELAY, msec);
8080                                         lite_spot(y, x);
8081                                         /*if (fresh_before)*/ Term_fresh();
8082
8083                                         /* Display "beam" grids */
8084                                         if (flg & (PROJECT_BEAM))
8085                                         {
8086                                                 /* Obtain the explosion pict */
8087                                                 p = bolt_pict(y, x, y, x, typ);
8088
8089                                                 /* Extract attr/char */
8090                                                 a = PICT_A(p);
8091                                                 c = PICT_C(p);
8092
8093                                                 /* Visual effects */
8094                                                 print_rel(c, a, y, x);
8095                                         }
8096
8097                                         /* Hack -- Activate delay */
8098                                         visual = TRUE;
8099                                 }
8100
8101                                 /* Hack -- delay anyway for consistency */
8102                                 else if (visual)
8103                                 {
8104                                         /* Delay for consistency */
8105                                         Term_xtra(TERM_XTRA_DELAY, msec);
8106                                 }
8107                         }
8108                         if(project_o(0,0,y,x,dam,GF_SEEKER))notice=TRUE;
8109                         if( cave[y][x].feat == FEAT_MIRROR )
8110                         {
8111                           /* The target of monsterspell becomes tha mirror(broken) */
8112                                 monster_target_y=(s16b)y;
8113                                 monster_target_x=(s16b)x;
8114
8115                                 cave_set_feat( y, x , FEAT_FLOOR );
8116                                 next_mirror( &oy,&ox );
8117
8118                                 path_n = i+project_path(&(path_g[i+1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
8119                                 for( j = last_i; j <=i ; j++ )
8120                                 {
8121                                         y = GRID_Y(path_g[j]);
8122                                         x = GRID_X(path_g[j]);
8123                                         if(project_m(0,0,y,x,dam,GF_SEEKER,flg))notice=TRUE;
8124                                         if(!who && (project_m_n==1) && !jump ){
8125                                           if(cave[project_m_y][project_m_x].m_idx >0 ){
8126                                             monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
8127
8128                                             /* Hack -- auto-recall */
8129                                             if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8130
8131                                             /* Hack - auto-track */
8132                                             if (m_ptr->ml) health_track(cave[project_m_y][project_m_x].m_idx);
8133                                           }
8134                                         }
8135                                         (void)project_f(0,0,y,x,dam,GF_SEEKER);
8136                                 }
8137                                 last_i = i;
8138                         }
8139                 }
8140                 for( i = last_i ; i < path_n ; i++ )
8141                 {
8142                         int x,y;
8143                         y = GRID_Y(path_g[i]);
8144                         x = GRID_X(path_g[i]);
8145                         if(project_m(0,0,y,x,dam,GF_SEEKER,flg))
8146                           notice=TRUE;
8147                         if(!who && (project_m_n==1) && !jump ){
8148                           if(cave[project_m_y][project_m_x].m_idx >0 ){
8149                             monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
8150                             
8151                             /* Hack -- auto-recall */
8152                             if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8153                             
8154                             /* Hack - auto-track */
8155                             if (m_ptr->ml) health_track(cave[project_m_y][project_m_x].m_idx);
8156                           }
8157                         }
8158                         (void)project_f(0,0,y,x,dam,GF_SEEKER);
8159                 }
8160                 return notice;
8161         }
8162         else if(typ == GF_SUPER_RAY){
8163                 int j;
8164                 int second_step = 0;
8165
8166                 /* Mega-Hack */
8167                 project_m_n = 0;
8168                 project_m_x = 0;
8169                 project_m_y = 0;
8170
8171                 for (i = 0; i < path_n; ++i)
8172                 {
8173                         int oy = y;
8174                         int ox = x;
8175
8176                         int ny = GRID_Y(path_g[i]);
8177                         int nx = GRID_X(path_g[i]);
8178
8179                         /* Advance */
8180                         y = ny;
8181                         x = nx;
8182
8183                         gy[grids] = y;
8184                         gx[grids] = x;
8185                         grids++;
8186
8187
8188                         /* Only do visuals if requested */
8189                         if (!blind && !(flg & (PROJECT_HIDE)))
8190                         {
8191                                 /* Only do visuals if the player can "see" the bolt */
8192                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8193                                 {
8194                                         u16b p;
8195
8196                                         byte a;
8197                                         char c;
8198
8199                                         /* Obtain the bolt pict */
8200                                         p = bolt_pict(oy, ox, y, x, typ);
8201
8202                                         /* Extract attr/char */
8203                                         a = PICT_A(p);
8204                                         c = PICT_C(p);
8205
8206                                         /* Visual effects */
8207                                         print_rel(c, a, y, x);
8208                                         move_cursor_relative(y, x);
8209                                         /*if (fresh_before)*/ Term_fresh();
8210                                         Term_xtra(TERM_XTRA_DELAY, msec);
8211                                         lite_spot(y, x);
8212                                         /*if (fresh_before)*/ Term_fresh();
8213
8214                                         /* Display "beam" grids */
8215                                         if (flg & (PROJECT_BEAM))
8216                                         {
8217                                                 /* Obtain the explosion pict */
8218                                                 p = bolt_pict(y, x, y, x, typ);
8219
8220                                                 /* Extract attr/char */
8221                                                 a = PICT_A(p);
8222                                                 c = PICT_C(p);
8223
8224                                                 /* Visual effects */
8225                                                 print_rel(c, a, y, x);
8226                                         }
8227
8228                                         /* Hack -- Activate delay */
8229                                         visual = TRUE;
8230                                 }
8231
8232                                 /* Hack -- delay anyway for consistency */
8233                                 else if (visual)
8234                                 {
8235                                         /* Delay for consistency */
8236                                         Term_xtra(TERM_XTRA_DELAY, msec);
8237                                 }
8238                         }
8239                         if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
8240                         if( cave[y][x].feat == FEAT_RUBBLE ||
8241                             cave[y][x].feat == FEAT_DOOR_HEAD ||
8242                             cave[y][x].feat == FEAT_DOOR_TAIL ||
8243                             (cave[y][x].feat >= FEAT_WALL_EXTRA &&
8244                              cave[y][x].feat <= FEAT_PERM_SOLID ))
8245                         {
8246                                 if( second_step )continue;
8247                                 break;
8248                         }
8249                         if( cave[y][x].feat == FEAT_MIRROR && !second_step )
8250                         {
8251                           /* The target of monsterspell becomes tha mirror(broken) */
8252                                 monster_target_y=(s16b)y;
8253                                 monster_target_x=(s16b)x;
8254
8255                                 cave_set_feat( y, x , FEAT_FLOOR );
8256                                 for( j = 0; j <=i ; j++ )
8257                                 {
8258                                         y = GRID_Y(path_g[j]);
8259                                         x = GRID_X(path_g[j]);
8260                                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
8261                                 }
8262                                 path_n = i;
8263                                 second_step =i+1;
8264                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
8265                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
8266                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
8267                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x-1, flg);
8268                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x+1, flg);
8269                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x-1, flg);
8270                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
8271                                 path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
8272                         }
8273                 }
8274                 for( i = 0; i < path_n ; i++ )
8275                 {
8276                         int x,y;
8277                         y = GRID_Y(path_g[i]);
8278                         x = GRID_X(path_g[i]);
8279                         (void)project_m(0,0,y,x,dam,GF_SUPER_RAY,flg);
8280                         if(!who && (project_m_n==1) && !jump ){
8281                           if(cave[project_m_y][project_m_x].m_idx >0 ){
8282                             monster_type *m_ptr = &m_list[cave[project_m_y][project_m_x].m_idx];
8283                             
8284                             /* Hack -- auto-recall */
8285                             if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8286                             
8287                             /* Hack - auto-track */
8288                             if (m_ptr->ml) health_track(cave[project_m_y][project_m_x].m_idx);
8289                           }
8290                         }
8291                         (void)project_f(0,0,y,x,dam,GF_SUPER_RAY);
8292                 }
8293                 return notice;
8294         }
8295
8296         /* Project along the path */
8297         for (i = 0; i < path_n; ++i)
8298         {
8299                 int oy = y;
8300                 int ox = x;
8301
8302                 int ny = GRID_Y(path_g[i]);
8303                 int nx = GRID_X(path_g[i]);
8304
8305                 if (flg & PROJECT_DISI)
8306                 {
8307                         /* Hack -- Balls explode before reaching walls */
8308                         if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
8309                 }
8310                 else
8311                 {
8312                         /* Hack -- Balls explode before reaching walls */
8313                         if (!cave_floor_bold(ny, nx) && (rad > 0)) break;
8314                 }
8315
8316                 /* Advance */
8317                 y = ny;
8318                 x = nx;
8319
8320                 /* Collect beam grids */
8321                 if (flg & (PROJECT_BEAM))
8322                 {
8323                         gy[grids] = y;
8324                         gx[grids] = x;
8325                         grids++;
8326                 }
8327
8328                 /* Only do visuals if requested */
8329                 if (!blind && !(flg & (PROJECT_HIDE)))
8330                 {
8331                         /* Only do visuals if the player can "see" the bolt */
8332                         if (panel_contains(y, x) && player_has_los_bold(y, x))
8333                         {
8334                                 u16b p;
8335
8336                                 byte a;
8337                                 char c;
8338
8339                                 /* Obtain the bolt pict */
8340                                 p = bolt_pict(oy, ox, y, x, typ);
8341
8342                                 /* Extract attr/char */
8343                                 a = PICT_A(p);
8344                                 c = PICT_C(p);
8345
8346                                 /* Visual effects */
8347                                 print_rel(c, a, y, x);
8348                                 move_cursor_relative(y, x);
8349                                 /*if (fresh_before)*/ Term_fresh();
8350                                 Term_xtra(TERM_XTRA_DELAY, msec);
8351                                 lite_spot(y, x);
8352                                 /*if (fresh_before)*/ Term_fresh();
8353
8354                                 /* Display "beam" grids */
8355                                 if (flg & (PROJECT_BEAM))
8356                                 {
8357                                         /* Obtain the explosion pict */
8358                                         p = bolt_pict(y, x, y, x, typ);
8359
8360                                         /* Extract attr/char */
8361                                         a = PICT_A(p);
8362                                         c = PICT_C(p);
8363
8364                                         /* Visual effects */
8365                                         print_rel(c, a, y, x);
8366                                 }
8367
8368                                 /* Hack -- Activate delay */
8369                                 visual = TRUE;
8370                         }
8371
8372                         /* Hack -- delay anyway for consistency */
8373                         else if (visual)
8374                         {
8375                                 /* Delay for consistency */
8376                                 Term_xtra(TERM_XTRA_DELAY, msec);
8377                         }
8378                 }
8379                 if ((typ == GF_ATTACK) && (dam == HISSATSU_NYUSIN) && ((i+1) == path_n))
8380                 {
8381                         if (cave_empty_bold(y, x)) teleport_player_to(ny, nx, FALSE);
8382                 }
8383
8384         }
8385
8386         /* Save the "blast epicenter" */
8387         y2 = y;
8388         x2 = x;
8389
8390         if (breath && (y1 == y2) && (x1 == x2))
8391         {
8392                 breath = FALSE;
8393                 gm_rad = 1;
8394                 if (!old_hide)
8395                 {
8396                         flg &= ~(PROJECT_HIDE);
8397                 }
8398         }
8399
8400         /* Start the "explosion" */
8401         gm[0] = 0;
8402
8403         /* Hack -- make sure beams get to "explode" */
8404         gm[1] = grids;
8405
8406         dist = path_n;
8407         dist_hack = dist;
8408
8409         project_length = 0;
8410
8411         /* If we found a "target", explode there */
8412         if (dist <= MAX_RANGE)
8413         {
8414                 /* Mega-Hack -- remove the final "beam" grid */
8415                 if ((flg & (PROJECT_BEAM)) && (grids > 0)) grids--;
8416
8417                 /*
8418                  * Create a conical breath attack
8419                  *
8420                  *         ***
8421                  *     ********
8422                  * D********@**
8423                  *     ********
8424                  *         ***
8425                  */
8426
8427                 if (breath)
8428                 {
8429                         flg &= ~(PROJECT_HIDE);
8430
8431                         breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, y2, x2, (bool)(typ == GF_DISINTEGRATE), TRUE);
8432                 }
8433                 else
8434                 {
8435                         /* Determine the blast area, work from the inside out */
8436                         for (dist = 0; dist <= rad; dist++)
8437                         {
8438                                 /* Scan the maximal blast area of radius "dist" */
8439                                 for (y = y2 - dist; y <= y2 + dist; y++)
8440                                 {
8441                                         for (x = x2 - dist; x <= x2 + dist; x++)
8442                                         {
8443                                                 /* Ignore "illegal" locations */
8444                                                 if (!in_bounds2(y, x)) continue;
8445
8446                                                 /* Enforce a "circular" explosion */
8447                                                 if (distance(y2, x2, y, x) != dist) continue;
8448
8449                                                 if (typ == GF_DISINTEGRATE)
8450                                                 {
8451                                                         /* Disintegration balls explosions are stopped by perma-walls */
8452                                                         if (!in_disintegration_range(y2, x2, y, x)) continue;
8453
8454                                                         if (cave_valid_bold(y, x) &&
8455                                                                 (cave[y][x].feat < FEAT_PATTERN_START ||
8456                                                                  cave[y][x].feat > FEAT_PATTERN_XTRA2) &&
8457                                                                 (cave[y][x].feat < FEAT_DEEP_WATER ||
8458                                                                  cave[y][x].feat > FEAT_GRASS))
8459                                                         {
8460                                                                 if (cave[y][x].feat == FEAT_TREES)
8461                                                                         cave_set_feat(y, x, FEAT_GRASS);
8462                                                                 else
8463                                                                 {
8464                                                                         cave[y][x].feat = floor_type[randint0(100)];
8465                                                                         cave[y][x].info &= ~(CAVE_MASK);
8466                                                                         cave[y][x].info |= CAVE_FLOOR;
8467                                                                 }
8468                                                         }
8469
8470                                                         /* Update some things -- similar to GF_KILL_WALL */
8471                                                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
8472                                                 }
8473                                                 else
8474                                                 {
8475                                                         /* Ball explosions are stopped by walls */
8476                                                         if (!los(y2, x2, y, x)) continue;
8477                                                 }
8478
8479                                                 /* Save this grid */
8480                                                 gy[grids] = y;
8481                                                 gx[grids] = x;
8482                                                 grids++;
8483                                         }
8484                                 }
8485
8486                                 /* Encode some more "radius" info */
8487                                 gm[dist+1] = grids;
8488                         }
8489                 }
8490         }
8491
8492         /* Speed -- ignore "non-explosions" */
8493         if (!grids) return (FALSE);
8494
8495
8496         /* Display the "blast area" if requested */
8497         if (!blind && !(flg & (PROJECT_HIDE)))
8498         {
8499                 /* Then do the "blast", from inside out */
8500                 for (t = 0; t <= gm_rad; t++)
8501                 {
8502                         /* Dump everything with this radius */
8503                         for (i = gm[t]; i < gm[t+1]; i++)
8504                         {
8505                                 /* Extract the location */
8506                                 y = gy[i];
8507                                 x = gx[i];
8508
8509                                 /* Only do visuals if the player can "see" the blast */
8510                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8511                                 {
8512                                         u16b p;
8513
8514                                         byte a;
8515                                         char c;
8516
8517                                         drawn = TRUE;
8518
8519                                         /* Obtain the explosion pict */
8520                                         p = bolt_pict(y, x, y, x, typ);
8521
8522                                         /* Extract attr/char */
8523                                         a = PICT_A(p);
8524                                         c = PICT_C(p);
8525
8526                                         /* Visual effects -- Display */
8527                                         print_rel(c, a, y, x);
8528                                 }
8529                         }
8530
8531                         /* Hack -- center the cursor */
8532                         move_cursor_relative(y2, x2);
8533
8534                         /* Flush each "radius" seperately */
8535                         /*if (fresh_before)*/ Term_fresh();
8536
8537                         /* Delay (efficiently) */
8538                         if (visual || drawn)
8539                         {
8540                                 Term_xtra(TERM_XTRA_DELAY, msec);
8541                         }
8542                 }
8543
8544                 /* Flush the erasing */
8545                 if (drawn)
8546                 {
8547                         /* Erase the explosion drawn above */
8548                         for (i = 0; i < grids; i++)
8549                         {
8550                                 /* Extract the location */
8551                                 y = gy[i];
8552                                 x = gx[i];
8553
8554                                 /* Hack -- Erase if needed */
8555                                 if (panel_contains(y, x) && player_has_los_bold(y, x))
8556                                 {
8557                                         lite_spot(y, x);
8558                                 }
8559                         }
8560
8561                         /* Hack -- center the cursor */
8562                         move_cursor_relative(y2, x2);
8563
8564                         /* Flush the explosion */
8565                         /*if (fresh_before)*/ Term_fresh();
8566                 }
8567         }
8568
8569
8570         /* Update stuff if needed */
8571         if (p_ptr->update) update_stuff();
8572
8573
8574         /* Check features */
8575         if (flg & (PROJECT_GRID))
8576         {
8577                 /* Start with "dist" of zero */
8578                 dist = 0;
8579
8580                 /* Scan for features */
8581                 for (i = 0; i < grids; i++)
8582                 {
8583                         /* Hack -- Notice new "dist" values */
8584                         if (gm[dist+1] == i) dist++;
8585
8586                         /* Get the grid location */
8587                         y = gy[i];
8588                         x = gx[i];
8589
8590                         /* Find the closest point in the blast */
8591                         if (breath)
8592                         {
8593                                 int d = dist_to_line(y, x, y1, x1, y2, x2);
8594
8595                                 /* Affect the grid */
8596                                 if (project_f(who, d, y, x, dam, typ)) notice = TRUE;
8597                         }
8598                         else
8599                         {
8600                                 /* Affect the grid */
8601                                 if (project_f(who, dist, y, x, dam, typ)) notice = TRUE;
8602                         }
8603                 }
8604         }
8605
8606
8607         /* Check objects */
8608         if (flg & (PROJECT_ITEM))
8609         {
8610                 /* Start with "dist" of zero */
8611                 dist = 0;
8612
8613                 /* Scan for objects */
8614                 for (i = 0; i < grids; i++)
8615                 {
8616                         /* Hack -- Notice new "dist" values */
8617                         if (gm[dist+1] == i) dist++;
8618
8619                         /* Get the grid location */
8620                         y = gy[i];
8621                         x = gx[i];
8622
8623                         /* Find the closest point in the blast */
8624                         if (breath)
8625                         {
8626                                 int d = dist_to_line(y, x, y1, x1, y2, x2);
8627
8628                                 /* Affect the object in the grid */
8629                                 if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
8630                         }
8631                         else
8632                         {
8633                                 /* Affect the object in the grid */
8634                                 if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
8635                         }
8636                 }
8637         }
8638
8639
8640         /* Check monsters */
8641         if (flg & (PROJECT_KILL))
8642         {
8643                 /* Mega-Hack */
8644                 project_m_n = 0;
8645                 project_m_x = 0;
8646                 project_m_y = 0;
8647
8648                 /* Start with "dist" of zero */
8649                 dist = 0;
8650
8651                 /* Scan for monsters */
8652                 for (i = 0; i < grids; i++)
8653                 {
8654                         /* Hack -- Notice new "dist" values */
8655                         if (gm[dist + 1] == i) dist++;
8656
8657                         /* Get the grid location */
8658                         y = gy[i];
8659                         x = gx[i];
8660
8661                         if (grids > 1)
8662                         {
8663                                 /* Find the closest point in the blast */
8664                                 if (breath)
8665                                 {
8666                                         int d = dist_to_line(y, x, y1, x1, y2, x2);
8667
8668                                         /* Affect the monster in the grid */
8669                                         if ((y == y2) && (x == x2) && (y == py) && (x == px) && (flg & PROJECT_PLAYER))
8670                                         {
8671                                                 if (project_m(who, d+1, y, x, dam, typ,flg)) notice = TRUE;
8672                                         }
8673                                         else if (project_m(who, d, y, x, dam, typ,flg)) notice = TRUE;
8674                                 }
8675                                 else
8676                                 {
8677                                         /* Affect the monster in the grid */
8678                                         if ((y == y2) && (x == x2) && (y == py) && (x == px) && (flg & PROJECT_PLAYER))
8679                                         {
8680                                                 if (!(flg & PROJECT_BEAM))
8681                                                 {
8682                                                         if (project_m(who, dist+1, y, x, dam, typ,flg)) notice = TRUE;
8683                                                 }
8684                                         }
8685                                         else if (project_m(who, dist, y, x, dam, typ,flg)) notice = TRUE;
8686                                 }
8687                         }
8688                         else
8689                         {
8690                                 monster_race *ref_ptr = &r_info[m_list[cave[y][x].m_idx].r_idx];
8691
8692                                 if ((ref_ptr->flags2 & RF2_REFLECTING) && (!one_in_(10) && !(flg & PROJECT_NO_REF) && (!who || dist_hack > 1)))
8693                                 {
8694                                         byte t_y, t_x;
8695                                         int max_attempts = 10;
8696
8697                                         /* Choose 'new' target */
8698                                         do
8699                                         {
8700                                                 t_y = y_saver - 1 + randint1(3);
8701                                                 t_x = x_saver - 1 + randint1(3);
8702                                                 max_attempts--;
8703                                         }
8704
8705                                         while (max_attempts && in_bounds2u(t_y, t_x) &&
8706                                             !(los(y, x, t_y, t_x)));
8707
8708                                         if (max_attempts < 1)
8709                                         {
8710                                                 t_y = y_saver;
8711                                                 t_x = x_saver;
8712                                         }
8713
8714                                         if (m_list[cave[y][x].m_idx].ml)
8715                                         {
8716 #ifdef JP
8717 if ((m_list[cave[y][x].m_idx].r_idx == MON_KENSHIROU)
8718         || (m_list[cave[y][x].m_idx].r_idx == MON_RAOU))
8719         msg_print("¡ÖËÌÅÍ¿À·ý±üµÁ¡¦Æó»Ø¿¿¶õÇÄ¡ª¡×");
8720 if (m_list[cave[y][x].m_idx].r_idx == MON_DIO) msg_print("¥Ç¥£¥ª¡¦¥Ö¥é¥ó¥É¡¼¤Ï»Ø°ìËܤǹ¶·â¤òÃƤ­ÊÖ¤·¤¿¡ª");
8721 else msg_print("¹¶·â¤ÏÄ·¤ÍÊ֤ä¿¡ª");
8722 #else
8723                                                 msg_print("The attack bounces!");
8724 #endif
8725
8726                                                 ref_ptr->r_flags2 |= RF2_REFLECTING;
8727                                         }
8728                                         flg &= ~(PROJECT_MONSTER | PROJECT_PLAYER);
8729                                         if (one_in_(2)) flg |= PROJECT_MONSTER;
8730                                         else flg |= PROJECT_PLAYER;
8731
8732                                         project(cave[y][x].m_idx, 0, t_y, t_x,  dam, typ, flg, monspell);
8733                                 }
8734                                 else
8735                                 {
8736                                         if ((y == y2) && (x == x2) && (y == py) && (x == px) && (flg & PROJECT_PLAYER))
8737                                         {
8738                                         }
8739                                         else if (project_m(who, dist, y, x, dam, typ,flg)) notice = TRUE;
8740                                 }
8741                         }
8742                 }
8743
8744                 /* Player affected one monster (without "jumping") */
8745                 if (!who && (project_m_n == 1) && !jump)
8746                 {
8747                         /* Location */
8748                         x = project_m_x;
8749                         y = project_m_y;
8750
8751                         /* Track if possible */
8752                         if (cave[y][x].m_idx > 0)
8753                         {
8754                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
8755
8756                                 /* Hack -- auto-recall */
8757                                 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
8758
8759                                 /* Hack - auto-track */
8760                                 if (m_ptr->ml) health_track(cave[y][x].m_idx);
8761                         }
8762                 }
8763         }
8764
8765
8766         /* Check player */
8767         if (flg & (PROJECT_KILL))
8768         {
8769                 /* Start with "dist" of zero */
8770                 dist = 0;
8771
8772                 /* Scan for player */
8773                 for (i = 0; i < grids; i++)
8774                 {
8775                         /* Hack -- Notice new "dist" values */
8776                         if (gm[dist+1] == i) dist++;
8777
8778                         /* Get the grid location */
8779                         y = gy[i];
8780                         x = gx[i];
8781
8782                         /* Find the closest point in the blast */
8783                         if (breath)
8784                         {
8785                                 int d = dist_to_line(y, x, y1, x1, y2, x2);
8786
8787                                 /* Affect the player */
8788                                 if ((y == y2) && (x == x2) && (y == py) && (x == px) && (flg & PROJECT_MONSTER))
8789                                 {
8790                                         if (project_p(who, who_name, d+1, y, x, dam, typ, rad, monspell)) notice = TRUE;
8791                                 }
8792                                 else if (project_p(who, who_name, d, y, x, dam, typ, rad, monspell)) notice = TRUE;
8793                         }
8794                         else
8795                         {
8796                                 /* Affect the player */
8797                                 if ((y == y2) && (x == x2) && (y == py) && (x == px) && (flg & PROJECT_MONSTER))
8798                                 {
8799                                         if (!((flg & PROJECT_BEAM) || (flg & PROJECT_STOP)))
8800                                         {
8801                                                 if (project_p(who, who_name, dist+1, y, x, dam, typ, rad, monspell)) notice = TRUE;
8802                                         }
8803                                 }
8804                                 else if (project_p(who, who_name, dist, y, x, dam, typ, rad, monspell)) notice = TRUE;
8805                         }
8806                 }
8807         }
8808
8809         if (p_ptr->riding)
8810         {
8811                 char m_name[80];
8812
8813                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
8814
8815                 if (rakubadam_m > 0)
8816                 {
8817                         if (rakuba(rakubadam_m, FALSE))
8818                         {
8819 #ifdef JP
8820 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
8821 #else
8822                                 msg_format("%^s has thrown you off!", m_name);
8823 #endif
8824                         }
8825                 }
8826                 if (p_ptr->riding && rakubadam_p > 0)
8827                 {
8828                         if(rakuba(rakubadam_p, FALSE))
8829                         {
8830 #ifdef JP
8831 msg_format("%^s¤«¤éÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª", m_name);
8832 #else
8833                                 msg_format("You have fallen from %s.", m_name);
8834 #endif
8835                         }
8836                 }
8837         }
8838
8839         /* Return "something was noticed" */
8840         return (notice);
8841 }
8842
8843 bool binding_field( int dam )
8844 {
8845         int mirror_x[10],mirror_y[10]; /* ¶À¤Ï¤â¤Ã¤È¾¯¤Ê¤¤ */
8846         int mirror_num=0;              /* ¶À¤Î¿ô */
8847         int x,y;
8848         int centersign;
8849         int x1,x2,y1,y2;
8850         u16b p;
8851         int msec= delay_factor*delay_factor*delay_factor;
8852
8853         /* »°³Ñ·Á¤ÎĺÅÀ */
8854         int point_x[3];
8855         int point_y[3];
8856
8857         /* Default target of monsterspell is player */
8858         monster_target_y=py;
8859         monster_target_x=px;
8860
8861         for( x=0 ; x < cur_wid ; x++ )
8862         {
8863                 for( y=0 ; y < cur_hgt ; y++ )
8864                 {
8865                         if( cave[y][x].feat == FEAT_MIRROR &&
8866                             distance(py,px,y,x) <= MAX_RANGE &&
8867                             distance(py,px,y,x) != 0 &&
8868                             player_has_los_bold(y,x)
8869                             ){
8870                                 mirror_y[mirror_num]=y;
8871                                 mirror_x[mirror_num]=x;
8872                                 mirror_num++;
8873                         }
8874                 }
8875         }
8876
8877         if( mirror_num < 2 )return FALSE;
8878
8879         point_x[0] = randint0( mirror_num );
8880         do {
8881           point_x[1] = randint0( mirror_num );
8882         }
8883         while( point_x[0] == point_x[1] );
8884
8885         point_y[0]=mirror_y[point_x[0]];
8886         point_x[0]=mirror_x[point_x[0]];
8887         point_y[1]=mirror_y[point_x[1]];
8888         point_x[1]=mirror_x[point_x[1]];
8889         point_y[2]=py;
8890         point_x[2]=px;
8891
8892         x=point_x[0]+point_x[1]+point_x[2];
8893         y=point_y[0]+point_y[1]+point_y[2];
8894
8895         centersign = (point_x[0]*3-x)*(point_y[1]*3-y)
8896                 - (point_y[0]*3-y)*(point_x[1]*3-x);
8897         if( centersign == 0 )return FALSE;
8898                             
8899         x1 = point_x[0] < point_x[1] ? point_x[0] : point_x[1];
8900         x1 = x1 < point_x[2] ? x1 : point_x[2];
8901         y1 = point_y[0] < point_y[1] ? point_y[0] : point_y[1];
8902         y1 = y1 < point_y[2] ? y1 : point_y[2];
8903
8904         x2 = point_x[0] > point_x[1] ? point_x[0] : point_x[1];
8905         x2 = x2 > point_x[2] ? x2 : point_x[2];
8906         y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
8907         y2 = y2 > point_y[2] ? y2 : point_y[2];
8908
8909         for( y=y1 ; y <=y2 ; y++ ){
8910                 for( x=x1 ; x <=x2 ; x++ ){
8911                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
8912                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
8913                             centersign*( (point_x[1]-x)*(point_y[2]-y)
8914                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
8915                             centersign*( (point_x[2]-x)*(point_y[0]-y)
8916                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
8917                         {
8918                                 if( player_has_los_bold(y,x)){
8919                                         /* Visual effects */
8920                                         if(!(p_ptr->blind)
8921                                            && panel_contains(y,x)){
8922                                           p = bolt_pict(y,x,y,x, GF_MANA );
8923                                           print_rel(PICT_C(p), PICT_A(p),y,x);
8924                                           move_cursor_relative(y, x);
8925                                           /*if (fresh_before)*/ Term_fresh();
8926                                           Term_xtra(TERM_XTRA_DELAY, msec);
8927                                         }
8928                                 }
8929                         }
8930                 }
8931         }
8932         for( y=y1 ; y <=y2 ; y++ ){
8933                 for( x=x1 ; x <=x2 ; x++ ){
8934                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
8935                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
8936                             centersign*( (point_x[1]-x)*(point_y[2]-y)
8937                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
8938                             centersign*( (point_x[2]-x)*(point_y[0]-y)
8939                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
8940                         {
8941                                 if( player_has_los_bold(y,x)){
8942                                         (void)project_f(0,0,y,x,dam,GF_MANA); 
8943                                 }
8944                         }
8945                 }
8946         }
8947         for( y=y1 ; y <=y2 ; y++ ){
8948                 for( x=x1 ; x <=x2 ; x++ ){
8949                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
8950                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
8951                             centersign*( (point_x[1]-x)*(point_y[2]-y)
8952                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
8953                             centersign*( (point_x[2]-x)*(point_y[0]-y)
8954                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
8955                         {
8956                                 if( player_has_los_bold(y,x)){
8957                                         (void)project_o(0,0,y,x,dam,GF_MANA); 
8958                                 }
8959                         }
8960                 }
8961         }
8962         for( y=y1 ; y <=y2 ; y++ ){
8963                 for( x=x1 ; x <=x2 ; x++ ){
8964                         if( centersign*( (point_x[0]-x)*(point_y[1]-y)
8965                                          -(point_y[0]-y)*(point_x[1]-x)) >=0 &&
8966                             centersign*( (point_x[1]-x)*(point_y[2]-y)
8967                                          -(point_y[1]-y)*(point_x[2]-x)) >=0 &&
8968                             centersign*( (point_x[2]-x)*(point_y[0]-y)
8969                                          -(point_y[2]-y)*(point_x[0]-x)) >=0 )
8970                         {
8971                                 if( player_has_los_bold(y,x) ){
8972                                         (void)project_m(0,0,y,x,dam,GF_MANA,
8973                                           (PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP|PROJECT_NO_REF));
8974                                 }
8975                         }
8976                 }
8977         }
8978         if( one_in_(7) ){
8979 #ifdef JP
8980                 msg_print("¶À¤¬·ë³¦¤ËÂѤ¨¤­¤ì¤º¡¢²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡£");
8981 #else
8982                 msg_print("The field broke a mirror");
8983 #endif  
8984                 cave_set_feat( point_y[0] , point_x[0] , FEAT_FLOOR );
8985         }
8986
8987         return TRUE;
8988 }
8989
8990 void seal_of_mirror( int dam )
8991 {
8992         int x,y;
8993
8994         for( x = 0 ; x < cur_wid ; x++ )
8995         {
8996                 for( y = 0 ; y < cur_hgt ; y++ )
8997                 {
8998                         if( cave[y][x].feat == FEAT_MIRROR )
8999                         {
9000                                 if(project_m(0,0,y,x,dam,GF_GENOCIDE,
9001                                                          (PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP|PROJECT_NO_REF)))
9002                                 {
9003                                         if( !cave[y][x].m_idx )
9004                                         {
9005                                                 cave_set_feat( y,x, FEAT_FLOOR );
9006                                         }
9007                                 }
9008                         }
9009                 }
9010         }
9011         return;
9012 }
9013