OSDN Git Service

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