OSDN Git Service

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