OSDN Git Service

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