OSDN Git Service

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