OSDN Git Service

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