OSDN Git Service

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