OSDN Git Service

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