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