OSDN Git Service

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