OSDN Git Service

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