OSDN Git Service

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