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