OSDN Git Service

[Refactor] #37353 item_tester_refill_torch() to object_can_refill_torch() in melee1.c.
[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
598         /* See how many items */
599         if (o_ptr->number > 1)
600         {
601                 /* Get a quantity */
602                 amt = get_quantity(NULL, o_ptr->number);
603
604                 /* Allow user abort */
605                 if (amt <= 0) return;
606         }
607
608         p_ptr->energy_use = 50;
609
610         /* Drop (some of) the item */
611         inven_drop(item, amt);
612
613         if (item >= INVEN_RARM)
614         {
615                 kamaenaoshi(item);
616                 calc_android_exp();
617         }
618
619         p_ptr->redraw |= (PR_EQUIPPY);
620 }
621
622
623 /*!
624  * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
625  * @return なし
626  */
627 void do_cmd_destroy(void)
628 {
629         OBJECT_IDX item;
630         QUANTITY amt = 1;
631         QUANTITY old_number;
632
633         bool force = FALSE;
634
635         object_type *o_ptr;
636         object_type forge;
637         object_type *q_ptr = &forge;
638
639         GAME_TEXT o_name[MAX_NLEN];
640         char out_val[MAX_NLEN+40];
641
642         concptr q, s;
643
644         if (p_ptr->special_defense & KATA_MUSOU)
645         {
646                 set_action(ACTION_NONE);
647         }
648
649         /* Hack -- force destruction */
650         if (command_arg > 0) force = TRUE;
651
652         q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
653         s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
654
655         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
656         if (!o_ptr) return;
657
658         /* Verify unless quantity given beforehand */
659         if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
660         {
661                 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
662
663                 /* Make a verification */
664                 sprintf(out_val, _("本当に%sを壊しますか? [y/n/Auto]", "Really destroy %s? [y/n/Auto]"), o_name);
665                 msg_print(NULL);
666
667                 /* HACK : Add the line to message buffer */
668                 message_add(out_val);
669                 p_ptr->window |= (PW_MESSAGE);
670                 handle_stuff();
671
672                 /* Get an acceptable answer */
673                 while (TRUE)
674                 {
675                         char i;
676
677                         /* Prompt */
678                         prt(out_val, 0, 0);
679
680                         i = inkey();
681
682                         /* Erase the prompt */
683                         prt("", 0, 0);
684
685
686                         if (i == 'y' || i == 'Y')
687                         {
688                                 break;
689                         }
690                         if (i == ESCAPE || i == 'n' || i == 'N')
691                         {
692                                 /* Cancel */
693                                 return;
694                         }
695                         if (i == 'A')
696                         {
697                                 /* Add an auto-destroy preference line */
698                                 if (autopick_autoregister(o_ptr))
699                                 {
700                                         /* Auto-destroy it */
701                                         autopick_alter_item(item, TRUE);
702                                 }
703
704                                 /* The object is already destroyed. */
705                                 return;
706                         }
707                 } /* while (TRUE) */
708         }
709
710         /* See how many items */
711         if (o_ptr->number > 1)
712         {
713                 /* Get a quantity */
714                 amt = get_quantity(NULL, o_ptr->number);
715
716                 /* Allow user abort */
717                 if (amt <= 0) return;
718         }
719
720
721         old_number = o_ptr->number;
722         o_ptr->number = amt;
723         object_desc(o_name, o_ptr, 0);
724         o_ptr->number = old_number;
725
726         take_turn(p_ptr, 100);
727
728         /* Artifacts cannot be destroyed */
729         if (!can_player_destroy_object(o_ptr))
730         {
731                 free_turn(p_ptr);
732
733                 msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
734                 return;
735         }
736
737         object_copy(q_ptr, o_ptr);
738
739         msg_format(_("%sを壊した。", "You destroy %s."), o_name);
740         sound(SOUND_DESTITEM);
741
742         /* Reduce the charges of rods/wands */
743         reduce_charges(o_ptr, amt);
744
745         /* Eliminate the item (from the pack) */
746         if (item >= 0)
747         {
748                 inven_item_increase(item, -amt);
749                 inven_item_describe(item);
750                 inven_item_optimize(item);
751         }
752
753         /* Eliminate the item (from the floor) */
754         else
755         {
756                 floor_item_increase(0 - item, -amt);
757                 floor_item_describe(0 - item);
758                 floor_item_optimize(0 - item);
759         }
760
761         if (item_tester_high_level_book(q_ptr))
762         {
763                 bool gain_expr = FALSE;
764
765                 if (p_ptr->prace == RACE_ANDROID)
766                 {
767                 }
768                 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
769                 {
770                         gain_expr = TRUE;
771                 }
772                 else if (p_ptr->pclass == CLASS_PALADIN)
773                 {
774                         if (is_good_realm(p_ptr->realm1))
775                         {
776                                 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
777                         }
778                         else
779                         {
780                                 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
781                         }
782                 }
783
784                 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
785                 {
786                         s32b tester_exp = p_ptr->max_exp / 20;
787                         if (tester_exp > 10000) tester_exp = 10000;
788                         if (q_ptr->sval < 3) tester_exp /= 4;
789                         if (tester_exp<1) tester_exp = 1;
790
791                         msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
792                         gain_exp(tester_exp * amt);
793                 }
794                 if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
795                 {
796                         chg_virtue(V_UNLIFE, 1);
797                         chg_virtue(V_VITALITY, -1);
798                 }
799                 else if (item_tester_high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
800                 {
801                         chg_virtue(V_UNLIFE, -1);
802                         chg_virtue(V_VITALITY, 1);
803                 }
804         
805                 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
806                         chg_virtue(V_ENCHANT, -1);
807         
808                 if (object_value_real(q_ptr) > 30000)
809                         chg_virtue(V_SACRIFICE, 2);
810         
811                 else if (object_value_real(q_ptr) > 10000)
812                         chg_virtue(V_SACRIFICE, 1);
813         }
814
815         if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
816                 chg_virtue(V_HARMONY, 1);
817
818         if (item >= INVEN_RARM) calc_android_exp();
819 }
820
821
822 /*!
823  * @brief アイテムを調査するコマンドのメインルーチン / Observe an item which has been *identify*-ed
824  * @return なし
825  */
826 void do_cmd_observe(void)
827 {
828         OBJECT_IDX item;
829         object_type *o_ptr;
830         GAME_TEXT o_name[MAX_NLEN];
831         concptr q, s;
832
833         q = _("どのアイテムを調べますか? ", "Examine which item? ");
834         s = _("調べられるアイテムがない。", "You have nothing to examine.");
835
836         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
837         if (!o_ptr) return;
838
839         /* Require full knowledge */
840         if (!(o_ptr->ident & IDENT_MENTAL))
841         {
842                 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
843                 return;
844         }
845
846         object_desc(o_name, o_ptr, 0);
847         msg_format(_("%sを調べている...", "Examining %s..."), o_name);
848         if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
849 }
850
851
852
853 /*!
854  * @brief アイテムの銘を消すコマンドのメインルーチン
855  * Remove the inscription from an object XXX Mention item (when done)?
856  * @return なし
857  */
858 void do_cmd_uninscribe(void)
859 {
860         OBJECT_IDX item;
861         object_type *o_ptr;
862         concptr q, s;
863
864         q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
865         s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
866
867         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
868         if (!o_ptr) return;
869
870         /* Nothing to remove */
871         if (!o_ptr->inscription)
872         {
873                 msg_print(_("このアイテムには消すべき銘がない。", "That item had no inscription to remove."));
874                 return;
875         }
876
877         msg_print(_("銘を消した。", "Inscription removed."));
878
879         /* Remove the incription */
880         o_ptr->inscription = 0;
881         p_ptr->update |= (PU_COMBINE);
882         p_ptr->window |= (PW_INVEN | PW_EQUIP);
883
884         /* .や$の関係で, 再計算が必要なはず -- henkma */
885         p_ptr->update |= (PU_BONUS);
886
887 }
888
889
890 /*!
891  * @brief アイテムの銘を刻むコマンドのメインルーチン
892  * Inscribe an object with a comment
893  * @return なし
894  */
895 void do_cmd_inscribe(void)
896 {
897         OBJECT_IDX item;
898         object_type *o_ptr;
899         GAME_TEXT o_name[MAX_NLEN];
900         char out_val[80];
901         concptr q, s;
902
903         q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
904         s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
905
906         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
907         if (!o_ptr) return;
908
909         /* Describe the activity */
910         object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
911
912         msg_format(_("%sに銘を刻む。", "Inscribing %s."), o_name);
913         msg_print(NULL);
914
915         /* Start with nothing */
916         strcpy(out_val, "");
917
918         /* Use old inscription */
919         if (o_ptr->inscription)
920         {
921                 /* Start with the old inscription */
922                 strcpy(out_val, quark_str(o_ptr->inscription));
923         }
924
925         /* Get a new inscription (possibly empty) */
926         if (get_string(_("銘: ", "Inscription: "), out_val, 80))
927         {
928                 /* Save the inscription */
929                 o_ptr->inscription = quark_add(out_val);
930                 p_ptr->update |= (PU_COMBINE);
931                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
932
933                 /* .や$の関係で, 再計算が必要なはず -- henkma */
934                 p_ptr->update |= (PU_BONUS);
935         }
936 }
937
938
939 /*!
940  * @brief ランタンに燃料を加えるコマンドのメインルーチン
941  * Refill the players lamp (from the pack or floor)
942  * @return なし
943  */
944 static void do_cmd_refill_lamp(void)
945 {
946         OBJECT_IDX item;
947         object_type *o_ptr;
948         object_type *j_ptr;
949         concptr q, s;
950
951         /* Restrict the choices */
952         item_tester_hook = item_tester_refill_lantern;
953
954         q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
955         s = _("油つぼがない。", "You have no flasks of oil.");
956
957         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
958         if (!o_ptr) return;
959
960         p_ptr->energy_use = 50;
961
962         /* Access the lantern */
963         j_ptr = &inventory[INVEN_LITE];
964
965         /* Refuel */
966         j_ptr->xtra4 += o_ptr->xtra4;
967         msg_print(_("ランプに油を注いだ。", "You fuel your lamp."));
968
969         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
970         {
971                 j_ptr->xtra4 = 0;
972                 msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!"));
973         }
974         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
975         {
976                 j_ptr->xtra4 = 0;
977                 msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light."));
978         }
979         else if (j_ptr->xtra4 >= FUEL_LAMP)
980         {
981                 j_ptr->xtra4 = FUEL_LAMP;
982                 msg_print(_("ランプの油は一杯だ。", "Your lamp is full."));
983         }
984
985         /* Decrease the item (from the pack) */
986         if (item >= 0)
987         {
988                 inven_item_increase(item, -1);
989                 inven_item_describe(item);
990                 inven_item_optimize(item);
991         }
992
993         /* Decrease the item (from the floor) */
994         else
995         {
996                 floor_item_increase(0 - item, -1);
997                 floor_item_describe(0 - item);
998                 floor_item_optimize(0 - item);
999         }
1000
1001         /* Recalculate torch */
1002         p_ptr->update |= (PU_TORCH);
1003 }
1004
1005 /*!
1006  * @brief 松明を束ねるコマンドのメインルーチン
1007  * Refuel the players torch (from the pack or floor)
1008  * @return なし
1009  */
1010 static void do_cmd_refill_torch(void)
1011 {
1012         OBJECT_IDX item;
1013
1014         object_type *o_ptr;
1015         object_type *j_ptr;
1016
1017         concptr q, s;
1018
1019         /* Restrict the choices */
1020         item_tester_hook = object_can_refill_torch;
1021
1022         q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1023         s = _("他に松明がない。", "You have no extra torches.");
1024
1025         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1026         if (!o_ptr) return;
1027
1028         p_ptr->energy_use = 50;
1029
1030         /* Access the primary torch */
1031         j_ptr = &inventory[INVEN_LITE];
1032
1033         /* Refuel */
1034         j_ptr->xtra4 += o_ptr->xtra4 + 5;
1035
1036         msg_print(_("松明を結合した。", "You combine the torches."));
1037
1038         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1039         {
1040                 j_ptr->xtra4 = 0;
1041                 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1042         }
1043         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1044         {
1045                 j_ptr->xtra4 = 0;
1046                 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1047         }
1048         /* Over-fuel message */
1049         else if (j_ptr->xtra4 >= FUEL_TORCH)
1050         {
1051                 j_ptr->xtra4 = FUEL_TORCH;
1052                 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1053         }
1054
1055         /* Refuel message */
1056         else
1057         {
1058                 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1059         }
1060
1061         /* Decrease the item (from the pack) */
1062         if (item >= 0)
1063         {
1064                 inven_item_increase(item, -1);
1065                 inven_item_describe(item);
1066                 inven_item_optimize(item);
1067         }
1068
1069         /* Decrease the item (from the floor) */
1070         else
1071         {
1072                 floor_item_increase(0 - item, -1);
1073                 floor_item_describe(0 - item);
1074                 floor_item_optimize(0 - item);
1075         }
1076
1077         /* Recalculate torch */
1078         p_ptr->update |= (PU_TORCH);
1079 }
1080
1081
1082 /*!
1083  * @brief 燃料を補充するコマンドのメインルーチン
1084  * Refill the players lamp, or restock his torches
1085  * @return なし
1086  */
1087 void do_cmd_refill(void)
1088 {
1089         object_type *o_ptr;
1090
1091         /* Get the light */
1092         o_ptr = &inventory[INVEN_LITE];
1093
1094         if (p_ptr->special_defense & KATA_MUSOU)
1095         {
1096                 set_action(ACTION_NONE);
1097         }
1098
1099         /* It is nothing */
1100         if (o_ptr->tval != TV_LITE)
1101         {
1102                 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1103         }
1104
1105         /* It's a lamp */
1106         else if (o_ptr->sval == SV_LITE_LANTERN)
1107         {
1108                 do_cmd_refill_lamp();
1109         }
1110
1111         /* It's a torch */
1112         else if (o_ptr->sval == SV_LITE_TORCH)
1113         {
1114                 do_cmd_refill_torch();
1115         }
1116
1117         /* No torch to refill */
1118         else
1119         {
1120                 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1121         }
1122 }
1123
1124
1125 /*!
1126  * @brief ターゲットを設定するコマンドのメインルーチン
1127  * Target command
1128  * @return なし
1129  */
1130 void do_cmd_target(void)
1131 {
1132         if (p_ptr->wild_mode) return;
1133
1134         /* Target set */
1135         if (target_set(TARGET_KILL))
1136         {
1137                 msg_print(_("ターゲット決定。", "Target Selected."));
1138         }
1139
1140         /* Target aborted */
1141         else
1142         {
1143                 msg_print(_("ターゲット解除。", "Target Aborted."));
1144         }
1145 }
1146
1147
1148
1149 /*!
1150  * @brief 周囲を見渡すコマンドのメインルーチン
1151  * Look command
1152  * @return なし
1153  */
1154 void do_cmd_look(void)
1155 {
1156         p_ptr->window |= PW_MONSTER_LIST;
1157         handle_stuff();
1158
1159         /* Look around */
1160         if (target_set(TARGET_LOOK))
1161         {
1162                 msg_print(_("ターゲット決定。", "Target Selected."));
1163         }
1164 }
1165
1166
1167 /*!
1168  * @brief 位置を確認するコマンドのメインルーチン
1169  * Allow the player to examine other sectors on the map
1170  * @return なし
1171  */
1172 void do_cmd_locate(void)
1173 {
1174         DIRECTION dir;
1175         POSITION y1, x1, y2, x2;
1176         GAME_TEXT tmp_val[80];
1177         GAME_TEXT out_val[160];
1178         TERM_LEN wid, hgt;
1179
1180         get_screen_size(&wid, &hgt);
1181
1182         /* Start at current panel */
1183         y2 = y1 = panel_row_min;
1184         x2 = x1 = panel_col_min;
1185
1186         /* Show panels until done */
1187         while (1)
1188         {
1189                 /* Describe the location */
1190                 if ((y2 == y1) && (x2 == x1))
1191                 {
1192                         strcpy(tmp_val, _("真上", "\0"));
1193                 }
1194                 else
1195                 {
1196                         sprintf(tmp_val, "%s%s",
1197                                 ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
1198                                 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
1199                 }
1200
1201                 /* Prepare to ask which way to look */
1202                 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", 
1203                                                "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?"),
1204                         y2 / (hgt / 2), y2 % (hgt / 2),
1205                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1206
1207                 /* Assume no direction */
1208                 dir = 0;
1209
1210                 /* Get a direction */
1211                 while (!dir)
1212                 {
1213                         char command;
1214
1215                         /* Get a command (or Cancel) */
1216                         if (!get_com(out_val, &command, TRUE)) break;
1217
1218                         /* Extract the action (if any) */
1219                         dir = get_keymap_dir(command);
1220
1221                         /* Error */
1222                         if (!dir) bell();
1223                 }
1224
1225                 /* No direction */
1226                 if (!dir) break;
1227
1228                 /* Apply the motion */
1229                 if (change_panel(ddy[dir], ddx[dir]))
1230                 {
1231                         y2 = panel_row_min;
1232                         x2 = panel_col_min;
1233                 }
1234         }
1235
1236
1237         /* Recenter the map around the player */
1238         verify_panel();
1239
1240         p_ptr->update |= (PU_MONSTERS);
1241         p_ptr->redraw |= (PR_MAP);
1242         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1243         handle_stuff();
1244 }
1245
1246
1247
1248 /*!
1249  * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1250  * Sorting hook -- Comp function -- see below
1251  * @param u モンスター種族情報の入れるポインタ
1252  * @param v 条件基準ID
1253  * @param a 比較するモンスター種族のID1
1254  * @param b 比較するモンスター種族のID2
1255  * @return 2の方が大きければTRUEを返す
1256  * We use "u" to point to array of monster indexes,
1257  * and "v" to select the type of sorting to perform on "u".
1258  */
1259 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1260 {
1261         u16b *who = (u16b*)(u);
1262         u16b *why = (u16b*)(v);
1263
1264         int w1 = who[a];
1265         int w2 = who[b];
1266
1267         int z1, z2;
1268
1269         /* Sort by player kills */
1270         if (*why >= 4)
1271         {
1272                 /* Extract player kills */
1273                 z1 = r_info[w1].r_pkills;
1274                 z2 = r_info[w2].r_pkills;
1275
1276                 /* Compare player kills */
1277                 if (z1 < z2) return (TRUE);
1278                 if (z1 > z2) return (FALSE);
1279         }
1280
1281
1282         /* Sort by total kills */
1283         if (*why >= 3)
1284         {
1285                 /* Extract total kills */
1286                 z1 = r_info[w1].r_tkills;
1287                 z2 = r_info[w2].r_tkills;
1288
1289                 /* Compare total kills */
1290                 if (z1 < z2) return (TRUE);
1291                 if (z1 > z2) return (FALSE);
1292         }
1293
1294
1295         /* Sort by monster level */
1296         if (*why >= 2)
1297         {
1298                 /* Extract levels */
1299                 z1 = r_info[w1].level;
1300                 z2 = r_info[w2].level;
1301
1302                 /* Compare levels */
1303                 if (z1 < z2) return (TRUE);
1304                 if (z1 > z2) return (FALSE);
1305         }
1306
1307
1308         /* Sort by monster experience */
1309         if (*why >= 1)
1310         {
1311                 /* Extract experience */
1312                 z1 = r_info[w1].mexp;
1313                 z2 = r_info[w2].mexp;
1314
1315                 /* Compare experience */
1316                 if (z1 < z2) return (TRUE);
1317                 if (z1 > z2) return (FALSE);
1318         }
1319
1320
1321         /* Compare indexes */
1322         return (w1 <= w2);
1323 }
1324
1325
1326 /*!
1327  * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1328  * Sorting hook -- Swap function -- see below
1329  * @param u モンスター種族情報の入れるポインタ
1330  * @param v 未使用
1331  * @param a スワップするモンスター種族のID1
1332  * @param b スワップするモンスター種族のID2
1333  * @return なし
1334  * @details
1335  * We use "u" to point to array of monster indexes,
1336  * and "v" to select the type of sorting to perform.
1337  */
1338 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1339 {
1340         u16b *who = (u16b*)(u);
1341         u16b holder;
1342
1343         /* Unused */
1344         (void)v;
1345
1346         /* Swap */
1347         holder = who[a];
1348         who[a] = who[b];
1349         who[b] = holder;
1350 }
1351
1352
1353
1354 /*!
1355  * @brief モンスターの思い出を見るコマンドのメインルーチン
1356  * Identify a character, allow recall of monsters
1357  * @return なし
1358  * @details
1359  * <pre>
1360  * Several "special" responses recall "multiple" monsters:
1361  *   ^A (all monsters)
1362  *   ^U (all unique monsters)
1363  *   ^N (all non-unique monsters)
1364  *
1365  * The responses may be sorted in several ways, see below.
1366  *
1367  * Note that the player ghosts are ignored. 
1368  * </pre>
1369  */
1370 void do_cmd_query_symbol(void)
1371 {
1372         IDX i;
1373         int n;
1374         MONRACE_IDX r_idx;
1375         char sym, query;
1376         char buf[128];
1377
1378         bool all = FALSE;
1379         bool uniq = FALSE;
1380         bool norm = FALSE;
1381         bool ride = FALSE;
1382         char temp[80] = "";
1383
1384         bool recall = FALSE;
1385
1386         u16b why = 0;
1387         MONRACE_IDX *who;
1388
1389         /* Get a character, or abort */
1390         if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", 
1391                                    "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1392
1393         /* Find that character info, and describe it */
1394         for (i = 0; ident_info[i]; ++i)
1395         {
1396                 if (sym == ident_info[i][0]) break;
1397         }
1398         if (sym == KTRL('A'))
1399         {
1400                 all = TRUE;
1401                 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1402         }
1403         else if (sym == KTRL('U'))
1404         {
1405                 all = uniq = TRUE;
1406                 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1407         }
1408         else if (sym == KTRL('N'))
1409         {
1410                 all = norm = TRUE;
1411                 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1412         }
1413         else if (sym == KTRL('R'))
1414         {
1415                 all = ride = TRUE;
1416                 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1417         }
1418         /* XTRA HACK WHATSEARCH */
1419         else if (sym == KTRL('M'))
1420         {
1421                 all = TRUE;
1422                 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1423                 {
1424                         temp[0]=0;
1425                         return;
1426                 }
1427                 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1428         }
1429         else if (ident_info[i])
1430         {
1431                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1432         }
1433         else
1434         {
1435                 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1436         }
1437
1438         /* Display the result */
1439         prt(buf, 0, 0);
1440
1441         /* Allocate the "who" array */
1442         C_MAKE(who, max_r_idx, MONRACE_IDX);
1443
1444         /* Collect matching monsters */
1445         for (n = 0, i = 1; i < max_r_idx; i++)
1446         {
1447                 monster_race *r_ptr = &r_info[i];
1448
1449                 /* Nothing to recall */
1450                 if (!cheat_know && !r_ptr->r_sights) continue;
1451
1452                 /* Require non-unique monsters if needed */
1453                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1454
1455                 /* Require unique monsters if needed */
1456                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1457
1458                 /* Require ridable monsters if needed */
1459                 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1460
1461                 /* XTRA HACK WHATSEARCH */
1462                 if (temp[0])
1463                 {
1464                         TERM_LEN xx;
1465                         char temp2[80];
1466
1467                         for (xx = 0; temp[xx] && xx < 80; xx++)
1468                         {
1469 #ifdef JP
1470                                 if (iskanji(temp[xx])) { xx++; continue; }
1471 #endif
1472                                 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1473                         }
1474
1475 #ifdef JP
1476                         strcpy(temp2, r_name + r_ptr->E_name);
1477 #else
1478                         strcpy(temp2, r_name + r_ptr->name);
1479 #endif
1480                         for (xx = 0; temp2[xx] && xx < 80; xx++)
1481                                 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1482
1483 #ifdef JP
1484                         if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1485 #else
1486                         if (my_strstr(temp2, temp))
1487 #endif
1488                                 who[n++] = i;
1489                 }
1490
1491                 /* Collect "appropriate" monsters */
1492                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1493         }
1494
1495         /* Nothing to recall */
1496         if (!n)
1497         {
1498                 /* Free the "who" array */
1499                 C_KILL(who, max_r_idx, IDX);
1500
1501                 return;
1502         }
1503
1504         /* Prompt */
1505         put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1506
1507         /* Query */
1508         query = inkey();
1509         prt(buf, 0, 0);
1510
1511         why = 2;
1512
1513         /* Select the sort method */
1514         ang_sort_comp = ang_sort_comp_hook;
1515         ang_sort_swap = ang_sort_swap_hook;
1516
1517         /* Sort the array */
1518         ang_sort(who, &why, n);
1519
1520         /* Sort by kills (and level) */
1521         if (query == 'k')
1522         {
1523                 why = 4;
1524                 query = 'y';
1525         }
1526
1527         /* Catch "escape" */
1528         if (query != 'y')
1529         {
1530                 /* Free the "who" array */
1531                 C_KILL(who, max_r_idx, IDX);
1532
1533                 return;
1534         }
1535
1536         /* Sort if needed */
1537         if (why == 4)
1538         {
1539                 /* Select the sort method */
1540                 ang_sort_comp = ang_sort_comp_hook;
1541                 ang_sort_swap = ang_sort_swap_hook;
1542
1543                 /* Sort the array */
1544                 ang_sort(who, &why, n);
1545         }
1546
1547
1548         /* Start at the end */
1549         i = n - 1;
1550
1551         /* Scan the monster memory */
1552         while (1)
1553         {
1554                 /* Extract a race */
1555                 r_idx = who[i];
1556
1557                 /* Hack -- Auto-recall */
1558                 monster_race_track(r_idx);
1559                 handle_stuff();
1560
1561                 /* Interact */
1562                 while (1)
1563                 {
1564                         /* Recall */
1565                         if (recall)
1566                         {
1567                                 screen_save();
1568
1569                                 /* Recall on screen */
1570                                 screen_roff(who[i], 0);
1571                         }
1572
1573                         /* Hack -- Begin the prompt */
1574                         roff_top(r_idx);
1575
1576                         /* Hack -- Complete the prompt */
1577                         Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1578
1579                         /* Command */
1580                         query = inkey();
1581
1582                         /* Unrecall */
1583                         if (recall)
1584                         {
1585                                 screen_load();
1586                         }
1587
1588                         /* Normal commands */
1589                         if (query != 'r') break;
1590
1591                         /* Toggle recall */
1592                         recall = !recall;
1593                 }
1594
1595                 /* Stop scanning */
1596                 if (query == ESCAPE) break;
1597
1598                 /* Move to "prev" monster */
1599                 if (query == '-')
1600                 {
1601                         if (++i == n)
1602                         {
1603                                 i = 0;
1604                                 if (!expand_list) break;
1605                         }
1606                 }
1607
1608                 /* Move to "next" monster */
1609                 else
1610                 {
1611                         if (i-- == 0)
1612                         {
1613                                 i = n - 1;
1614                                 if (!expand_list) break;
1615                         }
1616                 }
1617         }
1618
1619         /* Free the "who" array */
1620         C_KILL(who, max_r_idx, IDX);
1621
1622         /* Re-display the identity */
1623         prt(buf, 0, 0);
1624 }
1625
1626 /*!
1627  * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1628  * Use an item
1629  * @return なし
1630  * @details
1631  * XXX - Add actions for other item types
1632  */
1633 void do_cmd_use(void)
1634 {
1635         OBJECT_IDX item;
1636         object_type *o_ptr;
1637         concptr q, s;
1638
1639         if (p_ptr->wild_mode)
1640         {
1641                 return;
1642         }
1643
1644         if (cmd_limit_arena(p_ptr)) return;
1645
1646         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1647         {
1648                 set_action(ACTION_NONE);
1649         }
1650
1651         item_tester_hook = item_tester_hook_use;
1652
1653         q = _("どれを使いますか?", "Use which item? ");
1654         s = _("使えるものがありません。", "You have nothing to use.");
1655
1656         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1657         if (!o_ptr) return;
1658
1659         switch (o_ptr->tval)
1660         {
1661                 /* Spike a door */
1662                 case TV_SPIKE:
1663                 {
1664                         do_cmd_spike();
1665                         break;
1666                 }
1667
1668                 /* Eat some food */
1669                 case TV_FOOD:
1670                 {
1671                         do_cmd_eat_food_aux(item);
1672                         break;
1673                 }
1674
1675                 /* Aim a wand */
1676                 case TV_WAND:
1677                 {
1678                         do_cmd_aim_wand_aux(item);
1679                         break;
1680                 }
1681
1682                 /* Use a staff */
1683                 case TV_STAFF:
1684                 {
1685                         do_cmd_use_staff_aux(item);
1686                         break;
1687                 }
1688
1689                 /* Zap a rod */
1690                 case TV_ROD:
1691                 {
1692                         do_cmd_zap_rod_aux(item);
1693                         break;
1694                 }
1695
1696                 /* Quaff a potion */
1697                 case TV_POTION:
1698                 {
1699                         do_cmd_quaff_potion_aux(item);
1700                         break;
1701                 }
1702
1703                 /* Read a scroll */
1704                 case TV_SCROLL:
1705                 {
1706                         if (cmd_limit_blind(p_ptr)) return;
1707                         if (cmd_limit_confused(p_ptr)) return;
1708
1709                         do_cmd_read_scroll_aux(item, TRUE);
1710                         break;
1711                 }
1712
1713                 /* Fire ammo */
1714                 case TV_SHOT:
1715                 case TV_ARROW:
1716                 case TV_BOLT:
1717                 {
1718                         exe_fire(item, &inventory[INVEN_BOW]);
1719                         break;
1720                 }
1721
1722                 /* Activate an artifact */
1723                 default:
1724                 {
1725                         do_cmd_activate_aux(item);
1726                         break;
1727                 }
1728         }
1729 }
1730