OSDN Git Service

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