OSDN Git Service

[Refactor] #37353 Adjusted inclusion relationship in birth/, cmd-building/ and cmd-io/
[hengband/hengband.git] / src / spell / spells3.c
1 /*!
2  * @brief 魔法効果の実装/ Spell code (part 3)
3  * @date 2014/07/26
4  * @author
5  * <pre>
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  * </pre>
11  */
12
13 #include "spell/spells3.h"
14 #include "autopick/autopick.h"
15 #include "cmd-action/cmd-attack.h"
16 #include "cmd-action/cmd-spell.h"
17 #include "cmd-building/cmd-building.h"
18 #include "cmd-io/cmd-dump.h"
19 #include "core/asking-player.h"
20 #include "core/speed-table.h"
21 #include "core/stuff-handler.h"
22 #include "dungeon/dungeon.h"
23 #include "dungeon/quest.h"
24 #include "effect/effect-characteristics.h"
25 #include "effect/spells-effect-util.h"
26 #include "floor/floor-object.h"
27 #include "floor/floor-save.h"
28 #include "floor/floor-town.h"
29 #include "floor/wild.h"
30 #include "game-option/auto-destruction-options.h"
31 #include "game-option/birth-options.h"
32 #include "game-option/disturbance-options.h"
33 #include "game-option/input-options.h"
34 #include "game-option/play-record-options.h"
35 #include "grid/grid.h"
36 #include "inventory/inventory-object.h"
37 #include "inventory/player-inventory.h"
38 #include "io/files-util.h"
39 #include "io/input-key-acceptor.h"
40 #include "io/input-key-requester.h"
41 #include "io/targeting.h"
42 #include "io/write-diary.h"
43 #include "lore/lore-calculator.h"
44 #include "market/building-util.h"
45 #include "mind/mind-force-trainer.h"
46 #include "mind/mind-sniper.h"
47 #include "mind/mind.h"
48 #include "monster-floor/monster-generator.h"
49 #include "monster-floor/monster-remover.h"
50 #include "monster-floor/monster-summon.h"
51 #include "monster-floor/place-monster-types.h"
52 #include "monster-race/monster-race.h"
53 #include "monster-race/race-flags1.h"
54 #include "monster-race/race-flags7.h"
55 #include "monster/monster-describer.h"
56 #include "monster/monster-flag-types.h"
57 #include "monster/monster-info.h"
58 #include "monster/monster-list.h"
59 #include "monster/monster-processor.h"
60 #include "monster/monster-status.h"
61 #include "monster/monster-update.h"
62 #include "monster/monster-util.h"
63 #include "object-enchant/artifact.h"
64 #include "object-enchant/item-feeling.h"
65 #include "object-enchant/object-boost.h"
66 #include "object-enchant/object-ego.h"
67 #include "object-enchant/special-object-flags.h"
68 #include "object-enchant/tr-types.h"
69 #include "object-enchant/trc-types.h"
70 #include "object/item-use-flags.h"
71 #include "object/object-flavor.h"
72 #include "object/object-generator.h"
73 #include "object/object-hook.h"
74 #include "object/object-info.h"
75 #include "object/object-kind.h"
76 #include "object/object-mark-types.h"
77 #include "object/object-value.h"
78 #include "perception/identification.h"
79 #include "perception/object-perception.h"
80 #include "player/avatar.h"
81 #include "player/player-class.h"
82 #include "player/player-damage.h"
83 #include "player/player-effects.h"
84 #include "player/player-move.h"
85 #include "player/player-personalities-types.h"
86 #include "player/player-skill.h"
87 #include "player/player-status.h"
88 #include "realm/realm-names-table.h"
89 #include "spell-kind/earthquake.h"
90 #include "spell-kind/spells-floor.h"
91 #include "spell-kind/spells-launcher.h"
92 #include "spell-kind/spells-sight.h"
93 #include "spell-kind/spells-teleport.h"
94 #include "spell/process-effect.h"
95 #include "spell/spells-execution.h"
96 #include "spell/spells-summon.h"
97 #include "spell/spell-types.h"
98 #include "spell/technic-info-table.h"
99 #include "term/screen-processor.h"
100 #include "term/term-color-types.h"
101 #include "util/bit-flags-calculator.h"
102 #include "util/int-char-converter.h"
103 #include "view/display-main-window.h"
104 #include "view/display-messages.h"
105 #include "world/world.h"
106
107 // todo コピペ感が強くなったので関数化
108 static bool update_player(player_type *caster_ptr);
109 static bool redraw_player(player_type *caster_ptr);
110
111 /*!
112  * @brief プレイヤーの帰還発動及び中止処理 /
113  * Recall the player to town or dungeon
114  * @param creature_ptr プレーヤーへの参照ポインタ
115  * @param turns 発動までのターン数
116  * @return 常にTRUEを返す
117  */
118 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
119 {
120         /*
121          * TODO: Recall the player to the last
122          * visited town when in the wilderness
123          */
124         if (creature_ptr->current_floor_ptr->inside_arena || ironman_downward)
125         {
126                 msg_print(_("何も起こらなかった。", "Nothing happens."));
127                 return TRUE;
128         }
129
130         bool is_special_floor = creature_ptr->current_floor_ptr->dun_level > 0;
131         is_special_floor &= max_dlv[creature_ptr->dungeon_idx] > creature_ptr->current_floor_ptr->dun_level;
132         is_special_floor &= !creature_ptr->current_floor_ptr->inside_quest;
133         is_special_floor &= !creature_ptr->word_recall;
134         if (is_special_floor)
135         {
136                 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
137                 {
138                         max_dlv[creature_ptr->dungeon_idx] = creature_ptr->current_floor_ptr->dun_level;
139                         if (record_maxdepth)
140                                 exe_write_diary(creature_ptr, DIARY_TRUMP, creature_ptr->dungeon_idx, _("帰還のときに", "when recalled from dungeon"));
141                 }
142
143         }
144
145         if (creature_ptr->word_recall)
146         {
147                 creature_ptr->word_recall = 0;
148                 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
149                 creature_ptr->redraw |= (PR_STATUS);
150                 return TRUE;
151         }
152         
153         if (!creature_ptr->current_floor_ptr->dun_level)
154         {
155                 DUNGEON_IDX select_dungeon;
156                 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
157                 if (!select_dungeon) return FALSE;
158                 creature_ptr->recall_dungeon = select_dungeon;
159         }
160
161         creature_ptr->word_recall = turns;
162         msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
163         creature_ptr->redraw |= (PR_STATUS);
164         return TRUE;
165 }
166
167
168 bool free_level_recall(player_type *creature_ptr)
169 {
170         DUNGEON_IDX select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
171         if (!select_dungeon) return FALSE;
172
173         DEPTH max_depth = d_info[select_dungeon].maxdepth;
174         if (select_dungeon == DUNGEON_ANGBAND)
175         {
176                 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
177                 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
178         }
179
180         QUANTITY amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
181                 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
182         if (amt <= 0)
183         {
184                 return FALSE;
185         }
186
187         creature_ptr->word_recall = 1;
188         creature_ptr->recall_dungeon = select_dungeon;
189         max_dlv[creature_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
190         if (record_maxdepth)
191                 exe_write_diary(creature_ptr, DIARY_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
192
193         msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
194
195         creature_ptr->redraw |= PR_STATUS;
196         return TRUE;
197 }
198
199
200 /*!
201  * @brief フロア・リセット処理
202  * @param caster_ptr プレーヤーへの参照ポインタ
203  * @return リセット処理が実際に行われたらTRUEを返す
204  */
205 bool reset_recall(player_type *caster_ptr)
206 {
207         int select_dungeon, dummy = 0;
208         char ppp[80];
209         char tmp_val[160];
210
211         select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
212         if (ironman_downward)
213         {
214                 msg_print(_("何も起こらなかった。", "Nothing happens."));
215                 return TRUE;
216         }
217
218         if (!select_dungeon) return FALSE;
219         sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
220                 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
221         sprintf(tmp_val, "%d", (int)MAX(caster_ptr->current_floor_ptr->dun_level, 1));
222
223         if (!get_string(ppp, tmp_val, 10))
224         {
225                 return FALSE;
226         }
227
228         dummy = atoi(tmp_val);
229         if (dummy < 1) dummy = 1;
230         if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
231         if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
232
233         max_dlv[select_dungeon] = dummy;
234
235         if (record_maxdepth)
236                 exe_write_diary(caster_ptr, DIARY_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
237 #ifdef JP
238         msg_format("%sの帰還レベルを %d 階にセット。", d_name + d_info[select_dungeon].name, dummy, dummy * 50);
239 #else
240         msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
241 #endif
242         return TRUE;
243 }
244
245
246 /*!
247  * @brief プレイヤーの装備劣化処理 /
248  * Apply disenchantment to the player's stuff
249  * @param target_ptr プレーヤーへの参照ポインタ
250  * @param mode 最下位ビットが1ならば劣化処理が若干低減される
251  * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
252  * Return "TRUE" if the player notices anything
253  */
254 bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode)
255 {
256         int t = 0;
257         switch (randint1(8))
258         {
259                 case 1: t = INVEN_RARM; break;
260                 case 2: t = INVEN_LARM; break;
261                 case 3: t = INVEN_BOW; break;
262                 case 4: t = INVEN_BODY; break;
263                 case 5: t = INVEN_OUTER; break;
264                 case 6: t = INVEN_HEAD; break;
265                 case 7: t = INVEN_HANDS; break;
266                 case 8: t = INVEN_FEET; break;
267         }
268
269         object_type *o_ptr;
270         o_ptr = &target_ptr->inventory_list[t];
271         if (!o_ptr->k_idx) return FALSE;
272
273         if (!object_is_weapon_armour_ammo(o_ptr))
274                 return FALSE;
275
276         if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
277         {
278                 return FALSE;
279         }
280
281         GAME_TEXT o_name[MAX_NLEN];
282         object_desc(target_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
283         if (object_is_artifact(o_ptr) && (randint0(100) < 71))
284         {
285 #ifdef JP
286                 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
287 #else
288                 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
289                         ((o_ptr->number != 1) ? "" : "s"));
290 #endif
291                 return TRUE;
292         }
293         
294         int to_h = o_ptr->to_h;
295         int to_d = o_ptr->to_d;
296         int to_a = o_ptr->to_a;
297         int pval = o_ptr->pval;
298
299         if (o_ptr->to_h > 0) o_ptr->to_h--;
300         if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
301
302         if (o_ptr->to_d > 0) o_ptr->to_d--;
303         if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
304
305         if (o_ptr->to_a > 0) o_ptr->to_a--;
306         if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
307
308         if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
309
310         bool is_actually_disenchanted = to_h != o_ptr->to_h;
311         is_actually_disenchanted |= to_d != o_ptr->to_d;
312         is_actually_disenchanted |= to_a != o_ptr->to_a;
313         is_actually_disenchanted |= pval != o_ptr->pval;
314         if (!is_actually_disenchanted) return TRUE;
315
316 #ifdef JP
317         msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t));
318 #else
319         msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
320                 ((o_ptr->number != 1) ? "were" : "was"));
321 #endif
322         chg_virtue(target_ptr, V_HARMONY, 1);
323         chg_virtue(target_ptr, V_ENCHANT, -2);
324         target_ptr->update |= (PU_BONUS);
325         target_ptr->window |= (PW_EQUIP | PW_PLAYER);
326
327         calc_android_exp(target_ptr);
328         return TRUE;
329 }
330
331
332 /*!
333  * @brief 虚無招来によるフロア中の全壁除去処理 /
334  * Vanish all walls in this floor
335  * @param caster_ptr プレーヤーへの参照ポインタ
336  * @params caster_ptr 術者の参照ポインタ
337  * @return 実際に処理が反映された場合TRUE
338  */
339 bool vanish_dungeon(player_type *caster_ptr)
340 {
341         bool is_special_floor = caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest);
342         is_special_floor |= !caster_ptr->current_floor_ptr->dun_level;
343         if (is_special_floor) return FALSE;
344
345         grid_type *g_ptr;
346         feature_type *f_ptr;
347         monster_type *m_ptr;
348         GAME_TEXT m_name[MAX_NLEN];
349         for (POSITION y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
350         {
351                 for (POSITION x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
352                 {
353                         g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
354
355                         f_ptr = &f_info[g_ptr->feat];
356                         g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
357                         m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
358                         if (g_ptr->m_idx && monster_csleep_remaining(m_ptr))
359                         {
360                                 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
361                                 if (m_ptr->ml)
362                                 {
363                                         monster_desc(caster_ptr, m_name, m_ptr, 0);
364                                         msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
365                                 }
366                         }
367
368                         if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(caster_ptr, y, x, FF_HURT_DISI);
369                 }
370         }
371
372         for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++)
373         {
374                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[0][x];
375                 f_ptr = &f_info[g_ptr->mimic];
376                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
377
378                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
379                 {
380                         g_ptr->mimic = feat_state(caster_ptr, g_ptr->mimic, FF_HURT_DISI);
381                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
382                 }
383
384                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[caster_ptr->current_floor_ptr->height - 1][x];
385                 f_ptr = &f_info[g_ptr->mimic];
386                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
387
388                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
389                 {
390                         g_ptr->mimic = feat_state(caster_ptr, g_ptr->mimic, FF_HURT_DISI);
391                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
392                 }
393         }
394
395         /* Special boundary walls -- Left and right */
396         for (POSITION y = 1; y < (caster_ptr->current_floor_ptr->height - 1); y++)
397         {
398                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][0];
399                 f_ptr = &f_info[g_ptr->mimic];
400                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
401
402                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
403                 {
404                         g_ptr->mimic = feat_state(caster_ptr, g_ptr->mimic, FF_HURT_DISI);
405                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
406                 }
407
408                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][caster_ptr->current_floor_ptr->width - 1];
409                 f_ptr = &f_info[g_ptr->mimic];
410                 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
411
412                 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
413                 {
414                         g_ptr->mimic = feat_state(caster_ptr, g_ptr->mimic, FF_HURT_DISI);
415                         if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
416                 }
417         }
418
419         caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
420         caster_ptr->redraw |= (PR_MAP);
421         caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
422         return TRUE;
423 }
424
425
426 /*!
427  * @brief 虚無招来処理 /
428  * @param caster_ptr プレーヤーへの参照ポインタ
429  * @return なし
430  * @details
431  * Sorry, it becomes not (void)...
432  */
433 void call_the_void(player_type *caster_ptr)
434 {
435         grid_type *g_ptr;
436         bool do_call = TRUE;
437         for (int i = 0; i < 9; i++)
438         {
439                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[caster_ptr->y + ddy_ddd[i]][caster_ptr->x + ddx_ddd[i]];
440
441                 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
442                 {
443                         if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
444                             !permanent_wall(&f_info[g_ptr->feat]))
445                         {
446                                 do_call = FALSE;
447                                 break;
448                         }
449                 }
450         }
451
452         if (do_call)
453         {
454                 for (int i = 1; i < 10; i++)
455                 {
456                         if (i - 5) fire_ball(caster_ptr, GF_ROCKET, i, 175, 2);
457                 }
458
459                 for (int i = 1; i < 10; i++)
460                 {
461                         if (i - 5) fire_ball(caster_ptr, GF_MANA, i, 175, 3);
462                 }
463
464                 for (int i = 1; i < 10; i++)
465                 {
466                         if (i - 5) fire_ball(caster_ptr, GF_NUKE, i, 175, 4);
467                 }
468
469                 return;
470         }
471
472         bool is_special_fllor = caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest);
473         is_special_fllor |= !caster_ptr->current_floor_ptr->dun_level;
474         if (is_special_fllor)
475         {
476                 msg_print(_("地面が揺れた。", "The ground trembles."));
477                 return;
478         }
479
480 #ifdef JP
481         msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
482                 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
483 #else
484         msg_format("You %s the %s too close to a wall!",
485                 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
486                 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
487 #endif
488         msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
489
490         if (one_in_(666))
491         {
492                 if (!vanish_dungeon(caster_ptr)) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon becomes quiet for a moment."));
493                 take_hit(caster_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
494                 return;
495         }
496
497         if (destroy_area(caster_ptr, caster_ptr->y, caster_ptr->x, 15 + caster_ptr->lev + randint0(11), FALSE))
498                         msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
499         else
500                 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
501         take_hit(caster_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
502 }
503
504
505 /*!
506  * @brief アイテム引き寄せ処理 /
507  * Fetch an item (teleport it right underneath the caster)
508  * @param caster_ptr プレーヤーへの参照ポインタ
509  * @param dir 魔法の発動方向
510  * @param wgt 許容重量
511  * @param require_los 射線の通りを要求するならばTRUE
512  * @return なし
513  */
514 void fetch(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
515 {
516         grid_type *g_ptr;
517         object_type *o_ptr;
518         GAME_TEXT o_name[MAX_NLEN];
519
520         if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].o_idx)
521         {
522                 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
523                 return;
524         }
525
526         POSITION ty, tx;
527         if (dir == 5 && target_okay(caster_ptr))
528         {
529                 tx = target_col;
530                 ty = target_row;
531
532                 if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE)
533                 {
534                         msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
535                         return;
536                 }
537
538                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
539                 if (!g_ptr->o_idx)
540                 {
541                         msg_print(_("そこには何もありません。", "There is no object at this place."));
542                         return;
543                 }
544
545                 if (g_ptr->info & CAVE_ICKY)
546                 {
547                         msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
548                         return;
549                 }
550
551                 if (require_los)
552                 {
553                         if (!player_has_los_bold(caster_ptr, ty, tx))
554                         {
555                                 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
556                                 return;
557                         }
558                         else if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, ty, tx))
559                         {
560                                 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
561                                 return;
562                         }
563                 }
564         }
565         else
566         {
567                 ty = caster_ptr->y; 
568                 tx = caster_ptr->x;
569                 bool is_first_loop = TRUE;
570                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
571                 while (is_first_loop || !g_ptr->o_idx)
572                 {
573                         is_first_loop = FALSE;
574                         ty += ddy[dir];
575                         tx += ddx[dir];
576                         g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
577
578                         if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE) ||
579                                 !cave_have_flag_bold(caster_ptr->current_floor_ptr, ty, tx, FF_PROJECT)) return;
580                 }
581         }
582
583         o_ptr = &caster_ptr->current_floor_ptr->o_list[g_ptr->o_idx];
584         if (o_ptr->weight > wgt)
585         {
586                 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
587                 return;
588         }
589
590         OBJECT_IDX i = g_ptr->o_idx;
591         g_ptr->o_idx = o_ptr->next_o_idx;
592         caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].o_idx = i; /* 'move' it */
593
594         o_ptr->next_o_idx = 0;
595         o_ptr->iy = caster_ptr->y;
596         o_ptr->ix = caster_ptr->x;
597
598         object_desc(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
599         msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
600
601         note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
602         caster_ptr->redraw |= PR_MAP;
603 }
604
605
606 /*!
607  * @brief 現実変容処理
608  * @param caster_ptr プレーヤーへの参照ポインタ
609  * @return なし
610  */
611 void reserve_alter_reality(player_type *caster_ptr)
612 {
613         if (caster_ptr->current_floor_ptr->inside_arena || ironman_downward)
614         {
615                 msg_print(_("何も起こらなかった。", "Nothing happens."));
616                 return;
617         }
618
619         if (caster_ptr->alter_reality)
620         {
621                 caster_ptr->alter_reality = 0;
622                 msg_print(_("景色が元に戻った...", "The view around you returns to normal..."));
623                 caster_ptr->redraw |= PR_STATUS;
624                 return;
625         }
626
627         TIME_EFFECT turns = randint0(21) + 15;
628         caster_ptr->alter_reality = turns;
629         msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
630         caster_ptr->redraw |= PR_STATUS;
631 }
632
633
634 /*!
635  * @brief 全所持アイテム鑑定処理 /
636  * Identify everything being carried.
637  * Done by a potion of "self knowledge".
638  * @param target_ptr プレーヤーへの参照ポインタ
639  * @return なし
640  */
641 void identify_pack(player_type *target_ptr)
642 {
643         for (INVENTORY_IDX i = 0; i < INVEN_TOTAL; i++)
644         {
645                 object_type *o_ptr = &target_ptr->inventory_list[i];
646                 if (!o_ptr->k_idx) continue;
647
648                 identify_item(target_ptr, o_ptr);
649                 autopick_alter_item(target_ptr, i, FALSE);
650         }
651 }
652
653
654 /*!
655  * @brief 装備の解呪処理 /
656  * Removes curses from items in inventory
657  * @param creature_ptr プレーヤーへの参照ポインタ
658  * @param all 軽い呪いまでの解除ならば0
659  * @return 解呪されたアイテムの数
660  * @details
661  * <pre>
662  * Note that Items which are "Perma-Cursed" (The One Ring,
663  * The Crown of Morgoth) can NEVER be uncursed.
664  *
665  * Note that if "all" is FALSE, then Items which are
666  * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
667  * will not be uncursed.
668  * </pre>
669  */
670 static int remove_curse_aux(player_type *creature_ptr, int all)
671 {
672         int cnt = 0;
673         for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
674         {
675                 object_type *o_ptr = &creature_ptr->inventory_list[i];
676                 if (!o_ptr->k_idx) continue;
677                 if (!object_is_cursed(o_ptr)) continue;
678                 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
679                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
680                 {
681                         o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
682                         continue;
683                 }
684
685                 o_ptr->curse_flags = 0L;
686                 o_ptr->ident |= (IDENT_SENSE);
687                 o_ptr->feeling = FEEL_NONE;
688
689                 creature_ptr->update |= (PU_BONUS);
690                 creature_ptr->window |= (PW_EQUIP);
691                 cnt++;
692         }
693
694         if (cnt)
695                 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
696         
697         return cnt;
698 }
699
700
701 /*!
702  * @brief 装備の軽い呪い解呪処理 /
703  * Remove most curses
704  * @param caster_ptr プレーヤーへの参照ポインタ
705  * @return 解呪に成功した装備数
706  */
707 int remove_curse(player_type *caster_ptr)
708 {
709         return remove_curse_aux(caster_ptr, FALSE);
710 }
711
712
713 /*!
714  * @brief 装備の重い呪い解呪処理 /
715  * Remove all curses
716  * @return 解呪に成功した装備数
717  */
718 int remove_all_curse(player_type *caster_ptr)
719 {
720         return remove_curse_aux(caster_ptr, TRUE);
721 }
722
723
724 /*!
725  * @brief アイテムの価値に応じた錬金術処理 /
726  * Turns an object into gold, gain some of its value in a shop
727  * @param caster_ptr プレーヤーへの参照ポインタ
728  * @return 処理が実際に行われたらTRUEを返す
729  */
730 bool alchemy(player_type *caster_ptr)
731 {
732         bool force = FALSE;
733         if (command_arg > 0) force = TRUE;
734
735         concptr q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
736         concptr s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
737         OBJECT_IDX item;
738         object_type *o_ptr;
739         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
740         if (!o_ptr) return FALSE;
741
742         int amt = 1;
743         if (o_ptr->number > 1)
744         {
745                 amt = get_quantity(NULL, o_ptr->number);
746                 if (amt <= 0) return FALSE;
747         }
748
749         ITEM_NUMBER old_number = o_ptr->number;
750         o_ptr->number = amt;
751         GAME_TEXT o_name[MAX_NLEN];
752         object_desc(caster_ptr, o_name, o_ptr, 0);
753         o_ptr->number = old_number;
754
755         if (!force)
756         {
757                 if (confirm_destroy || (object_value(o_ptr) > 0))
758                 {
759                         char out_val[MAX_NLEN + 40];
760                         sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
761                         if (!get_check(out_val)) return FALSE;
762                 }
763         }
764
765         if (!can_player_destroy_object(o_ptr))
766         {
767                 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
768                 return FALSE;
769         }
770
771         PRICE price = object_value_real(o_ptr);
772         if (price <= 0)
773         {
774                 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
775                 vary_item(caster_ptr, item, -amt);
776                 return TRUE;
777         }
778         
779         price /= 3;
780
781         if (amt > 1) price *= amt;
782
783         if (price > 30000) price = 30000;
784         msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
785
786         caster_ptr->au += price;
787         caster_ptr->redraw |= PR_GOLD;
788         caster_ptr->window |= PW_PLAYER;
789         vary_item(caster_ptr, item, -amt);
790         return TRUE;
791 }
792
793
794 /*!
795  * @brief アーティファクト生成の巻物処理 /
796  * @param caster_ptr プレーヤーへの参照ポインタ
797  * @return 生成が実際に試みられたらTRUEを返す
798  */
799 bool artifact_scroll(player_type *caster_ptr)
800 {
801         item_tester_hook = item_tester_hook_nameless_weapon_armour;
802
803         concptr q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
804         concptr s = _("強化できるアイテムがない。", "You have nothing to enchant.");
805         object_type *o_ptr;
806         OBJECT_IDX item;
807         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
808         if (!o_ptr) return FALSE;
809
810         GAME_TEXT o_name[MAX_NLEN];
811         object_desc(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
812 #ifdef JP
813         msg_format("%s は眩い光を発した!",o_name);
814 #else
815         msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
816 #endif
817
818         bool okay = FALSE;
819         if (object_is_artifact(o_ptr))
820         {
821 #ifdef JP
822                 msg_format("%sは既に伝説のアイテムです!", o_name  );
823 #else
824                 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
825 #endif
826                 okay = FALSE;
827         }
828         else if (object_is_ego(o_ptr))
829         {
830 #ifdef JP
831                 msg_format("%sは既に名のあるアイテムです!", o_name );
832 #else
833                 msg_format("The %s %s already %s!",
834                     o_name, ((o_ptr->number > 1) ? "are" : "is"),
835                     ((o_ptr->number > 1) ? "ego items" : "an ego item"));
836 #endif
837                 okay = FALSE;
838         }
839         else if (o_ptr->xtra3)
840         {
841 #ifdef JP
842                 msg_format("%sは既に強化されています!", o_name );
843 #else
844                 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
845                     ((o_ptr->number > 1) ? "customized items" : "a customized item"));
846 #endif
847         }
848         else
849         {
850                 if (o_ptr->number > 1)
851                 {
852                         msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
853 #ifdef JP
854                         msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
855 #else
856                         msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
857 #endif
858
859                         if (item >= 0)
860                         {
861                                 inven_item_increase(caster_ptr, item, 1 - (o_ptr->number));
862                         }
863                         else
864                         {
865                                 floor_item_increase(caster_ptr->current_floor_ptr, 0 - item, 1 - (o_ptr->number));
866                         }
867                 }
868                 
869                 okay = become_random_artifact(caster_ptr, o_ptr, TRUE);
870         }
871
872         if (!okay)
873         {
874                 if (flush_failure) flush();
875                 msg_print(_("強化に失敗した。", "The enchantment failed."));
876                 if (one_in_(3)) chg_virtue(caster_ptr, V_ENCHANT, -1);
877                 calc_android_exp(caster_ptr);
878                 return TRUE;
879         }
880
881         if (record_rand_art)
882         {
883                 object_desc(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
884                 exe_write_diary(caster_ptr, DIARY_ART_SCROLL, 0, o_name);
885         }
886
887         chg_virtue(caster_ptr, V_ENCHANT, 1);
888         calc_android_exp(caster_ptr);
889         return TRUE;
890 }
891
892
893 /*!
894  * @brief アイテム鑑定処理 /
895  * Identify an object
896  * @param owner_ptr プレーヤーへの参照ポインタ
897  * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
898  * @return 実際に鑑定できたらTRUEを返す
899  */
900 bool identify_item(player_type *owner_ptr, object_type *o_ptr)
901 {
902         GAME_TEXT o_name[MAX_NLEN];
903         object_desc(owner_ptr, o_name, o_ptr, 0);
904
905         bool old_known = FALSE;
906         if (o_ptr->ident & IDENT_KNOWN)
907                 old_known = TRUE;
908
909         if (!object_is_fully_known(o_ptr))
910         {
911                 if (object_is_artifact(o_ptr) || one_in_(5))
912                         chg_virtue(owner_ptr, V_KNOWLEDGE, 1);
913         }
914
915         object_aware(owner_ptr, o_ptr);
916         object_known(o_ptr);
917         o_ptr->marked |= OM_TOUCHED;
918
919         owner_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
920         owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
921
922         strcpy(record_o_name, o_name);
923         record_turn = current_world_ptr->game_turn;
924
925         object_desc(owner_ptr, o_name, o_ptr, OD_NAME_ONLY);
926
927         if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
928                 exe_write_diary(owner_ptr, DIARY_ART, 0, o_name);
929         if(record_rand_art && !old_known && o_ptr->art_name)
930                 exe_write_diary(owner_ptr, DIARY_ART, 0, o_name);
931
932         return old_known;
933 }
934
935
936 /*!
937  * @brief アイテム鑑定のメインルーチン処理 /
938  * Identify an object in the inventory (or on the floor)
939  * @param caster_ptr プレーヤーへの参照ポインタ
940  * @param only_equip 装備品のみを対象とするならばTRUEを返す
941  * @return 実際に鑑定を行ったならばTRUEを返す
942  * @details
943  * This routine does *not* automatically combine objects.
944  * Returns TRUE if something was identified, else FALSE.
945  */
946 bool ident_spell(player_type *caster_ptr, bool only_equip, tval_type item_tester_tval)
947 {
948         if (only_equip)
949                 item_tester_hook = item_tester_hook_identify_weapon_armour;
950         else
951                 item_tester_hook = item_tester_hook_identify;
952
953         concptr q;
954         if (can_get_item(caster_ptr, item_tester_tval))
955         {
956                 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
957         }
958         else
959         {
960                 if (only_equip)
961                         item_tester_hook = object_is_weapon_armour_ammo;
962                 else
963                         item_tester_hook = NULL;
964
965                 q = _("すべて鑑定済みです。 ", "All items are identified. ");
966         }
967
968         concptr s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
969         OBJECT_IDX item;
970         object_type *o_ptr;
971         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
972         if (!o_ptr) return FALSE;
973
974         bool old_known = identify_item(caster_ptr, o_ptr);
975
976         GAME_TEXT o_name[MAX_NLEN];
977         object_desc(caster_ptr, o_name, o_ptr, 0);
978         if (item >= INVEN_RARM)
979         {
980                 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(caster_ptr, item), o_name, index_to_label(item));
981         }
982         else if (item >= 0)
983         {
984                 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
985         }
986         else
987         {
988                 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
989         }
990
991         autopick_alter_item(caster_ptr, item, (bool)(destroy_identify && !old_known));
992         return TRUE;
993 }
994
995
996 /*!
997  * @brief アイテム凡庸化のメインルーチン処理 /
998  * Identify an object in the inventory (or on the floor)
999  * @param owner_ptr プレーヤーへの参照ポインタ
1000  * @param only_equip 装備品のみを対象とするならばTRUEを返す
1001  * @return 実際に凡庸化をを行ったならばTRUEを返す
1002  * @details
1003  * <pre>
1004  * Mundanify an object in the inventory (or on the floor)
1005  * This routine does *not* automatically combine objects.
1006  * Returns TRUE if something was mundanified, else FALSE.
1007  * </pre>
1008  */
1009 bool mundane_spell(player_type *owner_ptr, bool only_equip)
1010 {
1011         if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
1012
1013         OBJECT_IDX item;
1014         object_type *o_ptr;
1015         concptr q = _("どれを使いますか?", "Use which item? ");
1016         concptr s = _("使えるものがありません。", "You have nothing you can use.");
1017
1018         o_ptr = choose_object(owner_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1019         if (!o_ptr) return FALSE;
1020
1021         msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
1022         POSITION iy = o_ptr->iy;
1023         POSITION ix = o_ptr->ix;
1024         OBJECT_IDX next_o_idx = o_ptr->next_o_idx;
1025         byte marked = o_ptr->marked;
1026         WEIGHT weight = o_ptr->number * o_ptr->weight;
1027         u16b inscription = o_ptr->inscription;
1028
1029         object_prep(o_ptr, o_ptr->k_idx);
1030
1031         o_ptr->iy = iy;
1032         o_ptr->ix = ix;
1033         o_ptr->next_o_idx = next_o_idx;
1034         o_ptr->marked = marked;
1035         o_ptr->inscription = inscription;
1036         if (item >= 0) owner_ptr->total_weight += (o_ptr->weight - weight);
1037
1038         calc_android_exp(owner_ptr);
1039         return TRUE;
1040 }
1041
1042
1043 /*!
1044  * @brief アイテム*鑑定*のメインルーチン処理 /
1045  * Identify an object in the inventory (or on the floor)
1046  * @param caster_ptr プレーヤーへの参照ポインタ
1047  * @param only_equip 装備品のみを対象とするならばTRUEを返す
1048  * @return 実際に鑑定を行ったならばTRUEを返す
1049  * @details
1050  * Fully "identify" an object in the inventory -BEN-
1051  * This routine returns TRUE if an item was identified.
1052  */
1053 bool identify_fully(player_type *caster_ptr, bool only_equip, tval_type item_tester_tval)
1054 {
1055         if (only_equip)
1056                 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
1057         else
1058                 item_tester_hook = item_tester_hook_identify_fully;
1059
1060         concptr q;
1061         if (can_get_item(caster_ptr, item_tester_tval))
1062         {
1063                 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
1064         }
1065         else
1066         {
1067                 if (only_equip)
1068                         item_tester_hook = object_is_weapon_armour_ammo;
1069                 else
1070                         item_tester_hook = NULL;
1071
1072                 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
1073         }
1074
1075         concptr s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
1076
1077         OBJECT_IDX item;
1078         object_type *o_ptr;
1079         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1080         if (!o_ptr) return FALSE;
1081
1082         bool old_known = identify_item(caster_ptr, o_ptr);
1083
1084         o_ptr->ident |= (IDENT_FULL_KNOWN);
1085         handle_stuff(caster_ptr);
1086
1087         GAME_TEXT o_name[MAX_NLEN];
1088         object_desc(caster_ptr, o_name, o_ptr, 0);
1089         if (item >= INVEN_RARM)
1090         {
1091                 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(caster_ptr, item), o_name, index_to_label(item));
1092         }
1093         else if (item >= 0)
1094         {
1095                 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
1096         }
1097         else
1098         {
1099                 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
1100         }
1101
1102         (void)screen_object(caster_ptr, o_ptr, 0L);
1103         autopick_alter_item(caster_ptr, item, (bool)(destroy_identify && !old_known));
1104         return TRUE;
1105 }
1106
1107
1108 /*!
1109  * @brief 魔力充填処理 /
1110  * Recharge a wand/staff/rod from the pack or on the floor.
1111  * This function has been rewritten in Oangband and ZAngband.
1112  * @param caster_ptr プレーヤーへの参照ポインタ
1113  * @param power 充填パワー
1114  * @return ターン消費を要する処理まで進んだらTRUEを返す
1115  *
1116  * Sorcery/Arcane -- Recharge  --> recharge(plev * 4)
1117  * Chaos -- Arcane Binding     --> recharge(90)
1118  *
1119  * Scroll of recharging        --> recharge(130)
1120  * Artifact activation/Thingol --> recharge(130)
1121  *
1122  * It is harder to recharge high level, and highly charged wands,
1123  * staffs, and rods.  The more wands in a stack, the more easily and
1124  * strongly they recharge.  Staffs, however, each get fewer charges if
1125  * stacked.
1126  *
1127  * Beware of "sliding index errors".
1128  */
1129 bool recharge(player_type *caster_ptr, int power)
1130 {
1131         item_tester_hook = item_tester_hook_recharge;
1132         concptr q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
1133         concptr s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
1134
1135         OBJECT_IDX item;
1136         object_type *o_ptr;
1137         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
1138         if (!o_ptr) return FALSE;
1139
1140         object_kind *k_ptr;
1141         k_ptr = &k_info[o_ptr->k_idx];
1142         DEPTH lev = k_info[o_ptr->k_idx].level;
1143
1144         TIME_EFFECT recharge_amount;
1145         int recharge_strength;
1146         bool is_recharge_successful = TRUE;
1147         if (o_ptr->tval == TV_ROD)
1148         {
1149                 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
1150                 if (one_in_(recharge_strength))
1151                 {
1152                         is_recharge_successful = FALSE;
1153                 }
1154                 else
1155                 {
1156                         recharge_amount = (power * damroll(3, 2));
1157                         if (o_ptr->timeout > recharge_amount)
1158                                 o_ptr->timeout -= recharge_amount;
1159                         else
1160                                 o_ptr->timeout = 0;
1161                 }
1162         }
1163         else
1164         {
1165                 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
1166                         recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
1167                 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
1168
1169                 if (recharge_strength < 0) recharge_strength = 0;
1170
1171                 if (one_in_(recharge_strength))
1172                 {
1173                         is_recharge_successful = FALSE;
1174                 }
1175                 else
1176                 {
1177                         recharge_amount = randint1(1 + k_ptr->pval / 2);
1178                         if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
1179                         {
1180                                 recharge_amount +=
1181                                         (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
1182                                 if (recharge_amount < 1) recharge_amount = 1;
1183                                 if (recharge_amount > 12) recharge_amount = 12;
1184                         }
1185
1186                         if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
1187                         {
1188                                 recharge_amount /= (TIME_EFFECT)o_ptr->number;
1189                                 if (recharge_amount < 1) recharge_amount = 1;
1190                         }
1191
1192                         o_ptr->pval += recharge_amount;
1193                         o_ptr->ident &= ~(IDENT_KNOWN);
1194                         o_ptr->ident &= ~(IDENT_EMPTY);
1195                 }
1196         }
1197         
1198         if (!is_recharge_successful)
1199         {
1200                 return update_player(caster_ptr);
1201         }
1202
1203         byte fail_type = 1;
1204         GAME_TEXT o_name[MAX_NLEN];
1205         if (object_is_fixed_artifact(o_ptr))
1206         {
1207                 object_desc(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
1208                 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
1209                 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
1210                         o_ptr->timeout = (o_ptr->timeout + 100) * 2;
1211                 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
1212                         o_ptr->pval = 0;
1213                 return update_player(caster_ptr);
1214         }
1215         
1216         object_desc(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1217
1218         if (IS_WIZARD_CLASS(caster_ptr) || caster_ptr->pclass == CLASS_MAGIC_EATER || caster_ptr->pclass == CLASS_BLUE_MAGE)
1219         {
1220                 /* 10% chance to blow up one rod, otherwise draining. */
1221                 if (o_ptr->tval == TV_ROD)
1222                 {
1223                         if (one_in_(10)) fail_type = 2;
1224                         else fail_type = 1;
1225                 }
1226                 /* 75% chance to blow up one wand, otherwise draining. */
1227                 else if (o_ptr->tval == TV_WAND)
1228                 {
1229                         if (!one_in_(3)) fail_type = 2;
1230                         else fail_type = 1;
1231                 }
1232                 /* 50% chance to blow up one staff, otherwise no effect. */
1233                 else if (o_ptr->tval == TV_STAFF)
1234                 {
1235                         if (one_in_(2)) fail_type = 2;
1236                         else fail_type = 0;
1237                 }
1238         }
1239         else
1240         {
1241                 /* 33% chance to blow up one rod, otherwise draining. */
1242                 if (o_ptr->tval == TV_ROD)
1243                 {
1244                         if (one_in_(3)) fail_type = 2;
1245                         else fail_type = 1;
1246                 }
1247                 /* 20% chance of the entire stack, else destroy one wand. */
1248                 else if (o_ptr->tval == TV_WAND)
1249                 {
1250                         if (one_in_(5)) fail_type = 3;
1251                         else fail_type = 2;
1252                 }
1253                 /* Blow up one staff. */
1254                 else if (o_ptr->tval == TV_STAFF)
1255                 {
1256                         fail_type = 2;
1257                 }
1258         }
1259
1260         if (fail_type == 1)
1261         {
1262                 if (o_ptr->tval == TV_ROD)
1263                 {
1264                         msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
1265
1266                         if (o_ptr->timeout < 10000)
1267                                 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
1268                 }
1269                 else if (o_ptr->tval == TV_WAND)
1270                 {
1271                         msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
1272                         o_ptr->pval = 0;
1273                 }
1274         }
1275
1276         if (fail_type == 2)
1277         {
1278                 if (o_ptr->number > 1)
1279                         msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
1280                 else
1281                         msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
1282
1283                 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
1284                 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
1285
1286                 vary_item(caster_ptr, item, -1);
1287         }
1288
1289         if (fail_type == 3)
1290         {
1291                 if (o_ptr->number > 1)
1292                         msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
1293                 else
1294                         msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
1295
1296                 vary_item(caster_ptr, item, -999);
1297         }
1298
1299         return update_player(caster_ptr);
1300 }
1301
1302
1303 /*!
1304  * @brief クリーチャー全既知呪文を表示する /
1305  * Hack -- Display all known spells in a window
1306  * @param caster_ptr 術者の参照ポインタ
1307  * return なし
1308  * @details
1309  * Need to analyze size of the window.
1310  * Need more color coding.
1311  */
1312 void display_spell_list(player_type *caster_ptr)
1313 {
1314         TERM_LEN y, x;
1315         int m[9];
1316         const magic_type *s_ptr;
1317         GAME_TEXT name[MAX_NLEN];
1318         char out_val[160];
1319
1320         clear_from(0);
1321
1322         if (caster_ptr->pclass == CLASS_SORCERER) return;
1323         if (caster_ptr->pclass == CLASS_RED_MAGE) return;
1324         if (caster_ptr->pclass == CLASS_SNIPER)
1325         {
1326                 display_snipe_list(caster_ptr);
1327                 return;
1328         }
1329
1330         if ((caster_ptr->pclass == CLASS_MINDCRAFTER) ||
1331             (caster_ptr->pclass == CLASS_BERSERKER) ||
1332             (caster_ptr->pclass == CLASS_NINJA) ||
1333             (caster_ptr->pclass == CLASS_MIRROR_MASTER) ||
1334             (caster_ptr->pclass == CLASS_FORCETRAINER))
1335         {
1336                 PERCENTAGE minfail = 0;
1337                 PLAYER_LEVEL plev = caster_ptr->lev;
1338                 PERCENTAGE chance = 0;
1339                 mind_type spell;
1340                 char comment[80];
1341                 char psi_desc[80];
1342                 int use_mind;
1343                 bool use_hp = FALSE;
1344
1345                 y = 1;
1346                 x = 1;
1347
1348                 prt("", y, x);
1349                 put_str(_("名前", "Name"), y, x + 5);
1350                 put_str(_("Lv   MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
1351
1352                 switch(caster_ptr->pclass)
1353                 {
1354                 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
1355                 case CLASS_FORCETRAINER:          use_mind = MIND_KI;break;
1356                 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
1357                 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
1358                 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
1359                 default:                use_mind = 0;break;
1360                 }
1361
1362                 for (int i = 0; i < MAX_MIND_POWERS; i++)
1363                 {
1364                         byte a = TERM_WHITE;
1365                         spell = mind_powers[use_mind].info[i];
1366                         if (spell.min_lev > plev) break;
1367
1368                         chance = spell.fail;
1369                         chance -= 3 * (caster_ptr->lev - spell.min_lev);
1370                         chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
1371                         if (!use_hp)
1372                         {
1373                                 if (spell.mana_cost > caster_ptr->csp)
1374                                 {
1375                                         chance += 5 * (spell.mana_cost - caster_ptr->csp);
1376                                         a = TERM_ORANGE;
1377                                 }
1378                         }
1379                         else
1380                         {
1381                                 if (spell.mana_cost > caster_ptr->chp)
1382                                 {
1383                                         chance += 100;
1384                                         a = TERM_RED;
1385                                 }
1386                         }
1387
1388                         minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
1389                         if (chance < minfail) chance = minfail;
1390
1391                         if (caster_ptr->stun > 50) chance += 25;
1392                         else if (caster_ptr->stun) chance += 15;
1393
1394                         if (chance > 95) chance = 95;
1395
1396                         mindcraft_info(caster_ptr, comment, use_mind, i);
1397                         sprintf(psi_desc, "  %c) %-30s%2d %4d %3d%%%s",
1398                             I2A(i), spell.name,
1399                             spell.min_lev, spell.mana_cost, chance, comment);
1400
1401                         Term_putstr(x, y + i + 1, -1, a, psi_desc);
1402                 }
1403
1404                 return;
1405         }
1406
1407         if (REALM_NONE == caster_ptr->realm1) return;
1408
1409         for (int j = 0; j < ((caster_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
1410         {
1411                 m[j] = 0;
1412                 y = (j < 3) ? 0 : (m[j - 3] + 2);
1413                 x = 27 * (j % 3);
1414                 int n = 0;
1415                 for (int i = 0; i < 32; i++)
1416                 {
1417                         byte a = TERM_WHITE;
1418
1419                         if (!is_magic((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2))
1420                         {
1421                                 s_ptr = &technic_info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - MIN_TECHNIC][i % 32];
1422                         }
1423                         else
1424                         {
1425                                 s_ptr = &mp_ptr->info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - 1][i % 32];
1426                         }
1427
1428                         strcpy(name, exe_spell(caster_ptr, (j < 1) ? caster_ptr->realm1 : caster_ptr->realm2, i % 32, SPELL_NAME));
1429
1430                         if (s_ptr->slevel >= 99)
1431                         {
1432                                 strcpy(name, _("(判読不能)", "(illegible)"));
1433                                 a = TERM_L_DARK;
1434                         }
1435                         else if ((j < 1) ?
1436                                 ((caster_ptr->spell_forgotten1 & (1L << i))) :
1437                                 ((caster_ptr->spell_forgotten2 & (1L << (i % 32)))))
1438                         {
1439                                 a = TERM_ORANGE;
1440                         }
1441                         else if (!((j < 1) ?
1442                                 (caster_ptr->spell_learned1 & (1L << i)) :
1443                                 (caster_ptr->spell_learned2 & (1L << (i % 32)))))
1444                         {
1445                                 a = TERM_RED;
1446                         }
1447                         else if (!((j < 1) ?
1448                                 (caster_ptr->spell_worked1 & (1L << i)) :
1449                                 (caster_ptr->spell_worked2 & (1L << (i % 32)))))
1450                         {
1451                                 a = TERM_YELLOW;
1452                         }
1453
1454                         sprintf(out_val, "%c/%c) %-20.20s",
1455                                 I2A(n / 8), I2A(n % 8), name);
1456
1457                         m[j] = y + n;
1458                         Term_putstr(x, m[j], -1, a, out_val);
1459                         n++;
1460                 }
1461         }
1462 }
1463
1464
1465 /*!
1466  * @brief 呪文の経験値を返す /
1467  * Returns experience of a spell
1468  * @param caster_ptr プレーヤーへの参照ポインタ
1469  * @param spell 呪文ID
1470  * @param use_realm 魔法領域
1471  * @return 経験値
1472  */
1473 EXP experience_of_spell(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_realm)
1474 {
1475         if (caster_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
1476         else if (caster_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
1477         else if (use_realm == caster_ptr->realm1) return caster_ptr->spell_exp[spell];
1478         else if (use_realm == caster_ptr->realm2) return caster_ptr->spell_exp[spell + 32];
1479         else return 0;
1480 }
1481
1482
1483 /*!
1484  * @brief 呪文の消費MPを返す /
1485  * Modify mana consumption rate using spell exp and dec_mana
1486  * @param caster_ptr プレーヤーへの参照ポインタ
1487  * @param need_mana 基本消費MP
1488  * @param spell 呪文ID
1489  * @param realm 魔法領域
1490  * @return 消費MP
1491  */
1492 MANA_POINT mod_need_mana(player_type *caster_ptr, MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
1493 {
1494 #define MANA_CONST   2400
1495 #define MANA_DIV        4
1496 #define DEC_MANA_DIV    3
1497         if ((realm > REALM_NONE) && (realm <= MAX_REALM))
1498         {
1499                 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(caster_ptr, spell, realm)) + (MANA_CONST - 1);
1500                 need_mana *= caster_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
1501                 need_mana /= MANA_CONST * MANA_DIV;
1502                 if (need_mana < 1) need_mana = 1;
1503         }
1504         else
1505         {
1506                 if (caster_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
1507         }
1508
1509 #undef DEC_MANA_DIV
1510 #undef MANA_DIV
1511 #undef MANA_CONST
1512
1513         return need_mana;
1514 }
1515
1516
1517 /*!
1518  * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
1519  * Modify spell fail rate
1520  * Using to_m_chance, dec_mana, easy_spell and heavy_spell
1521  * @param caster_ptr プレーヤーへの参照ポインタ
1522  * @param chance 修正前失敗率
1523  * @return 失敗率(%)
1524  * @todo 統合を検討
1525  */
1526 PERCENTAGE mod_spell_chance_1(player_type *caster_ptr, PERCENTAGE chance)
1527 {
1528         chance += caster_ptr->to_m_chance;
1529
1530         if (caster_ptr->heavy_spell) chance += 20;
1531
1532         if (caster_ptr->dec_mana && caster_ptr->easy_spell) chance -= 4;
1533         else if (caster_ptr->easy_spell) chance -= 3;
1534         else if (caster_ptr->dec_mana) chance -= 2;
1535
1536         return chance;
1537 }
1538
1539
1540 /*!
1541  * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
1542  * Modify spell fail rate
1543  * Using to_m_chance, dec_mana, easy_spell and heavy_spell
1544  * @param caster_ptr プレーヤーへの参照ポインタ
1545  * @param chance 修正前失敗率
1546  * @return 失敗率(%)
1547  * Modify spell fail rate (as "suffix" process)
1548  * Using dec_mana, easy_spell and heavy_spell
1549  * Note: variable "chance" cannot be negative.
1550  * @todo 統合を検討
1551  */
1552 PERCENTAGE mod_spell_chance_2(player_type *caster_ptr, PERCENTAGE chance)
1553 {
1554         if (caster_ptr->dec_mana) chance--;
1555         if (caster_ptr->heavy_spell) chance += 5;
1556         return MAX(chance, 0);
1557 }
1558
1559
1560 /*!
1561  * @brief 呪文の失敗率計算メインルーチン /
1562  * Returns spell chance of failure for spell -RAK-
1563  * @param caster_ptr プレーヤーへの参照ポインタ
1564  * @param spell 呪文ID
1565  * @param use_realm 魔法領域ID
1566  * @return 失敗率(%)
1567  */
1568 PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_realm)
1569 {
1570         if (!mp_ptr->spell_book) return 100;
1571         if (use_realm == REALM_HISSATSU) return 0;
1572
1573         const magic_type *s_ptr;
1574         if (!is_magic(use_realm))
1575         {
1576                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1577         }
1578         else
1579         {
1580                 s_ptr = &mp_ptr->info[use_realm - 1][spell];
1581         }
1582
1583         PERCENTAGE chance = s_ptr->sfail;
1584         chance -= 3 * (caster_ptr->lev - s_ptr->slevel);
1585         chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
1586         if (caster_ptr->riding)
1587                 chance += (MAX(r_info[caster_ptr->current_floor_ptr->m_list[caster_ptr->riding].r_idx].level - caster_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
1588
1589         MANA_POINT need_mana = mod_need_mana(caster_ptr, s_ptr->smana, spell, use_realm);
1590         if (need_mana > caster_ptr->csp)
1591         {
1592                 chance += 5 * (need_mana - caster_ptr->csp);
1593         }
1594
1595         if ((use_realm != caster_ptr->realm1) && ((caster_ptr->pclass == CLASS_MAGE) || (caster_ptr->pclass == CLASS_PRIEST))) chance += 5;
1596
1597         PERCENTAGE minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
1598         if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
1599         {
1600                 if (minfail < 5) minfail = 5;
1601         }
1602
1603         if (((caster_ptr->pclass == CLASS_PRIEST) || (caster_ptr->pclass == CLASS_SORCERER)) && caster_ptr->icky_wield[0]) chance += 25;
1604         if (((caster_ptr->pclass == CLASS_PRIEST) || (caster_ptr->pclass == CLASS_SORCERER)) && caster_ptr->icky_wield[1]) chance += 25;
1605
1606         chance = mod_spell_chance_1(caster_ptr, chance);
1607         PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
1608         switch (use_realm)
1609         {
1610         case REALM_NATURE:
1611                 if ((caster_ptr->align > 50) || (caster_ptr->align < -50)) chance += penalty;
1612                 break;
1613         case REALM_LIFE: case REALM_CRUSADE:
1614                 if (caster_ptr->align < -20) chance += penalty;
1615                 break;
1616         case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
1617                 if (caster_ptr->align > 20) chance += penalty;
1618                 break;
1619         }
1620
1621         if (chance < minfail) chance = minfail;
1622
1623         if (caster_ptr->stun > 50) chance += 25;
1624         else if (caster_ptr->stun) chance += 15;
1625
1626         if (chance > 95) chance = 95;
1627
1628         if ((use_realm == caster_ptr->realm1) || (use_realm == caster_ptr->realm2)
1629             || (caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE))
1630         {
1631                 EXP exp = experience_of_spell(caster_ptr, spell, use_realm);
1632                 if (exp >= SPELL_EXP_EXPERT) chance--;
1633                 if (exp >= SPELL_EXP_MASTER) chance--;
1634         }
1635
1636         return mod_spell_chance_2(caster_ptr, chance);
1637 }
1638
1639
1640 /*!
1641  * @brief 呪文情報の表示処理 /
1642  * Print a list of spells (for browsing or casting or viewing)
1643  * @param caster_ptr 術者の参照ポインタ
1644  * @param target_spell 呪文ID
1645  * @param spells 表示するスペルID配列の参照ポインタ
1646  * @param num 表示するスペルの数(spellsの要素数)
1647  * @param y 表示メッセージ左上Y座標
1648  * @param x 表示メッセージ左上X座標
1649  * @param use_realm 魔法領域ID
1650  * @return なし
1651  */
1652 void print_spells(player_type* caster_ptr, SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
1653 {
1654         if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && current_world_ptr->wizard)
1655         msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
1656
1657         prt("", y, x);
1658         char buf[256];
1659         if (use_realm == REALM_HISSATSU)
1660                 strcpy(buf,_("  Lv   MP", "  Lv   SP"));
1661         else
1662                 strcpy(buf,_("熟練度 Lv   MP 失率 効果", "Profic Lv   SP Fail Effect"));
1663
1664         put_str(_("名前", "Name"), y, x + 5);
1665         put_str(buf, y, x + 29);
1666
1667         int increment = 64;
1668         if ((caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
1669         else if (use_realm == caster_ptr->realm1) increment = 0;
1670         else if (use_realm == caster_ptr->realm2) increment = 32;
1671
1672         int i;
1673         int exp_level;
1674         const magic_type *s_ptr;
1675         char info[80];
1676         char out_val[160];
1677         char ryakuji[5];
1678         bool max = FALSE;
1679         for (i = 0; i < num; i++)
1680         {
1681                 SPELL_IDX spell = spells[i];
1682
1683                 if (!is_magic(use_realm))
1684                 {
1685                         s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1686                 }
1687                 else
1688                 {
1689                         s_ptr = &mp_ptr->info[use_realm - 1][spell];
1690                 }
1691
1692                 MANA_POINT need_mana;
1693                 if (use_realm == REALM_HISSATSU)
1694                         need_mana = s_ptr->smana;
1695                 else
1696                 {
1697                         EXP exp = experience_of_spell(caster_ptr, spell, use_realm);
1698                         need_mana = mod_need_mana(caster_ptr, s_ptr->smana, spell, use_realm);
1699                         if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
1700                         else exp_level = spell_exp_level(exp);
1701
1702                         max = FALSE;
1703                         if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
1704                         else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
1705                         else if (s_ptr->slevel >= 99) max = TRUE;
1706                         else if ((caster_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
1707
1708                         strncpy(ryakuji, exp_level_str[exp_level], 4);
1709                         ryakuji[3] = ']';
1710                         ryakuji[4] = '\0';
1711                 }
1712
1713                 if (use_menu && target_spell)
1714                 {
1715                         if (i == (target_spell-1))
1716                                 strcpy(out_val, _("  》 ", "  >  "));
1717                         else
1718                                 strcpy(out_val, "     ");
1719                 }
1720                 else sprintf(out_val, "  %c) ", I2A(i));
1721
1722                 if (s_ptr->slevel >= 99)
1723                 {
1724                         strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
1725                         c_prt(TERM_L_DARK, out_val, y + i + 1, x);
1726                         continue;
1727                 }
1728
1729                 strcpy(info, exe_spell(caster_ptr, use_realm, spell, SPELL_INFO));
1730                 concptr comment = info;
1731                 byte line_attr = TERM_WHITE;
1732                 if ((caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE))
1733                 {
1734                         if (s_ptr->slevel > caster_ptr->max_plv)
1735                         {
1736                                 comment = _("未知", "unknown");
1737                                 line_attr = TERM_L_BLUE;
1738                         }
1739                         else if (s_ptr->slevel > caster_ptr->lev)
1740                         {
1741                                 comment = _("忘却", "forgotten");
1742                                 line_attr = TERM_YELLOW;
1743                         }
1744                 }
1745                 else if ((use_realm != caster_ptr->realm1) && (use_realm != caster_ptr->realm2))
1746                 {
1747                         comment = _("未知", "unknown");
1748                         line_attr = TERM_L_BLUE;
1749                 }
1750                 else if ((use_realm == caster_ptr->realm1) ?
1751                     ((caster_ptr->spell_forgotten1 & (1L << spell))) :
1752                     ((caster_ptr->spell_forgotten2 & (1L << spell))))
1753                 {
1754                         comment = _("忘却", "forgotten");
1755                         line_attr = TERM_YELLOW;
1756                 }
1757                 else if (!((use_realm == caster_ptr->realm1) ?
1758                     (caster_ptr->spell_learned1 & (1L << spell)) :
1759                     (caster_ptr->spell_learned2 & (1L << spell))))
1760                 {
1761                         comment = _("未知", "unknown");
1762                         line_attr = TERM_L_BLUE;
1763                 }
1764                 else if (!((use_realm == caster_ptr->realm1) ?
1765                     (caster_ptr->spell_worked1 & (1L << spell)) :
1766                     (caster_ptr->spell_worked2 & (1L << spell))))
1767                 {
1768                         comment = _("未経験", "untried");
1769                         line_attr = TERM_L_GREEN;
1770                 }
1771
1772                 if (use_realm == REALM_HISSATSU)
1773                 {
1774                         strcat(out_val, format("%-25s %2d %4d",
1775                             exe_spell(caster_ptr, use_realm, spell, SPELL_NAME), s_ptr->slevel, need_mana));
1776                 }
1777                 else
1778                 {
1779                         strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
1780                             exe_spell(caster_ptr, use_realm, spell, SPELL_NAME), (max ? '!' : ' '), ryakuji,
1781                             s_ptr->slevel, need_mana, spell_chance(caster_ptr, spell, use_realm), comment));
1782                 }
1783
1784                 c_prt(line_attr, out_val, y + i + 1, x);
1785         }
1786
1787         prt("", y + i + 1, x);
1788 }
1789
1790
1791 /*!
1792  * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
1793  * Helper function -- return a "nearby" race for polymorphing
1794  * @param floor_ptr 配置するフロアの参照ポインタ
1795  * @param r_idx 基準となるモンスター種族ID
1796  * @return 変更先のモンスター種族ID
1797  * @details
1798  * Note that this function is one of the more "dangerous" ones...
1799  */
1800 static MONRACE_IDX poly_r_idx(player_type *caster_ptr, MONRACE_IDX r_idx)
1801 {
1802         monster_race *r_ptr = &r_info[r_idx];
1803         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
1804                 return (r_idx);
1805
1806         DEPTH lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
1807         DEPTH lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
1808         MONRACE_IDX r;
1809         for (int i = 0; i < 1000; i++)
1810         {
1811                 r = get_mon_num(caster_ptr, (caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5, 0);
1812                 if (!r) break;
1813
1814                 r_ptr = &r_info[r];
1815                 if (r_ptr->flags1 & RF1_UNIQUE) continue;
1816                 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
1817
1818                 r_idx = r;
1819                 break;
1820         }
1821
1822         return r_idx;
1823 }
1824
1825
1826 /*!
1827  * @brief 指定座標にいるモンスターを変身させる /
1828  * Helper function -- return a "nearby" race for polymorphing
1829  * @param caster_ptr プレーヤーへの参照ポインタ
1830  * @param y 指定のY座標
1831  * @param x 指定のX座標
1832  * @return 実際に変身したらTRUEを返す
1833  */
1834 bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x)
1835 {
1836         floor_type *floor_ptr = caster_ptr->current_floor_ptr;
1837         grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1838         monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
1839         MONRACE_IDX new_r_idx;
1840         MONRACE_IDX old_r_idx = m_ptr->r_idx;
1841         bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
1842         bool health_tracked = (caster_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
1843
1844         if (floor_ptr->inside_arena || caster_ptr->phase_out) return FALSE;
1845         if ((caster_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
1846
1847         monster_type back_m = *m_ptr;
1848         new_r_idx = poly_r_idx(caster_ptr, old_r_idx);
1849         if (new_r_idx == old_r_idx) return FALSE;
1850
1851         bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
1852         OBJECT_IDX this_o_idx, next_o_idx = 0;
1853
1854         BIT_FLAGS mode = 0L;
1855         if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
1856         if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1857         if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
1858
1859         m_ptr->hold_o_idx = 0;
1860         delete_monster_idx(caster_ptr, g_ptr->m_idx);
1861         bool polymorphed = FALSE;
1862         if (place_monster_aux(caster_ptr, 0, y, x, new_r_idx, mode))
1863         {
1864                 floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
1865                 floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
1866                 floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
1867                 polymorphed = TRUE;
1868         }
1869         else
1870         {
1871                 if (place_monster_aux(caster_ptr, 0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
1872                 {
1873                         floor_ptr->m_list[hack_m_idx_ii] = back_m;
1874                         mproc_init(floor_ptr);
1875                 }
1876                 else preserve_hold_objects = FALSE;
1877         }
1878
1879         if (preserve_hold_objects)
1880         {
1881                 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
1882                 {
1883                         object_type *o_ptr = &floor_ptr->o_list[this_o_idx];
1884                         next_o_idx = o_ptr->next_o_idx;
1885                         o_ptr->held_m_idx = hack_m_idx_ii;
1886                 }
1887         }
1888         else if (back_m.hold_o_idx)
1889         {
1890                 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
1891                 {
1892                         next_o_idx = floor_ptr->o_list[this_o_idx].next_o_idx;
1893                         delete_object_idx(caster_ptr, this_o_idx);
1894                 }
1895         }
1896
1897         if (targeted) target_who = hack_m_idx_ii;
1898         if (health_tracked) health_track(caster_ptr, hack_m_idx_ii);
1899         return polymorphed;
1900 }
1901
1902
1903 /*!
1904  * @brief 魔力食い処理
1905  * @param caster_ptr プレーヤーへの参照ポインタ
1906  * @param power 基本効力
1907  * @return ターンを消費した場合TRUEを返す
1908  */
1909 bool eat_magic(player_type *caster_ptr, int power)
1910 {
1911         byte fail_type = 1;
1912         GAME_TEXT o_name[MAX_NLEN];
1913
1914         item_tester_hook = item_tester_hook_recharge;
1915
1916         concptr q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
1917         concptr s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
1918
1919         object_type *o_ptr;
1920         OBJECT_IDX item;
1921         o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
1922         if (!o_ptr) return FALSE;
1923
1924         object_kind *k_ptr;
1925         k_ptr = &k_info[o_ptr->k_idx];
1926         DEPTH lev = k_info[o_ptr->k_idx].level;
1927
1928         int recharge_strength = 0;
1929         bool is_eating_successful = TRUE;
1930         if (o_ptr->tval == TV_ROD)
1931         {
1932                 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
1933                 if (one_in_(recharge_strength))
1934                 {
1935                         is_eating_successful = FALSE;
1936                 }
1937                 else
1938                 {
1939                         if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
1940                         {
1941                                 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
1942                         }
1943                         else
1944                         {
1945                                 caster_ptr->csp += lev;
1946                                 o_ptr->timeout += k_ptr->pval;
1947                         }
1948                 }
1949         }
1950         else
1951         {
1952                 recharge_strength = (100 + power - lev) / 15;
1953                 if (recharge_strength < 0) recharge_strength = 0;
1954
1955                 if (one_in_(recharge_strength))
1956                 {
1957                         is_eating_successful = FALSE;
1958                 }
1959                 else
1960                 {
1961                         if (o_ptr->pval > 0)
1962                         {
1963                                 caster_ptr->csp += lev / 2;
1964                                 o_ptr->pval --;
1965
1966                                 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
1967                                 {
1968                                         object_type forge;
1969                                         object_type *q_ptr;
1970                                         q_ptr = &forge;
1971                                         object_copy(q_ptr, o_ptr);
1972
1973                                         q_ptr->number = 1;
1974                                         o_ptr->pval++;
1975                                         o_ptr->number--;
1976                                         caster_ptr->total_weight -= q_ptr->weight;
1977                                         item = store_item_to_inventory(caster_ptr, q_ptr);
1978
1979                                         msg_print(_("杖をまとめなおした。", "You unstack your staff."));
1980                                 }
1981                         }
1982                         else
1983                         {
1984                                 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
1985                         }
1986
1987                         if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
1988                 }
1989         }
1990
1991         if (is_eating_successful)
1992         {
1993                 return redraw_player(caster_ptr);
1994         }
1995
1996         if (object_is_fixed_artifact(o_ptr))
1997         {
1998                 object_desc(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
1999                 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2000                 if (o_ptr->tval == TV_ROD)
2001                         o_ptr->timeout = k_ptr->pval * o_ptr->number;
2002                 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2003                         o_ptr->pval = 0;
2004
2005                 return redraw_player(caster_ptr);
2006         }
2007         
2008         object_desc(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2009
2010         /* Mages recharge objects more safely. */
2011         if (IS_WIZARD_CLASS(caster_ptr))
2012         {
2013                 /* 10% chance to blow up one rod, otherwise draining. */
2014                 if (o_ptr->tval == TV_ROD)
2015                 {
2016                         if (one_in_(10)) fail_type = 2;
2017                         else fail_type = 1;
2018                 }
2019                 /* 75% chance to blow up one wand, otherwise draining. */
2020                 else if (o_ptr->tval == TV_WAND)
2021                 {
2022                         if (!one_in_(3)) fail_type = 2;
2023                         else fail_type = 1;
2024                 }
2025                 /* 50% chance to blow up one staff, otherwise no effect. */
2026                 else if (o_ptr->tval == TV_STAFF)
2027                 {
2028                         if (one_in_(2)) fail_type = 2;
2029                         else fail_type = 0;
2030                 }
2031         }
2032
2033         /* All other classes get no special favors. */
2034         else
2035         {
2036                 /* 33% chance to blow up one rod, otherwise draining. */
2037                 if (o_ptr->tval == TV_ROD)
2038                 {
2039                         if (one_in_(3)) fail_type = 2;
2040                         else fail_type = 1;
2041                 }
2042                 /* 20% chance of the entire stack, else destroy one wand. */
2043                 else if (o_ptr->tval == TV_WAND)
2044                 {
2045                         if (one_in_(5)) fail_type = 3;
2046                         else fail_type = 2;
2047                 }
2048                 /* Blow up one staff. */
2049                 else if (o_ptr->tval == TV_STAFF)
2050                 {
2051                         fail_type = 2;
2052                 }
2053         }
2054
2055         if (fail_type == 1)
2056         {
2057                 if (o_ptr->tval == TV_ROD)
2058                 {
2059                         msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
2060                                 "You save your rod from destruction, but all charges are lost."), o_name);
2061                         o_ptr->timeout = k_ptr->pval * o_ptr->number;
2062                 }
2063                 else if (o_ptr->tval == TV_WAND)
2064                 {
2065                         msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2066                         o_ptr->pval = 0;
2067                 }
2068         }
2069
2070         if (fail_type == 2)
2071         {
2072                 if (o_ptr->number > 1)
2073                 {
2074                         msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2075                         /* Reduce rod stack maximum timeout, drain wands. */
2076                         if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
2077                         else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
2078                 }
2079                 else
2080                 {
2081                         msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
2082                 }
2083
2084                 vary_item(caster_ptr, item, -1);
2085         }
2086
2087         if (fail_type == 3)
2088         {
2089                 if (o_ptr->number > 1)
2090                         msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2091                 else
2092                         msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2093
2094                 vary_item(caster_ptr, item, -999);
2095         }
2096
2097         return redraw_player(caster_ptr);
2098 }
2099
2100
2101 /*!
2102  * @brief 皆殺し(全方向攻撃)処理
2103  * @param caster_ptr プレーヤーへの参照ポインタ
2104  * @return なし
2105  */
2106 void massacre(player_type *caster_ptr)
2107 {
2108         grid_type *g_ptr;
2109         monster_type *m_ptr;
2110         for (DIRECTION dir = 0; dir < 8; dir++)
2111         {
2112                 POSITION y = caster_ptr->y + ddy_ddd[dir];
2113                 POSITION x = caster_ptr->x + ddx_ddd[dir];
2114                 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
2115                 m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2116                 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT)))
2117                         do_cmd_attack(caster_ptr, y, x, 0);
2118         }
2119 }
2120
2121
2122 /*!
2123 * 岩石食い
2124 * @param caster_ptr プレーヤーへの参照ポインタ
2125 * @return コマンドの入力方向に地形があればTRUE
2126 */
2127 bool eat_rock(player_type *caster_ptr)
2128 {
2129         DIRECTION dir;
2130         if (!get_direction(caster_ptr, &dir, FALSE, FALSE)) return FALSE;
2131         POSITION y = caster_ptr->y + ddy[dir];
2132         POSITION x = caster_ptr->x + ddx[dir];
2133         grid_type *g_ptr;
2134         g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
2135         feature_type *f_ptr, *mimic_f_ptr;
2136         f_ptr = &f_info[g_ptr->feat];
2137         mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
2138
2139         stop_mouth(caster_ptr);
2140         if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
2141         {
2142                 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
2143         }
2144         else if (have_flag(f_ptr->flags, FF_PERMANENT))
2145         {
2146                 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
2147         }
2148         else if (g_ptr->m_idx)
2149         {
2150                 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2151                 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
2152
2153                 if (!m_ptr->ml || !is_pet(m_ptr)) do_cmd_attack(caster_ptr, y, x, 0);
2154         }
2155         else if (have_flag(f_ptr->flags, FF_TREE))
2156         {
2157                 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
2158         }
2159         else if (have_flag(f_ptr->flags, FF_GLASS))
2160         {
2161                 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
2162         }
2163         else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
2164         {
2165                 (void)set_food(caster_ptr, caster_ptr->food + 3000);
2166         }
2167         else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
2168         {
2169                 (void)set_food(caster_ptr, caster_ptr->food + 5000);
2170         }
2171         else
2172         {
2173                 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
2174                 (void)set_food(caster_ptr, caster_ptr->food + 10000);
2175         }
2176
2177         cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
2178         (void)move_player_effect(caster_ptr, y, x, MPE_DONT_PICKUP);
2179         return TRUE;
2180 }
2181
2182
2183 bool shock_power(player_type *caster_ptr)
2184 {
2185     int boost = get_current_ki(caster_ptr);
2186         if (heavy_armor(caster_ptr)) boost /= 2;
2187
2188         project_length = 1;
2189         DIRECTION dir;
2190         if (!get_aim_dir(caster_ptr, &dir)) return FALSE;
2191
2192         POSITION y = caster_ptr->y + ddy[dir];
2193         POSITION x = caster_ptr->x + ddx[dir];
2194         PLAYER_LEVEL plev = caster_ptr->lev;
2195         HIT_POINT dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
2196         fire_beam(caster_ptr, GF_MISSILE, dir, dam);
2197         if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) return TRUE;
2198
2199         POSITION ty = y, tx = x;
2200         POSITION oy = y, ox = x;
2201         MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[y][x].m_idx;
2202         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
2203         monster_race *r_ptr = &r_info[m_ptr->r_idx];
2204         GAME_TEXT m_name[MAX_NLEN];
2205         monster_desc(caster_ptr, m_name, m_ptr, 0);
2206
2207         if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
2208         {
2209                 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
2210                 return TRUE;
2211         }
2212         
2213         for (int i = 0; i < 5; i++)
2214         {
2215                 y += ddy[dir];
2216                 x += ddx[dir];
2217                 if (is_cave_empty_bold(caster_ptr, y, x))
2218                 {
2219                         ty = y;
2220                         tx = x;
2221                 }
2222                 else
2223                 {
2224                         break;
2225                 }
2226         }
2227
2228         bool is_shock_successful = ty != oy;
2229         is_shock_successful |= tx != ox;
2230         if (is_shock_successful) return TRUE;
2231
2232         msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
2233         caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
2234         caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
2235         m_ptr->fy = ty;
2236         m_ptr->fx = tx;
2237
2238         update_monster(caster_ptr, m_idx, TRUE);
2239         lite_spot(caster_ptr, oy, ox);
2240         lite_spot(caster_ptr, ty, tx);
2241
2242         if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
2243                 caster_ptr->update |= (PU_MON_LITE);
2244         return TRUE;
2245 }
2246
2247 bool fetch_monster(player_type *caster_ptr)
2248 {
2249         monster_type *m_ptr;
2250         MONSTER_IDX m_idx;
2251         GAME_TEXT m_name[MAX_NLEN];
2252         int i;
2253         int path_n;
2254         u16b path_g[512];
2255         POSITION ty, tx;
2256
2257         if (!target_set(caster_ptr, TARGET_KILL)) return FALSE;
2258         m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
2259         if (!m_idx) return FALSE;
2260         if (m_idx == caster_ptr->riding) return FALSE;
2261         if (!player_has_los_bold(caster_ptr, target_row, target_col)) return FALSE;
2262         if (!projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col)) return FALSE;
2263         m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
2264         monster_desc(caster_ptr, m_name, m_ptr, 0);
2265         msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
2266         path_n = project_path(caster_ptr, path_g, MAX_RANGE, target_row, target_col, caster_ptr->y, caster_ptr->x, 0);
2267         ty = target_row, tx = target_col;
2268         for (i = 1; i < path_n; i++)
2269         {
2270                 POSITION ny = GRID_Y(path_g[i]);
2271                 POSITION nx = GRID_X(path_g[i]);
2272                 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[ny][nx];
2273
2274                 if (in_bounds(caster_ptr->current_floor_ptr, ny, nx) && is_cave_empty_bold(caster_ptr, ny, nx) &&
2275                         !(g_ptr->info & CAVE_OBJECT) &&
2276                         !pattern_tile(caster_ptr->current_floor_ptr, ny, nx))
2277                 {
2278                         ty = ny;
2279                         tx = nx;
2280                 }
2281         }
2282         /* Update the old location */
2283         caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx = 0;
2284
2285         /* Update the new location */
2286         caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
2287
2288         /* Move the monster */
2289         m_ptr->fy = ty;
2290         m_ptr->fx = tx;
2291
2292         /* Wake the monster up */
2293         (void)set_monster_csleep(caster_ptr, m_idx, 0);
2294
2295         update_monster(caster_ptr, m_idx, TRUE);
2296         lite_spot(caster_ptr, target_row, target_col);
2297         lite_spot(caster_ptr, ty, tx);
2298
2299         if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
2300                 caster_ptr->update |= (PU_MON_LITE);
2301
2302         if (m_ptr->ml)
2303         {
2304                 /* Auto-Recall if possible and visible */
2305                 if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
2306                 health_track(caster_ptr, m_idx);
2307         }
2308         return TRUE;
2309
2310 }
2311
2312
2313 bool booze(player_type *creature_ptr)
2314 {
2315         bool ident = FALSE;
2316         if (creature_ptr->pclass != CLASS_MONK) chg_virtue(creature_ptr, V_HARMONY, -1);
2317         else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
2318         if (!creature_ptr->resist_conf && set_confused(creature_ptr, randint0(20) + 15))
2319         {
2320                 ident = TRUE;
2321         }
2322
2323         if (creature_ptr->resist_chaos)
2324         {
2325                 return ident;
2326         }
2327         
2328         if (one_in_(2) && set_image(creature_ptr, creature_ptr->image + randint0(150) + 150))
2329         {
2330                 ident = TRUE;
2331         }
2332
2333         if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
2334         {
2335                 ident = TRUE;
2336                 if (one_in_(3)) lose_all_info(creature_ptr);
2337                 else wiz_dark(creature_ptr);
2338                 (void)teleport_player_aux(creature_ptr, 100, FALSE, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
2339                 wiz_dark(creature_ptr);
2340                 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
2341                 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing or how you got here!"));
2342         }
2343
2344         return ident;
2345 }
2346
2347
2348 bool detonation(player_type *creature_ptr)
2349 {
2350         msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
2351         take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
2352         (void)set_stun(creature_ptr, creature_ptr->stun + 75);
2353         (void)set_cut(creature_ptr,creature_ptr->cut + 5000);
2354         return TRUE;
2355 }
2356
2357
2358 void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
2359 {
2360         monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
2361         grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
2362         BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
2363         int count = 0;
2364         bool is_first_loop = TRUE;
2365         while (is_first_loop || one_in_(5))
2366         {
2367                 is_first_loop = FALSE;
2368                 switch (randint1(28))
2369                 {
2370                 case 1: case 2:
2371                         if (!count)
2372                         {
2373                                 msg_print(_("地面が揺れた...", "The ground trembles..."));
2374                                 earthquake(caster_ptr, m_ptr->fy, m_ptr->fx, 4 + randint0(4), 0);
2375                                 if (!one_in_(6)) break;
2376                         }
2377                         /* Fall through */
2378                 case 3: case 4: case 5: case 6:
2379                         if (!count)
2380                         {
2381                                 int extra_dam = damroll(10, 10);
2382                                 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
2383
2384                                 project(caster_ptr, 0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
2385                                 if (!one_in_(6)) break;
2386                         }
2387                         /* Fall through */
2388                 case 7: case 8:
2389                         if (!count)
2390                         {
2391                                 msg_print(_("空間が歪んだ!", "Space warps about you!"));
2392
2393                                 if (m_ptr->r_idx) teleport_away(caster_ptr, g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
2394                                 if (one_in_(13)) count += activate_hi_summon(caster_ptr, m_ptr->fy, m_ptr->fx, TRUE);
2395                                 if (!one_in_(6)) break;
2396                         }
2397                         /* Fall through */
2398                 case 9: case 10: case 11:
2399                         msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
2400                         project(caster_ptr, 0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
2401                         if (!one_in_(6)) break;
2402                         /* Fall through */
2403                 case 12: case 13: case 14: case 15: case 16:
2404                         aggravate_monsters(caster_ptr, 0);
2405                         if (!one_in_(6)) break;
2406                         /* Fall through */
2407                 case 17: case 18:
2408                         count += activate_hi_summon(caster_ptr, m_ptr->fy, m_ptr->fx, TRUE);
2409                         if (!one_in_(6)) break;
2410                         /* Fall through */
2411                 case 19: case 20: case 21: case 22:
2412                 {
2413                         bool pet = !one_in_(3);
2414                         BIT_FLAGS mode = PM_ALLOW_GROUP;
2415
2416                         if (pet) mode |= PM_FORCE_PET;
2417                         else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
2418
2419                         count += summon_specific(caster_ptr, (pet ? -1 : 0), caster_ptr->y, caster_ptr->x, (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : caster_ptr->current_floor_ptr->dun_level), 0, mode);
2420                         if (!one_in_(6)) break;
2421                 }
2422                         /* Fall through */
2423                 case 23: case 24: case 25:
2424                         if (caster_ptr->hold_exp && (randint0(100) < 75)) break;
2425                         msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
2426
2427                         if (caster_ptr->hold_exp) lose_exp(caster_ptr, caster_ptr->exp / 160);
2428                         else lose_exp(caster_ptr, caster_ptr->exp / 16);
2429                         if (!one_in_(6)) break;
2430                         /* Fall through */
2431                 case 26: case 27: case 28:
2432                 {
2433                         if (one_in_(13))
2434                         {
2435                                 for (int i = 0; i < A_MAX; i++)
2436                                 {
2437                                         bool is_first_dec_stat = TRUE;
2438                                         while (is_first_dec_stat || one_in_(2))
2439                                         {
2440                                                 (void)do_dec_stat(caster_ptr, i);
2441                                         }
2442                                 }
2443                         }
2444                         else
2445                         {
2446                                 (void)do_dec_stat(caster_ptr, randint0(6));
2447                         }
2448
2449                         break;
2450                 }
2451                 }
2452         }
2453 }
2454
2455
2456 /*!
2457  * @brief クリムゾンを発射する / Fire Crimson, evoluting gun.
2458  @ @param shooter_ptr 射撃を行うクリーチャー参照
2459  * @return キャンセルした場合 false.
2460  * @details
2461  * Need to analyze size of the window.
2462  * Need more color coding.
2463  */
2464 bool fire_crimson(player_type *shooter_ptr)
2465 {
2466         DIRECTION dir;
2467         if (!get_aim_dir(shooter_ptr, &dir)) return FALSE;
2468
2469         POSITION tx = shooter_ptr->x + 99 * ddx[dir];
2470         POSITION ty = shooter_ptr->y + 99 * ddy[dir];
2471         if ((dir == 5) && target_okay(shooter_ptr))
2472         {
2473                 tx = target_col;
2474                 ty = target_row;
2475         }
2476
2477         int num = 1;
2478         if (shooter_ptr->pclass == CLASS_ARCHER)
2479         {
2480                 if (shooter_ptr->lev >= 10) num++;
2481                 if (shooter_ptr->lev >= 30) num++;
2482                 if (shooter_ptr->lev >= 45) num++;
2483         }
2484
2485         BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
2486         for (int i = 0; i < num; i++)
2487                 project(shooter_ptr, 0, shooter_ptr->lev / 20 + 1, ty, tx, shooter_ptr->lev*shooter_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
2488
2489         return TRUE;
2490 }
2491
2492
2493 /*!
2494  * @brief 町間のテレポートを行うメインルーチン
2495  * @param caster_ptr プレーヤーへの参照ポインタ
2496  * @return テレポート処理を決定したか否か
2497  */
2498 bool tele_town(player_type *caster_ptr)
2499 {
2500         if (caster_ptr->current_floor_ptr->dun_level)
2501         {
2502                 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
2503                 return FALSE;
2504         }
2505
2506         if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out)
2507         {
2508                 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
2509                 return FALSE;
2510         }
2511
2512         screen_save();
2513         clear_bldg(4, 10);
2514
2515         int i;
2516         int num = 0;
2517         for (i = 1; i < max_towns; i++)
2518         {
2519                 char buf[80];
2520
2521                 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == caster_ptr->town_num) || !(caster_ptr->visit & (1L << (i - 1)))) continue;
2522
2523                 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
2524                 prt(buf, 5 + i, 5);
2525                 num++;
2526         }
2527
2528         if (num == 0)
2529         {
2530                 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
2531                 msg_print(NULL);
2532                 screen_load();
2533                 return FALSE;
2534         }
2535
2536         prt(_("どこに行きますか:", "Where do you want to go: "), 0, 0);
2537         while (TRUE)
2538         {
2539                 i = inkey();
2540
2541                 if (i == ESCAPE)
2542                 {
2543                         screen_load();
2544                         return FALSE;
2545                 }
2546
2547                 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
2548                 else if (((i - 'a' + 1) == caster_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(caster_ptr->visit & (1L << (i - 'a')))) continue;
2549                 break;
2550         }
2551
2552         for (POSITION y = 0; y < current_world_ptr->max_wild_y; y++)
2553         {
2554                 for (POSITION x = 0; x < current_world_ptr->max_wild_x; x++)
2555                 {
2556                         if (wilderness[y][x].town == (i - 'a' + 1))
2557                         {
2558                                 caster_ptr->wilderness_y = y;
2559                                 caster_ptr->wilderness_x = x;
2560                         }
2561                 }
2562         }
2563
2564         caster_ptr->leaving = TRUE;
2565         caster_ptr->leave_bldg = TRUE;
2566         caster_ptr->teleport_town = TRUE;
2567         screen_load();
2568         return TRUE;
2569 }
2570
2571
2572 static bool update_player(player_type *caster_ptr)
2573 {
2574         caster_ptr->update |= PU_COMBINE | PU_REORDER;
2575         caster_ptr->window |= PW_INVEN;
2576         return TRUE;
2577 }
2578
2579
2580 static bool redraw_player(player_type *caster_ptr)
2581 {
2582         if (caster_ptr->csp > caster_ptr->msp)
2583         {
2584                 caster_ptr->csp = caster_ptr->msp;
2585         }
2586
2587         caster_ptr->redraw |= PR_MANA;
2588         caster_ptr->update |= PU_COMBINE | PU_REORDER;
2589         caster_ptr->window |= PW_INVEN;
2590         return TRUE;
2591 }