OSDN Git Service

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