OSDN Git Service

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