OSDN Git Service

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