OSDN Git Service

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