OSDN Git Service

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