OSDN Git Service

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