OSDN Git Service

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