OSDN Git Service

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