OSDN Git Service

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