OSDN Git Service

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