OSDN Git Service

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