OSDN Git Service

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