OSDN Git Service

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