OSDN Git Service

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