OSDN Git Service

74c08ea6420af5623171997013cb88f1aac95c31
[hengband/hengband.git] / src / cmd-item.c
1 /*!
2  *  @file cmd3.c
3  *  @brief プレイヤーのアイテムに関するコマンドの実装1 / Inventory commands
4  *  @date 2014/01/02
5  *  @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  */
12
13
14 #include "angband.h"
15 #include "util.h"
16 #include "autopick.h"
17 #include "term.h"
18
19 #include "selfinfo.h"
20 #include "cmd-activate.h"
21 #include "cmd-eat.h"
22 #include "cmd-quaff.h"
23 #include "cmd-read.h"
24 #include "cmd-usestaff.h"
25 #include "cmd-zaprod.h"
26 #include "cmd-zapwand.h"
27 #include "cmd-pet.h"
28 #include "cmd-basic.h"
29
30 #include "object-flavor.h"
31 #include "object-hook.h"
32 #include "sort.h"
33 #include "quest.h"
34 #include "artifact.h"
35 #include "avatar.h"
36 #include "player-status.h"
37 #include "player-effects.h"
38 #include "monster.h"
39 #include "view-mainwindow.h"
40 #include "spells.h"
41 #include "objectkind.h"
42 #include "autopick.h"
43 #include "targeting.h"
44
45 /*!
46  * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display p_ptr->inventory_list
47  * @return なし 
48  */
49 void do_cmd_inven(void)
50 {
51         char out_val[160];
52
53         /* Note that we are in "p_ptr->inventory_list" mode */
54         command_wrk = FALSE;
55
56         /* Note that we are in "p_ptr->inventory_list" mode */
57         if (easy_floor) command_wrk = (USE_INVEN);
58         screen_save();
59
60         /* Display the p_ptr->inventory_list */
61         (void)show_inven(0, USE_FULL);
62
63 #ifdef JP
64         sprintf(out_val, "持ち物: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
65                 (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
66                 (long int)((p_ptr->total_weight * 100) / weight_limit()));
67 #else
68         sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
69                 (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
70                 (p_ptr->total_weight * 100) / weight_limit());
71 #endif
72
73         prt(out_val, 0, 0);
74         command_new = inkey();
75         screen_load();
76
77         /* Process "Escape" */
78         if (command_new == ESCAPE)
79         {
80                 TERM_LEN wid, hgt;
81
82                 Term_get_size(&wid, &hgt);
83
84                 /* Reset stuff */
85                 command_new = 0;
86                 command_gap = wid - 30;
87         }
88
89         /* Process normal keys */
90         else
91         {
92                 /* Hack -- Use "display" mode */
93                 command_see = TRUE;
94         }
95 }
96
97
98 /*!
99  * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment
100  * @return なし 
101  */
102 void do_cmd_equip(void)
103 {
104         char out_val[160];
105
106         /* Note that we are in "equipment" mode */
107         command_wrk = TRUE;
108
109         /* Note that we are in "equipment" mode */
110         if (easy_floor) command_wrk = (USE_EQUIP);
111         screen_save();
112
113         (void)show_equip(0, USE_FULL);
114
115         /* Build a prompt */
116 #ifdef JP
117         sprintf(out_val, "装備: 合計 %3d.%1d kg (限界の%ld%%) コマンド: ",
118             (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) ,
119             (long int)((p_ptr->total_weight * 100) / weight_limit()));
120 #else
121         sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
122             (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
123             (long int)((p_ptr->total_weight * 100) / weight_limit()));
124 #endif
125
126         prt(out_val, 0, 0);
127         command_new = inkey();
128         screen_load();
129
130         /* Process "Escape" */
131         if (command_new == ESCAPE)
132         {
133                 TERM_LEN wid, hgt;
134
135                 Term_get_size(&wid, &hgt);
136
137                 /* Reset stuff */
138                 command_new = 0;
139                 command_gap = wid - 30;
140         }
141
142         /* Process normal keys */
143         else
144         {
145                 /* Enter "display" mode */
146                 command_see = TRUE;
147         }
148 }
149
150
151
152
153 bool select_ring_slot = FALSE;
154
155 /*!
156  * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
157  * @return なし 
158  */
159 void do_cmd_wield(void)
160 {
161         OBJECT_IDX item, slot;
162         object_type forge;
163         object_type *q_ptr;
164         object_type *o_ptr;
165
166         concptr act;
167         concptr q, s;
168
169         GAME_TEXT o_name[MAX_NLEN];
170
171
172         OBJECT_IDX need_switch_wielding = 0;
173
174         if (p_ptr->special_defense & KATA_MUSOU)
175         {
176                 set_action(ACTION_NONE);
177         }
178
179         /* Restrict the choices */
180         item_tester_hook = item_tester_hook_wear;
181
182         q = _("どれを装備しますか? ", "Wear/Wield which item? ");
183         s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
184
185         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
186         if (!o_ptr) return;
187
188         /* Check the slot */
189         slot = wield_slot(o_ptr);
190
191         switch (o_ptr->tval)
192         {
193         /* Shields and some misc. items */
194         case TV_CAPTURE:
195         case TV_SHIELD:
196         case TV_CARD:
197                 /* Dual wielding */
198                 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
199                 {
200                         /* Restrict the choices */
201                         item_tester_hook = item_tester_hook_melee_weapon;
202
203                         /* Choose a weapon from the equipment only */
204                         q = _("どちらの武器と取り替えますか?", "Replace which weapon? ");
205                         s = _("おっと。", "Oops.");
206                         if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
207                         if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
208                 }
209
210                 else if (has_melee_weapon(INVEN_LARM)) slot = INVEN_RARM;
211
212                 /* Both arms are already used by non-weapon */
213                 else if (p_ptr->inventory_list[INVEN_RARM].k_idx && !object_is_melee_weapon(&p_ptr->inventory_list[INVEN_RARM]) &&
214                          p_ptr->inventory_list[INVEN_LARM].k_idx && !object_is_melee_weapon(&p_ptr->inventory_list[INVEN_LARM]))
215                 {
216                         /* Restrict the choices */
217                         item_tester_hook = item_tester_hook_mochikae;
218
219                         /* Choose a hand */
220                         q = _("どちらの手に装備しますか?", "Equip which hand? ");
221                         s = _("おっと。", "Oops.");
222                         if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
223                 }
224                 break;
225
226         /* Melee weapons */
227         case TV_DIGGING:
228         case TV_HAFTED:
229         case TV_POLEARM:
230         case TV_SWORD:
231                 /* Asking for dual wielding */
232                 if (slot == INVEN_LARM)
233                 {
234                         if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_RARM;
235                 }
236
237                 else if (!p_ptr->inventory_list[INVEN_RARM].k_idx && has_melee_weapon(INVEN_LARM))
238                 {
239                         if (!get_check(_("二刀流で戦いますか?", "Dual wielding? "))) slot = INVEN_LARM;
240                 }
241
242                 /* Both arms are already used */
243                 else if (p_ptr->inventory_list[INVEN_LARM].k_idx && p_ptr->inventory_list[INVEN_RARM].k_idx)
244                 {
245                         /* Restrict the choices */
246                         item_tester_hook = item_tester_hook_mochikae;
247
248                         /* Choose a hand */
249                         q = _("どちらの手に装備しますか?", "Equip which hand? ");
250                         s = _("おっと。", "Oops.");
251                         
252                         if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
253                         if ((slot == INVEN_LARM) && !has_melee_weapon(INVEN_RARM))
254                                 need_switch_wielding = INVEN_RARM;
255                 }
256                 break;
257
258         /* Rings */
259         case TV_RING:
260                 /* Choose a ring slot */
261                 if (p_ptr->inventory_list[INVEN_LEFT].k_idx && p_ptr->inventory_list[INVEN_RIGHT].k_idx)
262                 {
263                         q = _("どちらの指輪と取り替えますか?", "Replace which ring? ");
264                 }
265                 else
266                 {
267                         q = _("どちらの手に装備しますか?", "Equip which hand? ");
268                 }
269                 s = _("おっと。", "Oops.");
270
271                 /* Restrict the choices */
272                 select_ring_slot = TRUE;
273
274                 if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
275                 {
276                         select_ring_slot = FALSE;
277                         return;
278                 }
279                 select_ring_slot = FALSE;
280                 break;
281         }
282
283         /* Prevent wielding into a cursed slot */
284         if (object_is_cursed(&p_ptr->inventory_list[slot]))
285         {
286                 object_desc(o_name, &p_ptr->inventory_list[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
287
288 #ifdef JP
289                 msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name );
290 #else
291                 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot));
292 #endif
293
294                 /* Cancel the command */
295                 return;
296         }
297
298         if (confirm_wear &&
299                 ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
300                 ((o_ptr->ident & IDENT_SENSE) &&
301                         (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
302         {
303                 char dummy[MAX_NLEN+80];
304
305                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
306                 sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name);
307
308                 if (!get_check(dummy)) return;
309         }
310
311         if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
312         {
313                 char dummy[MAX_NLEN+100];
314
315                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
316
317                 sprintf(dummy, _("%sを装備すると吸血鬼になります。よろしいですか?",
318                         "%s will transforms you into a vampire permanently when equiped. Do you become a vampire?"), o_name);
319
320                 if (!get_check(dummy)) return;
321         }
322
323         if (need_switch_wielding && !object_is_cursed(&p_ptr->inventory_list[need_switch_wielding]))
324         {
325                 object_type *slot_o_ptr = &p_ptr->inventory_list[slot];
326                 object_type *switch_o_ptr = &p_ptr->inventory_list[need_switch_wielding];
327                 object_type object_tmp;
328                 object_type *otmp_ptr = &object_tmp;
329                 GAME_TEXT switch_name[MAX_NLEN];
330
331                 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
332
333                 object_copy(otmp_ptr, switch_o_ptr);
334                 object_copy(switch_o_ptr, slot_o_ptr);
335                 object_copy(slot_o_ptr, otmp_ptr);
336                 
337                 msg_format(_("%sを%sに構えなおした。", "You wield %s at %s hand."), switch_name, 
338                                         (slot == INVEN_RARM) ? (left_hander ? _("左手", "left") : _("右手", "right")) : 
339                                                                                    (left_hander ? _("右手", "right") : _("左手", "left")));
340                 slot = need_switch_wielding;
341         }
342
343         check_find_art_quest_completion(o_ptr);
344
345         if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
346         {
347                 identify_item(o_ptr);
348
349                 /* Auto-inscription */
350                 autopick_alter_item(item, FALSE);
351         }
352
353         take_turn(p_ptr, 100);
354         q_ptr = &forge;
355
356         /* Obtain local object */
357         object_copy(q_ptr, o_ptr);
358
359         /* Modify quantity */
360         q_ptr->number = 1;
361
362         /* Decrease the item (from the pack) */
363         if (item >= 0)
364         {
365                 inven_item_increase(item, -1);
366                 inven_item_optimize(item);
367         }
368
369         /* Decrease the item (from the floor) */
370         else
371         {
372                 floor_item_increase(0 - item, -1);
373                 floor_item_optimize(0 - item);
374         }
375
376         /* Access the wield slot */
377         o_ptr = &p_ptr->inventory_list[slot];
378
379         /* Take off existing item */
380         if (o_ptr->k_idx)
381         {
382                 /* Take off existing item */
383                 (void)inven_takeoff(slot, 255);
384         }
385
386         /* Wear the new stuff */
387         object_copy(o_ptr, q_ptr);
388
389         o_ptr->marked |= OM_TOUCHED;
390
391         p_ptr->total_weight += q_ptr->weight;
392
393         /* Increment the equip counter by hand */
394         p_ptr->equip_cnt++;
395
396 #define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
397 #define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
398 #define STR_WIELD_ARMS _("%s(%c)を両手で構えた。", "You are wielding %s (%c) with both hands.")
399
400         /* Where is the item now */
401         switch (slot)
402         {
403         case INVEN_RARM:
404                 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
405                         act = STR_WIELD_ARMS;
406                 else
407                         act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
408                 break;
409
410         case INVEN_LARM:
411                 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
412                         act = STR_WIELD_ARMS;
413                 else
414                         act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
415                 break;
416
417         case INVEN_BOW:
418                 act = _("%s(%c)を射撃用に装備した。", "You are shooting with %s (%c).");
419                 break;
420
421         case INVEN_LITE:
422                 act = _("%s(%c)を光源にした。", "Your light source is %s (%c).");
423                 break;
424
425         default:
426                 act = _("%s(%c)を装備した。", "You are wearing %s (%c).");
427                 break;
428         }
429
430         object_desc(o_name, o_ptr, 0);
431         msg_format(act, o_name, index_to_label(slot));
432
433         /* Cursed! */
434         if (object_is_cursed(o_ptr))
435         {
436                 msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
437                 chg_virtue(V_HARMONY, -1);
438
439                 /* Note the curse */
440                 o_ptr->ident |= (IDENT_SENSE);
441         }
442
443         /* The Stone Mask make the player current_world_ptr->game_turn into a vampire! */
444         if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
445         {
446                 /* Turn into a vampire */
447                 change_race(RACE_VAMPIRE, "");
448         }
449
450         p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
451         p_ptr->redraw |= (PR_EQUIPPY);
452         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
453
454         calc_android_exp();
455 }
456
457 /*!
458  * @brief 持ち替え処理
459  * @param item 持ち替えを行いたい装備部位ID
460  * @return なし
461  */
462 void kamaenaoshi(INVENTORY_IDX item)
463 {
464         object_type *o_ptr, *new_o_ptr;
465         GAME_TEXT o_name[MAX_NLEN];
466
467         if (item == INVEN_RARM)
468         {
469                 if (has_melee_weapon(INVEN_LARM))
470                 {
471                         o_ptr = &p_ptr->inventory_list[INVEN_LARM];
472                         object_desc(o_name, o_ptr, 0);
473
474                         if (!object_is_cursed(o_ptr))
475                         {
476                                 new_o_ptr = &p_ptr->inventory_list[INVEN_RARM];
477                                 object_copy(new_o_ptr, o_ptr);
478                                 p_ptr->total_weight += o_ptr->weight;
479                                 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
480                                 inven_item_optimize(INVEN_LARM);
481                                 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
482                                         msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
483                                 else
484                                         msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name, 
485                                                 (left_hander ? _("左手", "left") : _("右手", "right")));
486                         }
487                         else
488                         {
489                                 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
490                                         msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
491                         }
492                 }
493         }
494         else if (item == INVEN_LARM)
495         {
496                 o_ptr = &p_ptr->inventory_list[INVEN_RARM];
497                 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
498
499                 if (has_melee_weapon(INVEN_RARM))
500                 {
501                         if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
502                                 msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name);
503                 }
504                 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
505                 {
506                         new_o_ptr = &p_ptr->inventory_list[INVEN_LARM];
507                         object_copy(new_o_ptr, o_ptr);
508                         p_ptr->total_weight += o_ptr->weight;
509                         inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
510                         inven_item_optimize(INVEN_RARM);
511                         msg_format(_("%sを持ち替えた。", "You switched hand of %s."), o_name);
512                 }
513         }
514 }
515
516
517 /*!
518  * @brief 装備を外すコマンドのメインルーチン / Take off an item
519  * @return なし
520  */
521 void do_cmd_takeoff(void)
522 {
523         OBJECT_IDX item;
524         object_type *o_ptr;
525         concptr q, s;
526
527         if (p_ptr->special_defense & KATA_MUSOU)
528         {
529                 set_action(ACTION_NONE);
530         }
531
532         q = _("どれを装備からはずしますか? ", "Take off which item? ");
533         s = _("はずせる装備がない。", "You are not wearing anything to take off.");
534
535         o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
536         if (!o_ptr) return;
537
538         /* Item is cursed */
539         if (object_is_cursed(o_ptr))
540         {
541                 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
542                 {
543                         msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
544
545                         return;
546                 }
547
548                 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
549                 {
550                         msg_print(_("呪われた装備を力づくで剥がした!", "You teared a cursed equipment off by sheer strength!"));
551
552                         o_ptr->ident |= (IDENT_SENSE);
553                         o_ptr->curse_flags = 0L;
554                         o_ptr->feeling = FEEL_NONE;
555
556                         p_ptr->update |= (PU_BONUS);
557                         p_ptr->window |= (PW_EQUIP);
558
559                         msg_print(_("呪いを打ち破った。", "You break the curse."));
560                 }
561                 else
562                 {
563                         msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
564                         take_turn(p_ptr, 50);
565                         return;
566                 }
567         }
568
569         take_turn(p_ptr, 50);
570
571         /* Take off the item */
572         (void)inven_takeoff(item, 255);
573         kamaenaoshi(item);
574         calc_android_exp();
575         p_ptr->redraw |= (PR_EQUIPPY);
576 }
577
578
579 /*!
580  * @brief アイテムを落とすコマンドのメインルーチン / Drop an item
581  * @return なし
582  */
583 void do_cmd_drop(void)
584 {
585         OBJECT_IDX item;
586         int amt = 1;
587
588         object_type *o_ptr;
589
590         concptr q, s;
591
592         if (p_ptr->special_defense & KATA_MUSOU)
593         {
594                 set_action(ACTION_NONE);
595         }
596
597         q = _("どのアイテムを落としますか? ", "Drop which item? ");
598         s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
599
600         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
601         if (!o_ptr) return;
602
603         /* Hack -- Cannot remove cursed items */
604         if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
605         {
606                 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
607                 return;
608         }
609
610         if (o_ptr->number > 1)
611         {
612                 amt = get_quantity(NULL, o_ptr->number);
613                 if (amt <= 0) return;
614         }
615
616         take_turn(p_ptr, 50);
617
618         /* Drop (some of) the item */
619         inven_drop(item, amt);
620
621         if (item >= INVEN_RARM)
622         {
623                 kamaenaoshi(item);
624                 calc_android_exp();
625         }
626
627         p_ptr->redraw |= (PR_EQUIPPY);
628 }
629
630
631 /*!
632  * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
633  * @return なし
634  */
635 void do_cmd_destroy(void)
636 {
637         OBJECT_IDX item;
638         QUANTITY amt = 1;
639         QUANTITY old_number;
640
641         bool force = FALSE;
642
643         object_type *o_ptr;
644         object_type forge;
645         object_type *q_ptr = &forge;
646
647         GAME_TEXT o_name[MAX_NLEN];
648         char out_val[MAX_NLEN+40];
649
650         concptr q, s;
651
652         if (p_ptr->special_defense & KATA_MUSOU)
653         {
654                 set_action(ACTION_NONE);
655         }
656
657         /* Hack -- force destruction */
658         if (command_arg > 0) force = TRUE;
659
660         q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
661         s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
662
663         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
664         if (!o_ptr) return;
665
666         /* Verify unless quantity given beforehand */
667         if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
668         {
669                 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
670
671                 /* Make a verification */
672                 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
673                 msg_print(NULL);
674
675                 /* HACK : Add the line to message buffer */
676                 message_add(out_val);
677                 p_ptr->window |= (PW_MESSAGE);
678                 handle_stuff();
679
680                 /* Get an acceptable answer */
681                 while (TRUE)
682                 {
683                         char i;
684
685                         /* Prompt */
686                         prt(out_val, 0, 0);
687
688                         i = inkey();
689
690                         /* Erase the prompt */
691                         prt("", 0, 0);
692
693
694                         if (i == 'y' || i == 'Y')
695                         {
696                                 break;
697                         }
698                         if (i == ESCAPE || i == 'n' || i == 'N')
699                         {
700                                 /* Cancel */
701                                 return;
702                         }
703                         if (i == 'A')
704                         {
705                                 /* Add an auto-destroy preference line */
706                                 if (autopick_autoregister(o_ptr))
707                                 {
708                                         /* Auto-destroy it */
709                                         autopick_alter_item(item, TRUE);
710                                 }
711
712                                 /* The object is already destroyed. */
713                                 return;
714                         }
715                 } /* while (TRUE) */
716         }
717
718         if (o_ptr->number > 1)
719         {
720                 amt = get_quantity(NULL, o_ptr->number);
721                 if (amt <= 0) return;
722         }
723
724
725         old_number = o_ptr->number;
726         o_ptr->number = amt;
727         object_desc(o_name, o_ptr, 0);
728         o_ptr->number = old_number;
729
730         take_turn(p_ptr, 100);
731
732         /* Artifacts cannot be destroyed */
733         if (!can_player_destroy_object(o_ptr))
734         {
735                 free_turn(p_ptr);
736
737                 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
738                 return;
739         }
740
741         object_copy(q_ptr, o_ptr);
742
743         msg_format(_("%sを壊した。", "You destroy %s."), o_name);
744         sound(SOUND_DESTITEM);
745
746         /* Reduce the charges of rods/wands */
747         reduce_charges(o_ptr, amt);
748
749         /* Eliminate the item (from the pack) */
750         if (item >= 0)
751         {
752                 inven_item_increase(item, -amt);
753                 inven_item_describe(item);
754                 inven_item_optimize(item);
755         }
756
757         /* Eliminate the item (from the floor) */
758         else
759         {
760                 floor_item_increase(0 - item, -amt);
761                 floor_item_describe(0 - item);
762                 floor_item_optimize(0 - item);
763         }
764
765         if (item_tester_high_level_book(q_ptr))
766         {
767                 bool gain_expr = FALSE;
768
769                 if (p_ptr->prace == RACE_ANDROID)
770                 {
771                 }
772                 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
773                 {
774                         gain_expr = TRUE;
775                 }
776                 else if (p_ptr->pclass == CLASS_PALADIN)
777                 {
778                         if (is_good_realm(p_ptr->realm1))
779                         {
780                                 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
781                         }
782                         else
783                         {
784                                 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
785                         }
786                 }
787
788                 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
789                 {
790                         s32b tester_exp = p_ptr->max_exp / 20;
791                         if (tester_exp > 10000) tester_exp = 10000;
792                         if (q_ptr->sval < 3) tester_exp /= 4;
793                         if (tester_exp<1) tester_exp = 1;
794
795                         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
796                         gain_exp(tester_exp * amt);
797                 }
798                 if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
799                 {
800                         chg_virtue(V_UNLIFE, 1);
801                         chg_virtue(V_VITALITY, -1);
802                 }
803                 else if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
804                 {
805                         chg_virtue(V_UNLIFE, -1);
806                         chg_virtue(V_VITALITY, 1);
807                 }
808         
809                 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
810                         chg_virtue(V_ENCHANT, -1);
811         
812                 if (object_value_real(q_ptr) > 30000)
813                         chg_virtue(V_SACRIFICE, 2);
814         
815                 else if (object_value_real(q_ptr) > 10000)
816                         chg_virtue(V_SACRIFICE, 1);
817         }
818
819         if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
820                 chg_virtue(V_HARMONY, 1);
821
822         if (item >= INVEN_RARM) calc_android_exp();
823 }
824
825
826 /*!
827  * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
828  * @return なし
829  */
830 void do_cmd_observe(void)
831 {
832         OBJECT_IDX item;
833         object_type *o_ptr;
834         GAME_TEXT o_name[MAX_NLEN];
835         concptr q, s;
836
837         q = _("どのアイテムを調べますか? ", "Examine which item? ");
838         s = _("調べられるアイテムがない。", "You have nothing to examine.");
839
840         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
841         if (!o_ptr) return;
842
843         /* Require full knowledge */
844         if (!(o_ptr->ident & IDENT_MENTAL))
845         {
846                 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
847                 return;
848         }
849
850         object_desc(o_name, o_ptr, 0);
851         msg_format(_("%sを調べている...", "Examining %s..."), o_name);
852         if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
853 }
854
855
856
857 /*!
858  * @brief アイテムの銘を消すコマンドのメインルーチン
859  * Remove the inscription from an object XXX Mention item (when done)?
860  * @return なし
861  */
862 void do_cmd_uninscribe(void)
863 {
864         OBJECT_IDX item;
865         object_type *o_ptr;
866         concptr q, s;
867
868         q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
869         s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
870
871         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
872         if (!o_ptr) return;
873
874         /* Nothing to remove */
875         if (!o_ptr->inscription)
876         {
877                 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
878                 return;
879         }
880
881         msg_print(_("銘を消した。", "Inscription removed."));
882
883         /* Remove the incription */
884         o_ptr->inscription = 0;
885         p_ptr->update |= (PU_COMBINE);
886         p_ptr->window |= (PW_INVEN | PW_EQUIP);
887
888         /* .や$の関係で, 再計算が必要なはず -- henkma */
889         p_ptr->update |= (PU_BONUS);
890
891 }
892
893
894 /*!
895  * @brief アイテムの銘を刻むコマンドのメインルーチン
896  * Inscribe an object with a comment
897  * @return なし
898  */
899 void do_cmd_inscribe(void)
900 {
901         OBJECT_IDX item;
902         object_type *o_ptr;
903         GAME_TEXT o_name[MAX_NLEN];
904         char out_val[80];
905         concptr q, s;
906
907         q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
908         s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
909
910         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
911         if (!o_ptr) return;
912
913         /* Describe the activity */
914         object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
915
916         msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
917         msg_print(NULL);
918
919         /* Start with nothing */
920         strcpy(out_val, "");
921
922         /* Use old inscription */
923         if (o_ptr->inscription)
924         {
925                 /* Start with the old inscription */
926                 strcpy(out_val, quark_str(o_ptr->inscription));
927         }
928
929         /* Get a new inscription (possibly empty) */
930         if (get_string(_("銘: ", "Inscription: "), out_val, 80))
931         {
932                 /* Save the inscription */
933                 o_ptr->inscription = quark_add(out_val);
934                 p_ptr->update |= (PU_COMBINE);
935                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
936
937                 /* .や$の関係で, 再計算が必要なはず -- henkma */
938                 p_ptr->update |= (PU_BONUS);
939         }
940 }
941
942
943 /*!
944  * @brief ランタンに燃料を加えるコマンドのメインルーチン
945  * Refill the players lamp (from the pack or floor)
946  * @return なし
947  */
948 static void do_cmd_refill_lamp(void)
949 {
950         OBJECT_IDX item;
951         object_type *o_ptr;
952         object_type *j_ptr;
953         concptr q, s;
954
955         /* Restrict the choices */
956         item_tester_hook = item_tester_refill_lantern;
957
958         q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
959         s = _("油つぼがない。", "You have no flasks of oil.");
960
961         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
962         if (!o_ptr) return;
963
964         take_turn(p_ptr, 50);
965
966         /* Access the lantern */
967         j_ptr = &p_ptr->inventory_list[INVEN_LITE];
968
969         /* Refuel */
970         j_ptr->xtra4 += o_ptr->xtra4;
971         msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
972
973         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
974         {
975                 j_ptr->xtra4 = 0;
976                 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
977         }
978         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
979         {
980                 j_ptr->xtra4 = 0;
981                 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
982         }
983         else if (j_ptr->xtra4 >= FUEL_LAMP)
984         {
985                 j_ptr->xtra4 = FUEL_LAMP;
986                 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
987         }
988
989         /* Decrease the item (from the pack) */
990         if (item >= 0)
991         {
992                 inven_item_increase(item, -1);
993                 inven_item_describe(item);
994                 inven_item_optimize(item);
995         }
996
997         /* Decrease the item (from the floor) */
998         else
999         {
1000                 floor_item_increase(0 - item, -1);
1001                 floor_item_describe(0 - item);
1002                 floor_item_optimize(0 - item);
1003         }
1004
1005         p_ptr->update |= (PU_TORCH);
1006 }
1007
1008 /*!
1009  * @brief 松明を束ねるコマンドのメインルーチン
1010  * Refuel the players torch (from the pack or floor)
1011  * @return なし
1012  */
1013 static void do_cmd_refill_torch(void)
1014 {
1015         OBJECT_IDX item;
1016
1017         object_type *o_ptr;
1018         object_type *j_ptr;
1019
1020         concptr q, s;
1021
1022         /* Restrict the choices */
1023         item_tester_hook = object_can_refill_torch;
1024
1025         q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1026         s = _("他に松明がない。", "You have no extra torches.");
1027
1028         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1029         if (!o_ptr) return;
1030
1031         take_turn(p_ptr, 50);
1032
1033         /* Access the primary torch */
1034         j_ptr = &p_ptr->inventory_list[INVEN_LITE];
1035
1036         /* Refuel */
1037         j_ptr->xtra4 += o_ptr->xtra4 + 5;
1038
1039         msg_print(_("松明を結合した。", "You combine the torches."));
1040
1041         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1042         {
1043                 j_ptr->xtra4 = 0;
1044                 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1045         }
1046         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1047         {
1048                 j_ptr->xtra4 = 0;
1049                 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1050         }
1051         /* Over-fuel message */
1052         else if (j_ptr->xtra4 >= FUEL_TORCH)
1053         {
1054                 j_ptr->xtra4 = FUEL_TORCH;
1055                 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1056         }
1057
1058         /* Refuel message */
1059         else
1060         {
1061                 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1062         }
1063
1064         /* Decrease the item (from the pack) */
1065         if (item >= 0)
1066         {
1067                 inven_item_increase(item, -1);
1068                 inven_item_describe(item);
1069                 inven_item_optimize(item);
1070         }
1071
1072         /* Decrease the item (from the floor) */
1073         else
1074         {
1075                 floor_item_increase(0 - item, -1);
1076                 floor_item_describe(0 - item);
1077                 floor_item_optimize(0 - item);
1078         }
1079
1080         p_ptr->update |= (PU_TORCH);
1081 }
1082
1083
1084 /*!
1085  * @brief 燃料を補充するコマンドのメインルーチン
1086  * Refill the players lamp, or restock his torches
1087  * @return なし
1088  */
1089 void do_cmd_refill(void)
1090 {
1091         object_type *o_ptr;
1092
1093         /* Get the light */
1094         o_ptr = &p_ptr->inventory_list[INVEN_LITE];
1095
1096         if (p_ptr->special_defense & KATA_MUSOU)
1097         {
1098                 set_action(ACTION_NONE);
1099         }
1100
1101         /* It is nothing */
1102         if (o_ptr->tval != TV_LITE)
1103         {
1104                 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1105         }
1106
1107         /* It's a lamp */
1108         else if (o_ptr->sval == SV_LITE_LANTERN)
1109         {
1110                 do_cmd_refill_lamp();
1111         }
1112
1113         /* It's a torch */
1114         else if (o_ptr->sval == SV_LITE_TORCH)
1115         {
1116                 do_cmd_refill_torch();
1117         }
1118
1119         /* No torch to refill */
1120         else
1121         {
1122                 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1123         }
1124 }
1125
1126
1127 /*!
1128  * @brief ターゲットを設定するコマンドのメインルーチン
1129  * Target command
1130  * @return なし
1131  */
1132 void do_cmd_target(void)
1133 {
1134         if (p_ptr->wild_mode) return;
1135
1136         /* Target set */
1137         if (target_set(TARGET_KILL))
1138         {
1139                 msg_print(_("ターゲット決定。", "Target Selected."));
1140         }
1141
1142         /* Target aborted */
1143         else
1144         {
1145                 msg_print(_("ターゲット解除。", "Target Aborted."));
1146         }
1147 }
1148
1149
1150
1151 /*!
1152  * @brief 周囲を見渡すコマンドのメインルーチン
1153  * Look command
1154  * @return なし
1155  */
1156 void do_cmd_look(void)
1157 {
1158         p_ptr->window |= PW_MONSTER_LIST;
1159         handle_stuff();
1160
1161         /* Look around */
1162         if (target_set(TARGET_LOOK))
1163         {
1164                 msg_print(_("ターゲット決定。", "Target Selected."));
1165         }
1166 }
1167
1168
1169 /*!
1170  * @brief 位置を確認するコマンドのメインルーチン
1171  * Allow the player to examine other sectors on the map
1172  * @return なし
1173  */
1174 void do_cmd_locate(void)
1175 {
1176         DIRECTION dir;
1177         POSITION y1, x1, y2, x2;
1178         GAME_TEXT tmp_val[80];
1179         GAME_TEXT out_val[160];
1180         TERM_LEN wid, hgt;
1181
1182         get_screen_size(&wid, &hgt);
1183
1184         /* Start at current panel */
1185         y2 = y1 = panel_row_min;
1186         x2 = x1 = panel_col_min;
1187
1188         /* Show panels until done */
1189         while (1)
1190         {
1191                 /* Describe the location */
1192                 if ((y2 == y1) && (x2 == x1))
1193                 {
1194                         strcpy(tmp_val, _("真上", "\0"));
1195                 }
1196                 else
1197                 {
1198                         sprintf(tmp_val, "%s%s",
1199                                 ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
1200                                 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
1201                 }
1202
1203                 /* Prepare to ask which way to look */
1204                 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", 
1205                                                "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?"),
1206                         y2 / (hgt / 2), y2 % (hgt / 2),
1207                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1208
1209                 /* Assume no direction */
1210                 dir = 0;
1211
1212                 /* Get a direction */
1213                 while (!dir)
1214                 {
1215                         char command;
1216
1217                         /* Get a command (or Cancel) */
1218                         if (!get_com(out_val, &command, TRUE)) break;
1219
1220                         /* Extract the action (if any) */
1221                         dir = get_keymap_dir(command);
1222
1223                         /* Error */
1224                         if (!dir) bell();
1225                 }
1226
1227                 /* No direction */
1228                 if (!dir) break;
1229
1230                 /* Apply the motion */
1231                 if (change_panel(ddy[dir], ddx[dir]))
1232                 {
1233                         y2 = panel_row_min;
1234                         x2 = panel_col_min;
1235                 }
1236         }
1237
1238
1239         /* Recenter the map around the player */
1240         verify_panel();
1241
1242         p_ptr->update |= (PU_MONSTERS);
1243         p_ptr->redraw |= (PR_MAP);
1244         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1245         handle_stuff();
1246 }
1247
1248
1249 /*!
1250  * @brief モンスターの思い出を見るコマンドのメインルーチン
1251  * Identify a character, allow recall of monsters
1252  * @return なし
1253  * @details
1254  * <pre>
1255  * Several "special" responses recall "multiple" monsters:
1256  *   ^A (all monsters)
1257  *   ^U (all unique monsters)
1258  *   ^N (all non-unique monsters)
1259  *
1260  * The responses may be sorted in several ways, see below.
1261  *
1262  * Note that the player ghosts are ignored. 
1263  * </pre>
1264  */
1265 void do_cmd_query_symbol(void)
1266 {
1267         IDX i;
1268         int n;
1269         MONRACE_IDX r_idx;
1270         char sym, query;
1271         char buf[128];
1272
1273         bool all = FALSE;
1274         bool uniq = FALSE;
1275         bool norm = FALSE;
1276         bool ride = FALSE;
1277         char temp[80] = "";
1278
1279         bool recall = FALSE;
1280
1281         u16b why = 0;
1282         MONRACE_IDX *who;
1283
1284         /* Get a character, or abort */
1285         if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", 
1286                                    "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1287
1288         /* Find that character info, and describe it */
1289         for (i = 0; ident_info[i]; ++i)
1290         {
1291                 if (sym == ident_info[i][0]) break;
1292         }
1293         if (sym == KTRL('A'))
1294         {
1295                 all = TRUE;
1296                 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1297         }
1298         else if (sym == KTRL('U'))
1299         {
1300                 all = uniq = TRUE;
1301                 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1302         }
1303         else if (sym == KTRL('N'))
1304         {
1305                 all = norm = TRUE;
1306                 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1307         }
1308         else if (sym == KTRL('R'))
1309         {
1310                 all = ride = TRUE;
1311                 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1312         }
1313         /* XTRA HACK WHATSEARCH */
1314         else if (sym == KTRL('M'))
1315         {
1316                 all = TRUE;
1317                 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1318                 {
1319                         temp[0]=0;
1320                         return;
1321                 }
1322                 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1323         }
1324         else if (ident_info[i])
1325         {
1326                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1327         }
1328         else
1329         {
1330                 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1331         }
1332
1333         /* Display the result */
1334         prt(buf, 0, 0);
1335
1336         /* Allocate the "who" array */
1337         C_MAKE(who, max_r_idx, MONRACE_IDX);
1338
1339         /* Collect matching monsters */
1340         for (n = 0, i = 1; i < max_r_idx; i++)
1341         {
1342                 monster_race *r_ptr = &r_info[i];
1343
1344                 /* Nothing to recall */
1345                 if (!cheat_know && !r_ptr->r_sights) continue;
1346
1347                 /* Require non-unique monsters if needed */
1348                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1349
1350                 /* Require unique monsters if needed */
1351                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1352
1353                 /* Require ridable monsters if needed */
1354                 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1355
1356                 /* XTRA HACK WHATSEARCH */
1357                 if (temp[0])
1358                 {
1359                         TERM_LEN xx;
1360                         char temp2[80];
1361
1362                         for (xx = 0; temp[xx] && xx < 80; xx++)
1363                         {
1364 #ifdef JP
1365                                 if (iskanji(temp[xx])) { xx++; continue; }
1366 #endif
1367                                 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1368                         }
1369
1370 #ifdef JP
1371                         strcpy(temp2, r_name + r_ptr->E_name);
1372 #else
1373                         strcpy(temp2, r_name + r_ptr->name);
1374 #endif
1375                         for (xx = 0; temp2[xx] && xx < 80; xx++)
1376                                 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1377
1378 #ifdef JP
1379                         if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1380 #else
1381                         if (my_strstr(temp2, temp))
1382 #endif
1383                                 who[n++] = i;
1384                 }
1385
1386                 /* Collect "appropriate" monsters */
1387                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1388         }
1389
1390         /* Nothing to recall */
1391         if (!n)
1392         {
1393                 C_KILL(who, max_r_idx, MONRACE_IDX);
1394                 return;
1395         }
1396
1397         /* Prompt */
1398         put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1399
1400         /* Query */
1401         query = inkey();
1402         prt(buf, 0, 0);
1403
1404         why = 2;
1405
1406         /* Sort the array */
1407         ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1408
1409         /* Sort by kills (and level) */
1410         if (query == 'k')
1411         {
1412                 why = 4;
1413                 query = 'y';
1414         }
1415
1416         /* Catch "escape" */
1417         if (query != 'y')
1418         {
1419                 C_KILL(who, max_r_idx, MONRACE_IDX);
1420                 return;
1421         }
1422
1423         /* Sort if needed */
1424         if (why == 4)
1425         {
1426                 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1427         }
1428
1429
1430         /* Start at the end */
1431         i = n - 1;
1432
1433         /* Scan the monster memory */
1434         while (1)
1435         {
1436                 /* Extract a race */
1437                 r_idx = who[i];
1438
1439                 /* Hack -- Auto-recall */
1440                 monster_race_track(r_idx);
1441                 handle_stuff();
1442
1443                 /* Interact */
1444                 while (1)
1445                 {
1446                         /* Recall */
1447                         if (recall)
1448                         {
1449                                 screen_save();
1450
1451                                 /* Recall on screen */
1452                                 screen_roff(who[i], 0);
1453                         }
1454
1455                         /* Hack -- Begin the prompt */
1456                         roff_top(r_idx);
1457
1458                         /* Hack -- Complete the prompt */
1459                         Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1460
1461                         query = inkey();
1462
1463                         /* Unrecall */
1464                         if (recall)
1465                         {
1466                                 screen_load();
1467                         }
1468
1469                         /* Normal commands */
1470                         if (query != 'r') break;
1471
1472                         /* Toggle recall */
1473                         recall = !recall;
1474                 }
1475
1476                 /* Stop scanning */
1477                 if (query == ESCAPE) break;
1478
1479                 /* Move to "prev" monster */
1480                 if (query == '-')
1481                 {
1482                         if (++i == n)
1483                         {
1484                                 i = 0;
1485                                 if (!expand_list) break;
1486                         }
1487                 }
1488
1489                 /* Move to "next" monster */
1490                 else
1491                 {
1492                         if (i-- == 0)
1493                         {
1494                                 i = n - 1;
1495                                 if (!expand_list) break;
1496                         }
1497                 }
1498         }
1499
1500         /* Free the "who" array */
1501         C_KILL(who, max_r_idx, IDX);
1502
1503         /* Re-display the identity */
1504         prt(buf, 0, 0);
1505 }
1506
1507 /*!
1508  * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1509  * Use an item
1510  * @return なし
1511  * @details
1512  * XXX - Add actions for other item types
1513  */
1514 void do_cmd_use(void)
1515 {
1516         OBJECT_IDX item;
1517         object_type *o_ptr;
1518         concptr q, s;
1519
1520         if (p_ptr->wild_mode)
1521         {
1522                 return;
1523         }
1524
1525         if (cmd_limit_arena(p_ptr)) return;
1526
1527         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1528         {
1529                 set_action(ACTION_NONE);
1530         }
1531
1532         item_tester_hook = item_tester_hook_use;
1533
1534         q = _("どれを使いますか?", "Use which item? ");
1535         s = _("使えるものがありません。", "You have nothing to use.");
1536
1537         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1538         if (!o_ptr) return;
1539
1540         switch (o_ptr->tval)
1541         {
1542                 /* Spike a door */
1543                 case TV_SPIKE:
1544                 {
1545                         do_cmd_spike();
1546                         break;
1547                 }
1548
1549                 /* Eat some food */
1550                 case TV_FOOD:
1551                 {
1552                         do_cmd_eat_food_aux(item);
1553                         break;
1554                 }
1555
1556                 /* Aim a wand */
1557                 case TV_WAND:
1558                 {
1559                         do_cmd_aim_wand_aux(item);
1560                         break;
1561                 }
1562
1563                 /* Use a staff */
1564                 case TV_STAFF:
1565                 {
1566                         do_cmd_use_staff_aux(item);
1567                         break;
1568                 }
1569
1570                 /* Zap a rod */
1571                 case TV_ROD:
1572                 {
1573                         do_cmd_zap_rod_aux(item);
1574                         break;
1575                 }
1576
1577                 /* Quaff a potion */
1578                 case TV_POTION:
1579                 {
1580                         do_cmd_quaff_potion_aux(item);
1581                         break;
1582                 }
1583
1584                 /* Read a scroll */
1585                 case TV_SCROLL:
1586                 {
1587                         if (cmd_limit_blind(p_ptr)) return;
1588                         if (cmd_limit_confused(p_ptr)) return;
1589
1590                         do_cmd_read_scroll_aux(item, TRUE);
1591                         break;
1592                 }
1593
1594                 /* Fire ammo */
1595                 case TV_SHOT:
1596                 case TV_ARROW:
1597                 case TV_BOLT:
1598                 {
1599                         exe_fire(item, &p_ptr->inventory_list[INVEN_BOW], SP_NONE);
1600                         break;
1601                 }
1602
1603                 /* Activate an artifact */
1604                 default:
1605                 {
1606                         do_cmd_activate_aux(item);
1607                         break;
1608                 }
1609         }
1610 }
1611