OSDN Git Service

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