OSDN Git Service

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