OSDN Git Service

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