OSDN Git Service

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