OSDN Git Service

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