OSDN Git Service

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