OSDN Git Service

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