OSDN Git Service

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