OSDN Git Service

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