OSDN Git Service

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