OSDN Git Service

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