OSDN Git Service

[Refactor] #37353 メッセージ整理。 / Refactor messages. (do_cmd_wield())
[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 /*!
1007  * @brief オブジェクトが松明に束ねられるかどうかを判定する
1008  * An "item_tester_hook" for refilling torches
1009  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
1010  * @return オブジェクトが松明に束ねられるならばTRUEを返す
1011  */
1012 static bool item_tester_refill_torch(object_type *o_ptr)
1013 {
1014         /* Torches are okay */
1015         if ((o_ptr->tval == TV_LITE) &&
1016             (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1017
1018         /* Assume not okay */
1019         return (FALSE);
1020 }
1021
1022
1023 /*!
1024  * @brief 松明を束ねるコマンドのメインルーチン
1025  * Refuel the players torch (from the pack or floor)
1026  * @return なし
1027  */
1028 static void do_cmd_refill_torch(void)
1029 {
1030         OBJECT_IDX item;
1031
1032         object_type *o_ptr;
1033         object_type *j_ptr;
1034
1035         concptr q, s;
1036
1037         /* Restrict the choices */
1038         item_tester_hook = item_tester_refill_torch;
1039
1040         q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1041         s = _("他に松明がない。", "You have no extra torches.");
1042
1043         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1044         if (!o_ptr) return;
1045
1046         p_ptr->energy_use = 50;
1047
1048         /* Access the primary torch */
1049         j_ptr = &inventory[INVEN_LITE];
1050
1051         /* Refuel */
1052         j_ptr->xtra4 += o_ptr->xtra4 + 5;
1053
1054         msg_print(_("松明を結合した。", "You combine the torches."));
1055
1056         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1057         {
1058                 j_ptr->xtra4 = 0;
1059                 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1060         }
1061         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1062         {
1063                 j_ptr->xtra4 = 0;
1064                 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1065         }
1066         /* Over-fuel message */
1067         else if (j_ptr->xtra4 >= FUEL_TORCH)
1068         {
1069                 j_ptr->xtra4 = FUEL_TORCH;
1070                 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1071         }
1072
1073         /* Refuel message */
1074         else
1075         {
1076                 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1077         }
1078
1079         /* Decrease the item (from the pack) */
1080         if (item >= 0)
1081         {
1082                 inven_item_increase(item, -1);
1083                 inven_item_describe(item);
1084                 inven_item_optimize(item);
1085         }
1086
1087         /* Decrease the item (from the floor) */
1088         else
1089         {
1090                 floor_item_increase(0 - item, -1);
1091                 floor_item_describe(0 - item);
1092                 floor_item_optimize(0 - item);
1093         }
1094
1095         /* Recalculate torch */
1096         p_ptr->update |= (PU_TORCH);
1097 }
1098
1099
1100 /*!
1101  * @brief 燃料を補充するコマンドのメインルーチン
1102  * Refill the players lamp, or restock his torches
1103  * @return なし
1104  */
1105 void do_cmd_refill(void)
1106 {
1107         object_type *o_ptr;
1108
1109         /* Get the light */
1110         o_ptr = &inventory[INVEN_LITE];
1111
1112         if (p_ptr->special_defense & KATA_MUSOU)
1113         {
1114                 set_action(ACTION_NONE);
1115         }
1116
1117         /* It is nothing */
1118         if (o_ptr->tval != TV_LITE)
1119         {
1120                 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1121         }
1122
1123         /* It's a lamp */
1124         else if (o_ptr->sval == SV_LITE_LANTERN)
1125         {
1126                 do_cmd_refill_lamp();
1127         }
1128
1129         /* It's a torch */
1130         else if (o_ptr->sval == SV_LITE_TORCH)
1131         {
1132                 do_cmd_refill_torch();
1133         }
1134
1135         /* No torch to refill */
1136         else
1137         {
1138                 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1139         }
1140 }
1141
1142
1143 /*!
1144  * @brief ターゲットを設定するコマンドのメインルーチン
1145  * Target command
1146  * @return なし
1147  */
1148 void do_cmd_target(void)
1149 {
1150         if (p_ptr->wild_mode) return;
1151
1152         /* Target set */
1153         if (target_set(TARGET_KILL))
1154         {
1155                 msg_print(_("ターゲット決定。", "Target Selected."));
1156         }
1157
1158         /* Target aborted */
1159         else
1160         {
1161                 msg_print(_("ターゲット解除。", "Target Aborted."));
1162         }
1163 }
1164
1165
1166
1167 /*!
1168  * @brief 周囲を見渡すコマンドのメインルーチン
1169  * Look command
1170  * @return なし
1171  */
1172 void do_cmd_look(void)
1173 {
1174         p_ptr->window |= PW_MONSTER_LIST;
1175         handle_stuff();
1176
1177         /* Look around */
1178         if (target_set(TARGET_LOOK))
1179         {
1180                 msg_print(_("ターゲット決定。", "Target Selected."));
1181         }
1182 }
1183
1184
1185 /*!
1186  * @brief 位置を確認するコマンドのメインルーチン
1187  * Allow the player to examine other sectors on the map
1188  * @return なし
1189  */
1190 void do_cmd_locate(void)
1191 {
1192         DIRECTION dir;
1193         POSITION y1, x1, y2, x2;
1194         GAME_TEXT tmp_val[80];
1195         GAME_TEXT out_val[160];
1196         TERM_LEN wid, hgt;
1197
1198         get_screen_size(&wid, &hgt);
1199
1200         /* Start at current panel */
1201         y2 = y1 = panel_row_min;
1202         x2 = x1 = panel_col_min;
1203
1204         /* Show panels until done */
1205         while (1)
1206         {
1207                 /* Describe the location */
1208                 if ((y2 == y1) && (x2 == x1))
1209                 {
1210                         strcpy(tmp_val, _("真上", "\0"));
1211                 }
1212                 else
1213                 {
1214                         sprintf(tmp_val, "%s%s",
1215                                 ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
1216                                 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
1217                 }
1218
1219                 /* Prepare to ask which way to look */
1220                 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", 
1221                                                "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?"),
1222                         y2 / (hgt / 2), y2 % (hgt / 2),
1223                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1224
1225                 /* Assume no direction */
1226                 dir = 0;
1227
1228                 /* Get a direction */
1229                 while (!dir)
1230                 {
1231                         char command;
1232
1233                         /* Get a command (or Cancel) */
1234                         if (!get_com(out_val, &command, TRUE)) break;
1235
1236                         /* Extract the action (if any) */
1237                         dir = get_keymap_dir(command);
1238
1239                         /* Error */
1240                         if (!dir) bell();
1241                 }
1242
1243                 /* No direction */
1244                 if (!dir) break;
1245
1246                 /* Apply the motion */
1247                 if (change_panel(ddy[dir], ddx[dir]))
1248                 {
1249                         y2 = panel_row_min;
1250                         x2 = panel_col_min;
1251                 }
1252         }
1253
1254
1255         /* Recenter the map around the player */
1256         verify_panel();
1257
1258         p_ptr->update |= (PU_MONSTERS);
1259         p_ptr->redraw |= (PR_MAP);
1260         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1261         handle_stuff();
1262 }
1263
1264
1265
1266 /*!
1267  * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1268  * Sorting hook -- Comp function -- see below
1269  * @param u モンスター種族情報の入れるポインタ
1270  * @param v 条件基準ID
1271  * @param a 比較するモンスター種族のID1
1272  * @param b 比較するモンスター種族のID2
1273  * @return 2の方が大きければTRUEを返す
1274  * We use "u" to point to array of monster indexes,
1275  * and "v" to select the type of sorting to perform on "u".
1276  */
1277 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1278 {
1279         u16b *who = (u16b*)(u);
1280         u16b *why = (u16b*)(v);
1281
1282         int w1 = who[a];
1283         int w2 = who[b];
1284
1285         int z1, z2;
1286
1287         /* Sort by player kills */
1288         if (*why >= 4)
1289         {
1290                 /* Extract player kills */
1291                 z1 = r_info[w1].r_pkills;
1292                 z2 = r_info[w2].r_pkills;
1293
1294                 /* Compare player kills */
1295                 if (z1 < z2) return (TRUE);
1296                 if (z1 > z2) return (FALSE);
1297         }
1298
1299
1300         /* Sort by total kills */
1301         if (*why >= 3)
1302         {
1303                 /* Extract total kills */
1304                 z1 = r_info[w1].r_tkills;
1305                 z2 = r_info[w2].r_tkills;
1306
1307                 /* Compare total kills */
1308                 if (z1 < z2) return (TRUE);
1309                 if (z1 > z2) return (FALSE);
1310         }
1311
1312
1313         /* Sort by monster level */
1314         if (*why >= 2)
1315         {
1316                 /* Extract levels */
1317                 z1 = r_info[w1].level;
1318                 z2 = r_info[w2].level;
1319
1320                 /* Compare levels */
1321                 if (z1 < z2) return (TRUE);
1322                 if (z1 > z2) return (FALSE);
1323         }
1324
1325
1326         /* Sort by monster experience */
1327         if (*why >= 1)
1328         {
1329                 /* Extract experience */
1330                 z1 = r_info[w1].mexp;
1331                 z2 = r_info[w2].mexp;
1332
1333                 /* Compare experience */
1334                 if (z1 < z2) return (TRUE);
1335                 if (z1 > z2) return (FALSE);
1336         }
1337
1338
1339         /* Compare indexes */
1340         return (w1 <= w2);
1341 }
1342
1343
1344 /*!
1345  * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1346  * Sorting hook -- Swap function -- see below
1347  * @param u モンスター種族情報の入れるポインタ
1348  * @param v 未使用
1349  * @param a スワップするモンスター種族のID1
1350  * @param b スワップするモンスター種族のID2
1351  * @return なし
1352  * @details
1353  * We use "u" to point to array of monster indexes,
1354  * and "v" to select the type of sorting to perform.
1355  */
1356 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1357 {
1358         u16b *who = (u16b*)(u);
1359         u16b holder;
1360
1361         /* Unused */
1362         (void)v;
1363
1364         /* Swap */
1365         holder = who[a];
1366         who[a] = who[b];
1367         who[b] = holder;
1368 }
1369
1370
1371
1372 /*!
1373  * @brief モンスターの思い出を見るコマンドのメインルーチン
1374  * Identify a character, allow recall of monsters
1375  * @return なし
1376  * @details
1377  * <pre>
1378  * Several "special" responses recall "multiple" monsters:
1379  *   ^A (all monsters)
1380  *   ^U (all unique monsters)
1381  *   ^N (all non-unique monsters)
1382  *
1383  * The responses may be sorted in several ways, see below.
1384  *
1385  * Note that the player ghosts are ignored. 
1386  * </pre>
1387  */
1388 void do_cmd_query_symbol(void)
1389 {
1390         IDX i;
1391         int n;
1392         MONRACE_IDX r_idx;
1393         char sym, query;
1394         char buf[128];
1395
1396         bool all = FALSE;
1397         bool uniq = FALSE;
1398         bool norm = FALSE;
1399         bool ride = FALSE;
1400         char temp[80] = "";
1401
1402         bool recall = FALSE;
1403
1404         u16b why = 0;
1405         MONRACE_IDX *who;
1406
1407         /* Get a character, or abort */
1408         if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", 
1409                                    "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1410
1411         /* Find that character info, and describe it */
1412         for (i = 0; ident_info[i]; ++i)
1413         {
1414                 if (sym == ident_info[i][0]) break;
1415         }
1416         if (sym == KTRL('A'))
1417         {
1418                 all = TRUE;
1419                 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1420         }
1421         else if (sym == KTRL('U'))
1422         {
1423                 all = uniq = TRUE;
1424                 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1425         }
1426         else if (sym == KTRL('N'))
1427         {
1428                 all = norm = TRUE;
1429                 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1430         }
1431         else if (sym == KTRL('R'))
1432         {
1433                 all = ride = TRUE;
1434                 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1435         }
1436         /* XTRA HACK WHATSEARCH */
1437         else if (sym == KTRL('M'))
1438         {
1439                 all = TRUE;
1440                 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1441                 {
1442                         temp[0]=0;
1443                         return;
1444                 }
1445                 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1446         }
1447         else if (ident_info[i])
1448         {
1449                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1450         }
1451         else
1452         {
1453                 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1454         }
1455
1456         /* Display the result */
1457         prt(buf, 0, 0);
1458
1459         /* Allocate the "who" array */
1460         C_MAKE(who, max_r_idx, MONRACE_IDX);
1461
1462         /* Collect matching monsters */
1463         for (n = 0, i = 1; i < max_r_idx; i++)
1464         {
1465                 monster_race *r_ptr = &r_info[i];
1466
1467                 /* Nothing to recall */
1468                 if (!cheat_know && !r_ptr->r_sights) continue;
1469
1470                 /* Require non-unique monsters if needed */
1471                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1472
1473                 /* Require unique monsters if needed */
1474                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1475
1476                 /* Require ridable monsters if needed */
1477                 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1478
1479                 /* XTRA HACK WHATSEARCH */
1480                 if (temp[0])
1481                 {
1482                         TERM_LEN xx;
1483                         char temp2[80];
1484
1485                         for (xx = 0; temp[xx] && xx < 80; xx++)
1486                         {
1487 #ifdef JP
1488                                 if (iskanji(temp[xx])) { xx++; continue; }
1489 #endif
1490                                 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1491                         }
1492
1493 #ifdef JP
1494                         strcpy(temp2, r_name + r_ptr->E_name);
1495 #else
1496                         strcpy(temp2, r_name + r_ptr->name);
1497 #endif
1498                         for (xx = 0; temp2[xx] && xx < 80; xx++)
1499                                 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1500
1501 #ifdef JP
1502                         if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1503 #else
1504                         if (my_strstr(temp2, temp))
1505 #endif
1506                                 who[n++] = i;
1507                 }
1508
1509                 /* Collect "appropriate" monsters */
1510                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1511         }
1512
1513         /* Nothing to recall */
1514         if (!n)
1515         {
1516                 /* Free the "who" array */
1517                 C_KILL(who, max_r_idx, IDX);
1518
1519                 return;
1520         }
1521
1522         /* Prompt */
1523         put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1524
1525         /* Query */
1526         query = inkey();
1527         prt(buf, 0, 0);
1528
1529         why = 2;
1530
1531         /* Select the sort method */
1532         ang_sort_comp = ang_sort_comp_hook;
1533         ang_sort_swap = ang_sort_swap_hook;
1534
1535         /* Sort the array */
1536         ang_sort(who, &why, n);
1537
1538         /* Sort by kills (and level) */
1539         if (query == 'k')
1540         {
1541                 why = 4;
1542                 query = 'y';
1543         }
1544
1545         /* Catch "escape" */
1546         if (query != 'y')
1547         {
1548                 /* Free the "who" array */
1549                 C_KILL(who, max_r_idx, IDX);
1550
1551                 return;
1552         }
1553
1554         /* Sort if needed */
1555         if (why == 4)
1556         {
1557                 /* Select the sort method */
1558                 ang_sort_comp = ang_sort_comp_hook;
1559                 ang_sort_swap = ang_sort_swap_hook;
1560
1561                 /* Sort the array */
1562                 ang_sort(who, &why, n);
1563         }
1564
1565
1566         /* Start at the end */
1567         i = n - 1;
1568
1569         /* Scan the monster memory */
1570         while (1)
1571         {
1572                 /* Extract a race */
1573                 r_idx = who[i];
1574
1575                 /* Hack -- Auto-recall */
1576                 monster_race_track(r_idx);
1577                 handle_stuff();
1578
1579                 /* Interact */
1580                 while (1)
1581                 {
1582                         /* Recall */
1583                         if (recall)
1584                         {
1585                                 screen_save();
1586
1587                                 /* Recall on screen */
1588                                 screen_roff(who[i], 0);
1589                         }
1590
1591                         /* Hack -- Begin the prompt */
1592                         roff_top(r_idx);
1593
1594                         /* Hack -- Complete the prompt */
1595                         Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1596
1597                         /* Command */
1598                         query = inkey();
1599
1600                         /* Unrecall */
1601                         if (recall)
1602                         {
1603                                 screen_load();
1604                         }
1605
1606                         /* Normal commands */
1607                         if (query != 'r') break;
1608
1609                         /* Toggle recall */
1610                         recall = !recall;
1611                 }
1612
1613                 /* Stop scanning */
1614                 if (query == ESCAPE) break;
1615
1616                 /* Move to "prev" monster */
1617                 if (query == '-')
1618                 {
1619                         if (++i == n)
1620                         {
1621                                 i = 0;
1622                                 if (!expand_list) break;
1623                         }
1624                 }
1625
1626                 /* Move to "next" monster */
1627                 else
1628                 {
1629                         if (i-- == 0)
1630                         {
1631                                 i = n - 1;
1632                                 if (!expand_list) break;
1633                         }
1634                 }
1635         }
1636
1637         /* Free the "who" array */
1638         C_KILL(who, max_r_idx, IDX);
1639
1640         /* Re-display the identity */
1641         prt(buf, 0, 0);
1642 }
1643
1644 /*!
1645  * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1646  * Use an item
1647  * @return なし
1648  * @details
1649  * XXX - Add actions for other item types
1650  */
1651 void do_cmd_use(void)
1652 {
1653         OBJECT_IDX item;
1654         object_type *o_ptr;
1655         concptr q, s;
1656
1657         if (p_ptr->wild_mode)
1658         {
1659                 return;
1660         }
1661
1662         if (cmd_limit_arena(p_ptr)) return;
1663
1664         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1665         {
1666                 set_action(ACTION_NONE);
1667         }
1668
1669         item_tester_hook = item_tester_hook_use;
1670
1671         q = _("どれを使いますか?", "Use which item? ");
1672         s = _("使えるものがありません。", "You have nothing to use.");
1673
1674         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1675         if (!o_ptr) return;
1676
1677         switch (o_ptr->tval)
1678         {
1679                 /* Spike a door */
1680                 case TV_SPIKE:
1681                 {
1682                         do_cmd_spike();
1683                         break;
1684                 }
1685
1686                 /* Eat some food */
1687                 case TV_FOOD:
1688                 {
1689                         do_cmd_eat_food_aux(item);
1690                         break;
1691                 }
1692
1693                 /* Aim a wand */
1694                 case TV_WAND:
1695                 {
1696                         do_cmd_aim_wand_aux(item);
1697                         break;
1698                 }
1699
1700                 /* Use a staff */
1701                 case TV_STAFF:
1702                 {
1703                         do_cmd_use_staff_aux(item);
1704                         break;
1705                 }
1706
1707                 /* Zap a rod */
1708                 case TV_ROD:
1709                 {
1710                         do_cmd_zap_rod_aux(item);
1711                         break;
1712                 }
1713
1714                 /* Quaff a potion */
1715                 case TV_POTION:
1716                 {
1717                         do_cmd_quaff_potion_aux(item);
1718                         break;
1719                 }
1720
1721                 /* Read a scroll */
1722                 case TV_SCROLL:
1723                 {
1724                         if (cmd_limit_blind(p_ptr)) return;
1725                         if (cmd_limit_confused(p_ptr)) return;
1726
1727                         do_cmd_read_scroll_aux(item, TRUE);
1728                         break;
1729                 }
1730
1731                 /* Fire ammo */
1732                 case TV_SHOT:
1733                 case TV_ARROW:
1734                 case TV_BOLT:
1735                 {
1736                         exe_fire(item, &inventory[INVEN_BOW]);
1737                         break;
1738                 }
1739
1740                 /* Activate an artifact */
1741                 default:
1742                 {
1743                         do_cmd_activate_aux(item);
1744                         break;
1745                 }
1746         }
1747 }
1748