OSDN Git Service

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