OSDN Git Service

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