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