OSDN Git Service

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