OSDN Git Service

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