OSDN Git Service

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