OSDN Git Service

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