OSDN Git Service

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